Skip to content

Commit

Permalink
Cleanup warnings and styling (#136)
Browse files Browse the repository at this point in the history
Co-authored-by: Kyle Dodson <[email protected]>
  • Loading branch information
cmeyertons and seniorquico authored May 20, 2023
1 parent 15f1dad commit a299d8f
Show file tree
Hide file tree
Showing 15 changed files with 243 additions and 79 deletions.
85 changes: 84 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning

csharp_style_namespace_declarations = file_scoped
csharp_style_namespace_declarations = file_scoped:silent

csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_pattern_matching_over_as_with_null_check = true:warning
Expand Down Expand Up @@ -461,3 +461,86 @@ max_line_length = 120

[nuget.config]
indent_size = 2

[*.cs]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.private_or_internal_field_should_be_begins_with_underscore.severity = suggestion
dotnet_naming_rule.private_or_internal_field_should_be_begins_with_underscore.symbols = private_or_internal_field
dotnet_naming_rule.private_or_internal_field_should_be_begins_with_underscore.style = begins_with_underscore

# Symbol specifications

dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected
dotnet_naming_symbols.private_or_internal_field.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_underscore.required_prefix = _
dotnet_naming_style.begins_with_underscore.required_suffix =
dotnet_naming_style.begins_with_underscore.word_separator =
dotnet_naming_style.begins_with_underscore.capitalization = camel_case
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
dotnet_diagnostic.SA1127.severity = silent
dotnet_diagnostic.SA1202.severity = silent

[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
end_of_line = crlf
dotnet_diagnostic.CA1002.severity = silent
dotnet_diagnostic.CA1030.severity = silent
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TargetFramework>net7.0</TargetFramework>
<AnalysisLevel>latest-Recommended</AnalysisLevel>
</PropertyGroup>

</Project>
15 changes: 15 additions & 0 deletions OrleansTestKit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrleansTestKit", "src\Orlea
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrleansTestKit.Tests", "test\OrleansTestKit.Tests\OrleansTestKit.Tests.csproj", "{1DBA9447-3F61-4F00-8DDF-2CA22D531D27}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5520B20D-D27A-4F49-BB24-BF34A6DC2EAC}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
CodeMaid.config = CodeMaid.config
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
global.json = global.json
LICENSE = LICENSE
omnisharp.json = omnisharp.json
README.md = README.md
stylecop.json = stylecop.json
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
32 changes: 19 additions & 13 deletions src/OrleansTestKit/Reminders/ReminderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@

namespace Orleans.TestKit;

/// <summary>
/// Extensions for test kit reminder firing.
/// </summary>
public static class ReminderExtensions
{
/// <summary>
/// Fire all reminders for this silo.
/// </summary>
/// <param name="silo">The test kit silo.</param>
/// <param name="tickStatus">The tick status.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
public static Task FireAllReminders(this TestKitSilo silo, TickStatus tickStatus = default)
{
if (silo == null)
{
throw new ArgumentNullException(nameof(silo));
}
ArgumentNullException.ThrowIfNull(silo);

return silo.ReminderRegistry.FireAllReminders(tickStatus);
}

/// <summary>
/// Fire specific reminder for this silo.
/// </summary>
/// <param name="silo">The test kit silo.</param>
/// <param name="reminderName">The reminder to fire.</param>
/// <param name="tickStatus">The tick status.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
public static Task FireReminder(this TestKitSilo silo, string reminderName, TickStatus tickStatus = default)
{
if (silo == null)
{
throw new ArgumentNullException(nameof(silo));
}

if (reminderName == null)
{
throw new ArgumentNullException(nameof(reminderName));
}
ArgumentNullException.ThrowIfNull(silo);
ArgumentNullException.ThrowIfNull(reminderName);

return silo.ReminderRegistry.FireReminder(reminderName, tickStatus);
}
Expand Down
15 changes: 7 additions & 8 deletions src/OrleansTestKit/Reminders/TestReminderRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ public sealed class TestReminderRegistry : IReminderRegistry
{
private readonly Dictionary<string, TestReminder> _reminders = new();

private IRemindable _grain;
private IRemindable? _grain;

private IRemindable Grain => _grain ?? throw new InvalidOperationException($"You must SetGrainTarget before invoking other methods");

public Mock<IReminderRegistry> Mock { get; } = new();

public async Task FireAllReminders(TickStatus tickStatus)
{
foreach (var reminderName in _reminders.Keys)
{
await _grain.ReceiveReminder(reminderName, tickStatus);
await Grain.ReceiveReminder(reminderName, tickStatus);
}
}

Expand All @@ -32,15 +34,12 @@ public Task FireReminder(string reminderName, TickStatus tickStatus)
throw new ArgumentException($"No reminder named {reminderName} found");
}

return _grain.ReceiveReminder(reminderName, tickStatus);
return Grain.ReceiveReminder(reminderName, tickStatus);
}

public async Task<IGrainReminder> GetReminder(GrainId callingGrainId, string reminderName)
public async Task<IGrainReminder?> GetReminder(GrainId callingGrainId, string reminderName)
{
if (reminderName == null)
{
throw new ArgumentNullException(nameof(reminderName));
}
ArgumentNullException.ThrowIfNull(reminderName);

await Mock.Object.GetReminder(callingGrainId, reminderName);
return !_reminders.TryGetValue(reminderName, out var reminder) ? null : reminder;
Expand Down
4 changes: 2 additions & 2 deletions src/OrleansTestKit/Storage/TestStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public TestStorage()
InitializeState();
}

public TestStorage(TState state) : this() =>
State = state;
public TestStorage(TState state)
: this() => State = state;

public string Etag =>
throw new NotImplementedException();
Expand Down
Loading

0 comments on commit a299d8f

Please sign in to comment.