From 86d06d75e0797d4a87314a9cb258f44fa9f5aa68 Mon Sep 17 00:00:00 2001 From: Stuart Turner Date: Wed, 10 Apr 2024 12:29:00 -0500 Subject: [PATCH] Updates & Modernization (#647) --- .editorconfig | 198 ++++++---- Directory.Build.props | 47 ++- Directory.Packages.props | 1 + .../SuperLinq.Async.Generator/Generator.cs | 2 +- Generators/SuperLinq.Generator/EquiZip.sbntxt | 2 +- Generators/SuperLinq.Generator/Generator.cs | 2 +- .../SuperLinq.Generator/ToDelimitedString.cs | 22 +- Source/SuperLinq.Async/Amb.cs | 4 +- Source/SuperLinq.Async/FillBackward.cs | 12 +- Source/SuperLinq.Async/FillForward.cs | 15 +- Source/SuperLinq.Async/Join.HashJoin.cs | 4 +- Source/SuperLinq.Async/Join.LoopJoin.cs | 2 +- Source/SuperLinq.Async/Join.MergeJoin.cs | 8 +- Source/SuperLinq.Async/Memoize.cs | 8 +- Source/SuperLinq.Async/Publish.cs | 6 +- Source/SuperLinq.Async/Share.cs | 6 +- Source/SuperLinq.Async/Split.cs | 4 +- Source/SuperLinq.Async/SuperLinq.Async.csproj | 280 +++++++------- Source/SuperLinq/Assert.cs | 4 +- .../Collections/UpdatablePriorityQueue.cs | 30 +- Source/SuperLinq/FillBackward.cs | 10 +- Source/SuperLinq/FillForward.cs | 4 +- .../EquiZip.g.cs | 6 +- Source/SuperLinq/Join.HashJoin.cs | 4 +- Source/SuperLinq/Join.LoopJoin.cs | 2 +- Source/SuperLinq/Join.MergeJoin.cs | 8 +- Source/SuperLinq/Lookup.cs | 4 +- Source/SuperLinq/Memoize.cs | 10 +- Source/SuperLinq/OrderBy.cs | 4 +- .../PublicAPI/net6.0/PublicAPI.Unshipped.txt | 5 + .../PublicAPI/net7.0/PublicAPI.Unshipped.txt | 5 + .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 5 + .../PublicAPI/net9.0/PublicAPI.Unshipped.txt | 5 + .../netcoreapp3.1/PublicAPI.Unshipped.txt | 5 + Source/SuperLinq/Publish.cs | 2 +- Source/SuperLinq/Share.cs | 2 +- Source/SuperLinq/Shuffle.cs | 2 +- Source/SuperLinq/SuperLinq.csproj | 365 +++++++++--------- Source/SuperLinq/TagFirstLast.cs | 4 +- Source/SuperLinq/ToDataTable.cs | 4 +- Source/SuperLinq/ToLookup.cs | 4 +- Source/SuperLinq/ValueTupleComparer.cs | 4 +- .../SuperLinq/ValueTupleEqualityComparer.cs | 4 +- Source/SuperLinq/WindowLeft.cs | 2 +- Tests/SuperLinq.Async.Test/.editorconfig | 5 +- Tests/SuperLinq.Async.Test/AggregateByTest.cs | 27 +- .../AggregateRightTest.cs | 14 +- Tests/SuperLinq.Async.Test/AmbTest.cs | 2 +- Tests/SuperLinq.Async.Test/AssertCountTest.cs | 2 +- Tests/SuperLinq.Async.Test/AtLeastTest.cs | 2 +- Tests/SuperLinq.Async.Test/AtMostTest.cs | 2 +- Tests/SuperLinq.Async.Test/BatchTest.cs | 2 +- Tests/SuperLinq.Async.Test/BindByIndexTest.cs | 2 +- .../SuperLinq.Async.Test/BreakingSequence.cs | 8 +- Tests/SuperLinq.Async.Test/BufferTest.cs | 2 +- Tests/SuperLinq.Async.Test/CaseTest.cs | 2 +- Tests/SuperLinq.Async.Test/CatchTest.cs | 2 +- Tests/SuperLinq.Async.Test/ChooseTest.cs | 2 +- .../CollectionEqualTest.cs | 2 +- .../SuperLinq.Async.Test/CompareCountTest.cs | 2 +- .../ConcurrentMergeTest.cs | 2 +- Tests/SuperLinq.Async.Test/ConsumeTest.cs | 2 +- Tests/SuperLinq.Async.Test/CopyToTest.cs | 2 +- .../SuperLinq.Async.Test/CountBetweenTest.cs | 2 +- Tests/SuperLinq.Async.Test/CountByTest.cs | 2 +- Tests/SuperLinq.Async.Test/CountDownTest.cs | 2 +- Tests/SuperLinq.Async.Test/DeferTest.cs | 2 +- .../DensePartialSortByTest.cs | 2 +- .../DensePartialSortTest.cs | 2 +- Tests/SuperLinq.Async.Test/DenseRankTest.cs | 2 +- Tests/SuperLinq.Async.Test/DistinctByTest.cs | 2 +- .../DistinctUntilChangedTest.cs | 2 +- Tests/SuperLinq.Async.Test/DoTest.cs | 2 +- Tests/SuperLinq.Async.Test/DoWhileTest.cs | 2 +- Tests/SuperLinq.Async.Test/DuplicatesTest.cs | 2 +- Tests/SuperLinq.Async.Test/ElementAtTest.cs | 2 +- Tests/SuperLinq.Async.Test/EndsWithTest.cs | 2 +- Tests/SuperLinq.Async.Test/EquiZipTest.cs | 2 +- Tests/SuperLinq.Async.Test/ExactlyTest.cs | 2 +- Tests/SuperLinq.Async.Test/ExceptByTest.cs | 2 +- .../FallbackIfEmptyTest.cs | 2 +- .../SuperLinq.Async.Test/FillBackwardTest.cs | 2 +- Tests/SuperLinq.Async.Test/FillForwardTest.cs | 8 +- Tests/SuperLinq.Async.Test/FinallyTest.cs | 2 +- Tests/SuperLinq.Async.Test/FindIndexTest.cs | 2 +- .../SuperLinq.Async.Test/FindLastIndexTest.cs | 2 +- Tests/SuperLinq.Async.Test/FoldTest.cs | 2 +- Tests/SuperLinq.Async.Test/ForEachTest.cs | 2 +- Tests/SuperLinq.Async.Test/FromTest.cs | 2 +- .../SuperLinq.Async.Test/FullOuterJoinTest.cs | 2 +- Tests/SuperLinq.Async.Test/GenerateTest.cs | 2 +- .../GetShortestPathTest.cs | 4 +- .../SuperLinq.Async.Test/GroupAdjacentTest.cs | 2 +- .../SuperLinq.Async.Test/HasDuplicatesTest.cs | 2 +- Tests/SuperLinq.Async.Test/IfTest.cs | 2 +- Tests/SuperLinq.Async.Test/IndexByTest.cs | 2 +- Tests/SuperLinq.Async.Test/IndexOfTest.cs | 2 +- Tests/SuperLinq.Async.Test/IndexTest.cs | 2 +- Tests/SuperLinq.Async.Test/InnerJoinTest.cs | 2 +- Tests/SuperLinq.Async.Test/InsertTest.cs | 2 +- Tests/SuperLinq.Async.Test/InterleaveTest.cs | 2 +- Tests/SuperLinq.Async.Test/LagTest.cs | 2 +- Tests/SuperLinq.Async.Test/LastIndexOfTest.cs | 2 +- Tests/SuperLinq.Async.Test/LeadTest.cs | 2 +- Tests/SuperLinq.Async.Test/LeftOuterJoin.cs | 2 +- Tests/SuperLinq.Async.Test/MaxItemsTest.cs | 2 +- Tests/SuperLinq.Async.Test/MemoizeTest.cs | 4 +- Tests/SuperLinq.Async.Test/MinItemsTest.cs | 2 +- .../SuperLinq.Async.Test/NullArgumentTest.cs | 72 ++-- .../OnErrorResumeNextTest.cs | 2 +- Tests/SuperLinq.Async.Test/OrderByTest.cs | 18 +- Tests/SuperLinq.Async.Test/PadStartTest.cs | 8 +- Tests/SuperLinq.Async.Test/PadTest.cs | 6 +- .../SuperLinq.Async.Test/PartialSortByTest.cs | 2 +- Tests/SuperLinq.Async.Test/PartialSortTest.cs | 2 +- Tests/SuperLinq.Async.Test/PartitionTest.cs | 2 +- Tests/SuperLinq.Async.Test/PreScanTest.cs | 2 +- Tests/SuperLinq.Async.Test/PublishTest.cs | 4 +- Tests/SuperLinq.Async.Test/RandomTest.cs | 2 +- Tests/SuperLinq.Async.Test/RankTest.cs | 4 +- Tests/SuperLinq.Async.Test/RepeatTest.cs | 2 +- Tests/SuperLinq.Async.Test/ReplaceTest.cs | 2 +- Tests/SuperLinq.Async.Test/RetryTest.cs | 2 +- Tests/SuperLinq.Async.Test/ReturnTest.cs | 2 +- Tests/SuperLinq.Async.Test/RightOuterJoin.cs | 2 +- .../RunLengthEncodeTest.cs | 2 +- Tests/SuperLinq.Async.Test/ScanByTest.cs | 2 +- Tests/SuperLinq.Async.Test/ScanRightTest.cs | 12 +- Tests/SuperLinq.Async.Test/ScanTest.cs | 2 +- Tests/SuperLinq.Async.Test/SegmentTest.cs | 6 +- Tests/SuperLinq.Async.Test/SequenceReader.cs | 4 +- Tests/SuperLinq.Async.Test/SequenceTest.cs | 2 +- Tests/SuperLinq.Async.Test/ShareTest.cs | 4 +- Tests/SuperLinq.Async.Test/SkipUntilTest.cs | 6 +- .../SuperLinq.Async.Test/SortedMergeByTest.cs | 2 +- Tests/SuperLinq.Async.Test/SortedMergeTest.cs | 2 +- Tests/SuperLinq.Async.Test/SplitTest.cs | 6 +- Tests/SuperLinq.Async.Test/StartsWithTest.cs | 2 +- .../SuperLinq.Async.Test.csproj | 3 +- .../SuperLinq.Async.Test/TagFirstLastTest.cs | 2 +- Tests/SuperLinq.Async.Test/TakeEveryTest.cs | 2 +- Tests/SuperLinq.Async.Test/TakeTest.cs | 2 +- Tests/SuperLinq.Async.Test/TakeUntilTest.cs | 2 +- Tests/SuperLinq.Async.Test/TestingSequence.cs | 22 +- Tests/SuperLinq.Async.Test/ThrowTest.cs | 2 +- Tests/SuperLinq.Async.Test/TimeoutTest.cs | 6 +- Tests/SuperLinq.Async.Test/TraverseTest.cs | 4 +- Tests/SuperLinq.Async.Test/TrySingleTest.cs | 2 +- Tests/SuperLinq.Async.Test/UsingTest.cs | 4 +- Tests/SuperLinq.Async.Test/WhereLagTest.cs | 2 +- Tests/SuperLinq.Async.Test/WhereLeadTest.cs | 2 +- Tests/SuperLinq.Async.Test/WhereTest.cs | 2 +- Tests/SuperLinq.Async.Test/WhileTest.cs | 2 +- Tests/SuperLinq.Async.Test/WindowLeftTest.cs | 2 +- Tests/SuperLinq.Async.Test/WindowRightTest.cs | 2 +- Tests/SuperLinq.Async.Test/WindowTest.cs | 2 +- Tests/SuperLinq.Async.Test/ZipLongestTest.cs | 2 +- Tests/SuperLinq.Async.Test/ZipMapTest.cs | 9 +- Tests/SuperLinq.Async.Test/ZipShortestTest.cs | 2 +- Tests/SuperLinq.Test/.editorconfig | 5 +- Tests/SuperLinq.Test/AggregateByTest.cs | 27 +- Tests/SuperLinq.Test/AggregateRightTest.cs | 20 +- Tests/SuperLinq.Test/AggregateTest.cs | 2 +- Tests/SuperLinq.Test/AssertCountTest.cs | 2 +- Tests/SuperLinq.Test/AtLeastTest.cs | 2 +- Tests/SuperLinq.Test/AtMostTest.cs | 2 +- Tests/SuperLinq.Test/BacksertTest.cs | 2 +- Tests/SuperLinq.Test/BatchTest.cs | 2 +- Tests/SuperLinq.Test/BindByIndexTest.cs | 2 +- Tests/SuperLinq.Test/BreakingList.cs | 20 +- Tests/SuperLinq.Test/BufferTest.cs | 2 +- Tests/SuperLinq.Test/CartesianTest.cs | 2 +- Tests/SuperLinq.Test/CaseTest.cs | 2 +- Tests/SuperLinq.Test/CatchTest.cs | 2 +- Tests/SuperLinq.Test/ChooseTest.cs | 2 +- Tests/SuperLinq.Test/CollectionEqualTest.cs | 2 +- Tests/SuperLinq.Test/CompareCountTest.cs | 2 +- Tests/SuperLinq.Test/ConsumeTest.cs | 2 +- Tests/SuperLinq.Test/CopyToTest.cs | 2 +- Tests/SuperLinq.Test/CountBetweenTest.cs | 2 +- Tests/SuperLinq.Test/CountByTest.cs | 2 +- Tests/SuperLinq.Test/CountDownTest.cs | 2 +- Tests/SuperLinq.Test/DeferTest.cs | 2 +- .../SuperLinq.Test/DensePartialSortByTest.cs | 2 +- Tests/SuperLinq.Test/DensePartialSortTest.cs | 2 +- Tests/SuperLinq.Test/DenseRankTest.cs | 2 +- Tests/SuperLinq.Test/DistinctByTest.cs | 2 +- .../DistinctUntilChangedTest.cs | 2 +- Tests/SuperLinq.Test/DoTest.cs | 2 +- Tests/SuperLinq.Test/DoWhileTest.cs | 2 +- Tests/SuperLinq.Test/DuplicatesTest.cs | 2 +- Tests/SuperLinq.Test/ElementAtTest.cs | 2 +- Tests/SuperLinq.Test/EndsWithTest.cs | 4 +- Tests/SuperLinq.Test/EqualityComparer.cs | 2 +- Tests/SuperLinq.Test/EquiZipTest.cs | 2 +- Tests/SuperLinq.Test/EvaluateTest.cs | 2 +- Tests/SuperLinq.Test/ExactlyTest.cs | 2 +- Tests/SuperLinq.Test/ExceptByTest.cs | 2 +- Tests/SuperLinq.Test/ExcludeTest.cs | 2 +- Tests/SuperLinq.Test/FallbackIfEmptyTest.cs | 2 +- Tests/SuperLinq.Test/FillBackwardTest.cs | 2 +- Tests/SuperLinq.Test/FillForwardTest.cs | 12 +- Tests/SuperLinq.Test/FinallyTest.cs | 2 +- Tests/SuperLinq.Test/FindIndexTest.cs | 2 +- Tests/SuperLinq.Test/FindLastIndexTest.cs | 2 +- Tests/SuperLinq.Test/FlattenTest.cs | 20 +- Tests/SuperLinq.Test/FoldTest.cs | 2 +- Tests/SuperLinq.Test/ForEachTest.cs | 2 +- Tests/SuperLinq.Test/FromTest.cs | 2 +- Tests/SuperLinq.Test/FullGroupJoinTest.cs | 2 +- Tests/SuperLinq.Test/FullOuterJoinTest.cs | 2 +- Tests/SuperLinq.Test/GenerateTest.cs | 2 +- Tests/SuperLinq.Test/GetShortestPathTest.cs | 4 +- Tests/SuperLinq.Test/GroupAdjacentTest.cs | 2 +- Tests/SuperLinq.Test/HasDuplicatesTest.cs | 2 +- Tests/SuperLinq.Test/IfTest.cs | 2 +- Tests/SuperLinq.Test/IndexByTest.cs | 2 +- Tests/SuperLinq.Test/IndexOfTest.cs | 2 +- Tests/SuperLinq.Test/IndexTest.cs | 2 +- Tests/SuperLinq.Test/InnerJoinTest.cs | 2 +- Tests/SuperLinq.Test/InsertTest.cs | 2 +- Tests/SuperLinq.Test/InterleaveTest.cs | 2 +- Tests/SuperLinq.Test/LagTest.cs | 2 +- Tests/SuperLinq.Test/LastIndexOfTest.cs | 2 +- Tests/SuperLinq.Test/LeadTest.cs | 2 +- Tests/SuperLinq.Test/LeftOuterJoin.cs | 2 +- Tests/SuperLinq.Test/MaxItemsTest.cs | 2 +- Tests/SuperLinq.Test/MemoizeTest.cs | 12 +- Tests/SuperLinq.Test/MinItemsTest.cs | 2 +- Tests/SuperLinq.Test/MoveTest.cs | 2 +- Tests/SuperLinq.Test/NullArgumentTest.cs | 59 ++- Tests/SuperLinq.Test/OnErrorResumeNextTest.cs | 2 +- Tests/SuperLinq.Test/OrderByTest.cs | 78 ++-- Tests/SuperLinq.Test/PadStartTest.cs | 2 +- Tests/SuperLinq.Test/PadTest.cs | 4 +- Tests/SuperLinq.Test/PartialSortByTest.cs | 2 +- Tests/SuperLinq.Test/PartialSortTest.cs | 2 +- Tests/SuperLinq.Test/PartitionTest.cs | 2 +- Tests/SuperLinq.Test/PermutationsTest.cs | 2 +- Tests/SuperLinq.Test/PreScanTest.cs | 2 +- Tests/SuperLinq.Test/PublishTest.cs | 4 +- Tests/SuperLinq.Test/RandomSubsetTest.cs | 2 +- Tests/SuperLinq.Test/RandomTest.cs | 2 +- Tests/SuperLinq.Test/RankTest.cs | 2 +- Tests/SuperLinq.Test/RepeatTest.cs | 4 +- Tests/SuperLinq.Test/ReplaceTest.cs | 2 +- Tests/SuperLinq.Test/RetryTest.cs | 2 +- Tests/SuperLinq.Test/ReturnTest.cs | 10 +- Tests/SuperLinq.Test/RightOuterJoin.cs | 2 +- Tests/SuperLinq.Test/RunLengthEncodeTest.cs | 2 +- Tests/SuperLinq.Test/ScanByTest.cs | 2 +- Tests/SuperLinq.Test/ScanRightTest.cs | 18 +- Tests/SuperLinq.Test/ScanTest.cs | 2 +- Tests/SuperLinq.Test/SegmentTest.cs | 4 +- Tests/SuperLinq.Test/SequenceReader.cs | 4 +- Tests/SuperLinq.Test/SequenceTest.cs | 2 +- Tests/SuperLinq.Test/ShareTest.cs | 4 +- Tests/SuperLinq.Test/ShuffleTest.cs | 2 +- Tests/SuperLinq.Test/SkipUntilTest.cs | 4 +- Tests/SuperLinq.Test/SliceTest.cs | 2 +- Tests/SuperLinq.Test/SortedMergeByTest.cs | 2 +- Tests/SuperLinq.Test/SortedMergeTest.cs | 2 +- Tests/SuperLinq.Test/SplitTest.cs | 6 +- Tests/SuperLinq.Test/StartsWithTest.cs | 4 +- Tests/SuperLinq.Test/SubsetTest.cs | 4 +- Tests/SuperLinq.Test/SuperLinq.Test.csproj | 2 - Tests/SuperLinq.Test/TagFirstLastTest.cs | 2 +- Tests/SuperLinq.Test/TakeEveryTest.cs | 2 +- Tests/SuperLinq.Test/TakeTest.cs | 22 +- Tests/SuperLinq.Test/TakeUntilTest.cs | 2 +- Tests/SuperLinq.Test/TestingCollection.cs | 6 +- Tests/SuperLinq.Test/TestingSequence.cs | 19 +- Tests/SuperLinq.Test/ThrowTest.cs | 2 +- Tests/SuperLinq.Test/ToArrayByIndexTest.cs | 4 +- Tests/SuperLinq.Test/ToDataTableTest.cs | 18 +- Tests/SuperLinq.Test/ToDelimitedStringTest.cs | 2 +- Tests/SuperLinq.Test/ToDictionaryTest.cs | 2 +- Tests/SuperLinq.Test/ToLookupTest.cs | 2 +- Tests/SuperLinq.Test/TransposeTest.cs | 6 +- Tests/SuperLinq.Test/TraverseTest.cs | 4 +- Tests/SuperLinq.Test/TrySingleTest.cs | 12 +- .../UpdatablePriorityQueueTest.cs | 28 +- Tests/SuperLinq.Test/UsingTest.cs | 4 +- .../SuperLinq.Test/ValueTupleComparerTest.cs | 8 +- .../ValueTupleEqualityComparerTest.cs | 16 +- Tests/SuperLinq.Test/WhereLagTest.cs | 2 +- Tests/SuperLinq.Test/WhereLeadTest.cs | 2 +- Tests/SuperLinq.Test/WhereTest.cs | 2 +- Tests/SuperLinq.Test/WhileTest.cs | 2 +- Tests/SuperLinq.Test/WindowLeftTest.cs | 4 +- Tests/SuperLinq.Test/WindowRightTest.cs | 4 +- Tests/SuperLinq.Test/WindowTest.cs | 4 +- Tests/SuperLinq.Test/ZipLongestTest.cs | 2 +- Tests/SuperLinq.Test/ZipMapTest.cs | 9 +- Tests/SuperLinq.Test/ZipShortestTest.cs | 2 +- 295 files changed, 1189 insertions(+), 1079 deletions(-) diff --git a/.editorconfig b/.editorconfig index 1a0bd818d..2d759694c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,39 +12,34 @@ charset = utf-8 ### Naming rules: ### -# Constants are PascalCase -dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants -dotnet_naming_rule.constants_should_be_pascal_case.style = non_private_static_field_style - -dotnet_naming_symbols.constants.applicable_kinds = field, local -dotnet_naming_symbols.constants.required_modifiers = const +## Styles: +dotnet_naming_style.pascal_case_style.capitalization = pascal_case -dotnet_naming_style.constant_style.capitalization = pascal_case +dotnet_naming_style.camel_case_style.capitalization = camel_case -# Non-private readonly fields are PascalCase -dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields -dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_static_field_style +dotnet_naming_style.static_field_style.capitalization = camel_case +dotnet_naming_style.static_field_style.required_prefix = s_ -dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field -dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected -dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly +dotnet_naming_style.instance_field_style.capitalization = camel_case +dotnet_naming_style.instance_field_style.required_prefix = _ -dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case +# Constants +dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants +dotnet_naming_rule.constants_should_be_pascal_case.style = pascal_case_style -# Non-private static fields are PascalCase -dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields -dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style +dotnet_naming_symbols.constants.applicable_kinds = * +dotnet_naming_symbols.constants.required_modifiers = const -dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field -dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected -dotnet_naming_symbols.non_private_static_fields.required_modifiers = static +# Non-private fields are PascalCase +dotnet_naming_rule.non_private_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_private_fields_should_be_pascal_case.symbols = non_private_readonly_fields +dotnet_naming_rule.non_private_fields_should_be_pascal_case.style = pascal_case_style -dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case +dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, protected_internal -# Static fields are camelCase and start with s_ +# Static fields are s_camelCase dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style @@ -52,9 +47,6 @@ dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style dotnet_naming_symbols.static_fields.applicable_kinds = field dotnet_naming_symbols.static_fields.required_modifiers = static -dotnet_naming_style.static_field_style.capitalization = camel_case -dotnet_naming_style.static_field_style.required_prefix = s_ - # Instance fields are camelCase and start with _ dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields @@ -62,9 +54,6 @@ dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_s dotnet_naming_symbols.instance_fields.applicable_kinds = field -dotnet_naming_style.instance_field_style.capitalization = camel_case -dotnet_naming_style.instance_field_style.required_prefix = _ - # Locals and parameters are camelCase dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters @@ -72,26 +61,20 @@ dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local -dotnet_naming_style.camel_case_style.capitalization = camel_case - # Local functions are PascalCase dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions -dotnet_naming_rule.local_functions_should_be_pascal_case.style = non_private_static_field_style +dotnet_naming_rule.local_functions_should_be_pascal_case.style = pascal_case_style dotnet_naming_symbols.local_functions.applicable_kinds = local_function -dotnet_naming_style.local_function_style.capitalization = pascal_case - # By default, name items with PascalCase dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members -dotnet_naming_rule.members_should_be_pascal_case.style = non_private_static_field_style +dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style dotnet_naming_symbols.all_members.applicable_kinds = * -dotnet_naming_style.pascal_case_style.capitalization = pascal_case - ### Dotnet code style settings: ### @@ -129,7 +112,7 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion # Assignments dotnet_style_prefer_conditional_expression_over_assignment = true:error -dotnet_style_prefer_conditional_expression_over_return = true:warning +dotnet_style_prefer_conditional_expression_over_return = true:none dotnet_style_prefer_compound_assignment = true:warning # Parenthesis @@ -279,13 +262,15 @@ csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimenta dotnet_analyzer_diagnostic.category-Style.severity = warning dotnet_analyzer_diagnostic.category-Globalization.severity = error -dotnet_diagnostic.IDE0011.severity = silent # IDE0011: Add braces -dotnet_diagnostic.IDE0046.severity = silent # IDE0046: Convert to conditional expression -dotnet_diagnostic.IDE0043.severity = error # IDE0043: Format string contains invalid placeholder +# IDE Diagnostics +dotnet_diagnostic.IDE0005.severity = error # IDE0005: Using directive is unnecessary +dotnet_diagnostic.IDE0011.severity = silent # IDE0011: Add braces +dotnet_diagnostic.IDE0046.severity = silent # IDE0046: Convert to conditional expression +dotnet_diagnostic.IDE0043.severity = error # IDE0043: Format string contains invalid placeholder dotnet_diagnostic.IDE0051.severity = warning # IDE0051: Remove unused private member dotnet_diagnostic.IDE0052.severity = warning # IDE0052: Remove unread private member dotnet_diagnostic.IDE0076.severity = warning # IDE0076: Remove invalid global 'SuppressMessageAttribute' -dotnet_diagnostic.IDE0305.severity = none # IDE0305: Simplify collection initialization +dotnet_diagnostic.IDE0305.severity = suggestion # IDE0305: Simplify collection initialization # XML Documentation dotnet_diagnostic.CS0105.severity = error # CS0105: Using directive is unnecessary. @@ -305,45 +290,102 @@ dotnet_diagnostic.CA2007.severity = none # CA2007: Consider calli dotnet_diagnostic.CA5394.severity = none # CA5394: Random is an insecure random number generator. Use cryptographically secure random number generators when randomness is required for security. # Public API Documentation -dotnet_diagnostic.RS0016.severity = error # RS0016: Add public types and members to the declared API -dotnet_diagnostic.RS0017.severity = error # RS0017: Remove deleted types and members from the declared API +dotnet_diagnostic.RS0016.severity = error # RS0016: Add public types and members to the declared API +dotnet_diagnostic.RS0017.severity = error # RS0017: Remove deleted types and members from the declared API # false positive for SuperLinq.Async CancellationTokens -dotnet_diagnostic.RS0026.severity = none # RS0026: Do not add multiple public overloads with optional parameters - -# Bug in compiler -dotnet_diagnostic.CA1861.severity = none # CA1861: Avoid constant arrays as arguments +dotnet_diagnostic.RS0026.severity = none # RS0026: Do not add multiple public overloads with optional parameters # Primary Constructors -dotnet_diagnostic.CS9107.severity = error # CS9107: Parameter is captured into the state of the enclosing type and its value is also passed to the base constructor -dotnet_diagnostic.CS9113.severity = error # CS9113: Your class never references the primary constructor -dotnet_diagnostic.CS9124.severity = error # CS9124: Parameter is captured into the state of the enclosing type and its value is also used to initialize a field, property, or event -dotnet_diagnostic.CS9179.severity = error # CS9179: Primary constructor parameter is shadowed by a member from base +dotnet_diagnostic.CS9107.severity = error # CS9107: Parameter is captured into the state of the enclosing type and its value is also passed to the base constructor +dotnet_diagnostic.CS9113.severity = error # CS9113: Your class never references the primary constructor +dotnet_diagnostic.CS9124.severity = error # CS9124: Parameter is captured into the state of the enclosing type and its value is also used to initialize a field, property, or event +dotnet_diagnostic.CS9179.severity = error # CS9179: Primary constructor parameter is shadowed by a member from base # Regex (can't use generated regex on pre-net7) dotnet_diagnostic.SYSLIB1045.severity = none # SYSLIB1045: Use GeneratedRegexAttribute to generate the regular expression implementation at compile time. # Miscellaneous analyzers -dotnet_diagnostic.CA1051.severity = error # CA1051: Do not declare visible instance fields -dotnet_diagnostic.CA1307.severity = error # CA1307: Specify StringComparison for clarity -dotnet_diagnostic.CA1507.severity = warning # CA1507: Use `nameof` in place of string -dotnet_diagnostic.CA1510.severity = error # CA1510: Use `ArgumentNullException` throw helper -dotnet_diagnostic.CA1511.severity = error # CA1511: Use `ArgumentException` throw helper -dotnet_diagnostic.CA1512.severity = error # CA1512: Use `ArgumentOutOfRangeException` throw helper -dotnet_diagnostic.CA1513.severity = error # CA1513: Use `ObjectDisposedException` throw helper -dotnet_diagnostic.CA1822.severity = warning # CA1822: Mark members as static -dotnet_diagnostic.CA1825.severity = error # CA1825: Avoid zero-length array allocations -dotnet_diagnostic.CA1826.severity = warning # CA1826: Use property instead of Linq Enumerable method -dotnet_diagnostic.CA1827.severity = warning # CA1827: Do not use Count()/LongCount() when Any() can be used -dotnet_diagnostic.CA1828.severity = warning # CA1828: Do not use CountAsync/LongCountAsync when AnyAsync can be used -dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Enumerable.Count method -dotnet_diagnostic.CA1841.severity = error # CA1841: Prefer Dictionary Contains methods -dotnet_diagnostic.CA1845.severity = warning # CA1845: Use span-based 'string.Concat' -dotnet_diagnostic.CA1852.severity = warning # CA1852: CA1852: Seal internal types -dotnet_diagnostic.CA1853.severity = warning # CA1853: Unnecessary call to 'Dictionary.ContainsKey(key)' -dotnet_diagnostic.CA1854.severity = warning # CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method -dotnet_diagnostic.CA1862.severity = warning # CA1862: Use the 'StringComparison' method overloads to perform case-insensitive string comparisons -dotnet_diagnostic.CA1863.severity = warning # CA1863: Use 'CompositeFormat' -dotnet_diagnostic.CA1864.severity = warning # CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method -dotnet_diagnostic.CA1868.severity = warning # CA1868: Unnecessary call to 'Contains' for sets -dotnet_diagnostic.CA2014.severity = error # CA2014: Do not use stackalloc in loops -dotnet_diagnostic.CA2016.severity = error # CA2016: Forward the CancellationToken parameter to methods that take one +dotnet_diagnostic.CA1051.severity = error # CA1051: Do not declare visible instance fields +dotnet_diagnostic.CA1307.severity = error # CA1307: Specify StringComparison for clarity +dotnet_diagnostic.CA1507.severity = warning # CA1507: Use `nameof` in place of string +dotnet_diagnostic.CA1510.severity = error # CA1510: Use `ArgumentNullException` throw helper +dotnet_diagnostic.CA1511.severity = error # CA1511: Use `ArgumentException` throw helper +dotnet_diagnostic.CA1512.severity = error # CA1512: Use `ArgumentOutOfRangeException` throw helper +dotnet_diagnostic.CA1513.severity = error # CA1513: Use `ObjectDisposedException` throw helper +dotnet_diagnostic.CA1716.severity = none # CA1716: Identifiers should not match keywords +dotnet_diagnostic.CA1822.severity = warning # CA1822: Mark members as static +dotnet_diagnostic.CA1825.severity = error # CA1825: Avoid zero-length array allocations +dotnet_diagnostic.CA1826.severity = warning # CA1826: Use property instead of Linq Enumerable method +dotnet_diagnostic.CA1827.severity = warning # CA1827: Do not use Count()/LongCount() when Any() can be used +dotnet_diagnostic.CA1828.severity = warning # CA1828: Do not use CountAsync/LongCountAsync when AnyAsync can be used +dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Enumerable.Count method +dotnet_diagnostic.CA1841.severity = error # CA1841: Prefer Dictionary Contains methods +dotnet_diagnostic.CA1845.severity = warning # CA1845: Use span-based 'string.Concat' +dotnet_diagnostic.CA1852.severity = warning # CA1852: CA1852: Seal internal types +dotnet_diagnostic.CA1853.severity = warning # CA1853: Unnecessary call to 'Dictionary.ContainsKey(key)' +dotnet_diagnostic.CA1854.severity = warning # CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method +dotnet_diagnostic.CA1862.severity = warning # CA1862: Use the 'StringComparison' method overloads to perform case-insensitive string comparisons +dotnet_diagnostic.CA1863.severity = warning # CA1863: Use 'CompositeFormat' +dotnet_diagnostic.CA1864.severity = warning # CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method +dotnet_diagnostic.CA1868.severity = warning # CA1868: Unnecessary call to 'Contains' for sets +dotnet_diagnostic.CA2014.severity = error # CA2014: Do not use stackalloc in loops +dotnet_diagnostic.CA2016.severity = error # CA2016: Forward the CancellationToken parameter to methods that take one + +dotnet_diagnostic.RS2008.severity = none # RS2008: Enable analyzer release tracking + +MA0053.public_class_should_be_sealed = true +MA0053.exceptions_should_be_sealed = true + +dotnet_diagnostic.MA0004.severity = none +dotnet_diagnostic.MA0005.severity = none +dotnet_diagnostic.MA0006.severity = suggestion +dotnet_diagnostic.MA0008.severity = none +dotnet_diagnostic.MA0009.severity = none +dotnet_diagnostic.MA0010.severity = none +dotnet_diagnostic.MA0016.severity = none +dotnet_diagnostic.MA0018.severity = none +dotnet_diagnostic.MA0024.severity = none +dotnet_diagnostic.MA0026.severity = suggestion +dotnet_diagnostic.MA0029.severity = none +dotnet_diagnostic.MA0030.severity = none +dotnet_diagnostic.MA0031.severity = warning +dotnet_diagnostic.MA0032.severity = none +dotnet_diagnostic.MA0033.severity = error +dotnet_diagnostic.MA0037.severity = none +dotnet_diagnostic.MA0038.severity = none +dotnet_diagnostic.MA0040.severity = none +dotnet_diagnostic.MA0041.severity = none +dotnet_diagnostic.MA0047.severity = none +dotnet_diagnostic.MA0048.severity = none +dotnet_diagnostic.MA0049.severity = none +dotnet_diagnostic.MA0051.severity = none +dotnet_diagnostic.MA0053.severity = warning +dotnet_diagnostic.MA0054.severity = error +dotnet_diagnostic.MA0064.severity = error +dotnet_diagnostic.MA0069.severity = error +dotnet_diagnostic.MA0071.severity = none +dotnet_diagnostic.MA0074.severity = none +dotnet_diagnostic.MA0075.severity = none +dotnet_diagnostic.MA0076.severity = none +dotnet_diagnostic.MA0079.severity = none +dotnet_diagnostic.MA0080.severity = none +dotnet_diagnostic.MA0094.severity = none +dotnet_diagnostic.MA0095.severity = none +dotnet_diagnostic.MA0096.severity = none +dotnet_diagnostic.MA0097.severity = none +dotnet_diagnostic.MA0099.severity = error +dotnet_diagnostic.MA0103.severity = error +dotnet_diagnostic.MA0110.severity = none +dotnet_diagnostic.MA0112.severity = none +dotnet_diagnostic.MA0127.severity = none +dotnet_diagnostic.MA0137.severity = none +dotnet_diagnostic.MA0140.severity = error +dotnet_diagnostic.MA0141.severity = warning +dotnet_diagnostic.MA0142.severity = warning +dotnet_diagnostic.MA0147.severity = error +dotnet_diagnostic.MA0148.severity = none +dotnet_diagnostic.MA0149.severity = none +dotnet_diagnostic.MA0154.severity = warning +dotnet_diagnostic.IDE0305.severity = suggestion +dotnet_diagnostic.MA0003.severity = suggestion +dotnet_diagnostic.MA0084.severity = none diff --git a/Directory.Build.props b/Directory.Build.props index 3dd9d612d..1122e75de 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,34 +1,33 @@ - - latest + + latest - enable - $(WarningsAsErrors);nullable; + enable + $(WarningsAsErrors);nullable; - enable + enable - false + false - latest-all - true + latest-all + true - true + true + - true - + + + + + - - - - + + + true - - - true - - true - true - true - opencover - + true + true + true + opencover + diff --git a/Directory.Packages.props b/Directory.Packages.props index 3fcdd9cc1..a3c3ad20c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,6 +9,7 @@ + diff --git a/Generators/SuperLinq.Async.Generator/Generator.cs b/Generators/SuperLinq.Async.Generator/Generator.cs index 8fb4cd135..fa1211835 100644 --- a/Generators/SuperLinq.Async.Generator/Generator.cs +++ b/Generators/SuperLinq.Async.Generator/Generator.cs @@ -10,7 +10,7 @@ namespace SuperLinq.Async.Generator; /// Uses source generation tools to automate the building of some operators /// [Generator] -public class Generator : IIncrementalGenerator +public sealed class Generator : IIncrementalGenerator { /// public void Initialize(IncrementalGeneratorInitializationContext context) diff --git a/Generators/SuperLinq.Generator/EquiZip.sbntxt b/Generators/SuperLinq.Generator/EquiZip.sbntxt index 2aafc0ccb..3ae9da23b 100644 --- a/Generators/SuperLinq.Generator/EquiZip.sbntxt +++ b/Generators/SuperLinq.Generator/EquiZip.sbntxt @@ -155,7 +155,7 @@ public static partial class SuperEnumerable {{~ end ~}} ) => EquiZip({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); - private class EquiZipIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator + private sealed class EquiZipIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator { {{~ for $j in 1..$i ~}} private readonly global::System.Collections.Generic.IList _list{{ $j }}; diff --git a/Generators/SuperLinq.Generator/Generator.cs b/Generators/SuperLinq.Generator/Generator.cs index 301b5ca0d..3d0e4a75d 100644 --- a/Generators/SuperLinq.Generator/Generator.cs +++ b/Generators/SuperLinq.Generator/Generator.cs @@ -9,7 +9,7 @@ namespace SuperLinq.Generator; /// Uses source generation tools to automate the building of some operators /// [Generator] -public class Generator : IIncrementalGenerator +public sealed class Generator : IIncrementalGenerator { /// public void Initialize(IncrementalGeneratorInitializationContext context) diff --git a/Generators/SuperLinq.Generator/ToDelimitedString.cs b/Generators/SuperLinq.Generator/ToDelimitedString.cs index 10bfeedb0..5c000c231 100644 --- a/Generators/SuperLinq.Generator/ToDelimitedString.cs +++ b/Generators/SuperLinq.Generator/ToDelimitedString.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; @@ -10,16 +10,16 @@ internal static class ToDelimitedString { public static SourceText Generate() { - var types = - from method in typeof(StringBuilder).GetMethods(BindingFlags.Public | BindingFlags.Instance) - where string.Equals("Append", method.Name, StringComparison.Ordinal) - select method.GetParameters() into parameters - where parameters.Length == 1 - select parameters[0].ParameterType into type - where !type.IsGenericType // e.g. ReadOnlySpan<> - && (type.IsValueType || type == typeof(string)) - orderby type.Name - select $"global::{type.FullName}"; + var types = typeof(StringBuilder).GetMethods(BindingFlags.Public | BindingFlags.Instance) + .Where(m => m.Name is "Append") + .Select(m => m.GetParameters()) + .Where(p => p.Length == 1) + .Select(p => p[0].ParameterType) + .Where(t => + !t.IsGenericType // e.g. ReadOnlySpan<> + && (t.IsValueType || t == typeof(string))) + .OrderBy(t => t.Name, StringComparer.Ordinal) + .Select(t => $"global::{t.FullName}"); var template = Template.Parse(ThisAssembly.Resources.ToDelimitedString.Text); var output = template.Render(new { Types = types.ToList(), }); diff --git a/Source/SuperLinq.Async/Amb.cs b/Source/SuperLinq.Async/Amb.cs index f65acc560..969a25171 100644 --- a/Source/SuperLinq.Async/Amb.cs +++ b/Source/SuperLinq.Async/Amb.cs @@ -109,7 +109,7 @@ static async IAsyncEnumerable Core( tasks.Add(firstMove.AsTask()); } - if (e == null) + if (e is null) { // who finishes first? var t = await Task.WhenAny(tasks).ConfigureAwait(false); @@ -158,7 +158,7 @@ ex is OperationCanceledException { } // if we're in the normal path, then e != null; in this case, we need to report any exceptions that we // encounter. - catch (Exception ex) when (e != null) + catch (Exception ex) when (e is not null) { edi = ExceptionDispatchInfo.Capture(ex); } diff --git a/Source/SuperLinq.Async/FillBackward.cs b/Source/SuperLinq.Async/FillBackward.cs index 5dad091b7..137988d88 100644 --- a/Source/SuperLinq.Async/FillBackward.cs +++ b/Source/SuperLinq.Async/FillBackward.cs @@ -1,4 +1,4 @@ -namespace SuperLinq.Async; +namespace SuperLinq.Async; public static partial class AsyncSuperEnumerable { @@ -21,7 +21,7 @@ public static partial class AsyncSuperEnumerable public static IAsyncEnumerable FillBackward(this IAsyncEnumerable source) { - return source.FillBackward(e => new ValueTask(e == null)); + return source.FillBackward(e => new ValueTask(e is null)); } /// @@ -223,13 +223,13 @@ private static async IAsyncEnumerable FillBackwardImpl(IAsyncEnumerable } else { - if (blanks != null) + if (blanks is not null) { foreach (var blank in blanks) { - yield return fillSelector != null - ? await fillSelector(blank, item).ConfigureAwait(false) - : item; + yield return fillSelector is not null + ? await fillSelector(blank, item).ConfigureAwait(false) + : item; } blanks.Clear(); diff --git a/Source/SuperLinq.Async/FillForward.cs b/Source/SuperLinq.Async/FillForward.cs index 99b53e3f7..96e0e6084 100644 --- a/Source/SuperLinq.Async/FillForward.cs +++ b/Source/SuperLinq.Async/FillForward.cs @@ -1,4 +1,4 @@ -namespace SuperLinq.Async; +namespace SuperLinq.Async; public static partial class AsyncSuperEnumerable { @@ -21,7 +21,7 @@ public static partial class AsyncSuperEnumerable public static IAsyncEnumerable FillForward(this IAsyncEnumerable source) { - return source.FillForward(e => new ValueTask(e == null)); + return source.FillForward(e => new ValueTask(e is null)); } /// @@ -218,11 +218,12 @@ private static async IAsyncEnumerable FillForwardImpl(IAsyncEnumerable { if (await predicate(item).ConfigureAwait(false)) { - yield return seed is (true, { } someSeed) - ? fillSelector != null - ? await fillSelector(item, someSeed).ConfigureAwait(false) - : someSeed - : item; + yield return (seed, fillSelector) switch + { + ((true, var s), { } f) => await f(item, s!).ConfigureAwait(false), + ((true, var s), _) => s!, + _ => item, + }; } else { diff --git a/Source/SuperLinq.Async/Join.HashJoin.cs b/Source/SuperLinq.Async/Join.HashJoin.cs index 08ef1e8fc..912b25517 100644 --- a/Source/SuperLinq.Async/Join.HashJoin.cs +++ b/Source/SuperLinq.Async/Join.HashJoin.cs @@ -646,7 +646,7 @@ private static async IAsyncEnumerable JoinHash JoinHash LoopJoin JoinMerge JoinMerge 0) { - if (rightResultSelector != null) + if (rightResultSelector is not null) { foreach (var e in r) yield return rightResultSelector(e); @@ -695,7 +695,7 @@ private static async IAsyncEnumerable JoinMerge JoinMerge GetEnumeratorImpl(CancellationToken cancellati _exception.Throw(); } - if (_enumerator == null) + if (_enumerator is null) break; var moved = false; @@ -203,7 +203,7 @@ public async ValueTask DisposeAsync() { _disposed = true; _buffer.Clear(); - if (_enumerator != null) + if (_enumerator is not null) await _enumerator.DisposeAsync().ConfigureAwait(false); _enumerator = null; _source = null; diff --git a/Source/SuperLinq.Async/Publish.cs b/Source/SuperLinq.Async/Publish.cs index 05be4b010..8fc999e9e 100644 --- a/Source/SuperLinq.Async/Publish.cs +++ b/Source/SuperLinq.Async/Publish.cs @@ -58,7 +58,7 @@ public async ValueTask Reset(CancellationToken cancellationToken = default) _buffers = null; - if (_enumerator != null) + if (_enumerator is not null) await _enumerator.DisposeAsync(); _enumerator = null; _exception = null; @@ -149,7 +149,7 @@ private async IAsyncEnumerator GetEnumeratorImpl(Queue buffer, int version { _exception?.Throw(); - if (_enumerator == null) + if (_enumerator is null) break; var moved = false; @@ -216,7 +216,7 @@ public async ValueTask DisposeAsync() _buffers = null; - if (_enumerator != null) + if (_enumerator is not null) await _enumerator.DisposeAsync().ConfigureAwait(false); _enumerator = null; _source = null; diff --git a/Source/SuperLinq.Async/Share.cs b/Source/SuperLinq.Async/Share.cs index 33495099f..cea54d4c6 100644 --- a/Source/SuperLinq.Async/Share.cs +++ b/Source/SuperLinq.Async/Share.cs @@ -51,7 +51,7 @@ public async ValueTask Reset(CancellationToken cancellationToken = default) _initialized = false; _version++; - if (_enumerator != null) + if (_enumerator is not null) await _enumerator.DisposeAsync(); _enumerator = null; _exception = null; @@ -126,7 +126,7 @@ private async IAsyncEnumerator GetEnumeratorImpl(CancellationToken cancellati _exception?.Throw(); - if (_enumerator == null) + if (_enumerator is null) break; var moved = false; @@ -169,7 +169,7 @@ public async ValueTask DisposeAsync() try { _disposed = true; - if (_enumerator != null) + if (_enumerator is not null) await _enumerator.DisposeAsync().ConfigureAwait(false); _enumerator = null; _source = null; diff --git a/Source/SuperLinq.Async/Split.cs b/Source/SuperLinq.Async/Split.cs index 673e0aec3..72e75f3a3 100644 --- a/Source/SuperLinq.Async/Split.cs +++ b/Source/SuperLinq.Async/Split.cs @@ -1,4 +1,4 @@ -namespace SuperLinq.Async; +namespace SuperLinq.Async; public static partial class AsyncSuperEnumerable { @@ -80,7 +80,7 @@ public static IAsyncEnumerable Split( TSource separator, int count, Func, TResult> resultSelector) { - return Split(source, separator, null, count, resultSelector); + return Split(source, separator, comparer: null, count, resultSelector); } /// diff --git a/Source/SuperLinq.Async/SuperLinq.Async.csproj b/Source/SuperLinq.Async/SuperLinq.Async.csproj index 75ce8f214..5ec3a0245 100644 --- a/Source/SuperLinq.Async/SuperLinq.Async.csproj +++ b/Source/SuperLinq.Async/SuperLinq.Async.csproj @@ -1,144 +1,144 @@ - - - - SuperLinq.Async - SuperLinq.Async - - true - - - - SuperLinq.Async - - SuperLinq Developers - linq;extensions;async - - Apache-2.0 - readme.md - - true - https://github.com/viceroypenguin/SuperLinq - - true - snupkg - - - - - This project enhances Async LINQ to Objects with the following methods: - - - AggregateRight - - AssertCount - - AtLeast - - AtMost - - Choose - - CollectionEqual - - CompareCount - - ConcurrentMerge - - Consume - - CountBetween - - CountBy - - CountDown - - DenseRank - - DenseRankBy - - DistinctBy - - ElementAt - - EndsWith - - Exactly - - ExceptBy - - FallbackIfEmpty - - FillBackward - - FillForward - - Fold - - From - - Generate - - GroupAdjacent - - Index - - IndexBy - - Insert - - Interleave - - OrderBy - - Pad - - PadStart - - PartialSort - - PartialSortBy - - Random - - Rank - - RankBy - - RunLengthEncode - - ScanBy - - ScanRight - - Segment - - Sequence - - SkipUntil - - SortedMerge - - Split - - StartsWith - - TagFirstLast - - Take - - TakeEvery - - TakeUntil - - ThenBy - - Where - - Window - - WindowLeft - - WindowRight - - ZipLongest - - ZipMap - - ZipShortest - - $([System.Text.RegularExpressions.Regex]::Replace($(Description), `\s+`, ` `).Trim().Replace(` - `, `, `).Replace(`:,`, `:`)) - - - Portions © 2008 Jonathan Skeet. - Portions © 2009 Atif Aziz, Chris Ammerman, Konrad Rudolph. - Portions © 2010 Johannes Rudolph, Leopold Bushkin. - Portions © 2015 Felipe Sateler, “sholland”. - Portions © 2016 Andreas Gullberg Larsen, Leandro F. Vieira (leandromoh). - Portions © 2017 Jonas Nyrup (jnyrup). - Portions © 2022 Turning Code, LLC - Portions © 2022 Amichai Mantinband - Portions © Microsoft. All rights reserved. - - $([System.Text.RegularExpressions.Regex]::Replace($(Copyright), `\s+`, ` `).Trim()) - - - - - - - - - - - - - - - - - - - - - - - true - Generated - - - - - - - - - - minor - preview.0 - v - + + + + SuperLinq.Async + SuperLinq.Async + + true + + + + SuperLinq.Async + + SuperLinq Developers + linq;extensions;async + + Apache-2.0 + readme.md + + true + https://github.com/viceroypenguin/SuperLinq + + true + snupkg + + + + + This project enhances Async LINQ to Objects with the following methods: + + - AggregateRight + - AssertCount + - AtLeast + - AtMost + - Choose + - CollectionEqual + - CompareCount + - ConcurrentMerge + - Consume + - CountBetween + - CountBy + - CountDown + - DenseRank + - DenseRankBy + - DistinctBy + - ElementAt + - EndsWith + - Exactly + - ExceptBy + - FallbackIfEmpty + - FillBackward + - FillForward + - Fold + - From + - Generate + - GroupAdjacent + - Index + - IndexBy + - Insert + - Interleave + - OrderBy + - Pad + - PadStart + - PartialSort + - PartialSortBy + - Random + - Rank + - RankBy + - RunLengthEncode + - ScanBy + - ScanRight + - Segment + - Sequence + - SkipUntil + - SortedMerge + - Split + - StartsWith + - TagFirstLast + - Take + - TakeEvery + - TakeUntil + - ThenBy + - Where + - Window + - WindowLeft + - WindowRight + - ZipLongest + - ZipMap + - ZipShortest + + $([System.Text.RegularExpressions.Regex]::Replace($(Description), `\s+`, ` `).Trim().Replace(` - `, `, `).Replace(`:,`, `:`)) + + + Portions © 2008 Jonathan Skeet. + Portions © 2009 Atif Aziz, Chris Ammerman, Konrad Rudolph. + Portions © 2010 Johannes Rudolph, Leopold Bushkin. + Portions © 2015 Felipe Sateler, “sholland”. + Portions © 2016 Andreas Gullberg Larsen, Leandro F. Vieira (leandromoh). + Portions © 2017 Jonas Nyrup (jnyrup). + Portions © 2022 Turning Code, LLC + Portions © 2022 Amichai Mantinband + Portions © Microsoft. All rights reserved. + + $([System.Text.RegularExpressions.Regex]::Replace($(Copyright), `\s+`, ` `).Trim()) + + + + + + + + + + + + + + + + + + + + + + + true + Generated + + + + + + + + + + minor + preview.0 + v + diff --git a/Source/SuperLinq/Assert.cs b/Source/SuperLinq/Assert.cs index 617594733..4fdbadd83 100644 --- a/Source/SuperLinq/Assert.cs +++ b/Source/SuperLinq/Assert.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace SuperLinq; @@ -9,7 +9,7 @@ internal static class Assert { public static void NotNull([NotNull, AllowNull] T? obj, [CallerArgumentExpression(nameof(obj))] string? parameter = null) { - if (obj == null) + if (obj is null) ThrowHelper.ThrowInvalidOperationException($"`SuperLinq` bug: '{parameter}' should not be null."); } diff --git a/Source/SuperLinq/Collections/UpdatablePriorityQueue.cs b/Source/SuperLinq/Collections/UpdatablePriorityQueue.cs index 29b46351e..75c53a95c 100644 --- a/Source/SuperLinq/Collections/UpdatablePriorityQueue.cs +++ b/Source/SuperLinq/Collections/UpdatablePriorityQueue.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // copied from https://github.com/dotnet/runtime/blob/main/src/libraries/System.Collections/src/System/Collections/Generic/PriorityQueue.cs // and further edited @@ -21,7 +21,7 @@ namespace SuperLinq.Collections; /// [DebuggerDisplay("Count = {Count}")] [DebuggerTypeProxy(typeof(PriorityQueueDebugView<,>))] -public class UpdatablePriorityQueue +public sealed class UpdatablePriorityQueue { /// /// Represents an implicit heap-ordered complete d-ary tree, stored as an array. @@ -236,7 +236,7 @@ public void Enqueue(TElement element, TPriority priority) if (_elementIndex.TryGetValue(element, out var index)) { - if (_priorityComparer == null) + if (_priorityComparer is null) { var cmp = Comparer.Default.Compare(_nodes[index].Priority, priority); if (cmp > 0) @@ -265,7 +265,7 @@ public void Enqueue(TElement element, TPriority priority) Grow(currentSize + 1); } - if (_priorityComparer == null) + if (_priorityComparer is null) { MoveUpDefaultComparer((element, priority), currentSize); } @@ -289,7 +289,7 @@ public void EnqueueMinimum(TElement element, TPriority priority) if (_elementIndex.TryGetValue(element, out var index)) { - if (_priorityComparer == null) + if (_priorityComparer is null) { var cmp = Comparer.Default.Compare(_nodes[index].Priority, priority); if (cmp > 0) @@ -314,7 +314,7 @@ public void EnqueueMinimum(TElement element, TPriority priority) Grow(currentSize + 1); } - if (_priorityComparer == null) + if (_priorityComparer is null) { MoveUpDefaultComparer((element, priority), currentSize); } @@ -426,7 +426,7 @@ public TElement EnqueueDequeue(TElement element, TPriority priority) var (rootElement, rootPriority) = _nodes[0]; _ = _elementIndex.Remove(rootElement); - if (_priorityComparer == null) + if (_priorityComparer is null) { if (Comparer.Default.Compare(priority, rootPriority) > 0) { @@ -778,7 +778,7 @@ private void RemoveRootNode() if (lastNodeIndex > 0) { var lastNode = _nodes[lastNodeIndex]; - if (_priorityComparer == null) + if (_priorityComparer is null) { MoveDownDefaultComparer(lastNode, 0); } @@ -840,7 +840,7 @@ private void Heapify() var lastParentWithChildren = GetParentIndex(Count - 1); - if (_priorityComparer == null) + if (_priorityComparer is null) { for (var index = lastParentWithChildren; index >= 0; --index) { @@ -1060,12 +1060,12 @@ private void MoveDownCustomComparer((TElement Element, TPriority Priority) node, [DebuggerTypeProxy(typeof(PriorityQueueDebugView<,>))] internal sealed class UnorderedItemsCollection : IReadOnlyCollection<(TElement Element, TPriority Priority)>, ICollection { - internal readonly UpdatablePriorityQueue Queue; + internal readonly UpdatablePriorityQueue _queue; - internal UnorderedItemsCollection(UpdatablePriorityQueue queue) => Queue = queue; + internal UnorderedItemsCollection(UpdatablePriorityQueue queue) => _queue = queue; /// - public int Count => Queue.Count; + public int Count => _queue.Count; object ICollection.SyncRoot => this; bool ICollection.IsSynchronized => false; @@ -1073,7 +1073,7 @@ void ICollection.CopyTo(Array array, int index) { ArgumentNullException.ThrowIfNull(array); - Array.Copy(Queue._nodes, 0, array, index, Queue.Count); + Array.Copy(_queue._nodes, 0, array, index, _queue.Count); } /// @@ -1156,7 +1156,7 @@ void IEnumerator.Reset() /// Returns an enumerator that iterates through the . /// /// An for the . - public Enumerator GetEnumerator() => new(Queue); + public Enumerator GetEnumerator() => new(_queue); IEnumerator<(TElement Element, TPriority Priority)> IEnumerable<(TElement Element, TPriority Priority)>.GetEnumerator() => GetEnumerator(); @@ -1181,7 +1181,7 @@ public PriorityQueueDebugView(UpdatablePriorityQueue.Unorde { ArgumentNullException.ThrowIfNull(collection); - _queue = collection.Queue; + _queue = collection._queue; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] diff --git a/Source/SuperLinq/FillBackward.cs b/Source/SuperLinq/FillBackward.cs index 8a18a2067..0dbc822a5 100644 --- a/Source/SuperLinq/FillBackward.cs +++ b/Source/SuperLinq/FillBackward.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; namespace SuperLinq; @@ -26,7 +26,7 @@ public static partial class SuperEnumerable /// public static IEnumerable FillBackward(this IEnumerable source) { - return source.FillBackward(static e => e == null); + return source.FillBackward(static e => e is null); } /// @@ -116,11 +116,11 @@ private static IEnumerable FillBackwardCore(IEnumerable source, Func public static IEnumerable FillForward(this IEnumerable source) { - return source.FillForward(static e => e == null); + return source.FillForward(static e => e is null); } /// @@ -162,7 +162,7 @@ public override void CopyTo(T[] array, int arrayIndex) { if (predicate(array[i])) { - array[i] = fillSelector != null + array[i] = fillSelector is not null ? fillSelector(array[i], last) : last; } diff --git a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/EquiZip.g.cs b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/EquiZip.g.cs index e7efecef8..e7c7c7fb1 100644 --- a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/EquiZip.g.cs +++ b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/EquiZip.g.cs @@ -140,7 +140,7 @@ public static partial class SuperEnumerable global::System.Collections.Generic.IEnumerable second ) => EquiZip(first, second, global::System.ValueTuple.Create); - private class EquiZipIterator : ListIterator + private sealed class EquiZipIterator : ListIterator { private readonly global::System.Collections.Generic.IList _list1; private readonly global::System.Collections.Generic.IList _list2; @@ -358,7 +358,7 @@ protected override TResult ElementAt(int index) global::System.Collections.Generic.IEnumerable third ) => EquiZip(first, second, third, global::System.ValueTuple.Create); - private class EquiZipIterator : ListIterator + private sealed class EquiZipIterator : ListIterator { private readonly global::System.Collections.Generic.IList _list1; private readonly global::System.Collections.Generic.IList _list2; @@ -611,7 +611,7 @@ protected override TResult ElementAt(int index) global::System.Collections.Generic.IEnumerable fourth ) => EquiZip(first, second, third, fourth, global::System.ValueTuple.Create); - private class EquiZipIterator : ListIterator + private sealed class EquiZipIterator : ListIterator { private readonly global::System.Collections.Generic.IList _list1; private readonly global::System.Collections.Generic.IList _list2; diff --git a/Source/SuperLinq/Join.HashJoin.cs b/Source/SuperLinq/Join.HashJoin.cs index 0ff39b6bc..b27f04b37 100644 --- a/Source/SuperLinq/Join.HashJoin.cs +++ b/Source/SuperLinq/Join.HashJoin.cs @@ -646,7 +646,7 @@ private static IEnumerable JoinHash( if (!rLookup.Contains(lKey)) { - if (leftResultSelector != null) + if (leftResultSelector is not null) yield return leftResultSelector(l); continue; } @@ -656,7 +656,7 @@ private static IEnumerable JoinHash( yield return bothResultSelector(l, r); } - if (rightResultSelector != null) + if (rightResultSelector is not null) { foreach (var g in rLookup) { diff --git a/Source/SuperLinq/Join.LoopJoin.cs b/Source/SuperLinq/Join.LoopJoin.cs index 166ec7e8b..9b20b49a8 100644 --- a/Source/SuperLinq/Join.LoopJoin.cs +++ b/Source/SuperLinq/Join.LoopJoin.cs @@ -324,7 +324,7 @@ private static IEnumerable LoopJoin( } } - if (leftResultSelector != null + if (leftResultSelector is not null && !flag) { yield return leftResultSelector(l); diff --git a/Source/SuperLinq/Join.MergeJoin.cs b/Source/SuperLinq/Join.MergeJoin.cs index 0a6921642..7e49c54f3 100644 --- a/Source/SuperLinq/Join.MergeJoin.cs +++ b/Source/SuperLinq/Join.MergeJoin.cs @@ -667,7 +667,7 @@ private static IEnumerable JoinMerge( if (comparison < 0) { - if (leftResultSelector != null) + if (leftResultSelector is not null) { foreach (var e in l) yield return leftResultSelector(e); @@ -677,7 +677,7 @@ private static IEnumerable JoinMerge( } else if (comparison > 0) { - if (rightResultSelector != null) + if (rightResultSelector is not null) { foreach (var e in r) yield return rightResultSelector(e); @@ -698,7 +698,7 @@ private static IEnumerable JoinMerge( } } - if (gotLeft && leftResultSelector != null) + if (gotLeft && leftResultSelector is not null) { do { @@ -708,7 +708,7 @@ private static IEnumerable JoinMerge( yield break; } - if (gotRight && rightResultSelector != null) + if (gotRight && rightResultSelector is not null) { do { diff --git a/Source/SuperLinq/Lookup.cs b/Source/SuperLinq/Lookup.cs index fff933302..ba29ec4ef 100644 --- a/Source/SuperLinq/Lookup.cs +++ b/Source/SuperLinq/Lookup.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; @@ -127,7 +127,7 @@ private int InternalGetHashCode(TKey key) => var index = hashCode % _groupings.Length; var g = new Grouping(key, hashCode) { - _hashNext = _groupings[index] + _hashNext = _groupings[index], }; _groupings[index] = g; if (_lastGrouping is null) diff --git a/Source/SuperLinq/Memoize.cs b/Source/SuperLinq/Memoize.cs index c829bc90b..9fb12ad81 100644 --- a/Source/SuperLinq/Memoize.cs +++ b/Source/SuperLinq/Memoize.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Runtime.ExceptionServices; @@ -159,7 +159,7 @@ private IEnumerator GetEnumeratorImpl() _exception.Throw(); } - if (_enumerator == null) + if (_enumerator is null) break; var moved = false; @@ -229,7 +229,7 @@ private sealed record CmbHelper(State State, T[]? Buffer = null, ExceptionDispat private ICollection? _source = source; - private volatile CmbHelper _state = new(State.Uninitialized, null); + private volatile CmbHelper _state = new(State.Uninitialized, Buffer: null); public int Count { @@ -383,7 +383,7 @@ private ICollection Source { get { - if (_source == null) + if (_source is null) ThrowHelper.ThrowObjectDisposedException>(); return _source; } @@ -391,7 +391,7 @@ private ICollection Source public void Reset() { - if (_source == null) + if (_source is null) ThrowHelper.ThrowObjectDisposedException>(); } diff --git a/Source/SuperLinq/OrderBy.cs b/Source/SuperLinq/OrderBy.cs index 5690d62a8..4161a19e0 100644 --- a/Source/SuperLinq/OrderBy.cs +++ b/Source/SuperLinq/OrderBy.cs @@ -34,7 +34,7 @@ public static partial class SuperEnumerable /// public static IOrderedEnumerable OrderBy(this IEnumerable source, Func keySelector, OrderByDirection direction) { - return OrderBy(source, keySelector, null, direction); + return OrderBy(source, keySelector, comparer: null, direction); } /// @@ -111,7 +111,7 @@ public static IOrderedEnumerable OrderBy(this IEnumerable source, /// public static IOrderedEnumerable ThenBy(this IOrderedEnumerable source, Func keySelector, OrderByDirection direction) { - return ThenBy(source, keySelector, null, direction); + return ThenBy(source, keySelector, comparer: null, direction); } /// diff --git a/Source/SuperLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt b/Source/SuperLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt index 354235808..32592580f 100644 --- a/Source/SuperLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt +++ b/Source/SuperLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt @@ -147,4 +147,9 @@ static SuperLinq.SuperEnumerable.WindowLeft(this System.Collec static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, int size, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, TSource[]! array, int size, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, TSource[]! array, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! +static SuperLinq.ValueTupleComparer.Create(System.Collections.Generic.IComparer? comparer1, System.Collections.Generic.IComparer? comparer2) -> System.Collections.Generic.IComparer<(T1, T2)>! +static SuperLinq.ValueTupleEqualityComparer.Create(System.Collections.Generic.IEqualityComparer? comparer1, System.Collections.Generic.IEqualityComparer? comparer2) -> System.Collections.Generic.IEqualityComparer<(T1, T2)>! +static SuperLinq.ValueTupleEqualityComparer.Create(System.Collections.Generic.IEqualityComparer? comparer1) -> System.Collections.Generic.IEqualityComparer>! SuperLinq.SuperEnumerable.ReadOnlySpanFunc +SuperLinq.ValueTupleComparer +SuperLinq.ValueTupleEqualityComparer diff --git a/Source/SuperLinq/PublicAPI/net7.0/PublicAPI.Unshipped.txt b/Source/SuperLinq/PublicAPI/net7.0/PublicAPI.Unshipped.txt index 354235808..32592580f 100644 --- a/Source/SuperLinq/PublicAPI/net7.0/PublicAPI.Unshipped.txt +++ b/Source/SuperLinq/PublicAPI/net7.0/PublicAPI.Unshipped.txt @@ -147,4 +147,9 @@ static SuperLinq.SuperEnumerable.WindowLeft(this System.Collec static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, int size, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, TSource[]! array, int size, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, TSource[]! array, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! +static SuperLinq.ValueTupleComparer.Create(System.Collections.Generic.IComparer? comparer1, System.Collections.Generic.IComparer? comparer2) -> System.Collections.Generic.IComparer<(T1, T2)>! +static SuperLinq.ValueTupleEqualityComparer.Create(System.Collections.Generic.IEqualityComparer? comparer1, System.Collections.Generic.IEqualityComparer? comparer2) -> System.Collections.Generic.IEqualityComparer<(T1, T2)>! +static SuperLinq.ValueTupleEqualityComparer.Create(System.Collections.Generic.IEqualityComparer? comparer1) -> System.Collections.Generic.IEqualityComparer>! SuperLinq.SuperEnumerable.ReadOnlySpanFunc +SuperLinq.ValueTupleComparer +SuperLinq.ValueTupleEqualityComparer diff --git a/Source/SuperLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/Source/SuperLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt index 354235808..32592580f 100644 --- a/Source/SuperLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/Source/SuperLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -147,4 +147,9 @@ static SuperLinq.SuperEnumerable.WindowLeft(this System.Collec static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, int size, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, TSource[]! array, int size, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, TSource[]! array, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! +static SuperLinq.ValueTupleComparer.Create(System.Collections.Generic.IComparer? comparer1, System.Collections.Generic.IComparer? comparer2) -> System.Collections.Generic.IComparer<(T1, T2)>! +static SuperLinq.ValueTupleEqualityComparer.Create(System.Collections.Generic.IEqualityComparer? comparer1, System.Collections.Generic.IEqualityComparer? comparer2) -> System.Collections.Generic.IEqualityComparer<(T1, T2)>! +static SuperLinq.ValueTupleEqualityComparer.Create(System.Collections.Generic.IEqualityComparer? comparer1) -> System.Collections.Generic.IEqualityComparer>! SuperLinq.SuperEnumerable.ReadOnlySpanFunc +SuperLinq.ValueTupleComparer +SuperLinq.ValueTupleEqualityComparer diff --git a/Source/SuperLinq/PublicAPI/net9.0/PublicAPI.Unshipped.txt b/Source/SuperLinq/PublicAPI/net9.0/PublicAPI.Unshipped.txt index f085ecd88..830de01be 100644 --- a/Source/SuperLinq/PublicAPI/net9.0/PublicAPI.Unshipped.txt +++ b/Source/SuperLinq/PublicAPI/net9.0/PublicAPI.Unshipped.txt @@ -147,4 +147,9 @@ static SuperLinq.SuperEnumerable.WindowLeft(this System.Collec static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, int size, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, TSource[]! array, int size, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, TSource[]! array, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! +static SuperLinq.ValueTupleComparer.Create(System.Collections.Generic.IComparer? comparer1, System.Collections.Generic.IComparer? comparer2) -> System.Collections.Generic.IComparer<(T1, T2)>! +static SuperLinq.ValueTupleEqualityComparer.Create(System.Collections.Generic.IEqualityComparer? comparer1, System.Collections.Generic.IEqualityComparer? comparer2) -> System.Collections.Generic.IEqualityComparer<(T1, T2)>! +static SuperLinq.ValueTupleEqualityComparer.Create(System.Collections.Generic.IEqualityComparer? comparer1) -> System.Collections.Generic.IEqualityComparer>! SuperLinq.SuperEnumerable.ReadOnlySpanFunc +SuperLinq.ValueTupleComparer +SuperLinq.ValueTupleEqualityComparer diff --git a/Source/SuperLinq/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt b/Source/SuperLinq/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt index 354235808..32592580f 100644 --- a/Source/SuperLinq/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt +++ b/Source/SuperLinq/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt @@ -147,4 +147,9 @@ static SuperLinq.SuperEnumerable.WindowLeft(this System.Collec static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, int size, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, TSource[]! array, int size, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! static SuperLinq.SuperEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, TSource[]! array, SuperLinq.SuperEnumerable.ReadOnlySpanFunc! selector) -> System.Collections.Generic.IEnumerable! +static SuperLinq.ValueTupleComparer.Create(System.Collections.Generic.IComparer? comparer1, System.Collections.Generic.IComparer? comparer2) -> System.Collections.Generic.IComparer<(T1, T2)>! +static SuperLinq.ValueTupleEqualityComparer.Create(System.Collections.Generic.IEqualityComparer? comparer1, System.Collections.Generic.IEqualityComparer? comparer2) -> System.Collections.Generic.IEqualityComparer<(T1, T2)>! +static SuperLinq.ValueTupleEqualityComparer.Create(System.Collections.Generic.IEqualityComparer? comparer1) -> System.Collections.Generic.IEqualityComparer>! SuperLinq.SuperEnumerable.ReadOnlySpanFunc +SuperLinq.ValueTupleComparer +SuperLinq.ValueTupleEqualityComparer diff --git a/Source/SuperLinq/Publish.cs b/Source/SuperLinq/Publish.cs index d7e30d04a..7642a0efe 100644 --- a/Source/SuperLinq/Publish.cs +++ b/Source/SuperLinq/Publish.cs @@ -144,7 +144,7 @@ private IEnumerator GetEnumeratorImpl(Queue buffer, int version) { _exception?.Throw(); - if (_enumerator == null) + if (_enumerator is null) break; var moved = false; diff --git a/Source/SuperLinq/Share.cs b/Source/SuperLinq/Share.cs index 694791ce8..f1af74fa4 100644 --- a/Source/SuperLinq/Share.cs +++ b/Source/SuperLinq/Share.cs @@ -118,7 +118,7 @@ private IEnumerator GetEnumeratorImpl() _exception?.Throw(); - if (_enumerator == null) + if (_enumerator is null) break; var moved = false; diff --git a/Source/SuperLinq/Shuffle.cs b/Source/SuperLinq/Shuffle.cs index 0820a793d..9eb29e94f 100644 --- a/Source/SuperLinq/Shuffle.cs +++ b/Source/SuperLinq/Shuffle.cs @@ -58,6 +58,6 @@ public static IEnumerable Shuffle(this IEnumerable source, Random rand) ArgumentNullException.ThrowIfNull(source); ArgumentNullException.ThrowIfNull(rand); - return RandomSubsetImpl(source, rand, null); + return RandomSubsetImpl(source, rand, subsetSize: null); } } diff --git a/Source/SuperLinq/SuperLinq.csproj b/Source/SuperLinq/SuperLinq.csproj index a6029b1dd..5ed9521a5 100644 --- a/Source/SuperLinq/SuperLinq.csproj +++ b/Source/SuperLinq/SuperLinq.csproj @@ -1,186 +1,187 @@ - - - - SuperLinq - SuperLinq - - true - - - - SuperLinq - - SuperLinq Developers - linq;extensions;linqpad-samples - - Apache-2.0 - readme.md - - true - https://github.com/viceroypenguin/SuperLinq - - true - snupkg - - - - - This project enhances LINQ to Objects with the following methods: - - - AggregateRight - - AssertCount - - AtLeast - - AtMost - - Cartesian - - Choose - - CountBetween - - CollectionEqual - - CompareCount - - CountBy - - CountDown - - Consume - - DenseRank - - DenseRankBy - - DistinctBy - - ElementAt (pre-.NET 6.0) - - EndsWith - - EquiZip - - Evaluate - - Exactly - - ExceptBy - - Exclude - - FallbackIfEmpty - - FillBackward - - FillForward - - Flatten - - Fold - - From - - FullGroupJoin - - FullJoin - - Generate - - GetShortestPath - - GetShortestPathCost - - GetShortestPaths - - GroupAdjacent - - Index - - IndexBy - - Insert - - Interleave - - Lag - - Lead - - LeftJoin - - Move - - OrderBy - - OrderedMerge - - Pad - - PadStart - - PartialSort - - PartialSortBy - - Partition - - Permutations - - Pipe - - PreScan - - Random - - RandomDouble - - RandomSubset - - Rank - - RankBy - - Return - - RightJoin - - RunLengthEncode - - ScanBy - - ScanRight - - Segment - - Sequence - - Shuffle - - SkipUntil - - Slice - - SortedMerge - - Split - - StartsWith - - Subsets - - TagFirstLast - - Take (pre-.NET 6.0) - - TakeEvery - - TakeUntil - - ThenBy - - ToArrayByIndex - - ToDataTable - - ToDelimitedString - - ToDictionary - - ToLookup - - Trace - - Transpose - - TraverseBreadthFirst - - TraverseDepthFirst - - TrySingle - - Where - - Window - - WindowLeft - - WindowRight - - ZipLongest - - ZipMap - - ZipShortest - - $([System.Text.RegularExpressions.Regex]::Replace($(Description), `\s+`, ` `).Trim().Replace(` - `, `, `).Replace(`:,`, `:`)) - - - Portions © 2008 Jonathan Skeet. - Portions © 2009 Atif Aziz, Chris Ammerman, Konrad Rudolph. - Portions © 2010 Johannes Rudolph, Leopold Bushkin. - Portions © 2015 Felipe Sateler, “sholland”. - Portions © 2016 Andreas Gullberg Larsen, Leandro F. Vieira (leandromoh). - Portions © 2017 Jonas Nyrup (jnyrup). - Portions © 2022 Turning Code, LLC - Portions © 2022 Amichai Mantinband - Portions © Microsoft. All rights reserved. - - $([System.Text.RegularExpressions.Regex]::Replace($(Copyright), `\s+`, ` `).Trim()) - - - - - - - - - - - - - - - - - - - - - - - - true - Generated - - - - - - - - - - minor - preview.0 - v - - - - - + + + + SuperLinq + SuperLinq + + true + true + + + + SuperLinq + + SuperLinq Developers + linq;extensions;linqpad-samples + + Apache-2.0 + readme.md + + true + https://github.com/viceroypenguin/SuperLinq + + true + snupkg + + + + + This project enhances LINQ to Objects with the following methods: + + - AggregateRight + - AssertCount + - AtLeast + - AtMost + - Cartesian + - Choose + - CountBetween + - CollectionEqual + - CompareCount + - CountBy + - CountDown + - Consume + - DenseRank + - DenseRankBy + - DistinctBy + - ElementAt (pre-.NET 6.0) + - EndsWith + - EquiZip + - Evaluate + - Exactly + - ExceptBy + - Exclude + - FallbackIfEmpty + - FillBackward + - FillForward + - Flatten + - Fold + - From + - FullGroupJoin + - FullJoin + - Generate + - GetShortestPath + - GetShortestPathCost + - GetShortestPaths + - GroupAdjacent + - Index + - IndexBy + - Insert + - Interleave + - Lag + - Lead + - LeftJoin + - Move + - OrderBy + - OrderedMerge + - Pad + - PadStart + - PartialSort + - PartialSortBy + - Partition + - Permutations + - Pipe + - PreScan + - Random + - RandomDouble + - RandomSubset + - Rank + - RankBy + - Return + - RightJoin + - RunLengthEncode + - ScanBy + - ScanRight + - Segment + - Sequence + - Shuffle + - SkipUntil + - Slice + - SortedMerge + - Split + - StartsWith + - Subsets + - TagFirstLast + - Take (pre-.NET 6.0) + - TakeEvery + - TakeUntil + - ThenBy + - ToArrayByIndex + - ToDataTable + - ToDelimitedString + - ToDictionary + - ToLookup + - Trace + - Transpose + - TraverseBreadthFirst + - TraverseDepthFirst + - TrySingle + - Where + - Window + - WindowLeft + - WindowRight + - ZipLongest + - ZipMap + - ZipShortest + + $([System.Text.RegularExpressions.Regex]::Replace($(Description), `\s+`, ` `).Trim().Replace(` - `, `, `).Replace(`:,`, `:`)) + + + Portions © 2008 Jonathan Skeet. + Portions © 2009 Atif Aziz, Chris Ammerman, Konrad Rudolph. + Portions © 2010 Johannes Rudolph, Leopold Bushkin. + Portions © 2015 Felipe Sateler, “sholland”. + Portions © 2016 Andreas Gullberg Larsen, Leandro F. Vieira (leandromoh). + Portions © 2017 Jonas Nyrup (jnyrup). + Portions © 2022 Turning Code, LLC + Portions © 2022 Amichai Mantinband + Portions © Microsoft. All rights reserved. + + $([System.Text.RegularExpressions.Regex]::Replace($(Copyright), `\s+`, ` `).Trim()) + + + + + + + + + + + + + + + + + + + + + + + + true + Generated + + + + + + + + + + minor + preview.0 + v + + + + + diff --git a/Source/SuperLinq/TagFirstLast.cs b/Source/SuperLinq/TagFirstLast.cs index 89f161ab9..2274cb817 100644 --- a/Source/SuperLinq/TagFirstLast.cs +++ b/Source/SuperLinq/TagFirstLast.cs @@ -1,4 +1,4 @@ -namespace SuperLinq; +namespace SuperLinq; public static partial class SuperEnumerable { @@ -86,7 +86,7 @@ static IEnumerable Core(IEnumerable source, Func( + private sealed class TagFirstLastIterator( IList source, Func resultSelector ) : ListIterator diff --git a/Source/SuperLinq/ToDataTable.cs b/Source/SuperLinq/ToDataTable.cs index aafb25401..d71eb8ea9 100644 --- a/Source/SuperLinq/ToDataTable.cs +++ b/Source/SuperLinq/ToDataTable.cs @@ -1,4 +1,4 @@ -using System.Data; +using System.Data; using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; using System.Reflection; @@ -258,7 +258,7 @@ private static MemberInfo[] BuildOrBindSchema(DataTable table, MemberInfo[] memb var member = info.Member; var column = info.Column; - if (column == null) + if (column is null) ThrowHelper.ThrowArgumentException(nameof(table), $"Column named '{member.Name}' is missing."); if (info.Type != column.DataType) diff --git a/Source/SuperLinq/ToLookup.cs b/Source/SuperLinq/ToLookup.cs index 82bea026b..972301bbf 100644 --- a/Source/SuperLinq/ToLookup.cs +++ b/Source/SuperLinq/ToLookup.cs @@ -29,7 +29,7 @@ public static partial class SuperEnumerable public static ILookup ToLookup( this IEnumerable> source) { - return source.ToLookup(null); + return source.ToLookup(comparer: null); } /// @@ -94,7 +94,7 @@ public static ILookup ToLookup( public static ILookup ToLookup( this IEnumerable<(TKey Key, TValue Value)> source) { - return source.ToLookup(null); + return source.ToLookup(comparer: null); } /// diff --git a/Source/SuperLinq/ValueTupleComparer.cs b/Source/SuperLinq/ValueTupleComparer.cs index f0dfe10b9..fda6f72b7 100644 --- a/Source/SuperLinq/ValueTupleComparer.cs +++ b/Source/SuperLinq/ValueTupleComparer.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; namespace SuperLinq; @@ -6,7 +6,7 @@ namespace SuperLinq; /// A utility class to easily compose a custom /// for s. /// -internal static class ValueTupleComparer +public static class ValueTupleComparer { /// /// Creates a custom for a based on custom comparers diff --git a/Source/SuperLinq/ValueTupleEqualityComparer.cs b/Source/SuperLinq/ValueTupleEqualityComparer.cs index 7b2b65bc6..683c31bfc 100644 --- a/Source/SuperLinq/ValueTupleEqualityComparer.cs +++ b/Source/SuperLinq/ValueTupleEqualityComparer.cs @@ -1,10 +1,10 @@ -namespace SuperLinq; +namespace SuperLinq; /// /// A utility class to easily compose a custom for s /// and s. /// -internal static class ValueTupleEqualityComparer +public static class ValueTupleEqualityComparer { /// /// Creates a custom for a based on custom diff --git a/Source/SuperLinq/WindowLeft.cs b/Source/SuperLinq/WindowLeft.cs index c32990c83..2e38bbca6 100644 --- a/Source/SuperLinq/WindowLeft.cs +++ b/Source/SuperLinq/WindowLeft.cs @@ -1,4 +1,4 @@ -namespace SuperLinq; +namespace SuperLinq; public static partial class SuperEnumerable { diff --git a/Tests/SuperLinq.Async.Test/.editorconfig b/Tests/SuperLinq.Async.Test/.editorconfig index 9ab78feb6..385f3533f 100644 --- a/Tests/SuperLinq.Async.Test/.editorconfig +++ b/Tests/SuperLinq.Async.Test/.editorconfig @@ -1,8 +1,7 @@ [*.cs] -dotnet_diagnostic.CA1305.severity = none # CA1305: Specify IFormatProvider dotnet_diagnostic.CA1707.severity = none # CA1707: Identifiers should not contain underscores -dotnet_diagnostic.CA1852.severity = none # CA1852: Type '' can be sealed because it has no subtypes in its containing assembly and is not externally visible +dotnet_diagnostic.CA1861.severity = none # CA1861: Avoid constant arrays as arguments dotnet_diagnostic.CA2201.severity = none # CA2201: Do not raise reserved exception types dotnet_diagnostic.IDE0022.severity = none # IDE0022: Use expression body for methods @@ -16,3 +15,5 @@ dotnet_diagnostic.CS1712.severity = none # CS1712: Type parameter dotnet_diagnostic.xUnit1008.severity = error # xUnit1008: Test data attribute should only be used on a Theory dotnet_diagnostic.xUnit1013.severity = error # xUnit1013: Public method should be marked as test dotnet_diagnostic.xUnit1042.severity = none # xUnit1042: The member referenced by the MemberData attribute returns untyped data rows + +dotnet_diagnostic.MA0046.severity = none diff --git a/Tests/SuperLinq.Async.Test/AggregateByTest.cs b/Tests/SuperLinq.Async.Test/AggregateByTest.cs index fe9ec6742..39ae63e03 100644 --- a/Tests/SuperLinq.Async.Test/AggregateByTest.cs +++ b/Tests/SuperLinq.Async.Test/AggregateByTest.cs @@ -1,9 +1,9 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Test.Async; -public class AggregateByTest +public sealed class AggregateByTest { [Theory] [MemberData(nameof(AggregateBy_TestData))] @@ -63,12 +63,12 @@ await ts.AggregateBy(keySelector, seedSelector, func, comparer) expected: Enumerable.Repeat(5, 1).ToDictionary(x => x, x => 100)); yield return WrapArgs( - source: new string[] { "Bob", "bob", "tim", "Bob", "Tim" }, + source: ["Bob", "bob", "tim", "Bob", "Tim"], keySelector: x => x, seedSelector: x => string.Empty, func: (x, y) => x + y, - null, - expected: new Dictionary + comparer: null, + expected: new Dictionary(StringComparer.Ordinal) { { "Bob", "BobBob" }, { "bob", "bob" }, @@ -77,15 +77,15 @@ await ts.AggregateBy(keySelector, seedSelector, func, comparer) }); yield return WrapArgs( - source: new string[] { "Bob", "bob", "tim", "Bob", "Tim" }, + source: ["Bob", "bob", "tim", "Bob", "Tim"], keySelector: x => x, seedSelector: x => string.Empty, func: (x, y) => x + y, StringComparer.OrdinalIgnoreCase, - expected: new Dictionary + expected: new Dictionary(StringComparer.Ordinal) { { "Bob", "BobbobBob" }, - { "tim", "timTim" } + { "tim", "timTim" }, }); yield return WrapArgs( @@ -98,7 +98,7 @@ await ts.AggregateBy(keySelector, seedSelector, func, comparer) { { 20, "I am 20 and my name is Tom" }, { 30, "I am 30 and my name is Dick" }, - { 40, "I am 40 and my name is Harry" } + { 40, "I am 40 and my name is Harry" }, }); yield return WrapArgs( @@ -110,7 +110,7 @@ await ts.AggregateBy(keySelector, seedSelector, func, comparer) expected: new Dictionary { { 20, "I am 20 and my name is maybe Tom maybe Dick" }, - { 40, "I am 40 and my name is maybe Harry" } + { 40, "I am 40 and my name is maybe Harry" }, }); yield return WrapArgs( @@ -119,7 +119,8 @@ await ts.AggregateBy(keySelector, seedSelector, func, comparer) seedSelector: x => 0, func: (x, y) => x + y.Age, comparer: null, - expected: new string[] { "Bob", "bob", "Harry" }.ToDictionary(x => x, x => 20)); + expected: new string[] { "Bob", "bob", "Harry" } + .ToDictionary(x => x, x => 20, StringComparer.Ordinal)); yield return WrapArgs( source: new (string Name, int Age)[] { ("Bob", 20), ("bob", 30), ("Harry", 40) }, @@ -127,10 +128,10 @@ await ts.AggregateBy(keySelector, seedSelector, func, comparer) seedSelector: x => 0, func: (x, y) => x + y.Age, comparer: StringComparer.OrdinalIgnoreCase, - expected: new Dictionary + expected: new Dictionary(StringComparer.Ordinal) { { "Bob", 50 }, - { "Harry", 40 } + { "Harry", 40 }, }); static object?[] WrapArgs(IEnumerable source, Func keySelector, Func seedSelector, Func func, IEqualityComparer? comparer, IEnumerable> expected) diff --git a/Tests/SuperLinq.Async.Test/AggregateRightTest.cs b/Tests/SuperLinq.Async.Test/AggregateRightTest.cs index 69364ab8f..f7ac7abbd 100644 --- a/Tests/SuperLinq.Async.Test/AggregateRightTest.cs +++ b/Tests/SuperLinq.Async.Test/AggregateRightTest.cs @@ -1,6 +1,8 @@ -namespace Test.Async; +using System.Globalization; -public class AggregateRightTest +namespace Test.Async; + +public sealed class AggregateRightTest { // Overload 1 Test @@ -23,8 +25,8 @@ public async Task AggregateRightFuncIsNotInvokedOnSingleElementSequence() [Fact] public async Task AggregateRight() { - await using var enumerable = AsyncEnumerable.Range(1, 5).Select(x => x.ToString()).AsTestingSequence(); - var result = await enumerable.AggregateRight((a, b) => string.Format("({0}+{1})", a, b)); + await using var enumerable = AsyncEnumerable.Range(1, 5).Select(x => x.ToString(CultureInfo.InvariantCulture)).AsTestingSequence(); + var result = await enumerable.AggregateRight((a, b) => FormattableString.Invariant($"({a}+{b})")); Assert.Equal("(1+(2+(3+(4+5))))", result); } @@ -53,7 +55,7 @@ public async Task AggregateRightSeed() { await using var enumerable = AsyncEnumerable.Range(1, 4).AsTestingSequence(); var result = await enumerable - .AggregateRight("5", (a, b) => string.Format("({0}+{1})", a, b)); + .AggregateRight("5", (a, b) => FormattableString.Invariant($"({a}+{b})")); Assert.Equal("(1+(2+(3+(4+5))))", result); } @@ -75,7 +77,7 @@ public async Task AggregateRightResultor() { await using var enumerable = AsyncEnumerable.Range(1, 4).AsTestingSequence(); var result = await enumerable - .AggregateRight("5", (a, b) => string.Format("({0}+{1})", a, b), a => a.Length); + .AggregateRight("5", (a, b) => FormattableString.Invariant($"({a}+{b})"), a => a.Length); Assert.Equal("(1+(2+(3+(4+5))))".Length, result); } diff --git a/Tests/SuperLinq.Async.Test/AmbTest.cs b/Tests/SuperLinq.Async.Test/AmbTest.cs index 4576f7e1d..a0cba12dd 100644 --- a/Tests/SuperLinq.Async.Test/AmbTest.cs +++ b/Tests/SuperLinq.Async.Test/AmbTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class AmbTest +public sealed class AmbTest { [Fact] public void AmbIsLazy() diff --git a/Tests/SuperLinq.Async.Test/AssertCountTest.cs b/Tests/SuperLinq.Async.Test/AssertCountTest.cs index 1687061ba..d111f7dfe 100644 --- a/Tests/SuperLinq.Async.Test/AssertCountTest.cs +++ b/Tests/SuperLinq.Async.Test/AssertCountTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class AssertCountTest +public sealed class AssertCountTest { [Fact] public void AssertCountIsLazy() diff --git a/Tests/SuperLinq.Async.Test/AtLeastTest.cs b/Tests/SuperLinq.Async.Test/AtLeastTest.cs index b0e96e184..f5b121f0e 100644 --- a/Tests/SuperLinq.Async.Test/AtLeastTest.cs +++ b/Tests/SuperLinq.Async.Test/AtLeastTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class AtLeastTest +public sealed class AtLeastTest { [Fact] public async Task AtLeastWithNegativeCount() diff --git a/Tests/SuperLinq.Async.Test/AtMostTest.cs b/Tests/SuperLinq.Async.Test/AtMostTest.cs index 644427fa2..99ac0b2d6 100644 --- a/Tests/SuperLinq.Async.Test/AtMostTest.cs +++ b/Tests/SuperLinq.Async.Test/AtMostTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class AtMostTest +public sealed class AtMostTest { [Fact] public async Task AtMostWithNegativeCount() diff --git a/Tests/SuperLinq.Async.Test/BatchTest.cs b/Tests/SuperLinq.Async.Test/BatchTest.cs index 59e4d3f82..fb0105dc4 100644 --- a/Tests/SuperLinq.Async.Test/BatchTest.cs +++ b/Tests/SuperLinq.Async.Test/BatchTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class BatchTest +public sealed class BatchTest { [Fact] public void BatchIsLazy() diff --git a/Tests/SuperLinq.Async.Test/BindByIndexTest.cs b/Tests/SuperLinq.Async.Test/BindByIndexTest.cs index 676962c75..abb04ee22 100644 --- a/Tests/SuperLinq.Async.Test/BindByIndexTest.cs +++ b/Tests/SuperLinq.Async.Test/BindByIndexTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class BindByIndexTest +public sealed class BindByIndexTest { [Fact] public void BindByIndexIsLazy() diff --git a/Tests/SuperLinq.Async.Test/BreakingSequence.cs b/Tests/SuperLinq.Async.Test/BreakingSequence.cs index ed2f2ca25..2ba4c8d9d 100644 --- a/Tests/SuperLinq.Async.Test/BreakingSequence.cs +++ b/Tests/SuperLinq.Async.Test/BreakingSequence.cs @@ -1,10 +1,10 @@ -namespace Test.Async; +namespace Test.Async; /// -/// Enumerable sequence which throws InvalidOperationException as soon as its -/// enumerator is requested. Used to check lazy evaluation. +/// Enumerable sequence which throws InvalidOperationException as soon as its enumerator is requested. Used to check +/// lazy evaluation. /// -internal class AsyncBreakingSequence : IAsyncEnumerable +internal sealed class AsyncBreakingSequence : IAsyncEnumerable { public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) => throw new TestException(); diff --git a/Tests/SuperLinq.Async.Test/BufferTest.cs b/Tests/SuperLinq.Async.Test/BufferTest.cs index 790402b35..5d7b80931 100644 --- a/Tests/SuperLinq.Async.Test/BufferTest.cs +++ b/Tests/SuperLinq.Async.Test/BufferTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class BufferTest +public sealed class BufferTest { [Fact] public void BufferIsLazy() diff --git a/Tests/SuperLinq.Async.Test/CaseTest.cs b/Tests/SuperLinq.Async.Test/CaseTest.cs index 0a5cea246..3bec9086e 100644 --- a/Tests/SuperLinq.Async.Test/CaseTest.cs +++ b/Tests/SuperLinq.Async.Test/CaseTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class CaseTest +public sealed class CaseTest { [Fact] public void CaseIsLazy() diff --git a/Tests/SuperLinq.Async.Test/CatchTest.cs b/Tests/SuperLinq.Async.Test/CatchTest.cs index 3cbf8338b..7f73579f6 100644 --- a/Tests/SuperLinq.Async.Test/CatchTest.cs +++ b/Tests/SuperLinq.Async.Test/CatchTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class CatchTest +public sealed class CatchTest { [Fact] public void CatchIsLazy() diff --git a/Tests/SuperLinq.Async.Test/ChooseTest.cs b/Tests/SuperLinq.Async.Test/ChooseTest.cs index 2725faa13..3c44a6150 100644 --- a/Tests/SuperLinq.Async.Test/ChooseTest.cs +++ b/Tests/SuperLinq.Async.Test/ChooseTest.cs @@ -2,7 +2,7 @@ namespace Test.Async; -public class ChooseTest +public sealed class ChooseTest { [Fact] public void IsLazy() diff --git a/Tests/SuperLinq.Async.Test/CollectionEqualTest.cs b/Tests/SuperLinq.Async.Test/CollectionEqualTest.cs index 7347eacbf..1131deab2 100644 --- a/Tests/SuperLinq.Async.Test/CollectionEqualTest.cs +++ b/Tests/SuperLinq.Async.Test/CollectionEqualTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class CollectionEqualTest +public sealed class CollectionEqualTest { [Fact] public async Task CollectionEqualIntSequenceInOrder() diff --git a/Tests/SuperLinq.Async.Test/CompareCountTest.cs b/Tests/SuperLinq.Async.Test/CompareCountTest.cs index e38b553e8..4cdc2f4b2 100644 --- a/Tests/SuperLinq.Async.Test/CompareCountTest.cs +++ b/Tests/SuperLinq.Async.Test/CompareCountTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class CompareCountTest +public sealed class CompareCountTest { [Theory] [InlineData(0, 0, 0)] diff --git a/Tests/SuperLinq.Async.Test/ConcurrentMergeTest.cs b/Tests/SuperLinq.Async.Test/ConcurrentMergeTest.cs index d83682c41..354690dfa 100644 --- a/Tests/SuperLinq.Async.Test/ConcurrentMergeTest.cs +++ b/Tests/SuperLinq.Async.Test/ConcurrentMergeTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ConcurrentMergeTest +public sealed class ConcurrentMergeTest { [Fact] public void ConcurrentMergeIsLazy() diff --git a/Tests/SuperLinq.Async.Test/ConsumeTest.cs b/Tests/SuperLinq.Async.Test/ConsumeTest.cs index 44e3ef268..5731124eb 100644 --- a/Tests/SuperLinq.Async.Test/ConsumeTest.cs +++ b/Tests/SuperLinq.Async.Test/ConsumeTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ConsumeTest +public sealed class ConsumeTest { [Fact] public async Task ConsumeReallyConsumes() diff --git a/Tests/SuperLinq.Async.Test/CopyToTest.cs b/Tests/SuperLinq.Async.Test/CopyToTest.cs index 6dc5e7820..d24a1f101 100644 --- a/Tests/SuperLinq.Async.Test/CopyToTest.cs +++ b/Tests/SuperLinq.Async.Test/CopyToTest.cs @@ -3,7 +3,7 @@ namespace Test.Async; -public class CopyToTest +public sealed class CopyToTest { [Fact] public async Task NullArgumentTest() diff --git a/Tests/SuperLinq.Async.Test/CountBetweenTest.cs b/Tests/SuperLinq.Async.Test/CountBetweenTest.cs index 5fbcfcae5..37754292e 100644 --- a/Tests/SuperLinq.Async.Test/CountBetweenTest.cs +++ b/Tests/SuperLinq.Async.Test/CountBetweenTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class CountBetweenTest +public sealed class CountBetweenTest { [Fact] public Task CountBetweenWithNegativeMin() diff --git a/Tests/SuperLinq.Async.Test/CountByTest.cs b/Tests/SuperLinq.Async.Test/CountByTest.cs index 7073528ee..bedcbec98 100644 --- a/Tests/SuperLinq.Async.Test/CountByTest.cs +++ b/Tests/SuperLinq.Async.Test/CountByTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class CountByTest +public sealed class CountByTest { [Fact] public async Task CountBySimpleTest() diff --git a/Tests/SuperLinq.Async.Test/CountDownTest.cs b/Tests/SuperLinq.Async.Test/CountDownTest.cs index 60f543b28..45f0a7e3a 100644 --- a/Tests/SuperLinq.Async.Test/CountDownTest.cs +++ b/Tests/SuperLinq.Async.Test/CountDownTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class CountDownTest +public sealed class CountDownTest { [Fact] public void IsLazy() diff --git a/Tests/SuperLinq.Async.Test/DeferTest.cs b/Tests/SuperLinq.Async.Test/DeferTest.cs index 1eb210d6c..cda9bf5b4 100644 --- a/Tests/SuperLinq.Async.Test/DeferTest.cs +++ b/Tests/SuperLinq.Async.Test/DeferTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class DeferTest +public sealed class DeferTest { [Fact] public void DeferIsLazy() diff --git a/Tests/SuperLinq.Async.Test/DensePartialSortByTest.cs b/Tests/SuperLinq.Async.Test/DensePartialSortByTest.cs index 486d6ecdb..7a5165dfe 100644 --- a/Tests/SuperLinq.Async.Test/DensePartialSortByTest.cs +++ b/Tests/SuperLinq.Async.Test/DensePartialSortByTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class DensePartialSortByTests +public sealed class DensePartialSortByTests { [Fact] public void DensePartialSortByIsLazy() diff --git a/Tests/SuperLinq.Async.Test/DensePartialSortTest.cs b/Tests/SuperLinq.Async.Test/DensePartialSortTest.cs index c0a104281..85f5d78a4 100644 --- a/Tests/SuperLinq.Async.Test/DensePartialSortTest.cs +++ b/Tests/SuperLinq.Async.Test/DensePartialSortTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class DensePartialSortTests +public sealed class DensePartialSortTests { [Fact] public void DensePartialSortIsLazy() diff --git a/Tests/SuperLinq.Async.Test/DenseRankTest.cs b/Tests/SuperLinq.Async.Test/DenseRankTest.cs index b930e9696..679330c14 100644 --- a/Tests/SuperLinq.Async.Test/DenseRankTest.cs +++ b/Tests/SuperLinq.Async.Test/DenseRankTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class DenseRankTests +public sealed class DenseRankTests { /// /// Verify that DenseRank uses deferred execution diff --git a/Tests/SuperLinq.Async.Test/DistinctByTest.cs b/Tests/SuperLinq.Async.Test/DistinctByTest.cs index fae6cb1e1..b35f3cedf 100644 --- a/Tests/SuperLinq.Async.Test/DistinctByTest.cs +++ b/Tests/SuperLinq.Async.Test/DistinctByTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class DistinctByTest +public sealed class DistinctByTest { [Fact] public async Task DistinctBy() diff --git a/Tests/SuperLinq.Async.Test/DistinctUntilChangedTest.cs b/Tests/SuperLinq.Async.Test/DistinctUntilChangedTest.cs index 9b6ff5acf..8013578e6 100644 --- a/Tests/SuperLinq.Async.Test/DistinctUntilChangedTest.cs +++ b/Tests/SuperLinq.Async.Test/DistinctUntilChangedTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class DistinctUntilChangedTest +public sealed class DistinctUntilChangedTest { [Fact] public void DistinctUntilChangedIsLazy() diff --git a/Tests/SuperLinq.Async.Test/DoTest.cs b/Tests/SuperLinq.Async.Test/DoTest.cs index 93fd27346..9cb77f8c9 100644 --- a/Tests/SuperLinq.Async.Test/DoTest.cs +++ b/Tests/SuperLinq.Async.Test/DoTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class DoTest +public sealed class DoTest { [Fact] public void DoOverloadsAreLazy() diff --git a/Tests/SuperLinq.Async.Test/DoWhileTest.cs b/Tests/SuperLinq.Async.Test/DoWhileTest.cs index ced0d3db7..b3129c00a 100644 --- a/Tests/SuperLinq.Async.Test/DoWhileTest.cs +++ b/Tests/SuperLinq.Async.Test/DoWhileTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class DoWhileTest +public sealed class DoWhileTest { [Fact] public void DoWhileIsLazy() diff --git a/Tests/SuperLinq.Async.Test/DuplicatesTest.cs b/Tests/SuperLinq.Async.Test/DuplicatesTest.cs index c1b9d2f02..39f0b6197 100644 --- a/Tests/SuperLinq.Async.Test/DuplicatesTest.cs +++ b/Tests/SuperLinq.Async.Test/DuplicatesTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class DuplicatesTest +public sealed class DuplicatesTest { [Fact] public void DuplicatesIsLazy() diff --git a/Tests/SuperLinq.Async.Test/ElementAtTest.cs b/Tests/SuperLinq.Async.Test/ElementAtTest.cs index f404cafc5..f53c67529 100644 --- a/Tests/SuperLinq.Async.Test/ElementAtTest.cs +++ b/Tests/SuperLinq.Async.Test/ElementAtTest.cs @@ -3,7 +3,7 @@ namespace Test.Async; -public class ElementAtTest +public sealed class ElementAtTest { [Fact] public async Task FromStartIndexInt() diff --git a/Tests/SuperLinq.Async.Test/EndsWithTest.cs b/Tests/SuperLinq.Async.Test/EndsWithTest.cs index 503462c14..2f16686a8 100644 --- a/Tests/SuperLinq.Async.Test/EndsWithTest.cs +++ b/Tests/SuperLinq.Async.Test/EndsWithTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class EndsWithTest +public sealed class EndsWithTest { [Theory] [InlineData(new[] { 1, 2, 3 }, new[] { 2, 3 }, true)] diff --git a/Tests/SuperLinq.Async.Test/EquiZipTest.cs b/Tests/SuperLinq.Async.Test/EquiZipTest.cs index c3724c44b..84979d8d1 100644 --- a/Tests/SuperLinq.Async.Test/EquiZipTest.cs +++ b/Tests/SuperLinq.Async.Test/EquiZipTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class EquiZipTest +public sealed class EquiZipTest { [Fact] public void EquiZipIsLazy() diff --git a/Tests/SuperLinq.Async.Test/ExactlyTest.cs b/Tests/SuperLinq.Async.Test/ExactlyTest.cs index 4e55c3784..60a847229 100644 --- a/Tests/SuperLinq.Async.Test/ExactlyTest.cs +++ b/Tests/SuperLinq.Async.Test/ExactlyTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ExactlyTest +public sealed class ExactlyTest { [Fact] public async Task ExactlyWithNegativeCount() diff --git a/Tests/SuperLinq.Async.Test/ExceptByTest.cs b/Tests/SuperLinq.Async.Test/ExceptByTest.cs index 39202d938..9c4fb7d3e 100644 --- a/Tests/SuperLinq.Async.Test/ExceptByTest.cs +++ b/Tests/SuperLinq.Async.Test/ExceptByTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ExceptByTest +public sealed class ExceptByTest { [Fact] public async Task SimpleExceptBy() diff --git a/Tests/SuperLinq.Async.Test/FallbackIfEmptyTest.cs b/Tests/SuperLinq.Async.Test/FallbackIfEmptyTest.cs index 87dab78db..a3a59d403 100644 --- a/Tests/SuperLinq.Async.Test/FallbackIfEmptyTest.cs +++ b/Tests/SuperLinq.Async.Test/FallbackIfEmptyTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class FallbackIfEmptyTest +public sealed class FallbackIfEmptyTest { [Fact] public async Task FallbackIfEmptyWithEmptySequence() diff --git a/Tests/SuperLinq.Async.Test/FillBackwardTest.cs b/Tests/SuperLinq.Async.Test/FillBackwardTest.cs index 885a36a76..ca89eee43 100644 --- a/Tests/SuperLinq.Async.Test/FillBackwardTest.cs +++ b/Tests/SuperLinq.Async.Test/FillBackwardTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class FillBackwardTest +public sealed class FillBackwardTest { [Fact] public void FillBackwardIsLazy() diff --git a/Tests/SuperLinq.Async.Test/FillForwardTest.cs b/Tests/SuperLinq.Async.Test/FillForwardTest.cs index a398695ab..1446a1a4f 100644 --- a/Tests/SuperLinq.Async.Test/FillForwardTest.cs +++ b/Tests/SuperLinq.Async.Test/FillForwardTest.cs @@ -1,8 +1,8 @@ -using System.Text.RegularExpressions; +using System.Globalization; namespace Test.Async; -public class FillForwardTest +public sealed class FillForwardTest { [Fact] public void FillForwardIsLazy() @@ -39,13 +39,13 @@ Africa Egypt Cairo 789 from line in Table.Split('\n') select line.Trim() into line where !string.IsNullOrEmpty(line) - let x = Regex.Split(line, "\x20+") + let x = line.Split(' ', StringSplitOptions.RemoveEmptyEntries) select new { Continent = x[0], Country = x[1], City = x[2], - Value = int.Parse(x[3]), + Value = int.Parse(x[3], CultureInfo.InvariantCulture), }).AsTestingSequence(); await data diff --git a/Tests/SuperLinq.Async.Test/FinallyTest.cs b/Tests/SuperLinq.Async.Test/FinallyTest.cs index 9b0f6ce4e..1881f1122 100644 --- a/Tests/SuperLinq.Async.Test/FinallyTest.cs +++ b/Tests/SuperLinq.Async.Test/FinallyTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class FinallyTest +public sealed class FinallyTest { [Fact] public void FinallyIsLazy() diff --git a/Tests/SuperLinq.Async.Test/FindIndexTest.cs b/Tests/SuperLinq.Async.Test/FindIndexTest.cs index 63235e11b..26ad9c7f7 100644 --- a/Tests/SuperLinq.Async.Test/FindIndexTest.cs +++ b/Tests/SuperLinq.Async.Test/FindIndexTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class FindIndexTest +public sealed class FindIndexTest { [Fact] public async Task FindIndexWithNegativeCount() diff --git a/Tests/SuperLinq.Async.Test/FindLastIndexTest.cs b/Tests/SuperLinq.Async.Test/FindLastIndexTest.cs index 86057fc6a..48a441652 100644 --- a/Tests/SuperLinq.Async.Test/FindLastIndexTest.cs +++ b/Tests/SuperLinq.Async.Test/FindLastIndexTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class FindLastIndexTest +public sealed class FindLastIndexTest { [Fact] public async Task FindLastIndexWithNegativeCount() diff --git a/Tests/SuperLinq.Async.Test/FoldTest.cs b/Tests/SuperLinq.Async.Test/FoldTest.cs index 7dfe695eb..40038930e 100644 --- a/Tests/SuperLinq.Async.Test/FoldTest.cs +++ b/Tests/SuperLinq.Async.Test/FoldTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class FoldTest +public sealed class FoldTest { [Fact] public async Task FoldWithTooFewItems() diff --git a/Tests/SuperLinq.Async.Test/ForEachTest.cs b/Tests/SuperLinq.Async.Test/ForEachTest.cs index 25ef42033..019457345 100644 --- a/Tests/SuperLinq.Async.Test/ForEachTest.cs +++ b/Tests/SuperLinq.Async.Test/ForEachTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ForEachTest +public sealed class ForEachTest { [Fact] public async Task ForEachWithSequence() diff --git a/Tests/SuperLinq.Async.Test/FromTest.cs b/Tests/SuperLinq.Async.Test/FromTest.cs index 02bc198c8..d62b509a5 100644 --- a/Tests/SuperLinq.Async.Test/FromTest.cs +++ b/Tests/SuperLinq.Async.Test/FromTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class FromTest +public sealed class FromTest { [Fact] public void TestFromIsLazy() diff --git a/Tests/SuperLinq.Async.Test/FullOuterJoinTest.cs b/Tests/SuperLinq.Async.Test/FullOuterJoinTest.cs index 7b2ea9b4e..1b7105d39 100644 --- a/Tests/SuperLinq.Async.Test/FullOuterJoinTest.cs +++ b/Tests/SuperLinq.Async.Test/FullOuterJoinTest.cs @@ -4,7 +4,7 @@ namespace Test.Async; public enum JoinOperation { None, Loop, Hash, Merge, } -public class FullOuterJoinTest +public sealed class FullOuterJoinTest { private static IAsyncEnumerable<((string, string) Left, (string, string) Right)> ExecuteJoin( IAsyncEnumerable<(string, string)> left, diff --git a/Tests/SuperLinq.Async.Test/GenerateTest.cs b/Tests/SuperLinq.Async.Test/GenerateTest.cs index d2d862c9f..715f3741e 100644 --- a/Tests/SuperLinq.Async.Test/GenerateTest.cs +++ b/Tests/SuperLinq.Async.Test/GenerateTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class GenerateTest +public sealed class GenerateTest { [Fact] public Task GenerateTerminatesWhenCheckReturnsFalse() diff --git a/Tests/SuperLinq.Async.Test/GetShortestPathTest.cs b/Tests/SuperLinq.Async.Test/GetShortestPathTest.cs index 9f572b5af..e73029882 100644 --- a/Tests/SuperLinq.Async.Test/GetShortestPathTest.cs +++ b/Tests/SuperLinq.Async.Test/GetShortestPathTest.cs @@ -42,7 +42,7 @@ private static void VerifySequences(this List> list) s.Dispose(); } - public class Dijkstra + public sealed class Dijkstra { public static IEnumerable GetStringIntCostData { get; } = [ @@ -347,7 +347,7 @@ public async Task InvalidMapThrowsException() } } - public class AStar + public sealed class AStar { public static IEnumerable GetStringIntCostData { get; } = [ diff --git a/Tests/SuperLinq.Async.Test/GroupAdjacentTest.cs b/Tests/SuperLinq.Async.Test/GroupAdjacentTest.cs index ad77e0e62..2b3d66096 100644 --- a/Tests/SuperLinq.Async.Test/GroupAdjacentTest.cs +++ b/Tests/SuperLinq.Async.Test/GroupAdjacentTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class GroupAdjacentTest +public sealed class GroupAdjacentTest { [Fact] public void GroupAdjacentIsLazy() diff --git a/Tests/SuperLinq.Async.Test/HasDuplicatesTest.cs b/Tests/SuperLinq.Async.Test/HasDuplicatesTest.cs index f84e93407..a0ba51878 100644 --- a/Tests/SuperLinq.Async.Test/HasDuplicatesTest.cs +++ b/Tests/SuperLinq.Async.Test/HasDuplicatesTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class HasDuplicatesTest +public sealed class HasDuplicatesTest { [Fact] public async Task DuplicatesDoesNotEnumerateUnnecessarily() diff --git a/Tests/SuperLinq.Async.Test/IfTest.cs b/Tests/SuperLinq.Async.Test/IfTest.cs index deb992af8..d116264a8 100644 --- a/Tests/SuperLinq.Async.Test/IfTest.cs +++ b/Tests/SuperLinq.Async.Test/IfTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class IfTest +public sealed class IfTest { [Fact] public void IfIsLazy() diff --git a/Tests/SuperLinq.Async.Test/IndexByTest.cs b/Tests/SuperLinq.Async.Test/IndexByTest.cs index f8da46757..7b203b826 100644 --- a/Tests/SuperLinq.Async.Test/IndexByTest.cs +++ b/Tests/SuperLinq.Async.Test/IndexByTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class IndexByTest +public sealed class IndexByTest { [Fact] public async Task IndexBySimpleTest() diff --git a/Tests/SuperLinq.Async.Test/IndexOfTest.cs b/Tests/SuperLinq.Async.Test/IndexOfTest.cs index 38982abd6..f54eed7e4 100644 --- a/Tests/SuperLinq.Async.Test/IndexOfTest.cs +++ b/Tests/SuperLinq.Async.Test/IndexOfTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class IndexOfTest +public sealed class IndexOfTest { [Fact] public async Task IndexOfWithNegativeCount() diff --git a/Tests/SuperLinq.Async.Test/IndexTest.cs b/Tests/SuperLinq.Async.Test/IndexTest.cs index 04b831764..db44ed302 100644 --- a/Tests/SuperLinq.Async.Test/IndexTest.cs +++ b/Tests/SuperLinq.Async.Test/IndexTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class IndexTest +public sealed class IndexTest { [Fact] public void IndexIsLazy() diff --git a/Tests/SuperLinq.Async.Test/InnerJoinTest.cs b/Tests/SuperLinq.Async.Test/InnerJoinTest.cs index 3ff9f3c21..f91ea66b7 100644 --- a/Tests/SuperLinq.Async.Test/InnerJoinTest.cs +++ b/Tests/SuperLinq.Async.Test/InnerJoinTest.cs @@ -2,7 +2,7 @@ namespace Test.Async; -public class InnerJoinTest +public sealed class InnerJoinTest { private static IAsyncEnumerable<((string, string) Left, (string, string) Right)> ExecuteJoin( IAsyncEnumerable<(string, string)> left, diff --git a/Tests/SuperLinq.Async.Test/InsertTest.cs b/Tests/SuperLinq.Async.Test/InsertTest.cs index 3eaab0a77..f339aa9f6 100644 --- a/Tests/SuperLinq.Async.Test/InsertTest.cs +++ b/Tests/SuperLinq.Async.Test/InsertTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class InsertTest +public sealed class InsertTest { [Fact] public void InsertWithNegativeIndex() diff --git a/Tests/SuperLinq.Async.Test/InterleaveTest.cs b/Tests/SuperLinq.Async.Test/InterleaveTest.cs index 4da91150b..0a7c7e1d9 100644 --- a/Tests/SuperLinq.Async.Test/InterleaveTest.cs +++ b/Tests/SuperLinq.Async.Test/InterleaveTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the Interleave operator /// -public class InterleaveTests +public sealed class InterleaveTests { /// /// Verify that Interleave behaves in a lazy manner diff --git a/Tests/SuperLinq.Async.Test/LagTest.cs b/Tests/SuperLinq.Async.Test/LagTest.cs index 5d588f92d..867bec355 100644 --- a/Tests/SuperLinq.Async.Test/LagTest.cs +++ b/Tests/SuperLinq.Async.Test/LagTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the Lag operator /// -public class LagTests +public sealed class LagTests { /// /// Verify that lag behaves in a lazy manner. diff --git a/Tests/SuperLinq.Async.Test/LastIndexOfTest.cs b/Tests/SuperLinq.Async.Test/LastIndexOfTest.cs index 9135d8ca5..114f0f4f0 100644 --- a/Tests/SuperLinq.Async.Test/LastIndexOfTest.cs +++ b/Tests/SuperLinq.Async.Test/LastIndexOfTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class LastIndexOfTest +public sealed class LastIndexOfTest { [Fact] public async Task LastIndexOfWithNegativeCount() diff --git a/Tests/SuperLinq.Async.Test/LeadTest.cs b/Tests/SuperLinq.Async.Test/LeadTest.cs index 1192d9587..030140ccc 100644 --- a/Tests/SuperLinq.Async.Test/LeadTest.cs +++ b/Tests/SuperLinq.Async.Test/LeadTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the Lead operator. /// -public class LeadTests +public sealed class LeadTests { /// /// Verify that Lead() behaves in a lazy manner. diff --git a/Tests/SuperLinq.Async.Test/LeftOuterJoin.cs b/Tests/SuperLinq.Async.Test/LeftOuterJoin.cs index 31fb2abbb..d0056fda0 100644 --- a/Tests/SuperLinq.Async.Test/LeftOuterJoin.cs +++ b/Tests/SuperLinq.Async.Test/LeftOuterJoin.cs @@ -2,7 +2,7 @@ namespace Test.Async; -public class LeftOuterJoinTest +public sealed class LeftOuterJoinTest { private static IAsyncEnumerable<((string, string) Left, (string, string) Right)> ExecuteJoin( IAsyncEnumerable<(string, string)> left, diff --git a/Tests/SuperLinq.Async.Test/MaxItemsTest.cs b/Tests/SuperLinq.Async.Test/MaxItemsTest.cs index 621310d86..f706651c2 100644 --- a/Tests/SuperLinq.Async.Test/MaxItemsTest.cs +++ b/Tests/SuperLinq.Async.Test/MaxItemsTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class MaxItemsTest +public sealed class MaxItemsTest { [Fact] public void MaxItemsIsLazy() diff --git a/Tests/SuperLinq.Async.Test/MemoizeTest.cs b/Tests/SuperLinq.Async.Test/MemoizeTest.cs index 2a6a7336b..04639f871 100644 --- a/Tests/SuperLinq.Async.Test/MemoizeTest.cs +++ b/Tests/SuperLinq.Async.Test/MemoizeTest.cs @@ -3,7 +3,7 @@ namespace Test.Async; -public class MemoizeTest +public sealed class MemoizeTest { [Fact] public void MemoizeIsLazy() @@ -289,7 +289,7 @@ public async Task MemoizeRethrowsErrorDuringFirstIterationStartToAllIterationsUn Assert.Equal(1, buffer.Count); } - private class FailingEnumerable : IEnumerable + private sealed class FailingEnumerable : IEnumerable { private bool _started; public IEnumerator GetEnumerator() diff --git a/Tests/SuperLinq.Async.Test/MinItemsTest.cs b/Tests/SuperLinq.Async.Test/MinItemsTest.cs index bae622e10..68ee0bb52 100644 --- a/Tests/SuperLinq.Async.Test/MinItemsTest.cs +++ b/Tests/SuperLinq.Async.Test/MinItemsTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class MinItemsTest +public sealed class MinItemsTest { [Fact] public void MinItemsIsLazy() diff --git a/Tests/SuperLinq.Async.Test/NullArgumentTest.cs b/Tests/SuperLinq.Async.Test/NullArgumentTest.cs index 4d7b2e83b..b842f1de1 100644 --- a/Tests/SuperLinq.Async.Test/NullArgumentTest.cs +++ b/Tests/SuperLinq.Async.Test/NullArgumentTest.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; @@ -7,7 +7,7 @@ namespace Test.Async; -public class NullArgumentTest +public sealed class NullArgumentTest { [Theory, MemberData(nameof(GetNotNullInlineDatas))] public void NotNull(Action inlineData) => @@ -39,9 +39,9 @@ public static IEnumerable GetCanBeNullInlineDatas() => } catch (TargetInvocationException tie) { - Assert.False(tie.InnerException != null - && tie.InnerException is ArgumentNullException ane - && ane.ParamName != paramName); + Assert.False( + tie.InnerException is ArgumentNullException ane + && !string.Equals(ane.ParamName, paramName, StringComparison.Ordinal)); } }); @@ -52,7 +52,7 @@ public static IEnumerable GetCanBeNullInlineDatas() => private static IEnumerable GetInlineDatas(bool canBeNull, Func inlineDataFactory) => from m in typeof(AsyncSuperEnumerable).GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly) - where !s_skipMethods.Contains(m.Name) + where !s_skipMethods.Contains(m.Name, StringComparer.Ordinal) from t in CreateInlineDatas(m, canBeNull, inlineDataFactory) select t; @@ -101,7 +101,7 @@ Type InstantiateType(TypeInfo typeParameter) if (constraints.Length == 0) { - return s_joinMethods.Contains(definition.Name) + return s_joinMethods.Contains(definition.Name, StringComparer.Ordinal) ? typeof(string) : typeof(int); } @@ -117,7 +117,7 @@ Type InstantiateType(TypeInfo typeParameter) return typeof(StringComparer); } - throw new NotImplementedException("NullArgumentTest.InstantiateType"); + throw new UnreachableException("NullArgumentTest.InstantiateType"); } } @@ -190,19 +190,19 @@ private static object CreateGenericInterfaceInstance(TypeInfo type) return Activator.CreateInstance(instantiation)!; } - private class Disposable : IDisposable + private sealed class Disposable : IDisposable { public void Dispose() { } } - private class AsyncDisposable : IAsyncDisposable + private sealed class AsyncDisposable : IAsyncDisposable { public ValueTask DisposeAsync() => default; } private static class EmptyEnumerable { - public static readonly IEnumerable Instance = new Enumerable(); + public static IEnumerable Instance { get; } = new Enumerable(); private sealed class Enumerable : IEnumerable { @@ -219,7 +219,7 @@ public void Reset() { } private static class GenericArgs { - private class Enumerator : IEnumerator + private sealed class Enumerator : IEnumerator { public bool MoveNext() => false; public T Current { get; private set; } = default!; @@ -234,7 +234,7 @@ public class Enumerable : IEnumerable IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } - public class OrderedEnumerable : Enumerable, IOrderedEnumerable + public sealed class OrderedEnumerable : Enumerable, IOrderedEnumerable { public IOrderedEnumerable CreateOrderedEnumerable(Func keySelector, IComparer? comparer, bool descending) { @@ -243,19 +243,19 @@ public IOrderedEnumerable CreateOrderedEnumerable(Func keySele } } - private class AsyncEnumerator : IAsyncEnumerator + private sealed class AsyncEnumerator : IAsyncEnumerator { - public ValueTask MoveNextAsync() => new(false); + public ValueTask MoveNextAsync() => new(result: false); public T Current { get; private set; } = default!; public ValueTask DisposeAsync() => default; } public class AsyncEnumerable : IAsyncEnumerable { - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken _) => new AsyncEnumerator(); + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) => new AsyncEnumerator(); } - public class OrderedAsyncEnumerable : AsyncEnumerable, IOrderedAsyncEnumerable + public sealed class OrderedAsyncEnumerable : AsyncEnumerable, IOrderedAsyncEnumerable { public IOrderedAsyncEnumerable CreateOrderedEnumerable(Func keySelector, IComparer? comparer, bool descending) { @@ -276,33 +276,33 @@ public IOrderedAsyncEnumerable CreateOrderedEnumerable(Func : IDictionary + public sealed class Dictionary : IDictionary where TKey : notnull { - public TValue this[TKey key] { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) => throw new NotImplementedException(); - public ICollection Keys => throw new NotImplementedException(); - public ICollection Values => throw new NotImplementedException(); - public int Count => throw new NotImplementedException(); - public bool IsReadOnly => throw new NotImplementedException(); - public void Add(TKey key, TValue value) => throw new NotImplementedException(); - public void Add(KeyValuePair item) => throw new NotImplementedException(); - public void Clear() => throw new NotImplementedException(); - public bool Contains(KeyValuePair item) => throw new NotImplementedException(); - public bool ContainsKey(TKey key) => throw new NotImplementedException(); - public void CopyTo(KeyValuePair[] array, int arrayIndex) => throw new NotImplementedException(); - public IEnumerator> GetEnumerator() => throw new NotImplementedException(); - IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException(); - public bool Remove(TKey key) => throw new NotImplementedException(); - public bool Remove(KeyValuePair item) => throw new NotImplementedException(); + public TValue this[TKey key] { get => throw new NotSupportedException(); set => throw new NotSupportedException(); } + public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) => throw new NotSupportedException(); + public ICollection Keys => throw new NotSupportedException(); + public ICollection Values => throw new NotSupportedException(); + public int Count => throw new NotSupportedException(); + public bool IsReadOnly => throw new NotSupportedException(); + public void Add(TKey key, TValue value) => throw new NotSupportedException(); + public void Add(KeyValuePair item) => throw new NotSupportedException(); + public void Clear() => throw new NotSupportedException(); + public bool Contains(KeyValuePair item) => throw new NotSupportedException(); + public bool ContainsKey(TKey key) => throw new NotSupportedException(); + public void CopyTo(KeyValuePair[] array, int arrayIndex) => throw new NotSupportedException(); + public IEnumerator> GetEnumerator() => throw new NotSupportedException(); + IEnumerator IEnumerable.GetEnumerator() => throw new NotSupportedException(); + public bool Remove(TKey key) => throw new NotSupportedException(); + public bool Remove(KeyValuePair item) => throw new NotSupportedException(); } - public class Comparer : IComparer + public sealed class Comparer : IComparer { public int Compare(T? x, T? y) => -1; } - public class EqualityComparer : IEqualityComparer + public sealed class EqualityComparer : IEqualityComparer { public bool Equals(T? x, T? y) => false; public int GetHashCode(T obj) => 0; diff --git a/Tests/SuperLinq.Async.Test/OnErrorResumeNextTest.cs b/Tests/SuperLinq.Async.Test/OnErrorResumeNextTest.cs index 72b606f95..1296ee2ad 100644 --- a/Tests/SuperLinq.Async.Test/OnErrorResumeNextTest.cs +++ b/Tests/SuperLinq.Async.Test/OnErrorResumeNextTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class OnErrorResumeNextTest +public sealed class OnErrorResumeNextTest { [Fact] public void OnErrorResumeNextIsLazy() diff --git a/Tests/SuperLinq.Async.Test/OrderByTest.cs b/Tests/SuperLinq.Async.Test/OrderByTest.cs index b608d1cad..333efcc4f 100644 --- a/Tests/SuperLinq.Async.Test/OrderByTest.cs +++ b/Tests/SuperLinq.Async.Test/OrderByTest.cs @@ -1,9 +1,11 @@ -namespace Test.Async; +using System.Globalization; + +namespace Test.Async; /// /// Verify the behavior of the OrderBy/ThenBy operators /// -public class OrderByTests +public sealed class OrderByTests { /// /// Verify that OrderBy preserves the selector @@ -32,10 +34,13 @@ public async Task TestOrderBySelectorPreserved() public async Task TestOrderByComparerPreserved() { var sequence = AsyncEnumerable.Range(1, 100); - var sequenceAscending = sequence.Select(x => x.ToString()); + var sequenceAscending = sequence.Select(x => x.ToString(CultureInfo.InvariantCulture)); var sequenceDescending = sequenceAscending.Reverse(); - var comparer = Comparer.Create((a, b) => int.Parse(a).CompareTo(int.Parse(b))); + var comparer = Comparer.Create( + (a, b) => int.Parse(a, CultureInfo.InvariantCulture) + .CompareTo(int.Parse(b, CultureInfo.InvariantCulture)) + ); var resultAsc1 = sequenceAscending.OrderBy(SuperEnumerable.Identity, comparer, OrderByDirection.Descending); var resultAsc2 = sequenceAscending.OrderByDescending(SuperEnumerable.Identity, comparer); @@ -99,7 +104,10 @@ public async Task TestThenByComparerPreserved() new { A = "1", B = "4", }, new { A = "2", B = "1", }); - var comparer = Comparer.Create((a, b) => int.Parse(a).CompareTo(int.Parse(b))); + var comparer = Comparer.Create( + (a, b) => int.Parse(a, CultureInfo.InvariantCulture) + .CompareTo(int.Parse(b, CultureInfo.InvariantCulture)) + ); var resultA1 = sequence .OrderBy(x => x.A, comparer, OrderByDirection.Ascending) diff --git a/Tests/SuperLinq.Async.Test/PadStartTest.cs b/Tests/SuperLinq.Async.Test/PadStartTest.cs index 042b4c37a..70071e566 100644 --- a/Tests/SuperLinq.Async.Test/PadStartTest.cs +++ b/Tests/SuperLinq.Async.Test/PadStartTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class PadStartTest +public sealed class PadStartTest { // PadStart(source, width) @@ -17,7 +17,7 @@ public void PadStartIsLazy() _ = new AsyncBreakingSequence().PadStart(0); } - public class PadStartWithDefaultPadding + public sealed class PadStartWithDefaultPadding { [Theory] [InlineData(new[] { 123, 456, 789 }, 2, new[] { 123, 456, 789 })] @@ -61,7 +61,7 @@ public void PadStartWithPaddingIsLazy() _ = new AsyncBreakingSequence().PadStart(0, -1); } - public class PadStartWithPadding + public sealed class PadStartWithPadding { [Theory] [InlineData(new[] { 123, 456, 789 }, 2, new[] { 123, 456, 789 })] @@ -105,7 +105,7 @@ public void PadStartWithSelectorIsLazy() _ = new AsyncBreakingSequence().PadStart(0, BreakingFunc.Of()); } - public class PadStartWithSelector + public sealed class PadStartWithSelector { [Theory] [InlineData(new[] { 123, 456, 789 }, 2, new[] { 123, 456, 789 })] diff --git a/Tests/SuperLinq.Async.Test/PadTest.cs b/Tests/SuperLinq.Async.Test/PadTest.cs index 5d3a01078..dcf5c023d 100644 --- a/Tests/SuperLinq.Async.Test/PadTest.cs +++ b/Tests/SuperLinq.Async.Test/PadTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class PadTest +public sealed class PadTest { [Fact] public void PadNegativeWidth() @@ -21,7 +21,7 @@ public void PadWithFillerIsLazy() _ = new AsyncBreakingSequence().Pad(0, new object()); } - public class ValueTypeElements + public sealed class ValueTypeElements { [Fact] public async Task PadWideSourceSequence() @@ -63,7 +63,7 @@ public async Task PadNarrowSourceSequenceWithDynamicPadding() } } - public class ReferenceTypeElements + public sealed class ReferenceTypeElements { [Fact] public async Task PadWideSourceSequence() diff --git a/Tests/SuperLinq.Async.Test/PartialSortByTest.cs b/Tests/SuperLinq.Async.Test/PartialSortByTest.cs index 460c4cd47..fe6bd9df1 100644 --- a/Tests/SuperLinq.Async.Test/PartialSortByTest.cs +++ b/Tests/SuperLinq.Async.Test/PartialSortByTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class PartialSortByTests +public sealed class PartialSortByTests { [Fact] public async Task PartialSortBy() diff --git a/Tests/SuperLinq.Async.Test/PartialSortTest.cs b/Tests/SuperLinq.Async.Test/PartialSortTest.cs index 335a44686..4b9866d8c 100644 --- a/Tests/SuperLinq.Async.Test/PartialSortTest.cs +++ b/Tests/SuperLinq.Async.Test/PartialSortTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class PartialSortTests +public sealed class PartialSortTests { [Fact] public async Task PartialSort() diff --git a/Tests/SuperLinq.Async.Test/PartitionTest.cs b/Tests/SuperLinq.Async.Test/PartitionTest.cs index 062bd8cbb..c68a05ba8 100644 --- a/Tests/SuperLinq.Async.Test/PartitionTest.cs +++ b/Tests/SuperLinq.Async.Test/PartitionTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class PartitionTest +public sealed class PartitionTest { [Fact] public async Task Partition() diff --git a/Tests/SuperLinq.Async.Test/PreScanTest.cs b/Tests/SuperLinq.Async.Test/PreScanTest.cs index 32fbfad06..3349f9917 100644 --- a/Tests/SuperLinq.Async.Test/PreScanTest.cs +++ b/Tests/SuperLinq.Async.Test/PreScanTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class PreScanTest +public sealed class PreScanTest { [Fact] public void PreScanIsLazy() diff --git a/Tests/SuperLinq.Async.Test/PublishTest.cs b/Tests/SuperLinq.Async.Test/PublishTest.cs index 6703be02a..ba866d56d 100644 --- a/Tests/SuperLinq.Async.Test/PublishTest.cs +++ b/Tests/SuperLinq.Async.Test/PublishTest.cs @@ -2,7 +2,7 @@ namespace Test.Async; -public class PublishTest +public sealed class PublishTest { [Fact] public void PublishIsLazy() @@ -275,7 +275,7 @@ public async Task PublishRethrowsErrorDuringFirstIterationStartToAllIterationsUn await buffer.AssertSequenceEqual(1); } - private class FailingEnumerable : IAsyncEnumerable + private sealed class FailingEnumerable : IAsyncEnumerable { private bool _started; diff --git a/Tests/SuperLinq.Async.Test/RandomTest.cs b/Tests/SuperLinq.Async.Test/RandomTest.cs index 788fcd69e..f89c7050e 100644 --- a/Tests/SuperLinq.Async.Test/RandomTest.cs +++ b/Tests/SuperLinq.Async.Test/RandomTest.cs @@ -3,7 +3,7 @@ /// /// Tests of the various overloads of .Random() /// -public class RandomTest +public sealed class RandomTest { private const int RandomTrials = 10000; diff --git a/Tests/SuperLinq.Async.Test/RankTest.cs b/Tests/SuperLinq.Async.Test/RankTest.cs index 516c94927..0a44e5372 100644 --- a/Tests/SuperLinq.Async.Test/RankTest.cs +++ b/Tests/SuperLinq.Async.Test/RankTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class RankTests +public sealed class RankTests { /// /// Verify that Rank uses deferred execution @@ -211,7 +211,7 @@ public async Task TestRankByKeySelector() new(Name: "Joe", Age: 31, ExpectedRank: 6), new(Name: "Mel", Age: 28, ExpectedRank: 5), new(Name: "Jim", Age: 74, ExpectedRank: 8), - new(Name: "Jes", Age: 11, ExpectedRank: 1) + new(Name: "Jes", Age: 11, ExpectedRank: 1), }, new Person[] { diff --git a/Tests/SuperLinq.Async.Test/RepeatTest.cs b/Tests/SuperLinq.Async.Test/RepeatTest.cs index 6edef4974..b8fb04666 100644 --- a/Tests/SuperLinq.Async.Test/RepeatTest.cs +++ b/Tests/SuperLinq.Async.Test/RepeatTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class RepeatTest +public sealed class RepeatTest { [Theory] [InlineData(1)] diff --git a/Tests/SuperLinq.Async.Test/ReplaceTest.cs b/Tests/SuperLinq.Async.Test/ReplaceTest.cs index f3bb90aad..56b1833cd 100644 --- a/Tests/SuperLinq.Async.Test/ReplaceTest.cs +++ b/Tests/SuperLinq.Async.Test/ReplaceTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ReplaceTest +public sealed class ReplaceTest { [Fact] public void ReplaceIsLazy() diff --git a/Tests/SuperLinq.Async.Test/RetryTest.cs b/Tests/SuperLinq.Async.Test/RetryTest.cs index 1b159da43..3d2420d22 100644 --- a/Tests/SuperLinq.Async.Test/RetryTest.cs +++ b/Tests/SuperLinq.Async.Test/RetryTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class RetryTest +public sealed class RetryTest { [Fact] public void RetryIsLazy() diff --git a/Tests/SuperLinq.Async.Test/ReturnTest.cs b/Tests/SuperLinq.Async.Test/ReturnTest.cs index 4f21fde3f..f669f418f 100644 --- a/Tests/SuperLinq.Async.Test/ReturnTest.cs +++ b/Tests/SuperLinq.Async.Test/ReturnTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ReturnTest +public sealed class ReturnTest { [Fact] public async Task TestResultingSequenceContainsSingle() diff --git a/Tests/SuperLinq.Async.Test/RightOuterJoin.cs b/Tests/SuperLinq.Async.Test/RightOuterJoin.cs index 3a7a8a92d..ae2ccef4e 100644 --- a/Tests/SuperLinq.Async.Test/RightOuterJoin.cs +++ b/Tests/SuperLinq.Async.Test/RightOuterJoin.cs @@ -2,7 +2,7 @@ namespace Test.Async; -public class RightOuterJoinTest +public sealed class RightOuterJoinTest { private static IAsyncEnumerable<((string, string) Left, (string, string) Right)> ExecuteJoin( IAsyncEnumerable<(string, string)> left, diff --git a/Tests/SuperLinq.Async.Test/RunLengthEncodeTest.cs b/Tests/SuperLinq.Async.Test/RunLengthEncodeTest.cs index 53f4f17f4..a19f841ed 100644 --- a/Tests/SuperLinq.Async.Test/RunLengthEncodeTest.cs +++ b/Tests/SuperLinq.Async.Test/RunLengthEncodeTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the RunLengthEncode() operator /// -public class RunLengthEncodeTests +public sealed class RunLengthEncodeTests { /// /// Verify that the RunLengthEncode() methods behave in a lazy manner. diff --git a/Tests/SuperLinq.Async.Test/ScanByTest.cs b/Tests/SuperLinq.Async.Test/ScanByTest.cs index 8d3f916ce..e67aefb7a 100644 --- a/Tests/SuperLinq.Async.Test/ScanByTest.cs +++ b/Tests/SuperLinq.Async.Test/ScanByTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ScanByTest +public sealed class ScanByTest { [Fact] public void ScanByIsLazy() diff --git a/Tests/SuperLinq.Async.Test/ScanRightTest.cs b/Tests/SuperLinq.Async.Test/ScanRightTest.cs index 63c41b2ab..113162907 100644 --- a/Tests/SuperLinq.Async.Test/ScanRightTest.cs +++ b/Tests/SuperLinq.Async.Test/ScanRightTest.cs @@ -1,6 +1,8 @@ -namespace Test.Async; +using System.Globalization; -public class ScanRightTest +namespace Test.Async; + +public sealed class ScanRightTest { // ScanRight(source, func) @@ -28,8 +30,8 @@ public async Task ScanRight() await using var seq = Enumerable.Range(1, 5).AsTestingSequence(); var result = seq - .Select(x => x.ToString()) - .ScanRight((a, b) => string.Format("({0}+{1})", a, b)); + .Select(x => x.ToString(CultureInfo.InvariantCulture)) + .ScanRight((a, b) => FormattableString.Invariant($"({a}+{b})")); await result.AssertSequenceEqual( "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5"); @@ -70,7 +72,7 @@ public async Task ScanRightSeed() await using var seq = Enumerable.Range(1, 4).AsTestingSequence(); var result = seq - .ScanRight("5", (a, b) => string.Format("({0}+{1})", a, b)); + .ScanRight("5", (a, b) => FormattableString.Invariant($"({a}+{b})")); await result.AssertSequenceEqual( "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5"); diff --git a/Tests/SuperLinq.Async.Test/ScanTest.cs b/Tests/SuperLinq.Async.Test/ScanTest.cs index cf00052ef..5872d368a 100644 --- a/Tests/SuperLinq.Async.Test/ScanTest.cs +++ b/Tests/SuperLinq.Async.Test/ScanTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ScanTest +public sealed class ScanTest { [Fact] public async Task ScanEmpty() diff --git a/Tests/SuperLinq.Async.Test/SegmentTest.cs b/Tests/SuperLinq.Async.Test/SegmentTest.cs index edf181101..3840f430c 100644 --- a/Tests/SuperLinq.Async.Test/SegmentTest.cs +++ b/Tests/SuperLinq.Async.Test/SegmentTest.cs @@ -1,9 +1,9 @@ -namespace Test.Async; +namespace Test.Async; /// /// Verify the behavior of the Segment operator /// -public class SegmentTests +public sealed class SegmentTests { /// /// Verify that the Segment operator behaves in a lazy manner @@ -119,7 +119,7 @@ public async Task VerifyCanSegmentByPrevious() Assert.True(result.All(s => s.Count == 5)); } - public static readonly IEnumerable TestData = + public static IEnumerable TestData { get; } = from e in new[] { // input sequence is empty diff --git a/Tests/SuperLinq.Async.Test/SequenceReader.cs b/Tests/SuperLinq.Async.Test/SequenceReader.cs index eadfeb4cf..38d14bec7 100644 --- a/Tests/SuperLinq.Async.Test/SequenceReader.cs +++ b/Tests/SuperLinq.Async.Test/SequenceReader.cs @@ -79,7 +79,7 @@ await _enumerator.MoveNextAsync(), [MemberNotNull(nameof(_enumerator))] private void EnsureNotDisposed() { - if (_enumerator == null) + if (_enumerator is null) Assert.Fail("Sequence was disposed before completing."); } @@ -89,7 +89,7 @@ private void EnsureNotDisposed() public async ValueTask DisposeAsync() { var e = _enumerator; - if (e == null) return; + if (e is null) return; _enumerator = null; await e.DisposeAsync(); } diff --git a/Tests/SuperLinq.Async.Test/SequenceTest.cs b/Tests/SuperLinq.Async.Test/SequenceTest.cs index bc00cfb81..a47304321 100644 --- a/Tests/SuperLinq.Async.Test/SequenceTest.cs +++ b/Tests/SuperLinq.Async.Test/SequenceTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class SequenceTest +public sealed class SequenceTest { [Theory] [InlineData(65600, 65536, 65536)] diff --git a/Tests/SuperLinq.Async.Test/ShareTest.cs b/Tests/SuperLinq.Async.Test/ShareTest.cs index d00905e64..6c72295fe 100644 --- a/Tests/SuperLinq.Async.Test/ShareTest.cs +++ b/Tests/SuperLinq.Async.Test/ShareTest.cs @@ -3,7 +3,7 @@ namespace Test.Async; -public class ShareTest +public sealed class ShareTest { [Fact] public void ShareIsLazy() @@ -244,7 +244,7 @@ public async Task ShareRethrowsErrorDuringFirstIterationStartToAllIterationsUnti await buffer.AssertSequenceEqual(1); } - private class FailingEnumerable : IEnumerable + private sealed class FailingEnumerable : IEnumerable { private bool _started; public IEnumerator GetEnumerator() diff --git a/Tests/SuperLinq.Async.Test/SkipUntilTest.cs b/Tests/SuperLinq.Async.Test/SkipUntilTest.cs index 0dc641f0e..2fbcc420a 100644 --- a/Tests/SuperLinq.Async.Test/SkipUntilTest.cs +++ b/Tests/SuperLinq.Async.Test/SkipUntilTest.cs @@ -1,6 +1,6 @@ -namespace Test.Async; +namespace Test.Async; -public class SkipUntilTest +public sealed class SkipUntilTest { [Fact] public async Task SkipUntilPredicateNeverFalse() @@ -49,7 +49,7 @@ await sequence .AssertSequenceEqual(0, 1, 2); } - public static readonly IEnumerable TestData = + public static IEnumerable TestData { get; } = [ [Array.Empty(), 0, Array.Empty()], // empty sequence [new[] { 0 }, 0, Array.Empty()], // one-item sequence, predicate succeed diff --git a/Tests/SuperLinq.Async.Test/SortedMergeByTest.cs b/Tests/SuperLinq.Async.Test/SortedMergeByTest.cs index c1af03bfb..d85770528 100644 --- a/Tests/SuperLinq.Async.Test/SortedMergeByTest.cs +++ b/Tests/SuperLinq.Async.Test/SortedMergeByTest.cs @@ -3,7 +3,7 @@ /// /// Tests that verify the behavior of the SortedMergeBy operator. /// -public class SortedMergeByTests +public sealed class SortedMergeByTests { /// /// Verify that SortedMergeBy behaves in a lazy manner. diff --git a/Tests/SuperLinq.Async.Test/SortedMergeTest.cs b/Tests/SuperLinq.Async.Test/SortedMergeTest.cs index 31d39e371..666583620 100644 --- a/Tests/SuperLinq.Async.Test/SortedMergeTest.cs +++ b/Tests/SuperLinq.Async.Test/SortedMergeTest.cs @@ -3,7 +3,7 @@ /// /// Tests that verify the behavior of the SortedMerge operator. /// -public class SortedMergeTests +public sealed class SortedMergeTests { /// /// Verify that SortedMerge behaves in a lazy manner. diff --git a/Tests/SuperLinq.Async.Test/SplitTest.cs b/Tests/SuperLinq.Async.Test/SplitTest.cs index a8c2b9d64..155abc2ba 100644 --- a/Tests/SuperLinq.Async.Test/SplitTest.cs +++ b/Tests/SuperLinq.Async.Test/SplitTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class SplitTest +public sealed class SplitTest { [Fact] public void SplitIsLazy() @@ -45,7 +45,7 @@ public async Task SplitUptoMaxCount() public async Task SplitWithSeparatorSelector() { await using var sequence = TestingSequence.Of(1, 2, null, 3, null, 4, 5, 6); - var result = sequence.Split(n => n == null); + var result = sequence.Split(n => n is null); await using var reader = result.Read(); (await reader.Read()).AssertSequenceEqual(1, 2); @@ -58,7 +58,7 @@ public async Task SplitWithSeparatorSelector() public async Task SplitWithSeparatorSelectorUptoMaxCount() { await using var sequence = TestingSequence.Of(1, 2, null, 3, null, 4, 5, 6); - var result = sequence.Split(n => n == null, 1); + var result = sequence.Split(n => n is null, 1); await using var reader = result.Read(); (await reader.Read()).AssertSequenceEqual(1, 2); diff --git a/Tests/SuperLinq.Async.Test/StartsWithTest.cs b/Tests/SuperLinq.Async.Test/StartsWithTest.cs index 5ef705f75..41eb9f051 100644 --- a/Tests/SuperLinq.Async.Test/StartsWithTest.cs +++ b/Tests/SuperLinq.Async.Test/StartsWithTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class StartsWithTest +public sealed class StartsWithTest { [Theory] [InlineData(new[] { 1, 2, 3 }, new[] { 1, 2 }, true)] diff --git a/Tests/SuperLinq.Async.Test/SuperLinq.Async.Test.csproj b/Tests/SuperLinq.Async.Test/SuperLinq.Async.Test.csproj index 5f478be24..567e65f1a 100644 --- a/Tests/SuperLinq.Async.Test/SuperLinq.Async.Test.csproj +++ b/Tests/SuperLinq.Async.Test/SuperLinq.Async.Test.csproj @@ -1,4 +1,4 @@ - + @@ -22,7 +22,6 @@ - diff --git a/Tests/SuperLinq.Async.Test/TagFirstLastTest.cs b/Tests/SuperLinq.Async.Test/TagFirstLastTest.cs index 49cf4e6e4..28291e698 100644 --- a/Tests/SuperLinq.Async.Test/TagFirstLastTest.cs +++ b/Tests/SuperLinq.Async.Test/TagFirstLastTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class TagFirstLastTest +public sealed class TagFirstLastTest { [Fact] public void TagFirstLastIsLazy() diff --git a/Tests/SuperLinq.Async.Test/TakeEveryTest.cs b/Tests/SuperLinq.Async.Test/TakeEveryTest.cs index 88d07e692..88e5bae0b 100644 --- a/Tests/SuperLinq.Async.Test/TakeEveryTest.cs +++ b/Tests/SuperLinq.Async.Test/TakeEveryTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class TakeEveryTest +public sealed class TakeEveryTest { [Fact] public void TakeEveryIsLazy() diff --git a/Tests/SuperLinq.Async.Test/TakeTest.cs b/Tests/SuperLinq.Async.Test/TakeTest.cs index 9ff3e081e..4f8cd753f 100644 --- a/Tests/SuperLinq.Async.Test/TakeTest.cs +++ b/Tests/SuperLinq.Async.Test/TakeTest.cs @@ -3,7 +3,7 @@ namespace Test.Async; -public class TakeTest +public sealed class TakeTest { [Fact] public async Task SameResultsRepeatCallsIntQuery() diff --git a/Tests/SuperLinq.Async.Test/TakeUntilTest.cs b/Tests/SuperLinq.Async.Test/TakeUntilTest.cs index 6cec9b62c..bee6bb3bc 100644 --- a/Tests/SuperLinq.Async.Test/TakeUntilTest.cs +++ b/Tests/SuperLinq.Async.Test/TakeUntilTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class TakeUntilTest +public sealed class TakeUntilTest { [Fact] public void TakeUntilEvaluatesSourceLazily() diff --git a/Tests/SuperLinq.Async.Test/TestingSequence.cs b/Tests/SuperLinq.Async.Test/TestingSequence.cs index f412b3a01..416ff6803 100644 --- a/Tests/SuperLinq.Async.Test/TestingSequence.cs +++ b/Tests/SuperLinq.Async.Test/TestingSequence.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using CommunityToolkit.Diagnostics; using static Test.Async.TestingSequence; @@ -20,16 +20,14 @@ internal static TestingSequence AsTestingSequence( this IEnumerable source, Options options = Options.None, int maxEnumerations = 1) => - source != null - ? new TestingSequence(source.ToAsyncEnumerable(), options, maxEnumerations) + source is not null ? new TestingSequence(source.ToAsyncEnumerable(), options, maxEnumerations) : throw new ArgumentNullException(nameof(source)); internal static TestingSequence AsTestingSequence( this IAsyncEnumerable source, Options options = Options.None, int maxEnumerations = 1) => - source != null - ? new TestingSequence(source, options, maxEnumerations) + source is not null ? new TestingSequence(source, options, maxEnumerations) : throw new ArgumentNullException(nameof(source)); internal static void AssertTestingSequence([DoesNotReturnIf(false)] bool expectation, string message, [CallerArgumentExpression(nameof(expectation))] string? expr = "") @@ -56,7 +54,7 @@ public enum Options } } -public class TestingSequenceException(string message) : Exception(message); +public sealed class TestingSequenceException(string message) : Exception(message); /// /// Sequence that asserts whether its iterator has been disposed @@ -113,16 +111,16 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToke } else if (!_options.HasFlag(Options.AllowRepeatedDisposals)) { - AssertTestingSequence(false, TooManyDisposals); + AssertTestingSequence(expectation: false, TooManyDisposals); } }; var ended = false; enumerator.MoveNextCalled += (_, moved) => { - AssertTestingSequence(disposed == false, MoveNextPostDisposal); + AssertTestingSequence(disposed is false, MoveNextPostDisposal); if (!_options.HasFlag(Options.AllowRepeatedMoveNexts)) - AssertTestingSequence(ended == false, MoveNextPostEnumeration); + AssertTestingSequence(ended is false, MoveNextPostEnumeration); ended = !moved; MoveNextCallCount++; @@ -130,15 +128,15 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToke enumerator.GetCurrentCalled += delegate { - AssertTestingSequence(disposed == false, CurrentPostDisposal); - AssertTestingSequence(ended == false, CurrentPostEnumeration); + AssertTestingSequence(disposed is false, CurrentPostDisposal); + AssertTestingSequence(ended is false, CurrentPostEnumeration); }; return enumerator; } } -public class TestingSequenceTest +public sealed class TestingSequenceTest { [Fact] public async Task TestingSequencePublicPropertiesTest() diff --git a/Tests/SuperLinq.Async.Test/ThrowTest.cs b/Tests/SuperLinq.Async.Test/ThrowTest.cs index 3c50a4907..c6fa8a255 100644 --- a/Tests/SuperLinq.Async.Test/ThrowTest.cs +++ b/Tests/SuperLinq.Async.Test/ThrowTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ThrowTest +public sealed class ThrowTest { [Fact] public void ThrowIsLazy() diff --git a/Tests/SuperLinq.Async.Test/TimeoutTest.cs b/Tests/SuperLinq.Async.Test/TimeoutTest.cs index b31197231..656af07cf 100644 --- a/Tests/SuperLinq.Async.Test/TimeoutTest.cs +++ b/Tests/SuperLinq.Async.Test/TimeoutTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class TimeoutTest +public sealed class TimeoutTest { [Fact] public void TimeoutIsLazy() @@ -86,7 +86,7 @@ public async Task TimeoutExceptionWithOperationCanceledExceptionInnerException() _ = Assert.IsAssignableFrom(timeoutException.InnerException); } - private class SequenceWithoutThrowIfCancellationRequested : IAsyncEnumerable + private sealed class SequenceWithoutThrowIfCancellationRequested : IAsyncEnumerable { public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = new()) { @@ -101,7 +101,7 @@ private class SequenceWithoutThrowIfCancellationRequested : IAsyncEnumerable + private sealed class SequenceWithThrowIfCancellationRequested : IAsyncEnumerable { public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = new()) { diff --git a/Tests/SuperLinq.Async.Test/TraverseTest.cs b/Tests/SuperLinq.Async.Test/TraverseTest.cs index 3e29bfbd9..3480e4a08 100644 --- a/Tests/SuperLinq.Async.Test/TraverseTest.cs +++ b/Tests/SuperLinq.Async.Test/TraverseTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class TraverseTest +public sealed class TraverseTest { [Fact] public void TraverseDepthFirstIsStreaming() @@ -32,7 +32,7 @@ public async Task TraverseBreadthFirstPreservesChildrenOrder() await res.AssertSequenceEqual(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); } - private class Tree( + private sealed class Tree( T value, IEnumerable> children ) diff --git a/Tests/SuperLinq.Async.Test/TrySingleTest.cs b/Tests/SuperLinq.Async.Test/TrySingleTest.cs index 0341ee2ad..7c2bb71b6 100644 --- a/Tests/SuperLinq.Async.Test/TrySingleTest.cs +++ b/Tests/SuperLinq.Async.Test/TrySingleTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class TrySingleTest +public sealed class TrySingleTest { [Fact] public async Task TrySingleWithEmptySource() diff --git a/Tests/SuperLinq.Async.Test/UsingTest.cs b/Tests/SuperLinq.Async.Test/UsingTest.cs index 204ee3d19..09dc6af18 100644 --- a/Tests/SuperLinq.Async.Test/UsingTest.cs +++ b/Tests/SuperLinq.Async.Test/UsingTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class UsingTest +public sealed class UsingTest { [Fact] public void UsingIsLazy() @@ -78,7 +78,7 @@ public async Task UsingDisposesOnFunctionError() Assert.True(dis.IsDisposed); } - private class TestDisposable : IAsyncDisposable + private sealed class TestDisposable : IAsyncDisposable { public bool IsDisposed { get; set; } public ValueTask DisposeAsync() diff --git a/Tests/SuperLinq.Async.Test/WhereLagTest.cs b/Tests/SuperLinq.Async.Test/WhereLagTest.cs index 8bd589dca..5369a1faf 100644 --- a/Tests/SuperLinq.Async.Test/WhereLagTest.cs +++ b/Tests/SuperLinq.Async.Test/WhereLagTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class WhereLagTest +public sealed class WhereLagTest { [Fact] public void WhereLagIsLazy() diff --git a/Tests/SuperLinq.Async.Test/WhereLeadTest.cs b/Tests/SuperLinq.Async.Test/WhereLeadTest.cs index e59ecef1d..90146906c 100644 --- a/Tests/SuperLinq.Async.Test/WhereLeadTest.cs +++ b/Tests/SuperLinq.Async.Test/WhereLeadTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class WhereLeadTest +public sealed class WhereLeadTest { [Fact] public void WhereLeadIsLazy() diff --git a/Tests/SuperLinq.Async.Test/WhereTest.cs b/Tests/SuperLinq.Async.Test/WhereTest.cs index 4de86022f..5bfa519a8 100644 --- a/Tests/SuperLinq.Async.Test/WhereTest.cs +++ b/Tests/SuperLinq.Async.Test/WhereTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class WhereTest +public sealed class WhereTest { [Fact] public void WhereIsLazy() diff --git a/Tests/SuperLinq.Async.Test/WhileTest.cs b/Tests/SuperLinq.Async.Test/WhileTest.cs index fae0298f6..f863ac61b 100644 --- a/Tests/SuperLinq.Async.Test/WhileTest.cs +++ b/Tests/SuperLinq.Async.Test/WhileTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class WhileTest +public sealed class WhileTest { [Fact] public void WhileIsLazy() diff --git a/Tests/SuperLinq.Async.Test/WindowLeftTest.cs b/Tests/SuperLinq.Async.Test/WindowLeftTest.cs index cb1897126..0d4e7eb37 100644 --- a/Tests/SuperLinq.Async.Test/WindowLeftTest.cs +++ b/Tests/SuperLinq.Async.Test/WindowLeftTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class WindowLeftTest +public sealed class WindowLeftTest { [Fact] public void WindowLeftIsLazy() diff --git a/Tests/SuperLinq.Async.Test/WindowRightTest.cs b/Tests/SuperLinq.Async.Test/WindowRightTest.cs index 7f593cf2c..5cfd87b37 100644 --- a/Tests/SuperLinq.Async.Test/WindowRightTest.cs +++ b/Tests/SuperLinq.Async.Test/WindowRightTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class WindowRightTest +public sealed class WindowRightTest { [Fact] public void WindowRightIsLazy() diff --git a/Tests/SuperLinq.Async.Test/WindowTest.cs b/Tests/SuperLinq.Async.Test/WindowTest.cs index e3871ac5f..9d7b146df 100644 --- a/Tests/SuperLinq.Async.Test/WindowTest.cs +++ b/Tests/SuperLinq.Async.Test/WindowTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the Window operator /// -public class WindowTests +public sealed class WindowTests { /// /// Verify that Window behaves in a lazy manner diff --git a/Tests/SuperLinq.Async.Test/ZipLongestTest.cs b/Tests/SuperLinq.Async.Test/ZipLongestTest.cs index 090dd6658..530737fc3 100644 --- a/Tests/SuperLinq.Async.Test/ZipLongestTest.cs +++ b/Tests/SuperLinq.Async.Test/ZipLongestTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ZipLongestTest +public sealed class ZipLongestTest { [Fact] public void ZipLongestIsLazy() diff --git a/Tests/SuperLinq.Async.Test/ZipMapTest.cs b/Tests/SuperLinq.Async.Test/ZipMapTest.cs index 39bca5988..3e8e271a4 100644 --- a/Tests/SuperLinq.Async.Test/ZipMapTest.cs +++ b/Tests/SuperLinq.Async.Test/ZipMapTest.cs @@ -1,16 +1,17 @@ -using System.Text.RegularExpressions; +using System.Globalization; +using System.Text.RegularExpressions; namespace Test.Async; -public class ZipMapTest +public sealed class ZipMapTest { [Fact] public async Task ZipMapIntTransformation() { var range = Enumerable.Range(1, 10); await using var ts1 = range.AsTestingSequence(); - await ts1.ZipMap(i => i.ToString()).AssertSequenceEqual( - range.Select(i => (i, i.ToString()))); + await ts1.ZipMap(i => i.ToString(CultureInfo.InvariantCulture)).AssertSequenceEqual( + range.Select(i => (i, i.ToString(CultureInfo.InvariantCulture)))); } [Fact] diff --git a/Tests/SuperLinq.Async.Test/ZipShortestTest.cs b/Tests/SuperLinq.Async.Test/ZipShortestTest.cs index 1d42efd8b..d00f6b6d6 100644 --- a/Tests/SuperLinq.Async.Test/ZipShortestTest.cs +++ b/Tests/SuperLinq.Async.Test/ZipShortestTest.cs @@ -1,6 +1,6 @@ namespace Test.Async; -public class ZipShortestTest +public sealed class ZipShortestTest { [Fact] public void ZipShortestIsLazy() diff --git a/Tests/SuperLinq.Test/.editorconfig b/Tests/SuperLinq.Test/.editorconfig index 9ab78feb6..385f3533f 100644 --- a/Tests/SuperLinq.Test/.editorconfig +++ b/Tests/SuperLinq.Test/.editorconfig @@ -1,8 +1,7 @@ [*.cs] -dotnet_diagnostic.CA1305.severity = none # CA1305: Specify IFormatProvider dotnet_diagnostic.CA1707.severity = none # CA1707: Identifiers should not contain underscores -dotnet_diagnostic.CA1852.severity = none # CA1852: Type '' can be sealed because it has no subtypes in its containing assembly and is not externally visible +dotnet_diagnostic.CA1861.severity = none # CA1861: Avoid constant arrays as arguments dotnet_diagnostic.CA2201.severity = none # CA2201: Do not raise reserved exception types dotnet_diagnostic.IDE0022.severity = none # IDE0022: Use expression body for methods @@ -16,3 +15,5 @@ dotnet_diagnostic.CS1712.severity = none # CS1712: Type parameter dotnet_diagnostic.xUnit1008.severity = error # xUnit1008: Test data attribute should only be used on a Theory dotnet_diagnostic.xUnit1013.severity = error # xUnit1013: Public method should be marked as test dotnet_diagnostic.xUnit1042.severity = none # xUnit1042: The member referenced by the MemberData attribute returns untyped data rows + +dotnet_diagnostic.MA0046.severity = none diff --git a/Tests/SuperLinq.Test/AggregateByTest.cs b/Tests/SuperLinq.Test/AggregateByTest.cs index 88ec6ffb7..ea06d903a 100644 --- a/Tests/SuperLinq.Test/AggregateByTest.cs +++ b/Tests/SuperLinq.Test/AggregateByTest.cs @@ -1,10 +1,10 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Test; [Obsolete("References `DistinctBy` which is obsolete in net9+")] -public class AggregateByTest +public sealed class AggregateByTest { [Theory] [MemberData(nameof(AggregateBy_TestData))] @@ -65,12 +65,12 @@ public static void AggregateBy_HasExpectedOutput( expected: Enumerable.Repeat(5, 1).ToDictionary(x => x, x => 100)); yield return WrapArgs( - source: new string[] { "Bob", "bob", "tim", "Bob", "Tim" }, + source: ["Bob", "bob", "tim", "Bob", "Tim"], keySelector: x => x, seedSelector: x => string.Empty, func: (x, y) => x + y, - null, - expected: new Dictionary + comparer: null, + expected: new Dictionary(StringComparer.Ordinal) { { "Bob", "BobBob" }, { "bob", "bob" }, @@ -79,15 +79,15 @@ public static void AggregateBy_HasExpectedOutput( }); yield return WrapArgs( - source: new string[] { "Bob", "bob", "tim", "Bob", "Tim" }, + source: ["Bob", "bob", "tim", "Bob", "Tim"], keySelector: x => x, seedSelector: x => string.Empty, func: (x, y) => x + y, StringComparer.OrdinalIgnoreCase, - expected: new Dictionary + expected: new Dictionary(StringComparer.Ordinal) { { "Bob", "BobbobBob" }, - { "tim", "timTim" } + { "tim", "timTim" }, }); yield return WrapArgs( @@ -100,7 +100,7 @@ public static void AggregateBy_HasExpectedOutput( { { 20, "I am 20 and my name is Tom" }, { 30, "I am 30 and my name is Dick" }, - { 40, "I am 40 and my name is Harry" } + { 40, "I am 40 and my name is Harry" }, }); yield return WrapArgs( @@ -112,7 +112,7 @@ public static void AggregateBy_HasExpectedOutput( expected: new Dictionary { { 20, "I am 20 and my name is maybe Tom maybe Dick" }, - { 40, "I am 40 and my name is maybe Harry" } + { 40, "I am 40 and my name is maybe Harry" }, }); yield return WrapArgs( @@ -121,7 +121,8 @@ public static void AggregateBy_HasExpectedOutput( seedSelector: x => 0, func: (x, y) => x + y.Age, comparer: null, - expected: new string[] { "Bob", "bob", "Harry" }.ToDictionary(x => x, x => 20)); + expected: new string[] { "Bob", "bob", "Harry" } + .ToDictionary(x => x, x => 20, StringComparer.Ordinal)); yield return WrapArgs( source: new (string Name, int Age)[] { ("Bob", 20), ("bob", 30), ("Harry", 40) }, @@ -129,10 +130,10 @@ public static void AggregateBy_HasExpectedOutput( seedSelector: x => 0, func: (x, y) => x + y.Age, comparer: StringComparer.OrdinalIgnoreCase, - expected: new Dictionary + expected: new Dictionary(StringComparer.Ordinal) { { "Bob", 50 }, - { "Harry", 40 } + { "Harry", 40 }, }); static object?[] WrapArgs(IEnumerable source, Func keySelector, Func seedSelector, Func func, IEqualityComparer? comparer, IEnumerable> expected) diff --git a/Tests/SuperLinq.Test/AggregateRightTest.cs b/Tests/SuperLinq.Test/AggregateRightTest.cs index 4222f5187..83f6e4909 100644 --- a/Tests/SuperLinq.Test/AggregateRightTest.cs +++ b/Tests/SuperLinq.Test/AggregateRightTest.cs @@ -1,6 +1,8 @@ -namespace Test; +using System.Globalization; -public class AggregateRightTest +namespace Test; + +public sealed class AggregateRightTest { [Fact] public void AggregateRightWithEmptySequence() @@ -21,8 +23,8 @@ public void AggregateRightFuncIsNotInvokedOnSingleElementSequence() [Fact] public void AggregateRight() { - using var enumerable = Enumerable.Range(1, 5).Select(x => x.ToString()).AsTestingSequence(); - var result = enumerable.AggregateRight((a, b) => string.Format("({0}+{1})", a, b)); + using var enumerable = Enumerable.Range(1, 5).Select(x => x.ToString(CultureInfo.InvariantCulture)).AsTestingSequence(); + var result = enumerable.AggregateRight((a, b) => FormattableString.Invariant($"({a}+{b})")); Assert.Equal("(1+(2+(3+(4+5))))", result); } @@ -30,8 +32,8 @@ public void AggregateRight() [Fact] public void AggregateRightWithList() { - var list = Enumerable.Range(1, 5).Select(x => x.ToString()).ToList(); - var result = list.AggregateRight((a, b) => string.Format("({0}+{1})", a, b)); + var list = Enumerable.Range(1, 5).Select(x => x.ToString(CultureInfo.InvariantCulture)).ToList(); + var result = list.AggregateRight((a, b) => FormattableString.Invariant($"({a}+{b})")); Assert.Equal("(1+(2+(3+(4+5))))", result); } @@ -59,7 +61,7 @@ public void AggregateRightSeedFuncIsNotInvokedOnEmptySequence() public void AggregateRightSeed() { using var enumerable = Enumerable.Range(1, 4).AsTestingSequence(); - var result = enumerable.AggregateRight("5", (a, b) => string.Format("({0}+{1})", a, b)); + var result = enumerable.AggregateRight("5", (a, b) => FormattableString.Invariant($"({a}+{b})")); Assert.Equal("(1+(2+(3+(4+5))))", result); } @@ -80,7 +82,7 @@ public void AggregateRightResultorWithEmptySequence(object defaultValue) public void AggregateRightResultor() { using var enumerable = Enumerable.Range(1, 4).AsTestingSequence(); - var result = enumerable.AggregateRight("5", (a, b) => string.Format("({0}+{1})", a, b), a => a.Length); + var result = enumerable.AggregateRight("5", (a, b) => FormattableString.Invariant($"({a}+{b})"), a => a.Length); Assert.Equal("(1+(2+(3+(4+5))))".Length, result); } @@ -89,7 +91,7 @@ public void AggregateRightResultor() public void AggregateRightResultorWithList() { var list = Enumerable.Range(1, 4).ToList(); - var result = list.AggregateRight("5", (a, b) => string.Format("({0}+{1})", a, b), a => a.Length); + var result = list.AggregateRight("5", (a, b) => FormattableString.Invariant($"({a}+{b})"), a => a.Length); Assert.Equal("(1+(2+(3+(4+5))))".Length, result); } diff --git a/Tests/SuperLinq.Test/AggregateTest.cs b/Tests/SuperLinq.Test/AggregateTest.cs index fdfe9ec2d..2dd1fb454 100644 --- a/Tests/SuperLinq.Test/AggregateTest.cs +++ b/Tests/SuperLinq.Test/AggregateTest.cs @@ -4,7 +4,7 @@ namespace Test; -public class AggregateTest +public sealed class AggregateTest { public static IEnumerable AccumulatorsTestSource() => diff --git a/Tests/SuperLinq.Test/AssertCountTest.cs b/Tests/SuperLinq.Test/AssertCountTest.cs index 2e365cf6b..2534a9ebd 100644 --- a/Tests/SuperLinq.Test/AssertCountTest.cs +++ b/Tests/SuperLinq.Test/AssertCountTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class AssertCountTest +public sealed class AssertCountTest { [Fact] public void AssertCountIsLazy() diff --git a/Tests/SuperLinq.Test/AtLeastTest.cs b/Tests/SuperLinq.Test/AtLeastTest.cs index 086a0671b..a13f5ab0a 100644 --- a/Tests/SuperLinq.Test/AtLeastTest.cs +++ b/Tests/SuperLinq.Test/AtLeastTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class AtLeastTest +public sealed class AtLeastTest { [Fact] public void AtLeastWithNegativeCount() diff --git a/Tests/SuperLinq.Test/AtMostTest.cs b/Tests/SuperLinq.Test/AtMostTest.cs index b360550cf..82965df34 100644 --- a/Tests/SuperLinq.Test/AtMostTest.cs +++ b/Tests/SuperLinq.Test/AtMostTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class AtMostTest +public sealed class AtMostTest { [Fact] public void AtMostWithNegativeCount() diff --git a/Tests/SuperLinq.Test/BacksertTest.cs b/Tests/SuperLinq.Test/BacksertTest.cs index b8f00ffce..152de6c90 100644 --- a/Tests/SuperLinq.Test/BacksertTest.cs +++ b/Tests/SuperLinq.Test/BacksertTest.cs @@ -1,7 +1,7 @@ namespace Test; [Obsolete("References `Backsert` which is obsolete in favor of `Insert`")] -public class BacksertTest +public sealed class BacksertTest { [Fact] public void BacksertIsLazy() diff --git a/Tests/SuperLinq.Test/BatchTest.cs b/Tests/SuperLinq.Test/BatchTest.cs index 66aaff236..1371f9c2b 100644 --- a/Tests/SuperLinq.Test/BatchTest.cs +++ b/Tests/SuperLinq.Test/BatchTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class BatchTest +public sealed class BatchTest { [Fact] public void BatchIsLazy() diff --git a/Tests/SuperLinq.Test/BindByIndexTest.cs b/Tests/SuperLinq.Test/BindByIndexTest.cs index 970af7562..57d3f436f 100644 --- a/Tests/SuperLinq.Test/BindByIndexTest.cs +++ b/Tests/SuperLinq.Test/BindByIndexTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class BindByIndexTest +public sealed class BindByIndexTest { [Fact] public void BindByIndexIsLazy() diff --git a/Tests/SuperLinq.Test/BreakingList.cs b/Tests/SuperLinq.Test/BreakingList.cs index 0e0e043df..bf20f1430 100644 --- a/Tests/SuperLinq.Test/BreakingList.cs +++ b/Tests/SuperLinq.Test/BreakingList.cs @@ -1,27 +1,27 @@ -namespace Test; +namespace Test; internal static class BreakingList { public static BreakingList AsBreakingList(this IEnumerable source) => new(source); } -internal class BreakingList : BreakingSequence, IList, IDisposableEnumerable +internal sealed class BreakingList : BreakingSequence, IList, IDisposableEnumerable { - protected readonly IList List; + private readonly IList _list; public BreakingList(params T[] values) : this((IList)values) { } - public BreakingList(IEnumerable source) => List = source.ToList(); - public BreakingList(IList list) => List = list; + public BreakingList(IEnumerable source) => _list = source.ToList(); + public BreakingList(IList list) => _list = list; - public int Count => List.Count; + public int Count => _list.Count; public T this[int index] { get { - if (index < 0 || index >= List.Count) + if (index < 0 || index >= _list.Count) Assert.Fail("LINQ Operators should prevent this from happening."); - return List[index]; + return _list[index]; } set => Assert.Fail("LINQ Operators should not be calling this method."); @@ -36,12 +36,12 @@ public int IndexOf(T item) public void Add(T item) => Assert.Fail("LINQ Operators should not be calling this method."); public void Insert(int index, T item) => Assert.Fail("LINQ Operators should not be calling this method."); public void Clear() => Assert.Fail("LINQ Operators should not be calling this method."); - public bool Contains(T item) => List.Contains(item); + public bool Contains(T item) => _list.Contains(item); public bool Remove(T item) { Assert.Fail("LINQ Operators should not be calling this method."); return false; } public void RemoveAt(int index) => Assert.Fail("LINQ Operators should not be calling this method."); public bool IsReadOnly => true; - public virtual void CopyTo(T[] array, int arrayIndex) => List.CopyTo(array, arrayIndex); + public void CopyTo(T[] array, int arrayIndex) => _list.CopyTo(array, arrayIndex); public void Dispose() { } } diff --git a/Tests/SuperLinq.Test/BufferTest.cs b/Tests/SuperLinq.Test/BufferTest.cs index fbd8cf655..e76046ee7 100644 --- a/Tests/SuperLinq.Test/BufferTest.cs +++ b/Tests/SuperLinq.Test/BufferTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class BufferTest +public sealed class BufferTest { [Fact] public void BufferIsLazy() diff --git a/Tests/SuperLinq.Test/CartesianTest.cs b/Tests/SuperLinq.Test/CartesianTest.cs index 7adb6ff2e..94b54d008 100644 --- a/Tests/SuperLinq.Test/CartesianTest.cs +++ b/Tests/SuperLinq.Test/CartesianTest.cs @@ -3,7 +3,7 @@ namespace Test; /// /// Verify the behavior of the Cartesian operator /// -public class CartesianTests +public sealed class CartesianTests { /// /// Verify that the Cartesian product is evaluated in a lazy fashion on demand. diff --git a/Tests/SuperLinq.Test/CaseTest.cs b/Tests/SuperLinq.Test/CaseTest.cs index 80cc9d530..f259241ae 100644 --- a/Tests/SuperLinq.Test/CaseTest.cs +++ b/Tests/SuperLinq.Test/CaseTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class CaseTest +public sealed class CaseTest { [Fact] public void CaseIsLazy() diff --git a/Tests/SuperLinq.Test/CatchTest.cs b/Tests/SuperLinq.Test/CatchTest.cs index 95c969146..eabb6d914 100644 --- a/Tests/SuperLinq.Test/CatchTest.cs +++ b/Tests/SuperLinq.Test/CatchTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class CatchTest +public sealed class CatchTest { [Fact] public void CatchIsLazy() diff --git a/Tests/SuperLinq.Test/ChooseTest.cs b/Tests/SuperLinq.Test/ChooseTest.cs index 56e3e1635..7012e4f01 100644 --- a/Tests/SuperLinq.Test/ChooseTest.cs +++ b/Tests/SuperLinq.Test/ChooseTest.cs @@ -2,7 +2,7 @@ namespace Test; -public class ChooseTest +public sealed class ChooseTest { [Fact] public void IsLazy() diff --git a/Tests/SuperLinq.Test/CollectionEqualTest.cs b/Tests/SuperLinq.Test/CollectionEqualTest.cs index 74fc1b068..17b768909 100644 --- a/Tests/SuperLinq.Test/CollectionEqualTest.cs +++ b/Tests/SuperLinq.Test/CollectionEqualTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class CollectionEqualTest +public sealed class CollectionEqualTest { [Fact] public void CollectionEqualIntSequenceInOrder() diff --git a/Tests/SuperLinq.Test/CompareCountTest.cs b/Tests/SuperLinq.Test/CompareCountTest.cs index b54158d16..f082ad5bc 100644 --- a/Tests/SuperLinq.Test/CompareCountTest.cs +++ b/Tests/SuperLinq.Test/CompareCountTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class CompareCountTest +public sealed class CompareCountTest { public static IEnumerable CompareCountData { get; } = from e in new[] diff --git a/Tests/SuperLinq.Test/ConsumeTest.cs b/Tests/SuperLinq.Test/ConsumeTest.cs index 484579a8f..47d263768 100644 --- a/Tests/SuperLinq.Test/ConsumeTest.cs +++ b/Tests/SuperLinq.Test/ConsumeTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ConsumeTest +public sealed class ConsumeTest { [Fact] public void ConsumeReallyConsumes() diff --git a/Tests/SuperLinq.Test/CopyToTest.cs b/Tests/SuperLinq.Test/CopyToTest.cs index dbbc01512..4a4a41888 100644 --- a/Tests/SuperLinq.Test/CopyToTest.cs +++ b/Tests/SuperLinq.Test/CopyToTest.cs @@ -5,7 +5,7 @@ namespace Test; #pragma warning disable IDE0034 -public class CopyToTest +public sealed class CopyToTest { [Fact] public void NullArgumentTest() diff --git a/Tests/SuperLinq.Test/CountBetweenTest.cs b/Tests/SuperLinq.Test/CountBetweenTest.cs index 04345459a..c4746a321 100644 --- a/Tests/SuperLinq.Test/CountBetweenTest.cs +++ b/Tests/SuperLinq.Test/CountBetweenTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class CountBetweenTest +public sealed class CountBetweenTest { [Fact] public void CountBetweenWithNegativeMin() diff --git a/Tests/SuperLinq.Test/CountByTest.cs b/Tests/SuperLinq.Test/CountByTest.cs index a57e442c9..39004dbe2 100644 --- a/Tests/SuperLinq.Test/CountByTest.cs +++ b/Tests/SuperLinq.Test/CountByTest.cs @@ -1,7 +1,7 @@ namespace Test; [Obsolete("References `CountBy` which is obsolete in net9+")] -public class CountByTest +public sealed class CountByTest { [Fact] public void CountBySimpleTest() diff --git a/Tests/SuperLinq.Test/CountDownTest.cs b/Tests/SuperLinq.Test/CountDownTest.cs index 0a885caac..1c6cefdb2 100644 --- a/Tests/SuperLinq.Test/CountDownTest.cs +++ b/Tests/SuperLinq.Test/CountDownTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class CountDownTest +public sealed class CountDownTest { [Fact] public void IsLazy() diff --git a/Tests/SuperLinq.Test/DeferTest.cs b/Tests/SuperLinq.Test/DeferTest.cs index 8d0e55ba4..5cd05d057 100644 --- a/Tests/SuperLinq.Test/DeferTest.cs +++ b/Tests/SuperLinq.Test/DeferTest.cs @@ -3,7 +3,7 @@ namespace Test; -public class DeferTest +public sealed class DeferTest { [Fact] public void DeferIsLazy() diff --git a/Tests/SuperLinq.Test/DensePartialSortByTest.cs b/Tests/SuperLinq.Test/DensePartialSortByTest.cs index aa51f67d9..7b5e6a396 100644 --- a/Tests/SuperLinq.Test/DensePartialSortByTest.cs +++ b/Tests/SuperLinq.Test/DensePartialSortByTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class DensePartialSortByTests +public sealed class DensePartialSortByTests { [Fact] public void DensePartialSortByIsLazy() diff --git a/Tests/SuperLinq.Test/DensePartialSortTest.cs b/Tests/SuperLinq.Test/DensePartialSortTest.cs index c7c03382f..bd38c6a80 100644 --- a/Tests/SuperLinq.Test/DensePartialSortTest.cs +++ b/Tests/SuperLinq.Test/DensePartialSortTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class DensePartialSortTests +public sealed class DensePartialSortTests { [Fact] public void DensePartialSortIsLazy() diff --git a/Tests/SuperLinq.Test/DenseRankTest.cs b/Tests/SuperLinq.Test/DenseRankTest.cs index 6a7f990d0..ccf13bf7c 100644 --- a/Tests/SuperLinq.Test/DenseRankTest.cs +++ b/Tests/SuperLinq.Test/DenseRankTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class DenseRankTests +public sealed class DenseRankTests { /// /// Verify that DenseRank uses deferred execution diff --git a/Tests/SuperLinq.Test/DistinctByTest.cs b/Tests/SuperLinq.Test/DistinctByTest.cs index a24861e35..789c675a3 100644 --- a/Tests/SuperLinq.Test/DistinctByTest.cs +++ b/Tests/SuperLinq.Test/DistinctByTest.cs @@ -1,7 +1,7 @@ namespace Test; [Obsolete("References `DistinctBy` which is obsolete in net6+")] -public class DistinctByTest +public sealed class DistinctByTest { [Fact] public void DistinctBy() diff --git a/Tests/SuperLinq.Test/DistinctUntilChangedTest.cs b/Tests/SuperLinq.Test/DistinctUntilChangedTest.cs index 28f07614a..07071d6a2 100644 --- a/Tests/SuperLinq.Test/DistinctUntilChangedTest.cs +++ b/Tests/SuperLinq.Test/DistinctUntilChangedTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class DistinctUntilChangedTest +public sealed class DistinctUntilChangedTest { [Fact] public void DistinctUntilChangedIsLazy() diff --git a/Tests/SuperLinq.Test/DoTest.cs b/Tests/SuperLinq.Test/DoTest.cs index c2961a902..41004c9d7 100644 --- a/Tests/SuperLinq.Test/DoTest.cs +++ b/Tests/SuperLinq.Test/DoTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class DoTest +public sealed class DoTest { [Fact] public void DoOverloadsAreLazy() diff --git a/Tests/SuperLinq.Test/DoWhileTest.cs b/Tests/SuperLinq.Test/DoWhileTest.cs index b433c8c67..3491d351a 100644 --- a/Tests/SuperLinq.Test/DoWhileTest.cs +++ b/Tests/SuperLinq.Test/DoWhileTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class DoWhileTest +public sealed class DoWhileTest { [Fact] public void DoWhileIsLazy() diff --git a/Tests/SuperLinq.Test/DuplicatesTest.cs b/Tests/SuperLinq.Test/DuplicatesTest.cs index cfadab8ab..0397ff499 100644 --- a/Tests/SuperLinq.Test/DuplicatesTest.cs +++ b/Tests/SuperLinq.Test/DuplicatesTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class DuplicatesTest +public sealed class DuplicatesTest { [Fact] public void DuplicatesIsLazy() diff --git a/Tests/SuperLinq.Test/ElementAtTest.cs b/Tests/SuperLinq.Test/ElementAtTest.cs index 12b5f969c..923add747 100644 --- a/Tests/SuperLinq.Test/ElementAtTest.cs +++ b/Tests/SuperLinq.Test/ElementAtTest.cs @@ -3,7 +3,7 @@ namespace Test; -public class ElementAtTest +public sealed class ElementAtTest { // simplified tests - already tested by fx, only need to prove that we don't step on fx toes diff --git a/Tests/SuperLinq.Test/EndsWithTest.cs b/Tests/SuperLinq.Test/EndsWithTest.cs index a17a182e4..8727b345a 100644 --- a/Tests/SuperLinq.Test/EndsWithTest.cs +++ b/Tests/SuperLinq.Test/EndsWithTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class EndsWithTest +public sealed class EndsWithTest { [Theory] [InlineData(new[] { 1, 2, 3 }, new[] { 2, 3 }, true)] @@ -68,7 +68,7 @@ public void EndsWithUsesSpecifiedEqualityComparerOrDefault() var second = Seq(4, 5, 6); Assert.False(first.EndsWith(second)); - Assert.False(first.EndsWith(second, null)); + Assert.False(first.EndsWith(second, comparer: null)); Assert.False(first.EndsWith(second, EqualityComparer.Create(delegate { return false; }))); Assert.True(first.EndsWith(second, EqualityComparer.Create(delegate { return true; }))); } diff --git a/Tests/SuperLinq.Test/EqualityComparer.cs b/Tests/SuperLinq.Test/EqualityComparer.cs index 9104bb0e7..9a1b3576e 100644 --- a/Tests/SuperLinq.Test/EqualityComparer.cs +++ b/Tests/SuperLinq.Test/EqualityComparer.cs @@ -17,7 +17,7 @@ Func hasher private readonly Func _hasher = hasher ?? throw new ArgumentNullException(nameof(hasher)); public DelegatingComparer(Func comparer) - : this(comparer, x => x == null ? 0 : x.GetHashCode()) { } + : this(comparer, x => x is null ? 0 : x.GetHashCode()) { } public bool Equals(T? x, T? y) => _comparer(x!, y!); public int GetHashCode(T obj) => _hasher(obj); diff --git a/Tests/SuperLinq.Test/EquiZipTest.cs b/Tests/SuperLinq.Test/EquiZipTest.cs index 38b3aa796..f2bbe40b0 100644 --- a/Tests/SuperLinq.Test/EquiZipTest.cs +++ b/Tests/SuperLinq.Test/EquiZipTest.cs @@ -2,7 +2,7 @@ namespace Test; -public class EquiZipTest +public sealed class EquiZipTest { private static readonly string[] s_cardinals = [ diff --git a/Tests/SuperLinq.Test/EvaluateTest.cs b/Tests/SuperLinq.Test/EvaluateTest.cs index 4dab7fb07..9c64e8878 100644 --- a/Tests/SuperLinq.Test/EvaluateTest.cs +++ b/Tests/SuperLinq.Test/EvaluateTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class EvaluateTest +public sealed class EvaluateTest { [Fact] public void TestEvaluateIsLazy() diff --git a/Tests/SuperLinq.Test/ExactlyTest.cs b/Tests/SuperLinq.Test/ExactlyTest.cs index 9d61eacd1..e001ad629 100644 --- a/Tests/SuperLinq.Test/ExactlyTest.cs +++ b/Tests/SuperLinq.Test/ExactlyTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ExactlyTest +public sealed class ExactlyTest { [Fact] public void ExactlyWithNegativeCount() diff --git a/Tests/SuperLinq.Test/ExceptByTest.cs b/Tests/SuperLinq.Test/ExceptByTest.cs index 3713d709d..84a25d000 100644 --- a/Tests/SuperLinq.Test/ExceptByTest.cs +++ b/Tests/SuperLinq.Test/ExceptByTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ExceptByTest +public sealed class ExceptByTest { [Fact] public void SimpleExceptBy() diff --git a/Tests/SuperLinq.Test/ExcludeTest.cs b/Tests/SuperLinq.Test/ExcludeTest.cs index fb7f204b1..9321f256a 100644 --- a/Tests/SuperLinq.Test/ExcludeTest.cs +++ b/Tests/SuperLinq.Test/ExcludeTest.cs @@ -3,7 +3,7 @@ namespace Test; /// /// Verify the behavior of the Exclude operator /// -public class ExcludeTests +public sealed class ExcludeTests { [Fact] public void TestExcludeIsLazy() diff --git a/Tests/SuperLinq.Test/FallbackIfEmptyTest.cs b/Tests/SuperLinq.Test/FallbackIfEmptyTest.cs index c3a4f5c68..3e2c760ac 100644 --- a/Tests/SuperLinq.Test/FallbackIfEmptyTest.cs +++ b/Tests/SuperLinq.Test/FallbackIfEmptyTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class FallbackIfEmptyTest +public sealed class FallbackIfEmptyTest { [Fact] public void FallbackIfEmptyWithEmptySequence() diff --git a/Tests/SuperLinq.Test/FillBackwardTest.cs b/Tests/SuperLinq.Test/FillBackwardTest.cs index 9e681f612..169b1c29a 100644 --- a/Tests/SuperLinq.Test/FillBackwardTest.cs +++ b/Tests/SuperLinq.Test/FillBackwardTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class FillBackwardTest +public sealed class FillBackwardTest { [Fact] public void FillBackwardIsLazy() diff --git a/Tests/SuperLinq.Test/FillForwardTest.cs b/Tests/SuperLinq.Test/FillForwardTest.cs index b79fc00df..0e22cb5d7 100644 --- a/Tests/SuperLinq.Test/FillForwardTest.cs +++ b/Tests/SuperLinq.Test/FillForwardTest.cs @@ -1,8 +1,8 @@ -using System.Text.RegularExpressions; +using System.Globalization; namespace Test; -public class FillForwardTest +public sealed class FillForwardTest { [Fact] public void FillForwardIsLazy() @@ -77,18 +77,18 @@ Africa Egypt Cairo 789 from line in Table.Split('\n') select line.Trim() into line where !string.IsNullOrEmpty(line) - let x = Regex.Split(line, "\x20+") + let x = line.Split(' ', StringSplitOptions.RemoveEmptyEntries) select new { Continent = x[0], Country = x[1], City = x[2], - Value = int.Parse(x[3]), + Value = int.Parse(x[3], CultureInfo.InvariantCulture), }).AsTestingSequence(); data - .FillForward(e => e.Continent == "-", (e, f) => new { f.Continent, e.Country, e.City, e.Value }) - .FillForward(e => e.Country == "-", (e, f) => new { e.Continent, f.Country, e.City, e.Value }) + .FillForward(e => e.Continent is "-", (e, f) => new { f.Continent, e.Country, e.City, e.Value }) + .FillForward(e => e.Country is "-", (e, f) => new { e.Continent, f.Country, e.City, e.Value }) .AssertSequenceEqual( new { Continent = "Europe", Country = "UK", City = "London", Value = 123 }, new { Continent = "Europe", Country = "UK", City = "Manchester", Value = 234 }, diff --git a/Tests/SuperLinq.Test/FinallyTest.cs b/Tests/SuperLinq.Test/FinallyTest.cs index 3c604f826..bce8491ed 100644 --- a/Tests/SuperLinq.Test/FinallyTest.cs +++ b/Tests/SuperLinq.Test/FinallyTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class FinallyTest +public sealed class FinallyTest { [Fact] public void FinallyIsLazy() diff --git a/Tests/SuperLinq.Test/FindIndexTest.cs b/Tests/SuperLinq.Test/FindIndexTest.cs index fc059444b..cbe2c527f 100644 --- a/Tests/SuperLinq.Test/FindIndexTest.cs +++ b/Tests/SuperLinq.Test/FindIndexTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class FindIndexTest +public sealed class FindIndexTest { [Fact] public void FindIndexWithNegativeCount() diff --git a/Tests/SuperLinq.Test/FindLastIndexTest.cs b/Tests/SuperLinq.Test/FindLastIndexTest.cs index d45bca561..a05280494 100644 --- a/Tests/SuperLinq.Test/FindLastIndexTest.cs +++ b/Tests/SuperLinq.Test/FindLastIndexTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class FindLastIndexTest +public sealed class FindLastIndexTest { [Fact] public void FindLastIndexWithNegativeCount() diff --git a/Tests/SuperLinq.Test/FlattenTest.cs b/Tests/SuperLinq.Test/FlattenTest.cs index de8c56313..b72593ba1 100644 --- a/Tests/SuperLinq.Test/FlattenTest.cs +++ b/Tests/SuperLinq.Test/FlattenTest.cs @@ -1,8 +1,8 @@ -using System.Collections; +using System.Collections; namespace Test; -public class FlattenTest +public sealed class FlattenTest { // Flatten(this IEnumerable source) @@ -81,7 +81,7 @@ public void FlattenPredicate() 4, new[] { - true, false + true, false, }, 5, }, @@ -102,7 +102,7 @@ public void FlattenPredicate() new[] { true, - false + false, }, 5, 6, @@ -123,7 +123,7 @@ public void FlattenPredicateAlwaysFalse() true, false, }, - 6 + 6, }; using var source = orig.AsTestingSequence(); @@ -146,7 +146,7 @@ public void FlattenPredicateAlwaysTrue() 4, 5, }, - 6 + 6, }.AsTestingSequence(); source @@ -332,18 +332,18 @@ public void FlattenSelectorWithTree() .AssertSequenceEqual(Enumerable.Range(1, 7).Cast()); } - private class Series + private sealed class Series { public string Name { get; init; } = string.Empty; public Attribute[] Attributes { get; init; } = []; } - private class Attribute + private sealed class Attribute { public int[] Values { get; init; } = []; } - private class Tree( + private sealed class Tree( Tree? left, T value, Tree? right @@ -353,6 +353,6 @@ private class Tree( public readonly Tree? Left = left; public readonly Tree? Right = right; - public Tree(T value) : this(null, value, null) { } + public Tree(T value) : this(left: null, value, right: null) { } } } diff --git a/Tests/SuperLinq.Test/FoldTest.cs b/Tests/SuperLinq.Test/FoldTest.cs index da1605cd2..887d76768 100644 --- a/Tests/SuperLinq.Test/FoldTest.cs +++ b/Tests/SuperLinq.Test/FoldTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class FoldTest +public sealed class FoldTest { [Fact] public void FoldWithTooFewItems() diff --git a/Tests/SuperLinq.Test/ForEachTest.cs b/Tests/SuperLinq.Test/ForEachTest.cs index 1c970003f..ba8548c02 100644 --- a/Tests/SuperLinq.Test/ForEachTest.cs +++ b/Tests/SuperLinq.Test/ForEachTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ForEachTest +public sealed class ForEachTest { [Fact] public void ForEachWithSequence() diff --git a/Tests/SuperLinq.Test/FromTest.cs b/Tests/SuperLinq.Test/FromTest.cs index bb41ce4dd..582c5ab8c 100644 --- a/Tests/SuperLinq.Test/FromTest.cs +++ b/Tests/SuperLinq.Test/FromTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class FromTest +public sealed class FromTest { [Fact] public void TestFromIsLazy() diff --git a/Tests/SuperLinq.Test/FullGroupJoinTest.cs b/Tests/SuperLinq.Test/FullGroupJoinTest.cs index 7c061f7f2..9a4bdca01 100644 --- a/Tests/SuperLinq.Test/FullGroupJoinTest.cs +++ b/Tests/SuperLinq.Test/FullGroupJoinTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class FullGroupJoinTest +public sealed class FullGroupJoinTest { public enum OverloadCase { CustomResult, TupleResult } diff --git a/Tests/SuperLinq.Test/FullOuterJoinTest.cs b/Tests/SuperLinq.Test/FullOuterJoinTest.cs index 3d4615332..af87d0997 100644 --- a/Tests/SuperLinq.Test/FullOuterJoinTest.cs +++ b/Tests/SuperLinq.Test/FullOuterJoinTest.cs @@ -4,7 +4,7 @@ namespace Test; public enum JoinOperation { None, Loop, Hash, Merge, } -public class FullOuterJoinTest +public sealed class FullOuterJoinTest { private static IEnumerable<((string, string) Left, (string, string) Right)> ExecuteJoin( IEnumerable<(string, string)> left, diff --git a/Tests/SuperLinq.Test/GenerateTest.cs b/Tests/SuperLinq.Test/GenerateTest.cs index 25ff4360f..540f3e512 100644 --- a/Tests/SuperLinq.Test/GenerateTest.cs +++ b/Tests/SuperLinq.Test/GenerateTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class GenerateTest +public sealed class GenerateTest { [Fact] public void GenerateTerminatesWhenCheckReturnsFalse() diff --git a/Tests/SuperLinq.Test/GetShortestPathTest.cs b/Tests/SuperLinq.Test/GetShortestPathTest.cs index 5d8edfb65..8dac7681a 100644 --- a/Tests/SuperLinq.Test/GetShortestPathTest.cs +++ b/Tests/SuperLinq.Test/GetShortestPathTest.cs @@ -42,7 +42,7 @@ internal static void VerifySequences(this List> list) s.Dispose(); } - public class Dijkstra + public sealed class Dijkstra { public static IEnumerable GetStringIntCostData { get; } = [ @@ -345,7 +345,7 @@ public void InvalidMapThrowsException() } } - public class AStar + public sealed class AStar { public static IEnumerable GetStringIntCostData { get; } = [ diff --git a/Tests/SuperLinq.Test/GroupAdjacentTest.cs b/Tests/SuperLinq.Test/GroupAdjacentTest.cs index 28f731439..441524cca 100644 --- a/Tests/SuperLinq.Test/GroupAdjacentTest.cs +++ b/Tests/SuperLinq.Test/GroupAdjacentTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class GroupAdjacentTest +public sealed class GroupAdjacentTest { [Fact] public void GroupAdjacentIsLazy() diff --git a/Tests/SuperLinq.Test/HasDuplicatesTest.cs b/Tests/SuperLinq.Test/HasDuplicatesTest.cs index 10ee1d5cf..dd6d2f4a7 100644 --- a/Tests/SuperLinq.Test/HasDuplicatesTest.cs +++ b/Tests/SuperLinq.Test/HasDuplicatesTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class HasDuplicatesTest +public sealed class HasDuplicatesTest { [Fact] public void DuplicatesDoesNotEnumerateUnnecessarily() diff --git a/Tests/SuperLinq.Test/IfTest.cs b/Tests/SuperLinq.Test/IfTest.cs index d46faafde..c7ddaa202 100644 --- a/Tests/SuperLinq.Test/IfTest.cs +++ b/Tests/SuperLinq.Test/IfTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class IfTest +public sealed class IfTest { [Fact] public void IfIsLazy() diff --git a/Tests/SuperLinq.Test/IndexByTest.cs b/Tests/SuperLinq.Test/IndexByTest.cs index de817053c..c300bdd0f 100644 --- a/Tests/SuperLinq.Test/IndexByTest.cs +++ b/Tests/SuperLinq.Test/IndexByTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class IndexByTest +public sealed class IndexByTest { [Fact] public void IndexBySimpleTest() diff --git a/Tests/SuperLinq.Test/IndexOfTest.cs b/Tests/SuperLinq.Test/IndexOfTest.cs index a90305989..e65b1d4d4 100644 --- a/Tests/SuperLinq.Test/IndexOfTest.cs +++ b/Tests/SuperLinq.Test/IndexOfTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class IndexOfTest +public sealed class IndexOfTest { [Fact] public void IndexOfWithNegativeCount() diff --git a/Tests/SuperLinq.Test/IndexTest.cs b/Tests/SuperLinq.Test/IndexTest.cs index e62e493f2..ae26c3b6f 100644 --- a/Tests/SuperLinq.Test/IndexTest.cs +++ b/Tests/SuperLinq.Test/IndexTest.cs @@ -1,7 +1,7 @@ namespace Test; [Obsolete("References `Index` which is obsolete in net9+")] -public class IndexTest +public sealed class IndexTest { [Fact] public void IndexIsLazy() diff --git a/Tests/SuperLinq.Test/InnerJoinTest.cs b/Tests/SuperLinq.Test/InnerJoinTest.cs index 5604bf39f..260d642ec 100644 --- a/Tests/SuperLinq.Test/InnerJoinTest.cs +++ b/Tests/SuperLinq.Test/InnerJoinTest.cs @@ -2,7 +2,7 @@ namespace Test; -public class InnerJoinTest +public sealed class InnerJoinTest { private static IEnumerable<((string, string) Left, (string, string) Right)> ExecuteJoin( IEnumerable<(string, string)> left, diff --git a/Tests/SuperLinq.Test/InsertTest.cs b/Tests/SuperLinq.Test/InsertTest.cs index 21ec8da1a..3eea0f3ba 100644 --- a/Tests/SuperLinq.Test/InsertTest.cs +++ b/Tests/SuperLinq.Test/InsertTest.cs @@ -2,7 +2,7 @@ namespace Test; -public class InsertTest +public sealed class InsertTest { [Fact] public void InsertIsLazy() diff --git a/Tests/SuperLinq.Test/InterleaveTest.cs b/Tests/SuperLinq.Test/InterleaveTest.cs index 948d48893..17dc52d06 100644 --- a/Tests/SuperLinq.Test/InterleaveTest.cs +++ b/Tests/SuperLinq.Test/InterleaveTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the Interleave operator /// -public class InterleaveTest +public sealed class InterleaveTest { /// /// Verify that Interleave behaves in a lazy manner diff --git a/Tests/SuperLinq.Test/LagTest.cs b/Tests/SuperLinq.Test/LagTest.cs index 286f8f748..285e73a51 100644 --- a/Tests/SuperLinq.Test/LagTest.cs +++ b/Tests/SuperLinq.Test/LagTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the Lag operator /// -public class LagTest +public sealed class LagTest { /// /// Verify that lag behaves in a lazy manner. diff --git a/Tests/SuperLinq.Test/LastIndexOfTest.cs b/Tests/SuperLinq.Test/LastIndexOfTest.cs index 8493fabf0..5263d03a0 100644 --- a/Tests/SuperLinq.Test/LastIndexOfTest.cs +++ b/Tests/SuperLinq.Test/LastIndexOfTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class LastIndexOfTest +public sealed class LastIndexOfTest { [Fact] public void LastIndexOfWithNegativeCount() diff --git a/Tests/SuperLinq.Test/LeadTest.cs b/Tests/SuperLinq.Test/LeadTest.cs index f891e0b0f..6b04bc235 100644 --- a/Tests/SuperLinq.Test/LeadTest.cs +++ b/Tests/SuperLinq.Test/LeadTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the Lead operator. /// -public class LeadTest +public sealed class LeadTest { /// /// Verify that Lead() behaves in a lazy manner. diff --git a/Tests/SuperLinq.Test/LeftOuterJoin.cs b/Tests/SuperLinq.Test/LeftOuterJoin.cs index df19a7d8e..1963ac96c 100644 --- a/Tests/SuperLinq.Test/LeftOuterJoin.cs +++ b/Tests/SuperLinq.Test/LeftOuterJoin.cs @@ -2,7 +2,7 @@ namespace Test; -public class LeftOuterJoinTest +public sealed class LeftOuterJoinTest { private static IEnumerable<((string, string) Left, (string, string) Right)> ExecuteJoin( IEnumerable<(string, string)> left, diff --git a/Tests/SuperLinq.Test/MaxItemsTest.cs b/Tests/SuperLinq.Test/MaxItemsTest.cs index 7b1796a6e..fa1763222 100644 --- a/Tests/SuperLinq.Test/MaxItemsTest.cs +++ b/Tests/SuperLinq.Test/MaxItemsTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class MaxItemsTest +public sealed class MaxItemsTest { [Fact] public void MaxItemsIsLazy() diff --git a/Tests/SuperLinq.Test/MemoizeTest.cs b/Tests/SuperLinq.Test/MemoizeTest.cs index 0eac94c0f..7b71f3554 100644 --- a/Tests/SuperLinq.Test/MemoizeTest.cs +++ b/Tests/SuperLinq.Test/MemoizeTest.cs @@ -1,9 +1,9 @@ -using System.Collections; +using System.Collections; using CommunityToolkit.Diagnostics; namespace Test; -public class MemoizeTest +public sealed class MemoizeTest { [Fact] public void MemoizeIsLazy() @@ -306,7 +306,7 @@ public void MemoizeIteratorRethrowsErrorDuringFirstIterationStartToAllIterations Assert.Equal(1, buffer.Count); } - private class FailingEnumerable : IEnumerable + private sealed class FailingEnumerable : IEnumerable { private bool _started; public IEnumerator GetEnumerator() @@ -381,7 +381,7 @@ public void MemoizeCollectionRethrowsErrorDuringFirstIterationStartToAllIteratio Assert.Equal(1, ts.CopyCount); } - private class FailingCollection : BreakingCollection + private sealed class FailingCollection : BreakingCollection { public FailingCollection() : base(1) { } @@ -449,7 +449,7 @@ public void MemoizeProxyReturnsCollectionIteratorDirectly() Assert.Equal(42, memo.Count); } - private class ProxyCollection( + private sealed class ProxyCollection( Func> enumeratorFunc, Func countFunc ) : ICollection @@ -462,7 +462,7 @@ Func countFunc public bool Remove(int item) => throw new TestException(); public bool IsReadOnly => true; - public virtual void CopyTo(int[] array, int arrayIndex) => throw new TestException(); + public void CopyTo(int[] array, int arrayIndex) => throw new TestException(); public IEnumerator GetEnumerator() => enumeratorFunc(); IEnumerator IEnumerable.GetEnumerator() => enumeratorFunc(); diff --git a/Tests/SuperLinq.Test/MinItemsTest.cs b/Tests/SuperLinq.Test/MinItemsTest.cs index 982c6940e..e61a9388f 100644 --- a/Tests/SuperLinq.Test/MinItemsTest.cs +++ b/Tests/SuperLinq.Test/MinItemsTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class MinItemsTest +public sealed class MinItemsTest { [Fact] public void MinItemsIsLazy() diff --git a/Tests/SuperLinq.Test/MoveTest.cs b/Tests/SuperLinq.Test/MoveTest.cs index 5bb076c19..590946d61 100644 --- a/Tests/SuperLinq.Test/MoveTest.cs +++ b/Tests/SuperLinq.Test/MoveTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class MoveTest +public sealed class MoveTest { [Fact] public void MoveWithNegativeFromIndex() diff --git a/Tests/SuperLinq.Test/NullArgumentTest.cs b/Tests/SuperLinq.Test/NullArgumentTest.cs index 3def68f5f..9e773a364 100644 --- a/Tests/SuperLinq.Test/NullArgumentTest.cs +++ b/Tests/SuperLinq.Test/NullArgumentTest.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; @@ -7,7 +7,7 @@ namespace Test; -public class NullArgumentTest +public sealed class NullArgumentTest { [Theory, MemberData(nameof(GetNotNullInlineDatas))] public void NotNull(Action inlineData) => @@ -39,8 +39,7 @@ public static IEnumerable GetCanBeNullInlineDatas() => } catch (TargetInvocationException tie) { - Assert.False(tie.InnerException != null - && tie.InnerException is ArgumentNullException ane + Assert.False(tie.InnerException is not null && tie.InnerException is ArgumentNullException ane && ane.ParamName != paramName); } }); @@ -52,7 +51,7 @@ public static IEnumerable GetCanBeNullInlineDatas() => private static IEnumerable GetInlineDatas(bool canBeNull, Func inlineDataFactory) => from m in typeof(SuperEnumerable).GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly) - where !s_skipMethods.Contains(m.Name) + where !s_skipMethods.Contains(m.Name, StringComparer.Ordinal) from t in CreateInlineDatas(m, canBeNull, inlineDataFactory) select t; @@ -101,7 +100,7 @@ Type InstantiateType(TypeInfo typeParameter) if (constraints.Length == 0) { - return s_joinMethods.Contains(definition.Name) + return s_joinMethods.Contains(definition.Name, StringComparer.Ordinal) ? typeof(string) : typeof(int); } @@ -117,7 +116,7 @@ Type InstantiateType(TypeInfo typeParameter) return typeof(StringComparer); } - throw new NotImplementedException("NullArgumentTest.InstantiateType"); + throw new UnreachableException("NullArgumentTest.InstantiateType"); } } @@ -180,14 +179,14 @@ private static object CreateGenericInterfaceInstance(TypeInfo type) return Activator.CreateInstance(instantiation)!; } - private class Disposable : IDisposable + private sealed class Disposable : IDisposable { public void Dispose() { } } private static class EmptyEnumerable { - public static readonly IEnumerable Instance = new Enumerable(); + public static IEnumerable Instance { get; } = new Enumerable(); private sealed class Enumerable : IEnumerable { @@ -204,7 +203,7 @@ public void Reset() { } private static class GenericArgs { - private class Enumerator : IEnumerator + private sealed class Enumerator : IEnumerator { public bool MoveNext() => false; public T Current { get; private set; } = default!; @@ -219,7 +218,7 @@ public class Enumerable : IEnumerable IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } - public class OrderedEnumerable : Enumerable, IOrderedEnumerable + public sealed class OrderedEnumerable : Enumerable, IOrderedEnumerable { public IOrderedEnumerable CreateOrderedEnumerable(Func keySelector, IComparer? comparer, bool descending) { @@ -228,33 +227,33 @@ public IOrderedEnumerable CreateOrderedEnumerable(Func keySele } } - public class Dictionary : IDictionary + public sealed class Dictionary : IDictionary where TKey : notnull { - public TValue this[TKey key] { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) => throw new NotImplementedException(); - public ICollection Keys => throw new NotImplementedException(); - public ICollection Values => throw new NotImplementedException(); - public int Count => throw new NotImplementedException(); - public bool IsReadOnly => throw new NotImplementedException(); - public void Add(TKey key, TValue value) => throw new NotImplementedException(); - public void Add(KeyValuePair item) => throw new NotImplementedException(); - public void Clear() => throw new NotImplementedException(); - public bool Contains(KeyValuePair item) => throw new NotImplementedException(); - public bool ContainsKey(TKey key) => throw new NotImplementedException(); - public void CopyTo(KeyValuePair[] array, int arrayIndex) => throw new NotImplementedException(); - public IEnumerator> GetEnumerator() => throw new NotImplementedException(); - IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException(); - public bool Remove(TKey key) => throw new NotImplementedException(); - public bool Remove(KeyValuePair item) => throw new NotImplementedException(); + public TValue this[TKey key] { get => throw new NotSupportedException(); set => throw new NotSupportedException(); } + public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) => throw new NotSupportedException(); + public ICollection Keys => throw new NotSupportedException(); + public ICollection Values => throw new NotSupportedException(); + public int Count => throw new NotSupportedException(); + public bool IsReadOnly => throw new NotSupportedException(); + public void Add(TKey key, TValue value) => throw new NotSupportedException(); + public void Add(KeyValuePair item) => throw new NotSupportedException(); + public void Clear() => throw new NotSupportedException(); + public bool Contains(KeyValuePair item) => throw new NotSupportedException(); + public bool ContainsKey(TKey key) => throw new NotSupportedException(); + public void CopyTo(KeyValuePair[] array, int arrayIndex) => throw new NotSupportedException(); + public IEnumerator> GetEnumerator() => throw new NotSupportedException(); + IEnumerator IEnumerable.GetEnumerator() => throw new NotSupportedException(); + public bool Remove(TKey key) => throw new NotSupportedException(); + public bool Remove(KeyValuePair item) => throw new NotSupportedException(); } - public class Comparer : IComparer + public sealed class Comparer : IComparer { public int Compare(T? x, T? y) => -1; } - public class EqualityComparer : IEqualityComparer + public sealed class EqualityComparer : IEqualityComparer { public bool Equals(T? x, T? y) => false; public int GetHashCode(T obj) => 0; diff --git a/Tests/SuperLinq.Test/OnErrorResumeNextTest.cs b/Tests/SuperLinq.Test/OnErrorResumeNextTest.cs index 876598072..c1b31fcb5 100644 --- a/Tests/SuperLinq.Test/OnErrorResumeNextTest.cs +++ b/Tests/SuperLinq.Test/OnErrorResumeNextTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class OnErrorResumeNextTest +public sealed class OnErrorResumeNextTest { [Fact] public void OnErrorResumeNextIsLazy() diff --git a/Tests/SuperLinq.Test/OrderByTest.cs b/Tests/SuperLinq.Test/OrderByTest.cs index b584603cf..41e2b2d97 100644 --- a/Tests/SuperLinq.Test/OrderByTest.cs +++ b/Tests/SuperLinq.Test/OrderByTest.cs @@ -1,9 +1,11 @@ -namespace Test; +using System.Globalization; + +namespace Test; /// /// Verify the behavior of the OrderBy/ThenBy operators /// -public class OrderByTests +public sealed class OrderByTests { /// /// Verify that OrderBy preserves the selector @@ -32,10 +34,13 @@ public void TestOrderBySelectorPreserved() public void TestOrderByComparerPreserved() { var sequence = Enumerable.Range(1, 100); - var sequenceAscending = sequence.Select(x => x.ToString()); + var sequenceAscending = sequence.Select(x => x.ToString(CultureInfo.InvariantCulture)); var sequenceDescending = sequenceAscending.Reverse(); - var comparer = Comparer.Create((a, b) => int.Parse(a).CompareTo(int.Parse(b))); + var comparer = Comparer.Create( + (a, b) => int.Parse(a, CultureInfo.InvariantCulture) + .CompareTo(int.Parse(b, CultureInfo.InvariantCulture)) + ); var resultAsc1 = sequenceAscending.OrderBy(SuperEnumerable.Identity, comparer, OrderByDirection.Descending); var resultAsc2 = sequenceAscending.OrderByDescending(SuperEnumerable.Identity, comparer); @@ -60,25 +65,33 @@ public void TestThenBySelectorPreserved() { var sequence = new[] { - new {A = 2, B = 0}, - new {A = 1, B = 5}, - new {A = 2, B = 2}, - new {A = 1, B = 3}, - new {A = 1, B = 4}, - new {A = 2, B = 1}, + new { A = 2, B = 0, }, + new { A = 1, B = 5, }, + new { A = 2, B = 2, }, + new { A = 1, B = 3, }, + new { A = 1, B = 4, }, + new { A = 2, B = 1, }, }; - var resultA1 = sequence.OrderBy(x => x.A, OrderByDirection.Ascending) - .ThenBy(y => y.B, OrderByDirection.Ascending); - var resultA2 = sequence.OrderBy(x => x.A) - .ThenBy(y => y.B); + var resultA1 = sequence + .OrderBy(x => x.A, OrderByDirection.Ascending) + .ThenBy(y => y.B, OrderByDirection.Ascending); + + var resultA2 = sequence + .OrderBy(x => x.A) + .ThenBy(y => y.B); + // ensure both produce the same order Assert.Equal(resultA2, resultA1); - var resultB1 = sequence.OrderBy(x => x.A, OrderByDirection.Ascending) - .ThenBy(y => y.B, OrderByDirection.Descending); - var resultB2 = sequence.OrderBy(x => x.A) - .ThenByDescending(y => y.B); + var resultB1 = sequence + .OrderBy(x => x.A, OrderByDirection.Ascending) + .ThenBy(y => y.B, OrderByDirection.Descending); + + var resultB2 = sequence + .OrderBy(x => x.A) + .ThenByDescending(y => y.B); + // ensure both produce the same order Assert.Equal(resultB2, resultB1); } @@ -99,19 +112,30 @@ public void TestThenByComparerPreserved() new { A = "2", B = "1", }, }; - var comparer = Comparer.Create((a, b) => int.Parse(a).CompareTo(int.Parse(b))); + var comparer = Comparer.Create( + (a, b) => int.Parse(a, CultureInfo.InvariantCulture) + .CompareTo(int.Parse(b, CultureInfo.InvariantCulture)) + ); + + var resultA1 = sequence + .OrderBy(x => x.A, comparer, OrderByDirection.Ascending) + .ThenBy(y => y.B, comparer, OrderByDirection.Ascending); + + var resultA2 = sequence + .OrderBy(x => x.A, comparer) + .ThenBy(y => y.B, comparer); - var resultA1 = sequence.OrderBy(x => x.A, comparer, OrderByDirection.Ascending) - .ThenBy(y => y.B, comparer, OrderByDirection.Ascending); - var resultA2 = sequence.OrderBy(x => x.A, comparer) - .ThenBy(y => y.B, comparer); // ensure both produce the same order Assert.Equal(resultA2, resultA1); - var resultB1 = sequence.OrderBy(x => x.A, comparer, OrderByDirection.Ascending) - .ThenBy(y => y.B, comparer, OrderByDirection.Descending); - var resultB2 = sequence.OrderBy(x => x.A, comparer) - .ThenByDescending(y => y.B, comparer); + var resultB1 = sequence + .OrderBy(x => x.A, comparer, OrderByDirection.Ascending) + .ThenBy(y => y.B, comparer, OrderByDirection.Descending); + + var resultB2 = sequence + .OrderBy(x => x.A, comparer) + .ThenByDescending(y => y.B, comparer); + // ensure both produce the same order Assert.Equal(resultB2, resultB1); } diff --git a/Tests/SuperLinq.Test/PadStartTest.cs b/Tests/SuperLinq.Test/PadStartTest.cs index 06ef28187..c9e996acf 100644 --- a/Tests/SuperLinq.Test/PadStartTest.cs +++ b/Tests/SuperLinq.Test/PadStartTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class PadStartTest +public sealed class PadStartTest { [Fact] public void PadStartNegativeWidth() diff --git a/Tests/SuperLinq.Test/PadTest.cs b/Tests/SuperLinq.Test/PadTest.cs index 7ade29c3c..ecdf7161c 100644 --- a/Tests/SuperLinq.Test/PadTest.cs +++ b/Tests/SuperLinq.Test/PadTest.cs @@ -1,6 +1,6 @@ -namespace Test; +namespace Test; -public class PadTest +public sealed class PadTest { [Fact] public void PadNegativeWidth() diff --git a/Tests/SuperLinq.Test/PartialSortByTest.cs b/Tests/SuperLinq.Test/PartialSortByTest.cs index 0b3456984..e4542c6a0 100644 --- a/Tests/SuperLinq.Test/PartialSortByTest.cs +++ b/Tests/SuperLinq.Test/PartialSortByTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class PartialSortByTests +public sealed class PartialSortByTests { [Fact] public void PartialSortBy() diff --git a/Tests/SuperLinq.Test/PartialSortTest.cs b/Tests/SuperLinq.Test/PartialSortTest.cs index c3c771bc5..ebb032453 100644 --- a/Tests/SuperLinq.Test/PartialSortTest.cs +++ b/Tests/SuperLinq.Test/PartialSortTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class PartialSortTests +public sealed class PartialSortTests { [Fact] public void PartialSort() diff --git a/Tests/SuperLinq.Test/PartitionTest.cs b/Tests/SuperLinq.Test/PartitionTest.cs index f6bd87918..9d03938e0 100644 --- a/Tests/SuperLinq.Test/PartitionTest.cs +++ b/Tests/SuperLinq.Test/PartitionTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class PartitionTest +public sealed class PartitionTest { [Fact] public void Partition() diff --git a/Tests/SuperLinq.Test/PermutationsTest.cs b/Tests/SuperLinq.Test/PermutationsTest.cs index 6534a9e8b..4c071e755 100644 --- a/Tests/SuperLinq.Test/PermutationsTest.cs +++ b/Tests/SuperLinq.Test/PermutationsTest.cs @@ -6,7 +6,7 @@ namespace Test; /// /// Tests that verify the behavior of the Permutations() operator. /// -public class PermutationsTest +public sealed class PermutationsTest { /// /// Verify that the permutation of the empty set is the empty set. diff --git a/Tests/SuperLinq.Test/PreScanTest.cs b/Tests/SuperLinq.Test/PreScanTest.cs index 537e3e35d..618d493b8 100644 --- a/Tests/SuperLinq.Test/PreScanTest.cs +++ b/Tests/SuperLinq.Test/PreScanTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class PreScanTest +public sealed class PreScanTest { [Fact] public void PreScanIsLazy() diff --git a/Tests/SuperLinq.Test/PublishTest.cs b/Tests/SuperLinq.Test/PublishTest.cs index 48a40d8cb..02549c473 100644 --- a/Tests/SuperLinq.Test/PublishTest.cs +++ b/Tests/SuperLinq.Test/PublishTest.cs @@ -3,7 +3,7 @@ namespace Test; -public class PublishTest +public sealed class PublishTest { [Fact] public void PublishIsLazy() @@ -273,7 +273,7 @@ public void PublishRethrowsErrorDuringFirstIterationStartToAllIterationsUntilRes buffer.AssertSequenceEqual(1); } - private class FailingEnumerable : IEnumerable + private sealed class FailingEnumerable : IEnumerable { private bool _started; public IEnumerator GetEnumerator() diff --git a/Tests/SuperLinq.Test/RandomSubsetTest.cs b/Tests/SuperLinq.Test/RandomSubsetTest.cs index 4dcd2031c..425040025 100644 --- a/Tests/SuperLinq.Test/RandomSubsetTest.cs +++ b/Tests/SuperLinq.Test/RandomSubsetTest.cs @@ -3,7 +3,7 @@ /// /// Tests that verify the behavior of the RandomSubset() operator /// -public class RandomSubsetTest +public sealed class RandomSubsetTest { /// /// Verify that RandomSubset() behaves in a lazy manner. diff --git a/Tests/SuperLinq.Test/RandomTest.cs b/Tests/SuperLinq.Test/RandomTest.cs index 5a7ae035a..f5f524626 100644 --- a/Tests/SuperLinq.Test/RandomTest.cs +++ b/Tests/SuperLinq.Test/RandomTest.cs @@ -3,7 +3,7 @@ /// /// Tests of the various overloads of .Random() /// -public class RandomTest +public sealed class RandomTest { private const int RandomTrials = 10000; diff --git a/Tests/SuperLinq.Test/RankTest.cs b/Tests/SuperLinq.Test/RankTest.cs index e39f1b170..b5a65bd8f 100644 --- a/Tests/SuperLinq.Test/RankTest.cs +++ b/Tests/SuperLinq.Test/RankTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class RankTests +public sealed class RankTests { /// /// Verify that Rank uses deferred execution diff --git a/Tests/SuperLinq.Test/RepeatTest.cs b/Tests/SuperLinq.Test/RepeatTest.cs index d0e87d152..4ef628847 100644 --- a/Tests/SuperLinq.Test/RepeatTest.cs +++ b/Tests/SuperLinq.Test/RepeatTest.cs @@ -1,6 +1,6 @@ -namespace Test; +namespace Test; -public class RepeatTest +public sealed class RepeatTest { [Theory] [InlineData(1)] diff --git a/Tests/SuperLinq.Test/ReplaceTest.cs b/Tests/SuperLinq.Test/ReplaceTest.cs index 453015e40..ecea6ab8f 100644 --- a/Tests/SuperLinq.Test/ReplaceTest.cs +++ b/Tests/SuperLinq.Test/ReplaceTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ReplaceTest +public sealed class ReplaceTest { [Fact] public void ReplaceIsLazy() diff --git a/Tests/SuperLinq.Test/RetryTest.cs b/Tests/SuperLinq.Test/RetryTest.cs index 3196177fe..563bb7aaa 100644 --- a/Tests/SuperLinq.Test/RetryTest.cs +++ b/Tests/SuperLinq.Test/RetryTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class RetryTest +public sealed class RetryTest { [Fact] public void RetryIsLazy() diff --git a/Tests/SuperLinq.Test/ReturnTest.cs b/Tests/SuperLinq.Test/ReturnTest.cs index f76eca4a9..47dc74aa4 100644 --- a/Tests/SuperLinq.Test/ReturnTest.cs +++ b/Tests/SuperLinq.Test/ReturnTest.cs @@ -1,19 +1,19 @@ namespace Test; -public class ReturnTest +public sealed class ReturnTest { private static class SomeSingleton { - public static readonly object Item = new(); - public static readonly IEnumerable Sequence = SuperEnumerable.Return(Item); + public static object Item { get; } = new(); + public static IEnumerable Sequence { get; } = SuperEnumerable.Return(Item); public static IList List => (IList)Sequence; public static ICollection Collection => (ICollection)Sequence; } private static class NullSingleton { - public static readonly IEnumerable Sequence = SuperEnumerable.Return(null); - public static IList List => (IList)Sequence; + private static readonly IEnumerable s_sequence = SuperEnumerable.Return(item: null); + public static IList List => (IList)s_sequence; } [Fact] diff --git a/Tests/SuperLinq.Test/RightOuterJoin.cs b/Tests/SuperLinq.Test/RightOuterJoin.cs index 5f114fd39..5d3f384df 100644 --- a/Tests/SuperLinq.Test/RightOuterJoin.cs +++ b/Tests/SuperLinq.Test/RightOuterJoin.cs @@ -2,7 +2,7 @@ namespace Test; -public class RightOuterJoinTest +public sealed class RightOuterJoinTest { private static IEnumerable<((string, string) Left, (string, string) Right)> ExecuteJoin( IEnumerable<(string, string)> left, diff --git a/Tests/SuperLinq.Test/RunLengthEncodeTest.cs b/Tests/SuperLinq.Test/RunLengthEncodeTest.cs index 9a3ef60e4..299351007 100644 --- a/Tests/SuperLinq.Test/RunLengthEncodeTest.cs +++ b/Tests/SuperLinq.Test/RunLengthEncodeTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the RunLengthEncode() operator /// -public class RunLengthEncodeTests +public sealed class RunLengthEncodeTests { /// /// Verify that the RunLengthEncode() methods behave in a lazy manner. diff --git a/Tests/SuperLinq.Test/ScanByTest.cs b/Tests/SuperLinq.Test/ScanByTest.cs index aecebe600..617c4d195 100644 --- a/Tests/SuperLinq.Test/ScanByTest.cs +++ b/Tests/SuperLinq.Test/ScanByTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ScanByTest +public sealed class ScanByTest { [Fact] public void ScanByIsLazy() diff --git a/Tests/SuperLinq.Test/ScanRightTest.cs b/Tests/SuperLinq.Test/ScanRightTest.cs index 015dbb7db..af18c06bc 100644 --- a/Tests/SuperLinq.Test/ScanRightTest.cs +++ b/Tests/SuperLinq.Test/ScanRightTest.cs @@ -1,6 +1,8 @@ -namespace Test; +using System.Globalization; -public class ScanRightTest +namespace Test; + +public sealed class ScanRightTest { // ScanRight(source, func) @@ -26,11 +28,11 @@ public void ScanRightFuncIsNotInvokedOnSingleElementSequence() public void ScanRight() { using var seq = Enumerable.Range(1, 5) - .Select(x => x.ToString()) + .Select(x => x.ToString(CultureInfo.InvariantCulture)) .AsTestingSequence(); var result = seq - .ScanRight((a, b) => string.Format("({0}+{1})", a, b)); + .ScanRight((a, b) => FormattableString.Invariant($"({a}+{b})")); result.AssertSequenceEqual( "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5"); @@ -40,11 +42,11 @@ public void ScanRight() public void ScanRightWithList() { var list = Enumerable.Range(1, 5) - .Select(x => x.ToString()) + .Select(x => x.ToString(CultureInfo.InvariantCulture)) .ToList(); var result = list - .ScanRight((a, b) => string.Format("({0}+{1})", a, b)); + .ScanRight((a, b) => FormattableString.Invariant($"({a}+{b})")); result.AssertSequenceEqual( "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5"); @@ -85,7 +87,7 @@ public void ScanRightSeed() using var seq = Enumerable.Range(1, 4).AsTestingSequence(); var result = seq - .ScanRight("5", (a, b) => string.Format("({0}+{1})", a, b)); + .ScanRight("5", (a, b) => FormattableString.Invariant($"({a}+{b})")); result.AssertSequenceEqual( "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5"); @@ -97,7 +99,7 @@ public void ScanRightSeedWithList() var list = Enumerable.Range(1, 4).ToList(); var result = list - .ScanRight("5", (a, b) => string.Format("({0}+{1})", a, b)); + .ScanRight("5", (a, b) => FormattableString.Invariant($"({a}+{b})")); result.AssertSequenceEqual( "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5"); diff --git a/Tests/SuperLinq.Test/ScanTest.cs b/Tests/SuperLinq.Test/ScanTest.cs index 7bd71c0da..bd99f3bb5 100644 --- a/Tests/SuperLinq.Test/ScanTest.cs +++ b/Tests/SuperLinq.Test/ScanTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ScanTest +public sealed class ScanTest { [Fact] public void ScanEmpty() diff --git a/Tests/SuperLinq.Test/SegmentTest.cs b/Tests/SuperLinq.Test/SegmentTest.cs index da4280291..4541b1338 100644 --- a/Tests/SuperLinq.Test/SegmentTest.cs +++ b/Tests/SuperLinq.Test/SegmentTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the Segment operator /// -public class SegmentTests +public sealed class SegmentTests { /// /// Verify that the Segment operator behaves in a lazy manner @@ -117,7 +117,7 @@ public void VerifyCanSegmentByPrevious() Assert.True(result.All(s => s.Count == 5)); } - public static readonly IEnumerable TestData = + public static IEnumerable TestData { get; } = from e in new[] { // input sequence is empty diff --git a/Tests/SuperLinq.Test/SequenceReader.cs b/Tests/SuperLinq.Test/SequenceReader.cs index ddbb2aa4a..032d9f696 100644 --- a/Tests/SuperLinq.Test/SequenceReader.cs +++ b/Tests/SuperLinq.Test/SequenceReader.cs @@ -78,7 +78,7 @@ public void ReadEnd() [MemberNotNull(nameof(_enumerator))] private void EnsureNotDisposed() { - if (_enumerator == null) + if (_enumerator is null) Assert.Fail("Sequence was disposed before completing."); } @@ -88,7 +88,7 @@ private void EnsureNotDisposed() public void Dispose() { var e = _enumerator; - if (e == null) return; + if (e is null) return; _enumerator = null; e.Dispose(); } diff --git a/Tests/SuperLinq.Test/SequenceTest.cs b/Tests/SuperLinq.Test/SequenceTest.cs index b77dc3f49..0869b9570 100644 --- a/Tests/SuperLinq.Test/SequenceTest.cs +++ b/Tests/SuperLinq.Test/SequenceTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class SequenceTest +public sealed class SequenceTest { [Theory] [InlineData(65600, 65536, 65536)] diff --git a/Tests/SuperLinq.Test/ShareTest.cs b/Tests/SuperLinq.Test/ShareTest.cs index 8733c6d16..b7c2a7863 100644 --- a/Tests/SuperLinq.Test/ShareTest.cs +++ b/Tests/SuperLinq.Test/ShareTest.cs @@ -3,7 +3,7 @@ namespace Test; -public class ShareTest +public sealed class ShareTest { [Fact] public void ShareIsLazy() @@ -244,7 +244,7 @@ public void ShareRethrowsErrorDuringFirstIterationStartToAllIterationsUntilReset buffer.AssertSequenceEqual(1); } - private class FailingEnumerable : IEnumerable + private sealed class FailingEnumerable : IEnumerable { private bool _started; public IEnumerator GetEnumerator() diff --git a/Tests/SuperLinq.Test/ShuffleTest.cs b/Tests/SuperLinq.Test/ShuffleTest.cs index a2ab54c8a..52a71750c 100644 --- a/Tests/SuperLinq.Test/ShuffleTest.cs +++ b/Tests/SuperLinq.Test/ShuffleTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ShuffleTest +public sealed class ShuffleTest { private static readonly Random s_seed = new(12345); diff --git a/Tests/SuperLinq.Test/SkipUntilTest.cs b/Tests/SuperLinq.Test/SkipUntilTest.cs index 251978612..de7d555ec 100644 --- a/Tests/SuperLinq.Test/SkipUntilTest.cs +++ b/Tests/SuperLinq.Test/SkipUntilTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class SkipUntilTest +public sealed class SkipUntilTest { [Fact] public void SkipUntilPredicateNeverFalse() @@ -48,7 +48,7 @@ public void SkipUntilEvaluatesPredicateLazily() .AssertSequenceEqual(0, 1, 2); } - public static readonly IEnumerable TestData = + public static IEnumerable TestData { get; } = [ [Array.Empty(), 0, Array.Empty()], // empty sequence [new[] { 0 }, 0, Array.Empty()], // one-item sequence, predicate succeed diff --git a/Tests/SuperLinq.Test/SliceTest.cs b/Tests/SuperLinq.Test/SliceTest.cs index fffd7b3bc..99d647af7 100644 --- a/Tests/SuperLinq.Test/SliceTest.cs +++ b/Tests/SuperLinq.Test/SliceTest.cs @@ -3,7 +3,7 @@ /// /// Verify the behavior of the Slice operator /// -public class SliceTests +public sealed class SliceTests { /// /// Verify that Slice evaluates in a lazy manner. diff --git a/Tests/SuperLinq.Test/SortedMergeByTest.cs b/Tests/SuperLinq.Test/SortedMergeByTest.cs index b38e0e653..30aea3fcf 100644 --- a/Tests/SuperLinq.Test/SortedMergeByTest.cs +++ b/Tests/SuperLinq.Test/SortedMergeByTest.cs @@ -3,7 +3,7 @@ /// /// Tests that verify the behavior of the SortedMergeBy operator. /// -public class SortedMergeByTests +public sealed class SortedMergeByTests { /// /// Verify that SortedMergeBy behaves in a lazy manner. diff --git a/Tests/SuperLinq.Test/SortedMergeTest.cs b/Tests/SuperLinq.Test/SortedMergeTest.cs index c2fd4c324..53020c93c 100644 --- a/Tests/SuperLinq.Test/SortedMergeTest.cs +++ b/Tests/SuperLinq.Test/SortedMergeTest.cs @@ -3,7 +3,7 @@ /// /// Tests that verify the behavior of the SortedMerge operator. /// -public class SortedMergeTests +public sealed class SortedMergeTests { /// /// Verify that SortedMerge behaves in a lazy manner. diff --git a/Tests/SuperLinq.Test/SplitTest.cs b/Tests/SuperLinq.Test/SplitTest.cs index c45770865..5ff26c0f8 100644 --- a/Tests/SuperLinq.Test/SplitTest.cs +++ b/Tests/SuperLinq.Test/SplitTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class SplitTest +public sealed class SplitTest { [Fact] public void SplitIsLazy() @@ -45,7 +45,7 @@ public void SplitUptoMaxCount() public void SplitWithSeparatorSelector() { using var sequence = TestingSequence.Of(1, 2, null, 3, null, 4, 5, 6); - var result = sequence.Split(n => n == null); + var result = sequence.Split(n => n is null); using var reader = result.Read(); reader.Read().AssertSequenceEqual(1, 2); @@ -58,7 +58,7 @@ public void SplitWithSeparatorSelector() public void SplitWithSeparatorSelectorUptoMaxCount() { using var sequence = TestingSequence.Of(1, 2, null, 3, null, 4, 5, 6); - var result = sequence.Split(n => n == null, 1); + var result = sequence.Split(n => n is null, 1); using var reader = result.Read(); reader.Read().AssertSequenceEqual(1, 2); diff --git a/Tests/SuperLinq.Test/StartsWithTest.cs b/Tests/SuperLinq.Test/StartsWithTest.cs index 03453bd50..dc4a2deed 100644 --- a/Tests/SuperLinq.Test/StartsWithTest.cs +++ b/Tests/SuperLinq.Test/StartsWithTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class StartsWithTest +public sealed class StartsWithTest { [Theory] [InlineData(new[] { 1, 2, 3 }, new[] { 1, 2 }, true)] @@ -73,7 +73,7 @@ public void StartsWithUsesSpecifiedEqualityComparerOrDefault() var first = Seq(1, 2, 3); var second = Seq(4, 5, 6); - Assert.False(first.StartsWith(second, null)); + Assert.False(first.StartsWith(second, comparer: null)); Assert.False(first.StartsWith(second, EqualityComparer.Create(delegate { return false; }))); Assert.True(first.StartsWith(second, EqualityComparer.Create(delegate { return true; }))); } diff --git a/Tests/SuperLinq.Test/SubsetTest.cs b/Tests/SuperLinq.Test/SubsetTest.cs index 465e1844b..9f4bd606d 100644 --- a/Tests/SuperLinq.Test/SubsetTest.cs +++ b/Tests/SuperLinq.Test/SubsetTest.cs @@ -3,7 +3,7 @@ /// /// Tests of the Subset() family of extension methods. /// -public class SubsetTest +public sealed class SubsetTest { /// /// Verify that Subsets() behaves in a lazy manner. @@ -116,7 +116,7 @@ public void TestAllSubsetsExpectedResults() [1], [2], [3], [4], [1,2], [1,3], [1,4], [2,3], [2,4], [3,4], [1,2,3], [1,2,4], [1,3,4], [2,3,4], - [1,2,3,4] + [1,2,3,4], }; foreach (var (actual, expected) in result.Zip(expectedSubsets)) diff --git a/Tests/SuperLinq.Test/SuperLinq.Test.csproj b/Tests/SuperLinq.Test/SuperLinq.Test.csproj index 94d0bd12e..b2b7302ae 100644 --- a/Tests/SuperLinq.Test/SuperLinq.Test.csproj +++ b/Tests/SuperLinq.Test/SuperLinq.Test.csproj @@ -13,8 +13,6 @@ - - diff --git a/Tests/SuperLinq.Test/TagFirstLastTest.cs b/Tests/SuperLinq.Test/TagFirstLastTest.cs index 3ba672ecb..edbec2de0 100644 --- a/Tests/SuperLinq.Test/TagFirstLastTest.cs +++ b/Tests/SuperLinq.Test/TagFirstLastTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class TagFirstLastTest +public sealed class TagFirstLastTest { [Fact] public void TagFirstLastIsLazy() diff --git a/Tests/SuperLinq.Test/TakeEveryTest.cs b/Tests/SuperLinq.Test/TakeEveryTest.cs index 3ee26514c..78f894b33 100644 --- a/Tests/SuperLinq.Test/TakeEveryTest.cs +++ b/Tests/SuperLinq.Test/TakeEveryTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class TakeEveryTest +public sealed class TakeEveryTest { [Fact] public void TakeEveryIsLazy() diff --git a/Tests/SuperLinq.Test/TakeTest.cs b/Tests/SuperLinq.Test/TakeTest.cs index b45c372a7..32760932b 100644 --- a/Tests/SuperLinq.Test/TakeTest.cs +++ b/Tests/SuperLinq.Test/TakeTest.cs @@ -3,7 +3,7 @@ namespace Test; -public class TakeTest +public sealed class TakeTest { #if !NET60_OR_GREATER [Fact] @@ -268,23 +268,23 @@ public void ForcedToEnumeratorDoesNotEnumerate() var iterator1 = Enumerable.Range(0, 3).Take(2); // Don't insist on this behaviour, but check it's correct if it happens var en1 = iterator1 as IEnumerator; - Assert.False(en1 != null && en1.MoveNext()); + Assert.False(en1 is not null && en1.MoveNext()); var iterator2 = Enumerable.Range(0, 3).Take(0..2); var en2 = iterator2 as IEnumerator; - Assert.False(en2 != null && en2.MoveNext()); + Assert.False(en2 is not null && en2.MoveNext()); var iterator3 = Enumerable.Range(0, 3).Take(^3..2); var en3 = iterator3 as IEnumerator; - Assert.False(en3 != null && en3.MoveNext()); + Assert.False(en3 is not null && en3.MoveNext()); var iterator4 = Enumerable.Range(0, 3).Take(0..^1); var en4 = iterator4 as IEnumerator; - Assert.False(en4 != null && en4.MoveNext()); + Assert.False(en4 is not null && en4.MoveNext()); var iterator5 = Enumerable.Range(0, 3).Take(^3..^1); var en5 = iterator5 as IEnumerator; - Assert.False(en5 != null && en5.MoveNext()); + Assert.False(en5 is not null && en5.MoveNext()); } #pragma warning disable xUnit2013 // Do not use equality check to check for collection size. @@ -319,23 +319,23 @@ public void ForcedToEnumeratorDoesntEnumerateIList() var iterator1 = Enumerable.Range(0, 3).ToList().Take(2); // Don't insist on this behaviour, but check it's correct if it happens var en1 = iterator1 as IEnumerator; - Assert.False(en1 != null && en1.MoveNext()); + Assert.False(en1 is not null && en1.MoveNext()); var iterator2 = Enumerable.Range(0, 3).ToList().Take(0..2); var en2 = iterator2 as IEnumerator; - Assert.False(en2 != null && en2.MoveNext()); + Assert.False(en2 is not null && en2.MoveNext()); var iterator3 = Enumerable.Range(0, 3).ToList().Take(^3..2); var en3 = iterator3 as IEnumerator; - Assert.False(en3 != null && en3.MoveNext()); + Assert.False(en3 is not null && en3.MoveNext()); var iterator4 = Enumerable.Range(0, 3).ToList().Take(0..^1); var en4 = iterator4 as IEnumerator; - Assert.False(en4 != null && en4.MoveNext()); + Assert.False(en4 is not null && en4.MoveNext()); var iterator5 = Enumerable.Range(0, 3).ToList().Take(^3..^1); var en5 = iterator5 as IEnumerator; - Assert.False(en5 != null && en5.MoveNext()); + Assert.False(en5 is not null && en5.MoveNext()); } [Fact] diff --git a/Tests/SuperLinq.Test/TakeUntilTest.cs b/Tests/SuperLinq.Test/TakeUntilTest.cs index f0e811665..7c14e71b8 100644 --- a/Tests/SuperLinq.Test/TakeUntilTest.cs +++ b/Tests/SuperLinq.Test/TakeUntilTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class TakeUntilTest +public sealed class TakeUntilTest { [Fact] public void TakeUntilEvaluatesSourceLazily() diff --git a/Tests/SuperLinq.Test/TestingCollection.cs b/Tests/SuperLinq.Test/TestingCollection.cs index 67b97f939..d2272cc55 100644 --- a/Tests/SuperLinq.Test/TestingCollection.cs +++ b/Tests/SuperLinq.Test/TestingCollection.cs @@ -1,4 +1,4 @@ -using static Test.TestingSequence; +using static Test.TestingSequence; namespace Test; @@ -9,7 +9,7 @@ internal static TestingCollection AsTestingCollection( new(source as IList ?? source.ToList(), options, maxEnumerations); } -internal class TestingCollection : TestingSequence, ICollection +internal sealed class TestingCollection : TestingSequence, ICollection { private readonly ICollection _collection; @@ -29,7 +29,7 @@ internal TestingCollection( public bool IsReadOnly => true; public int CopyCount { get; private set; } - public virtual void CopyTo(T[] array, int arrayIndex) + public void CopyTo(T[] array, int arrayIndex) { _collection.CopyTo(array, arrayIndex); CopyCount++; diff --git a/Tests/SuperLinq.Test/TestingSequence.cs b/Tests/SuperLinq.Test/TestingSequence.cs index cc808f66c..03cd25454 100644 --- a/Tests/SuperLinq.Test/TestingSequence.cs +++ b/Tests/SuperLinq.Test/TestingSequence.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using CommunityToolkit.Diagnostics; @@ -15,8 +15,7 @@ internal static TestingSequence AsTestingSequence( this IEnumerable source, Options options = Options.None, int maxEnumerations = 1 - ) => source != null - ? new TestingSequence(source, options, maxEnumerations) + ) => source is not null ? new TestingSequence(source, options, maxEnumerations) : throw new ArgumentNullException(nameof(source)); internal static void AssertTestingSequence([DoesNotReturnIf(false)] bool expectation, string message, [CallerArgumentExpression(nameof(expectation))] string? expr = "") @@ -43,7 +42,7 @@ public enum Options } } -public class TestingSequenceException(string message) : Exception(message); +public sealed class TestingSequenceException(string message) : Exception(message); /// /// Sequence that asserts whether its iterator has been disposed @@ -93,16 +92,16 @@ public IEnumerator GetEnumerator() } else if (!_options.HasFlag(Options.AllowRepeatedDisposals)) { - AssertTestingSequence(false, TooManyDisposals); + AssertTestingSequence(expectation: false, TooManyDisposals); } }; var ended = false; enumerator.MoveNextCalled += (_, moved) => { - AssertTestingSequence(disposed == false, MoveNextPostDisposal); + AssertTestingSequence(disposed is false, MoveNextPostDisposal); if (!_options.HasFlag(Options.AllowRepeatedMoveNexts)) - AssertTestingSequence(ended == false, MoveNextPostEnumeration); + AssertTestingSequence(ended is false, MoveNextPostEnumeration); ended = !moved; MoveNextCallCount++; @@ -110,8 +109,8 @@ public IEnumerator GetEnumerator() enumerator.GetCurrentCalled += delegate { - AssertTestingSequence(disposed == false, CurrentPostDisposal); - AssertTestingSequence(ended == false, CurrentPostEnumeration); + AssertTestingSequence(disposed is false, CurrentPostDisposal); + AssertTestingSequence(ended is false, CurrentPostEnumeration); }; return enumerator; @@ -120,7 +119,7 @@ public IEnumerator GetEnumerator() IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } -public class TestingSequenceTest +public sealed class TestingSequenceTest { [Fact] public void TestingSequencePublicPropertiesTest() diff --git a/Tests/SuperLinq.Test/ThrowTest.cs b/Tests/SuperLinq.Test/ThrowTest.cs index 9a6455ea8..bbe5d068d 100644 --- a/Tests/SuperLinq.Test/ThrowTest.cs +++ b/Tests/SuperLinq.Test/ThrowTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ThrowTest +public sealed class ThrowTest { [Fact] public void ThrowIsLazy() diff --git a/Tests/SuperLinq.Test/ToArrayByIndexTest.cs b/Tests/SuperLinq.Test/ToArrayByIndexTest.cs index b907d1622..50c908320 100644 --- a/Tests/SuperLinq.Test/ToArrayByIndexTest.cs +++ b/Tests/SuperLinq.Test/ToArrayByIndexTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ToArrayByIndexTest +public sealed class ToArrayByIndexTest { [Theory] [InlineData(false, new int[0])] @@ -33,7 +33,7 @@ public void ToArrayByIndex(bool withLength, int[] indices) expected = expected.Replace(i, i); result.AssertSequenceEqual( - expected.Select(x => x == null ? null : new { Index = x.Value, })); + expected.Select(x => x is null ? null : new { Index = x.Value, })); } [Fact] diff --git a/Tests/SuperLinq.Test/ToDataTableTest.cs b/Tests/SuperLinq.Test/ToDataTableTest.cs index b54ef0cc5..5b78f7911 100644 --- a/Tests/SuperLinq.Test/ToDataTableTest.cs +++ b/Tests/SuperLinq.Test/ToDataTableTest.cs @@ -1,18 +1,20 @@ -using System.Collections; +using System.Collections; using System.Data; +using System.Diagnostics.CodeAnalysis; namespace Test; -public class ToDataTableTest +[SuppressMessage("Design", "MA0150:Do not call the default object.ToString explicitly")] +public sealed class ToDataTableTest { - private class TestObject(int key) + private sealed class TestObject(int key) { - public int _keyField = key; - public Guid? _aNullableGuidField = Guid.NewGuid(); + public int KeyField = key; + public Guid? ANullableGuidField = Guid.NewGuid(); public string AString { get; } = "ABCDEFGHIKKLMNOPQRSTUVWXYSZ"; public decimal? ANullableDecimal { get; } = key / 3; - public object Unreadable { set => throw new NotImplementedException(); } + public object Unreadable { set => throw new NotSupportedException(); } public object this[int index] { @@ -86,10 +88,10 @@ public void ToDataTableSchemaInDeclarationOrder() Assert.Equal(nameof(TestObject.ANullableDecimal), dt.Columns[1].Caption); Assert.Equal(typeof(decimal), dt.Columns[1].DataType); - Assert.Equal(nameof(TestObject._keyField), dt.Columns[2].Caption); + Assert.Equal(nameof(TestObject.KeyField), dt.Columns[2].Caption); Assert.Equal(typeof(int), dt.Columns[2].DataType); - Assert.Equal(nameof(TestObject._aNullableGuidField), dt.Columns[3].Caption); + Assert.Equal(nameof(TestObject.ANullableGuidField), dt.Columns[3].Caption); Assert.Equal(typeof(Guid), dt.Columns[3].DataType); Assert.True(dt.Columns[3].AllowDBNull); diff --git a/Tests/SuperLinq.Test/ToDelimitedStringTest.cs b/Tests/SuperLinq.Test/ToDelimitedStringTest.cs index 8fbcc7398..aebff03ae 100644 --- a/Tests/SuperLinq.Test/ToDelimitedStringTest.cs +++ b/Tests/SuperLinq.Test/ToDelimitedStringTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ToDelimitedStringTest +public sealed class ToDelimitedStringTest { [Fact] public void ToDelimitedStringWithNonEmptySequenceAndDelimiter() diff --git a/Tests/SuperLinq.Test/ToDictionaryTest.cs b/Tests/SuperLinq.Test/ToDictionaryTest.cs index c05dcf680..76322485c 100644 --- a/Tests/SuperLinq.Test/ToDictionaryTest.cs +++ b/Tests/SuperLinq.Test/ToDictionaryTest.cs @@ -1,7 +1,7 @@ namespace Test; [Obsolete("References `ToDictionary` which is obsolete in net8+")] -public class ToDictionaryTest +public sealed class ToDictionaryTest { [Fact] public void ToDictionaryWithKeyValuePairs() diff --git a/Tests/SuperLinq.Test/ToLookupTest.cs b/Tests/SuperLinq.Test/ToLookupTest.cs index c58a11055..ecfaa66d6 100644 --- a/Tests/SuperLinq.Test/ToLookupTest.cs +++ b/Tests/SuperLinq.Test/ToLookupTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class ToLookupTest +public sealed class ToLookupTest { [Fact] public void ToLookupWithKeyValuePairs() diff --git a/Tests/SuperLinq.Test/TransposeTest.cs b/Tests/SuperLinq.Test/TransposeTest.cs index 5adc59fbd..ab9ca2d2d 100644 --- a/Tests/SuperLinq.Test/TransposeTest.cs +++ b/Tests/SuperLinq.Test/TransposeTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class TransposeTest +public sealed class TransposeTest { [Fact] public void TransposeIsLazy() @@ -96,7 +96,7 @@ public void TransposeWithAllRowsAsInfiniteSequences() [4, 9, 25], [8, 27, 125], [16, 81, 625], - [32, 243, 3125] + [32, 243, 3125], }; AssertMatrix(expectations, result); @@ -123,7 +123,7 @@ public void TransposeWithSomeRowsAsInfiniteSequences() [4, 9, 25], [8, 125], [16, 625], - [32, 3125] + [32, 3125], }; AssertMatrix(expectations, result); diff --git a/Tests/SuperLinq.Test/TraverseTest.cs b/Tests/SuperLinq.Test/TraverseTest.cs index 75a526a16..2a23b585a 100644 --- a/Tests/SuperLinq.Test/TraverseTest.cs +++ b/Tests/SuperLinq.Test/TraverseTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class TraverseTest +public sealed class TraverseTest { [Fact] public void TraverseDepthFirstIsStreaming() @@ -32,7 +32,7 @@ public void TraverseBreadthFirstPreservesChildrenOrder() res.AssertSequenceEqual(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); } - private class Tree( + private sealed class Tree( T value, IEnumerable> children ) diff --git a/Tests/SuperLinq.Test/TrySingleTest.cs b/Tests/SuperLinq.Test/TrySingleTest.cs index 3d948319d..7dac1499a 100644 --- a/Tests/SuperLinq.Test/TrySingleTest.cs +++ b/Tests/SuperLinq.Test/TrySingleTest.cs @@ -2,7 +2,7 @@ namespace Test; -public class TrySingleTest +public sealed class TrySingleTest { public static IEnumerable GetSequences(IEnumerable seq) => seq.Select(x => (int?)x) @@ -64,11 +64,11 @@ public IEnumerator GetEnumerator() IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - public void Add(T item) => throw new NotImplementedException(); - public void Clear() => throw new NotImplementedException(); - public bool Contains(T item) => throw new NotImplementedException(); - public void CopyTo(T[] array, int arrayIndex) => throw new NotImplementedException(); - public bool Remove(T item) => throw new NotImplementedException(); + public void Add(T item) => throw new NotSupportedException(); + public void Clear() => throw new NotSupportedException(); + public bool Contains(T item) => throw new NotSupportedException(); + public void CopyTo(T[] array, int arrayIndex) => throw new NotSupportedException(); + public bool Remove(T item) => throw new NotSupportedException(); public bool IsReadOnly => true; } diff --git a/Tests/SuperLinq.Test/UpdatablePriorityQueueTest.cs b/Tests/SuperLinq.Test/UpdatablePriorityQueueTest.cs index 6c1133b52..2e650b712 100644 --- a/Tests/SuperLinq.Test/UpdatablePriorityQueueTest.cs +++ b/Tests/SuperLinq.Test/UpdatablePriorityQueueTest.cs @@ -8,7 +8,7 @@ namespace Test; -public class UpdatableUpdatablePriorityQueueTest +public sealed class UpdatableUpdatablePriorityQueueTest { public abstract class TestBase { @@ -283,24 +283,24 @@ protected override (int, int) CreateT(int seed) } } - public class PriorityQueue_Generic_Tests_string_string_CustomPriorityComparer : UpdatablePriorityQueue_Generic_Tests_string_string + public sealed class PriorityQueue_Generic_Tests_string_string_CustomPriorityComparer : UpdatablePriorityQueue_Generic_Tests_string_string { protected override IComparer GetPriorityComparer() => StringComparer.InvariantCultureIgnoreCase; } - public class PriorityQueue_Generic_Tests_string_string_CustomElementComparer : UpdatablePriorityQueue_Generic_Tests_string_string + public sealed class PriorityQueue_Generic_Tests_string_string_CustomElementComparer : UpdatablePriorityQueue_Generic_Tests_string_string { protected override IEqualityComparer? GetElementComparer() => StringComparer.InvariantCultureIgnoreCase; } - public class PriorityQueue_Generic_Tests_int_int_CustomComparer : UpdatablePriorityQueue_Generic_Tests_int_int + public sealed class PriorityQueue_Generic_Tests_int_int_CustomComparer : UpdatablePriorityQueue_Generic_Tests_int_int { protected override IComparer GetPriorityComparer() => Comparer.Create((x, y) => -x.CompareTo(y)); } - public class UpdatablePriorityQueue_NonGeneric_Tests : TestBase + public sealed class UpdatablePriorityQueue_NonGeneric_Tests : TestBase { - protected static UpdatablePriorityQueue CreateSmallUpdatablePriorityQueue(out HashSet<(string, int)> items) + private static UpdatablePriorityQueue CreateSmallUpdatablePriorityQueue(out HashSet<(string, int)> items) { items = [ @@ -313,7 +313,7 @@ protected static UpdatablePriorityQueue CreateSmallUpdatablePriorit return queue; } - protected static UpdatablePriorityQueue CreateUpdatablePriorityQueue(int initialCapacity, int count) + private static UpdatablePriorityQueue CreateUpdatablePriorityQueue(int initialCapacity, int count) { var pq = new UpdatablePriorityQueue(initialCapacity); for (var i = 0; i < count; i++) @@ -327,7 +327,7 @@ protected static UpdatablePriorityQueue CreateUpdatablePriorityQueue(i [Fact] public void UpdatablePriorityQueue_Generic_EnqueueDequeue_Empty() { - var queue = new UpdatablePriorityQueue(); + var queue = new UpdatablePriorityQueue(StringComparer.Ordinal); Assert.Equal("hello", queue.EnqueueDequeue("hello", 42)); Assert.Equal(0, queue.Count); @@ -380,7 +380,7 @@ public void UpdatablePriorityQueue_Generic_Constructor_IEnumerable_Null() [Fact] public void UpdatablePriorityQueue_Generic_Enqueue_Null() { - var queue = new UpdatablePriorityQueue(); + var queue = new UpdatablePriorityQueue(StringComparer.Ordinal); queue.Enqueue(element: null, 1); queue.Enqueue(element: "zero", 0); @@ -394,7 +394,7 @@ public void UpdatablePriorityQueue_Generic_Enqueue_Null() [Fact] public void UpdatablePriorityQueue_Generic_EnqueueRange_Null() { - var queue = new UpdatablePriorityQueue(); + var queue = new UpdatablePriorityQueue(StringComparer.Ordinal); queue.EnqueueRange([null, null, null], 0); queue.EnqueueRange(["not null"], 1); @@ -407,7 +407,7 @@ public void UpdatablePriorityQueue_Generic_EnqueueRange_Null() [Fact] public void UpdatablePriorityQueue_Generic_Enqueue_ChangesPriority() { - var queue = new UpdatablePriorityQueue(); + var queue = new UpdatablePriorityQueue(StringComparer.Ordinal); queue.EnqueueRange(["alpha", "bravo", "charlie", "delta", "echo",], 30); @@ -434,7 +434,7 @@ public void UpdatablePriorityQueue_Generic_Enqueue_ChangesPriority() [Fact] public void UpdatablePriorityQueue_Generic_EnqueueRange_ChangesPriority() { - var queue = new UpdatablePriorityQueue(); + var queue = new UpdatablePriorityQueue(StringComparer.Ordinal); queue.EnqueueRange(["alpha", "bravo", "charlie", "delta", "echo",], 30); @@ -464,7 +464,7 @@ public void UpdatablePriorityQueue_Generic_EnqueueRange_ChangesPriority() [Fact] public void UpdatablePriorityQueue_Generic_EnqueueMinimum_UsesLowestPriority() { - var queue = new UpdatablePriorityQueue(); + var queue = new UpdatablePriorityQueue(StringComparer.Ordinal); queue.EnqueueRange(["alpha", "bravo", "charlie", "delta", "echo",], 30); @@ -488,7 +488,7 @@ public void UpdatablePriorityQueue_Generic_EnqueueMinimum_UsesLowestPriority() [Fact] public void UpdatablePriorityQueue_Generic_EnqueueRangeMinimum_UsesLowestPriority() { - var queue = new UpdatablePriorityQueue(); + var queue = new UpdatablePriorityQueue(StringComparer.Ordinal); queue.EnqueueRange(["alpha", "bravo", "charlie", "delta", "echo",], 30); diff --git a/Tests/SuperLinq.Test/UsingTest.cs b/Tests/SuperLinq.Test/UsingTest.cs index b89659b4c..4791d63b2 100644 --- a/Tests/SuperLinq.Test/UsingTest.cs +++ b/Tests/SuperLinq.Test/UsingTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class UsingTest +public sealed class UsingTest { [Fact] public void UsingIsLazy() @@ -76,7 +76,7 @@ public void UsingDisposesOnFunctionError() Assert.True(dis.IsDisposed); } - private class TestDisposable : IDisposable + private sealed class TestDisposable : IDisposable { public bool IsDisposed { get; set; } public void Dispose() => IsDisposed = true; diff --git a/Tests/SuperLinq.Test/ValueTupleComparerTest.cs b/Tests/SuperLinq.Test/ValueTupleComparerTest.cs index cdb6a277b..35e2f5cb8 100644 --- a/Tests/SuperLinq.Test/ValueTupleComparerTest.cs +++ b/Tests/SuperLinq.Test/ValueTupleComparerTest.cs @@ -2,9 +2,9 @@ namespace Test; -public class ValueTupleComparerTest +public sealed class ValueTupleComparerTest { - private class TestComparer : IComparer + private sealed class TestComparer : IComparer { public int Compare([AllowNull] string x, [AllowNull] string y) { @@ -17,7 +17,7 @@ public int Compare([AllowNull] string x, [AllowNull] string y) [Fact] public void ValueTupleComparerShouldCreateWithDefaultComparers() { - var comparer = ValueTupleComparer.Create(null, null); + var comparer = ValueTupleComparer.Create(comparer1: null, comparer2: null); ValueTuple left = new(1, 2); ValueTuple right = new(3, 4); var result = comparer.Compare(left, right); @@ -27,7 +27,7 @@ public void ValueTupleComparerShouldCreateWithDefaultComparers() [Fact] public void ValueTupleComparerShouldCheckSecondItemIfFirstIsZero() { - var comparer = ValueTupleComparer.Create(null, null); + var comparer = ValueTupleComparer.Create(comparer1: null, comparer2: null); ValueTuple left = new(1, 3); ValueTuple right = new(1, 2); var result = comparer.Compare(left, right); diff --git a/Tests/SuperLinq.Test/ValueTupleEqualityComparerTest.cs b/Tests/SuperLinq.Test/ValueTupleEqualityComparerTest.cs index f9ee88e37..dfe53ba68 100644 --- a/Tests/SuperLinq.Test/ValueTupleEqualityComparerTest.cs +++ b/Tests/SuperLinq.Test/ValueTupleEqualityComparerTest.cs @@ -2,10 +2,10 @@ namespace Test; -public class ValueTupleEqualityComparerTest +public sealed class ValueTupleEqualityComparerTest { - private record TestObject(string Value); - private class TestComparer(Func comparer) : IEqualityComparer + private sealed record TestObject(string Value); + private sealed class TestComparer(Func comparer) : IEqualityComparer { public bool Equals(T? x, T? y) => comparer(x, y); public int GetHashCode([DisallowNull] T obj) => obj.GetHashCode(); @@ -14,7 +14,7 @@ private class TestComparer(Func comparer) : IEqualityComparer(null); + var comparer = ValueTupleEqualityComparer.Create(comparer1: null); ValueTuple left = new(1); ValueTuple right = new(1); var result = comparer.Equals(left, right); @@ -24,8 +24,8 @@ public void ValueTupleEqualityComparerWithOneTypeArgShouldCreateWhenNoComparerPr [Fact] public void ValueTupleEqualityComparerWithOneTypeArgShouldGetHashCode() { - var comparer = ValueTupleEqualityComparer.Create(null); - ValueTuple first = new(null); + var comparer = ValueTupleEqualityComparer.Create(comparer1: null); + ValueTuple first = new(item1: null); var firstHashCode = comparer.GetHashCode(first); Assert.Equal(0, firstHashCode); @@ -48,7 +48,7 @@ public void ValueTupleEqualityComparerWithOneTypeArgShouldCreateWhenComparerProv [Fact] public void ValueTupleEqualityComparerWithTwoTypeArgsShouldCreateWhenNoComparerProvided() { - var comparer = ValueTupleEqualityComparer.Create(null, null); + var comparer = ValueTupleEqualityComparer.Create(comparer1: null, comparer2: null); ValueTuple left = new(1, 2); ValueTuple right = new(1, 2); var result = comparer.Equals(left, right); @@ -70,7 +70,7 @@ public void ValueTupleEqualityComparerWithTwoTypeArgsShouldCreateWhenComparerPro [Fact] public void ValueTupleEqualityComparerWithTwoTypeArgsShouldGetHashCode() { - var comparer = ValueTupleEqualityComparer.Create(null, null); + var comparer = ValueTupleEqualityComparer.Create(comparer1: null, comparer2: null); ValueTuple first = new(1, 2); var firstHashCode = comparer.GetHashCode(first); var expectedHashCode = HashCode.Combine(1.GetHashCode(), 2.GetHashCode()); diff --git a/Tests/SuperLinq.Test/WhereLagTest.cs b/Tests/SuperLinq.Test/WhereLagTest.cs index a56da19f7..cae9bbd33 100644 --- a/Tests/SuperLinq.Test/WhereLagTest.cs +++ b/Tests/SuperLinq.Test/WhereLagTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class WhereLagTest +public sealed class WhereLagTest { [Fact] public void WhereLagIsLazy() diff --git a/Tests/SuperLinq.Test/WhereLeadTest.cs b/Tests/SuperLinq.Test/WhereLeadTest.cs index ce5261ca5..6b6763ffe 100644 --- a/Tests/SuperLinq.Test/WhereLeadTest.cs +++ b/Tests/SuperLinq.Test/WhereLeadTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class WhereLeadTest +public sealed class WhereLeadTest { [Fact] public void WhereLeadIsLazy() diff --git a/Tests/SuperLinq.Test/WhereTest.cs b/Tests/SuperLinq.Test/WhereTest.cs index f07ec6fb7..2de65535c 100644 --- a/Tests/SuperLinq.Test/WhereTest.cs +++ b/Tests/SuperLinq.Test/WhereTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class WhereTest +public sealed class WhereTest { [Fact] public void WhereIsLazy() diff --git a/Tests/SuperLinq.Test/WhileTest.cs b/Tests/SuperLinq.Test/WhileTest.cs index a3d4dc94b..296940a03 100644 --- a/Tests/SuperLinq.Test/WhileTest.cs +++ b/Tests/SuperLinq.Test/WhileTest.cs @@ -1,6 +1,6 @@ namespace Test; -public class WhileTest +public sealed class WhileTest { [Fact] public void WhileIsLazy() diff --git a/Tests/SuperLinq.Test/WindowLeftTest.cs b/Tests/SuperLinq.Test/WindowLeftTest.cs index 62e0223a9..d63150f2b 100644 --- a/Tests/SuperLinq.Test/WindowLeftTest.cs +++ b/Tests/SuperLinq.Test/WindowLeftTest.cs @@ -1,6 +1,6 @@ -namespace Test; +namespace Test; -public partial class WindowLeftTest +public sealed class WindowLeftTest { [Fact] public void WindowLeftIsLazy() diff --git a/Tests/SuperLinq.Test/WindowRightTest.cs b/Tests/SuperLinq.Test/WindowRightTest.cs index 0b1d5eea5..e0af584cf 100644 --- a/Tests/SuperLinq.Test/WindowRightTest.cs +++ b/Tests/SuperLinq.Test/WindowRightTest.cs @@ -1,6 +1,6 @@ -namespace Test; +namespace Test; -public partial class WindowRightTest +public sealed class WindowRightTest { [Fact] public void WindowRightIsLazy() diff --git a/Tests/SuperLinq.Test/WindowTest.cs b/Tests/SuperLinq.Test/WindowTest.cs index a0a35105b..78db07a01 100644 --- a/Tests/SuperLinq.Test/WindowTest.cs +++ b/Tests/SuperLinq.Test/WindowTest.cs @@ -1,9 +1,9 @@ -namespace Test; +namespace Test; /// /// Verify the behavior of the Window operator /// -public partial class WindowTests +public sealed class WindowTests { [Fact] public void TestWindowIsLazy() diff --git a/Tests/SuperLinq.Test/ZipLongestTest.cs b/Tests/SuperLinq.Test/ZipLongestTest.cs index 0c6fd18c9..0b18360b0 100644 --- a/Tests/SuperLinq.Test/ZipLongestTest.cs +++ b/Tests/SuperLinq.Test/ZipLongestTest.cs @@ -1,5 +1,5 @@ namespace Test; -public class ZipLongestTest +public sealed class ZipLongestTest { [Fact] public void ZipLongestIsLazy() diff --git a/Tests/SuperLinq.Test/ZipMapTest.cs b/Tests/SuperLinq.Test/ZipMapTest.cs index 01ca1a265..a299385f8 100644 --- a/Tests/SuperLinq.Test/ZipMapTest.cs +++ b/Tests/SuperLinq.Test/ZipMapTest.cs @@ -1,8 +1,9 @@ -using System.Text.RegularExpressions; +using System.Globalization; +using System.Text.RegularExpressions; namespace Test; -public class ZipMapTest +public sealed class ZipMapTest { public static IEnumerable GetIntSequences() => Enumerable.Range(1, 10) @@ -15,9 +16,9 @@ public void ZipMapIntTransformation(IDisposableEnumerable seq) { using (seq) { - var result = seq.ZipMap(i => i.ToString()); + var result = seq.ZipMap(i => i.ToString(CultureInfo.InvariantCulture)); result - .AssertSequenceEqual(Enumerable.Range(1, 10).Select(i => (i, i.ToString()))); + .AssertSequenceEqual(Enumerable.Range(1, 10).Select(i => (i, i.ToString(CultureInfo.InvariantCulture)))); } } diff --git a/Tests/SuperLinq.Test/ZipShortestTest.cs b/Tests/SuperLinq.Test/ZipShortestTest.cs index d1d463499..48e181e0f 100644 --- a/Tests/SuperLinq.Test/ZipShortestTest.cs +++ b/Tests/SuperLinq.Test/ZipShortestTest.cs @@ -1,5 +1,5 @@ namespace Test; -public class ZipShortestTest +public sealed class ZipShortestTest { [Fact] public void ZipShortestIsLazy()