diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..0c42f3c
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto eol=crlf
diff --git a/global.json b/global.json
new file mode 100644
index 0000000..20957fb
--- /dev/null
+++ b/global.json
@@ -0,0 +1,7 @@
+{
+ "sdk": {
+ "version": "9.0.320",
+ "rollForward": "latestPatch",
+ "allowPrerelease": false
+ }
+}
diff --git a/src/.editorconfig b/src/.editorconfig
index ded953d..9a1822d 100644
--- a/src/.editorconfig
+++ b/src/.editorconfig
@@ -20,7 +20,7 @@ tab_width = 4
# New line preferences
end_of_line = crlf
-insert_final_newline = false
+insert_final_newline = true
#### .NET Code Actions ####
@@ -271,41 +271,10 @@ dotnet_naming_style.begins_with__.required_suffix =
dotnet_naming_style.begins_with__.word_separator =
dotnet_naming_style.begins_with__.capitalization = camel_case
-[*.{cs,vb}]
-dotnet_style_coalesce_expression = true:suggestion
-dotnet_style_null_propagation = true:suggestion
-dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
-dotnet_style_prefer_auto_properties = true:suggestion
-dotnet_style_object_initializer = true:suggestion
-dotnet_style_collection_initializer = true:suggestion
-dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
-dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
-dotnet_style_prefer_conditional_expression_over_return = true:suggestion
-dotnet_style_explicit_tuple_names = true:warning
-dotnet_style_prefer_inferred_tuple_names = false:silent
-dotnet_style_prefer_inferred_anonymous_type_member_names = false:silent
-dotnet_style_prefer_compound_assignment = true:suggestion
-dotnet_style_prefer_simplified_interpolation = true:suggestion
-dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
-dotnet_style_namespace_match_folder = true:suggestion
-dotnet_style_operator_placement_when_wrapping = beginning_of_line
-tab_width = 4
-indent_size = 4
-end_of_line = crlf
-dotnet_style_readonly_field = true:suggestion
-dotnet_style_predefined_type_for_locals_parameters_members = true:warning
-dotnet_style_predefined_type_for_member_access = true:warning
-dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
-dotnet_style_allow_multiple_blank_lines_experimental = true:silent
-dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
-dotnet_code_quality_unused_parameters = non_public:suggestion
-dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
-dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
-dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
-dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
-dotnet_style_qualification_for_field = false:silent
-dotnet_style_qualification_for_property = false:warning
-dotnet_style_qualification_for_method = false:warning
-dotnet_style_qualification_for_event = false:warning
+# API shape rules intentionally not applied: CA1040 and CA1034 are valid in this library.
dotnet_diagnostic.CA1040.severity = none
-dotnet_diagnostic.CA1034.severity = none
\ No newline at end of file
+dotnet_diagnostic.CA1034.severity = none
+
+[**/*Tests.cs]
+# xUnit method names use underscores to describe scenario and expected result.
+dotnet_diagnostic.CA1707.severity = none
\ No newline at end of file
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
new file mode 100644
index 0000000..9ea47d5
--- /dev/null
+++ b/src/Directory.Build.props
@@ -0,0 +1,8 @@
+
+
+ true
+ latest
+ Recommended
+ true
+
+
diff --git a/src/WeakEvent.Tests/WeakEventGenericTests.cs b/src/WeakEvent.Tests/WeakEventGenericTests.cs
index eecf47d..de8b32a 100644
--- a/src/WeakEvent.Tests/WeakEventGenericTests.cs
+++ b/src/WeakEvent.Tests/WeakEventGenericTests.cs
@@ -252,7 +252,7 @@ public async Task OpenInstanceHandler_IsInvoked()
Assert.Equal(1, subscriber.CallCount);
}
- private class OpenInstanceSubscriber
+ private sealed class OpenInstanceSubscriber
{
public int CallCount { get; private set; }
@@ -287,7 +287,7 @@ private static void CollectGarbage()
}
}
- private class GenericSubscriber(Action onEvent)
+ private sealed class GenericSubscriber(Action onEvent)
{
private readonly Action _onEvent = onEvent;
@@ -295,4 +295,4 @@ private class GenericSubscriber(Action onEvent)
}
private sealed class TestException : Exception;
-}
\ No newline at end of file
+}
diff --git a/src/WeakEvent.Tests/WeakEventHandlerTests.cs b/src/WeakEvent.Tests/WeakEventHandlerTests.cs
index b094c3d..42b43fc 100644
--- a/src/WeakEvent.Tests/WeakEventHandlerTests.cs
+++ b/src/WeakEvent.Tests/WeakEventHandlerTests.cs
@@ -115,7 +115,7 @@ private static WeakEventHandler CreateWeakSubscriber()
// 'subscriber' goes out of scope after this method.
}
- private class Subscriber
+ private sealed class Subscriber
{
public bool Invoked { get; private set; }
public bool ThrowIfInvoked { get; init; }
@@ -150,4 +150,4 @@ private static void CollectGarbage()
GC.WaitForPendingFinalizers();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/WeakEvent.Tests/WeakEventLockingTests.cs b/src/WeakEvent.Tests/WeakEventLockingTests.cs
index fad1fcc..e895a49 100644
--- a/src/WeakEvent.Tests/WeakEventLockingTests.cs
+++ b/src/WeakEvent.Tests/WeakEventLockingTests.cs
@@ -36,7 +36,10 @@ async Task firstHandler()
callCount++;
}
- void secondHandler() => callCount++;
+ void secondHandler()
+ {
+ callCount++;
+ }
e.Subscribe(firstHandler);
var firstPublication = e.PublishAsync();
@@ -51,5 +54,4 @@ async Task firstHandler()
await e.PublishAsync();
Assert.Equal(3, callCount);
}
-
-}
\ No newline at end of file
+}
diff --git a/src/WeakEvent.Tests/WeakEventNonGenericTests.cs b/src/WeakEvent.Tests/WeakEventNonGenericTests.cs
index 2d9b47e..9fd512a 100644
--- a/src/WeakEvent.Tests/WeakEventNonGenericTests.cs
+++ b/src/WeakEvent.Tests/WeakEventNonGenericTests.cs
@@ -187,10 +187,10 @@ private static void CollectGarbage()
}
}
- private class NonGenericSubscriber(Action onEvent)
+ private sealed class NonGenericSubscriber(Action onEvent)
{
private readonly Action _onEvent = onEvent;
public void Handler() => _onEvent();
}
-}
\ No newline at end of file
+}
diff --git a/src/WeakEvent/AssemblyInfo.cs b/src/WeakEvent/AssemblyInfo.cs
index 635fbbf..afd4d54 100644
--- a/src/WeakEvent/AssemblyInfo.cs
+++ b/src/WeakEvent/AssemblyInfo.cs
@@ -1,3 +1,3 @@
using System.Runtime.CompilerServices;
-[assembly: InternalsVisibleTo("WeakEvent.Tests")]
\ No newline at end of file
+[assembly: InternalsVisibleTo("WeakEvent.Tests")]
diff --git a/src/WeakEvent/WeakEvent.cs b/src/WeakEvent/WeakEvent.cs
index bb53fbc..a6ef52d 100644
--- a/src/WeakEvent/WeakEvent.cs
+++ b/src/WeakEvent/WeakEvent.cs
@@ -158,4 +158,4 @@ public void Subscribe(Func handler)
/// The cancellation token to cancel the operation.
public Task PublishAsync(CancellationToken cancellationToken = default)
=> _core.PublishAsync