diff --git a/.editorconfig b/.editorconfig
index 69c17b8f..d2d18bd0 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -17,3 +17,93 @@ indent_size = 2
[*.verified.cs]
trim_trailing_whitespace = false
insert_final_newline = false
+
+# We have to set the severity via dotnet_diagnostic.ID.severity because
+# otherwise the warnings are only shown in the IDE, not in the build:
+# See: https://github.com/dotnet/roslyn/issues/49439
+
+# Some rules can't be enforced during builds unfortunately,
+# but are enforced by `dotnet format`.
+# https://github.com/dotnet/roslyn/blob/9f87b444da9c48a4d492b19f8337339056bf2b95/src/Analyzers/Core/Analyzers/EnforceOnBuildValues.cs#L95
+
+[*.cs]
+# "This." and "Me." qualifiers
+dotnet_style_qualification_for_field = false
+dotnet_style_qualification_for_property = false
+dotnet_style_qualification_for_method = false
+dotnet_style_qualification_for_event = false
+dotnet_diagnostic.IDE0003.severity = warning # Remove `this` or `Me` qualification
+
+# Remove unnecessary usings
+dotnet_diagnostic.IDE0005.severity = warning # Remove unnecessary import
+
+# Prefer `var` over explicit type
+csharp_style_var_for_built_in_types = true
+csharp_style_var_when_type_is_apparent = true
+csharp_style_var_elsewhere = true
+dotnet_diagnostic.IDE0007.severity = warning
+
+# Missing Switch Cases
+dotnet_diagnostic.IDE0010.severity = warning # Add missing cases to switch statement
+
+# Braces
+csharp_prefer_braces = true
+dotnet_diagnostic.IDE0011.severity = warning # Add braces
+
+# `out var`
+csharp_style_inlined_variable_declaration = true # Prefer `out` variables to be declared inline in the argument list of a method call when possible
+dotnet_diagnostic.IDE0018.severity = warning
+
+# TODO: Go through all language rules: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/language-rules
+
+# Formatting
+# See: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options
+dotnet_diagnostic.IDE0055.severity = warning
+
+dotnet_sort_system_directives_first = true
+
+## New-line options
+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_anonymous_types = true
+csharp_new_line_between_query_expression_clauses = true
+
+## Indentation options
+csharp_indent_case_contents = true
+csharp_indent_switch_labels = true
+csharp_indent_labels = flush_left
+csharp_indent_block_contents = true
+csharp_indent_braces = false
+csharp_indent_case_contents_when_block = true
+
+## Spacing Options
+csharp_space_after_cast = false
+csharp_space_after_keywords_in_control_flow_statements = true
+csharp_space_between_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_parameter_list_parentheses = false
+csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
+csharp_space_between_method_declaration_name_and_open_parenthesis = false
+csharp_space_between_method_call_parameter_list_parentheses = false
+csharp_space_between_method_call_empty_parameter_list_parentheses = false
+csharp_space_between_method_call_name_and_opening_parenthesis = false
+csharp_space_after_comma = true
+csharp_space_before_comma = false
+csharp_space_after_dot = false
+csharp_space_before_dot = false
+csharp_space_after_semicolon_in_for_statement = true
+csharp_space_before_semicolon_in_for_statement = false
+csharp_space_around_declaration_statements = false
+csharp_space_before_open_square_brackets = false
+csharp_space_between_empty_square_brackets = false
+csharp_space_between_square_brackets = false
+
+## Wrap Options
+csharp_preserve_single_line_statements = false
+
+# Naming
+# TODO: Define naming (see https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/naming-rules)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1b506bc5..71131ada 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -47,6 +47,24 @@ jobs:
- name: Run Tests
run: dotnet test --configuration Release --no-build
+ style:
+ name: Check Formatting and Style
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-dotnet@v3
+ name: Install Current .NET SDK
+ - name: Restore dependencies
+ run: dotnet restore
+ # We need to run a build first so that the attribute from our source generator is available.
+ # Otherwise we get warnings about unused usings.
+ - name: Build
+ run: dotnet build Funcky.SourceGenerator --no-restore && dotnet build Funcky.FsCheck --no-restore
+ - run: dotnet format style --verify-no-changes --no-restore
+ name: Check Style
+ - run: dotnet format whitespace --verify-no-changes --no-restore
+ name: Check Whitespace
+
trimming-test:
name: Trimming Test
runs-on: ubuntu-latest
diff --git a/Directory.Build.props b/Directory.Build.props
index 3b750436..f9afee6a 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -9,9 +9,6 @@
false
-
-
-
5.0
diff --git a/Directory.Packages.props b/Directory.Packages.props
index d25dc544..5f009bee 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -13,7 +13,6 @@
-
diff --git a/Funcky.Analyzers/Funcky.Analyzers/EnumerableRepeatOnceAnalyzer.cs b/Funcky.Analyzers/Funcky.Analyzers/EnumerableRepeatOnceAnalyzer.cs
index 8371c1eb..5ae6bdbe 100644
--- a/Funcky.Analyzers/Funcky.Analyzers/EnumerableRepeatOnceAnalyzer.cs
+++ b/Funcky.Analyzers/Funcky.Analyzers/EnumerableRepeatOnceAnalyzer.cs
@@ -57,7 +57,7 @@ private static bool MatchRepeatOnce(
{
valueArgument = null;
return MatchMethod(operation, enumerableType, nameof(Enumerable.Repeat))
- && MatchArguments(operation, out valueArgument, AnyArgument, out _, ConstantArgument(1));
+ && MatchArguments(operation, out valueArgument, AnyArgument, out _, ConstantArgument(1));
}
private static Diagnostic CreateDiagnostic(IInvocationOperation operation, IArgumentOperation valueArgument)
diff --git a/Funcky.Analyzers/Funcky.BuiltinAnalyzers/TryGetValueAnalyzer.cs b/Funcky.Analyzers/Funcky.BuiltinAnalyzers/TryGetValueAnalyzer.cs
index 2bb93742..ed496dba 100644
--- a/Funcky.Analyzers/Funcky.BuiltinAnalyzers/TryGetValueAnalyzer.cs
+++ b/Funcky.Analyzers/Funcky.BuiltinAnalyzers/TryGetValueAnalyzer.cs
@@ -100,7 +100,7 @@ private static bool OriginatesInRazorFile(IOperation operation)
private static IEnumerable GetBaseTypes(INamedTypeSymbol type)
{
- for (INamedTypeSymbol? baseType = type.BaseType; baseType is not null; baseType = baseType.BaseType)
+ for (var baseType = type.BaseType; baseType is not null; baseType = baseType.BaseType)
{
yield return baseType;
}
diff --git a/Funcky.Async.Test/Extensions/AsyncEnumerableExtensions/InterleaveTest.cs b/Funcky.Async.Test/Extensions/AsyncEnumerableExtensions/InterleaveTest.cs
index ac6b8d71..d23a432f 100644
--- a/Funcky.Async.Test/Extensions/AsyncEnumerableExtensions/InterleaveTest.cs
+++ b/Funcky.Async.Test/Extensions/AsyncEnumerableExtensions/InterleaveTest.cs
@@ -89,7 +89,7 @@ public async Task GivenASequenceOfSequencesInterleaveReturnsTheExpectedSequence(
var innerSum = sequences.Select(async element => await element.CountAsync()).Aggregate(0, (total, part) => total + part.Result);
Assert.Equal(innerSum, await sequences.Interleave().CountAsync());
- int expected = 1;
+ var expected = 1;
await foreach (var element in sequences.Interleave())
{
Assert.Equal(expected, element);
diff --git a/Funcky.Async/AsyncSequence/AsyncSequence.CycleRange.cs b/Funcky.Async/AsyncSequence/AsyncSequence.CycleRange.cs
index 59bebd9b..2beec9c6 100644
--- a/Funcky.Async/AsyncSequence/AsyncSequence.CycleRange.cs
+++ b/Funcky.Async/AsyncSequence/AsyncSequence.CycleRange.cs
@@ -84,7 +84,7 @@ private async IAsyncEnumerator GetEnumeratorInternal()
// this can change on Dispose!
var bufferCount = _buffer.Count;
- for (int cycle = 1; IsCycling(cycle); ++cycle)
+ for (var cycle = 1; IsCycling(cycle); ++cycle)
{
for (var index = 0; index < bufferCount; ++index)
{
diff --git a/Funcky.Async/Extensions/AsyncEnumerableExtensions/Interleave.cs b/Funcky.Async/Extensions/AsyncEnumerableExtensions/Interleave.cs
index 4919eee7..0e473539 100644
--- a/Funcky.Async/Extensions/AsyncEnumerableExtensions/Interleave.cs
+++ b/Funcky.Async/Extensions/AsyncEnumerableExtensions/Interleave.cs
@@ -45,9 +45,9 @@ private static async IAsyncEnumerable InterleaveInternal(
}
}
- #pragma warning disable IDISP007 // The entire point of this method is to dispose.
+#pragma warning disable IDISP007 // The entire point of this method is to dispose.
private static async Task DisposeEnumerator(IAsyncEnumerator enumerator) => await enumerator.DisposeAsync().ConfigureAwait(false);
- #pragma warning restore IDISP007
+#pragma warning restore IDISP007
private static ImmutableList> GetInterleaveEnumerators(
IEnumerable> source,
diff --git a/Funcky.Async/Extensions/AsyncEnumerableExtensions/Pairwise.cs b/Funcky.Async/Extensions/AsyncEnumerableExtensions/Pairwise.cs
index 359b03b7..e77ff422 100644
--- a/Funcky.Async/Extensions/AsyncEnumerableExtensions/Pairwise.cs
+++ b/Funcky.Async/Extensions/AsyncEnumerableExtensions/Pairwise.cs
@@ -33,9 +33,9 @@ private static async IAsyncEnumerable PairwiseInternal resultSelector,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
- #pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
+#pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
await using var enumerator = source.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
- #pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task
+#pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task
if (await enumerator.MoveNextAsync() == false)
{
diff --git a/Funcky.Async/Extensions/AsyncEnumerableExtensions/WithFirst.cs b/Funcky.Async/Extensions/AsyncEnumerableExtensions/WithFirst.cs
index c5211987..7166ed26 100644
--- a/Funcky.Async/Extensions/AsyncEnumerableExtensions/WithFirst.cs
+++ b/Funcky.Async/Extensions/AsyncEnumerableExtensions/WithFirst.cs
@@ -11,9 +11,9 @@ public static partial class AsyncEnumerableExtensions
[Pure]
public static async IAsyncEnumerable> WithFirst(this IAsyncEnumerable source)
{
- #pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
+#pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
await using var enumerator = source.ConfigureAwait(false).GetAsyncEnumerator();
- #pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task
+#pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task
if (!await enumerator.MoveNextAsync())
{
diff --git a/Funcky.Async/Extensions/AsyncEnumerableExtensions/WithLast.cs b/Funcky.Async/Extensions/AsyncEnumerableExtensions/WithLast.cs
index 1624f8e7..3b465e69 100644
--- a/Funcky.Async/Extensions/AsyncEnumerableExtensions/WithLast.cs
+++ b/Funcky.Async/Extensions/AsyncEnumerableExtensions/WithLast.cs
@@ -11,9 +11,9 @@ public static partial class AsyncEnumerableExtensions
[Pure]
public static async IAsyncEnumerable> WithLast(this IAsyncEnumerable source)
{
- #pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
+#pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
await using var enumerator = source.ConfigureAwait(false).GetAsyncEnumerator();
- #pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task
+#pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task
if (!await enumerator.MoveNextAsync())
{
diff --git a/Funcky.Async/Extensions/AsyncEnumerableExtensions/ZipLongest.cs b/Funcky.Async/Extensions/AsyncEnumerableExtensions/ZipLongest.cs
index 7f284546..5168d482 100644
--- a/Funcky.Async/Extensions/AsyncEnumerableExtensions/ZipLongest.cs
+++ b/Funcky.Async/Extensions/AsyncEnumerableExtensions/ZipLongest.cs
@@ -33,10 +33,10 @@ public static async IAsyncEnumerable ZipLongest
where TLeft : notnull
where TRight : notnull
{
- #pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
+#pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
await using var leftEnumerator = left.ConfigureAwait(false).GetAsyncEnumerator();
await using var rightEnumerator = right.ConfigureAwait(false).GetAsyncEnumerator();
- #pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task
+#pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task
while ((await MoveNextOrNone(leftEnumerator, rightEnumerator).ConfigureAwait(false)).TryGetValue(out var next))
{
diff --git a/Funcky.Test/Extensions/EnumerableExtensions/ChunkTest.cs b/Funcky.Test/Extensions/EnumerableExtensions/ChunkTest.cs
index 90f273cc..2287f242 100644
--- a/Funcky.Test/Extensions/EnumerableExtensions/ChunkTest.cs
+++ b/Funcky.Test/Extensions/EnumerableExtensions/ChunkTest.cs
@@ -80,7 +80,9 @@ public void GivenAnEnumerableNotAMultipleOfSizeWeHaveASmallerLastSlice()
var numbers = Sequence.Return("a", "b", "c", "d", "e", "g", "h", "i", "j").ToList();
const int chunkSize = 4;
+#pragma warning disable IDE0007 // False positive
IEnumerable> chunked = numbers.Chunk(chunkSize);
+#pragma warning restore IDE0007
Assert.Collection(
chunked,
diff --git a/Funcky.Test/Extensions/EnumerableExtensions/InterleaveTest.cs b/Funcky.Test/Extensions/EnumerableExtensions/InterleaveTest.cs
index 1a75f00b..5f541440 100644
--- a/Funcky.Test/Extensions/EnumerableExtensions/InterleaveTest.cs
+++ b/Funcky.Test/Extensions/EnumerableExtensions/InterleaveTest.cs
@@ -18,7 +18,7 @@ public void GivenAnEmptySequenceOfSequencesInterleaveReturnsAnEmptySequence()
{
IEnumerable> emptySequence = [];
- IEnumerable interleaved = emptySequence.Interleave();
+ var interleaved = emptySequence.Interleave();
Assert.Empty(interleaved);
}
@@ -42,7 +42,7 @@ public void GivenTwoSequencesOfUnequalLengthIGetAnInterleavedResult()
IEnumerable evens = [2, 4, 6];
IEnumerable expected = [1, 2, 3, 4, 5, 6, 7, 9, 11];
- IEnumerable interleaved = odds.Interleave(evens);
+ var interleaved = odds.Interleave(evens);
Assert.Equal(expected, interleaved);
}
@@ -99,7 +99,7 @@ public void GivenASequenceOfSequencesInterleaveReturnsTheExpectedSequence()
Assert.Equal(sequences.Select(s => s.Count()).Sum(), sequences.Interleave().Count());
- int expected = 1;
+ var expected = 1;
foreach (var element in sequences.Interleave())
{
Assert.Equal(expected, element);
diff --git a/Funcky.Test/FunctionalClass/FlipTest.cs b/Funcky.Test/FunctionalClass/FlipTest.cs
index def0b380..7a952c63 100644
--- a/Funcky.Test/FunctionalClass/FlipTest.cs
+++ b/Funcky.Test/FunctionalClass/FlipTest.cs
@@ -60,7 +60,7 @@ public Property GivenAFunctionWith8ParametersTheFirstTwoParametersGetFlipped(int
[Property]
public Property GivenAnActionWith2ParametersTheFirstTwoParametersGetFlipped(int number, string text)
{
- string side = string.Empty;
+ var side = string.Empty;
Action f = (number, text) => side = $"number:{number}, text:{text}";
f(number, text);
@@ -73,7 +73,7 @@ public Property GivenAnActionWith2ParametersTheFirstTwoParametersGetFlipped(int
[Property]
public Property GivenAnActionWith3ParametersTheFirstTwoParametersGetFlipped(int number, string text)
{
- string side = string.Empty;
+ var side = string.Empty;
Action f = (number, text, p3) => side = $"number:{number}, text:{text}, {p3}";
f(number, text, true);
@@ -86,7 +86,7 @@ public Property GivenAnActionWith3ParametersTheFirstTwoParametersGetFlipped(int
[Property]
public Property GivenAnActionWith4ParametersTheFirstTwoParametersGetFlipped(int number, string text)
{
- string side = string.Empty;
+ var side = string.Empty;
Action f = (number, text, p3, p4) => side = $"number:{number}, text:{text}, {p3}, {p4}";
f(number, text, true, false);
@@ -99,7 +99,7 @@ public Property GivenAnActionWith4ParametersTheFirstTwoParametersGetFlipped(int
[Property]
public Property GivenAnActionWith5ParametersTheFirstTwoParametersGetFlipped(int number, string text)
{
- string side = string.Empty;
+ var side = string.Empty;
Action f = (number, text, p3, p4, p5) => side = $"number:{number}, text:{text}, {p3}, {p4}, {p5}";
f(number, text, true, false, false);
@@ -112,7 +112,7 @@ public Property GivenAnActionWith5ParametersTheFirstTwoParametersGetFlipped(int
[Property]
public Property GivenAnActionWith6ParametersTheFirstTwoParametersGetFlipped(int number, string text)
{
- string side = string.Empty;
+ var side = string.Empty;
Action f = (number, text, p3, p4, p5, p6) => side = $"number:{number}, text:{text}, {p3}, {p4}, {p5}, {p6}";
f(number, text, true, false, false, true);
@@ -125,7 +125,7 @@ public Property GivenAnActionWith6ParametersTheFirstTwoParametersGetFlipped(int
[Property]
public Property GivenAnActionWith7ParametersTheFirstTwoParametersGetFlipped(int number, string text)
{
- string side = string.Empty;
+ var side = string.Empty;
Action f = (number, text, p3, p4, p5, p6, p7) => side = $"number:{number}, text:{text}, {p3}, {p4}, {p5}, {p6}, {p7}";
f(number, text, true, false, false, true, true);
@@ -138,7 +138,7 @@ public Property GivenAnActionWith7ParametersTheFirstTwoParametersGetFlipped(int
[Property]
public Property GivenAnActionWith8ParametersTheFirstTwoParametersGetFlipped(int number, string text)
{
- string side = string.Empty;
+ var side = string.Empty;
Action f = (number, text, p3, p4, p5, p6, p7, p8) => side = $"number:{number}, text:{text}, {p3}, {p4}, {p5}, {p6}, {p7}, {p8}";
f(number, text, true, false, false, true, true, true);
diff --git a/Funcky.Test/UpCastTest.cs b/Funcky.Test/UpCastTest.cs
index 3aca74f6..28c442a1 100644
--- a/Funcky.Test/UpCastTest.cs
+++ b/Funcky.Test/UpCastTest.cs
@@ -1,3 +1,5 @@
+#pragma warning disable IDE0007 // Use implicit type
+
using System.Collections.Immutable;
namespace Funcky.Test;
diff --git a/Funcky.Xunit/FunctionalAssert/Error.cs b/Funcky.Xunit/FunctionalAssert/Error.cs
index fb80d1d1..9d90a13c 100644
--- a/Funcky.Xunit/FunctionalAssert/Error.cs
+++ b/Funcky.Xunit/FunctionalAssert/Error.cs
@@ -7,11 +7,11 @@ public static partial class FunctionalAssert
{
/// Asserts that the given is Error.
/// Thrown when is Ok.
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[System.Diagnostics.StackTraceHidden]
- #else
+#else
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- #endif
+#endif
[SuppressMessage("Microsoft.Usage", "CA2200", Justification = "Stack trace erasure intentional.")]
public static Exception Error(Result result)
where TValidResult : notnull
diff --git a/Funcky.Xunit/FunctionalAssert/Left.cs b/Funcky.Xunit/FunctionalAssert/Left.cs
index 4d4c92f9..1acbf7dc 100644
--- a/Funcky.Xunit/FunctionalAssert/Left.cs
+++ b/Funcky.Xunit/FunctionalAssert/Left.cs
@@ -8,11 +8,11 @@ public static partial class FunctionalAssert
{
/// Asserts that the given is Left and contains the given .
/// Thrown when is Right.
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[System.Diagnostics.StackTraceHidden]
- #else
+#else
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- #endif
+#endif
public static void Left(TLeft expectedLeft, Either either)
where TLeft : notnull
where TRight : notnull
@@ -33,11 +33,11 @@ public static void Left(TLeft expectedLeft, Either
/// Asserts that the given is Left.
/// Thrown when is Right.
/// Returns the value in if it was Left.
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[System.Diagnostics.StackTraceHidden]
- #else
+#else
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- #endif
+#endif
[SuppressMessage("Microsoft.Usage", "CA2200", Justification = "Stack trace erasure intentional.")]
[SuppressMessage("ReSharper", "PossibleIntendedRethrow", Justification = "Stack trace erasure intentional.")]
public static TLeft Left(Either either)
diff --git a/Funcky.Xunit/FunctionalAssert/None.cs b/Funcky.Xunit/FunctionalAssert/None.cs
index fbac3cf6..03db3fed 100644
--- a/Funcky.Xunit/FunctionalAssert/None.cs
+++ b/Funcky.Xunit/FunctionalAssert/None.cs
@@ -7,11 +7,11 @@ public static partial class FunctionalAssert
{
/// Asserts that the given is None.
/// Thrown when is Some.
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[System.Diagnostics.StackTraceHidden]
- #else
+#else
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- #endif
+#endif
[SuppressMessage("Microsoft.Usage", "CA2200", Justification = "Stack trace erasure intentional.")]
[SuppressMessage("ReSharper", "PossibleIntendedRethrow", Justification = "Stack trace erasure intentional.")]
public static void None(Option option)
diff --git a/Funcky.Xunit/FunctionalAssert/Ok.cs b/Funcky.Xunit/FunctionalAssert/Ok.cs
index 3b6efd19..8769d653 100644
--- a/Funcky.Xunit/FunctionalAssert/Ok.cs
+++ b/Funcky.Xunit/FunctionalAssert/Ok.cs
@@ -8,11 +8,11 @@ public static partial class FunctionalAssert
{
/// Asserts that the given is Ok and contains the given .
/// Thrown when is Error.
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[System.Diagnostics.StackTraceHidden]
- #else
+#else
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- #endif
+#endif
public static void Ok(TValidResult expectedResult, Result result)
where TValidResult : notnull
{
@@ -32,11 +32,11 @@ public static void Ok(TValidResult expectedResult, ResultAsserts that the given is Ok.
/// Thrown when is Error.
/// Returns the value in if it was Ok.
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[System.Diagnostics.StackTraceHidden]
- #else
+#else
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- #endif
+#endif
[SuppressMessage("Microsoft.Usage", "CA2200", Justification = "Stack trace erasure intentional.")]
[SuppressMessage("ReSharper", "PossibleIntendedRethrow", Justification = "Stack trace erasure intentional.")]
public static TValidResult Ok(Result result)
diff --git a/Funcky.Xunit/FunctionalAssert/Right.cs b/Funcky.Xunit/FunctionalAssert/Right.cs
index 505b5d10..76cc668d 100644
--- a/Funcky.Xunit/FunctionalAssert/Right.cs
+++ b/Funcky.Xunit/FunctionalAssert/Right.cs
@@ -8,11 +8,11 @@ public static partial class FunctionalAssert
{
/// Asserts that the given is Right and contains the given .
/// Thrown when is Left.
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[System.Diagnostics.StackTraceHidden]
- #else
+#else
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- #endif
+#endif
public static void Right(TRight expectedRight, Either either)
where TLeft : notnull
where TRight : notnull
@@ -33,11 +33,11 @@ public static void Right(TRight expectedRight, EitherAsserts that the given is Right.
/// Thrown when is Left.
/// Returns the value in if it was Right.
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[System.Diagnostics.StackTraceHidden]
- #else
+#else
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- #endif
+#endif
[SuppressMessage("Microsoft.Usage", "CA2200", Justification = "Stack trace erasure intentional.")]
[SuppressMessage("ReSharper", "PossibleIntendedRethrow", Justification = "Stack trace erasure intentional.")]
public static TRight Right(Either either)
diff --git a/Funcky.Xunit/FunctionalAssert/Some.cs b/Funcky.Xunit/FunctionalAssert/Some.cs
index bf17666b..f0d846de 100644
--- a/Funcky.Xunit/FunctionalAssert/Some.cs
+++ b/Funcky.Xunit/FunctionalAssert/Some.cs
@@ -8,11 +8,11 @@ public static partial class FunctionalAssert
{
/// Asserts that the given is Some and contains the given .
/// Thrown when the option is None.
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[System.Diagnostics.StackTraceHidden]
- #else
+#else
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- #endif
+#endif
public static void Some(TItem expectedValue, Option option)
where TItem : notnull
{
@@ -33,11 +33,11 @@ public static void Some(TItem expectedValue, Option option)
/// Thrown when is None.
/// Returns the value in if it was Some.
[Pure]
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[System.Diagnostics.StackTraceHidden]
- #else
+#else
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- #endif
+#endif
[SuppressMessage("Microsoft.Usage", "CA2200", Justification = "Stack trace erasure intentional.")]
[SuppressMessage("ReSharper", "PossibleIntendedRethrow", Justification = "Stack trace erasure intentional.")]
public static TItem Some(Option option)
diff --git a/Funcky/Extensions/EnumerableExtensions/Shuffle.cs b/Funcky/Extensions/EnumerableExtensions/Shuffle.cs
index 5d6c9d0c..eb3cdcfa 100644
--- a/Funcky/Extensions/EnumerableExtensions/Shuffle.cs
+++ b/Funcky/Extensions/EnumerableExtensions/Shuffle.cs
@@ -32,5 +32,5 @@ public static IReadOnlyList Shuffle(this IEnumerable
=> source
.ToList()
.ToRandomList(random);
- #endif
+#endif
}
diff --git a/Funcky/Internal/Validators/ChunkSizeValidator.cs b/Funcky/Internal/Validators/ChunkSizeValidator.cs
index c3ce35da..8dd5a983 100644
--- a/Funcky/Internal/Validators/ChunkSizeValidator.cs
+++ b/Funcky/Internal/Validators/ChunkSizeValidator.cs
@@ -1,4 +1,4 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
namespace Funcky.Internal.Validators;
diff --git a/Funcky/Monads/Result/Result.Core.cs b/Funcky/Monads/Result/Result.Core.cs
index 4ff3516e..ac58d644 100644
--- a/Funcky/Monads/Result/Result.Core.cs
+++ b/Funcky/Monads/Result/Result.Core.cs
@@ -15,9 +15,9 @@ namespace Funcky.Monads;
public readonly partial struct Result : IEquatable>
where TValidResult : notnull
{
- #if !SET_CURRENT_STACK_TRACE_SUPPORTED
+#if !SET_CURRENT_STACK_TRACE_SUPPORTED
private const int SkipLowestStackFrame = 1;
- #endif
+#endif
private readonly TValidResult _result;
private readonly Exception? _error;
@@ -49,16 +49,16 @@ private Result(Exception error)
/// Creates a new from an and sets
/// the stack trace if not already set.
/// This method has side effects: It sets the stack trace on if not already set.
- #if SET_CURRENT_STACK_TRACE_SUPPORTED
+#if SET_CURRENT_STACK_TRACE_SUPPORTED
// Methods with AggressiveInlining are always excluded from the stack trace.
// This is required for SetCurrentStackTrace to work properly.
// See: https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs#L347
- #if STACK_TRACE_HIDDEN_SUPPORTED
+#if STACK_TRACE_HIDDEN_SUPPORTED
[StackTraceHidden]
- #else
+#else
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- #endif
- #endif
+#endif
+#endif
public static Result Error(Exception exception)
{
if (exception is null)
@@ -68,11 +68,11 @@ public static Result Error(Exception exception)
if (exception.StackTrace is null)
{
- #if SET_CURRENT_STACK_TRACE_SUPPORTED
- ExceptionDispatchInfo.SetCurrentStackTrace(exception);
- #else
- exception.SetStackTrace(new StackTrace(SkipLowestStackFrame, true));
- #endif
+#if SET_CURRENT_STACK_TRACE_SUPPORTED
+ ExceptionDispatchInfo.SetCurrentStackTrace(exception);
+#else
+ exception.SetStackTrace(new StackTrace(SkipLowestStackFrame, true));
+#endif
}
return new Result(exception);
diff --git a/Funcky/Sequence/Sequence.CycleRange.cs b/Funcky/Sequence/Sequence.CycleRange.cs
index 912da0e4..a1f117db 100644
--- a/Funcky/Sequence/Sequence.CycleRange.cs
+++ b/Funcky/Sequence/Sequence.CycleRange.cs
@@ -92,7 +92,7 @@ private IEnumerator GetEnumeratorInternal()
// this can change on Dispose!
var bufferCount = _buffer.Count;
- for (int cycle = 1; IsCycling(cycle); ++cycle)
+ for (var cycle = 1; IsCycling(cycle); ++cycle)
{
for (var index = 0; index < bufferCount; ++index)
{