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

Update to NServiceBus 9 #866

Merged
merged 30 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8908726
Bump major version
bording Nov 27, 2024
79a06dd
Add Fody reference
bording Nov 27, 2024
dfa5e21
Bump TFM to net8.0
bording Nov 27, 2024
41ab1e3
Update to NServiceBus 9 packages
bording Nov 27, 2024
141e64f
Separate public and private packages
bording Nov 27, 2024
036a7f3
Use latest Particular.Analyzers
bording Nov 27, 2024
0d3d312
Remove ifdef
bording Nov 27, 2024
b37cc51
Use collection expressions
bording Nov 27, 2024
6bbbc86
Remove unused Guard
bording Nov 27, 2024
f827b75
Add setting for .NET8 inproc host
bording Nov 27, 2024
83b236a
Remove props file that is no longer needed
bording Nov 27, 2024
7184f87
Rename Analyzer project
bording Nov 27, 2024
d77c4e4
Clean up trailing whitespace
bording Nov 27, 2024
9d16f4a
Move source generator into Analyzer project
bording Nov 27, 2024
4dd48c7
Move source generator diagnostic descriptors
bording Nov 27, 2024
a6b7cf0
Sort descriptors by id number
bording Nov 27, 2024
47b3aa8
Update Microsoft.CodeAnalysis.CSharp.Workspaces
bording Nov 27, 2024
96d98ef
Update Particular.Approvals
bording Nov 27, 2024
a9575a9
Update path for permissions fix
bording Nov 27, 2024
50ef595
Update APIApprovals
bording Nov 27, 2024
2f3ec61
Remove unneeded editorconfig settings
bording Feb 13, 2025
2989b4a
Update testing packages
bording Feb 14, 2025
22ac05c
Update PublicApiGenerator
bording Feb 14, 2025
67ff689
Update NServiceBus packages
bording Feb 14, 2025
55ec231
Update Obsolete.Fody
bording Feb 14, 2025
4ff33fc
Update Particular.Packaging
bording Feb 14, 2025
c7e908e
Update Particular.Approvals
bording Feb 14, 2025
a0d919c
Update workflow
bording Feb 14, 2025
a694b5d
Exclude system.clientmodel from scanning
andreasohlund Feb 14, 2025
42bec1f
Apply workaround to https://github.com/Azure/azure-functions-host/iss…
andreasohlund Feb 14, 2025
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
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/[email protected]
with:
dotnet-version: |
8.0.x
6.0.x
dotnet-version: 8.0.x
- name: Setup Azure Functions Core Tools - Windows
if: runner.os == 'Windows'
run: |
Expand All @@ -51,7 +49,7 @@ jobs:
shell: bash
- name: Fix Azure Functions Core Tools permissions - Linux
if: runner.os == 'Linux'
run: sudo chmod +x /usr/lib/azure-functions-core-tools/in-proc6/func
run: sudo chmod +x /usr/lib/azure-functions-core-tools/in-proc8/func
- name: Build
run: dotnet build src --configuration Release
- name: Upload packages
Expand Down
3 changes: 1 addition & 2 deletions src/Custom.Build.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<Project>

<PropertyGroup>
<ParticularAnalyzersVersion>0.9.0</ParticularAnalyzersVersion>
<AnalyzerTargetFramework>netstandard2.0</AnalyzerTargetFramework>
</PropertyGroup>

<PropertyGroup>
<MinVerMinimumMajorMinor>4.1</MinVerMinimumMajorMinor>
<MinVerMinimumMajorMinor>5.0</MinVerMinimumMajorMinor>
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
</PropertyGroup>

Expand Down
10 changes: 6 additions & 4 deletions src/IntegrationTests.HostV4/HttpSender.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -7,6 +8,8 @@
using Microsoft.Extensions.Logging;
using NServiceBus;

using ExecutionContext = Microsoft.Azure.WebJobs.ExecutionContext;

class HttpSender
{
readonly IFunctionEndpoint functionEndpoint;
Expand All @@ -17,15 +20,14 @@ public HttpSender(IFunctionEndpoint functionEndpoint)
}

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

var sendOptions = new SendOptions();
sendOptions.RouteToThisEndpoint();

await functionEndpoint.Send(new TriggerMessage(), sendOptions, executionContext, logger).ConfigureAwait(false);
await functionEndpoint.Send(new TriggerMessage(), sendOptions, executionContext, logger, cancellationToken).ConfigureAwait(false);

return new OkObjectResult($"{nameof(TriggerMessage)} sent.");
}
Expand Down
19 changes: 10 additions & 9 deletions src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GeneratedFiles</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NServiceBus.AzureFunctions.InProcess.Analyzer\NServiceBus.AzureFunctions.InProcess.Analyzer.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\NServiceBus.AzureFunctions.InProcess.ServiceBus\NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj" />
<ProjectReference Include="..\NServiceBus.AzureFunctions.SourceGenerator\NServiceBus.AzureFunctions.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
bording marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<FunctionsPreservedDependencies Include="System.Memory.Data.dll" />
</ItemGroup>

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

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

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public async Task Should_not_blow_up()

hasResult = true;
}
catch (OperationCanceledException)
catch (OperationCanceledException) when (cancellationTokenSource.Token.IsCancellationRequested)
{
}
catch (Exception ex)
Expand All @@ -186,7 +186,7 @@ public async Task Should_not_blow_up()
{
await funcProcess.WaitForExitAsync(cancellationTokenSource.Token);
}
catch (OperationCanceledException)
catch (OperationCanceledException) when (cancellationTokenSource.Token.IsCancellationRequested)
{
funcProcess.Kill();
}
Expand Down
1 change: 1 addition & 0 deletions src/IntegrationTests.HostV4/local.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_INPROC_NET8_ENABLED": "1",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",

"AzureWebJobsServiceBus": "<set your ASB connection string here>",
Expand Down
13 changes: 0 additions & 13 deletions src/NServiceBus.AzureFunctions.Analyzer.Tests/.editorconfig

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# ConfigureAwait(false)
dotnet_diagnostic.CA2007.severity = none
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NServiceBus.AzureFunctions.Analyzer.Tests
namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests
{
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -30,7 +30,7 @@ protected async Task Assert(string[] expectedDiagnosticIds, string markupCode, s
var (code, markupSpans) = Parse(markupCode);

var project = CreateProject(code);
await WriteCode(project);
await WriteCode(project, cancellationToken);

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

protected static async Task WriteCode(Project project)
protected static async Task WriteCode(Project project, CancellationToken cancellationToken = default)
{
if (!VerboseLogging)
{
Expand All @@ -69,7 +69,7 @@ protected static async Task WriteCode(Project project)
foreach (var document in project.Documents)
{
Console.WriteLine(document.Name);
var code = await document.GetCode();
var code = await document.GetCode(cancellationToken);
foreach (var (line, index) in code.Replace("\r\n", "\n").Split('\n')
.Select((line, index) => (line, index)))
{
Expand Down Expand Up @@ -104,17 +104,16 @@ protected Project CreateProject(string[] code)

static AnalyzerTestFixture()
{
ProjectReferences = ImmutableList.Create(
ProjectReferences =
[
MetadataReference.CreateFromFile(typeof(object).GetTypeInfo().Assembly.Location),
MetadataReference.CreateFromFile(typeof(Enumerable).GetTypeInfo().Assembly.Location),
MetadataReference.CreateFromFile(typeof(System.Linq.Expressions.Expression).GetTypeInfo().Assembly
.Location),
#if NET
MetadataReference.CreateFromFile(typeof(System.Linq.Expressions.Expression).GetTypeInfo().Assembly.Location),
MetadataReference.CreateFromFile(Assembly.Load("System.Runtime").Location),
#endif
MetadataReference.CreateFromFile(typeof(IFunctionEndpoint).GetTypeInfo().Assembly.Location),
MetadataReference.CreateFromFile(typeof(EndpointConfiguration).GetTypeInfo().Assembly.Location),
MetadataReference.CreateFromFile(typeof(AzureServiceBusTransport).GetTypeInfo().Assembly.Location));
MetadataReference.CreateFromFile(typeof(AzureServiceBusTransport).GetTypeInfo().Assembly.Location),
];
}

static readonly ImmutableList<PortableExecutableReference> ProjectReferences;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NServiceBus.AzureFunctions.Analyzer.Tests
namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests
{
using System.Threading.Tasks;
using NUnit.Framework;
Expand All @@ -17,9 +17,9 @@ public class ConfigurationAnalyzerTests : AnalyzerTestFixture<ConfigurationAnaly
public Task DiagnosticIsReportedForEndpointConfiguration(string configuration, string diagnosticId)
{
var source =
$@"using NServiceBus;
$@"using NServiceBus;
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;
class Foo
{{
void Bar(ServiceBusTriggeredEndpointConfiguration endpointConfig)
Expand All @@ -44,10 +44,10 @@ void Bar(ServiceBusTriggeredEndpointConfiguration endpointConfig)
public Task DiagnosticIsNotReportedForOtherEndpointConfiguration(string configuration, string diagnosticId)
{
var source =
$@"using NServiceBus;
$@"using NServiceBus;
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks;

class SomeOtherClass
{{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NServiceBus.AzureFunctions.Analyzer.Tests
namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests
{
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
Expand All @@ -13,9 +13,9 @@ public class ConfigurationAnalyzerTestsCSharp8 : AnalyzerTestFixture<Configurati
public Task DiagnosticIsReportedForEndpointConfiguration(string configuration, string diagnosticId)
{
var source =
$@"using NServiceBus;
$@"using NServiceBus;
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;
class Foo
{{
void Bar(ServiceBusTriggeredEndpointConfiguration endpointConfig)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NServiceBus.AzureFunctions.Analyzer.Tests
namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests
{
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -44,7 +44,7 @@ public static async Task<IEnumerable<Diagnostic>> GetAnalyzerDiagnostics(this Co
logAnalyzerExecutionTime: false);

var diagnostics = await compilation
.WithAnalyzers(ImmutableArray.Create(analyzer), analysisOptions)
.WithAnalyzers([analyzer], analysisOptions)
.GetAnalyzerDiagnosticsAsync(cancellationToken);

if (exceptions.Any())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NServiceBus.AzureFunctions.Analyzer.Tests
namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests
{
using System.Collections.Generic;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NServiceBus.AzureFunctions.InProcess.Analyzer\NServiceBus.AzureFunctions.InProcess.Analyzer.csproj" />
<ProjectReference Include="..\NServiceBus.AzureFunctions.InProcess.ServiceBus\NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageReference Include="Particular.Approvals" Version="2.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NServiceBus.AzureFunctions.Analyzer.Tests
namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests
{
using System.Threading.Tasks;
using NUnit.Framework;
Expand All @@ -13,7 +13,7 @@ public class OptionsAnalyzerTests : AnalyzerTestFixture<ConfigurationAnalyzer>
public Task DiagnosticIsReportedForOptions(string optionsType, string method, string diagnosticId)
{
var source =
$@"using NServiceBus;
$@"using NServiceBus;
class Foo
{{
void Bar({optionsType} options)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NServiceBus.AzureFunctions.SourceGenerator.Tests
namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests
{
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void Invalid_name_should_cause_an_error(string endpointName)
";
var (_, diagnostics) = GetGeneratedOutput(source, suppressGeneratedDiagnosticsErrors: true);

Assert.That(diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error && d.Id == TriggerFunctionGenerator.InvalidEndpointNameError.Id), Is.True);
Assert.That(diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error && d.Id == AzureFunctionsDiagnostics.InvalidEndpointNameErrorId), Is.True);
}

[TestCase(null)]
Expand All @@ -123,7 +123,7 @@ public void Invalid_trigger_function_name_should_cause_an_error(string triggerFu
";
var (_, diagnostics) = GetGeneratedOutput(source, suppressGeneratedDiagnosticsErrors: true);

Assert.That(diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error && d.Id == TriggerFunctionGenerator.InvalidTriggerFunctionNameError.Id), Is.True);
Assert.That(diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error && d.Id == AzureFunctionsDiagnostics.InvalidTriggerFunctionNameErrorId), Is.True);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NServiceBus.AzureFunctions.Analyzer.Tests
namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests
{
using System.Threading.Tasks;
using NUnit.Framework;
Expand Down
Loading