Skip to content

Commit

Permalink
Ran dotnet format
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Mar 27, 2024
1 parent d96b16c commit d7ecd0f
Show file tree
Hide file tree
Showing 9 changed files with 623 additions and 627 deletions.
12 changes: 8 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ csharp_indent_labels = one_less_than_current
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion

# avoid this. unless absolutely necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_qualification_for_field = false:error
dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_event = false:error

# Types: use keywords instead of BCL types, and permit var only when the type is clear
csharp_style_var_for_built_in_types = false:suggestion
Expand Down Expand Up @@ -154,6 +154,10 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

# Custom
csharp_style_namespace_declarations = file_scoped:error
dotnet_diagnostic.IDE0005.severity = error # Using directive is unnecessary.

# C++ Files
[*.{cpp,h,in}]
curly_bracket_next_line = true
Expand Down
9 changes: 4 additions & 5 deletions samples/Foundatio.RabbitMQ.Publish/MyMessage.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace Foundatio.RabbitMQ
namespace Foundatio.RabbitMQ;

public class MyMessage
{
public class MyMessage
{
public string Hey { get; set; }
}
public string Hey { get; set; }
}
31 changes: 15 additions & 16 deletions samples/Foundatio.RabbitMQ.Publish/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
using System.Threading.Tasks;
using Foundatio.Messaging;

namespace Foundatio.RabbitMQ.Publish
namespace Foundatio.RabbitMQ.Publish;

public class Program
{
public class Program
public static async Task Main()
{
public static async Task Main()
{
Console.WriteLine("Enter the message and press enter to send:");
Console.WriteLine("Enter the message and press enter to send:");

using var messageBus = new RabbitMQMessageBus(new RabbitMQMessageBusOptions { ConnectionString = "amqp://localhost:5672" });
string message;
do
{
message = Console.ReadLine();
var delay = TimeSpan.FromSeconds(1);
var body = new MyMessage { Hey = message };
await messageBus.PublishAsync(body, delay);
Console.WriteLine("Message sent. Enter new message or press enter to exit:");
} while (!String.IsNullOrEmpty(message));
}
using var messageBus = new RabbitMQMessageBus(new RabbitMQMessageBusOptions { ConnectionString = "amqp://localhost:5672" });
string message;
do
{
message = Console.ReadLine();
var delay = TimeSpan.FromSeconds(1);
var body = new MyMessage { Hey = message };
await messageBus.PublishAsync(body, delay);
Console.WriteLine("Message sent. Enter new message or press enter to exit:");
} while (!String.IsNullOrEmpty(message));
}
}
33 changes: 16 additions & 17 deletions samples/Foundatio.RabbitMQ.Subscribe/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@
using System.Threading.Tasks;
using Foundatio.Messaging;

namespace Foundatio.RabbitMQ.Subscribe
namespace Foundatio.RabbitMQ.Subscribe;

public class Program
{
public class Program
public static async Task Main(string[] args)
{
public static async Task Main(string[] args)
{
Console.WriteLine("Waiting to receive messages, press enter to quit...");
Console.WriteLine("Waiting to receive messages, press enter to quit...");

var tasks = new List<Task>();
var messageBuses = new List<IMessageBus>();
for (int i = 0; i < 3; i++)
{
var messageBus = new RabbitMQMessageBus(new RabbitMQMessageBusOptions { ConnectionString = "amqp://localhost:5672" });
messageBuses.Add(messageBus);
tasks.Add(messageBus.SubscribeAsync<MyMessage>(msg => { Console.WriteLine($"Got subscriber {messageBus.MessageBusId} message: {msg.Hey}"); }));
}
await Task.WhenAll(tasks);
Console.ReadLine();
foreach (var messageBus in messageBuses)
messageBus.Dispose();
var tasks = new List<Task>();
var messageBuses = new List<IMessageBus>();
for (int i = 0; i < 3; i++)
{
var messageBus = new RabbitMQMessageBus(new RabbitMQMessageBusOptions { ConnectionString = "amqp://localhost:5672" });
messageBuses.Add(messageBus);
tasks.Add(messageBus.SubscribeAsync<MyMessage>(msg => { Console.WriteLine($"Got subscriber {messageBus.MessageBusId} message: {msg.Hey}"); }));
}
await Task.WhenAll(tasks);
Console.ReadLine();
foreach (var messageBus in messageBuses)
messageBus.Dispose();
}
}
33 changes: 16 additions & 17 deletions src/Foundatio.RabbitMQ/Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@
using System.Threading.Tasks;
using Foundatio.AsyncEx;

namespace Foundatio.Extensions
namespace Foundatio.Extensions;

internal static class TaskExtensions
{
internal static class TaskExtensions
[DebuggerStepThrough]
public static ConfiguredTaskAwaitable<TResult> AnyContext<TResult>(this Task<TResult> task)
{
[DebuggerStepThrough]
public static ConfiguredTaskAwaitable<TResult> AnyContext<TResult>(this Task<TResult> task)
{
return task.ConfigureAwait(continueOnCapturedContext: false);
}
return task.ConfigureAwait(continueOnCapturedContext: false);
}

[DebuggerStepThrough]
public static ConfiguredTaskAwaitable AnyContext(this Task task)
{
return task.ConfigureAwait(continueOnCapturedContext: false);
}
[DebuggerStepThrough]
public static ConfiguredTaskAwaitable AnyContext(this Task task)
{
return task.ConfigureAwait(continueOnCapturedContext: false);
}

[DebuggerStepThrough]
public static ConfiguredTaskAwaitable<TResult> AnyContext<TResult>(this AwaitableDisposable<TResult> task) where TResult : IDisposable
{
return task.ConfigureAwait(continueOnCapturedContext: false);
}
[DebuggerStepThrough]
public static ConfiguredTaskAwaitable<TResult> AnyContext<TResult>(this AwaitableDisposable<TResult> task) where TResult : IDisposable
{
return task.ConfigureAwait(continueOnCapturedContext: false);
}
}
11 changes: 5 additions & 6 deletions src/Foundatio.RabbitMQ/Messaging/AcknowledgementStrategy.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
namespace Foundatio.Messaging
namespace Foundatio.Messaging;

public enum AcknowledgementStrategy
{
public enum AcknowledgementStrategy
{
FireAndForget,
Automatic
}
FireAndForget,
Automatic
}
Loading

0 comments on commit d7ecd0f

Please sign in to comment.