Skip to content

Commit 86d06d7

Browse files
Updates & Modernization (#647)
1 parent ecb5d27 commit 86d06d7

File tree

295 files changed

+1189
-1079
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+1189
-1079
lines changed

.editorconfig

+120-78
Large diffs are not rendered by default.

Directory.Build.props

+23-24
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
<Project>
2-
<PropertyGroup>
3-
<LangVersion>latest</LangVersion>
2+
<PropertyGroup>
3+
<LangVersion>latest</LangVersion>
44

5-
<Nullable>enable</Nullable>
6-
<WarningsAsErrors>$(WarningsAsErrors);nullable;</WarningsAsErrors>
5+
<Nullable>enable</Nullable>
6+
<WarningsAsErrors>$(WarningsAsErrors);nullable;</WarningsAsErrors>
77

8-
<ImplicitUsings>enable</ImplicitUsings>
8+
<ImplicitUsings>enable</ImplicitUsings>
99

10-
<CheckEolTargetFramework>false</CheckEolTargetFramework>
10+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
1111

12-
<AnalysisLevel>latest-all</AnalysisLevel>
13-
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
12+
<AnalysisLevel>latest-all</AnalysisLevel>
13+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1414

15-
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
15+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
16+
</PropertyGroup>
1617

17-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
18-
</PropertyGroup>
18+
<ItemGroup>
19+
<PackageReference Include="Meziantou.Analyzer" PrivateAssets="All" />
20+
<PackageReference Include="Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers" PrivateAssets="All" />
21+
<PackageReference Include="PolySharp" PrivateAssets="All" />
22+
</ItemGroup>
1923

20-
<ItemGroup>
21-
<PackageReference Include="Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers" PrivateAssets="All" />
22-
<PackageReference Include="PolySharp" PrivateAssets="All" />
23-
</ItemGroup>
24+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
25+
<!-- Don't block development work; but block CI if dev work isn't complete. -->
26+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2427

25-
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
26-
<!-- Don't block development work; but block CI if dev work isn't complete. -->
27-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
28-
29-
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
30-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
31-
<CollectCoverage>true</CollectCoverage>
32-
<CoverletOutputFormat>opencover</CoverletOutputFormat>
33-
</PropertyGroup>
28+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
29+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
30+
<CollectCoverage>true</CollectCoverage>
31+
<CoverletOutputFormat>opencover</CoverletOutputFormat>
32+
</PropertyGroup>
3433
</Project>

Directory.Packages.props

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
1010
<PackageVersion Include="DocFx.App" Version="2.76.0" />
1111
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
12+
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.146" />
1213
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
1314
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
1415
<PackageVersion Include="Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers" Version="3.3.1" />

Generators/SuperLinq.Async.Generator/Generator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace SuperLinq.Async.Generator;
1010
/// Uses source generation tools to automate the building of some operators
1111
/// </summary>
1212
[Generator]
13-
public class Generator : IIncrementalGenerator
13+
public sealed class Generator : IIncrementalGenerator
1414
{
1515
/// <inheritdoc />
1616
public void Initialize(IncrementalGeneratorInitializationContext context)

Generators/SuperLinq.Generator/EquiZip.sbntxt

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public static partial class SuperEnumerable
155155
{{~ end ~}}
156156
) => EquiZip({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
157157

158-
private class EquiZipIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator<TResult>
158+
private sealed class EquiZipIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator<TResult>
159159
{
160160
{{~ for $j in 1..$i ~}}
161161
private readonly global::System.Collections.Generic.IList<T{{ $j }}> _list{{ $j }};

Generators/SuperLinq.Generator/Generator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace SuperLinq.Generator;
99
/// Uses source generation tools to automate the building of some operators
1010
/// </summary>
1111
[Generator]
12-
public class Generator : IIncrementalGenerator
12+
public sealed class Generator : IIncrementalGenerator
1313
{
1414
/// <inheritdoc />
1515
public void Initialize(IncrementalGeneratorInitializationContext context)

Generators/SuperLinq.Generator/ToDelimitedString.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Reflection;
1+
using System.Reflection;
22
using System.Text;
33
using Microsoft.CodeAnalysis;
44
using Microsoft.CodeAnalysis.Text;
@@ -10,16 +10,16 @@ internal static class ToDelimitedString
1010
{
1111
public static SourceText Generate()
1212
{
13-
var types =
14-
from method in typeof(StringBuilder).GetMethods(BindingFlags.Public | BindingFlags.Instance)
15-
where string.Equals("Append", method.Name, StringComparison.Ordinal)
16-
select method.GetParameters() into parameters
17-
where parameters.Length == 1
18-
select parameters[0].ParameterType into type
19-
where !type.IsGenericType // e.g. ReadOnlySpan<>
20-
&& (type.IsValueType || type == typeof(string))
21-
orderby type.Name
22-
select $"global::{type.FullName}";
13+
var types = typeof(StringBuilder).GetMethods(BindingFlags.Public | BindingFlags.Instance)
14+
.Where(m => m.Name is "Append")
15+
.Select(m => m.GetParameters())
16+
.Where(p => p.Length == 1)
17+
.Select(p => p[0].ParameterType)
18+
.Where(t =>
19+
!t.IsGenericType // e.g. ReadOnlySpan<>
20+
&& (t.IsValueType || t == typeof(string)))
21+
.OrderBy(t => t.Name, StringComparer.Ordinal)
22+
.Select(t => $"global::{t.FullName}");
2323

2424
var template = Template.Parse(ThisAssembly.Resources.ToDelimitedString.Text);
2525
var output = template.Render(new { Types = types.ToList(), });

Source/SuperLinq.Async/Amb.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static async IAsyncEnumerable<TSource> Core(
109109
tasks.Add(firstMove.AsTask());
110110
}
111111

112-
if (e == null)
112+
if (e is null)
113113
{
114114
// who finishes first?
115115
var t = await Task.WhenAny(tasks).ConfigureAwait(false);
@@ -158,7 +158,7 @@ ex is OperationCanceledException
158158
{ }
159159
// if we're in the normal path, then e != null; in this case, we need to report any exceptions that we
160160
// encounter.
161-
catch (Exception ex) when (e != null)
161+
catch (Exception ex) when (e is not null)
162162
{
163163
edi = ExceptionDispatchInfo.Capture(ex);
164164
}

Source/SuperLinq.Async/FillBackward.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace SuperLinq.Async;
1+
namespace SuperLinq.Async;
22

33
public static partial class AsyncSuperEnumerable
44
{
@@ -21,7 +21,7 @@ public static partial class AsyncSuperEnumerable
2121

2222
public static IAsyncEnumerable<T> FillBackward<T>(this IAsyncEnumerable<T> source)
2323
{
24-
return source.FillBackward(e => new ValueTask<bool>(e == null));
24+
return source.FillBackward(e => new ValueTask<bool>(e is null));
2525
}
2626

2727
/// <summary>
@@ -223,13 +223,13 @@ private static async IAsyncEnumerable<T> FillBackwardImpl<T>(IAsyncEnumerable<T>
223223
}
224224
else
225225
{
226-
if (blanks != null)
226+
if (blanks is not null)
227227
{
228228
foreach (var blank in blanks)
229229
{
230-
yield return fillSelector != null
231-
? await fillSelector(blank, item).ConfigureAwait(false)
232-
: item;
230+
yield return fillSelector is not null
231+
? await fillSelector(blank, item).ConfigureAwait(false)
232+
: item;
233233
}
234234

235235
blanks.Clear();

Source/SuperLinq.Async/FillForward.cs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace SuperLinq.Async;
1+
namespace SuperLinq.Async;
22

33
public static partial class AsyncSuperEnumerable
44
{
@@ -21,7 +21,7 @@ public static partial class AsyncSuperEnumerable
2121

2222
public static IAsyncEnumerable<T> FillForward<T>(this IAsyncEnumerable<T> source)
2323
{
24-
return source.FillForward(e => new ValueTask<bool>(e == null));
24+
return source.FillForward(e => new ValueTask<bool>(e is null));
2525
}
2626

2727
/// <summary>
@@ -218,11 +218,12 @@ private static async IAsyncEnumerable<T> FillForwardImpl<T>(IAsyncEnumerable<T>
218218
{
219219
if (await predicate(item).ConfigureAwait(false))
220220
{
221-
yield return seed is (true, { } someSeed)
222-
? fillSelector != null
223-
? await fillSelector(item, someSeed).ConfigureAwait(false)
224-
: someSeed
225-
: item;
221+
yield return (seed, fillSelector) switch
222+
{
223+
((true, var s), { } f) => await f(item, s!).ConfigureAwait(false),
224+
((true, var s), _) => s!,
225+
_ => item,
226+
};
226227
}
227228
else
228229
{

Source/SuperLinq.Async/Join.HashJoin.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ private static async IAsyncEnumerable<TResult> JoinHash<TLeft, TRight, TKey, TRe
646646

647647
if (!rLookup.Contains(lKey))
648648
{
649-
if (leftResultSelector != null)
649+
if (leftResultSelector is not null)
650650
yield return leftResultSelector(l);
651651
continue;
652652
}
@@ -656,7 +656,7 @@ private static async IAsyncEnumerable<TResult> JoinHash<TLeft, TRight, TKey, TRe
656656
yield return bothResultSelector(l, r);
657657
}
658658

659-
if (rightResultSelector != null)
659+
if (rightResultSelector is not null)
660660
{
661661
foreach (var g in rLookup)
662662
{

Source/SuperLinq.Async/Join.LoopJoin.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ private static async IAsyncEnumerable<TResult> LoopJoin<TLeft, TRight, TKey, TRe
325325
}
326326
}
327327

328-
if (leftResultSelector != null
328+
if (leftResultSelector is not null
329329
&& !flag)
330330
{
331331
yield return leftResultSelector(l);

Source/SuperLinq.Async/Join.MergeJoin.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ private static async IAsyncEnumerable<TResult> JoinMerge<TLeft, TRight, TKey, TR
664664

665665
if (comparison < 0)
666666
{
667-
if (leftResultSelector != null)
667+
if (leftResultSelector is not null)
668668
{
669669
foreach (var e in l)
670670
yield return leftResultSelector(e);
@@ -674,7 +674,7 @@ private static async IAsyncEnumerable<TResult> JoinMerge<TLeft, TRight, TKey, TR
674674
}
675675
else if (comparison > 0)
676676
{
677-
if (rightResultSelector != null)
677+
if (rightResultSelector is not null)
678678
{
679679
foreach (var e in r)
680680
yield return rightResultSelector(e);
@@ -695,7 +695,7 @@ private static async IAsyncEnumerable<TResult> JoinMerge<TLeft, TRight, TKey, TR
695695
}
696696
}
697697

698-
if (gotLeft && leftResultSelector != null)
698+
if (gotLeft && leftResultSelector is not null)
699699
{
700700
do
701701
{
@@ -705,7 +705,7 @@ private static async IAsyncEnumerable<TResult> JoinMerge<TLeft, TRight, TKey, TR
705705
yield break;
706706
}
707707

708-
if (gotRight && rightResultSelector != null)
708+
if (gotRight && rightResultSelector is not null)
709709
{
710710
do
711711
{

Source/SuperLinq.Async/Memoize.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Runtime.ExceptionServices;
1+
using System.Runtime.ExceptionServices;
22

33
namespace SuperLinq.Async;
44

@@ -64,7 +64,7 @@ public async ValueTask Reset(CancellationToken cancellationToken = default)
6464

6565
_buffer = [];
6666
_initialized = false;
67-
if (_enumerator != null)
67+
if (_enumerator is not null)
6868
await _enumerator.DisposeAsync().ConfigureAwait(false);
6969
_enumerator = null;
7070
_exceptionIndex = null;
@@ -152,7 +152,7 @@ private async IAsyncEnumerator<T> GetEnumeratorImpl(CancellationToken cancellati
152152
_exception.Throw();
153153
}
154154

155-
if (_enumerator == null)
155+
if (_enumerator is null)
156156
break;
157157

158158
var moved = false;
@@ -203,7 +203,7 @@ public async ValueTask DisposeAsync()
203203
{
204204
_disposed = true;
205205
_buffer.Clear();
206-
if (_enumerator != null)
206+
if (_enumerator is not null)
207207
await _enumerator.DisposeAsync().ConfigureAwait(false);
208208
_enumerator = null;
209209
_source = null;

Source/SuperLinq.Async/Publish.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public async ValueTask Reset(CancellationToken cancellationToken = default)
5858

5959
_buffers = null;
6060

61-
if (_enumerator != null)
61+
if (_enumerator is not null)
6262
await _enumerator.DisposeAsync();
6363
_enumerator = null;
6464
_exception = null;
@@ -149,7 +149,7 @@ private async IAsyncEnumerator<T> GetEnumeratorImpl(Queue<T> buffer, int version
149149
{
150150
_exception?.Throw();
151151

152-
if (_enumerator == null)
152+
if (_enumerator is null)
153153
break;
154154

155155
var moved = false;
@@ -216,7 +216,7 @@ public async ValueTask DisposeAsync()
216216

217217
_buffers = null;
218218

219-
if (_enumerator != null)
219+
if (_enumerator is not null)
220220
await _enumerator.DisposeAsync().ConfigureAwait(false);
221221
_enumerator = null;
222222
_source = null;

Source/SuperLinq.Async/Share.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async ValueTask Reset(CancellationToken cancellationToken = default)
5151
_initialized = false;
5252
_version++;
5353

54-
if (_enumerator != null)
54+
if (_enumerator is not null)
5555
await _enumerator.DisposeAsync();
5656
_enumerator = null;
5757
_exception = null;
@@ -126,7 +126,7 @@ private async IAsyncEnumerator<T> GetEnumeratorImpl(CancellationToken cancellati
126126

127127
_exception?.Throw();
128128

129-
if (_enumerator == null)
129+
if (_enumerator is null)
130130
break;
131131

132132
var moved = false;
@@ -169,7 +169,7 @@ public async ValueTask DisposeAsync()
169169
try
170170
{
171171
_disposed = true;
172-
if (_enumerator != null)
172+
if (_enumerator is not null)
173173
await _enumerator.DisposeAsync().ConfigureAwait(false);
174174
_enumerator = null;
175175
_source = null;

Source/SuperLinq.Async/Split.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace SuperLinq.Async;
1+
namespace SuperLinq.Async;
22

33
public static partial class AsyncSuperEnumerable
44
{
@@ -80,7 +80,7 @@ public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
8080
TSource separator, int count,
8181
Func<IReadOnlyList<TSource>, TResult> resultSelector)
8282
{
83-
return Split(source, separator, null, count, resultSelector);
83+
return Split(source, separator, comparer: null, count, resultSelector);
8484
}
8585

8686
/// <summary>

0 commit comments

Comments
 (0)