diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0803bf5c..22959e57 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,15 @@ { "name": "Octokit.Webhooks", - "image": "mcr.microsoft.com/devcontainers/dotnet:7.0", + "image": "mcr.microsoft.com/devcontainers/dotnet:dev-8.0", "postCreateCommand": "dotnet restore", + "features": { + "ghcr.io/devcontainers/features/dotnet": { + "dotnetRuntimeVersions": "6.0" + } + }, "customizations": { "vscode": { - "extensions": [ - "ms-dotnettools.csdevkit" - ] + "extensions": ["ms-dotnettools.csdevkit"] } } } diff --git a/global.json b/global.json index eabcf0f3..3cb3d541 100644 --- a/global.json +++ b/global.json @@ -2,6 +2,6 @@ "sdk": { "rollForward": "latestFeature", "allowPrerelease": false, - "version": "7.0.404" + "version": "8.0.100" } } diff --git a/samples/AspNetCore/MyWebhookEventProcessor.cs b/samples/AspNetCore/MyWebhookEventProcessor.cs index 26cdbb07..866e8765 100644 --- a/samples/AspNetCore/MyWebhookEventProcessor.cs +++ b/samples/AspNetCore/MyWebhookEventProcessor.cs @@ -6,22 +6,18 @@ using Octokit.Webhooks.Events; using Octokit.Webhooks.Events.PullRequest; -public class MyWebhookEventProcessor : WebhookEventProcessor +public class MyWebhookEventProcessor(ILogger logger) : WebhookEventProcessor { - private readonly ILogger logger; - - public MyWebhookEventProcessor(ILogger logger) => this.logger = logger; - protected override async Task ProcessPullRequestWebhookAsync(WebhookHeaders headers, PullRequestEvent pullRequestEvent, PullRequestAction action) { switch (action) { case PullRequestActionValue.Opened: - this.logger.LogInformation("pull request opened"); + logger.LogInformation("pull request opened"); await Task.Delay(1000); break; default: - this.logger.LogInformation("Some other pull request event"); + logger.LogInformation("Some other pull request event"); await Task.Delay(1000); break; } diff --git a/samples/AzureFunctions/MyWebhookEventProcessor.cs b/samples/AzureFunctions/MyWebhookEventProcessor.cs index c427cc22..1e0f21d5 100644 --- a/samples/AzureFunctions/MyWebhookEventProcessor.cs +++ b/samples/AzureFunctions/MyWebhookEventProcessor.cs @@ -6,25 +6,18 @@ namespace AzureFunctions; using Octokit.Webhooks.Events; using Octokit.Webhooks.Events.PullRequest; -public class MyWebhookEventProcessor : WebhookEventProcessor +public class MyWebhookEventProcessor(ILogger logger) : WebhookEventProcessor { - private readonly ILogger logger; - - public MyWebhookEventProcessor(ILogger logger) - { - this.logger = logger; - } - protected override async Task ProcessPullRequestWebhookAsync(WebhookHeaders headers, PullRequestEvent pullRequestEvent, PullRequestAction action) { switch (action) { case PullRequestActionValue.Opened: - this.logger.LogInformation("pull request opened"); + logger.LogInformation("pull request opened"); await Task.Delay(1000); break; default: - this.logger.LogInformation("Some other pull request event"); + logger.LogInformation("Some other pull request event"); await Task.Delay(1000); break; } diff --git a/src/Octokit.Webhooks.AzureFunctions/GitHubWebhooksHttpFunction.cs b/src/Octokit.Webhooks.AzureFunctions/GitHubWebhooksHttpFunction.cs index 6536e6d3..aca97b20 100644 --- a/src/Octokit.Webhooks.AzureFunctions/GitHubWebhooksHttpFunction.cs +++ b/src/Octokit.Webhooks.AzureFunctions/GitHubWebhooksHttpFunction.cs @@ -19,12 +19,8 @@ namespace Octokit.Webhooks.AzureFunctions; /// /// A class containing an Azure Function that processes GitHub webhooks. /// -public sealed partial class GitHubWebhooksHttpFunction +public sealed partial class GitHubWebhooksHttpFunction(IOptions options) { - private readonly IOptions options; - - public GitHubWebhooksHttpFunction(IOptions options) => this.options = options; - [Function(nameof(MapGitHubWebhooksAsync))] public async Task MapGitHubWebhooksAsync( [HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = "github/webhooks")] HttpRequestData req, @@ -43,7 +39,7 @@ public sealed partial class GitHubWebhooksHttpFunction var body = await GetBodyAsync(req).ConfigureAwait(false); // Verify signature - if (!VerifySignature(req, this.options.Value.Secret, body)) + if (!VerifySignature(req, options.Value.Secret, body)) { Log.SignatureValidationFailed(logger); return req.CreateResponse(HttpStatusCode.BadRequest); diff --git a/src/Octokit.Webhooks/Octokit.Webhooks.csproj b/src/Octokit.Webhooks/Octokit.Webhooks.csproj index cd548d1f..4985643f 100644 --- a/src/Octokit.Webhooks/Octokit.Webhooks.csproj +++ b/src/Octokit.Webhooks/Octokit.Webhooks.csproj @@ -16,6 +16,4 @@ - - diff --git a/src/Octokit.Webhooks/WebhookActionTypeAttribute.cs b/src/Octokit.Webhooks/WebhookActionTypeAttribute.cs index 3c9c31ec..8d6b6e49 100644 --- a/src/Octokit.Webhooks/WebhookActionTypeAttribute.cs +++ b/src/Octokit.Webhooks/WebhookActionTypeAttribute.cs @@ -1,9 +1,7 @@ namespace Octokit.Webhooks; [AttributeUsage(AttributeTargets.Class)] -internal sealed class WebhookActionTypeAttribute : Attribute +internal sealed class WebhookActionTypeAttribute(string actionType) : Attribute { - public WebhookActionTypeAttribute(string actionType) => this.ActionType = actionType; - - public string ActionType { get; } + public string ActionType { get; } = actionType; } diff --git a/src/Octokit.Webhooks/WebhookEventTypeAttribute.cs b/src/Octokit.Webhooks/WebhookEventTypeAttribute.cs index 422555cc..8bad626b 100644 --- a/src/Octokit.Webhooks/WebhookEventTypeAttribute.cs +++ b/src/Octokit.Webhooks/WebhookEventTypeAttribute.cs @@ -1,9 +1,7 @@ namespace Octokit.Webhooks; [AttributeUsage(AttributeTargets.Class)] -internal sealed class WebhookEventTypeAttribute : Attribute +internal sealed class WebhookEventTypeAttribute(string eventType) : Attribute { - public WebhookEventTypeAttribute(string eventType) => this.EventType = eventType; - - public string EventType { get; } + public string EventType { get; } = eventType; }