diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72615f33..d9eb180f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,9 +35,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v4.3.0 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: | @@ -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 diff --git a/src/Custom.Build.props b/src/Custom.Build.props index dd483374..5b885869 100644 --- a/src/Custom.Build.props +++ b/src/Custom.Build.props @@ -1,12 +1,11 @@ - 0.9.0 netstandard2.0 - 4.1 + 5.0 minor diff --git a/src/IntegrationTests.HostV4/HttpSender.cs b/src/IntegrationTests.HostV4/HttpSender.cs index 3525a484..fddd196e 100644 --- a/src/IntegrationTests.HostV4/HttpSender.cs +++ b/src/IntegrationTests.HostV4/HttpSender.cs @@ -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; @@ -7,6 +8,8 @@ using Microsoft.Extensions.Logging; using NServiceBus; +using ExecutionContext = Microsoft.Azure.WebJobs.ExecutionContext; + class HttpSender { readonly IFunctionEndpoint functionEndpoint; @@ -17,15 +20,14 @@ public HttpSender(IFunctionEndpoint functionEndpoint) } [FunctionName("InProcessHttpSenderV4")] - public async Task Run( - [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest request, ExecutionContext executionContext, ILogger logger) + public async Task 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."); } diff --git a/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj b/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj index 0c390782..134bbfed 100644 --- a/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj +++ b/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj @@ -1,23 +1,27 @@ - net6.0 + net8.0 v4 true $(BaseIntermediateOutputPath)\GeneratedFiles + - - - - - + + + + + + + + @@ -29,7 +33,4 @@ - - - \ No newline at end of file diff --git a/src/IntegrationTests.HostV4/When_starting_the_function_host.cs b/src/IntegrationTests.HostV4/When_starting_the_function_host.cs index 3efe6ac8..9fb7a972 100644 --- a/src/IntegrationTests.HostV4/When_starting_the_function_host.cs +++ b/src/IntegrationTests.HostV4/When_starting_the_function_host.cs @@ -163,7 +163,7 @@ public async Task Should_not_blow_up() hasResult = true; } - catch (OperationCanceledException) + catch (OperationCanceledException) when (cancellationTokenSource.Token.IsCancellationRequested) { } catch (Exception ex) @@ -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(); } diff --git a/src/IntegrationTests.HostV4/local.settings.json b/src/IntegrationTests.HostV4/local.settings.json index 71e6cd3e..56b7480a 100644 --- a/src/IntegrationTests.HostV4/local.settings.json +++ b/src/IntegrationTests.HostV4/local.settings.json @@ -2,6 +2,7 @@ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", + "FUNCTIONS_INPROC_NET8_ENABLED": "1", "FUNCTIONS_WORKER_RUNTIME": "dotnet", "AzureWebJobsServiceBus": "", diff --git a/src/NServiceBus.AzureFunctions.Analyzer.Tests/.editorconfig b/src/NServiceBus.AzureFunctions.Analyzer.Tests/.editorconfig deleted file mode 100644 index 671d13ff..00000000 --- a/src/NServiceBus.AzureFunctions.Analyzer.Tests/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -[*.cs] - -# ConfigureAwait(false) -dotnet_diagnostic.CA2007.severity = none - -# Use pattern matching (may change code meaning) -dotnet_diagnostic.IDE0078.severity = none - -# Use pattern matching -dotnet_diagnostic.IDE0083.severity = none - -# Convert switch statement to expression -dotnet_diagnostic.IDE0066.severity = none diff --git a/src/NServiceBus.AzureFunctions.Analyzer.Tests/NServiceBus.AzureFunctions.Analyzer.Tests.csproj b/src/NServiceBus.AzureFunctions.Analyzer.Tests/NServiceBus.AzureFunctions.Analyzer.Tests.csproj deleted file mode 100644 index 8f90641a..00000000 --- a/src/NServiceBus.AzureFunctions.Analyzer.Tests/NServiceBus.AzureFunctions.Analyzer.Tests.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net6.0 - - - - - - - - - - - - - - - - diff --git a/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/.editorconfig b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/.editorconfig new file mode 100644 index 00000000..fb00cd90 --- /dev/null +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# ConfigureAwait(false) +dotnet_diagnostic.CA2007.severity = none diff --git a/src/NServiceBus.AzureFunctions.Analyzer.Tests/AnalyzerTestFixture.cs b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/AnalyzerTestFixture.cs similarity index 94% rename from src/NServiceBus.AzureFunctions.Analyzer.Tests/AnalyzerTestFixture.cs rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/AnalyzerTestFixture.cs index e13dc872..3ee6b02c 100644 --- a/src/NServiceBus.AzureFunctions.Analyzer.Tests/AnalyzerTestFixture.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/AnalyzerTestFixture.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.AzureFunctions.Analyzer.Tests +namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests { using System; using System.Collections.Generic; @@ -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)))) @@ -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) { @@ -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))) { @@ -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 ProjectReferences; diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.Can_enable_transactions.approved.txt b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.Can_enable_transactions.approved.txt similarity index 100% rename from src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.Can_enable_transactions.approved.txt rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.Can_enable_transactions.approved.txt diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.Can_override_trigger_function_name.approved.txt b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.Can_override_trigger_function_name.approved.txt similarity index 100% rename from src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.Can_override_trigger_function_name.approved.txt rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.Can_override_trigger_function_name.approved.txt diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.NameIsStringValue.approved.txt b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.NameIsStringValue.approved.txt similarity index 100% rename from src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.NameIsStringValue.approved.txt rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.NameIsStringValue.approved.txt diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.No_attribute_should_not_generate_trigger_function.approved.txt b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.No_attribute_should_not_generate_trigger_function.approved.txt similarity index 100% rename from src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.No_attribute_should_not_generate_trigger_function.approved.txt rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.No_attribute_should_not_generate_trigger_function.approved.txt diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.Two_optionals_out_of_order.approved.txt b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.Two_optionals_out_of_order.approved.txt similarity index 100% rename from src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.Two_optionals_out_of_order.approved.txt rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.Two_optionals_out_of_order.approved.txt diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.Use_two_optionals.approved.txt b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.Use_two_optionals.approved.txt similarity index 100% rename from src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.Use_two_optionals.approved.txt rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.Use_two_optionals.approved.txt diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.UsingFullyQualifiedAttributeName.approved.txt b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.UsingFullyQualifiedAttributeName.approved.txt similarity index 100% rename from src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.UsingFullyQualifiedAttributeName.approved.txt rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.UsingFullyQualifiedAttributeName.approved.txt diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.UsingNamespace.approved.txt b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.UsingNamespace.approved.txt similarity index 100% rename from src/NServiceBus.AzureFunctions.SourceGenerator.Tests/ApprovalFiles/SourceGeneratorApprovals.UsingNamespace.approved.txt rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ApprovalFiles/SourceGeneratorApprovals.UsingNamespace.approved.txt diff --git a/src/NServiceBus.AzureFunctions.Analyzer.Tests/ConfigurationAnalyzerTests.cs b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ConfigurationAnalyzerTests.cs similarity index 93% rename from src/NServiceBus.AzureFunctions.Analyzer.Tests/ConfigurationAnalyzerTests.cs rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ConfigurationAnalyzerTests.cs index ffca45aa..37687f1e 100644 --- a/src/NServiceBus.AzureFunctions.Analyzer.Tests/ConfigurationAnalyzerTests.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/ConfigurationAnalyzerTests.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.AzureFunctions.Analyzer.Tests +namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests { using System.Threading.Tasks; using NUnit.Framework; @@ -17,9 +17,9 @@ public class ConfigurationAnalyzerTests : AnalyzerTestFixture> GetAnalyzerDiagnostics(this Co logAnalyzerExecutionTime: false); var diagnostics = await compilation - .WithAnalyzers(ImmutableArray.Create(analyzer), analysisOptions) + .WithAnalyzers([analyzer], analysisOptions) .GetAnalyzerDiagnosticsAsync(cancellationToken); if (exceptions.Any()) diff --git a/src/NServiceBus.AzureFunctions.Analyzer.Tests/Extensions/DocumentExtensions.cs b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/Extensions/DocumentExtensions.cs similarity index 97% rename from src/NServiceBus.AzureFunctions.Analyzer.Tests/Extensions/DocumentExtensions.cs rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/Extensions/DocumentExtensions.cs index b02a6207..deeeae96 100644 --- a/src/NServiceBus.AzureFunctions.Analyzer.Tests/Extensions/DocumentExtensions.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/Extensions/DocumentExtensions.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.AzureFunctions.Analyzer.Tests +namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests { using System.Collections.Generic; using System.Linq; diff --git a/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests.csproj b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests.csproj new file mode 100644 index 00000000..c7a80098 --- /dev/null +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests.csproj @@ -0,0 +1,25 @@ + + + + net8.0 + + + + + + + + + + + + + + + + + + + + + diff --git a/src/NServiceBus.AzureFunctions.Analyzer.Tests/OptionsAnalyzerTests.cs b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/OptionsAnalyzerTests.cs similarity index 94% rename from src/NServiceBus.AzureFunctions.Analyzer.Tests/OptionsAnalyzerTests.cs rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/OptionsAnalyzerTests.cs index 8ffc2493..3bc1d76c 100644 --- a/src/NServiceBus.AzureFunctions.Analyzer.Tests/OptionsAnalyzerTests.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/OptionsAnalyzerTests.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.AzureFunctions.Analyzer.Tests +namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests { using System.Threading.Tasks; using NUnit.Framework; @@ -13,7 +13,7 @@ public class OptionsAnalyzerTests : AnalyzerTestFixture public Task DiagnosticIsReportedForOptions(string optionsType, string method, string diagnosticId) { var source = - $@"using NServiceBus; + $@"using NServiceBus; class Foo {{ void Bar({optionsType} options) diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/SourceGeneratorApprovals.cs b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/SourceGeneratorApprovals.cs similarity index 96% rename from src/NServiceBus.AzureFunctions.SourceGenerator.Tests/SourceGeneratorApprovals.cs rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/SourceGeneratorApprovals.cs index 285c1ffd..f713e7fb 100644 --- a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/SourceGeneratorApprovals.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/SourceGeneratorApprovals.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.AzureFunctions.SourceGenerator.Tests +namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests { using System; using System.Collections.Generic; @@ -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)] @@ -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] diff --git a/src/NServiceBus.AzureFunctions.Analyzer.Tests/TransportConfigurationAnalyzerTests.cs b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/TransportConfigurationAnalyzerTests.cs similarity index 98% rename from src/NServiceBus.AzureFunctions.Analyzer.Tests/TransportConfigurationAnalyzerTests.cs rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/TransportConfigurationAnalyzerTests.cs index 264709b2..23697da5 100644 --- a/src/NServiceBus.AzureFunctions.Analyzer.Tests/TransportConfigurationAnalyzerTests.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer.Tests/TransportConfigurationAnalyzerTests.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.AzureFunctions.Analyzer.Tests +namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests { using System.Threading.Tasks; using NUnit.Framework; diff --git a/src/NServiceBus.AzureFunctions.Analyzer/.editorconfig b/src/NServiceBus.AzureFunctions.InProcess.Analyzer/.editorconfig similarity index 100% rename from src/NServiceBus.AzureFunctions.Analyzer/.editorconfig rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer/.editorconfig diff --git a/src/NServiceBus.AzureFunctions.Analyzer/AzureFunctionsDiagnostics.cs b/src/NServiceBus.AzureFunctions.InProcess.Analyzer/AzureFunctionsDiagnostics.cs similarity index 90% rename from src/NServiceBus.AzureFunctions.Analyzer/AzureFunctionsDiagnostics.cs rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer/AzureFunctionsDiagnostics.cs index 9d944d6f..c29af635 100644 --- a/src/NServiceBus.AzureFunctions.Analyzer/AzureFunctionsDiagnostics.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer/AzureFunctionsDiagnostics.cs @@ -1,9 +1,11 @@ -namespace NServiceBus.AzureFunctions.Analyzer +namespace NServiceBus.AzureFunctions.InProcess.Analyzer { using Microsoft.CodeAnalysis; public static class AzureFunctionsDiagnostics { + public const string InvalidEndpointNameErrorId = "NSBFUNC001"; + public const string InvalidTriggerFunctionNameErrorId = "NSBFUNC002"; public const string PurgeOnStartupNotAllowedId = "NSBFUNC003"; public const string LimitMessageProcessingToNotAllowedId = "NSBFUNC004"; public const string DefineCriticalErrorActionNotAllowedId = "NSBFUNC005"; @@ -18,12 +20,27 @@ public static class AzureFunctionsDiagnostics public const string PrefetchCountNotAllowedId = "NSBFUNC014"; public const string PrefetchMultiplierNotAllowedId = "NSBFUNC015"; public const string TimeToWaitBeforeTriggeringCircuitBreakerNotAllowedId = "NSBFUNC016"; - public const string EntityMaximumSizeNotAllowedId = "NSBFUNC017"; public const string EnablePartitioningNotAllowedId = "NSBFUNC018"; const string DiagnosticCategory = "NServiceBus.AzureFunctions"; + internal static readonly DiagnosticDescriptor InvalidEndpointNameError = new DiagnosticDescriptor( + id: InvalidEndpointNameErrorId, + title: "Invalid Endpoint Name", + messageFormat: "Endpoint name is invalid and cannot be used to generate trigger function", + category: "TriggerFunctionGenerator", + DiagnosticSeverity.Error, + isEnabledByDefault: true); + + internal static readonly DiagnosticDescriptor InvalidTriggerFunctionNameError = new DiagnosticDescriptor( + id: InvalidTriggerFunctionNameErrorId, + title: "Invalid Trigger Function Name", + messageFormat: "Trigger function name is invalid and cannot be used to generate trigger function", + category: "TriggerFunctionGenerator", + DiagnosticSeverity.Error, + isEnabledByDefault: true); + internal static readonly DiagnosticDescriptor PurgeOnStartupNotAllowed = new DiagnosticDescriptor( id: PurgeOnStartupNotAllowedId, title: "PurgeOnStartup is not supported in Azure Functions", @@ -105,6 +122,15 @@ public static class AzureFunctionsDiagnostics isEnabledByDefault: true ); + internal static readonly DiagnosticDescriptor TransportTransactionModeNotAllowed = new DiagnosticDescriptor( + id: TransportTransactionModeNotAllowedId, + title: "TransportTransactionMode is not supported in Azure Functions", + messageFormat: "Transport TransactionMode is controlled by the Azure Service Bus trigger and cannot be configured via the NServiceBus transport configuration API when using Azure Functions.", + category: DiagnosticCategory, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true + ); + internal static readonly DiagnosticDescriptor MaxAutoLockRenewalDurationNotAllowed = new DiagnosticDescriptor( id: MaxAutoLockRenewalDurationNotAllowedId, title: "MaxAutoLockRenewalDuration is not supported in Azure Functions", @@ -158,14 +184,5 @@ public static class AzureFunctionsDiagnostics defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true ); - - internal static readonly DiagnosticDescriptor TransportTransactionModeNotAllowed = new DiagnosticDescriptor( - id: TransportTransactionModeNotAllowedId, - title: "TransportTransactionMode is not supported in Azure Functions", - messageFormat: "Transport TransactionMode is controlled by the Azure Service Bus trigger and cannot be configured via the NServiceBus transport configuration API when using Azure Functions.", - category: DiagnosticCategory, - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true - ); } } \ No newline at end of file diff --git a/src/NServiceBus.AzureFunctions.Analyzer/ConfigurationAnalyzer.cs b/src/NServiceBus.AzureFunctions.InProcess.Analyzer/ConfigurationAnalyzer.cs similarity index 99% rename from src/NServiceBus.AzureFunctions.Analyzer/ConfigurationAnalyzer.cs rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer/ConfigurationAnalyzer.cs index 1c8b1ab6..4f550ff8 100644 --- a/src/NServiceBus.AzureFunctions.Analyzer/ConfigurationAnalyzer.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer/ConfigurationAnalyzer.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.AzureFunctions.Analyzer +namespace NServiceBus.AzureFunctions.InProcess.Analyzer { using System.Collections.Generic; using System.Collections.Immutable; diff --git a/src/NServiceBus.AzureFunctions.Analyzer/Extensions/SyntaxNodeAnalysisContextExtension.cs b/src/NServiceBus.AzureFunctions.InProcess.Analyzer/Extensions/SyntaxNodeAnalysisContextExtension.cs similarity index 100% rename from src/NServiceBus.AzureFunctions.Analyzer/Extensions/SyntaxNodeAnalysisContextExtension.cs rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer/Extensions/SyntaxNodeAnalysisContextExtension.cs diff --git a/src/NServiceBus.AzureFunctions.Analyzer/NServiceBus.AzureFunctions.Analyzer.csproj b/src/NServiceBus.AzureFunctions.InProcess.Analyzer/NServiceBus.AzureFunctions.InProcess.Analyzer.csproj similarity index 86% rename from src/NServiceBus.AzureFunctions.Analyzer/NServiceBus.AzureFunctions.Analyzer.csproj rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer/NServiceBus.AzureFunctions.InProcess.Analyzer.csproj index 761ec1c2..0b5cbe17 100644 --- a/src/NServiceBus.AzureFunctions.Analyzer/NServiceBus.AzureFunctions.Analyzer.csproj +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer/NServiceBus.AzureFunctions.InProcess.Analyzer.csproj @@ -7,12 +7,13 @@ ..\NServiceBus.snk false false + true - - + + diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator/TriggerFunctionGenerator.cs b/src/NServiceBus.AzureFunctions.InProcess.Analyzer/TriggerFunctionGenerator.cs similarity index 86% rename from src/NServiceBus.AzureFunctions.SourceGenerator/TriggerFunctionGenerator.cs rename to src/NServiceBus.AzureFunctions.InProcess.Analyzer/TriggerFunctionGenerator.cs index b7b90d8f..215a82f1 100644 --- a/src/NServiceBus.AzureFunctions.SourceGenerator/TriggerFunctionGenerator.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.Analyzer/TriggerFunctionGenerator.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.AzureFunctions.SourceGenerator +namespace NServiceBus.AzureFunctions.InProcess.Analyzer { using System.Linq; using System.Text; @@ -9,20 +9,6 @@ [Generator] public class TriggerFunctionGenerator : ISourceGenerator { - internal static readonly DiagnosticDescriptor InvalidEndpointNameError = new DiagnosticDescriptor(id: "NSBFUNC001", - title: "Invalid Endpoint Name", - messageFormat: "Endpoint name is invalid and cannot be used to generate trigger function", - category: "TriggerFunctionGenerator", - DiagnosticSeverity.Error, - isEnabledByDefault: true); - - internal static readonly DiagnosticDescriptor InvalidTriggerFunctionNameError = new DiagnosticDescriptor(id: "NSBFUNC002", - title: "Invalid Trigger Function Name", - messageFormat: "Trigger function name is invalid and cannot be used to generate trigger function", - category: "TriggerFunctionGenerator", - DiagnosticSeverity.Error, - isEnabledByDefault: true); - public void Initialize(GeneratorInitializationContext context) { context.RegisterForSyntaxNotifications(() => new SyntaxReceiver()); @@ -97,14 +83,14 @@ public void Execute(GeneratorExecutionContext context) // Generate an error if empty/null/space is used as endpoint name if (string.IsNullOrWhiteSpace(syntaxReceiver.endpointName)) { - context.ReportDiagnostic(Diagnostic.Create(InvalidEndpointNameError, Location.None, syntaxReceiver.endpointName)); + context.ReportDiagnostic(Diagnostic.Create(AzureFunctionsDiagnostics.InvalidEndpointNameError, Location.None, syntaxReceiver.endpointName)); return; } // Generate an error if empty/null/space is used as trigger function name if (string.IsNullOrWhiteSpace(syntaxReceiver.triggerFunctionName)) { - context.ReportDiagnostic(Diagnostic.Create(InvalidTriggerFunctionNameError, Location.None, syntaxReceiver.triggerFunctionName)); + context.ReportDiagnostic(Diagnostic.Create(AzureFunctionsDiagnostics.InvalidTriggerFunctionNameError, Location.None, syntaxReceiver.triggerFunctionName)); return; } diff --git a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus.sln b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus.sln index 5a67fcd9..105b6ae4 100644 --- a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus.sln +++ b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus.sln @@ -15,17 +15,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Testing.Handlers", "Testing.Handlers\Testing.Handlers.csproj", "{F922CF8D-9012-4D04-84FF-3C923F79A075}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.AzureFunctions.SourceGenerator", "NServiceBus.AzureFunctions.SourceGenerator\NServiceBus.AzureFunctions.SourceGenerator.csproj", "{D2345DCC-2A8D-4B30-9701-F276597D6858}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.AzureFunctions.SourceGenerator.Tests", "NServiceBus.AzureFunctions.SourceGenerator.Tests\NServiceBus.AzureFunctions.SourceGenerator.Tests.csproj", "{22BE8002-D99B-461B-B472-F2361A849E47}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceBus.AcceptanceTests", "ServiceBus.AcceptanceTests\ServiceBus.AcceptanceTests.csproj", "{259C7716-0038-493C-831F-A9193C94741C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests.HostV4", "IntegrationTests.HostV4\IntegrationTests.HostV4.csproj", "{D4B26C04-CD88-4356-922F-CCF69D74F442}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.AzureFunctions.Analyzer", "NServiceBus.AzureFunctions.Analyzer\NServiceBus.AzureFunctions.Analyzer.csproj", "{0D840DDA-A554-4764-871E-3ACB7A454FF9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.AzureFunctions.InProcess.Analyzer", "NServiceBus.AzureFunctions.InProcess.Analyzer\NServiceBus.AzureFunctions.InProcess.Analyzer.csproj", "{0D840DDA-A554-4764-871E-3ACB7A454FF9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.AzureFunctions.Analyzer.Tests", "NServiceBus.AzureFunctions.Analyzer.Tests\NServiceBus.AzureFunctions.Analyzer.Tests.csproj", "{BA6AF5D9-9784-498A-9E9E-8A726A35B0EE}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.AzureFunctions.InProcess.Analyzer.Tests", "NServiceBus.AzureFunctions.InProcess.Analyzer.Tests\NServiceBus.AzureFunctions.InProcess.Analyzer.Tests.csproj", "{BA6AF5D9-9784-498A-9E9E-8A726A35B0EE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -45,14 +41,6 @@ Global {F922CF8D-9012-4D04-84FF-3C923F79A075}.Debug|Any CPU.Build.0 = Debug|Any CPU {F922CF8D-9012-4D04-84FF-3C923F79A075}.Release|Any CPU.ActiveCfg = Release|Any CPU {F922CF8D-9012-4D04-84FF-3C923F79A075}.Release|Any CPU.Build.0 = Release|Any CPU - {D2345DCC-2A8D-4B30-9701-F276597D6858}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D2345DCC-2A8D-4B30-9701-F276597D6858}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D2345DCC-2A8D-4B30-9701-F276597D6858}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D2345DCC-2A8D-4B30-9701-F276597D6858}.Release|Any CPU.Build.0 = Release|Any CPU - {22BE8002-D99B-461B-B472-F2361A849E47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {22BE8002-D99B-461B-B472-F2361A849E47}.Debug|Any CPU.Build.0 = Debug|Any CPU - {22BE8002-D99B-461B-B472-F2361A849E47}.Release|Any CPU.ActiveCfg = Release|Any CPU - {22BE8002-D99B-461B-B472-F2361A849E47}.Release|Any CPU.Build.0 = Release|Any CPU {259C7716-0038-493C-831F-A9193C94741C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {259C7716-0038-493C-831F-A9193C94741C}.Debug|Any CPU.Build.0 = Debug|Any CPU {259C7716-0038-493C-831F-A9193C94741C}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/InProcessFunctionEndpoint.cs b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/InProcessFunctionEndpoint.cs index b439475e..95863bd5 100644 --- a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/InProcessFunctionEndpoint.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/InProcessFunctionEndpoint.cs @@ -35,7 +35,7 @@ public async Task ProcessAtomic( { await InitializeEndpointIfNecessary(cancellationToken).ConfigureAwait(false); } - catch (Exception) + catch (Exception ex) when (ex is not OperationCanceledException || !cancellationToken.IsCancellationRequested) { await messageActions.AbandonMessageAsync(message, cancellationToken: cancellationToken).ConfigureAwait(false); throw; @@ -154,10 +154,11 @@ public Task Unsubscribe(Type eventType, ExecutionContext executionContext, ILogg "Microsoft.Identity.Client.dll", "Microsoft.Identity.Client.Extensions.Msal.dll", "NCrontab.Signed.dll", - "NServiceBus.Extensions.DependencyInjection.dll" + "NServiceBus.Extensions.DependencyInjection.dll", + "System.ClientModel.dll" }; - internal async Task InitializeEndpointIfNecessary(CancellationToken cancellationToken) + internal async Task InitializeEndpointIfNecessary(CancellationToken cancellationToken = default) { if (messageProcessor == null) { diff --git a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj index 6c9ee2ec..7fcfa8a1 100644 --- a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj +++ b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj @@ -1,40 +1,33 @@  - net6.0 + net8.0 true ..\NServiceBus.snk - + - - - - - + + + - + + + - - + - - - - - - diff --git a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Serverless/TransportWrapper/PipelineInvokingMessageProcessor.cs b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Serverless/TransportWrapper/PipelineInvokingMessageProcessor.cs index 109ce5b4..e592c0c6 100644 --- a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Serverless/TransportWrapper/PipelineInvokingMessageProcessor.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Serverless/TransportWrapper/PipelineInvokingMessageProcessor.cs @@ -16,7 +16,7 @@ class PipelineInvokingMessageProcessor : IMessageReceiver, IMessageProcessor public PipelineInvokingMessageProcessor(IMessageReceiver baseTransportReceiver) => this.baseTransportReceiver = baseTransportReceiver; public Task Initialize(PushRuntimeSettings limitations, OnMessage onMessage, OnError onError, - CancellationToken cancellationToken) + CancellationToken cancellationToken = default) { this.onMessage = onMessage; this.onError = onError; @@ -37,9 +37,9 @@ public async Task ProcessNonAtomic( await onMessage(messageContext, cancellationToken).ConfigureAwait(false); } - catch (Exception exception) + catch (Exception ex) when (ex is not OperationCanceledException || !cancellationToken.IsCancellationRequested) { - var errorContext = CreateErrorContext(message, new TransportTransaction(), exception); + var errorContext = CreateErrorContext(message, new TransportTransaction(), ex); var errorHandleResult = await onError(errorContext, cancellationToken).ConfigureAwait(false); @@ -69,12 +69,12 @@ public async Task ProcessAtomic( azureServiceBusTransaction.Commit(); } } - catch (Exception exception) + catch (Exception ex) when (ex is not OperationCanceledException || !cancellationToken.IsCancellationRequested) { ErrorHandleResult result; using (var azureServiceBusTransaction = CreateTransaction(message.PartitionKey, serviceBusClient)) { - var errorContext = CreateErrorContext(message, azureServiceBusTransaction.TransportTransaction, exception); + var errorContext = CreateErrorContext(message, azureServiceBusTransaction.TransportTransaction, ex); result = await onError(errorContext, cancellationToken).ConfigureAwait(false); @@ -122,7 +122,7 @@ MessageContext CreateMessageContext(ServiceBusReceivedMessage message, Transport return messageContext; } - static async Task SafeCompleteMessageAsync(ServiceBusMessageActions messageActions, ServiceBusReceivedMessage message, AzureServiceBusTransportTransaction azureServiceBusTransaction, CancellationToken cancellationToken = default) + static async Task SafeCompleteMessageAsync(ServiceBusMessageActions messageActions, ServiceBusReceivedMessage message, AzureServiceBusTransportTransaction azureServiceBusTransaction, CancellationToken cancellationToken) { using var scope = azureServiceBusTransaction.ToTransactionScope(); await messageActions.CompleteMessageAsync(message, cancellationToken).ConfigureAwait(false); @@ -136,12 +136,12 @@ static AzureServiceBusTransportTransaction CreateTransaction(string messageParti Timeout = TransactionManager.MaximumTimeout }); - public Task StartReceive(CancellationToken cancellationToken) => Task.CompletedTask; + public Task StartReceive(CancellationToken cancellationToken = default) => Task.CompletedTask; // No-op because the rate at which Azure Functions pushes messages to the pipeline can't be controlled. public Task ChangeConcurrency(PushRuntimeSettings limitations, CancellationToken cancellationToken = default) => Task.CompletedTask; - public Task StopReceive(CancellationToken cancellationToken) => Task.CompletedTask; + public Task StopReceive(CancellationToken cancellationToken = default) => Task.CompletedTask; public ISubscriptionManager Subscriptions => baseTransportReceiver.Subscriptions; public string Id => baseTransportReceiver.Id; diff --git a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Serverless/TransportWrapper/ServerlessTransport.cs b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Serverless/TransportWrapper/ServerlessTransport.cs index 6e91394e..11442fc9 100644 --- a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Serverless/TransportWrapper/ServerlessTransport.cs +++ b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Serverless/TransportWrapper/ServerlessTransport.cs @@ -55,12 +55,6 @@ public override async Task Initialize(HostSettings host return serverlessTransportInfrastructure; } -#pragma warning disable CS0672 // Member overrides obsolete member -#pragma warning disable CS0618 // Type or member is obsolete - public override string ToTransportAddress(QueueAddress address) => transportExtensions.Transport.ToTransportAddress(address); -#pragma warning restore CS0618 // Type or member is obsolete -#pragma warning restore CS0672 // Member overrides obsolete member - public override IReadOnlyCollection GetSupportedTransactionModes() => supportedTransactionModes; diff --git a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Utils/Guard.cs b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Utils/Guard.cs deleted file mode 100644 index b286731e..00000000 --- a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Utils/Guard.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace NServiceBus -{ - using System; - - static class Guard - { - public static void AgainstNullAndEmpty(string argumentName, string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentNullException(argumentName); - } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/build/NServiceBus.AzureFunctions.InProcess.ServiceBus.props b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/build/NServiceBus.AzureFunctions.InProcess.ServiceBus.props deleted file mode 100644 index 449a9eb9..00000000 --- a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/build/NServiceBus.AzureFunctions.InProcess.ServiceBus.props +++ /dev/null @@ -1,12 +0,0 @@ - - - CS8032 - - - - - - - - - \ No newline at end of file diff --git a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/obsoletes-v4.cs b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/obsoletes-v4.cs deleted file mode 100644 index cff615dc..00000000 --- a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/obsoletes-v4.cs +++ /dev/null @@ -1,60 +0,0 @@ -#pragma warning disable 1591 - -namespace NServiceBus -{ - using System; - using Microsoft.Azure.Functions.Extensions.DependencyInjection; - using Microsoft.Extensions.Configuration; - using Transport; - - public partial class ServiceBusTriggeredEndpointConfiguration - { - [ObsoleteEx(ReplacementTypeOrMember = "UseNServiceBus(ENDPOINTNAME, CONNECTIONSTRING)", - TreatAsErrorFromVersion = "4", - RemoveInVersion = "5")] - public string ServiceBusConnectionString { get; set; } - - [ObsoleteEx( - TreatAsErrorFromVersion = "4", - RemoveInVersion = "5")] - public ServiceBusTriggeredEndpointConfiguration(IConfiguration configuration) - => throw new NotImplementedException(); - - [ObsoleteEx( - TreatAsErrorFromVersion = "4", - RemoveInVersion = "5")] - public ServiceBusTriggeredEndpointConfiguration(string endpointName, IConfiguration configuration = null) - => throw new NotImplementedException(); - - [ObsoleteEx( - TreatAsErrorFromVersion = "4", - RemoveInVersion = "5")] - public ServiceBusTriggeredEndpointConfiguration(string endpointName, string connectionStringName = null) - => throw new NotImplementedException(); - - [ObsoleteEx( - TreatAsErrorFromVersion = "4", - RemoveInVersion = "5")] - public ServiceBusTriggeredEndpointConfiguration(string endpointName) - => throw new NotImplementedException(); - - [ObsoleteEx( - TreatAsErrorFromVersion = "4", - RemoveInVersion = "5")] - protected TransportExtensions UseTransport() - where TTransport : TransportDefinition, new() - => throw new NotImplementedException(); - } - - public static partial class FunctionsHostBuilderExtensions - { - [ObsoleteEx( - TreatAsErrorFromVersion = "4", - RemoveInVersion = "5")] - public static void UseNServiceBus( - this IFunctionsHostBuilder functionsHostBuilder, - Func configurationFactory) => new NotImplementedException(); - } -} - -#pragma warning restore 1591 \ No newline at end of file diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/NServiceBus.AzureFunctions.SourceGenerator.Tests.csproj b/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/NServiceBus.AzureFunctions.SourceGenerator.Tests.csproj deleted file mode 100644 index e919a7e8..00000000 --- a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/NServiceBus.AzureFunctions.SourceGenerator.Tests.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - net6.0 - true - ..\NServiceBusTests.snk - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator/.editorconfig b/src/NServiceBus.AzureFunctions.SourceGenerator/.editorconfig deleted file mode 100644 index fcccce5b..00000000 --- a/src/NServiceBus.AzureFunctions.SourceGenerator/.editorconfig +++ /dev/null @@ -1,5 +0,0 @@ -[*.cs] - -# Justification: Not using the analzyer release tracking feature -dotnet_diagnostic.RS2008.severity = none - diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator/NServiceBus.AzureFunctions.SourceGenerator.csproj b/src/NServiceBus.AzureFunctions.SourceGenerator/NServiceBus.AzureFunctions.SourceGenerator.csproj deleted file mode 100644 index 48ef387b..00000000 --- a/src/NServiceBus.AzureFunctions.SourceGenerator/NServiceBus.AzureFunctions.SourceGenerator.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - netstandard2.0 - true - true - ..\NServiceBus.snk - false - false - - - - - - - - - - - $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0 - - - - - - - - \ No newline at end of file diff --git a/src/ServiceBus.AcceptanceTests/.editorconfig b/src/ServiceBus.AcceptanceTests/.editorconfig index 0f61b0e1..493b55ff 100644 --- a/src/ServiceBus.AcceptanceTests/.editorconfig +++ b/src/ServiceBus.AcceptanceTests/.editorconfig @@ -3,5 +3,9 @@ # Justification: Test project dotnet_diagnostic.CA2007.severity = none +# may be enabled in future +dotnet_diagnostic.PS0018.severity = suggestion # A task-returning method should have a CancellationToken parameter unless it has a parameter implementing ICancellableContext + # Justification: Tests don't support cancellation and don't need to forward IMessageHandlerContext.CancellationToken dotnet_diagnostic.NSB0002.severity = suggestion +dotnet_diagnostic.PS0013.severity = suggestion diff --git a/src/ServiceBus.AcceptanceTests/FunctionEndpointComponent.cs b/src/ServiceBus.AcceptanceTests/FunctionEndpointComponent.cs index adbe3c16..f7bda9f8 100644 --- a/src/ServiceBus.AcceptanceTests/FunctionEndpointComponent.cs +++ b/src/ServiceBus.AcceptanceTests/FunctionEndpointComponent.cs @@ -47,7 +47,7 @@ public Task CreateRunner(RunDescriptor runDescriptor) => sendsAtomicWithReceive, ServiceBusMessageActionsFactory)); - protected IList Messages { get; } = new List(); + protected IList Messages { get; } = []; protected bool DoNotFailOnErrorMessages { get; init; } @@ -204,7 +204,7 @@ public override async Task ComponentsStarted(CancellationToken cancellationToken cancellationToken); await receiver.CompleteMessageAsync(receivedMessage, cancellationToken); } - catch (Exception) + catch (Exception ex) when (ex is not OperationCanceledException || !cancellationToken.IsCancellationRequested) { await receiver.AbandonMessageAsync(receivedMessage, cancellationToken: cancellationToken); @@ -227,11 +227,11 @@ await receiver.AbandonMessageAsync(receivedMessage, } } - public override async Task Stop() + public override async Task Stop(CancellationToken cancellationToken = default) { try { - await host.StopAsync(); + await host.StopAsync(cancellationToken); if (!doNotFailOnErrorMessages) { diff --git a/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj b/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj index f84a0265..afda94e9 100644 --- a/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj +++ b/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true ..\NServiceBusTests.snk @@ -13,15 +13,15 @@ - - - - + + + + - - + + diff --git a/src/ServiceBus.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt b/src/ServiceBus.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt index 8883e515..c9533039 100644 --- a/src/ServiceBus.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt +++ b/src/ServiceBus.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt @@ -11,9 +11,6 @@ namespace NServiceBus public static class FunctionsHostBuilderExtensions { public static void UseNServiceBus(this Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder functionsHostBuilder, System.Action configurationFactory = null) { } - [System.Obsolete("The member currently throws a NotImplementedException. Will be removed in version" + - " 5.0.0.", true)] - public static void UseNServiceBus(this Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder functionsHostBuilder, System.Func configurationFactory) { } public static void UseNServiceBus(this Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder functionsHostBuilder, System.Func configurationFactory) { } public static void UseNServiceBus(this Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder functionsHostBuilder, string endpointName, System.Action configurationFactory = null) { } public static void UseNServiceBus(this Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder functionsHostBuilder, string endpointName, string connectionString, System.Action configurationFactory = null) { } @@ -46,31 +43,12 @@ namespace NServiceBus } public class ServiceBusTriggeredEndpointConfiguration { - [System.Obsolete("The member currently throws a NotImplementedException. Will be removed in version" + - " 5.0.0.", true)] - public ServiceBusTriggeredEndpointConfiguration(Microsoft.Extensions.Configuration.IConfiguration configuration) { } - [System.Obsolete("The member currently throws a NotImplementedException. Will be removed in version" + - " 5.0.0.", true)] - public ServiceBusTriggeredEndpointConfiguration(string endpointName) { } - [System.Obsolete("The member currently throws a NotImplementedException. Will be removed in version" + - " 5.0.0.", true)] - public ServiceBusTriggeredEndpointConfiguration(string endpointName, Microsoft.Extensions.Configuration.IConfiguration configuration = null) { } - [System.Obsolete("The member currently throws a NotImplementedException. Will be removed in version" + - " 5.0.0.", true)] - public ServiceBusTriggeredEndpointConfiguration(string endpointName, string connectionStringName = null) { } public NServiceBus.EndpointConfiguration AdvancedConfiguration { get; } public NServiceBus.RoutingSettings Routing { get; } - [System.Obsolete("Use `UseNServiceBus(ENDPOINTNAME, CONNECTIONSTRING)` instead. Will be removed in " + - "version 5.0.0.", true)] - public string ServiceBusConnectionString { get; set; } public NServiceBus.AzureServiceBusTransport Transport { get; } public void DoNotSendMessagesToErrorQueue() { } public void LogDiagnostics() { } public NServiceBus.Serialization.SerializationExtensions UseSerialization() where T : NServiceBus.Serialization.SerializationDefinition, new () { } - [System.Obsolete("The member currently throws a NotImplementedException. Will be removed in version" + - " 5.0.0.", true)] - protected NServiceBus.TransportExtensions UseTransport() - where TTransport : NServiceBus.Transport.TransportDefinition, new () { } } } \ No newline at end of file diff --git a/src/ServiceBus.Tests/ServiceBus.Tests.csproj b/src/ServiceBus.Tests/ServiceBus.Tests.csproj index 11bfea5a..53529e1f 100644 --- a/src/ServiceBus.Tests/ServiceBus.Tests.csproj +++ b/src/ServiceBus.Tests/ServiceBus.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true ..\NServiceBusTests.snk @@ -12,15 +12,15 @@ - - - - + + + + - - + + diff --git a/src/Testing.Handlers/Testing.Handlers.csproj b/src/Testing.Handlers/Testing.Handlers.csproj index 8e209c3d..0cb8e021 100644 --- a/src/Testing.Handlers/Testing.Handlers.csproj +++ b/src/Testing.Handlers/Testing.Handlers.csproj @@ -1,11 +1,11 @@ - net6.0 + net8.0 - +