From 6bc06a9ed22b17688d3e2acdc02554426acfb392 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 4 Sep 2017 00:15:42 +1000 Subject: [PATCH 1/6] update to v7 --- GitVersion.yml | 7 + .../nuget/nservicebus.filebasedrouting.nuspec | 28 ---- src/Contracts/Contracts.csproj | 54 +------ src/Contracts/packages.config | 4 - src/Directory.Build.props | 36 +++++ src/Directory.Build.targets | 22 +++ src/EndpointA/App.config | 6 - src/EndpointA/DemoCommandReceivedHandler.cs | 11 +- src/EndpointA/EndpointA.csproj | 77 +-------- src/EndpointA/Program.cs | 82 +++++----- src/EndpointA/packages.config | 4 - src/EndpointB/Configuration.cs | 43 +++-- src/EndpointB/DemoCommandHandler.cs | 13 +- src/EndpointB/DemoEventHandler.cs | 13 +- src/EndpointB_1/App.config | 6 - src/EndpointB_1/EndpointB_1.csproj | 68 +------- src/EndpointB_1/Program.cs | 13 +- src/EndpointB_1/packages.config | 4 - src/EndpointB_2/App.config | 6 - src/EndpointB_2/EndpointB_2.csproj | 68 +------- src/EndpointB_2/Program.cs | 13 +- src/EndpointB_2/packages.config | 4 - ...us.FileBasedRouting.Tests.Contracts.csproj | 59 ------- .../EndpointBasedIntegrationTests.cs | 113 ------------- .../NServiceBus.FileBasedRouting.Tests.csproj | 79 ---------- .../XmlRoutingFileAccessTests.cs | 77 --------- .../XmlRoutingFileTests.cs | 149 ------------------ .../packages.config | 5 - src/NServiceBus.FileBasedRouting.sln | 23 +-- ...erviceBus.FileBasedRouting.sln.DotSettings | 3 +- .../FileBasedRoutingConfigExtensions.cs | 7 +- .../FileBasedRoutingFeature.cs | 4 +- .../InternalsVisible.cs | 3 + .../NServiceBus.FileBasedRouting.csproj | 80 ++-------- .../Properties/AssemblyInfo.cs | 4 - .../SubscribeTerminator.cs | 2 +- .../UnicastSubscriberTable.cs | 6 +- .../UnsubscribeTerminator.cs | 2 +- .../XmlRoutingFileParser.cs | 5 +- .../packages.config | 6 - src/NServiceBus.snk | Bin 0 -> 596 bytes .../C.cs | 2 +- .../Commands/A.cs | 0 .../Commands/B.cs | 0 .../D.cs | 0 src/Tests.Contracts/Tests.Contracts.csproj | 18 +++ src/Tests/EndpointBasedIntegrationTests.cs | 117 ++++++++++++++ src/Tests/Tests.csproj | 23 +++ src/Tests/XmlRoutingFileAccessTests.cs | 75 +++++++++ src/Tests/XmlRoutingFileTests.cs | 146 +++++++++++++++++ 50 files changed, 597 insertions(+), 993 deletions(-) create mode 100644 GitVersion.yml delete mode 100644 packaging/nuget/nservicebus.filebasedrouting.nuspec delete mode 100644 src/Contracts/packages.config create mode 100644 src/Directory.Build.props create mode 100644 src/Directory.Build.targets delete mode 100644 src/EndpointA/App.config delete mode 100644 src/EndpointA/packages.config delete mode 100644 src/EndpointB_1/App.config delete mode 100644 src/EndpointB_1/packages.config delete mode 100644 src/EndpointB_2/App.config delete mode 100644 src/EndpointB_2/packages.config delete mode 100644 src/NServiceBus.FileBasedRouting.Tests.Contracts/NServiceBus.FileBasedRouting.Tests.Contracts.csproj delete mode 100644 src/NServiceBus.FileBasedRouting.Tests/EndpointBasedIntegrationTests.cs delete mode 100644 src/NServiceBus.FileBasedRouting.Tests/NServiceBus.FileBasedRouting.Tests.csproj delete mode 100644 src/NServiceBus.FileBasedRouting.Tests/XmlRoutingFileAccessTests.cs delete mode 100644 src/NServiceBus.FileBasedRouting.Tests/XmlRoutingFileTests.cs delete mode 100644 src/NServiceBus.FileBasedRouting.Tests/packages.config create mode 100644 src/NServiceBus.FileBasedRouting/InternalsVisible.cs delete mode 100644 src/NServiceBus.FileBasedRouting/Properties/AssemblyInfo.cs delete mode 100644 src/NServiceBus.FileBasedRouting/packages.config create mode 100644 src/NServiceBus.snk rename src/{NServiceBus.FileBasedRouting.Tests.Contracts => Tests.Contracts}/C.cs (91%) rename src/{NServiceBus.FileBasedRouting.Tests.Contracts => Tests.Contracts}/Commands/A.cs (100%) rename src/{NServiceBus.FileBasedRouting.Tests.Contracts => Tests.Contracts}/Commands/B.cs (100%) rename src/{NServiceBus.FileBasedRouting.Tests.Contracts => Tests.Contracts}/D.cs (100%) create mode 100644 src/Tests.Contracts/Tests.Contracts.csproj create mode 100644 src/Tests/EndpointBasedIntegrationTests.cs create mode 100644 src/Tests/Tests.csproj create mode 100644 src/Tests/XmlRoutingFileAccessTests.cs create mode 100644 src/Tests/XmlRoutingFileTests.cs diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..5b6aab4 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,7 @@ +assembly-versioning-scheme: Major +next-version: 2.0 +branches: + develop: + tag: beta + release: + tag: rc \ No newline at end of file diff --git a/packaging/nuget/nservicebus.filebasedrouting.nuspec b/packaging/nuget/nservicebus.filebasedrouting.nuspec deleted file mode 100644 index ccf08d3..0000000 --- a/packaging/nuget/nservicebus.filebasedrouting.nuspec +++ /dev/null @@ -1,28 +0,0 @@ - - - - NServiceBus.FileBasedRouting - NServiceBus.FileBasedRouting - $version$ - $authors$ - $owners$ - $licenseUrl$ - $projectUrl$ - $iconUrl$ - $requireLicenseAcceptance$ - NServiceBus support for defining message routing via XML file - - $copyright$ - nservicebus servicebus msmq cqrs publish subscribe - - - - - - - - - - - - diff --git a/src/Contracts/Contracts.csproj b/src/Contracts/Contracts.csproj index 489ab3a..f04dae3 100644 --- a/src/Contracts/Contracts.csproj +++ b/src/Contracts/Contracts.csproj @@ -1,39 +1,10 @@  - - + - Debug - AnyCPU - {FB64C215-540A-4ED1-901F-1E0A242D0908} - Library - Properties - Contracts - Contracts - v4.6 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + net452 - - ..\packages\NServiceBus.6.1.0\lib\net452\NServiceBus.Core.dll - True - + @@ -43,23 +14,4 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Contracts/packages.config b/src/Contracts/packages.config deleted file mode 100644 index 676ea57..0000000 --- a/src/Contracts/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..a2abd0e --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,36 @@ + + + + true + 7.1 + + + + + true + false + false + false + + + + + 4.0.0-* + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets new file mode 100644 index 0000000..dd52f13 --- /dev/null +++ b/src/Directory.Build.targets @@ -0,0 +1,22 @@ + + + + NServiceBus Ltd + NServiceBus Ltd + http://particular.net/LicenseAgreement + true + Copyright 2010-$([System.DateTime]::UtcNow.ToString(yyyy)) NServiceBus. All rights reserved + nservicebus servicebus msmq cqrs publish subscribe + http://s3.amazonaws.com/nuget.images/NServiceBus_32.png + https://docs.particular.net/nuget/$(PackageId) + ..\..\nugets + $(TargetsForTfmSpecificContentInPackage);IncludePDBsInPackage + + + + + + + + + \ No newline at end of file diff --git a/src/EndpointA/App.config b/src/EndpointA/App.config deleted file mode 100644 index 8324aa6..0000000 --- a/src/EndpointA/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/EndpointA/DemoCommandReceivedHandler.cs b/src/EndpointA/DemoCommandReceivedHandler.cs index ed4279b..1c4eeb2 100644 --- a/src/EndpointA/DemoCommandReceivedHandler.cs +++ b/src/EndpointA/DemoCommandReceivedHandler.cs @@ -3,14 +3,11 @@ using Contracts.Events; using NServiceBus; -namespace EndpointA +public class DemoCommandReceivedHandler : IHandleMessages { - public class DemoCommandReceivedHandler : IHandleMessages + public Task Handle(DemoCommandReceived message, IMessageHandlerContext context) { - public Task Handle(DemoCommandReceived message, IMessageHandlerContext context) - { - Console.WriteLine($"Received {nameof(DemoCommandReceived)} for command {message.ReceivedCommandId}"); - return Task.CompletedTask; - } + Console.WriteLine($"Received {nameof(DemoCommandReceived)} for command {message.ReceivedCommandId}"); + return Task.FromResult(0); } } \ No newline at end of file diff --git a/src/EndpointA/EndpointA.csproj b/src/EndpointA/EndpointA.csproj index 8f73140..f32886f 100644 --- a/src/EndpointA/EndpointA.csproj +++ b/src/EndpointA/EndpointA.csproj @@ -1,42 +1,12 @@  - - + - Debug - AnyCPU - {8B25A222-B70F-490C-8EF4-E8B788563176} + net452 Exe - Properties - EndpointA - EndpointA - v4.6 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - ..\packages\NServiceBus.6.1.0\lib\net452\NServiceBus.Core.dll - True - + + @@ -45,42 +15,7 @@ + + - - - - - - - - - - - {fb64c215-540a-4ed1-901f-1e0a242d0908} - Contracts - - - {b6417ca5-3892-4c53-8356-31018692ae35} - NServiceBus.FileBasedRouting - - - - - Always - - - Always - - - - - - - \ No newline at end of file diff --git a/src/EndpointA/Program.cs b/src/EndpointA/Program.cs index 6181e29..fdf21b2 100644 --- a/src/EndpointA/Program.cs +++ b/src/EndpointA/Program.cs @@ -5,57 +5,61 @@ using NServiceBus; using NServiceBus.FileBasedRouting; -namespace EndpointA +class Program { - class Program + static async Task Main() { - static void Main(string[] args) - { - AsyncMain().GetAwaiter().GetResult(); - } - - static async Task AsyncMain() - { - var endpointConfiguration = new EndpointConfiguration("endpointA"); + var endpointConfiguration = new EndpointConfiguration("endpointA"); - endpointConfiguration.UsePersistence(); - endpointConfiguration.SendFailedMessagesTo("error"); + endpointConfiguration.UsePersistence(); + endpointConfiguration.SendFailedMessagesTo("error"); - var routingConfig = endpointConfiguration.UseTransport().Routing(); - routingConfig.RegisterPublisher(typeof(DemoCommandReceived), "endpointB"); - routingConfig.InstanceMappingFile().FilePath("instance-mapping.xml"); - routingConfig.UseFileBasedRouting(); + var routingConfig = endpointConfiguration.UseTransport().Routing(); + routingConfig.RegisterPublisher(typeof(DemoCommandReceived), "endpointB"); + routingConfig.InstanceMappingFile().FilePath("instance-mapping.xml"); + routingConfig.UseFileBasedRouting(); - var endpoint = await Endpoint.Start(endpointConfiguration); + var endpoint = await Endpoint.Start(endpointConfiguration) + .ConfigureAwait(false); - Console.WriteLine("Press [c] to send a command. Press [e] to publish an event. Press [Esc] to quit."); + Console.WriteLine("Press [c] to send a command. Press [e] to publish an event. Press [Esc] to quit."); - while (true) + while (true) + { + var key = Console.ReadKey(); + if (key.Key == ConsoleKey.Escape) { - var key = Console.ReadKey(); - if (key.Key == ConsoleKey.Escape) - { - break; - } + break; + } - if (key.Key == ConsoleKey.C) + if (key.Key == ConsoleKey.C) + { + var commandId = Guid.NewGuid(); + var demoCommand = new DemoCommand { - var commandId = Guid.NewGuid(); - await endpoint.Send(new DemoCommand { CommandId = commandId }); - Console.WriteLine(); - Console.WriteLine("Sent command with id: " + commandId); - } + CommandId = commandId + }; + await endpoint.Send(demoCommand) + .ConfigureAwait(false); + Console.WriteLine(); + Console.WriteLine("Sent command with id: " + commandId); + } - if (key.Key == ConsoleKey.E) + if (key.Key == ConsoleKey.E) + { + var eventId = Guid.NewGuid(); + var demoEvent = new DemoEvent { - var eventId = Guid.NewGuid(); - await endpoint.Publish(new DemoEvent() { EventId = eventId }); - Console.WriteLine(); - Console.WriteLine("Sent event with id: " + eventId); - } + EventId = eventId + }; + await endpoint.Publish(demoEvent) + .ConfigureAwait(false); + Console.WriteLine(); + Console.WriteLine("Sent event with id: " + eventId); } - - await endpoint.Stop(); } + + await endpoint.Stop() + .ConfigureAwait(false); } -} +} \ No newline at end of file diff --git a/src/EndpointA/packages.config b/src/EndpointA/packages.config deleted file mode 100644 index 676ea57..0000000 --- a/src/EndpointA/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/EndpointB/Configuration.cs b/src/EndpointB/Configuration.cs index 31ea73b..cfb554d 100644 --- a/src/EndpointB/Configuration.cs +++ b/src/EndpointB/Configuration.cs @@ -4,36 +4,35 @@ using NServiceBus; using NServiceBus.FileBasedRouting; -namespace EndpointB +static class Configuration { - static class Configuration + public static async Task Start(string discriminator) { - public static async Task Start(string discriminator) - { - var endpointConfiguration = new EndpointConfiguration("endpointB"); - endpointConfiguration.MakeInstanceUniquelyAddressable(discriminator); + var endpointConfiguration = new EndpointConfiguration("endpointB"); + endpointConfiguration.MakeInstanceUniquelyAddressable(discriminator); - endpointConfiguration.UsePersistence(); - endpointConfiguration.SendFailedMessagesTo("error"); + endpointConfiguration.UsePersistence(); + endpointConfiguration.SendFailedMessagesTo("error"); - var routingConfig = endpointConfiguration.UseTransport().Routing(); - routingConfig.RegisterPublisher(typeof(DemoEvent), "endpointA"); - routingConfig.UseFileBasedRouting(); + var routingConfig = endpointConfiguration.UseTransport().Routing(); + routingConfig.RegisterPublisher(typeof(DemoEvent), "endpointA"); + routingConfig.UseFileBasedRouting(); - var endpoint = await Endpoint.Start(endpointConfiguration); + var endpoint = await Endpoint.Start(endpointConfiguration) + .ConfigureAwait(false); - Console.WriteLine("Press [Esc] to quit."); + Console.WriteLine("Press [Esc] to quit."); - while (true) + while (true) + { + var key = Console.ReadKey(); + if (key.Key == ConsoleKey.Escape) { - var key = Console.ReadKey(); - if (key.Key == ConsoleKey.Escape) - { - break; - } + break; } - - await endpoint.Stop(); } + + await endpoint.Stop() + .ConfigureAwait(false); } -} +} \ No newline at end of file diff --git a/src/EndpointB/DemoCommandHandler.cs b/src/EndpointB/DemoCommandHandler.cs index 53f2f6c..d52b381 100644 --- a/src/EndpointB/DemoCommandHandler.cs +++ b/src/EndpointB/DemoCommandHandler.cs @@ -4,14 +4,15 @@ using Contracts.Events; using NServiceBus; -namespace EndpointB +class DemoCommandHandler : IHandleMessages { - class DemoCommandHandler : IHandleMessages + public Task Handle(DemoCommand message, IMessageHandlerContext context) { - public Task Handle(DemoCommand message, IMessageHandlerContext context) + Console.WriteLine($"Received {nameof(DemoCommand)} {message.CommandId}"); + var commandReceived = new DemoCommandReceived { - Console.WriteLine($"Received {nameof(DemoCommand)} {message.CommandId}"); - return context.Publish(new DemoCommandReceived { ReceivedCommandId = message.CommandId }); - } + ReceivedCommandId = message.CommandId + }; + return context.Publish(commandReceived); } } diff --git a/src/EndpointB/DemoEventHandler.cs b/src/EndpointB/DemoEventHandler.cs index ed1ae1a..5c6c9f0 100644 --- a/src/EndpointB/DemoEventHandler.cs +++ b/src/EndpointB/DemoEventHandler.cs @@ -3,14 +3,11 @@ using Contracts.Events; using NServiceBus; -namespace EndpointB +class DemoEventHandler : IHandleMessages { - class DemoEventHandler : IHandleMessages + public Task Handle(DemoEvent message, IMessageHandlerContext context) { - public Task Handle(DemoEvent message, IMessageHandlerContext context) - { - Console.WriteLine($"Received {nameof(DemoEvent)} {message.EventId}"); - return Task.CompletedTask; - } + Console.WriteLine($"Received {nameof(DemoEvent)} {message.EventId}"); + return Task.FromResult(0); } -} +} \ No newline at end of file diff --git a/src/EndpointB_1/App.config b/src/EndpointB_1/App.config deleted file mode 100644 index 8324aa6..0000000 --- a/src/EndpointB_1/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/EndpointB_1/EndpointB_1.csproj b/src/EndpointB_1/EndpointB_1.csproj index bd44781..871025f 100644 --- a/src/EndpointB_1/EndpointB_1.csproj +++ b/src/EndpointB_1/EndpointB_1.csproj @@ -1,42 +1,12 @@  - - + - Debug - AnyCPU - {EB4B2281-8C83-4BAB-B35B-A30C94B939FE} + net452 Exe - Properties - EndpointB_1 - EndpointB_1 - v4.6 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - ..\packages\NServiceBus.6.1.0\lib\net452\NServiceBus.Core.dll - True - + + @@ -45,23 +15,8 @@ - - - - - - - - - - - {fb64c215-540a-4ed1-901f-1e0a242d0908} - Contracts - - - {b6417ca5-3892-4c53-8356-31018692ae35} - NServiceBus.FileBasedRouting - + + @@ -69,16 +24,5 @@ Always - - - - - \ No newline at end of file diff --git a/src/EndpointB_1/Program.cs b/src/EndpointB_1/Program.cs index 3d4eb39..2ea00a0 100644 --- a/src/EndpointB_1/Program.cs +++ b/src/EndpointB_1/Program.cs @@ -1,12 +1,9 @@ -using EndpointB; +using System.Threading.Tasks; -namespace EndpointB_1 +class Program { - class Program + static Task Main() { - static void Main(string[] args) - { - Configuration.Start("1").GetAwaiter().GetResult(); - } + return Configuration.Start("1"); } -} +} \ No newline at end of file diff --git a/src/EndpointB_1/packages.config b/src/EndpointB_1/packages.config deleted file mode 100644 index 676ea57..0000000 --- a/src/EndpointB_1/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/EndpointB_2/App.config b/src/EndpointB_2/App.config deleted file mode 100644 index 8324aa6..0000000 --- a/src/EndpointB_2/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/EndpointB_2/EndpointB_2.csproj b/src/EndpointB_2/EndpointB_2.csproj index 7fe56b4..871025f 100644 --- a/src/EndpointB_2/EndpointB_2.csproj +++ b/src/EndpointB_2/EndpointB_2.csproj @@ -1,42 +1,12 @@  - - + - Debug - AnyCPU - {9B21E30F-61C0-4404-BB18-88CEBC69122C} + net452 Exe - Properties - EndpointB_2 - EndpointB_2 - v4.6 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - ..\packages\NServiceBus.6.1.0\lib\net452\NServiceBus.Core.dll - True - + + @@ -45,23 +15,8 @@ - - - - - - - - - - - {fb64c215-540a-4ed1-901f-1e0a242d0908} - Contracts - - - {b6417ca5-3892-4c53-8356-31018692ae35} - NServiceBus.FileBasedRouting - + + @@ -69,16 +24,5 @@ Always - - - - - \ No newline at end of file diff --git a/src/EndpointB_2/Program.cs b/src/EndpointB_2/Program.cs index 39751dc..bc287b9 100644 --- a/src/EndpointB_2/Program.cs +++ b/src/EndpointB_2/Program.cs @@ -1,12 +1,9 @@ -using EndpointB; +using System.Threading.Tasks; -namespace EndpointB_2 +class Program { - class Program + static Task Main() { - static void Main(string[] args) - { - Configuration.Start("2").GetAwaiter().GetResult(); - } + return Configuration.Start("2"); } -} +} \ No newline at end of file diff --git a/src/EndpointB_2/packages.config b/src/EndpointB_2/packages.config deleted file mode 100644 index 676ea57..0000000 --- a/src/EndpointB_2/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting.Tests.Contracts/NServiceBus.FileBasedRouting.Tests.Contracts.csproj b/src/NServiceBus.FileBasedRouting.Tests.Contracts/NServiceBus.FileBasedRouting.Tests.Contracts.csproj deleted file mode 100644 index e9478bb..0000000 --- a/src/NServiceBus.FileBasedRouting.Tests.Contracts/NServiceBus.FileBasedRouting.Tests.Contracts.csproj +++ /dev/null @@ -1,59 +0,0 @@ - - - - - Debug - AnyCPU - {88F2D59F-CE5D-4BD5-B9EB-494A2728AD98} - Library - Properties - NServiceBus.FileBasedRouting.Tests.Contracts - NServiceBus.FileBasedRouting.Tests.Contracts - v4.6 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting.Tests/EndpointBasedIntegrationTests.cs b/src/NServiceBus.FileBasedRouting.Tests/EndpointBasedIntegrationTests.cs deleted file mode 100644 index 684b4e8..0000000 --- a/src/NServiceBus.FileBasedRouting.Tests/EndpointBasedIntegrationTests.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.IO; -using System.Reflection; -using System.Threading.Tasks; -using NServiceBus.Configuration.AdvanceExtensibility; -using NServiceBus.FileBasedRouting.Tests.Contracts.Commands; -using NServiceBus.Routing; -using NUnit.Framework; - -namespace NServiceBus.FileBasedRouting.Tests -{ - public class EndpointBasedIntegrationTests - { - const string XmlA = @" - - - - - - - - "; - const string XmlB = @" - - - - - - - - "; - const string EndpointName = "EndpointName"; - - [Test] - public async Task Should_read_default_file() - { - using (Use("endpoints.xml", XmlA)) - { - var routing = await GetRouting(null); - - var routeA = routing(typeof(A)); - Assert.AreEqual(EndpointName, routeA.Endpoint); - - var routeB = routing(typeof(B)); - Assert.IsNull(routeB); - } - } - - [Test] - public async Task Should_read_custom_file() - { - const string name = "custom.xml"; - using (Use(name, XmlB)) - { - var routing = await GetRouting(name); - - var routeA = routing(typeof(A)); - Assert.IsNull(routeA); - - var routeB = routing(typeof(B)); - Assert.AreEqual(EndpointName, routeB.Endpoint); - } - } - - static async Task> GetRouting(string filePath) - { - var endpointConfiguration = new EndpointConfiguration("test"); - endpointConfiguration.UsePersistence(); - endpointConfiguration.SendFailedMessagesTo("error"); - var routing = endpointConfiguration.UseTransport().Routing(); - - if (filePath == null) - { - routing.UseFileBasedRouting(); - } - else - { - routing.UseFileBasedRouting(filePath); - } - - await Endpoint.Create(endpointConfiguration); // to init all features - var routingTable = endpointConfiguration.GetSettings().Get(); - var getRouteFor = typeof(UnicastRoutingTable).GetMethod("GetRouteFor", - BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); - - return t => (UnicastRoute) getRouteFor.Invoke(routingTable, new object[] {t}); - } - - static IDisposable Use(string fileName, string xml) - { - // the feature uses the relative path - var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - File.WriteAllText(file, xml); - - return new Disposable(() => File.Delete(file)); - } - - class Disposable : IDisposable - { - readonly Action dispose; - - public Disposable(Action dispose) - { - this.dispose = dispose; - } - - public void Dispose() - { - dispose(); - } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting.Tests/NServiceBus.FileBasedRouting.Tests.csproj b/src/NServiceBus.FileBasedRouting.Tests/NServiceBus.FileBasedRouting.Tests.csproj deleted file mode 100644 index 35913ba..0000000 --- a/src/NServiceBus.FileBasedRouting.Tests/NServiceBus.FileBasedRouting.Tests.csproj +++ /dev/null @@ -1,79 +0,0 @@ - - - - - Debug - AnyCPU - {01B5FB13-9952-4537-A340-42706EA66019} - Library - Properties - NServiceBus.FileBasedRouting.Tests - NServiceBus.FileBasedRouting.Tests - v4.6 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\NServiceBus.6.1.0\lib\net452\NServiceBus.Core.dll - True - - - ..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll - True - - - - - - - - - - - - - - - - - - - - - {88f2d59f-ce5d-4bd5-b9eb-494a2728ad98} - NServiceBus.FileBasedRouting.Tests.Contracts - - - {b6417ca5-3892-4c53-8356-31018692ae35} - NServiceBus.FileBasedRouting - - - - - - - - \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting.Tests/XmlRoutingFileAccessTests.cs b/src/NServiceBus.FileBasedRouting.Tests/XmlRoutingFileAccessTests.cs deleted file mode 100644 index d63c10d..0000000 --- a/src/NServiceBus.FileBasedRouting.Tests/XmlRoutingFileAccessTests.cs +++ /dev/null @@ -1,77 +0,0 @@ -namespace NServiceBus.FileBasedRouting.Tests -{ - using System; - using System.IO; - using System.Xml; - using NUnit.Framework; - - public class XmlRoutingFileAccessTests - { - [Test] - public void Should_throw_when_file_not_found() - { - var fileAccess = new XmlRoutingFileAccess(new Uri("non-existing.file", UriKind.RelativeOrAbsolute)); - - Assert.Throws(() => fileAccess.Read()); - } - - [Test] - public void Should_return_loaded_document() - { - var fileName = "hello-world.xml"; - var fileAccess = new XmlRoutingFileAccess(new Uri(fileName, UriKind.RelativeOrAbsolute)); - - File.WriteAllText(fileName, "Hello World!"); - try - { - var document = fileAccess.Read(); - Assert.IsNotNull(document); - Assert.AreEqual("Hello World!", document.Root.Value); - } - finally - { - File.Delete(fileName); - } - } - - [Test] - public void Should_load_valid_xml_content() - { - var fileName = "hello-world.html"; - var fileAccess = new XmlRoutingFileAccess(new Uri(fileName, UriKind.RelativeOrAbsolute)); - - File.WriteAllText(fileName, "

Hello World!

"); - try - { - var document = fileAccess.Read(); - Assert.IsNotNull(document); - Assert.AreEqual("Hello World!", document.Root.Value); - } - finally - { - File.Delete(fileName); - } - } - - [Test] - public void Should_throw_when_file_contains_no_xml_content() - { - var fileName = "hello-world.txt"; - var fileAccess = new XmlRoutingFileAccess(new Uri(fileName, UriKind.RelativeOrAbsolute)); - - File.WriteAllText(fileName, "Hello World!"); - try - { - - var exception = Assert.Throws(() => fileAccess.Read()); - - StringAssert.Contains("The configured routing file is no valid XML file.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); - } - finally - { - File.Delete(fileName); - } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting.Tests/XmlRoutingFileTests.cs b/src/NServiceBus.FileBasedRouting.Tests/XmlRoutingFileTests.cs deleted file mode 100644 index 04d239d..0000000 --- a/src/NServiceBus.FileBasedRouting.Tests/XmlRoutingFileTests.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System.Linq; -using NServiceBus.FileBasedRouting.Tests.Contracts; -using NServiceBus.FileBasedRouting.Tests.Contracts.Commands; -using NUnit.Framework; - -namespace NServiceBus.FileBasedRouting.Tests -{ - using System.Xml.Linq; - - public class XmlRoutingFileTests - { - [Test] - public void It_can_parse_file_with_single_commands() - { - const string xml = @" - - - - - - - - - "; - var configurations = GetConfigurations(xml); - - Assert.AreEqual(1, configurations.Length); - var configuration = configurations[0]; - Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); - - CollectionAssert.AreEquivalent(new[] { typeof(A), typeof(B) }, configuration.Commands); - } - - [Test] - public void It_can_parse_file_with_commands_with_assembly_only() - { - const string xml = @" - - - - - - - - "; - var configurations = GetConfigurations(xml); - - Assert.AreEqual(1, configurations.Length); - var configuration = configurations[0]; - Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); - - CollectionAssert.AreEquivalent(new[] { typeof(A), typeof(B), typeof(C), typeof(D) }, configuration.Commands); - } - - [Test] - public void It_can_parse_file_with_commands_with_assembly_and_namespace() - { - const string xml = @" - - - - - - - - "; - var configurations = GetConfigurations(xml); - - Assert.AreEqual(1, configurations.Length); - var configuration = configurations[0]; - Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); - - CollectionAssert.AreEquivalent(new[] { typeof(A), typeof(B) }, configuration.Commands); - } - - [Test] - public void It_can_parse_file_with_commands_with_assembly_and_empty_namespace() - { - const string xml = @" - - - - - - - - "; - var configurations = GetConfigurations(xml); - - Assert.AreEqual(1, configurations.Length); - var configuration = configurations[0]; - Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); - - CollectionAssert.AreEquivalent(new[] { typeof(D) }, configuration.Commands); - } - - [Test] - public void It_provides_distinct_result_even_when_types_are_registered_multiple_times() - { - const string xml = @" - - - - - - - - - - - - - "; - var configurations = GetConfigurations(xml); - - Assert.AreEqual(1, configurations.Length); - var configuration = configurations[0]; - Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); - - CollectionAssert.AreEquivalent(new[] { typeof(A), typeof(B) }, configuration.Commands); - } - - [Test] - public void It_does_not_throw_if_assembly_cannot_be_found() - { - const string xml = @" - - - - - - - - "; - var configurations = GetConfigurations(xml); - - Assert.AreEqual(1, configurations.Length); - var configuration = configurations[0]; - Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); - } - - - static EndpointRoutingConfiguration[] GetConfigurations(string xml) - { - var result = new XmlRoutingFileParser(); - return result.Parse(XDocument.Parse(xml)).ToArray(); - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting.Tests/packages.config b/src/NServiceBus.FileBasedRouting.Tests/packages.config deleted file mode 100644 index f1ec31f..0000000 --- a/src/NServiceBus.FileBasedRouting.Tests/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting.sln b/src/NServiceBus.FileBasedRouting.sln index 6f4ce53..1202a5d 100644 --- a/src/NServiceBus.FileBasedRouting.sln +++ b/src/NServiceBus.FileBasedRouting.sln @@ -1,25 +1,25 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.FileBasedRouting", "NServiceBus.FileBasedRouting\NServiceBus.FileBasedRouting.csproj", "{B6417CA5-3892-4C53-8356-31018692AE35}" +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.12 +MinimumVisualStudioVersion = 15.0.26430.12 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.FileBasedRouting", "NServiceBus.FileBasedRouting\NServiceBus.FileBasedRouting.csproj", "{B6417CA5-3892-4C53-8356-31018692AE35}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sample", "Sample", "{5C4D228C-9FF6-4F63-B413-68CC922EB652}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{FB64C215-540A-4ED1-901F-1E0A242D0908}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{FB64C215-540A-4ED1-901F-1E0A242D0908}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndpointA", "EndpointA\EndpointA.csproj", "{8B25A222-B70F-490C-8EF4-E8B788563176}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointA", "EndpointA\EndpointA.csproj", "{8B25A222-B70F-490C-8EF4-E8B788563176}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "EndpointB", "EndpointB\EndpointB.shproj", "{54093E78-EB7C-46E5-B495-3D6198EAFA5C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndpointB_1", "EndpointB_1\EndpointB_1.csproj", "{EB4B2281-8C83-4BAB-B35B-A30C94B939FE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointB_1", "EndpointB_1\EndpointB_1.csproj", "{EB4B2281-8C83-4BAB-B35B-A30C94B939FE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndpointB_2", "EndpointB_2\EndpointB_2.csproj", "{9B21E30F-61C0-4404-BB18-88CEBC69122C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointB_2", "EndpointB_2\EndpointB_2.csproj", "{9B21E30F-61C0-4404-BB18-88CEBC69122C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.FileBasedRouting.Tests", "NServiceBus.FileBasedRouting.Tests\NServiceBus.FileBasedRouting.Tests.csproj", "{01B5FB13-9952-4537-A340-42706EA66019}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{01B5FB13-9952-4537-A340-42706EA66019}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.FileBasedRouting.Tests.Contracts", "NServiceBus.FileBasedRouting.Tests.Contracts\NServiceBus.FileBasedRouting.Tests.Contracts.csproj", "{88F2D59F-CE5D-4BD5-B9EB-494A2728AD98}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Contracts", "Tests.Contracts\Tests.Contracts.csproj", "{88F2D59F-CE5D-4BD5-B9EB-494A2728AD98}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution @@ -71,4 +71,7 @@ Global {EB4B2281-8C83-4BAB-B35B-A30C94B939FE} = {5C4D228C-9FF6-4F63-B413-68CC922EB652} {9B21E30F-61C0-4404-BB18-88CEBC69122C} = {5C4D228C-9FF6-4F63-B413-68CC922EB652} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FEB07B8F-3B0F-47DB-8637-84FA79652C2E} + EndGlobalSection EndGlobal diff --git a/src/NServiceBus.FileBasedRouting.sln.DotSettings b/src/NServiceBus.FileBasedRouting.sln.DotSettings index bcf1588..03a3153 100644 --- a/src/NServiceBus.FileBasedRouting.sln.DotSettings +++ b/src/NServiceBus.FileBasedRouting.sln.DotSettings @@ -1,6 +1,6 @@  - CSharp60 + CSharp71 True True True @@ -599,6 +599,7 @@ II.2.12 <HandlesEvent /> True True True + True diff --git a/src/NServiceBus.FileBasedRouting/FileBasedRoutingConfigExtensions.cs b/src/NServiceBus.FileBasedRouting/FileBasedRoutingConfigExtensions.cs index 2ebcd17..89ecee0 100644 --- a/src/NServiceBus.FileBasedRouting/FileBasedRoutingConfigExtensions.cs +++ b/src/NServiceBus.FileBasedRouting/FileBasedRoutingConfigExtensions.cs @@ -1,10 +1,13 @@ -using NServiceBus.Configuration.AdvanceExtensibility; -using System; +using System; namespace NServiceBus.FileBasedRouting { + using Configuration.AdvancedExtensibility; using Features; + /// + /// Extensions to to add file based routing functionality. + /// public static class FileBasedRoutingConfigExtensions { /// diff --git a/src/NServiceBus.FileBasedRouting/FileBasedRoutingFeature.cs b/src/NServiceBus.FileBasedRouting/FileBasedRoutingFeature.cs index ebd1167..f1ed77c 100644 --- a/src/NServiceBus.FileBasedRouting/FileBasedRoutingFeature.cs +++ b/src/NServiceBus.FileBasedRouting/FileBasedRoutingFeature.cs @@ -134,7 +134,7 @@ protected override Task OnStart(IMessageSession session) } }, null, routeFileUpdateInterval, routeFileUpdateInterval); - return Task.CompletedTask; + return Task.FromResult(0); } protected override Task OnStop(IMessageSession session) @@ -142,7 +142,7 @@ protected override Task OnStop(IMessageSession session) updateTimer?.Dispose(); updateTimer = null; - return Task.CompletedTask; + return Task.FromResult(0); } public void Dispose() diff --git a/src/NServiceBus.FileBasedRouting/InternalsVisible.cs b/src/NServiceBus.FileBasedRouting/InternalsVisible.cs new file mode 100644 index 0000000..c160f1b --- /dev/null +++ b/src/NServiceBus.FileBasedRouting/InternalsVisible.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100dde965e6172e019ac82c2639ffe494dd2e7dd16347c34762a05732b492e110f2e4e2e1b5ef2d85c848ccfb671ee20a47c8d1376276708dc30a90ff1121b647ba3b7259a6bc383b2034938ef0e275b58b920375ac605076178123693c6c4f1331661a62eba28c249386855637780e3ff5f23a6d854700eaa6803ef48907513b92")] \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj b/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj index 7ef9f39..0240949 100644 --- a/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj +++ b/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj @@ -1,41 +1,17 @@  - - + - Debug - AnyCPU - {B6417CA5-3892-4C53-8356-31018692AE35} - Library - Properties - NServiceBus.FileBasedRouting - NServiceBus.FileBasedRouting - v4.6 - 512 - - + net452 + true + $(SolutionDir)NServiceBus.snk + true - - true - full - false - ..\..\binaries\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\binaries\ - TRACE - prompt - 4 + + NServiceBus support for defining message routing via XML file + true - - ..\packages\NServiceBus.6.1.0\lib\net452\NServiceBus.Core.dll - True - + @@ -46,42 +22,6 @@ - - - - - - - - - - - - - - - - Designer - - - - + - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting/Properties/AssemblyInfo.cs b/src/NServiceBus.FileBasedRouting/Properties/AssemblyInfo.cs deleted file mode 100644 index 92da518..0000000 --- a/src/NServiceBus.FileBasedRouting/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ - -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("NServiceBus.FileBasedRouting.Tests")] \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting/SubscribeTerminator.cs b/src/NServiceBus.FileBasedRouting/SubscribeTerminator.cs index d10978a..4538f41 100644 --- a/src/NServiceBus.FileBasedRouting/SubscribeTerminator.cs +++ b/src/NServiceBus.FileBasedRouting/SubscribeTerminator.cs @@ -10,7 +10,7 @@ class SubscribeTerminator : PipelineTerminator protected override Task Terminate(ISubscribeContext context) { log.Debug($"Subscribe was called for {context.EventType.FullName}. With FileBasedRouting, subscribe operations have no effect and subscribers should be configured in the routing file. If subscribe was not called by you, consider disabling the {nameof(AutoSubscribe)} feature."); - return Task.CompletedTask; + return Task.FromResult(0); } static readonly ILog log = LogManager.GetLogger(); diff --git a/src/NServiceBus.FileBasedRouting/UnicastSubscriberTable.cs b/src/NServiceBus.FileBasedRouting/UnicastSubscriberTable.cs index 06bd824..e2a3b67 100644 --- a/src/NServiceBus.FileBasedRouting/UnicastSubscriberTable.cs +++ b/src/NServiceBus.FileBasedRouting/UnicastSubscriberTable.cs @@ -14,8 +14,7 @@ class UnicastSubscriberTable public UnicastRouteGroup[] GetRoutesFor(Type messageType) { - UnicastRouteGroup[] unicastRoutes; - return routeTable.TryGetValue(messageType, out unicastRoutes) + return routeTable.TryGetValue(messageType, out var unicastRoutes) ? unicastRoutes : emptyResult; } @@ -62,8 +61,7 @@ Dictionary CalculateNewRouteTable() var newRouteTable = new Dictionary>(); foreach (var entry in routeGroups.Values.SelectMany(g => g)) { - List typeRoutes; - if (!newRouteTable.TryGetValue(entry.MessageType, out typeRoutes)) + if (!newRouteTable.TryGetValue(entry.MessageType, out var typeRoutes)) { typeRoutes = new List(); newRouteTable[entry.MessageType] = typeRoutes; diff --git a/src/NServiceBus.FileBasedRouting/UnsubscribeTerminator.cs b/src/NServiceBus.FileBasedRouting/UnsubscribeTerminator.cs index 3b89e63..98882a9 100644 --- a/src/NServiceBus.FileBasedRouting/UnsubscribeTerminator.cs +++ b/src/NServiceBus.FileBasedRouting/UnsubscribeTerminator.cs @@ -9,7 +9,7 @@ class UnsubscribeTerminator : PipelineTerminator protected override Task Terminate(IUnsubscribeContext context) { log.Debug($"Unsubscribe was called for {context.EventType.FullName}. With FileBasedRouting, unsubscribe operations have no effect and subscribers should be configured in the routing file."); - return Task.CompletedTask; + return Task.FromResult(0); } static readonly ILog log = LogManager.GetLogger(); diff --git a/src/NServiceBus.FileBasedRouting/XmlRoutingFileParser.cs b/src/NServiceBus.FileBasedRouting/XmlRoutingFileParser.cs index 1bde7d3..98581f9 100644 --- a/src/NServiceBus.FileBasedRouting/XmlRoutingFileParser.cs +++ b/src/NServiceBus.FileBasedRouting/XmlRoutingFileParser.cs @@ -54,8 +54,7 @@ static IEnumerable GetAllMessageTypes(XElement endpointElement, string sin .ToArray() ?? Type.EmptyTypes; var filteredCommands = handles?.Elements(plural).SelectMany(SelectMessages) ?? Type.EmptyTypes; - var allCommands = separatelyConfiguredCommands.Concat(filteredCommands).Distinct(); - return allCommands; + return separatelyConfiguredCommands.Concat(filteredCommands).Distinct(); } static Type FindMessageType(string typeName) @@ -92,7 +91,7 @@ static IEnumerable SelectMessages(XElement commandsElement) logger.Warn($"Cannot add route for unknown assembly {assemblyName}."); return Enumerable.Empty(); } - + var exportedTypes = assembly.ExportedTypes; var @namespace = commandsElement.Attribute("namespace"); if (@namespace == null) diff --git a/src/NServiceBus.FileBasedRouting/packages.config b/src/NServiceBus.FileBasedRouting/packages.config deleted file mode 100644 index aae28a3..0000000 --- a/src/NServiceBus.FileBasedRouting/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/NServiceBus.snk b/src/NServiceBus.snk new file mode 100644 index 0000000000000000000000000000000000000000..6fa7ddec107b33bd6da190c08275d6c10af3be7d GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50098q>1E~@E&-azEG9Ys2^;tEH|(KljtaE-$XkpB@Ownw@ zb+wC<19hxmP<9uABWXNrPZKd_8e;3Bj3kqWg;qCs4nOtsI&FnV0P3cIKJgVr(JeRIRcl*d;SswO<|nyVEFU@+C20$L@E~%;cCH zxeB1g4xZq;@C<1|dd0gnD6E^s6Kw}I6O7qzHY@GWLw3@VJ zlE6iHNPJy}#^!Lt3$iiqH77>+v^OolAVgl1Rs^i%54KcUycsmu#O+>8625DxPD<}| zeEmEMT%o(BV;EXSAMbx`zdJ|(lv(Vd=FDi`ajh&TSUl=wi@aYShFOEDgY}ZN<^#oY#T*~SFhB|#dQ6Q}V literal 0 HcmV?d00001 diff --git a/src/NServiceBus.FileBasedRouting.Tests.Contracts/C.cs b/src/Tests.Contracts/C.cs similarity index 91% rename from src/NServiceBus.FileBasedRouting.Tests.Contracts/C.cs rename to src/Tests.Contracts/C.cs index 3532708..d41e3dd 100644 --- a/src/NServiceBus.FileBasedRouting.Tests.Contracts/C.cs +++ b/src/Tests.Contracts/C.cs @@ -2,6 +2,6 @@ { public class C { - + } } \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting.Tests.Contracts/Commands/A.cs b/src/Tests.Contracts/Commands/A.cs similarity index 100% rename from src/NServiceBus.FileBasedRouting.Tests.Contracts/Commands/A.cs rename to src/Tests.Contracts/Commands/A.cs diff --git a/src/NServiceBus.FileBasedRouting.Tests.Contracts/Commands/B.cs b/src/Tests.Contracts/Commands/B.cs similarity index 100% rename from src/NServiceBus.FileBasedRouting.Tests.Contracts/Commands/B.cs rename to src/Tests.Contracts/Commands/B.cs diff --git a/src/NServiceBus.FileBasedRouting.Tests.Contracts/D.cs b/src/Tests.Contracts/D.cs similarity index 100% rename from src/NServiceBus.FileBasedRouting.Tests.Contracts/D.cs rename to src/Tests.Contracts/D.cs diff --git a/src/Tests.Contracts/Tests.Contracts.csproj b/src/Tests.Contracts/Tests.Contracts.csproj new file mode 100644 index 0000000..a8e2ab0 --- /dev/null +++ b/src/Tests.Contracts/Tests.Contracts.csproj @@ -0,0 +1,18 @@ + + + + net452 + true + $(SolutionDir)NServiceBus.snk + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Tests/EndpointBasedIntegrationTests.cs b/src/Tests/EndpointBasedIntegrationTests.cs new file mode 100644 index 0000000..4f3bd84 --- /dev/null +++ b/src/Tests/EndpointBasedIntegrationTests.cs @@ -0,0 +1,117 @@ +using System; +using System.IO; +using System.Reflection; +using System.Threading.Tasks; +using NServiceBus; +using NServiceBus.Configuration.AdvancedExtensibility; +using NServiceBus.FileBasedRouting; +using NServiceBus.FileBasedRouting.Tests.Contracts.Commands; +using NServiceBus.Routing; +using NUnit.Framework; + +public class EndpointBasedIntegrationTests +{ + const string XmlA = @" + + + + + + + +"; + + const string XmlB = @" + + + + + + + +"; + + const string EndpointName = "EndpointName"; + + [Test] + public async Task Should_read_default_file() + { + using (Use("endpoints.xml", XmlA)) + { + var routing = await GetRouting(null); + + var routeA = routing(typeof(A)); + Assert.AreEqual(EndpointName, routeA.Endpoint); + + var routeB = routing(typeof(B)); + Assert.IsNull(routeB); + } + } + + [Test] + public async Task Should_read_custom_file() + { + const string name = "custom.xml"; + using (Use(name, XmlB)) + { + var routing = await GetRouting(name); + + var routeA = routing(typeof(A)); + Assert.IsNull(routeA); + + var routeB = routing(typeof(B)); + Assert.AreEqual(EndpointName, routeB.Endpoint); + } + } + + static async Task> GetRouting(string filePath) + { + var endpointConfiguration = new EndpointConfiguration("test"); + endpointConfiguration.UsePersistence(); + endpointConfiguration.SendFailedMessagesTo("error"); + var routing = endpointConfiguration.UseTransport().Routing(); + + if (filePath == null) + { + routing.UseFileBasedRouting(); + } + else + { + routing.UseFileBasedRouting(filePath); + } + + await Endpoint.Create(endpointConfiguration); // to init all features + var routingTable = endpointConfiguration.GetSettings().Get(); + var getRouteFor = typeof(UnicastRoutingTable).GetMethod("GetRouteFor", + BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); + + return t => (UnicastRoute) getRouteFor.Invoke(routingTable, new object[] + { + t + }); + } + + static IDisposable Use(string fileName, string xml) + { + // the feature uses the relative path + var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + File.WriteAllText(file, xml); + + return new Disposable(() => File.Delete(file)); + } + + class Disposable : IDisposable + { + readonly Action dispose; + + public Disposable(Action dispose) + { + this.dispose = dispose; + } + + public void Dispose() + { + dispose(); + } + } +} \ No newline at end of file diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj new file mode 100644 index 0000000..2a860df --- /dev/null +++ b/src/Tests/Tests.csproj @@ -0,0 +1,23 @@ + + + + net452 + true + $(SolutionDir)NServiceBus.snk + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Tests/XmlRoutingFileAccessTests.cs b/src/Tests/XmlRoutingFileAccessTests.cs new file mode 100644 index 0000000..ceb8a4e --- /dev/null +++ b/src/Tests/XmlRoutingFileAccessTests.cs @@ -0,0 +1,75 @@ +using System; +using System.IO; +using System.Xml; +using NServiceBus.FileBasedRouting; +using NUnit.Framework; + +public class XmlRoutingFileAccessTests +{ + [Test] + public void Should_throw_when_file_not_found() + { + var fileAccess = new XmlRoutingFileAccess(new Uri("non-existing.file", UriKind.RelativeOrAbsolute)); + + Assert.Throws(() => fileAccess.Read()); + } + + [Test] + public void Should_return_loaded_document() + { + var fileName = "hello-world.xml"; + var fileAccess = new XmlRoutingFileAccess(new Uri(fileName, UriKind.RelativeOrAbsolute)); + + File.WriteAllText(fileName, "Hello World!"); + try + { + var document = fileAccess.Read(); + Assert.IsNotNull(document); + Assert.AreEqual("Hello World!", document.Root.Value); + } + finally + { + File.Delete(fileName); + } + } + + [Test] + public void Should_load_valid_xml_content() + { + var fileName = "hello-world.html"; + var fileAccess = new XmlRoutingFileAccess(new Uri(fileName, UriKind.RelativeOrAbsolute)); + + File.WriteAllText(fileName, "

Hello World!

"); + try + { + var document = fileAccess.Read(); + Assert.IsNotNull(document); + Assert.AreEqual("Hello World!", document.Root.Value); + } + finally + { + File.Delete(fileName); + } + } + + [Test] + public void Should_throw_when_file_contains_no_xml_content() + { + var fileName = "hello-world.txt"; + var fileAccess = new XmlRoutingFileAccess(new Uri(fileName, UriKind.RelativeOrAbsolute)); + + File.WriteAllText(fileName, "Hello World!"); + try + { + + var exception = Assert.Throws(() => fileAccess.Read()); + + StringAssert.Contains("The configured routing file is no valid XML file.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + finally + { + File.Delete(fileName); + } + } +} \ No newline at end of file diff --git a/src/Tests/XmlRoutingFileTests.cs b/src/Tests/XmlRoutingFileTests.cs new file mode 100644 index 0000000..927ce74 --- /dev/null +++ b/src/Tests/XmlRoutingFileTests.cs @@ -0,0 +1,146 @@ +using System.Linq; +using NServiceBus.FileBasedRouting.Tests.Contracts; +using NServiceBus.FileBasedRouting.Tests.Contracts.Commands; +using NUnit.Framework; +using System.Xml.Linq; +using NServiceBus.FileBasedRouting; + +public class XmlRoutingFileTests +{ + [Test] + public void It_can_parse_file_with_single_commands() + { + const string xml = @" + + + + + + + + +"; + var configurations = GetConfigurations(xml); + + Assert.AreEqual(1, configurations.Length); + var configuration = configurations[0]; + Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); + + CollectionAssert.AreEquivalent(new[] { typeof(A), typeof(B) }, configuration.Commands); + } + + [Test] + public void It_can_parse_file_with_commands_with_assembly_only() + { + const string xml = @" + + + + + + + +"; + var configurations = GetConfigurations(xml); + + Assert.AreEqual(1, configurations.Length); + var configuration = configurations[0]; + Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); + + CollectionAssert.AreEquivalent(new[] { typeof(A), typeof(B), typeof(C), typeof(D) }, configuration.Commands); + } + + [Test] + public void It_can_parse_file_with_commands_with_assembly_and_namespace() + { + const string xml = @" + + + + + + + +"; + var configurations = GetConfigurations(xml); + + Assert.AreEqual(1, configurations.Length); + var configuration = configurations[0]; + Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); + + CollectionAssert.AreEquivalent(new[] { typeof(A), typeof(B) }, configuration.Commands); + } + + [Test] + public void It_can_parse_file_with_commands_with_assembly_and_empty_namespace() + { + const string xml = @" + + + + + + + +"; + var configurations = GetConfigurations(xml); + + Assert.AreEqual(1, configurations.Length); + var configuration = configurations[0]; + Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); + + CollectionAssert.AreEquivalent(new[] { typeof(D) }, configuration.Commands); + } + + [Test] + public void It_provides_distinct_result_even_when_types_are_registered_multiple_times() + { + const string xml = @" + + + + + + + + + + + + +"; + var configurations = GetConfigurations(xml); + + Assert.AreEqual(1, configurations.Length); + var configuration = configurations[0]; + Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); + + CollectionAssert.AreEquivalent(new[] { typeof(A), typeof(B) }, configuration.Commands); + } + + [Test] + public void It_does_not_throw_if_assembly_cannot_be_found() + { + const string xml = @" + + + + + + + +"; + var configurations = GetConfigurations(xml); + + Assert.AreEqual(1, configurations.Length); + var configuration = configurations[0]; + Assert.AreEqual("EndpointName", configuration.LogicalEndpointName); + } + + + static EndpointRoutingConfiguration[] GetConfigurations(string xml) + { + var result = new XmlRoutingFileParser(); + return result.Parse(XDocument.Parse(xml)).ToArray(); + } +} From e08f5320a22dd037e2338f11966568f05cd749a4 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 4 Sep 2017 00:17:50 +1000 Subject: [PATCH 2/6] redundant refs --- src/Contracts/Contracts.csproj | 8 -------- src/EndpointA/EndpointA.csproj | 8 -------- src/EndpointB_1/EndpointB_1.csproj | 8 -------- src/EndpointB_2/EndpointB_2.csproj | 8 -------- .../NServiceBus.FileBasedRouting.csproj | 8 -------- src/Tests.Contracts/Tests.Contracts.csproj | 10 ---------- src/Tests/Tests.csproj | 8 -------- 7 files changed, 58 deletions(-) diff --git a/src/Contracts/Contracts.csproj b/src/Contracts/Contracts.csproj index f04dae3..99adb8e 100644 --- a/src/Contracts/Contracts.csproj +++ b/src/Contracts/Contracts.csproj @@ -5,13 +5,5 @@ - - - - - - - -
\ No newline at end of file diff --git a/src/EndpointA/EndpointA.csproj b/src/EndpointA/EndpointA.csproj index f32886f..e0a263e 100644 --- a/src/EndpointA/EndpointA.csproj +++ b/src/EndpointA/EndpointA.csproj @@ -7,14 +7,6 @@ - - - - - - - - diff --git a/src/EndpointB_1/EndpointB_1.csproj b/src/EndpointB_1/EndpointB_1.csproj index 871025f..fe0bc6a 100644 --- a/src/EndpointB_1/EndpointB_1.csproj +++ b/src/EndpointB_1/EndpointB_1.csproj @@ -7,14 +7,6 @@ - - - - - - - - diff --git a/src/EndpointB_2/EndpointB_2.csproj b/src/EndpointB_2/EndpointB_2.csproj index 871025f..fe0bc6a 100644 --- a/src/EndpointB_2/EndpointB_2.csproj +++ b/src/EndpointB_2/EndpointB_2.csproj @@ -7,14 +7,6 @@ - - - - - - - - diff --git a/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj b/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj index 0240949..38f2695 100644 --- a/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj +++ b/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj @@ -12,14 +12,6 @@ - - - - - - - - diff --git a/src/Tests.Contracts/Tests.Contracts.csproj b/src/Tests.Contracts/Tests.Contracts.csproj index a8e2ab0..4584924 100644 --- a/src/Tests.Contracts/Tests.Contracts.csproj +++ b/src/Tests.Contracts/Tests.Contracts.csproj @@ -5,14 +5,4 @@ true $(SolutionDir)NServiceBus.snk - - - - - - - - - - \ No newline at end of file diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index 2a860df..0b5bbac 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -9,14 +9,6 @@ - - - - - - - - From 31d4795677226856ddc58928ea2b8a5262ec1b79 Mon Sep 17 00:00:00 2001 From: SzymonPobiega Date: Mon, 4 Sep 2017 14:08:15 +0200 Subject: [PATCH 3/6] Fixed the tests and sample. --- src/EndpointA/EndpointA.csproj | 8 +++++++ src/Tests.Contracts/C.cs | 2 +- src/Tests.Contracts/Commands/A.cs | 2 +- src/Tests.Contracts/Commands/B.cs | 2 +- src/Tests/EndpointBasedIntegrationTests.cs | 6 ++--- src/Tests/XmlRoutingFileTests.cs | 26 +++++++++++----------- 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/EndpointA/EndpointA.csproj b/src/EndpointA/EndpointA.csproj index e0a263e..1c8b28e 100644 --- a/src/EndpointA/EndpointA.csproj +++ b/src/EndpointA/EndpointA.csproj @@ -10,4 +10,12 @@ + + + PreserveNewest + + + PreserveNewest + + \ No newline at end of file diff --git a/src/Tests.Contracts/C.cs b/src/Tests.Contracts/C.cs index d41e3dd..d71fa4a 100644 --- a/src/Tests.Contracts/C.cs +++ b/src/Tests.Contracts/C.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.FileBasedRouting.Tests.Contracts +namespace Tests.Contracts { public class C { diff --git a/src/Tests.Contracts/Commands/A.cs b/src/Tests.Contracts/Commands/A.cs index cde6adf..f6be0e4 100644 --- a/src/Tests.Contracts/Commands/A.cs +++ b/src/Tests.Contracts/Commands/A.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.FileBasedRouting.Tests.Contracts.Commands +namespace Tests.Contracts.Commands { public class A { diff --git a/src/Tests.Contracts/Commands/B.cs b/src/Tests.Contracts/Commands/B.cs index 818075d..143d6c8 100644 --- a/src/Tests.Contracts/Commands/B.cs +++ b/src/Tests.Contracts/Commands/B.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.FileBasedRouting.Tests.Contracts.Commands +namespace Tests.Contracts.Commands { public class B { diff --git a/src/Tests/EndpointBasedIntegrationTests.cs b/src/Tests/EndpointBasedIntegrationTests.cs index 4f3bd84..036825c 100644 --- a/src/Tests/EndpointBasedIntegrationTests.cs +++ b/src/Tests/EndpointBasedIntegrationTests.cs @@ -5,9 +5,9 @@ using NServiceBus; using NServiceBus.Configuration.AdvancedExtensibility; using NServiceBus.FileBasedRouting; -using NServiceBus.FileBasedRouting.Tests.Contracts.Commands; using NServiceBus.Routing; using NUnit.Framework; +using Tests.Contracts.Commands; public class EndpointBasedIntegrationTests { @@ -15,7 +15,7 @@ public class EndpointBasedIntegrationTests - + @@ -25,7 +25,7 @@ public class EndpointBasedIntegrationTests - + diff --git a/src/Tests/XmlRoutingFileTests.cs b/src/Tests/XmlRoutingFileTests.cs index 927ce74..da3d404 100644 --- a/src/Tests/XmlRoutingFileTests.cs +++ b/src/Tests/XmlRoutingFileTests.cs @@ -1,9 +1,9 @@ using System.Linq; -using NServiceBus.FileBasedRouting.Tests.Contracts; -using NServiceBus.FileBasedRouting.Tests.Contracts.Commands; using NUnit.Framework; using System.Xml.Linq; using NServiceBus.FileBasedRouting; +using Tests.Contracts; +using Tests.Contracts.Commands; public class XmlRoutingFileTests { @@ -14,8 +14,8 @@ public void It_can_parse_file_with_single_commands() - - + + @@ -36,7 +36,7 @@ public void It_can_parse_file_with_commands_with_assembly_only() - + @@ -57,7 +57,7 @@ public void It_can_parse_file_with_commands_with_assembly_and_namespace() - + @@ -78,7 +78,7 @@ public void It_can_parse_file_with_commands_with_assembly_and_empty_namespace() - + @@ -99,12 +99,12 @@ public void It_provides_distinct_result_even_when_types_are_registered_multiple_ - - - - - - + + + + + + From 3b832f028cd287c04016b497d263331a267a097b Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Fri, 12 Jan 2018 21:46:55 +0100 Subject: [PATCH 4/6] Update Release Candidate (#31) * update dependencies * update to new distributionstrategy API * update test project package dependencies * use particular.packaging * remove unnecessary dependency * Clean up project files * Grammar tweak * Update testing packages * Add Directory.Build.props and GitVersion.yml to solution items * Simplify sample dependencies * Use learning transport instead of MSMQ * Add netstandard2.0 target * Remove unneeded RegisterPublisher calls * Add EnableInstallers call * Move sample into Sample folder * Replace shared project with Compile item * Fixed mixed spaces and tabs --- src/Directory.Build.props | 30 +------------------ src/Directory.Build.targets | 22 -------------- src/EndpointA/EndpointA.csproj | 21 ------------- src/EndpointB/EndpointB.projitems | 16 ---------- src/EndpointB/EndpointB.shproj | 13 -------- src/EndpointB_1/EndpointB_1.csproj | 20 ------------- src/EndpointB_2/EndpointB_2.csproj | 20 ------------- src/NServiceBus.FileBasedRouting.sln | 20 +++++++------ .../FileBasedRoutingFeature.cs | 8 ++--- .../NServiceBus.FileBasedRouting.csproj | 18 ++++++----- .../PublishRoutingConnector.cs | 12 ++++---- .../Contracts/Commands/DemoCommand.cs | 0 src/{ => Sample}/Contracts/Contracts.csproj | 6 ++-- .../Contracts/Events/DemoCommandReceived.cs | 0 .../Contracts/Events/DemoEvent.cs | 0 .../EndpointA/DemoCommandReceivedHandler.cs | 0 src/Sample/EndpointA/EndpointA.csproj | 22 ++++++++++++++ src/{ => Sample}/EndpointA/Program.cs | 3 +- src/{ => Sample}/EndpointA/endpoints.xml | 0 .../EndpointA/instance-mapping.xml | 0 src/Sample/EndpointB_1/EndpointB_1.csproj | 22 ++++++++++++++ src/{ => Sample}/EndpointB_1/Program.cs | 0 src/Sample/EndpointB_2/EndpointB_2.csproj | 22 ++++++++++++++ src/{ => Sample}/EndpointB_2/Program.cs | 0 .../EndpointB_Shared}/Configuration.cs | 3 +- .../EndpointB_Shared}/DemoCommandHandler.cs | 0 .../EndpointB_Shared}/DemoEventHandler.cs | 0 src/Tests.Contracts/Tests.Contracts.csproj | 7 +++-- src/Tests/EndpointBasedIntegrationTests.cs | 4 +-- src/Tests/Tests.csproj | 20 ++++++++----- 30 files changed, 124 insertions(+), 185 deletions(-) delete mode 100644 src/Directory.Build.targets delete mode 100644 src/EndpointA/EndpointA.csproj delete mode 100644 src/EndpointB/EndpointB.projitems delete mode 100644 src/EndpointB/EndpointB.shproj delete mode 100644 src/EndpointB_1/EndpointB_1.csproj delete mode 100644 src/EndpointB_2/EndpointB_2.csproj rename src/{ => Sample}/Contracts/Commands/DemoCommand.cs (100%) rename src/{ => Sample}/Contracts/Contracts.csproj (71%) rename src/{ => Sample}/Contracts/Events/DemoCommandReceived.cs (100%) rename src/{ => Sample}/Contracts/Events/DemoEvent.cs (100%) rename src/{ => Sample}/EndpointA/DemoCommandReceivedHandler.cs (100%) create mode 100644 src/Sample/EndpointA/EndpointA.csproj rename src/{ => Sample}/EndpointA/Program.cs (95%) rename src/{ => Sample}/EndpointA/endpoints.xml (100%) rename src/{ => Sample}/EndpointA/instance-mapping.xml (100%) create mode 100644 src/Sample/EndpointB_1/EndpointB_1.csproj rename src/{ => Sample}/EndpointB_1/Program.cs (100%) create mode 100644 src/Sample/EndpointB_2/EndpointB_2.csproj rename src/{ => Sample}/EndpointB_2/Program.cs (100%) rename src/{EndpointB => Sample/EndpointB_Shared}/Configuration.cs (93%) rename src/{EndpointB => Sample/EndpointB_Shared}/DemoCommandHandler.cs (100%) rename src/{EndpointB => Sample/EndpointB_Shared}/DemoEventHandler.cs (100%) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a2abd0e..965a519 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,36 +1,8 @@ + latest true - 7.1 - - - true - false - false - false - - - - - 4.0.0-* - - - - - - - - - - - \ No newline at end of file diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets deleted file mode 100644 index dd52f13..0000000 --- a/src/Directory.Build.targets +++ /dev/null @@ -1,22 +0,0 @@ - - - - NServiceBus Ltd - NServiceBus Ltd - http://particular.net/LicenseAgreement - true - Copyright 2010-$([System.DateTime]::UtcNow.ToString(yyyy)) NServiceBus. All rights reserved - nservicebus servicebus msmq cqrs publish subscribe - http://s3.amazonaws.com/nuget.images/NServiceBus_32.png - https://docs.particular.net/nuget/$(PackageId) - ..\..\nugets - $(TargetsForTfmSpecificContentInPackage);IncludePDBsInPackage - - - - - - - - - \ No newline at end of file diff --git a/src/EndpointA/EndpointA.csproj b/src/EndpointA/EndpointA.csproj deleted file mode 100644 index 1c8b28e..0000000 --- a/src/EndpointA/EndpointA.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - net452 - Exe - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - \ No newline at end of file diff --git a/src/EndpointB/EndpointB.projitems b/src/EndpointB/EndpointB.projitems deleted file mode 100644 index 1f9c25e..0000000 --- a/src/EndpointB/EndpointB.projitems +++ /dev/null @@ -1,16 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - 54093e78-eb7c-46e5-b495-3d6198eafa5c - - - EndpointB - - - - - - - \ No newline at end of file diff --git a/src/EndpointB/EndpointB.shproj b/src/EndpointB/EndpointB.shproj deleted file mode 100644 index 434c826..0000000 --- a/src/EndpointB/EndpointB.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - 54093e78-eb7c-46e5-b495-3d6198eafa5c - 14.0 - - - - - - - - diff --git a/src/EndpointB_1/EndpointB_1.csproj b/src/EndpointB_1/EndpointB_1.csproj deleted file mode 100644 index fe0bc6a..0000000 --- a/src/EndpointB_1/EndpointB_1.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net452 - Exe - - - - - - - - - - endpoints.xml - Always - - - - \ No newline at end of file diff --git a/src/EndpointB_2/EndpointB_2.csproj b/src/EndpointB_2/EndpointB_2.csproj deleted file mode 100644 index fe0bc6a..0000000 --- a/src/EndpointB_2/EndpointB_2.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net452 - Exe - - - - - - - - - - endpoints.xml - Always - - - - \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting.sln b/src/NServiceBus.FileBasedRouting.sln index 1202a5d..d877e1d 100644 --- a/src/NServiceBus.FileBasedRouting.sln +++ b/src/NServiceBus.FileBasedRouting.sln @@ -1,29 +1,32 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.12 +VisualStudioVersion = 15.0.27130.2020 MinimumVisualStudioVersion = 15.0.26430.12 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.FileBasedRouting", "NServiceBus.FileBasedRouting\NServiceBus.FileBasedRouting.csproj", "{B6417CA5-3892-4C53-8356-31018692AE35}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sample", "Sample", "{5C4D228C-9FF6-4F63-B413-68CC922EB652}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{FB64C215-540A-4ED1-901F-1E0A242D0908}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Sample\Contracts\Contracts.csproj", "{FB64C215-540A-4ED1-901F-1E0A242D0908}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointA", "EndpointA\EndpointA.csproj", "{8B25A222-B70F-490C-8EF4-E8B788563176}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointA", "Sample\EndpointA\EndpointA.csproj", "{8B25A222-B70F-490C-8EF4-E8B788563176}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "EndpointB", "EndpointB\EndpointB.shproj", "{54093E78-EB7C-46E5-B495-3D6198EAFA5C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointB_1", "Sample\EndpointB_1\EndpointB_1.csproj", "{EB4B2281-8C83-4BAB-B35B-A30C94B939FE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointB_1", "EndpointB_1\EndpointB_1.csproj", "{EB4B2281-8C83-4BAB-B35B-A30C94B939FE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointB_2", "EndpointB_2\EndpointB_2.csproj", "{9B21E30F-61C0-4404-BB18-88CEBC69122C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointB_2", "Sample\EndpointB_2\EndpointB_2.csproj", "{9B21E30F-61C0-4404-BB18-88CEBC69122C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{01B5FB13-9952-4537-A340-42706EA66019}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Contracts", "Tests.Contracts\Tests.Contracts.csproj", "{88F2D59F-CE5D-4BD5-B9EB-494A2728AD98}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4238E063-B249-4935-B50D-177CB083FCED}" + ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props + ..\GitVersion.yml = ..\GitVersion.yml + EndProjectSection +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution - EndpointB\EndpointB.projitems*{54093e78-eb7c-46e5-b495-3d6198eafa5c}*SharedItemsImports = 13 EndpointB\EndpointB.projitems*{9b21e30f-61c0-4404-bb18-88cebc69122c}*SharedItemsImports = 4 EndpointB\EndpointB.projitems*{eb4b2281-8c83-4bab-b35b-a30c94b939fe}*SharedItemsImports = 4 EndGlobalSection @@ -67,7 +70,6 @@ Global GlobalSection(NestedProjects) = preSolution {FB64C215-540A-4ED1-901F-1E0A242D0908} = {5C4D228C-9FF6-4F63-B413-68CC922EB652} {8B25A222-B70F-490C-8EF4-E8B788563176} = {5C4D228C-9FF6-4F63-B413-68CC922EB652} - {54093E78-EB7C-46E5-B495-3D6198EAFA5C} = {5C4D228C-9FF6-4F63-B413-68CC922EB652} {EB4B2281-8C83-4BAB-B35B-A30C94B939FE} = {5C4D228C-9FF6-4F63-B413-68CC922EB652} {9B21E30F-61C0-4404-BB18-88CEBC69122C} = {5C4D228C-9FF6-4F63-B413-68CC922EB652} EndGlobalSection diff --git a/src/NServiceBus.FileBasedRouting/FileBasedRoutingFeature.cs b/src/NServiceBus.FileBasedRouting/FileBasedRoutingFeature.cs index f1ed77c..be9b420 100644 --- a/src/NServiceBus.FileBasedRouting/FileBasedRoutingFeature.cs +++ b/src/NServiceBus.FileBasedRouting/FileBasedRoutingFeature.cs @@ -111,13 +111,13 @@ static void UpdateRoutingTable(XmlRoutingFileParser routingFileParser, XmlRoutin class UpdateRoutingTask : FeatureStartupTask, IDisposable { Action updateRoutingCallback; - TimeSpan routeFileUpdateInterval; - Timer updateTimer; + TimeSpan routeFileUpdateInterval; + Timer updateTimer; public UpdateRoutingTask(Action updateRoutingCallback, TimeSpan routeFileUpdateInterval) { - this.updateRoutingCallback = updateRoutingCallback; - this.routeFileUpdateInterval = routeFileUpdateInterval; + this.updateRoutingCallback = updateRoutingCallback; + this.routeFileUpdateInterval = routeFileUpdateInterval; } protected override Task OnStart(IMessageSession session) diff --git a/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj b/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj index 38f2695..df9aa35 100644 --- a/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj +++ b/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj @@ -1,19 +1,23 @@ - - + + - net452 + net452;netstandard2.0 true $(SolutionDir)NServiceBus.snk - true + - NServiceBus support for defining message routing via XML file - true + NServiceBus support for defining message routing via XML files + - + + + + + \ No newline at end of file diff --git a/src/NServiceBus.FileBasedRouting/PublishRoutingConnector.cs b/src/NServiceBus.FileBasedRouting/PublishRoutingConnector.cs index 609e4aa..620f25d 100644 --- a/src/NServiceBus.FileBasedRouting/PublishRoutingConnector.cs +++ b/src/NServiceBus.FileBasedRouting/PublishRoutingConnector.cs @@ -26,7 +26,7 @@ public PublishRoutingConnector(UnicastSubscriberTable routingTable, EndpointInst public override async Task Invoke(IOutgoingPublishContext context, Func stage) { var eventType = context.Message.MessageType; - var routingStrategies = Route(eventType).ToList(); + var routingStrategies = Route(eventType, context).ToList(); if (routingStrategies.Count == 0) { //No subscribers for this message. @@ -45,14 +45,14 @@ public override async Task Invoke(IOutgoingPublishContext context, Func Route(Type messageType) + IEnumerable Route(Type messageType, IOutgoingPublishContext context) { var routes = routingTable.GetRoutesFor(messageType); - var selectedDestinations = SelectDestinationsForEachEndpoint(routes); + var selectedDestinations = SelectDestinationsForEachEndpoint(routes, context); return selectedDestinations.Select(destination => new UnicastRoutingStrategy(destination)); } - HashSet SelectDestinationsForEachEndpoint(IEnumerable routeGroups) + HashSet SelectDestinationsForEachEndpoint(IEnumerable routeGroups, IOutgoingPublishContext context) { //Make sure we are sending only one to each transport destination. Might happen when there are multiple routing information sources. var addresses = new HashSet(); @@ -73,7 +73,9 @@ HashSet SelectDestinationsForEachEndpoint(IEnumerable else { var candidates = group.Routes.SelectMany(ResolveRoute).ToArray(); - var selected = distributionPolicy.GetDistributionStrategy(group.EndpointName, DistributionStrategyScope.Publish).SelectReceiver(candidates); + var distributionStrategy = distributionPolicy.GetDistributionStrategy(@group.EndpointName, DistributionStrategyScope.Publish); + var distributionContext = new DistributionContext(candidates, context.Message, context.MessageId, context.Headers, resolveTransportAddress, context.Extensions); + var selected = distributionStrategy.SelectDestination(distributionContext); addresses.Add(selected); } } diff --git a/src/Contracts/Commands/DemoCommand.cs b/src/Sample/Contracts/Commands/DemoCommand.cs similarity index 100% rename from src/Contracts/Commands/DemoCommand.cs rename to src/Sample/Contracts/Commands/DemoCommand.cs diff --git a/src/Contracts/Contracts.csproj b/src/Sample/Contracts/Contracts.csproj similarity index 71% rename from src/Contracts/Contracts.csproj rename to src/Sample/Contracts/Contracts.csproj index 99adb8e..ff18cb0 100644 --- a/src/Contracts/Contracts.csproj +++ b/src/Sample/Contracts/Contracts.csproj @@ -1,9 +1,11 @@ - - + + net452 + + \ No newline at end of file diff --git a/src/Contracts/Events/DemoCommandReceived.cs b/src/Sample/Contracts/Events/DemoCommandReceived.cs similarity index 100% rename from src/Contracts/Events/DemoCommandReceived.cs rename to src/Sample/Contracts/Events/DemoCommandReceived.cs diff --git a/src/Contracts/Events/DemoEvent.cs b/src/Sample/Contracts/Events/DemoEvent.cs similarity index 100% rename from src/Contracts/Events/DemoEvent.cs rename to src/Sample/Contracts/Events/DemoEvent.cs diff --git a/src/EndpointA/DemoCommandReceivedHandler.cs b/src/Sample/EndpointA/DemoCommandReceivedHandler.cs similarity index 100% rename from src/EndpointA/DemoCommandReceivedHandler.cs rename to src/Sample/EndpointA/DemoCommandReceivedHandler.cs diff --git a/src/Sample/EndpointA/EndpointA.csproj b/src/Sample/EndpointA/EndpointA.csproj new file mode 100644 index 0000000..e85c4bd --- /dev/null +++ b/src/Sample/EndpointA/EndpointA.csproj @@ -0,0 +1,22 @@ + + + + net452 + Exe + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/EndpointA/Program.cs b/src/Sample/EndpointA/Program.cs similarity index 95% rename from src/EndpointA/Program.cs rename to src/Sample/EndpointA/Program.cs index fdf21b2..2999b42 100644 --- a/src/EndpointA/Program.cs +++ b/src/Sample/EndpointA/Program.cs @@ -10,12 +10,11 @@ class Program static async Task Main() { var endpointConfiguration = new EndpointConfiguration("endpointA"); - + endpointConfiguration.EnableInstallers(); endpointConfiguration.UsePersistence(); endpointConfiguration.SendFailedMessagesTo("error"); var routingConfig = endpointConfiguration.UseTransport().Routing(); - routingConfig.RegisterPublisher(typeof(DemoCommandReceived), "endpointB"); routingConfig.InstanceMappingFile().FilePath("instance-mapping.xml"); routingConfig.UseFileBasedRouting(); diff --git a/src/EndpointA/endpoints.xml b/src/Sample/EndpointA/endpoints.xml similarity index 100% rename from src/EndpointA/endpoints.xml rename to src/Sample/EndpointA/endpoints.xml diff --git a/src/EndpointA/instance-mapping.xml b/src/Sample/EndpointA/instance-mapping.xml similarity index 100% rename from src/EndpointA/instance-mapping.xml rename to src/Sample/EndpointA/instance-mapping.xml diff --git a/src/Sample/EndpointB_1/EndpointB_1.csproj b/src/Sample/EndpointB_1/EndpointB_1.csproj new file mode 100644 index 0000000..5d87af6 --- /dev/null +++ b/src/Sample/EndpointB_1/EndpointB_1.csproj @@ -0,0 +1,22 @@ + + + + net452 + Exe + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/EndpointB_1/Program.cs b/src/Sample/EndpointB_1/Program.cs similarity index 100% rename from src/EndpointB_1/Program.cs rename to src/Sample/EndpointB_1/Program.cs diff --git a/src/Sample/EndpointB_2/EndpointB_2.csproj b/src/Sample/EndpointB_2/EndpointB_2.csproj new file mode 100644 index 0000000..5d87af6 --- /dev/null +++ b/src/Sample/EndpointB_2/EndpointB_2.csproj @@ -0,0 +1,22 @@ + + + + net452 + Exe + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/EndpointB_2/Program.cs b/src/Sample/EndpointB_2/Program.cs similarity index 100% rename from src/EndpointB_2/Program.cs rename to src/Sample/EndpointB_2/Program.cs diff --git a/src/EndpointB/Configuration.cs b/src/Sample/EndpointB_Shared/Configuration.cs similarity index 93% rename from src/EndpointB/Configuration.cs rename to src/Sample/EndpointB_Shared/Configuration.cs index cfb554d..87a0de3 100644 --- a/src/EndpointB/Configuration.cs +++ b/src/Sample/EndpointB_Shared/Configuration.cs @@ -10,12 +10,11 @@ public static async Task Start(string discriminator) { var endpointConfiguration = new EndpointConfiguration("endpointB"); endpointConfiguration.MakeInstanceUniquelyAddressable(discriminator); - + endpointConfiguration.EnableInstallers(); endpointConfiguration.UsePersistence(); endpointConfiguration.SendFailedMessagesTo("error"); var routingConfig = endpointConfiguration.UseTransport().Routing(); - routingConfig.RegisterPublisher(typeof(DemoEvent), "endpointA"); routingConfig.UseFileBasedRouting(); var endpoint = await Endpoint.Start(endpointConfiguration) diff --git a/src/EndpointB/DemoCommandHandler.cs b/src/Sample/EndpointB_Shared/DemoCommandHandler.cs similarity index 100% rename from src/EndpointB/DemoCommandHandler.cs rename to src/Sample/EndpointB_Shared/DemoCommandHandler.cs diff --git a/src/EndpointB/DemoEventHandler.cs b/src/Sample/EndpointB_Shared/DemoEventHandler.cs similarity index 100% rename from src/EndpointB/DemoEventHandler.cs rename to src/Sample/EndpointB_Shared/DemoEventHandler.cs diff --git a/src/Tests.Contracts/Tests.Contracts.csproj b/src/Tests.Contracts/Tests.Contracts.csproj index 4584924..db09776 100644 --- a/src/Tests.Contracts/Tests.Contracts.csproj +++ b/src/Tests.Contracts/Tests.Contracts.csproj @@ -1,8 +1,9 @@ - - + + - net452 + net452;netstandard2.0 true $(SolutionDir)NServiceBus.snk + \ No newline at end of file diff --git a/src/Tests/EndpointBasedIntegrationTests.cs b/src/Tests/EndpointBasedIntegrationTests.cs index 036825c..b05297d 100644 --- a/src/Tests/EndpointBasedIntegrationTests.cs +++ b/src/Tests/EndpointBasedIntegrationTests.cs @@ -67,9 +67,7 @@ public async Task Should_read_custom_file() static async Task> GetRouting(string filePath) { var endpointConfiguration = new EndpointConfiguration("test"); - endpointConfiguration.UsePersistence(); - endpointConfiguration.SendFailedMessagesTo("error"); - var routing = endpointConfiguration.UseTransport().Routing(); + var routing = endpointConfiguration.UseTransport().Routing(); if (filePath == null) { diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index 0b5bbac..5be9aa7 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -1,15 +1,21 @@ - - + + - net452 + net452;netcoreapp2.0 true $(SolutionDir)NServiceBus.snk + true + - - - - + + + + + + + + \ No newline at end of file From b1d4aeb47f91a266074d559a31c0365074057a98 Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Thu, 1 Feb 2018 09:07:33 +0100 Subject: [PATCH 5/6] Prepare RC4 (#33) * remove unnecessary using statement * replacing wildcard dependencies * update nsb.core dependency to rc1 --- .../NServiceBus.FileBasedRouting.csproj | 2 +- src/Sample/Contracts/Contracts.csproj | 2 +- src/Sample/EndpointA/EndpointA.csproj | 2 +- src/Sample/EndpointB_1/EndpointB_1.csproj | 2 +- src/Sample/EndpointB_2/EndpointB_2.csproj | 2 +- src/Sample/EndpointB_Shared/Configuration.cs | 1 - 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj b/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj index df9aa35..925a82b 100644 --- a/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj +++ b/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Sample/Contracts/Contracts.csproj b/src/Sample/Contracts/Contracts.csproj index ff18cb0..4821b40 100644 --- a/src/Sample/Contracts/Contracts.csproj +++ b/src/Sample/Contracts/Contracts.csproj @@ -5,7 +5,7 @@ - + \ No newline at end of file diff --git a/src/Sample/EndpointA/EndpointA.csproj b/src/Sample/EndpointA/EndpointA.csproj index e85c4bd..75edb8a 100644 --- a/src/Sample/EndpointA/EndpointA.csproj +++ b/src/Sample/EndpointA/EndpointA.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Sample/EndpointB_1/EndpointB_1.csproj b/src/Sample/EndpointB_1/EndpointB_1.csproj index 5d87af6..9a9b366 100644 --- a/src/Sample/EndpointB_1/EndpointB_1.csproj +++ b/src/Sample/EndpointB_1/EndpointB_1.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Sample/EndpointB_2/EndpointB_2.csproj b/src/Sample/EndpointB_2/EndpointB_2.csproj index 5d87af6..9a9b366 100644 --- a/src/Sample/EndpointB_2/EndpointB_2.csproj +++ b/src/Sample/EndpointB_2/EndpointB_2.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Sample/EndpointB_Shared/Configuration.cs b/src/Sample/EndpointB_Shared/Configuration.cs index 87a0de3..2081b92 100644 --- a/src/Sample/EndpointB_Shared/Configuration.cs +++ b/src/Sample/EndpointB_Shared/Configuration.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Tasks; -using Contracts.Events; using NServiceBus; using NServiceBus.FileBasedRouting; From d1af7bce7f5362e73f127183abd5dc51aaf4670d Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Wed, 9 May 2018 00:47:44 -0500 Subject: [PATCH 6/6] Update packages to RTM versions (#36) --- .../NServiceBus.FileBasedRouting.csproj | 2 +- src/Sample/Contracts/Contracts.csproj | 2 +- src/Sample/EndpointA/EndpointA.csproj | 2 +- src/Sample/EndpointB_1/EndpointB_1.csproj | 2 +- src/Sample/EndpointB_2/EndpointB_2.csproj | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj b/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj index 925a82b..daa8cd0 100644 --- a/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj +++ b/src/NServiceBus.FileBasedRouting/NServiceBus.FileBasedRouting.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Sample/Contracts/Contracts.csproj b/src/Sample/Contracts/Contracts.csproj index 4821b40..973f1be 100644 --- a/src/Sample/Contracts/Contracts.csproj +++ b/src/Sample/Contracts/Contracts.csproj @@ -5,7 +5,7 @@ - + \ No newline at end of file diff --git a/src/Sample/EndpointA/EndpointA.csproj b/src/Sample/EndpointA/EndpointA.csproj index 75edb8a..8fc078b 100644 --- a/src/Sample/EndpointA/EndpointA.csproj +++ b/src/Sample/EndpointA/EndpointA.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Sample/EndpointB_1/EndpointB_1.csproj b/src/Sample/EndpointB_1/EndpointB_1.csproj index 9a9b366..fa9e054 100644 --- a/src/Sample/EndpointB_1/EndpointB_1.csproj +++ b/src/Sample/EndpointB_1/EndpointB_1.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Sample/EndpointB_2/EndpointB_2.csproj b/src/Sample/EndpointB_2/EndpointB_2.csproj index 9a9b366..fa9e054 100644 --- a/src/Sample/EndpointB_2/EndpointB_2.csproj +++ b/src/Sample/EndpointB_2/EndpointB_2.csproj @@ -11,7 +11,7 @@ - +