Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
dotnet-version: 10.x

- name: Restore NuGet Package Cache
uses: actions/cache/restore@v4
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
dotnet-version: 10.x

- name: Restore NuGet Package Cache
uses: actions/cache/restore@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
dotnet-version: 10.x

# Publish all NuGet packages to the GitHub feed
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
Expand All @@ -92,7 +92,7 @@ jobs:
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
dotnet-version: 10.x

# Publish all NuGet packages to the NuGet feed
- name: Publish NuGet Packages (NuGet)
Expand Down
20 changes: 15 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
<Project>
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>net10.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<AssemblyFileName>$(AssemblyTitle).dll</AssemblyFileName>
<LangVersion>12.0</LangVersion>
<LangVersion>13.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Deterministic>true</Deterministic>
<DebugType>portable</DebugType>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>

<PropertyGroup>
<Authors>Banane9</Authors>

<PackageTags>IEnumerable; enumerable; tool; tools; toolkit; helper; linq</PackageTags>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<!--<PackageIconUrl></PackageIconUrl>
<PackageIconUrl>/Icon.png</PackageIconUrl>-->

<PackageProjectUrl>https://github.com/Banane9/EnumerableToolkit</PackageProjectUrl>
<RepositoryUrl>$(PackageProjectUrl).git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>

<IncludeSymbols>True</IncludeSymbols>
<EmbedAllSources>True</EmbedAllSources>
<EmbedUntrackedSources>True</EmbedUntrackedSources>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<!--<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>-->
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PolySharp" Version="1.14.1">
<PackageReference Include="PolySharp" Version="1.15.0">
<Private>False</Private>
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
29 changes: 14 additions & 15 deletions EnumerableToolkit.Async/AsyncTopologicalSortExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ public static class AsyncTopologicalSortExtensions
/// <summary>
/// Outputs all nodes that are part of cycles, given an expression that produces a set of connected nodes.
/// </summary>
/// <remarks>
/// Note that this method requires a full evaluation of the input sequence to produce an output.
/// </remarks>
/// <param name="nodes">The input nodes.</param>
/// <param name="identifier">Gets the dependency identifier of a node.</param>
/// <param name="connected">The expression producing connected nodes.</param>
/// <typeparam name="TNode">The node type.</typeparam>
/// <typeparam name="TDependency">The dependency connection type.</typeparam>
/// <returns>All input nodes that are part of a cycle.</returns>
public static async IAsyncEnumerable<TNode> FindCycles<TNode, TDependency>(this IAsyncEnumerable<TNode> nodes, Func<TNode, TDependency> identifier, Func<TNode, IEnumerable<TDependency>> connected)

where TNode : notnull
where TDependency : notnull
{
Expand All @@ -27,9 +29,9 @@ public static async IAsyncEnumerable<TNode> FindCycles<TNode, TDependency>(this

while (dependencies.Count > 0)
{
var key = dependencies.FirstOrDefault(x => x.Value.Count == 0).Key
var key = (await dependencies.ToAsyncEnumerable().FirstOrDefaultAsync(x => x.Value.Count == 0)).Key
?? throw new ArgumentException($"Cyclic dependencies are not allowed!{Environment.NewLine}" +
$"Sorted: {string.Join(", ", nodes.Select(identifier).ToEnumerable().Except(dependencies.Keys.Select(identifier)))}{Environment.NewLine}" +
$"Sorted: {string.Join(", ", nodes.Select(identifier).Except(dependencies.Keys.Select(identifier).ToAsyncEnumerable()))}{Environment.NewLine}" +
$"Unsorted:{Environment.NewLine}" +
$" {string.Join($"{Environment.NewLine} ", dependencies.Select(element => $"{identifier(element.Key)}:{Environment.NewLine} {string.Join($"{Environment.NewLine} ", element.Value)}"))}");

Expand All @@ -43,26 +45,23 @@ public static async IAsyncEnumerable<TNode> FindCycles<TNode, TDependency>(this
}
}

/// <summary>
/// Performs a topological sort of the input <paramref name="nodes"/>, given an expression that produces a set of connected nodes.
/// </summary>
/// <param name="nodes">The input nodes.</param>
/// <param name="connected">The expression producing connected nodes.</param>
/// <typeparam name="TNode">The node type.</typeparam>
/// <returns>The input nodes, sorted.</returns>
/// <exception cref="ArgumentException">Thrown if a cyclic dependency is found.</exception>
/// <inheritdoc cref="TopologicalSort{TNode, TDependency}(IAsyncEnumerable{TNode}, Func{TNode, TDependency}, Func{TNode, IEnumerable{TDependency}})"/>
public static IAsyncEnumerable<TNode> TopologicalSort<TNode>(this IAsyncEnumerable<TNode> nodes, Func<TNode, IEnumerable<TNode>> connected)
where TNode : notnull => nodes.TopologicalSort(node => node, connected);
where TNode : notnull
=> nodes.TopologicalSort(node => node, connected);

/// <summary>
/// Performs a topological sort of the input <paramref name="nodes"/>, given an expression that produces a set of connected nodes.
/// </summary>
/// <remarks>
/// Note that this method requires a full evaluation of the input sequence to produce an output.
/// </remarks>
/// <param name="nodes">The input nodes.</param>
/// <param name="identifier">Gets the dependency identifier of a node.</param>
/// <param name="connected">The expression producing connected nodes.</param>
/// <typeparam name="TNode">The node type.</typeparam>
/// <typeparam name="TDependency">The dependency connection type.</typeparam>
/// <returns>The input nodes, sorted .</returns>
/// <returns>The input nodes, sorted.</returns>
/// <exception cref="ArgumentException">Thrown if a cyclic dependency is found.</exception>
public static async IAsyncEnumerable<TNode> TopologicalSort<TNode, TDependency>(this IAsyncEnumerable<TNode> nodes, Func<TNode, TDependency> identifier, Func<TNode, IEnumerable<TDependency>> connected)
where TNode : notnull
Expand All @@ -72,9 +71,9 @@ public static async IAsyncEnumerable<TNode> TopologicalSort<TNode, TDependency>(

while (elements.Count > 0)
{
var key = elements.FirstOrDefault(x => x.Value.Count == 0).Key
var key = (await elements.ToAsyncEnumerable().FirstOrDefaultAsync(x => x.Value.Count == 0)).Key
?? throw new ArgumentException($"Cyclic dependencies are not allowed!{Environment.NewLine}" +
$"Sorted: {string.Join(", ", nodes.Select(identifier).ToEnumerable().Except(elements.Keys.Select(identifier)))}{Environment.NewLine}" +
$"Sorted: {string.Join(", ", nodes.Select(identifier).Except(elements.Keys.Select(identifier).ToAsyncEnumerable()))}{Environment.NewLine}" +
$"Unsorted:{Environment.NewLine}" +
$" {string.Join($"{Environment.NewLine} ", elements.Select(element => $"{identifier(element.Key)}:{Environment.NewLine} {string.Join($"{Environment.NewLine} ", element.Value)}"))}");

Expand Down
20 changes: 3 additions & 17 deletions EnumerableToolkit.Async/EnumerableToolkit.Async.csproj
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
</PropertyGroup>-->

<PropertyGroup>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<RootNamespace>EnumerableToolkit</RootNamespace>
<Title>$(AssemblyTitle)</Title>
<Authors>Banane9</Authors>
<Version>1.2.0</Version>
<Description>Contains helpful convenience methods to work with async enumerables.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/Banane9/EnumerableToolkit</PackageProjectUrl>
<RepositoryUrl>$(PackageProjectUrl).git</RepositoryUrl>
<!--<PackageIconUrl></PackageIconUrl>
<PackageIconUrl>/Icon.png</PackageIconUrl>-->
<PackageTags>IEnumerable; enumerable; tool; tools; toolkit; builder; helper; linq; async</PackageTags>
<PackageTags>$(PackageTags); IAsyncEnumerable; async</PackageTags>
</PropertyGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="" />
<!--<None Include="..\Icon.png" Pack="true" PackagePath="" /> -->
</ItemGroup>

<!-- <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
</ItemGroup>-->

<ItemGroup>
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="System.Linq.AsyncEnumerable" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<DefaultNamespace>EnumerableToolkit.Builder</DefaultNamespace>
</PropertyGroup>

<PropertyGroup>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<RootNamespace>EnumerableToolkit.Builder</RootNamespace>
<Title>$(AssemblyTitle)</Title>
<Authors>Banane9</Authors>
<Version>2.0.2</Version>
<Description>Adds an AsyncEnumerableBuilder to incrementally construct an async enumerable sequence out of building blocks.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/Banane9/EnumerableToolkit</PackageProjectUrl>
<RepositoryUrl>$(PackageProjectUrl).git</RepositoryUrl>
<!--<PackageIconUrl></PackageIconUrl>
<PackageIconUrl>/Icon.png</PackageIconUrl>-->
<PackageTags>IAsyncEnumerable; enumerable; tool; tools; toolkit; builder; helper; linq; async</PackageTags>
<PackageTags>$(PackageTags); IAsyncEnumerable; builder; async</PackageTags>
</PropertyGroup>

<ItemGroup>
<None Include="README.md" Pack="True" PackagePath="" />
<!--<None Include="..\Icon.png" Pack="true" PackagePath="" /> -->
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EnumerableToolkit.Async\EnumerableToolkit.Async.csproj" />
</ItemGroup>
Expand Down
8 changes: 1 addition & 7 deletions EnumerableToolkit.Builder/EnumerableToolkit.Builder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
<PropertyGroup>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>$(AssemblyTitle)</Title>
<Authors>Banane9</Authors>
<Version>2.0.2</Version>
<Description>Adds an EnumerableBuilder to incrementally construct an enumerable sequence out of building blocks.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/Banane9/EnumerableToolkit</PackageProjectUrl>
<RepositoryUrl>$(PackageProjectUrl).git</RepositoryUrl>
<!--<PackageIconUrl></PackageIconUrl>
<PackageIconUrl>/Icon.png</PackageIconUrl>-->
<PackageTags>IEnumerable; enumerable; tool; tools; toolkit; builder; helper; linq</PackageTags>
<PackageTags>$(PackageTags); builder</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions EnumerableToolkit.Tests/AssemblyAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
16 changes: 10 additions & 6 deletions EnumerableToolkit.Tests/EnumerableToolkit.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net48;net8.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="4.0.2" />
</ItemGroup>

<ItemGroup>
Expand All @@ -26,5 +31,4 @@
<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions EnumerableToolkit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnumerableToolkit.Builder.A
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnumerableToolkit.Tests", "EnumerableToolkit.Tests\EnumerableToolkit.Tests.csproj", "{0516AF95-0995-4C80-8F81-A5600D21D4D0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build.yml = .github\workflows\build.yml
.github\workflows\publish.yml = .github\workflows\publish.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -48,6 +54,9 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {5C6DBB92-7E98-4D41-B8DF-540417285AD4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {95A463BB-A248-4C31-A626-A45EAB2A9F09}
EndGlobalSection
Expand Down
8 changes: 0 additions & 8 deletions EnumerableToolkit/EnumerableToolkit.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>$(AssemblyTitle)</Title>
<Authors>Banane9</Authors>
<Version>1.3.1</Version>
<Description>Contains helpful convenience methods to work with enumerables and some more specific types.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/Banane9/EnumerableToolkit</PackageProjectUrl>
<RepositoryUrl>$(PackageProjectUrl).git</RepositoryUrl>
<!--<PackageIconUrl></PackageIconUrl>
<PackageIconUrl>/Icon.png</PackageIconUrl>-->
<PackageTags>IEnumerable; enumerable; tool; tools; toolkit; builder; helper; linq</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading