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
19 changes: 9 additions & 10 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
<Project>
<!-- Shared package refs -->
<ItemGroup>
<!-- NBGV drives versions; PrivateAssets=all keeps it out of consumers -->
<PackageReference Include="Nerdbank.GitVersioning" Version="3.8.38-alpha" PrivateAssets="all" />

<PackageReference Include="Nerdbank.GitVersioning" PrivateAssets="all" />
<!-- SourceLink for GitHub -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<PackageReference Include="Microsoft.SourceLink.GitHub"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" />
</ItemGroup>

<!-- SourceLink / build hygiene -->

<PropertyGroup>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<Deterministic>true</Deterministic>
Expand Down Expand Up @@ -44,4 +38,9 @@
PackagePath="\"
Link="LICENSE" />
</ItemGroup>
<!-- Global project properies -->
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
</PropertyGroup>
</Project>
37 changes: 37 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- Development Tools -->
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.9.50" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
<PackageVersion Include="DotNext.Metaprogramming" Version="5.26.1" />
<PackageVersion Include="FastExpressionCompiler" Version="5.3.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<!-- Hyperbee.Json: conditional versions by target framework -->
<PackageVersion Include="Hyperbee.Json" Version="3.0.6" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageVersion Include="Hyperbee.Json" Version="3.1.2" Condition="'$(TargetFramework)' == 'net10.0'" />

<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.1" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="10.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="MSTest.TestAdapter" Version="4.0.2" />
<PackageVersion Include="MSTest.TestFramework" Version="4.0.2" />
<PackageVersion Include="Hyperbee.Collections" Version="2.6.4" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.1" />
<!-- Roslyn: use consistent version for all frameworks -->
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="5.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="5.0.0" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions Hyperbee.Expressions.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35122.118
# Visual Studio Version 18
VisualStudioVersion = 18.1.11312.151 d18.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6103145C-EC79-4B5F-9CE6-8F10BFC6ACC5}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
LICENSE = LICENSE
README.md = README.md
version.json = version.json
Expand Down
22 changes: 9 additions & 13 deletions src/Hyperbee.Expressions.Lab/Hyperbee.Expressions.Lab.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<IsPackable>true</IsPackable>

Expand Down Expand Up @@ -43,18 +41,16 @@
<None Include="..\..\assets\icon.png" Pack="true" Visible="false" PackagePath="/" />
<None Include="..\..\README.md" Pack="true" Visible="true" PackagePath="/" Link="README.md" />
<None Include="..\..\LICENSE" Pack="true" Visible="false" PackagePath="/" />
<PackageReference Include="Hyperbee.Collections" Version="2.4.0" />
<PackageReference Include="Hyperbee.Json" Version="3.0.6" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.8" />
<PackageReference Include="Hyperbee.Collections" />
<PackageReference Include="Hyperbee.Json" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Http" />
<ProjectReference Include="..\Hyperbee.Expressions\Hyperbee.Expressions.csproj" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Update="Microsoft.SourceLink.GitHub" />
</ItemGroup>

</Project>
18 changes: 7 additions & 11 deletions src/Hyperbee.Expressions/Hyperbee.Expressions.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<IsPackable>true</IsPackable>

Expand Down Expand Up @@ -43,15 +41,13 @@
<None Include="..\..\assets\icon.png" Pack="true" Visible="false" PackagePath="/" />
<None Include="..\..\README.md" Pack="true" Visible="true" PackagePath="/" Link="README.md" />
<None Include="..\..\LICENSE" Pack="true" Visible="false" PackagePath="/" />
<PackageReference Include="Hyperbee.Collections" Version="2.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.8" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Hyperbee.Collections" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Update="Microsoft.SourceLink.GitHub" />
</ItemGroup>

</Project>
10 changes: 9 additions & 1 deletion test/Hyperbee.Expressions.Benchmark/BenchmarkConfig.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
Expand All @@ -15,7 +16,14 @@ public class Config : ManualConfig
{
public Config()
{
AddJob( Job.ShortRun );
AddJob( Job.ShortRun
.WithRuntime( CoreRuntime.Core80 )
.WithId( ".NET 8" ) );

AddJob( Job.ShortRun
.WithRuntime( CoreRuntime.Core10_0 )
.WithId( ".NET 10" ) );


AddExporter( MarkdownExporter.GitHub );
AddValidator( JitOptimizationsValidator.DontFailOnError );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
<PackageReference Include="DotNext.Metaprogramming" Version="5.23.0" />
<PackageReference Include="FastExpressionCompiler" Version="5.1.1" />
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="DotNext.Metaprogramming" />
<PackageReference Include="FastExpressionCompiler" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Hyperbee.Expressions\Hyperbee.Expressions.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Update="Microsoft.SourceLink.GitHub" />
</ItemGroup>

</Project>
8 changes: 3 additions & 5 deletions test/Hyperbee.Expressions.Tests/BlockAsyncBasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@
[DataRow( CompilerType.Fast )]
[DataRow( CompilerType.System )]
[DataRow( CompilerType.Interpret )]
[ExpectedException( typeof( InvalidOperationException ) )]
public async Task BlockAsync_ShouldThrowException_WithFaultedTask( CompilerType compiler )
{

Check warning on line 125 in test/Hyperbee.Expressions.Tests/BlockAsyncBasicTests.cs

View workflow job for this annotation

GitHub Actions / test / test

Prefer 'Assert.ThrowsExactly/ThrowsExactlyAsync' over '[ExpectedException]' (https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0006)
// Arrange
var block = BlockAsync(
Await( Constant( Task.FromException<int>( new InvalidOperationException( "Test Exception" ) ) ) )
Expand All @@ -133,17 +132,16 @@
var compiledLambda = lambda.Compile( compiler );

// Act & Assert
await compiledLambda();
await Assert.ThrowsExactlyAsync<InvalidOperationException>( async () => await compiledLambda() );
}

[TestMethod]
[DataRow( CompilerType.Fast )]
[DataRow( CompilerType.System )]
[DataRow( CompilerType.Interpret )]
[ExpectedException( typeof( TaskCanceledException ) )]
public async Task BlockAsync_ShouldHandleCanceledTask_WithCancellation( CompilerType compiler )
{
// Arrange

Check warning on line 144 in test/Hyperbee.Expressions.Tests/BlockAsyncBasicTests.cs

View workflow job for this annotation

GitHub Actions / test / test

Prefer 'Assert.ThrowsExactly/ThrowsExactlyAsync' over '[ExpectedException]' (https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0006)
var cancellationTokenSource = new CancellationTokenSource();
await cancellationTokenSource.CancelAsync();

Expand All @@ -153,7 +151,7 @@
var compiledLambda = lambda.Compile( compiler );

// Act & Assert
await compiledLambda();
await Assert.ThrowsExactlyAsync<TaskCanceledException>( async () => await compiledLambda() );
}

[TestMethod]
Expand Down Expand Up @@ -554,7 +552,7 @@
var result = await compiledLambda();

// Assert
Assert.AreEqual( threadCount, result.Length );
Assert.HasCount( threadCount, result );
for ( var tC = 0; tC < threadCount; tC++ )
{
Assert.AreEqual( tC, result[tC] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ public async Task AsyncBlock_ShouldAwaitSuccessfully_WithConditionalReturningTas
}

[TestMethod]
[ExpectedException( typeof( NullReferenceException ) )]
public async Task AsyncBlock_ShouldThrowException_WithNullTaskInConditional()
{
// Arrange: One of the branches returns a null task, leading to exception
Expand All @@ -385,6 +384,6 @@ public async Task AsyncBlock_ShouldThrowException_WithNullTaskInConditional()
var compiledLambda = lambda.Compile();

// Act & Assert
await compiledLambda();
await Assert.ThrowsExactlyAsync<NullReferenceException>( async () => await compiledLambda() );
}
}
40 changes: 20 additions & 20 deletions test/Hyperbee.Expressions.Tests/BlockAsyncSwitchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,29 +189,29 @@ public async Task AsyncBlock_ShouldAwaitSuccessfully_WithNestedSwitchesAndAwaits
[DataRow( CompleterType.Deferred, CompilerType.Fast )]
[DataRow( CompleterType.Deferred, CompilerType.System )]
[DataRow( CompleterType.Deferred, CompilerType.Interpret )]
[ExpectedException( typeof( ArgumentException ) )]
public async Task AsyncBlock_ShouldThrowException_WithAwaitInSwitchCaseTestValues( CompleterType completer, CompilerType compiler )
{
// Arrange: Switch case test values cannot contain awaited tasks
var block = Switch(
Constant( 1 ),
Constant( 0 ),
SwitchCase(
Constant( 10 ),
Await( BlockAsync(
Await( AsyncHelper.Completer(
Constant( completer ),
Constant( 1 )
// Act & Assert: The exception should be thrown during lambda construction or compilation
await Assert.ThrowsExactlyAsync<ArgumentException>(async () =>
{
var block = Switch(
Constant( 1 ),
Constant( 0 ),
SwitchCase(
Constant( 10 ),
Await( BlockAsync(
Await( AsyncHelper.Completer(
Constant( completer ),
Constant( 1 )
) )
) )
) )
),
SwitchCase( Constant( 20 ), Constant( 2 ) )
);
var lambda = Lambda<Func<Task<int>>>( block );
var compiledLambda = lambda.Compile( compiler );

// Act
await compiledLambda();
),
SwitchCase( Constant( 20 ), Constant( 2 ) )
);
var lambda = Lambda<Func<Task<int>>>( block );
var compiledLambda = lambda.Compile( compiler );
await compiledLambda();
});
}

[TestMethod]
Expand Down
6 changes: 3 additions & 3 deletions test/Hyperbee.Expressions.Tests/BlockYieldConditionalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void YieldBlock_ShouldYieldSuccessfully_WithIfThenElseBreaks( CompilerTyp
var result = compiledLambda().ToArray();

// Assert
Assert.AreEqual( 1, result.Length );
Assert.HasCount( 1, result );
Assert.AreEqual( 10, result[0] );
}

Expand All @@ -109,7 +109,7 @@ public void YieldBlock_ShouldYieldSuccessfully_WithIfThen_TrueBreak( CompilerTyp
var result = compiledLambda().ToArray();

// Assert
Assert.AreEqual( 0, result.Length );
Assert.IsEmpty( result );
}

[TestMethod]
Expand All @@ -134,7 +134,7 @@ public void YieldBlock_ShouldYieldSuccessfully_WithIfThen_FalseBreak( CompilerTy
var result = compiledLambda().ToArray();

// Assert
Assert.AreEqual( 1, result.Length );
Assert.HasCount( 1, result );
Assert.AreEqual( 5, result[0] );
}

Expand Down
10 changes: 5 additions & 5 deletions test/Hyperbee.Expressions.Tests/BlockYieldLoopTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void YieldBlock_ShouldYieldSuccessfully_WithOutLoopBreakOrContinue( Compi
var result = compiledLambda().ToArray();

// Assert
Assert.AreEqual( 2, result.Length ); // Loop continues past the first iteration
Assert.HasCount( 2, result ); // Loop continues past the first iteration
Assert.AreEqual( 1, result[0] );
Assert.AreEqual( 2, result[1] );
}
Expand Down Expand Up @@ -152,7 +152,7 @@ public void YieldBlock_ShouldYieldSuccessfully_WithYieldBeforeContinue( Compiler
var result = compiledLambda().ToArray();

// Assert
Assert.AreEqual( 2, result.Length ); // Loop continues past the first iteration
Assert.HasCount( 2, result ); // Loop continues past the first iteration
Assert.AreEqual( 1, result[0] );
Assert.AreEqual( 2, result[1] );
}
Expand Down Expand Up @@ -192,7 +192,7 @@ public void YieldBlock_ShouldYieldSuccessfully_WithYieldAfterContinue( CompilerT
var result = compiledLambda().ToArray();

// Assert
Assert.AreEqual( 1, result.Length ); // Loop continues past the first iteration
Assert.HasCount( 1, result ); // Loop continues past the first iteration
Assert.AreEqual( 2, result[0] );
}

Expand Down Expand Up @@ -227,7 +227,7 @@ public void YieldBlock_ShouldYieldSuccessfully_WithMultipleYieldInLoop( Compiler
var result = compiledLambda().ToArray();

// Assert
Assert.AreEqual( 2, result.Length );
Assert.HasCount( 2, result );
Assert.AreEqual( 0, result[0] );
Assert.AreEqual( 1, result[1] );
}
Expand Down Expand Up @@ -272,7 +272,7 @@ public void YieldBlock_ShouldYieldSuccessfully_WithBreakAndContinueLabels( Compi
var result = compiledLambda().ToArray();

// Assert
Assert.AreEqual( 3, result.Length );
Assert.HasCount( 3, result );
Assert.AreEqual( 1, result[0] );
Assert.AreEqual( 2, result[1] );
Assert.AreEqual( 3, result[2] );
Expand Down
Loading
Loading