ConstExpr 0.2.0
See the version list below for details.
dotnet add package ConstExpr --version 0.2.0
NuGet\Install-Package ConstExpr -Version 0.2.0
<PackageReference Include="ConstExpr" Version="0.2.0" />
<PackageVersion Include="ConstExpr" Version="0.2.0" />
<PackageReference Include="ConstExpr" />
paket add ConstExpr --version 0.2.0
#r "nuget: ConstExpr, 0.2.0"
#:package ConstExpr@0.2.0
#addin nuget:?package=ConstExpr&version=0.2.0
#tool nuget:?package=ConstExpr&version=0.2.0
ConstExpr
A C# analyser and source generator library targeting .NET Standard 2.0.
The first implementation evaluates parameterless static [ConstExpr] methods returning int during compilation and generates interceptors that return their precomputed values. Direct calls are intercepted; method-group delegates continue to execute the original method. Consumers must enable interception for the ConstExpr.Generated namespace.
Evaluation currently compiles and loads the original compilation inside the compiler process. Methods must be compilable before generated source is added. General result types and isolated execution are outside this initial slice.
Structure
| Project | Responsibility |
|---|---|
ConstExpr |
The method-only [ConstExpr] attribute and application-facing contracts. |
ConstExpr.Core |
Roslyn-independent method evaluation and serialisation using System.Text.Json. |
ConstExpr.Roslyn |
Compiler integration and interceptor generation in ConstExpr.Roslyn.Generators. |
ConstExpr.Core.Tests |
TUnit tests for evaluation and serialisation. |
ConstExpr.Roslyn.Tests |
Compiler controls, pipeline tests, call-site theories, and source-edit tests. |
ConstExpr.IntegrationTests |
A consumer build and run using a temporary NuGet package. |
Roslyn references Core and contracts. Core references contracts. ArchonAnalysers enforces this direction and forbids Microsoft.CodeAnalysis* assembly references from Core and contracts. It is a private development dependency in every project and is excluded from the consumer package.
The three production projects target netstandard2.0. Test projects target net10.0. One ConstExpr package contains the contracts assembly under lib/netstandard2.0 and all three production assemblies under analyzers/dotnet/cs for generator dependency resolution. System.Text.Json and its transitive dependencies are bundled beside the generator. Core, Roslyn, and the bundled dependencies are not runtime references for applications. No Archon, Roslyn, or test package dependencies are exposed to consumers.
The generator uses Roslyn 5.0 and requires a compatible compiler host, such as the .NET 10 SDK.
Build and check the package
dotnet restore src/ConstExpr.slnx
dotnet build src/ConstExpr.slnx -c Release --no-restore
dotnet format src/ConstExpr.slnx --verify-no-changes --no-restore
dotnet pack src/ConstExpr.slnx -c Release --no-build --no-restore -o artifacts/packages
bash .github/scripts/check-package.sh 0.1.0
The package check validates the NuGet layout and dependency metadata. The integration test packs ConstExpr, then builds and runs a temporary consumer using that package.
Tests
dotnet test --solution src/ConstExpr.slnx -c Release --no-build --no-restore --report-trx --results-directory "$PWD/artifacts/test-results"
Releases
CI builds, checks formatting, and validates the NuGet package on pull requests. CD runs on changes to main, calculates a version from conventional commits, and publishes to NuGet.org and GitHub Packages before creating a GitHub release. v0.0.0 marks the initial repository commit for version calculation. CD also supports manual dispatch.
NuGet publishing uses NuGet/login@v1 with OIDC. The repository variable NUGET_USER is hughesjs. Publishing requires a NuGet trusted publishing policy with these values:
| Field | Value |
|---|---|
| Repository owner | ScottishTapWater |
| Repository | ConstExpr |
| Workflow file | cd.yml |
| Environment | Leave empty |
| Package scope | ConstExpr, including new packages |
The publishing step will fail until that policy exists.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.