diff --git a/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj b/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj index a2d0d06..2b83fe4 100644 --- a/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj +++ b/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj @@ -7,11 +7,11 @@ - - + + - - + + diff --git a/Examples/01-PublishSubscribe/Program.cs b/Examples/01-PublishSubscribe/Program.cs index a53b65b..295de7b 100644 --- a/Examples/01-PublishSubscribe/Program.cs +++ b/Examples/01-PublishSubscribe/Program.cs @@ -17,6 +17,8 @@ using Tapeti.UnityContainer; using Unity; using Container = SimpleInjector.Container; +// ReSharper disable UnusedMember.Global + namespace _01_PublishSubscribe { public class Program diff --git a/Examples/02-DeclareDurableQueues/02-DeclareDurableQueues.csproj b/Examples/02-DeclareDurableQueues/02-DeclareDurableQueues.csproj index c16ddf6..8a580e7 100644 --- a/Examples/02-DeclareDurableQueues/02-DeclareDurableQueues.csproj +++ b/Examples/02-DeclareDurableQueues/02-DeclareDurableQueues.csproj @@ -7,7 +7,7 @@ - + diff --git a/Examples/03-FlowRequestResponse/03-FlowRequestResponse.csproj b/Examples/03-FlowRequestResponse/03-FlowRequestResponse.csproj index bfa9f7e..504511e 100644 --- a/Examples/03-FlowRequestResponse/03-FlowRequestResponse.csproj +++ b/Examples/03-FlowRequestResponse/03-FlowRequestResponse.csproj @@ -7,7 +7,7 @@ - + diff --git a/Examples/04-Transient/04-Transient.csproj b/Examples/04-Transient/04-Transient.csproj index bb077b6..93269e8 100644 --- a/Examples/04-Transient/04-Transient.csproj +++ b/Examples/04-Transient/04-Transient.csproj @@ -7,7 +7,7 @@ - + diff --git a/Examples/05-SpeedTest/05-SpeedTest.csproj b/Examples/05-SpeedTest/05-SpeedTest.csproj index f85333c..7ef9e09 100644 --- a/Examples/05-SpeedTest/05-SpeedTest.csproj +++ b/Examples/05-SpeedTest/05-SpeedTest.csproj @@ -7,7 +7,7 @@ - + diff --git a/Examples/06-StatelessRequestResponse/06-StatelessRequestResponse.csproj b/Examples/06-StatelessRequestResponse/06-StatelessRequestResponse.csproj index 7d6c898..62a3961 100644 --- a/Examples/06-StatelessRequestResponse/06-StatelessRequestResponse.csproj +++ b/Examples/06-StatelessRequestResponse/06-StatelessRequestResponse.csproj @@ -7,7 +7,7 @@ - + diff --git a/Examples/ExampleLib/ExampleConsoleApp.cs b/Examples/ExampleLib/ExampleConsoleApp.cs index 6555c61..cc248be 100644 --- a/Examples/ExampleLib/ExampleConsoleApp.cs +++ b/Examples/ExampleLib/ExampleConsoleApp.cs @@ -23,11 +23,12 @@ namespace ExampleLib { private readonly IDependencyContainer dependencyResolver; private readonly int expectedDoneCount; - private int doneCount = 0; + private int doneCount; private readonly TaskCompletionSource doneSignal = new TaskCompletionSource(); /// Uses Tapeti's IDependencyContainer interface so you can easily switch an example to your favourite IoC container + /// public ExampleConsoleApp(IDependencyContainer dependencyResolver, int expectedDoneCount = 1) { this.dependencyResolver = dependencyResolver; diff --git a/Examples/Messaging.TapetiExample/Messaging.TapetiExample.csproj b/Examples/Messaging.TapetiExample/Messaging.TapetiExample.csproj index cc9631d..055ea68 100644 --- a/Examples/Messaging.TapetiExample/Messaging.TapetiExample.csproj +++ b/Examples/Messaging.TapetiExample/Messaging.TapetiExample.csproj @@ -5,7 +5,7 @@ - + diff --git a/Examples/Messaging.TapetiExample/SpeedTestMessage.cs b/Examples/Messaging.TapetiExample/SpeedTestMessage.cs index 08e03de..f71e216 100644 --- a/Examples/Messaging.TapetiExample/SpeedTestMessage.cs +++ b/Examples/Messaging.TapetiExample/SpeedTestMessage.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations; - -namespace Messaging.TapetiExample +namespace Messaging.TapetiExample { public class SpeedTestMessage { diff --git a/Tapeti.Autofac/AutofacDependencyResolver.cs b/Tapeti.Autofac/AutofacDependencyResolver.cs index cf6cee8..74ac975 100644 --- a/Tapeti.Autofac/AutofacDependencyResolver.cs +++ b/Tapeti.Autofac/AutofacDependencyResolver.cs @@ -33,7 +33,8 @@ namespace Tapeti.Autofac } - /// + /// + /// public AutofacDependencyResolver(ContainerBuilder containerBuilder) { this.containerBuilder = containerBuilder; diff --git a/Tapeti.Autofac/Tapeti.Autofac.csproj b/Tapeti.Autofac/Tapeti.Autofac.csproj index a1d9d12..dfc6146 100644 --- a/Tapeti.Autofac/Tapeti.Autofac.csproj +++ b/Tapeti.Autofac/Tapeti.Autofac.csproj @@ -14,7 +14,7 @@ - + diff --git a/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj b/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj index cb294d3..b2623cf 100644 --- a/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj +++ b/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj @@ -14,7 +14,7 @@ - + diff --git a/Tapeti.CastleWindsor/WindsorDependencyResolver.cs b/Tapeti.CastleWindsor/WindsorDependencyResolver.cs index 419d115..e398157 100644 --- a/Tapeti.CastleWindsor/WindsorDependencyResolver.cs +++ b/Tapeti.CastleWindsor/WindsorDependencyResolver.cs @@ -13,7 +13,8 @@ namespace Tapeti.CastleWindsor private readonly IWindsorContainer container; - /// + /// + /// public WindsorDependencyResolver(IWindsorContainer container) { this.container = container; @@ -51,7 +52,7 @@ namespace Tapeti.CastleWindsor container.Register( Component .For() - .UsingFactoryMethod(() => factory()) + .UsingFactoryMethod(factory) ); } @@ -83,7 +84,7 @@ namespace Tapeti.CastleWindsor container.Register( Component .For() - .UsingFactoryMethod(() => factory()) + .UsingFactoryMethod(factory) .LifestyleSingleton() ); } diff --git a/Tapeti.Cmd/Commands/ExportCommand.cs b/Tapeti.Cmd/Commands/ExportCommand.cs index 2f69aa4..013a9bb 100644 --- a/Tapeti.Cmd/Commands/ExportCommand.cs +++ b/Tapeti.Cmd/Commands/ExportCommand.cs @@ -33,7 +33,7 @@ namespace Tapeti.Cmd.Commands RoutingKey = result.RoutingKey, Queue = QueueName, Properties = result.BasicProperties, - Body = result.Body + Body = result.Body.ToArray() }); if (RemoveMessages) diff --git a/Tapeti.Cmd/Commands/ImportCommand.cs b/Tapeti.Cmd/Commands/ImportCommand.cs index a981051..ecb3eb1 100644 --- a/Tapeti.Cmd/Commands/ImportCommand.cs +++ b/Tapeti.Cmd/Commands/ImportCommand.cs @@ -15,7 +15,7 @@ namespace Tapeti.Cmd.Commands { var messageCount = 0; - foreach (var message in MessageSerializer.Deserialize()) + foreach (var message in MessageSerializer.Deserialize(channel)) { rateLimiter.Execute(() => { diff --git a/Tapeti.Cmd/Mock/MockBasicProperties.cs b/Tapeti.Cmd/Mock/MockBasicProperties.cs new file mode 100644 index 0000000..f55e13c --- /dev/null +++ b/Tapeti.Cmd/Mock/MockBasicProperties.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using RabbitMQ.Client; + +namespace Tapeti.Cmd.Mock +{ + public class MockBasicProperties : IBasicProperties + { + public ushort ProtocolClassId { get; set; } + public string ProtocolClassName { get; set; } + + public void ClearAppId() + { + throw new NotImplementedException(); + } + + public void ClearClusterId() + { + throw new NotImplementedException(); + } + + public void ClearContentEncoding() + { + throw new NotImplementedException(); + } + + public void ClearContentType() + { + throw new NotImplementedException(); + } + + public void ClearCorrelationId() + { + throw new NotImplementedException(); + } + + public void ClearDeliveryMode() + { + throw new NotImplementedException(); + } + + public void ClearExpiration() + { + throw new NotImplementedException(); + } + + public void ClearHeaders() + { + throw new NotImplementedException(); + } + + public void ClearMessageId() + { + throw new NotImplementedException(); + } + + public void ClearPriority() + { + throw new NotImplementedException(); + } + + public void ClearReplyTo() + { + throw new NotImplementedException(); + } + + public void ClearTimestamp() + { + throw new NotImplementedException(); + } + + public void ClearType() + { + throw new NotImplementedException(); + } + + public void ClearUserId() + { + throw new NotImplementedException(); + } + + public bool IsAppIdPresent() + { + throw new NotImplementedException(); + } + + public bool IsClusterIdPresent() + { + throw new NotImplementedException(); + } + + public bool IsContentEncodingPresent() + { + throw new NotImplementedException(); + } + + public bool IsContentTypePresent() + { + throw new NotImplementedException(); + } + + public bool IsCorrelationIdPresent() + { + throw new NotImplementedException(); + } + + public bool IsDeliveryModePresent() + { + throw new NotImplementedException(); + } + + public bool IsExpirationPresent() + { + throw new NotImplementedException(); + } + + public bool IsHeadersPresent() + { + throw new NotImplementedException(); + } + + public bool IsMessageIdPresent() + { + throw new NotImplementedException(); + } + + public bool IsPriorityPresent() + { + throw new NotImplementedException(); + } + + public bool IsReplyToPresent() + { + throw new NotImplementedException(); + } + + public bool IsTimestampPresent() + { + throw new NotImplementedException(); + } + + public bool IsTypePresent() + { + throw new NotImplementedException(); + } + + public bool IsUserIdPresent() + { + throw new NotImplementedException(); + } + + public string AppId { get; set; } + public string ClusterId { get; set; } + public string ContentEncoding { get; set; } + public string ContentType { get; set; } + public string CorrelationId { get; set; } + public byte DeliveryMode { get; set; } + public string Expiration { get; set; } + public IDictionary Headers { get; set; } + public string MessageId { get; set; } + public bool Persistent { get; set; } + public byte Priority { get; set; } + public string ReplyTo { get; set; } + public PublicationAddress ReplyToAddress { get; set; } + public AmqpTimestamp Timestamp { get; set; } + public string Type { get; set; } + public string UserId { get; set; } + } +} diff --git a/Tapeti.Cmd/Program.cs b/Tapeti.Cmd/Program.cs index 6862f78..99c412d 100644 --- a/Tapeti.Cmd/Program.cs +++ b/Tapeti.Cmd/Program.cs @@ -5,8 +5,8 @@ using System.IO; using System.Text; using CommandLine; using RabbitMQ.Client; -using RabbitMQ.Client.Framing; using Tapeti.Cmd.Commands; +using Tapeti.Cmd.Mock; using Tapeti.Cmd.RateLimiter; using Tapeti.Cmd.Serialization; @@ -256,7 +256,7 @@ namespace Tapeti.Cmd private static IRateLimiter GetRateLimiter(int? maxRate) { - if (maxRate.GetValueOrDefault() <= 0) + if (!maxRate.HasValue || maxRate.Value <= 0) return new NoRateLimiter(); return new SpreadRateLimiter(maxRate.Value, TimeSpan.FromSeconds(1)); @@ -376,7 +376,7 @@ namespace Tapeti.Cmd Port = options.TargetPort ?? options.Port, VirtualHost = !string.IsNullOrEmpty(options.TargetVirtualHost) ? options.TargetVirtualHost : options.VirtualHost, UserName = !string.IsNullOrEmpty(options.TargetUsername) ? options.TargetUsername : options.Username, - Password = !string.IsNullOrEmpty(options.TargetPassword) ? options.TargetPassword : options.Password, + Password = !string.IsNullOrEmpty(options.TargetPassword) ? options.TargetPassword : options.Password }; return factory.CreateConnection(); @@ -417,7 +417,7 @@ namespace Tapeti.Cmd Queue = "example.queue", RoutingKey = "example.routing.key", DeliveryTag = 42, - Properties = new BasicProperties + Properties = new MockBasicProperties { ContentType = "application/json", DeliveryMode = 2, diff --git a/Tapeti.Cmd/Serialization/EasyNetQMessageSerializer.cs b/Tapeti.Cmd/Serialization/EasyNetQMessageSerializer.cs index db3f589..d0b99ee 100644 --- a/Tapeti.Cmd/Serialization/EasyNetQMessageSerializer.cs +++ b/Tapeti.Cmd/Serialization/EasyNetQMessageSerializer.cs @@ -6,7 +6,6 @@ using System.Text; using System.Text.RegularExpressions; using Newtonsoft.Json; using RabbitMQ.Client; -using RabbitMQ.Client.Framing; namespace Tapeti.Cmd.Serialization { @@ -61,7 +60,7 @@ namespace Tapeti.Cmd.Serialization } - public IEnumerable Deserialize() + public IEnumerable Deserialize(IModel channel) { foreach (var file in Directory.GetFiles(path, "*.*.message.txt")) { @@ -80,8 +79,13 @@ namespace Tapeti.Cmd.Serialization var infoJson = File.ReadAllText(infoFileName); var info = JsonConvert.DeserializeObject(infoJson); + if (info == null) + continue; + var message = info.ToMessage(); - message.Properties = properties.ToBasicProperties(); + if (properties != null) + message.Properties = properties.ToBasicProperties(channel); + message.Body = Encoding.UTF8.GetBytes(body); yield return message; @@ -117,13 +121,13 @@ namespace Tapeti.Cmd.Serialization if (!basicProperties.IsHeadersPresent()) return; - foreach (var header in basicProperties.Headers) - Headers.Add(header.Key, (byte[])header.Value); + foreach (var (key, value) in basicProperties.Headers) + Headers.Add(key, (byte[])value); } - public IBasicProperties ToBasicProperties() + public IBasicProperties ToBasicProperties(IModel channel) { - var basicProperties = new BasicProperties(); + var basicProperties = channel.CreateBasicProperties(); if (ContentTypePresent) basicProperties.ContentType = ContentType; if (ContentEncodingPresent) basicProperties.ContentEncoding = ContentEncoding; @@ -169,6 +173,7 @@ namespace Tapeti.Cmd.Serialization public IDictionary Headers { get => headers; + // ReSharper disable once UnusedMember.Local set { headers = value; HeadersPresent = true; } } @@ -268,6 +273,7 @@ namespace Tapeti.Cmd.Serialization private class EasyNetQMessageReceivedInfo { + // ReSharper disable once UnusedAutoPropertyAccessor.Local - used by JSON deserialization public string ConsumerTag { get; set; } public ulong DeliverTag { get; set; } public bool Redelivered { get; set; } diff --git a/Tapeti.Cmd/Serialization/IMessageSerializer.cs b/Tapeti.Cmd/Serialization/IMessageSerializer.cs index e8ce5a3..3aae717 100644 --- a/Tapeti.Cmd/Serialization/IMessageSerializer.cs +++ b/Tapeti.Cmd/Serialization/IMessageSerializer.cs @@ -19,6 +19,6 @@ namespace Tapeti.Cmd.Serialization public interface IMessageSerializer : IDisposable { void Serialize(Message message); - IEnumerable Deserialize(); + IEnumerable Deserialize(IModel channel); } } diff --git a/Tapeti.Cmd/Serialization/SingleFileJSONMessageSerializer.cs b/Tapeti.Cmd/Serialization/SingleFileJSONMessageSerializer.cs index f8210fc..05f2e88 100644 --- a/Tapeti.Cmd/Serialization/SingleFileJSONMessageSerializer.cs +++ b/Tapeti.Cmd/Serialization/SingleFileJSONMessageSerializer.cs @@ -5,7 +5,6 @@ using System.Text; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using RabbitMQ.Client; -using RabbitMQ.Client.Framing; namespace Tapeti.Cmd.Serialization { @@ -42,7 +41,7 @@ namespace Tapeti.Cmd.Serialization } - public IEnumerable Deserialize() + public IEnumerable Deserialize(IModel channel) { using (var reader = new StreamReader(stream, encoding)) { @@ -56,7 +55,7 @@ namespace Tapeti.Cmd.Serialization if (serializableMessage == null) continue; - yield return serializableMessage.ToMessage(); + yield return serializableMessage.ToMessage(channel); } } } @@ -134,7 +133,7 @@ namespace Tapeti.Cmd.Serialization } - public Message ToMessage() + public Message ToMessage(IModel channel) { return new Message { @@ -143,7 +142,7 @@ namespace Tapeti.Cmd.Serialization Exchange = Exchange, RoutingKey = RoutingKey, Queue = Queue, - Properties = Properties.ToBasicProperties(), + Properties = Properties.ToBasicProperties(channel), Body = Body != null ? Encoding.UTF8.GetBytes(Body.ToString(Formatting.None)) : RawBody @@ -198,17 +197,17 @@ namespace Tapeti.Cmd.Serialization Headers = new Dictionary(); // This assumes header values are UTF-8 encoded strings. This is true for Tapeti. - foreach (var pair in fromProperties.Headers) - Headers.Add(pair.Key, Encoding.UTF8.GetString((byte[])pair.Value)); + foreach (var (key, value) in fromProperties.Headers) + Headers.Add(key, Encoding.UTF8.GetString((byte[])value)); } else Headers = null; } - public IBasicProperties ToBasicProperties() + public IBasicProperties ToBasicProperties(IModel channel) { - var properties = new BasicProperties(); + var properties = channel.CreateBasicProperties(); if (!string.IsNullOrEmpty(AppId)) properties.AppId = AppId; if (!string.IsNullOrEmpty(ClusterId)) properties.ClusterId = ClusterId; @@ -228,8 +227,8 @@ namespace Tapeti.Cmd.Serialization { properties.Headers = new Dictionary(); - foreach (var pair in Headers) - properties.Headers.Add(pair.Key, Encoding.UTF8.GetBytes(pair.Value)); + foreach (var (key, value) in Headers) + properties.Headers.Add(key, Encoding.UTF8.GetBytes(value)); } return properties; diff --git a/Tapeti.Cmd/Tapeti.Cmd.csproj b/Tapeti.Cmd/Tapeti.Cmd.csproj index 9379bdb..388750a 100644 --- a/Tapeti.Cmd/Tapeti.Cmd.csproj +++ b/Tapeti.Cmd/Tapeti.Cmd.csproj @@ -15,9 +15,9 @@ - - - + + + diff --git a/Tapeti.DataAnnotations.Extensions/Tapeti.DataAnnotations.Extensions.csproj b/Tapeti.DataAnnotations.Extensions/Tapeti.DataAnnotations.Extensions.csproj index 056fe45..3de7536 100644 --- a/Tapeti.DataAnnotations.Extensions/Tapeti.DataAnnotations.Extensions.csproj +++ b/Tapeti.DataAnnotations.Extensions/Tapeti.DataAnnotations.Extensions.csproj @@ -18,7 +18,7 @@ - + diff --git a/Tapeti.DataAnnotations/Tapeti.DataAnnotations.csproj b/Tapeti.DataAnnotations/Tapeti.DataAnnotations.csproj index 9a86c4b..27bb111 100644 --- a/Tapeti.DataAnnotations/Tapeti.DataAnnotations.csproj +++ b/Tapeti.DataAnnotations/Tapeti.DataAnnotations.csproj @@ -18,7 +18,7 @@ - + diff --git a/Tapeti.Flow.SQL/SqlConnectionFlowRepository.cs b/Tapeti.Flow.SQL/SqlConnectionFlowRepository.cs index bba7085..19f7a8b 100644 --- a/Tapeti.Flow.SQL/SqlConnectionFlowRepository.cs +++ b/Tapeti.Flow.SQL/SqlConnectionFlowRepository.cs @@ -27,7 +27,8 @@ namespace Tapeti.Flow.SQL private readonly string tableName; - /// + /// + /// public SqlConnectionFlowRepository(string connectionString, string tableName = "Flow") { this.connectionString = connectionString; diff --git a/Tapeti.Flow.SQL/SqlExceptionHelper.cs b/Tapeti.Flow.SQL/SqlExceptionHelper.cs index 5a596a1..e4d507e 100644 --- a/Tapeti.Flow.SQL/SqlExceptionHelper.cs +++ b/Tapeti.Flow.SQL/SqlExceptionHelper.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.Data.SqlClient; -using System.Text; +using System.Linq; + +// ReSharper disable UnusedMember.Global namespace Tapeti.Flow.SQL { @@ -24,16 +26,8 @@ namespace Tapeti.Flow.SQL case Exception exception: { - var sqlExceptions = ExtractSqlExceptions(e); - foreach (var sqlException in sqlExceptions) - { - var sqlErrors = UnwrapSqlErrors(sqlException); - - if (IsRecoverableSQLError(sqlErrors)) - return true; - } - - return false; + var sqlExceptions = ExtractSqlExceptions(exception); + return sqlExceptions.Select(UnwrapSqlErrors).Any(IsRecoverableSQLError); } default: diff --git a/Tapeti.Flow.SQL/Tapeti.Flow.SQL.csproj b/Tapeti.Flow.SQL/Tapeti.Flow.SQL.csproj index 2cb02b9..c23f096 100644 --- a/Tapeti.Flow.SQL/Tapeti.Flow.SQL.csproj +++ b/Tapeti.Flow.SQL/Tapeti.Flow.SQL.csproj @@ -26,7 +26,7 @@ - + diff --git a/Tapeti.Flow/Default/FlowContinuationMiddleware.cs b/Tapeti.Flow/Default/FlowContinuationMiddleware.cs index f610d8b..b07c819 100644 --- a/Tapeti.Flow/Default/FlowContinuationMiddleware.cs +++ b/Tapeti.Flow/Default/FlowContinuationMiddleware.cs @@ -63,7 +63,7 @@ namespace Tapeti.Flow.Default // Do not call when the controller method was filtered, if the same message has two methods return; - if (flowContext?.FlowStateLock != null) + if (flowContext.FlowStateLock != null) { if (!flowContext.IsStoredOrDeleted()) // The exception strategy can set the consume result to Success. Instead, check if the yield point diff --git a/Tapeti.Flow/Default/FlowHandlerContext.cs b/Tapeti.Flow/Default/FlowHandlerContext.cs index fc35b68..6bcbab9 100644 --- a/Tapeti.Flow/Default/FlowHandlerContext.cs +++ b/Tapeti.Flow/Default/FlowHandlerContext.cs @@ -9,13 +9,15 @@ namespace Tapeti.Flow.Default /// internal class FlowHandlerContext : IFlowHandlerContext { - /// + /// + /// public FlowHandlerContext() { } - /// + /// + /// public FlowHandlerContext(IControllerMessageContext source) { if (source == null) diff --git a/Tapeti.Flow/Default/FlowProvider.cs b/Tapeti.Flow/Default/FlowProvider.cs index 123c80b..d7b28b4 100644 --- a/Tapeti.Flow/Default/FlowProvider.cs +++ b/Tapeti.Flow/Default/FlowProvider.cs @@ -22,7 +22,8 @@ namespace Tapeti.Flow.Default private readonly IInternalPublisher publisher; - /// + /// + /// public FlowProvider(ITapetiConfig config, IPublisher publisher) { this.config = config; diff --git a/Tapeti.Flow/Default/FlowStarter.cs b/Tapeti.Flow/Default/FlowStarter.cs index 68c8813..f391fe8 100644 --- a/Tapeti.Flow/Default/FlowStarter.cs +++ b/Tapeti.Flow/Default/FlowStarter.cs @@ -15,7 +15,8 @@ namespace Tapeti.Flow.Default private readonly ITapetiConfig config; - /// + /// + /// public FlowStarter(ITapetiConfig config) { this.config = config; diff --git a/Tapeti.Flow/Default/FlowStore.cs b/Tapeti.Flow/Default/FlowStore.cs index 3b0c9db..f380962 100644 --- a/Tapeti.Flow/Default/FlowStore.cs +++ b/Tapeti.Flow/Default/FlowStore.cs @@ -35,7 +35,8 @@ namespace Tapeti.Flow.Default private volatile bool loaded; - /// + /// + /// public FlowStore(IFlowRepository repository) { this.repository = repository; diff --git a/Tapeti.Flow/FlowExtension.cs b/Tapeti.Flow/FlowExtension.cs index 05a17d2..6c979e9 100644 --- a/Tapeti.Flow/FlowExtension.cs +++ b/Tapeti.Flow/FlowExtension.cs @@ -12,7 +12,8 @@ namespace Tapeti.Flow { private readonly IFlowRepository flowRepository; - /// + /// + /// public FlowExtension(IFlowRepository flowRepository) { this.flowRepository = flowRepository; diff --git a/Tapeti.Flow/FlowHelpers/LockCollection.cs b/Tapeti.Flow/FlowHelpers/LockCollection.cs index d7f929a..309e916 100644 --- a/Tapeti.Flow/FlowHelpers/LockCollection.cs +++ b/Tapeti.Flow/FlowHelpers/LockCollection.cs @@ -11,7 +11,8 @@ namespace Tapeti.Flow.FlowHelpers { private readonly Dictionary locks; - /// + /// + /// public LockCollection(IEqualityComparer comparer) { locks = new Dictionary(comparer); diff --git a/Tapeti.Ninject/NinjectDependencyResolver.cs b/Tapeti.Ninject/NinjectDependencyResolver.cs index 7a2ac17..0e2fdcf 100644 --- a/Tapeti.Ninject/NinjectDependencyResolver.cs +++ b/Tapeti.Ninject/NinjectDependencyResolver.cs @@ -13,7 +13,8 @@ namespace Tapeti.Ninject private readonly IKernel kernel; - /// + /// + /// public NinjectDependencyResolver(IKernel kernel) { this.kernel = kernel; diff --git a/Tapeti.Serilog/Tapeti.Serilog.csproj b/Tapeti.Serilog/Tapeti.Serilog.csproj index fd1f6f5..25d7d29 100644 --- a/Tapeti.Serilog/Tapeti.Serilog.csproj +++ b/Tapeti.Serilog/Tapeti.Serilog.csproj @@ -18,7 +18,7 @@ - + diff --git a/Tapeti.SimpleInjector/SimpleInjectorDependencyResolver.cs b/Tapeti.SimpleInjector/SimpleInjectorDependencyResolver.cs index 1cfbaef..c8a189f 100644 --- a/Tapeti.SimpleInjector/SimpleInjectorDependencyResolver.cs +++ b/Tapeti.SimpleInjector/SimpleInjectorDependencyResolver.cs @@ -14,7 +14,8 @@ namespace Tapeti.SimpleInjector private readonly Lifestyle defaultsLifestyle; private readonly Lifestyle controllersLifestyle; - /// + /// + /// public SimpleInjectorDependencyResolver(Container container, Lifestyle defaultsLifestyle = null, Lifestyle controllersLifestyle = null) { this.container = container; diff --git a/Tapeti.SimpleInjector/Tapeti.SimpleInjector.csproj b/Tapeti.SimpleInjector/Tapeti.SimpleInjector.csproj index c941ce7..050dd5d 100644 --- a/Tapeti.SimpleInjector/Tapeti.SimpleInjector.csproj +++ b/Tapeti.SimpleInjector/Tapeti.SimpleInjector.csproj @@ -19,7 +19,7 @@ - + diff --git a/Tapeti.Tests/Default/TypeNameRoutingKeyStrategyTests.cs b/Tapeti.Tests/Default/TypeNameRoutingKeyStrategyTests.cs index d61f0b2..ed133fb 100644 --- a/Tapeti.Tests/Default/TypeNameRoutingKeyStrategyTests.cs +++ b/Tapeti.Tests/Default/TypeNameRoutingKeyStrategyTests.cs @@ -60,7 +60,8 @@ namespace Tapeti.Tests.Default AssertRoutingKey("acr.test.mixed.case", typeof(ACRTestMIXEDCaseMESSAGE)); } - private void AssertRoutingKey(string expected, Type messageType) + // ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local + private static void AssertRoutingKey(string expected, Type messageType) { if (expected == null) throw new ArgumentNullException(nameof(expected)); if (messageType == null) throw new ArgumentNullException(nameof(messageType)); diff --git a/Tapeti.Tests/Tapeti.Tests.csproj b/Tapeti.Tests/Tapeti.Tests.csproj index f9fa098..cc4c3a6 100644 --- a/Tapeti.Tests/Tapeti.Tests.csproj +++ b/Tapeti.Tests/Tapeti.Tests.csproj @@ -9,9 +9,9 @@ - + - + all runtime; build; native; contentfiles; analyzers diff --git a/Tapeti.Transient/TransientExtension.cs b/Tapeti.Transient/TransientExtension.cs index 2ce8477..ec642e5 100644 --- a/Tapeti.Transient/TransientExtension.cs +++ b/Tapeti.Transient/TransientExtension.cs @@ -11,7 +11,8 @@ namespace Tapeti.Transient private readonly TransientRouter router; - /// + /// + /// public TransientExtension(TimeSpan defaultTimeout, string dynamicQueuePrefix) { this.dynamicQueuePrefix = dynamicQueuePrefix; diff --git a/Tapeti.Transient/TransientGenericBinding.cs b/Tapeti.Transient/TransientGenericBinding.cs index 94c6e6b..f55bb45 100644 --- a/Tapeti.Transient/TransientGenericBinding.cs +++ b/Tapeti.Transient/TransientGenericBinding.cs @@ -21,7 +21,8 @@ namespace Tapeti.Transient public QueueType QueueType => QueueType.Dynamic; - /// + /// + /// public TransientGenericBinding(TransientRouter router, string dynamicQueuePrefix) { this.router = router; diff --git a/Tapeti.Transient/TransientPublisher.cs b/Tapeti.Transient/TransientPublisher.cs index 525e887..3092c86 100644 --- a/Tapeti.Transient/TransientPublisher.cs +++ b/Tapeti.Transient/TransientPublisher.cs @@ -12,7 +12,8 @@ namespace Tapeti.Transient private readonly IPublisher publisher; - /// + /// + /// public TransientPublisher(TransientRouter router, IPublisher publisher) { this.router = router; diff --git a/Tapeti.Transient/TransientRouter.cs b/Tapeti.Transient/TransientRouter.cs index 82e8eb3..c6a79d6 100644 --- a/Tapeti.Transient/TransientRouter.cs +++ b/Tapeti.Transient/TransientRouter.cs @@ -21,7 +21,8 @@ namespace Tapeti.Transient public string TransientResponseQueueName { get; set; } - /// + /// + /// public TransientRouter(TimeSpan defaultTimeout) { defaultTimeoutMs = (int)defaultTimeout.TotalMilliseconds; diff --git a/Tapeti.UnityContainer/Tapeti.UnityContainer.csproj b/Tapeti.UnityContainer/Tapeti.UnityContainer.csproj index 1e3e4a2..42399ca 100644 --- a/Tapeti.UnityContainer/Tapeti.UnityContainer.csproj +++ b/Tapeti.UnityContainer/Tapeti.UnityContainer.csproj @@ -14,7 +14,7 @@ - + diff --git a/Tapeti.UnityContainer/UnityDependencyResolver.cs b/Tapeti.UnityContainer/UnityDependencyResolver.cs index 98db82b..a3ab84e 100644 --- a/Tapeti.UnityContainer/UnityDependencyResolver.cs +++ b/Tapeti.UnityContainer/UnityDependencyResolver.cs @@ -13,7 +13,8 @@ namespace Tapeti.UnityContainer private readonly IUnityContainer container; - /// + /// + /// public UnityDependencyResolver(IUnityContainer container) { this.container = container; diff --git a/Tapeti/Config/IBinding.cs b/Tapeti/Config/IBinding.cs index 7d924fa..8cbb45f 100644 --- a/Tapeti/Config/IBinding.cs +++ b/Tapeti/Config/IBinding.cs @@ -1,5 +1,4 @@ using System; -using System.Threading; using System.Threading.Tasks; namespace Tapeti.Config diff --git a/Tapeti/Config/IExceptionStrategyContext.cs b/Tapeti/Config/IExceptionStrategyContext.cs index e418a96..7945404 100644 --- a/Tapeti/Config/IExceptionStrategyContext.cs +++ b/Tapeti/Config/IExceptionStrategyContext.cs @@ -1,6 +1,7 @@ using System; // ReSharper disable UnusedMember.Global +// ReSharper disable UnusedMemberInSuper.Global namespace Tapeti.Config { diff --git a/Tapeti/Config/IPublishContext.cs b/Tapeti/Config/IPublishContext.cs index 30a51b6..a5fb435 100644 --- a/Tapeti/Config/IPublishContext.cs +++ b/Tapeti/Config/IPublishContext.cs @@ -1,4 +1,5 @@ // ReSharper disable UnusedMember.Global +// ReSharper disable UnusedMemberInSuper.Global namespace Tapeti.Config { diff --git a/Tapeti/Connection/ITapetiClient.cs b/Tapeti/Connection/ITapetiClient.cs index 4a9e4de..e8c7654 100644 --- a/Tapeti/Connection/ITapetiClient.cs +++ b/Tapeti/Connection/ITapetiClient.cs @@ -10,7 +10,7 @@ namespace Tapeti.Connection /// /// Defines a queue binding to an exchange using a routing key /// - public struct QueueBinding : IEquatable + public readonly struct QueueBinding : IEquatable { /// public readonly string Exchange; diff --git a/Tapeti/Connection/TapetiBasicConsumer.cs b/Tapeti/Connection/TapetiBasicConsumer.cs index 92fec5a..7dd969a 100644 --- a/Tapeti/Connection/TapetiBasicConsumer.cs +++ b/Tapeti/Connection/TapetiBasicConsumer.cs @@ -24,13 +24,19 @@ namespace Tapeti.Connection /// - public override void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body) + public override void HandleBasicDeliver(string consumerTag, + ulong deliveryTag, + bool redelivered, + string exchange, + string routingKey, + IBasicProperties properties, + ReadOnlyMemory body) { Task.Run(async () => { try { - var response = await consumer.Consume(exchange, routingKey, new RabbitMQMessageProperties(properties), body); + var response = await consumer.Consume(exchange, routingKey, new RabbitMQMessageProperties(properties), body.ToArray()); await onRespond(deliveryTag, response); } catch diff --git a/Tapeti/Connection/TapetiClient.cs b/Tapeti/Connection/TapetiClient.cs index 71a49d1..c41e7b4 100644 --- a/Tapeti/Connection/TapetiClient.cs +++ b/Tapeti/Connection/TapetiClient.cs @@ -351,7 +351,7 @@ namespace Tapeti.Connection } catch (OperationInterruptedException e) { - if (e.ShutdownReason.ReplyCode == RabbitMQ.Client.Framing.Constants.PreconditionFailed) + if (e.ShutdownReason.ReplyCode == Constants.PreconditionFailed) retry = true; else throw; @@ -519,9 +519,10 @@ namespace Tapeti.Connection var bindings = JsonConvert.DeserializeObject>(content); // Filter out the binding to an empty source, which is always present for direct-to-queue routing - return bindings + return bindings? .Where(binding => !string.IsNullOrEmpty(binding.Source)) - .Select(binding => new QueueBinding(binding.Source, binding.RoutingKey)); + .Select(binding => new QueueBinding(binding.Source, binding.RoutingKey)) + ?? Enumerable.Empty(); }); } @@ -655,7 +656,7 @@ namespace Tapeti.Connection Password = connectionParams.Password, AutomaticRecoveryEnabled = false, TopologyRecoveryEnabled = false, - RequestedHeartbeat = 30 + RequestedHeartbeat = TimeSpan.FromSeconds(30) }; if (connectionParams.ClientProperties != null) diff --git a/Tapeti/Connection/TapetiSubscriber.cs b/Tapeti/Connection/TapetiSubscriber.cs index 34c08e1..3c207a7 100644 --- a/Tapeti/Connection/TapetiSubscriber.cs +++ b/Tapeti/Connection/TapetiSubscriber.cs @@ -18,7 +18,6 @@ namespace Tapeti.Connection private CancellationTokenSource initializeCancellationTokenSource; - /// public TapetiSubscriber(Func clientFactory, ITapetiConfig config) { this.clientFactory = clientFactory; diff --git a/Tapeti/Default/ControllerBindingContext.cs b/Tapeti/Default/ControllerBindingContext.cs index 8eb0150..9318c98 100644 --- a/Tapeti/Default/ControllerBindingContext.cs +++ b/Tapeti/Default/ControllerBindingContext.cs @@ -118,7 +118,10 @@ namespace Tapeti.Default public bool HasBinding => Binding != null; - /// + /// + /// Creates a new default implementation for IBindingParameter + /// + /// public ControllerBindingParameter(ParameterInfo info) { Info = info; @@ -155,6 +158,10 @@ namespace Tapeti.Default public bool HasHandler => Handler != null; + /// + /// Creates a new default implementation for IBindingResult + /// + /// public ControllerBindingResult(ParameterInfo info) { Info = info; diff --git a/Tapeti/Default/ControllerMessageContext.cs b/Tapeti/Default/ControllerMessageContext.cs index b5aa037..92ac61c 100644 --- a/Tapeti/Default/ControllerMessageContext.cs +++ b/Tapeti/Default/ControllerMessageContext.cs @@ -32,7 +32,6 @@ namespace Tapeti.Default IControllerMethodBinding IControllerMessageContext.Binding => decoratedContext.Binding as IControllerMethodBinding; - /// public ControllerMessageContext(IMessageContext decoratedContext) { this.decoratedContext = decoratedContext; diff --git a/Tapeti/Default/ExceptionStrategyContext.cs b/Tapeti/Default/ExceptionStrategyContext.cs index 56e2a8a..f61d41f 100644 --- a/Tapeti/Default/ExceptionStrategyContext.cs +++ b/Tapeti/Default/ExceptionStrategyContext.cs @@ -18,7 +18,6 @@ namespace Tapeti.Default public Exception Exception { get; } - /// public ExceptionStrategyContext(IMessageContext messageContext, Exception exception) { MessageContext = messageContext; diff --git a/Tapeti/Default/FallbackStringEnumConverter.cs b/Tapeti/Default/FallbackStringEnumConverter.cs index 9801f6c..8967c0e 100644 --- a/Tapeti/Default/FallbackStringEnumConverter.cs +++ b/Tapeti/Default/FallbackStringEnumConverter.cs @@ -60,7 +60,7 @@ namespace Tapeti.Default if (reader.TokenType != JsonToken.String) throw new JsonSerializationException($"Unexpected token {reader.TokenType} when parsing enum"); - var enumText = reader.Value.ToString(); + var enumText = reader.Value?.ToString() ?? ""; if (enumText == string.Empty && isNullable) return null; diff --git a/Tapeti/Default/JsonMessageSerializer.cs b/Tapeti/Default/JsonMessageSerializer.cs index e15a4d3..cebed7d 100644 --- a/Tapeti/Default/JsonMessageSerializer.cs +++ b/Tapeti/Default/JsonMessageSerializer.cs @@ -21,7 +21,8 @@ namespace Tapeti.Default private readonly JsonSerializerSettings serializerSettings; - /// + /// + /// public JsonMessageSerializer() { serializerSettings = new JsonSerializerSettings diff --git a/Tapeti/Default/MessageProperties.cs b/Tapeti/Default/MessageProperties.cs index 64b2eb2..3184da9 100644 --- a/Tapeti/Default/MessageProperties.cs +++ b/Tapeti/Default/MessageProperties.cs @@ -29,13 +29,15 @@ namespace Tapeti.Default public DateTime? Timestamp { get; set; } - /// + /// + /// public MessageProperties() { } - /// + /// + /// public MessageProperties(IMessageProperties source) { if (source == null) diff --git a/Tapeti/Default/PublishResultBinding.cs b/Tapeti/Default/PublishResultBinding.cs index 933302a..dd0bee9 100644 --- a/Tapeti/Default/PublishResultBinding.cs +++ b/Tapeti/Default/PublishResultBinding.cs @@ -30,6 +30,7 @@ namespace Tapeti.Default // Verify the return type matches with the Request attribute of the message class. This is a backwards incompatible change in // Tapeti 1.2: if you just want to publish another message as a result of the incoming message, explicitly call IPublisher.Publish. + // ReSharper disable once ConvertIfStatementToSwitchStatement if (!hasClassResult && expectedClassResult != null || hasClassResult && expectedClassResult != actualType) throw new ArgumentException($"Message handler must return type {expectedClassResult?.FullName ?? "void"} in controller {context.Method.DeclaringType?.FullName}, method {context.Method.Name}, found: {actualType?.FullName ?? "void"}"); diff --git a/Tapeti/Default/RabbitMQMessageProperties.cs b/Tapeti/Default/RabbitMQMessageProperties.cs index 3ddd967..0b524ae 100644 --- a/Tapeti/Default/RabbitMQMessageProperties.cs +++ b/Tapeti/Default/RabbitMQMessageProperties.cs @@ -56,14 +56,16 @@ namespace Tapeti.Default } - /// + /// + /// public RabbitMQMessageProperties(IBasicProperties basicProperties) { BasicProperties = basicProperties; } - /// + /// + /// public RabbitMQMessageProperties(IBasicProperties basicProperties, IMessageProperties source) { BasicProperties = basicProperties; diff --git a/Tapeti/IConnection.cs b/Tapeti/IConnection.cs index eedc765..4453362 100644 --- a/Tapeti/IConnection.cs +++ b/Tapeti/IConnection.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; // ReSharper disable UnusedMember.Global +// ReSharper disable UnusedMemberInSuper.Global namespace Tapeti { diff --git a/Tapeti/ILogger.cs b/Tapeti/ILogger.cs index 8fbabd8..c24a798 100644 --- a/Tapeti/ILogger.cs +++ b/Tapeti/ILogger.cs @@ -2,6 +2,7 @@ using Tapeti.Config; // ReSharper disable UnusedMember.Global +// ReSharper disable UnusedMemberInSuper.Global namespace Tapeti { diff --git a/Tapeti/IPublisher.cs b/Tapeti/IPublisher.cs index 417dc1a..70cb754 100644 --- a/Tapeti/IPublisher.cs +++ b/Tapeti/IPublisher.cs @@ -3,7 +3,7 @@ using System.Linq.Expressions; using System.Threading.Tasks; using Tapeti.Config; -// ReSharper disable once UnusedMember.Global +// ReSharper disable UnusedMember.Global namespace Tapeti { diff --git a/Tapeti/ISubscriber.cs b/Tapeti/ISubscriber.cs index 3110f65..1e7d864 100644 --- a/Tapeti/ISubscriber.cs +++ b/Tapeti/ISubscriber.cs @@ -1,6 +1,8 @@ using System; using System.Threading.Tasks; +// ReSharper disable UnusedMember.Global + namespace Tapeti { /// diff --git a/Tapeti/Tapeti.csproj b/Tapeti/Tapeti.csproj index f701e63..3a6632e 100644 --- a/Tapeti/Tapeti.csproj +++ b/Tapeti/Tapeti.csproj @@ -18,9 +18,9 @@ - - - + + + diff --git a/Tapeti/TapetiAppSettingsConnectionParams.cs b/Tapeti/TapetiAppSettingsConnectionParams.cs index a18285b..87138b7 100644 --- a/Tapeti/TapetiAppSettingsConnectionParams.cs +++ b/Tapeti/TapetiAppSettingsConnectionParams.cs @@ -1,6 +1,8 @@ using System.Configuration; using System.Linq; +// ReSharper disable UnusedMember.Global + namespace Tapeti { /// @@ -23,6 +25,7 @@ namespace Tapeti public class TapetiAppSettingsConnectionParams : TapetiConnectionParams { private const string DefaultPrefix = "rabbitmq:"; + // ReSharper disable InconsistentNaming private const string KeyHostname = "hostname"; private const string KeyPort = "port"; private const string KeyVirtualHost = "virtualhost"; @@ -31,9 +34,10 @@ namespace Tapeti private const string KeyPrefetchCount = "prefetchcount"; private const string KeyManagementPort = "managementport"; private const string KeyClientProperty = "clientproperty:"; + // ReSharper restore InconsistentNaming - private struct AppSettingsKey + private readonly struct AppSettingsKey { public readonly string Entry; public readonly string Parameter; diff --git a/Tapeti/TapetiConnectionParams.cs b/Tapeti/TapetiConnectionParams.cs index ac739b1..a3a6ea6 100644 --- a/Tapeti/TapetiConnectionParams.cs +++ b/Tapeti/TapetiConnectionParams.cs @@ -65,7 +65,8 @@ namespace Tapeti } - /// + /// + /// public TapetiConnectionParams() { }