Skip to content

Commit 2a8f961

Browse files
authored
Add Count(predicate) (#363)
1 parent 3c29ee4 commit 2a8f961

File tree

77 files changed

+1252
-217
lines changed

Some content is hidden

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

77 files changed

+1252
-217
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<PropertyGroup>
55
<Authors>Antao Almada</Authors>
66
<Copyright>Copyright 2019-2021 Antao Almada</Copyright>
7-
<LangVersion>9.0</LangVersion>
7+
<LangVersion>latest</LangVersion>
88
<Features>strict</Features>
99
<Nullable>enable</Nullable>
1010
</PropertyGroup>

NetFabric.Hyperlinq.Abstractions/NetFabric.Hyperlinq.Abstractions.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net461;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
4+
<TargetFrameworks>net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
55
<PackageId>NetFabric.Hyperlinq.Abstractions</PackageId>
66
<Title>NetFabric.Hyperlinq.Abstractions</Title>
77
<Description>Abstractions for high performance enumeration.</Description>
8-
<Version>1.2.0</Version>
8+
<Version>1.3.0</Version>
99
<PackageIcon>Icon.png</PackageIcon>
1010
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1111
<PackageTags>netfabric, hyperlinq, abstractions, linq, enumeration, performance</PackageTags>
1212
<PublishRepositoryUrl>true</PublishRepositoryUrl>
13+
<IncludeSymbols>true</IncludeSymbols>
14+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1315
<PackageReleaseNotes></PackageReleaseNotes>
1416
</PropertyGroup>
1517

NetFabric.Hyperlinq.Benchmarks/NetFabric.Hyperlinq.Benchmarks.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="BenchmarkDotNet" Version="0.13.0.1555" />
21+
<PackageReference Include="BenchmarkDotNet" Version="0.13.0.1561" />
2222
<PackageReference Include="LinqFaster.SIMD" Version="1.0.3" />
23-
<PackageReference Include="StructLinq" Version="0.26.0" />
23+
<PackageReference Include="StructLinq" Version="0.27.0" />
2424
<PackageReference Include="System.Interactive" Version="5.0.0" />
2525
<PackageReference Include="System.Interactive.Async" Version="5.0.0" />
2626
<PackageReference Include="System.Linq.Async" Version="5.0.0" />

NetFabric.Hyperlinq.Immutable/NetFabric.Hyperlinq.Immutable.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
55
<PackageId>NetFabric.Hyperlinq.Immutable</PackageId>
66
<Title>NetFabric.Hyperlinq.Immutable</Title>
77
<Description> High performance LINQ implementation with minimal heap allocations. Supports all collections in System.Collections.Immutable.</Description>
@@ -36,7 +36,7 @@
3636
<PrivateAssets>all</PrivateAssets>
3737
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
3838
</PackageReference>
39-
<PackageReference Include="Meziantou.Analyzer" Version="1.0.663">
39+
<PackageReference Include="Meziantou.Analyzer" Version="1.0.667">
4040
<PrivateAssets>all</PrivateAssets>
4141
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4242
</PackageReference>

NetFabric.Hyperlinq.SourceGenerator.UnitTests/NetFabric.Hyperlinq.SourceGenerator.UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.9.0" />
10+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.10.0" />
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
1212
<PackageReference Include="NetFabric.Assertive" Version="3.0.1" />
1313
<PackageReference Include="xunit" Version="2.4.1" />

NetFabric.Hyperlinq.SourceGenerator/NetFabric.Hyperlinq.SourceGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.9.0" PrivateAssets="all" />
13+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.10.0" PrivateAssets="all" />
1414
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" PrivateAssets="all" />
1515
<PackageReference Include="Nullable" Version="1.3.0">
1616
<PrivateAssets>all</PrivateAssets>

NetFabric.Hyperlinq.SourceGenerator/OverloadsGenerator.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,10 @@ void GenerateMethodSource(CodeBuilder builder, CompilationContext context, IName
344344

345345
if (isExtensionMethod)
346346
{
347-
_ = builder.AppendLine($"public static {methodReturnType} {methodName}{methodGenericParametersString}(this {methodExtensionType} source{methodParameters})");
347+
var extraMethodParameter = methodParameters is { Length: 0 }
348+
? string.Empty
349+
: $", {methodParameters}";
350+
_ = builder.AppendLine($"public static {methodReturnType} {methodName}{methodGenericParametersString}(this {methodExtensionType} source{extraMethodParameter})");
348351

349352
firstCallParameter = bindingsAttribute is null
350353
? "source"

NetFabric.Hyperlinq.UnitTests/Conversion/AsValueEnumerable/Bindings/System/Collections/Immutable/ImmutableArray.Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void AsValueEnumerable_With_ImmutableArray_Must_ReturnWrapper(int[] sourc
2424
.BeOfType<ArrayExtensions.ArraySegmentValueEnumerable<int>>()
2525
.BeEnumerableOf<int>()
2626
.BeEqualTo(wrapped, testRefStructs: false);
27-
result.SequenceEqual(wrapped).Must().BeTrue();
27+
_ = result.SequenceEqual(wrapped).Must().BeTrue();
2828
}
2929
}
3030
}

NetFabric.Hyperlinq.UnitTests/NetFabric.Hyperlinq.UnitTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net461;netcoreapp2.1;netcoreapp3.1;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net48;netcoreapp2.1;netcoreapp3.1;net6.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

@@ -24,7 +24,7 @@
2424
</PackageReference>
2525
</ItemGroup>
2626

27-
<ItemGroup Condition="'$(TargetFramework)'=='net461' Or '$(TargetFramework)'=='netcoreapp2.1'">
27+
<ItemGroup Condition="'$(TargetFramework)'=='net48' Or '$(TargetFramework)'=='netcoreapp2.1'">
2828
<ProjectReference Include="..\NetFabric.Hyperlinq.Immutable\NetFabric.Hyperlinq.Immutable.csproj" />
2929
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
3030
</ItemGroup>

NetFabric.Hyperlinq/Aggregation/Count/Count.ReadOnlySpan.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ public static partial class ArrayExtensions
99
static int Count<TSource>(this ReadOnlySpan<TSource> source)
1010
=> source.Length;
1111

12-
[GeneratorIgnore]
13-
static int Count<TSource, TPredicate>(this ReadOnlySpan<TSource> source, TPredicate predicate)
12+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
13+
static int Count<TSource>(this ReadOnlySpan<TSource> source, Func<TSource, bool> predicate)
14+
=> source.Count(new FunctionWrapper<TSource, bool>(predicate));
15+
16+
static int Count<TSource, TPredicate>(this ReadOnlySpan<TSource> source, TPredicate predicate = default)
1417
where TPredicate: struct, IFunction<TSource, bool>
1518
{
1619
var counter = 0;
@@ -21,8 +24,11 @@ static int Count<TSource, TPredicate>(this ReadOnlySpan<TSource> source, TPredic
2124
return counter;
2225
}
2326

24-
[GeneratorIgnore]
25-
static int CountAt<TSource, TPredicate>(this ReadOnlySpan<TSource> source, TPredicate predicate)
27+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
28+
static int Count<TSource>(this ReadOnlySpan<TSource> source, Func<TSource, int, bool> predicate)
29+
=> source.CountAt(new FunctionWrapper<TSource, int, bool>(predicate));
30+
31+
static int CountAt<TSource, TPredicate>(this ReadOnlySpan<TSource> source, TPredicate predicate = default)
2632
where TPredicate: struct, IFunction<TSource, int, bool>
2733
{
2834
var counter = 0;

0 commit comments

Comments
 (0)