Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the source generator to be public #371

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 11 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ indent_style = space
tab_width = 4

# New line preferences
end_of_line = crlf
# end_of_line = crlf
insert_final_newline = false

#### .NET Coding Conventions ####
Expand Down Expand Up @@ -58,7 +58,7 @@ dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
dotnet_style_readonly_field = true:error

# Parameter preferences
dotnet_code_quality_unused_parameters = all:error
dotnet_code_quality_unused_parameters = all:warning

#### C# Coding Conventions ####

Expand All @@ -68,14 +68,14 @@ csharp_style_var_for_built_in_types = true:error
csharp_style_var_when_type_is_apparent = true:error

# Expression-bodied members
csharp_style_expression_bodied_accessors = true:error
csharp_style_expression_bodied_constructors = true:error
csharp_style_expression_bodied_indexers = true:error
csharp_style_expression_bodied_lambdas = true:error
csharp_style_expression_bodied_local_functions = true:error
csharp_style_expression_bodied_methods = true:error
csharp_style_expression_bodied_operators = true:error
csharp_style_expression_bodied_properties = true:error
csharp_style_expression_bodied_accessors =true:warning
csharp_style_expression_bodied_constructors =true:warning
csharp_style_expression_bodied_indexers =true:warning
csharp_style_expression_bodied_lambdas =true:warning
csharp_style_expression_bodied_local_functions =true:warning
csharp_style_expression_bodied_methods =true:warning
csharp_style_expression_bodied_operators =true:warning
csharp_style_expression_bodied_properties =true:warning

# Pattern matching preferences
csharp_style_pattern_matching_over_as_with_null_check = true:error
Expand All @@ -101,7 +101,7 @@ csharp_style_pattern_local_over_anonymous_function = true:error
csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_range_operator = true:warning
csharp_style_throw_expression = true:error
csharp_style_unused_value_assignment_preference = discard_variable:error
csharp_style_unused_value_assignment_preference =discard_variable:warning
csharp_style_unused_value_expression_statement_preference = discard_variable:error

# 'using' directive preferences
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
* text eol=lf

###############################################################################
# Set default behavior for command prompt diff.
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ jobs:
- name: Check out repository
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1.7.2
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.100-preview.2.21155.3'
dotnet-version: '6.0.x'
include-prerelease: true
- name: Test source generator
run: dotnet test ./NetFabric.Hyperlinq.SourceGenerator.UnitTests/NetFabric.Hyperlinq.SourceGenerator.UnitTests.csproj
run: dotnet test ./NetFabric.Hyperlinq.UnitTests/NetFabric.Hyperlinq.UnitTests.csproj
- name: Build solution
run: dotnet build
- name: Tests and coverage
run: dotnet test ./NetFabric.Hyperlinq.UnitTests/NetFabric.Hyperlinq.UnitTests.csproj -f:net6.0 -p:CollectCoverage=true -p:CoverletOutputFormat=lcov -p:CoverletOutput=TestResults/
run: dotnet test ./NetFabric.Hyperlinq.Core.UnitTests/NetFabric.Hyperlinq.Core.UnitTests.csproj -f:net6.0 -p:CollectCoverage=true -p:CoverletOutputFormat=lcov -p:CoverletOutput=TestResults/
- name: Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./NetFabric.Hyperlinq.UnitTests/TestResults/coverage.net6.0.info
path-to-lcov: ./NetFabric.Hyperlinq.Core.UnitTests/TestResults/coverage.net6.0.info



Expand Down
Binary file modified Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
<Configuration>Release</Configuration>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NetFabric.Hyperlinq\NetFabric.Hyperlinq.csproj" />
<ProjectReference Include="..\NetFabric.Hyperlinq.UnitTests\NetFabric.Hyperlinq.UnitTests.csproj" />
<ProjectReference Include="..\NetFabric.Hyperlinq.Core.UnitTests\NetFabric.Hyperlinq.Core.UnitTests.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

<TargetFrameworks>net48;netcoreapp2.1;netcoreapp3.1;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.10.0" />
<PackageReference Include="coverlet.msbuild" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="NetFabric.Assertive" Version="3.0.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PackageReference Include="NetFabric.Hyperlinq.Analyzer" Version="2.0.3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
<PackageReference Include="System.Interactive" Version="5.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NetFabric.Hyperlinq.SourceGenerator\NetFabric.Hyperlinq.SourceGenerator.csproj" />
<ProjectReference Include="..\NetFabric.Hyperlinq.Core\NetFabric.Hyperlinq.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="TestData\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
<DotNetCliToolReference Include="dotnet-reportgenerator-cli" Version="4.3.8" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ public AsyncEnumerator<T> GetAsyncEnumerator()
IAsyncEnumerator<T> IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken _)
// ReSharper disable once HeapView.BoxingAllocation
=> new AsyncEnumerator<T>(source);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public AsyncEnumerableExtensions.AsyncValueEnumerable<AsyncEnumerableWrapper<T>, AsyncEnumerator<T>, AsyncEnumerator<T>, T, GetAsyncEnumeratorFunction, GetAsyncEnumeratorFunction> AsAsyncValueEnumerable()
=> this.AsAsyncValueEnumerable<AsyncEnumerableWrapper<T>, AsyncEnumerator<T>, T, GetAsyncEnumeratorFunction>();


public readonly struct GetAsyncEnumeratorFunction
: IFunction<AsyncEnumerableWrapper<T>, CancellationToken, AsyncEnumerator<T>>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ AsyncEnumerator<T> IAsyncValueEnumerable<T, AsyncEnumerator<T>>.GetAsyncEnumerat
IAsyncEnumerator<T> IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken _)
// ReSharper disable once HeapView.BoxingAllocation
=> new AsyncEnumerator<T>(source);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public AsyncValueEnumerableExtensions.AsyncValueEnumerable<AsyncValueEnumerableWrapper<T>, AsyncEnumerator<T>, AsyncEnumerator<T>, T, GetAsyncEnumeratorFunction, GetAsyncEnumeratorFunction> AsAsyncValueEnumerable()
=> AsyncValueEnumerableExtensions.AsAsyncValueEnumerable<AsyncValueEnumerableWrapper<T>, AsyncEnumerator<T>, T, GetAsyncEnumeratorFunction>(this);

public readonly struct GetAsyncEnumeratorFunction
: IFunction<AsyncValueEnumerableWrapper<T>, CancellationToken, AsyncEnumerator<T>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ IEnumerator<T> IEnumerable<T>.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator()
// ReSharper disable once HeapView.BoxingAllocation
=> GetEnumerator();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public EnumerableExtensions.ValueEnumerable<EnumerableWrapper<T>, Enumerator<T>, Enumerator<T>, T, GetEnumeratorFunction, GetEnumeratorFunction> AsValueEnumerable()
=> this.AsValueEnumerable<EnumerableWrapper<T>, Enumerator<T>, T, GetEnumeratorFunction>();

public readonly struct GetEnumeratorFunction
: IFunction<EnumerableWrapper<T>, Enumerator<T>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ public ReadOnlyCollectionWrapper(T[] source)

public int Count
=> source.Length;

public new ReadOnlyCollectionExtensions.ValueEnumerable<ReadOnlyCollectionWrapper<T>, Enumerator<T>, Enumerator<T>, T, GetEnumeratorFunction, GetEnumeratorFunction> AsValueEnumerable()
=> ReadOnlyCollectionExtensions.AsValueEnumerable<ReadOnlyCollectionWrapper<T>, Enumerator<T>, T, GetEnumeratorFunction>(this);

public new readonly struct GetEnumeratorFunction
: IFunction<ReadOnlyCollectionWrapper<T>, Enumerator<T>>
{
public Enumerator<T> Invoke(ReadOnlyCollectionWrapper<T> enumerable)
=> enumerable.GetEnumerator();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ internal ReadOnlyListWrapper(T[] source)

public T this[int index]
=> source[index];

public new ReadOnlyListExtensions.ValueEnumerable<ReadOnlyListWrapper<T>, T> AsValueEnumerable()
=> this.AsValueEnumerable<ReadOnlyListWrapper<T>, T>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ bool ICollection<T>.Remove(T item)
=> throw new NotSupportedException();
void ICollection<T>.Clear()
=> throw new NotSupportedException();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ValueReadOnlyCollectionExtensions.ValueEnumerable<ValueCollectionWrapper<T>, Enumerator<T>, Enumerator<T>, T, GetEnumeratorFunction, GetEnumeratorFunction> AsValueEnumerable()
=> ValueReadOnlyCollectionExtensions.AsValueEnumerable<ValueCollectionWrapper<T>, Enumerator<T>, T, GetEnumeratorFunction>(this);

public readonly struct GetEnumeratorFunction
: IFunction<ValueCollectionWrapper<T>, Enumerator<T>>
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Enumerator<T> Invoke(ValueCollectionWrapper<T> enumerable)
=> enumerable.GetEnumerator();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ IEnumerator<T> IEnumerable<T>.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator()
// ReSharper disable once HeapView.BoxingAllocation
=> GetEnumerator();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ValueEnumerableExtensions.ValueEnumerable<ValueEnumerableWrapper<T>, Enumerator<T>, Enumerator<T>, T, GetEnumeratorFunction, GetEnumeratorFunction> AsValueEnumerable()
=> ValueEnumerableExtensions.AsValueEnumerable<ValueEnumerableWrapper<T>, Enumerator<T>, T, GetEnumeratorFunction>(this);

public readonly struct GetEnumeratorFunction
: IFunction<ValueEnumerableWrapper<T>, Enumerator<T>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ void IList<T>.Insert(int index, T item)
=> throw new NotSupportedException();
void IList<T>.RemoveAt(int index)
=> throw new NotSupportedException();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ValueReadOnlyListExtensions.ValueEnumerable<ValueListWrapper<T>, Enumerator<T>, Enumerator<T>, T, GetEnumeratorFunction, GetEnumeratorFunction> AsValueEnumerable()
=> ValueReadOnlyListExtensions.AsValueEnumerable<ValueListWrapper<T>, Enumerator<T>, T, GetEnumeratorFunction>(this);

public readonly struct GetEnumeratorFunction
: IFunction<ValueListWrapper<T>, Enumerator<T>>
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Enumerator<T> Invoke(ValueListWrapper<T> enumerable)
=> enumerable.GetEnumerator();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ IEnumerator<T> IEnumerable<T>.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator()
// ReSharper disable once HeapView.BoxingAllocation
=> GetEnumerator();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlyCollectionExtensions.ValueEnumerable<ValueReadOnlyCollectionWrapper<T>, Enumerator<T>, Enumerator<T>, T, GetEnumeratorFunction, GetEnumeratorFunction> AsValueEnumerable()
=> ReadOnlyCollectionExtensions.AsValueEnumerable<ValueReadOnlyCollectionWrapper<T>, Enumerator<T>, T, GetEnumeratorFunction>(this);

public readonly struct GetEnumeratorFunction
: IFunction<ValueReadOnlyCollectionWrapper<T>, Enumerator<T>>
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Enumerator<T> Invoke(ValueReadOnlyCollectionWrapper<T> enumerable)
=> enumerable.GetEnumerator();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ IEnumerator<T> IEnumerable<T>.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator()
// ReSharper disable once HeapView.BoxingAllocation
=> GetEnumerator();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ValueReadOnlyListExtensions.ValueEnumerable<ValueReadOnlyListWrapper<T>, Enumerator<T>, Enumerator<T>, T, GetEnumeratorFunction, GetEnumeratorFunction> AsValueEnumerable()
=> ValueReadOnlyListExtensions.AsValueEnumerable<ValueReadOnlyListWrapper<T>, Enumerator<T>, T, GetEnumeratorFunction>(this);

public readonly struct GetEnumeratorFunction
: IFunction<ValueReadOnlyListWrapper<T>, Enumerator<T>>
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Enumerator<T> Invoke(ValueReadOnlyListWrapper<T> enumerable)
=> enumerable.GetEnumerator();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ namespace NetFabric.Hyperlinq
public static partial class ArrayExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int Count<TSource>(this ReadOnlySpan<TSource> source)
public static int Count<TSource>(ReadOnlySpan<TSource> source)
=> source.Length;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int Count<TSource>(this ReadOnlySpan<TSource> source, Func<TSource, bool> predicate)
public static int Count<TSource>(ReadOnlySpan<TSource> source, Func<TSource, bool> predicate)
=> source.Count(new FunctionWrapper<TSource, bool>(predicate));

static int Count<TSource, TPredicate>(this ReadOnlySpan<TSource> source, TPredicate predicate = default)
public static int Count<TSource, TPredicate>(this ReadOnlySpan<TSource> source, TPredicate predicate = default)
where TPredicate: struct, IFunction<TSource, bool>
{
var counter = 0;
Expand All @@ -25,10 +25,10 @@ static int Count<TSource, TPredicate>(this ReadOnlySpan<TSource> source, TPredic
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int Count<TSource>(this ReadOnlySpan<TSource> source, Func<TSource, int, bool> predicate)
public static int Count<TSource>(this ReadOnlySpan<TSource> source, Func<TSource, int, bool> predicate)
=> source.CountAt(new FunctionWrapper<TSource, int, bool>(predicate));

static int CountAt<TSource, TPredicate>(this ReadOnlySpan<TSource> source, TPredicate predicate = default)
public static int CountAt<TSource, TPredicate>(this ReadOnlySpan<TSource> source, TPredicate predicate = default)
where TPredicate: struct, IFunction<TSource, int, bool>
{
var counter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ public static int Count<TEnumerable, TEnumerator, TSource>(this TEnumerable sour
return counter;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Count<TEnumerable, TEnumerator, TSource>(this TEnumerable source, Func<TSource, bool> predicate)
where TEnumerable : IValueEnumerable<TSource, TEnumerator>
where TEnumerator : struct, IEnumerator<TSource>
=> source.Count<TEnumerable, TEnumerator, TSource, FunctionWrapper<TSource, bool>>(new FunctionWrapper<TSource, bool>(predicate));

public static int Count<TEnumerable, TEnumerator, TSource, TPredicate>(this TEnumerable source, TPredicate predicate = default)
where TEnumerable : IValueEnumerable<TSource, TEnumerator>
where TEnumerator : struct, IEnumerator<TSource>
Expand All @@ -40,12 +34,6 @@ public static int Count<TEnumerable, TEnumerator, TSource, TPredicate>(this TEnu
}
return counter;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Count<TEnumerable, TEnumerator, TSource>(this TEnumerable source, Func<TSource, int, bool> predicate)
where TEnumerable : IValueEnumerable<TSource, TEnumerator>
where TEnumerator : struct, IEnumerator<TSource>
=> source.CountAt<TEnumerable, TEnumerator, TSource, FunctionWrapper<TSource, int, bool>>(new FunctionWrapper<TSource, int, bool>(predicate));

public static int CountAt<TEnumerable, TEnumerator, TSource, TPredicate>(this TEnumerable source, TPredicate predicate = default)
where TEnumerable : IValueEnumerable<TSource, TEnumerator>
Expand Down
Loading