Skip to content

Commit

Permalink
Add .editorconfig + code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sanych-sun committed Jan 25, 2024
1 parent c09b06e commit 4303da8
Show file tree
Hide file tree
Showing 67 changed files with 569 additions and 381 deletions.
132 changes: 132 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = false
insert_final_newline = false
indent_style = space
indent_size = 4

[{*.yml,*.yaml}]
indent_size = 2

[*.json]
indent_size = 2

[{*.sh,*.ps1}]
indent_size = 2

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2

# Code files
[*.{cs,csx,vb,vbx}]
insert_final_newline = true
###############################
# .NET Coding Conventions #
###############################
[*.{cs,vb}]
# Organize usings
dotnet_sort_system_directives_first = true
# this. preferences
dotnet_style_qualification_for_field = true:warning
dotnet_style_qualification_for_property = true:warning
dotnet_style_qualification_for_method = true:warning
dotnet_style_qualification_for_event = true:warning
# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
dotnet_style_readonly_field = true:suggestion
# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
###############################
# Naming Conventions #
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
###############################
# C# Coding Conventions #
###############################
[*.cs]
# var preferences
csharp_style_var_for_built_in_types = true:silent
csharp_style_var_when_type_is_apparent = true:silent
csharp_style_var_elsewhere = true:silent
# Expression-bodied members
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
# Pattern matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
# Null-checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion
# Expression-level preferences
csharp_prefer_braces = true:silent
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
###############################
# C# Formatting Rules #
###############################
# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# Indentation preferences
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left
# Space preferences
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace RabbitMQ.Next.Examples.DemoSaslAuthMechanism;

class Program
internal static class Program
{
static async Task Main()
private static async Task Main()
{
Console.WriteLine("Hello World! Will try to connect RabbitMQ server with RABBIT-CR-DEMO auth mechanism.");

Expand All @@ -21,4 +21,4 @@ static async Task Main()

Console.ReadKey();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public class DummyDto
{
public string SomeProperty { get; set; }
}
public string SomeProperty { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace RabbitMQ.Next.Examples.DynamicSerializer;

class Program
internal static class Program
{
static async Task Main()
private static async Task Main()
{
await using var connection = ConnectionBuilder.Default
.Endpoint("amqp://test2:test2@localhost:5672/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

namespace RabbitMQ.Next.Examples.SimpleConsumer;

class Program
internal static class Program
{
static async Task Main()
private static async Task Main()
{
Console.WriteLine("Hello World! This is consumer based on RabbitMQ.Next library.");

Expand All @@ -30,7 +30,7 @@ static async Task Main()

MonitorKeypressAsync(cancellation);

await consumer.ConsumeAsync(async (message, content) =>
await consumer.ConsumeAsync((message, content) =>
{
Console.WriteLine($"[{DateTimeOffset.Now.TimeOfDay}] Message received via '{message.Exchange}' exchange: {content.Get<string>()}");
} ,cancellation.Token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

namespace RabbitMQ.Next.Examples.SimplePublisher;

class Program
internal static class Program
{
static async Task Main()
private static async Task Main()
{
Console.WriteLine("Hello World! This is publisher based on RabbitMQ.Next library.");

Expand All @@ -33,10 +33,9 @@ static async Task Main()

Console.WriteLine("Publisher created. Type any text to send it to the 'amq.fanout' exchange. Enter empty string to exit");

string input;
while(true)
{
input = Console.ReadLine();
var input = Console.ReadLine();
if (string.IsNullOrEmpty(input))
{
break;
Expand All @@ -53,4 +52,4 @@ static async Task Main()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace RabbitMQ.Next.Examples.TopologyBuilder;

class Program
internal static class Program
{
static async Task Main()
private static async Task Main()
{
try
{
Expand Down Expand Up @@ -56,4 +56,4 @@ await topology.Queue.DeclareClassicAsync("my-advanced-queue",
throw;
}
}
}
}
3 changes: 3 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.{cs,vb}]
# Rider specific settings
configure_await_analysis_mode = library
3 changes: 1 addition & 2 deletions src/RabbitMQ.Next.Abstractions/Channels/IPayload.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using RabbitMQ.Next.Messaging;
using RabbitMQ.Next.Serialization;

namespace RabbitMQ.Next.Channels;

public interface IPayload: IMessageProperties, IContentAccessor, IDisposable
{
}
}
4 changes: 2 additions & 2 deletions src/RabbitMQ.Next.Abstractions/ConnectionBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static (string host, int port, bool ssl, string vhost, IAuthMechanism au
if (!string.Equals(endpoint.Scheme, DefaultSchemaName, StringComparison.OrdinalIgnoreCase)
&& !string.Equals(endpoint.Scheme, SslSchemaName, StringComparison.OrdinalIgnoreCase))
{
throw new ArgumentException(@"Endpoint scheme '{endpoint.Scheme}' does not supported.", nameof(endpoint));
throw new ArgumentException("Endpoint scheme '{endpoint.Scheme}' does not supported.", nameof(endpoint));
}

var ssl = endpoint.Scheme == SslSchemaName;
Expand Down Expand Up @@ -87,4 +87,4 @@ private static (string host, int port, bool ssl, string vhost, IAuthMechanism au

return (endpoint.Host, port, ssl, vhost, authMechanism);
}
}
}
4 changes: 1 addition & 3 deletions src/RabbitMQ.Next.Abstractions/IConnectionBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Threading;
using System.Threading.Tasks;
using RabbitMQ.Next.Serialization;

namespace RabbitMQ.Next;
Expand All @@ -19,4 +17,4 @@ public interface IConnectionBuilder: ISerializationBuilder<IConnectionBuilder>
IConnectionBuilder MaxFrameSize(int sizeBytes);

IConnection Build();
}
}
4 changes: 2 additions & 2 deletions src/RabbitMQ.Next.Abstractions/ReplyCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ public enum ReplyCode : ushort
ResourceError = 506,
NotAllowed = 530,
NotImplemented = 540,
InternalError = 541
}
InternalError = 541,
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static IConsumerBuilder BindToStream(this IConsumerBuilder consumer, stri
OffsetType.Hour => $"{offset.Argument}h",
OffsetType.Minute => $"{offset.Argument}m",
OffsetType.Second => $"{offset.Argument}s",
_ => throw new ArgumentOutOfRangeException()
_ => throw new ArgumentOutOfRangeException(),
};

consumer.BindToQueue(stream, s =>
Expand Down Expand Up @@ -65,4 +65,4 @@ public static IConsumerBuilder UseConsumerMiddleware(this IConsumerBuilder build

return builder;
}
}
}
4 changes: 2 additions & 2 deletions src/RabbitMQ.Next.Consumer.Abstractions/ConsumerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public static Task ConsumeAsync(this IConsumer consumer, Action<IDeliveredMessag
=> consumer.ConsumeAsync((m, c) =>
{
handler(m, c);
return default;
return Task.CompletedTask;
}, cancellation);
}
}
3 changes: 1 addition & 2 deletions src/RabbitMQ.Next.Consumer.Abstractions/IConsumerBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using RabbitMQ.Next.Channels;
using RabbitMQ.Next.Messaging;
Expand All @@ -21,4 +20,4 @@ public interface IConsumerBuilder
IConsumerBuilder OnPoisonMessage(PoisonMessageMode mode);

IConsumerBuilder UseConsumerMiddleware(Func<IDeliveredMessage,IContentAccessor,Func<IDeliveredMessage,IContentAccessor,Task>,Task> middleware);
}
}
2 changes: 1 addition & 1 deletion src/RabbitMQ.Next.Consumer.Abstractions/StreamOffset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ public enum OffsetType
Day,
Hour,
Minute,
Second
Second,
}
3 changes: 1 addition & 2 deletions src/RabbitMQ.Next.Consumer/ConsumerBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using RabbitMQ.Next.Channels;
using RabbitMQ.Next.Messaging;
Expand Down Expand Up @@ -89,4 +88,4 @@ public IConsumerBuilder UseConsumerMiddleware(Func<IDeliveredMessage, IContentAc
this.middlewares.Add(middleware);
return this;
}
}
}
6 changes: 3 additions & 3 deletions src/RabbitMQ.Next.Consumer/DeliverMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public DeliverMessageHandler(
}

public void Handle(DeliverMethod method, IPayload payload)
=> this.deliverChannel.Writer.TryWrite(new (method, payload));
=> this.deliverChannel.Writer.TryWrite(new DeliveredMessage(method, payload));


public void Release(Exception ex = null)
Expand All @@ -59,7 +59,7 @@ private async Task ProcessDeliveredMessagesAsync()
await this.messageHandler(message, message).ConfigureAwait(false);
await this.acknowledgement.AckAsync(message.DeliveryTag).ConfigureAwait(false);
}
catch (Exception)
catch (Exception ex)
{
await this.acknowledgement.NackAsync(message.DeliveryTag, this.onPoisonMessage == PoisonMessageMode.Requeue).ConfigureAwait(false);
}
Expand All @@ -70,4 +70,4 @@ private async Task ProcessDeliveredMessagesAsync()
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using RabbitMQ.Next.Messaging;

Expand Down Expand Up @@ -29,4 +28,4 @@ public static IPublisherBuilder UsePublishMiddleware(this IPublisherBuilder buil

return builder;
}
}
}
Loading

0 comments on commit 4303da8

Please sign in to comment.