Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): upgrade to .net 8 sdk #393

Merged
merged 5 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
}
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sdk": {
"rollForward": "latestFeature",
"allowPrerelease": false,
"version": "7.0.404"
"version": "8.0.100"
}
}
10 changes: 3 additions & 7 deletions samples/AspNetCore/MyWebhookEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@
using Octokit.Webhooks.Events;
using Octokit.Webhooks.Events.PullRequest;

public class MyWebhookEventProcessor : WebhookEventProcessor
public class MyWebhookEventProcessor(ILogger<MyWebhookEventProcessor> logger) : WebhookEventProcessor
JamieMagee marked this conversation as resolved.
Show resolved Hide resolved
{
private readonly ILogger<MyWebhookEventProcessor> logger;

public MyWebhookEventProcessor(ILogger<MyWebhookEventProcessor> 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;
}
Expand Down
13 changes: 3 additions & 10 deletions samples/AzureFunctions/MyWebhookEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,18 @@ namespace AzureFunctions;
using Octokit.Webhooks.Events;
using Octokit.Webhooks.Events.PullRequest;

public class MyWebhookEventProcessor : WebhookEventProcessor
public class MyWebhookEventProcessor(ILogger<MyWebhookEventProcessor> logger) : WebhookEventProcessor
{
private readonly ILogger<MyWebhookEventProcessor> logger;

public MyWebhookEventProcessor(ILogger<MyWebhookEventProcessor> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ namespace Octokit.Webhooks.AzureFunctions;
/// <summary>
/// A class containing an Azure Function that processes GitHub webhooks.
/// </summary>
public sealed partial class GitHubWebhooksHttpFunction
public sealed partial class GitHubWebhooksHttpFunction(IOptions<GitHubWebhooksOptions> options)
{
private readonly IOptions<GitHubWebhooksOptions> options;

public GitHubWebhooksHttpFunction(IOptions<GitHubWebhooksOptions> options) => this.options = options;

[Function(nameof(MapGitHubWebhooksAsync))]
public async Task<HttpResponseData?> MapGitHubWebhooksAsync(
[HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = "github/webhooks")] HttpRequestData req,
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/Octokit.Webhooks/Octokit.Webhooks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@
<PackageReference Include="Microsoft.Extensions.Primitives" Version="8.0.0" />
</ItemGroup>



</Project>
6 changes: 2 additions & 4 deletions src/Octokit.Webhooks/WebhookActionTypeAttribute.cs
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 2 additions & 4 deletions src/Octokit.Webhooks/WebhookEventTypeAttribute.cs
Original file line number Diff line number Diff line change
@@ -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;
}