Skip to content

Commit

Permalink
Updates & Modernization (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceroypenguin authored Apr 10, 2024
1 parent ecb5d27 commit 86d06d7
Show file tree
Hide file tree
Showing 295 changed files with 1,189 additions and 1,079 deletions.
198 changes: 120 additions & 78 deletions .editorconfig

Large diffs are not rendered by default.

47 changes: 23 additions & 24 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<PropertyGroup>
<LangVersion>latest</LangVersion>

<Nullable>enable</Nullable>
<WarningsAsErrors>$(WarningsAsErrors);nullable;</WarningsAsErrors>
<Nullable>enable</Nullable>
<WarningsAsErrors>$(WarningsAsErrors);nullable;</WarningsAsErrors>

<ImplicitUsings>enable</ImplicitUsings>
<ImplicitUsings>enable</ImplicitUsings>

<CheckEolTargetFramework>false</CheckEolTargetFramework>
<CheckEolTargetFramework>false</CheckEolTargetFramework>

<AnalysisLevel>latest-all</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-all</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>

<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers" PrivateAssets="All" />
<PackageReference Include="PolySharp" PrivateAssets="All" />
</ItemGroup>

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

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<!-- Don't block development work; but block CI if dev work isn't complete. -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<CollectCoverage>true</CollectCoverage>
<CoverletOutputFormat>opencover</CoverletOutputFormat>
</PropertyGroup>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<CollectCoverage>true</CollectCoverage>
<CoverletOutputFormat>opencover</CoverletOutputFormat>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
<PackageVersion Include="DocFx.App" Version="2.76.0" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.146" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers" Version="3.3.1" />
Expand Down
2 changes: 1 addition & 1 deletion Generators/SuperLinq.Async.Generator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace SuperLinq.Async.Generator;
/// Uses source generation tools to automate the building of some operators
/// </summary>
[Generator]
public class Generator : IIncrementalGenerator
public sealed class Generator : IIncrementalGenerator
{
/// <inheritdoc />
public void Initialize(IncrementalGeneratorInitializationContext context)
Expand Down
2 changes: 1 addition & 1 deletion Generators/SuperLinq.Generator/EquiZip.sbntxt
Original file line number Diff line number Diff line change
Expand Up @@ -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<TResult>
private sealed class EquiZipIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator<TResult>
{
{{~ for $j in 1..$i ~}}
private readonly global::System.Collections.Generic.IList<T{{ $j }}> _list{{ $j }};
Expand Down
2 changes: 1 addition & 1 deletion Generators/SuperLinq.Generator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace SuperLinq.Generator;
/// Uses source generation tools to automate the building of some operators
/// </summary>
[Generator]
public class Generator : IIncrementalGenerator
public sealed class Generator : IIncrementalGenerator
{
/// <inheritdoc />
public void Initialize(IncrementalGeneratorInitializationContext context)
Expand Down
22 changes: 11 additions & 11 deletions Generators/SuperLinq.Generator/ToDelimitedString.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
Expand All @@ -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(), });
Expand Down
4 changes: 2 additions & 2 deletions Source/SuperLinq.Async/Amb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static async IAsyncEnumerable<TSource> Core(
tasks.Add(firstMove.AsTask());
}

if (e == null)
if (e is null)
{
// who finishes first?
var t = await Task.WhenAny(tasks).ConfigureAwait(false);
Expand Down Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions Source/SuperLinq.Async/FillBackward.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SuperLinq.Async;
namespace SuperLinq.Async;

public static partial class AsyncSuperEnumerable
{
Expand All @@ -21,7 +21,7 @@ public static partial class AsyncSuperEnumerable

public static IAsyncEnumerable<T> FillBackward<T>(this IAsyncEnumerable<T> source)
{
return source.FillBackward(e => new ValueTask<bool>(e == null));
return source.FillBackward(e => new ValueTask<bool>(e is null));
}

/// <summary>
Expand Down Expand Up @@ -223,13 +223,13 @@ private static async IAsyncEnumerable<T> FillBackwardImpl<T>(IAsyncEnumerable<T>
}
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();
Expand Down
15 changes: 8 additions & 7 deletions Source/SuperLinq.Async/FillForward.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SuperLinq.Async;
namespace SuperLinq.Async;

public static partial class AsyncSuperEnumerable
{
Expand All @@ -21,7 +21,7 @@ public static partial class AsyncSuperEnumerable

public static IAsyncEnumerable<T> FillForward<T>(this IAsyncEnumerable<T> source)
{
return source.FillForward(e => new ValueTask<bool>(e == null));
return source.FillForward(e => new ValueTask<bool>(e is null));
}

/// <summary>
Expand Down Expand Up @@ -218,11 +218,12 @@ private static async IAsyncEnumerable<T> FillForwardImpl<T>(IAsyncEnumerable<T>
{
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
{
Expand Down
4 changes: 2 additions & 2 deletions Source/SuperLinq.Async/Join.HashJoin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ private static async IAsyncEnumerable<TResult> JoinHash<TLeft, TRight, TKey, TRe

if (!rLookup.Contains(lKey))
{
if (leftResultSelector != null)
if (leftResultSelector is not null)
yield return leftResultSelector(l);
continue;
}
Expand All @@ -656,7 +656,7 @@ private static async IAsyncEnumerable<TResult> JoinHash<TLeft, TRight, TKey, TRe
yield return bothResultSelector(l, r);
}

if (rightResultSelector != null)
if (rightResultSelector is not null)
{
foreach (var g in rLookup)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/SuperLinq.Async/Join.LoopJoin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private static async IAsyncEnumerable<TResult> LoopJoin<TLeft, TRight, TKey, TRe
}
}

if (leftResultSelector != null
if (leftResultSelector is not null
&& !flag)
{
yield return leftResultSelector(l);
Expand Down
8 changes: 4 additions & 4 deletions Source/SuperLinq.Async/Join.MergeJoin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ private static async IAsyncEnumerable<TResult> JoinMerge<TLeft, TRight, TKey, TR

if (comparison < 0)
{
if (leftResultSelector != null)
if (leftResultSelector is not null)
{
foreach (var e in l)
yield return leftResultSelector(e);
Expand All @@ -674,7 +674,7 @@ private static async IAsyncEnumerable<TResult> JoinMerge<TLeft, TRight, TKey, TR
}
else if (comparison > 0)
{
if (rightResultSelector != null)
if (rightResultSelector is not null)
{
foreach (var e in r)
yield return rightResultSelector(e);
Expand All @@ -695,7 +695,7 @@ private static async IAsyncEnumerable<TResult> JoinMerge<TLeft, TRight, TKey, TR
}
}

if (gotLeft && leftResultSelector != null)
if (gotLeft && leftResultSelector is not null)
{
do
{
Expand All @@ -705,7 +705,7 @@ private static async IAsyncEnumerable<TResult> JoinMerge<TLeft, TRight, TKey, TR
yield break;
}

if (gotRight && rightResultSelector != null)
if (gotRight && rightResultSelector is not null)
{
do
{
Expand Down
8 changes: 4 additions & 4 deletions Source/SuperLinq.Async/Memoize.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.ExceptionServices;
using System.Runtime.ExceptionServices;

namespace SuperLinq.Async;

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

_buffer = [];
_initialized = false;
if (_enumerator != null)
if (_enumerator is not null)
await _enumerator.DisposeAsync().ConfigureAwait(false);
_enumerator = null;
_exceptionIndex = null;
Expand Down Expand Up @@ -152,7 +152,7 @@ private async IAsyncEnumerator<T> GetEnumeratorImpl(CancellationToken cancellati
_exception.Throw();
}

if (_enumerator == null)
if (_enumerator is null)
break;

var moved = false;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Source/SuperLinq.Async/Publish.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -149,7 +149,7 @@ private async IAsyncEnumerator<T> GetEnumeratorImpl(Queue<T> buffer, int version
{
_exception?.Throw();

if (_enumerator == null)
if (_enumerator is null)
break;

var moved = false;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Source/SuperLinq.Async/Share.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -126,7 +126,7 @@ private async IAsyncEnumerator<T> GetEnumeratorImpl(CancellationToken cancellati

_exception?.Throw();

if (_enumerator == null)
if (_enumerator is null)
break;

var moved = false;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Source/SuperLinq.Async/Split.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SuperLinq.Async;
namespace SuperLinq.Async;

public static partial class AsyncSuperEnumerable
{
Expand Down Expand Up @@ -80,7 +80,7 @@ public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
TSource separator, int count,
Func<IReadOnlyList<TSource>, TResult> resultSelector)
{
return Split(source, separator, null, count, resultSelector);
return Split(source, separator, comparer: null, count, resultSelector);
}

/// <summary>
Expand Down
Loading

0 comments on commit 86d06d7

Please sign in to comment.