From 3ff3f5e2b2497a791d4c7fa174699bf0f624bd04 Mon Sep 17 00:00:00 2001 From: Mauro Servienti Date: Tue, 12 Oct 2021 15:14:59 +0200 Subject: [PATCH 1/3] add multi-targeting support net core/net48 --- src/MyOtherService/MyOtherService.csproj | 2 +- src/MyService/MyService.csproj | 2 +- src/MySystem.AcceptanceTests/DockerCompose.cs | 20 ++- .../MySystem.AcceptanceTests.csproj | 6 +- ...rviceBus.AssemblyScanner.Extensions.csproj | 2 +- ...tegrationTesting.Tests.TestEndpoint.csproj | 2 +- .../API/ApiApprovals.cs | 7 + .../APIApprovals.Approve_API.approved.txt | 124 ++++++++++++++++++ .../APIApprovals.Approve_API.approved.txt | 0 ...ServiceBus.IntegrationTesting.Tests.csproj | 2 +- .../NServiceBus.IntegrationTesting.csproj | 2 +- 11 files changed, 160 insertions(+), 9 deletions(-) create mode 100644 src/NServiceBus.IntegrationTesting.Tests/API/NET48/APIApprovals.Approve_API.approved.txt rename src/NServiceBus.IntegrationTesting.Tests/API/{ => NETCOREAPP}/APIApprovals.Approve_API.approved.txt (100%) diff --git a/src/MyOtherService/MyOtherService.csproj b/src/MyOtherService/MyOtherService.csproj index 5f741fd8..c2ead6bf 100644 --- a/src/MyOtherService/MyOtherService.csproj +++ b/src/MyOtherService/MyOtherService.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + netcoreapp3.1;net48 latest diff --git a/src/MyService/MyService.csproj b/src/MyService/MyService.csproj index 7b9d131e..d7a97bf9 100644 --- a/src/MyService/MyService.csproj +++ b/src/MyService/MyService.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + netcoreapp3.1;net48 latest diff --git a/src/MySystem.AcceptanceTests/DockerCompose.cs b/src/MySystem.AcceptanceTests/DockerCompose.cs index 6606c866..757cb70a 100644 --- a/src/MySystem.AcceptanceTests/DockerCompose.cs +++ b/src/MySystem.AcceptanceTests/DockerCompose.cs @@ -1,8 +1,15 @@ using System; -using System.Net.Http; using System.Threading.Tasks; using static SimpleExec.Command; +#if NETCOREAPP +using System.Net.Http; +#endif + +#if NET48 +using System.Net; +#endif + namespace MySystem.AcceptanceTests { public static class DockerCompose @@ -16,9 +23,18 @@ static async Task statusChecker() { try { + var managementUrl = "http://localhost:15672/"; +#if NETCOREAPP using var client = new HttpClient(); - var response = await client.GetAsync("http://localhost:15672/"); + var response = await client.GetAsync(managementUrl); return response.IsSuccessStatusCode; +#endif + +#if NET48 + var request = HttpWebRequest.Create(managementUrl); + var response = await request.GetResponseAsync(); + return ((HttpWebResponse)response).StatusCode == HttpStatusCode.OK; +#endif } catch { diff --git a/src/MySystem.AcceptanceTests/MySystem.AcceptanceTests.csproj b/src/MySystem.AcceptanceTests/MySystem.AcceptanceTests.csproj index 4eb25e66..69f1d3ff 100644 --- a/src/MySystem.AcceptanceTests/MySystem.AcceptanceTests.csproj +++ b/src/MySystem.AcceptanceTests/MySystem.AcceptanceTests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netcoreapp3.1;net48 false @@ -15,6 +15,10 @@ + + + + diff --git a/src/NServiceBus.AssemblyScanner.Extensions/NServiceBus.AssemblyScanner.Extensions.csproj b/src/NServiceBus.AssemblyScanner.Extensions/NServiceBus.AssemblyScanner.Extensions.csproj index a75a094d..954c5741 100644 --- a/src/NServiceBus.AssemblyScanner.Extensions/NServiceBus.AssemblyScanner.Extensions.csproj +++ b/src/NServiceBus.AssemblyScanner.Extensions/NServiceBus.AssemblyScanner.Extensions.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netcoreapp3.1;net48 diff --git a/src/NServiceBus.IntegrationTesting.Tests.TestEndpoint/NServiceBus.IntegrationTesting.Tests.TestEndpoint.csproj b/src/NServiceBus.IntegrationTesting.Tests.TestEndpoint/NServiceBus.IntegrationTesting.Tests.TestEndpoint.csproj index 2b80b393..d574bac0 100644 --- a/src/NServiceBus.IntegrationTesting.Tests.TestEndpoint/NServiceBus.IntegrationTesting.Tests.TestEndpoint.csproj +++ b/src/NServiceBus.IntegrationTesting.Tests.TestEndpoint/NServiceBus.IntegrationTesting.Tests.TestEndpoint.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + netcoreapp3.1;net48 latest diff --git a/src/NServiceBus.IntegrationTesting.Tests/API/ApiApprovals.cs b/src/NServiceBus.IntegrationTesting.Tests/API/ApiApprovals.cs index 31513c33..5595e891 100644 --- a/src/NServiceBus.IntegrationTesting.Tests/API/ApiApprovals.cs +++ b/src/NServiceBus.IntegrationTesting.Tests/API/ApiApprovals.cs @@ -1,5 +1,6 @@ using System.Runtime.CompilerServices; using ApprovalTests; +using ApprovalTests.Namers; using ApprovalTests.Reporters; using NUnit.Framework; using PublicApiGenerator; @@ -11,6 +12,12 @@ public class APIApprovals [Test] [UseReporter(typeof(DiffReporter))] [MethodImpl(MethodImplOptions.NoInlining)] +#if NETCOREAPP + [UseApprovalSubdirectory("NETCOREAPP")] +#endif +#if NET48 + [UseApprovalSubdirectory("NET48")] +#endif public void Approve_API() { var publicApi = typeof(IntegrationScenarioContext).Assembly.GeneratePublicApi(); diff --git a/src/NServiceBus.IntegrationTesting.Tests/API/NET48/APIApprovals.Approve_API.approved.txt b/src/NServiceBus.IntegrationTesting.Tests/API/NET48/APIApprovals.Approve_API.approved.txt new file mode 100644 index 00000000..18fe3bd8 --- /dev/null +++ b/src/NServiceBus.IntegrationTesting.Tests/API/NET48/APIApprovals.Approve_API.approved.txt @@ -0,0 +1,124 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/mauroservienti/NServiceBus.IntegrationTesting.git")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("NServiceBus.IntegrationTesting.Tests")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName=".NET Framework 4.8")] +namespace NServiceBus.IntegrationTesting +{ + public class EmptyTestCompletionHandler : NServiceBus.IntegrationTesting.IHandleTestCompletion + { + public EmptyTestCompletionHandler() { } + public System.Threading.Tasks.Task OnTestCompleted(NServiceBus.AcceptanceTesting.Support.RunSummary summary) { } + } + public static class EndpointConfigurationExtensions + { + public static void RegisterRequiredPipelineBehaviors(this NServiceBus.EndpointConfiguration builder, string endpointName, NServiceBus.IntegrationTesting.IntegrationScenarioContext integrationScenarioContext) { } + public static void RegisterScenarioContext(this NServiceBus.EndpointConfiguration builder, NServiceBus.AcceptanceTesting.ScenarioContext scenarioContext) { } + } + public abstract class EndpointTemplate : NServiceBus.AcceptanceTesting.Support.IEndpointSetupTemplate + { + protected EndpointTemplate() { } + public System.Threading.Tasks.Task GetConfiguration(NServiceBus.AcceptanceTesting.Support.RunDescriptor runDescriptor, NServiceBus.AcceptanceTesting.Support.EndpointCustomizationConfiguration endpointCustomizationConfiguration, System.Action configurationBuilderCustomization) { } + protected abstract System.Threading.Tasks.Task OnGetConfiguration(NServiceBus.AcceptanceTesting.Support.RunDescriptor runDescriptor, NServiceBus.AcceptanceTesting.Support.EndpointCustomizationConfiguration endpointCustomizationConfiguration, System.Action configurationBuilderCustomization); + } + public class EndpointTemplate : NServiceBus.IntegrationTesting.EndpointTemplate + where T : NServiceBus.EndpointConfiguration, new () + { + public EndpointTemplate() { } + protected override System.Threading.Tasks.Task OnGetConfiguration(NServiceBus.AcceptanceTesting.Support.RunDescriptor runDescriptor, NServiceBus.AcceptanceTesting.Support.EndpointCustomizationConfiguration endpointCustomizationConfiguration, System.Action configurationBuilderCustomization) { } + } + public class EndpointTemplate : NServiceBus.IntegrationTesting.EndpointTemplate + where T : NServiceBus.EndpointConfiguration, new () + where C : NServiceBus.IntegrationTesting.IHandleTestCompletion, new () + { + public EndpointTemplate() { } + protected override System.Threading.Tasks.Task OnGetConfiguration(NServiceBus.AcceptanceTesting.Support.RunDescriptor runDescriptor, NServiceBus.AcceptanceTesting.Support.EndpointCustomizationConfiguration endpointConfiguration, System.Action configurationBuilderCustomization) { } + } + public class GenericHostEndpointBehaviorBuilder + where TContext : NServiceBus.AcceptanceTesting.ScenarioContext + { + public GenericHostEndpointBehaviorBuilder() { } + public System.Collections.Generic.IList Whens { get; } + public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder When(System.Func action) { } + public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder When(System.Func action) { } + public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder When(System.Func> condition, System.Func action) { } + public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder When(System.Func> condition, System.Func action) { } + public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder When(System.Predicate condition, System.Func action) { } + public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder When(System.Predicate condition, System.Func action) { } + } + public class HandlerInvocation : NServiceBus.IntegrationTesting.Invocation + { + public HandlerInvocation() { } + public System.Type HandlerType { get; } + } + public interface IHandleTestCompletion + { + System.Threading.Tasks.Task OnTestCompleted(NServiceBus.AcceptanceTesting.Support.RunSummary summary); + } + public class IntegrationScenarioContext : NServiceBus.AcceptanceTesting.ScenarioContext + { + public IntegrationScenarioContext() { } + public System.Collections.Generic.IEnumerable InvokedHandlers { get; } + public System.Collections.Generic.IEnumerable InvokedSagas { get; } + public System.Collections.Generic.IEnumerable OutgoingMessageOperations { get; } + public bool HandlerWasInvoked() { } + public bool HasFailedMessages() { } + public bool HasHandlingErrors() { } + public bool MessageWasProcessed() { } + public bool MessageWasProcessedByHandler() { } + public bool MessageWasProcessedBySaga() { } + public void RegisterTimeoutRescheduleRule(System.Func rule) { } + public bool SagaWasCompleted() + where TSaga : NServiceBus.Saga { } + public bool SagaWasInvoked() + where TSaga : NServiceBus.Saga { } + } + public abstract class Invocation + { + protected Invocation() { } + public string EndpointName { get; } + public System.Exception HandlingError { get; } + public object Message { get; } + public System.Type MessageType { get; } + } + public abstract class OutgoingMessageOperation + { + protected OutgoingMessageOperation() { } + public System.Collections.Generic.Dictionary MessageHeaders { get; } + public string MessageId { get; } + public object MessageInstance { get; } + public System.Type MessageType { get; } + public System.Exception OperationError { get; } + public string SenderEndpoint { get; } + } + public class PublishOperation : NServiceBus.IntegrationTesting.OutgoingMessageOperation + { + public PublishOperation() { } + } + public class ReplyOperation : NServiceBus.IntegrationTesting.OutgoingMessageOperation + { + public ReplyOperation() { } + } + public class RequestTimeoutOperation : NServiceBus.IntegrationTesting.SendOperation + { + public RequestTimeoutOperation() { } + public string SagaId { get; } + public string SagaTypeAssemblyQualifiedName { get; } + } + public class SagaInvocation : NServiceBus.IntegrationTesting.Invocation + { + public SagaInvocation() { } + public bool IsCompleted { get; } + public bool IsNew { get; } + public bool NotFound { get; } + public NServiceBus.IContainSagaData SagaData { get; } + public System.Type SagaType { get; } + } + public static class ScenarioWithEndpointBehaviorExtensions + { + public static NServiceBus.AcceptanceTesting.Support.IScenarioWithEndpointBehavior WithGenericHostEndpoint(this NServiceBus.AcceptanceTesting.Support.IScenarioWithEndpointBehavior scenarioWithEndpoint, string endpointName, System.Func, Microsoft.Extensions.Hosting.IHost> hostBuilder, System.Action> behavior = null) + where TContext : NServiceBus.AcceptanceTesting.ScenarioContext { } + } + public class SendOperation : NServiceBus.IntegrationTesting.OutgoingMessageOperation + { + public SendOperation() { } + } +} \ No newline at end of file diff --git a/src/NServiceBus.IntegrationTesting.Tests/API/APIApprovals.Approve_API.approved.txt b/src/NServiceBus.IntegrationTesting.Tests/API/NETCOREAPP/APIApprovals.Approve_API.approved.txt similarity index 100% rename from src/NServiceBus.IntegrationTesting.Tests/API/APIApprovals.Approve_API.approved.txt rename to src/NServiceBus.IntegrationTesting.Tests/API/NETCOREAPP/APIApprovals.Approve_API.approved.txt diff --git a/src/NServiceBus.IntegrationTesting.Tests/NServiceBus.IntegrationTesting.Tests.csproj b/src/NServiceBus.IntegrationTesting.Tests/NServiceBus.IntegrationTesting.Tests.csproj index 756e7873..f190414e 100644 --- a/src/NServiceBus.IntegrationTesting.Tests/NServiceBus.IntegrationTesting.Tests.csproj +++ b/src/NServiceBus.IntegrationTesting.Tests/NServiceBus.IntegrationTesting.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + netcoreapp3.1;net48 diff --git a/src/NServiceBus.IntegrationTesting/NServiceBus.IntegrationTesting.csproj b/src/NServiceBus.IntegrationTesting/NServiceBus.IntegrationTesting.csproj index ed2e84d7..db3ad607 100644 --- a/src/NServiceBus.IntegrationTesting/NServiceBus.IntegrationTesting.csproj +++ b/src/NServiceBus.IntegrationTesting/NServiceBus.IntegrationTesting.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netcoreapp3.1;net48 From b9ee31b7c2663a7660913c2abdbb13468d00a751 Mon Sep 17 00:00:00 2001 From: Mauro Servienti Date: Thu, 14 Oct 2021 22:01:19 +0200 Subject: [PATCH 2/3] Use build matrix --- appveyor.yml | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 5ed497a4..8f326ca5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,7 @@ version: '{build}' -image: ubuntu2004 +image: +- ubuntu2004 +- Visual Studio 2019 skip_branch_with_pr: true pull_requests: @@ -15,17 +17,6 @@ branches: - /release-.*/ - /^\d+\.\d+\.\d+(-\S*)?$/ -skip_commits: - files: - - '**/*.source.md' - -before_build: -- sh: sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose -- sh: sudo chmod +x /usr/local/bin/docker-compose - -build_script: -- sh: ./build.sh - artifacts: - path: ./**/*.nupkg type: NuGetPackage @@ -34,3 +25,27 @@ artifacts: test: off deploy: off + +for: +- + matrix: + only: + - image: ubuntu2004 + + before_build: + - sh: sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + - sh: sudo chmod +x /usr/local/bin/docker-compose + + build_script: + - sh: ./build.sh + +- + matrix: + only: + - image: Visual Studio 2019 + + before_build: + - cmd: docker-switch-linux + + build_script: + - cmd: .\build.cmd From 9c5b9b5b2cc81799025489a8d5cecbec1de3a451 Mon Sep 17 00:00:00 2001 From: Mauro Servienti Date: Sat, 16 Oct 2021 17:13:38 +0200 Subject: [PATCH 3/3] on Unix only tests against .NET Core --- targets/Program.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/targets/Program.cs b/targets/Program.cs index 6423ed70..082f71fe 100644 --- a/targets/Program.cs +++ b/targets/Program.cs @@ -12,6 +12,8 @@ public static void Main(string[] args) var sourceDir = "src"; var sdk = new DotnetSdkManager(); + var isUnix = Environment.OSVersion.Platform == PlatformID.Unix; + var unixFx = "netcoreapp3.1"; Target("default", DependsOn("test")); @@ -21,7 +23,7 @@ public static void Main(string[] args) Target("test", DependsOn("build"), Directory.EnumerateFiles(sourceDir, "*Tests.csproj", SearchOption.AllDirectories), - proj => Run(sdk.GetDotnetCliPath(), $"test \"{proj}\" --configuration Release --no-build")); + proj => Run(sdk.GetDotnetCliPath(), $"test \"{proj}\" {(isUnix ? "--framework " + unixFx : "")} --configuration Release --no-build")); RunTargetsAndExit(args); }