Skip to content

Commit b67f51a

Browse files
Update to NServiceBus 9 (#866)
* Bump major version * Add Fody reference * Bump TFM to net8.0 * Update to NServiceBus 9 packages * Separate public and private packages * Use latest Particular.Analyzers * Remove ifdef * Use collection expressions * Remove unused Guard * Add setting for .NET8 inproc host * Remove props file that is no longer needed * Rename Analyzer project * Clean up trailing whitespace * Move source generator into Analyzer project * Move source generator diagnostic descriptors * Sort descriptors by id number * Update Microsoft.CodeAnalysis.CSharp.Workspaces * Update Particular.Approvals * Update path for permissions fix * Update APIApprovals * Remove unneeded editorconfig settings * Update testing packages * Update PublicApiGenerator * Update NServiceBus packages * Update Obsolete.Fody * Update Particular.Packaging * Update Particular.Approvals * Update workflow * Exclude system.clientmodel from scanning * Apply workaround to Azure/azure-functions-host#10575 --------- Co-authored-by: Andreas Öhlund <[email protected]>
1 parent 745701a commit b67f51a

File tree

49 files changed

+159
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+159
-348
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ jobs:
3535
- name: Setup .NET SDK
3636
uses: actions/[email protected]
3737
with:
38-
dotnet-version: |
39-
8.0.x
40-
6.0.x
38+
dotnet-version: 8.0.x
4139
- name: Setup Azure Functions Core Tools - Windows
4240
if: runner.os == 'Windows'
4341
run: |
@@ -51,7 +49,7 @@ jobs:
5149
shell: bash
5250
- name: Fix Azure Functions Core Tools permissions - Linux
5351
if: runner.os == 'Linux'
54-
run: sudo chmod +x /usr/lib/azure-functions-core-tools/in-proc6/func
52+
run: sudo chmod +x /usr/lib/azure-functions-core-tools/in-proc8/func
5553
- name: Build
5654
run: dotnet build src --configuration Release
5755
- name: Upload packages

src/Custom.Build.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<Project>
22

33
<PropertyGroup>
4-
<ParticularAnalyzersVersion>0.9.0</ParticularAnalyzersVersion>
54
<AnalyzerTargetFramework>netstandard2.0</AnalyzerTargetFramework>
65
</PropertyGroup>
76

87
<PropertyGroup>
9-
<MinVerMinimumMajorMinor>4.1</MinVerMinimumMajorMinor>
8+
<MinVerMinimumMajorMinor>5.0</MinVerMinimumMajorMinor>
109
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
1110
</PropertyGroup>
1211

src/IntegrationTests.HostV4/HttpSender.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading.Tasks;
1+
using System.Threading;
2+
using System.Threading.Tasks;
23
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Http.Extensions;
45
using Microsoft.AspNetCore.Mvc;
@@ -7,6 +8,8 @@
78
using Microsoft.Extensions.Logging;
89
using NServiceBus;
910

11+
using ExecutionContext = Microsoft.Azure.WebJobs.ExecutionContext;
12+
1013
class HttpSender
1114
{
1215
readonly IFunctionEndpoint functionEndpoint;
@@ -17,15 +20,14 @@ public HttpSender(IFunctionEndpoint functionEndpoint)
1720
}
1821

1922
[FunctionName("InProcessHttpSenderV4")]
20-
public async Task<IActionResult> Run(
21-
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest request, ExecutionContext executionContext, ILogger logger)
23+
public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest request, ExecutionContext executionContext, ILogger logger, CancellationToken cancellationToken = default)
2224
{
2325
logger.LogInformation("C# HTTP trigger function received a request at {0}", request.GetEncodedPathAndQuery());
2426

2527
var sendOptions = new SendOptions();
2628
sendOptions.RouteToThisEndpoint();
2729

28-
await functionEndpoint.Send(new TriggerMessage(), sendOptions, executionContext, logger).ConfigureAwait(false);
30+
await functionEndpoint.Send(new TriggerMessage(), sendOptions, executionContext, logger, cancellationToken).ConfigureAwait(false);
2931

3032
return new OkObjectResult($"{nameof(TriggerMessage)} sent.");
3133
}
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
66
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
77
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GeneratedFiles</CompilerGeneratedFilesOutputPath>
88
</PropertyGroup>
99

1010
<ItemGroup>
11+
<ProjectReference Include="..\NServiceBus.AzureFunctions.InProcess.Analyzer\NServiceBus.AzureFunctions.InProcess.Analyzer.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
1112
<ProjectReference Include="..\NServiceBus.AzureFunctions.InProcess.ServiceBus\NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj" />
12-
<ProjectReference Include="..\NServiceBus.AzureFunctions.SourceGenerator\NServiceBus.AzureFunctions.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
1313
</ItemGroup>
1414

1515
<ItemGroup>
1616
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
18-
<PackageReference Include="NUnit" Version="4.2.2" />
19-
<PackageReference Include="NUnit.Analyzers" Version="4.5.0" />
20-
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
18+
<PackageReference Include="NUnit" Version="4.3.2" />
19+
<PackageReference Include="NUnit.Analyzers" Version="4.6.0" />
20+
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<FunctionsPreservedDependencies Include="System.Memory.Data.dll" />
2125
</ItemGroup>
2226

2327
<ItemGroup>
@@ -29,7 +33,4 @@
2933
<None Update="local.settings.json" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="Never" />
3034
</ItemGroup>
3135

32-
<!-- Import the props file from the component because it's referenced as a ProjectReference here, not a PackageReference -->
33-
<Import Project="..\NServiceBus.AzureFunctions.InProcess.ServiceBus\build\NServiceBus.AzureFunctions.InProcess.ServiceBus.props" />
34-
3536
</Project>

src/IntegrationTests.HostV4/When_starting_the_function_host.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public async Task Should_not_blow_up()
163163

164164
hasResult = true;
165165
}
166-
catch (OperationCanceledException)
166+
catch (OperationCanceledException) when (cancellationTokenSource.Token.IsCancellationRequested)
167167
{
168168
}
169169
catch (Exception ex)
@@ -186,7 +186,7 @@ public async Task Should_not_blow_up()
186186
{
187187
await funcProcess.WaitForExitAsync(cancellationTokenSource.Token);
188188
}
189-
catch (OperationCanceledException)
189+
catch (OperationCanceledException) when (cancellationTokenSource.Token.IsCancellationRequested)
190190
{
191191
funcProcess.Kill();
192192
}

src/IntegrationTests.HostV4/local.settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"IsEncrypted": false,
33
"Values": {
44
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
5+
"FUNCTIONS_INPROC_NET8_ENABLED": "1",
56
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
67

78
"AzureWebJobsServiceBus": "<set your ASB connection string here>",

src/NServiceBus.AzureFunctions.Analyzer.Tests/.editorconfig

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/NServiceBus.AzureFunctions.Analyzer.Tests/NServiceBus.AzureFunctions.Analyzer.Tests.csproj

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*.cs]
2+
3+
# ConfigureAwait(false)
4+
dotnet_diagnostic.CA2007.severity = none

src/NServiceBus.AzureFunctions.Analyzer.Tests/AnalyzerTestFixture.cs renamed to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/AnalyzerTestFixture.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace NServiceBus.AzureFunctions.Analyzer.Tests
1+
namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests
22
{
33
using System;
44
using System.Collections.Generic;
@@ -30,7 +30,7 @@ protected async Task Assert(string[] expectedDiagnosticIds, string markupCode, s
3030
var (code, markupSpans) = Parse(markupCode);
3131

3232
var project = CreateProject(code);
33-
await WriteCode(project);
33+
await WriteCode(project, cancellationToken);
3434

3535
var compilerDiagnostics = (await Task.WhenAll(project.Documents
3636
.Select(doc => doc.GetCompilerDiagnostics(cancellationToken))))
@@ -59,7 +59,7 @@ protected async Task Assert(string[] expectedDiagnosticIds, string markupCode, s
5959
NUnit.Framework.Assert.That(actualSpansAndIds, Is.EqualTo(expectedSpansAndIds).AsCollection);
6060
}
6161

62-
protected static async Task WriteCode(Project project)
62+
protected static async Task WriteCode(Project project, CancellationToken cancellationToken = default)
6363
{
6464
if (!VerboseLogging)
6565
{
@@ -69,7 +69,7 @@ protected static async Task WriteCode(Project project)
6969
foreach (var document in project.Documents)
7070
{
7171
Console.WriteLine(document.Name);
72-
var code = await document.GetCode();
72+
var code = await document.GetCode(cancellationToken);
7373
foreach (var (line, index) in code.Replace("\r\n", "\n").Split('\n')
7474
.Select((line, index) => (line, index)))
7575
{
@@ -104,17 +104,16 @@ protected Project CreateProject(string[] code)
104104

105105
static AnalyzerTestFixture()
106106
{
107-
ProjectReferences = ImmutableList.Create(
107+
ProjectReferences =
108+
[
108109
MetadataReference.CreateFromFile(typeof(object).GetTypeInfo().Assembly.Location),
109110
MetadataReference.CreateFromFile(typeof(Enumerable).GetTypeInfo().Assembly.Location),
110-
MetadataReference.CreateFromFile(typeof(System.Linq.Expressions.Expression).GetTypeInfo().Assembly
111-
.Location),
112-
#if NET
111+
MetadataReference.CreateFromFile(typeof(System.Linq.Expressions.Expression).GetTypeInfo().Assembly.Location),
113112
MetadataReference.CreateFromFile(Assembly.Load("System.Runtime").Location),
114-
#endif
115113
MetadataReference.CreateFromFile(typeof(IFunctionEndpoint).GetTypeInfo().Assembly.Location),
116114
MetadataReference.CreateFromFile(typeof(EndpointConfiguration).GetTypeInfo().Assembly.Location),
117-
MetadataReference.CreateFromFile(typeof(AzureServiceBusTransport).GetTypeInfo().Assembly.Location));
115+
MetadataReference.CreateFromFile(typeof(AzureServiceBusTransport).GetTypeInfo().Assembly.Location),
116+
];
118117
}
119118

120119
static readonly ImmutableList<PortableExecutableReference> ProjectReferences;

0 commit comments

Comments
 (0)