Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
89586a2
Add the functionality to use NativeAOT-LLVM to build a P1 .wasm (core…
JasonAtClockwork Apr 2, 2026
891a4b4
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff Apr 28, 2026
2351acb
Add support for .NET 8 JIT, .NET AOT and .NET 10 AOT in the same NuGe…
rekhoff Apr 29, 2026
3abc343
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff Apr 29, 2026
62f1354
Resolved 3 CI failures
rekhoff Apr 29, 2026
c3041ac
Update C# module smoketests for .NET 10, cli ref docs, and Unity Meta…
rekhoff Apr 29, 2026
98216f9
Update lint
rekhoff Apr 29, 2026
fcfbef2
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff Apr 29, 2026
1fe6d8b
Adding additional `dotnet-experimental` package sources
rekhoff Apr 30, 2026
8008c6e
Group package by source and install WASI SDK on Linux
rekhoff Apr 30, 2026
e3e1d78
Target Linux WASI SDK
rekhoff Apr 30, 2026
b0d1fc6
Added specific `dotnet-experimental` check for quickstart, and `WASI …
rekhoff Apr 30, 2026
171767f
Update lint
rekhoff Apr 30, 2026
551b656
Fix NativeAOT-LLVM CI build and add --dotnet-version flag
rekhoff May 1, 2026
15266d0
Update lint
rekhoff May 1, 2026
eb613c2
Added check if `WASI SDK` already installed, and changed target to ve…
rekhoff May 1, 2026
5e5ed90
Updated target framework to also check for `net10.0`
rekhoff May 3, 2026
73fceb0
Update `csharp_module` to use .NET 8 JIT path
rekhoff May 3, 2026
024bf61
Add `--from-previous-sdk` to `dotnet workload update`
rekhoff May 4, 2026
c2ac428
Adding additional `wasi-experimental` install locations
rekhoff May 5, 2026
0a9dd20
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 5, 2026
a1fd123
Write `global.json` files for .NET 8 workloads, to ensure `wasi-exper…
rekhoff May 5, 2026
633861a
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 5, 2026
aaf16d6
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 5, 2026
dba4176
Adds additional checks on when to use NativeAOT to the Runtime.props
rekhoff May 6, 2026
157499d
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 6, 2026
1304ac9
Adds a step to install native WASI SDK toolchain to the `csharp-tests…
rekhoff May 6, 2026
d645103
Adds a crash protection when `global.json` appears missing
rekhoff May 6, 2026
1fc33cf
Fixed logic error in crash protection when `global.json` appears missing
rekhoff May 6, 2026
044d516
Fix global.json symlinks for regression tests
rekhoff May 6, 2026
6655bff
Use absolute path to the repo root in GitHub Actions
rekhoff May 6, 2026
17ee828
Just creating the `global.json` if missing
rekhoff May 6, 2026
9273f4f
Restores the original global.json symlinks after regression test
rekhoff May 6, 2026
c320f48
Running `spacetimedb-sdk` test with `--test-threads=1` to avoid SIGKI…
rekhoff May 6, 2026
61d57eb
Reverting `spacetimedb-sdk` tests back to `--test-threads=2`
rekhoff May 6, 2026
2f268e8
Updates made to documentation
rekhoff May 7, 2026
3b5fb03
Setting CI test to use `ubuntu-latest` rather than `spacetimedb-new-r…
rekhoff May 7, 2026
1247efa
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 7, 2026
15ae5e8
Update Wasi SDK version back to 29
rekhoff May 7, 2026
764abb6
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 7, 2026
9902837
Move back to custom runner
jdetter May 8, 2026
8d9f5e3
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 8, 2026
ee9ddce
Remove `run_dlls` function from `main.rs`
rekhoff May 8, 2026
adf35e5
Update lint
rekhoff May 8, 2026
ee130e4
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 11, 2026
576db3e
Fixed some dotnet version ordering logic
rekhoff May 11, 2026
a5a0d58
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 11, 2026
b0ce8d3
Resolve conflict with .NET 8 GC removing a needed .NET 10 workload
rekhoff May 12, 2026
b023178
Explicitly adding `EXPERIMENTAL_WASM_AOT` to .NET restore
rekhoff May 12, 2026
2f612bd
Adding a cache clearing step for AOT paths to prevent fallback to .NE…
rekhoff May 12, 2026
503f790
Moved `EXPERIMENTAL_WASM_AOT` set to start of `csharp-testsuite` job
rekhoff May 12, 2026
283ce83
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 14, 2026
01f4b74
Support Net8 JIT "bindings" ABI and fix CLI native_aot env isolation
rekhoff May 15, 2026
e3999d9
Update lint
rekhoff May 15, 2026
2d06a3d
Moved `EXPERIMENTAL_WASM_AOT` to Override NuGet packages step
rekhoff May 16, 2026
25ceaee
Only delete `project.assets.json` for `Net8Aot`
rekhoff May 16, 2026
95f0f67
Add diagnostic for `bin_dir_name`
rekhoff May 16, 2026
b92a91c
Update lint
rekhoff May 16, 2026
202f125
Additional diagnostics
rekhoff May 16, 2026
e0961df
Fix `IL1034` entry point error and schema extraction hang
rekhoff May 18, 2026
8bb32ef
Update C# regression test targets to .NET 10
rekhoff May 18, 2026
2e3df4b
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 19, 2026
5bb5829
Revert bindings namespace and fix NativeAOT-LLVM builds
rekhoff May 19, 2026
64337ca
Add `--dotnet-version 8` to `test_quickstart_csharp` test
rekhoff May 19, 2026
27c7912
Suppress the hardcoded wasi-sdk version check in WasiApp.targets
rekhoff May 20, 2026
d7753be
Move `WasmSingleFileBundle` to the non-AOT path of Runtime.props
rekhoff May 20, 2026
92d2daa
Suppress the Mono/WasiApp.targets pipeline for AOT
rekhoff May 20, 2026
2fee8d8
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 21, 2026
fcf09c5
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 21, 2026
3221c3b
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 23, 2026
be0975d
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 26, 2026
5745f96
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 27, 2026
a680920
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 28, 2026
ea42791
Corrected merge conflict issue
rekhoff May 28, 2026
eafe0e1
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 29, 2026
7f730ad
Merge branch 'master' into rekhoff/nativeaot-net10
rekhoff May 29, 2026
4b203d1
Merge branch 'master' into rekhoff/nativeaot-net10
lisandroct Jun 12, 2026
199f167
Merge branch 'master' into rekhoff/nativeaot-net10
jdetter Jun 15, 2026
fd119d2
Merge branch 'master' into rekhoff/nativeaot-net10
lisandroct Jun 16, 2026
7523e2e
Minor cleanup
lisandroct Jun 9, 2026
5f10d9e
Fix compilation error due to uint [CallerLineNumber]
lisandroct Jun 9, 2026
e980a41
Fix TaggedEnumInlineTuple verify error
lisandroct Jun 22, 2026
dc1e2b2
Update to Roslyn 5.0.0 and add net10.0 target to test projects
lisandroct Jun 22, 2026
6ad1c62
Fix Lint
lisandroct Jun 22, 2026
feddae6
Add net10.0 target to chat-console-cs
lisandroct Jun 22, 2026
4c569c2
Add net10.0 target to basic-cs template
lisandroct Jun 22, 2026
27677e7
Add global.json files back but targeting .NET 10
lisandroct Jun 23, 2026
d7da8d6
Target .NET 10 on Smoketests
lisandroct Jun 23, 2026
3f27385
Force publishing Smoketest targeting .NET 10
lisandroct Jun 23, 2026
bce67fd
Merge branch 'master' into rekhoff/nativeaot-net10
lisandroct Jun 23, 2026
7146438
Potential fix for smoketests
lisandroct Jun 23, 2026
ccfc214
Change Microsoft.CodeAnalysis.CSharp version back to 4.3.1
lisandroct Jun 23, 2026
629cf84
Make templates target .NET 10 only
lisandroct Jun 24, 2026
1654e6f
Fix <TargetFrameworks> to <TargetFramework> in templates
lisandroct Jun 24, 2026
4321ae8
Clean Runtime.csproj
lisandroct Jun 24, 2026
ce0386d
Keep ;$(RestoreAdditionalProjectSources)
lisandroct Jun 24, 2026
05b8632
Restore RestoreAdditionalProjectSources
lisandroct Jun 24, 2026
6c48f76
Force define EXPERIMENTAL_WASM_AOT in .NET 10
lisandroct Jun 24, 2026
a90fe1e
Fix NativeAOT-LLVM packages resolution
lisandroct Jun 24, 2026
1d25e18
Clean up some .csproj
lisandroct Jun 24, 2026
057383a
Start assuming .NET 10 is the default
lisandroct Jun 24, 2026
7bbdd0f
Fix Lint
lisandroct Jun 24, 2026
cda92ff
Update last bits to net10.0
lisandroct Jun 25, 2026
f80988b
Add purely style warnings to WarningsNotAsErrors for Test Suite to pass
lisandroct Jun 25, 2026
0276a71
Merge branch 'master' into rekhoff/nativeaot-net10
lisandroct Jun 25, 2026
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
136 changes: 134 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,26 @@ jobs:
./emsdk install 4.0.21
./emsdk activate 4.0.21

# Install WASI SDK for .NET 10 NativeAOT-LLVM compilation.
- name: Install WASI SDK (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
WASI_SDK_VERSION="29"
WASI_SDK_PATH="/opt/wasi-sdk"
if [ -d "$WASI_SDK_PATH" ] && [ -f "$WASI_SDK_PATH/bin/clang" ]; then
echo "WASI SDK already installed at $WASI_SDK_PATH"
else
echo "Installing WASI SDK version $WASI_SDK_VERSION..."
wget -q "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz"
tar -xzf "wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz"
sudo mv "wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux" "$WASI_SDK_PATH"
rm -f "wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz"
echo "WASI SDK installed successfully"
fi
echo "WASI_SDK_PATH=$WASI_SDK_PATH" >> "$GITHUB_ENV"
echo "Using WASI SDK at: $WASI_SDK_PATH"

- name: Install emscripten (Windows)
if: runner.os == 'Windows'
shell: pwsh
Expand All @@ -153,6 +173,29 @@ jobs:
.\emsdk install 4.0.21
.\emsdk activate 4.0.21

# Install WASI SDK for .NET 10 NativeAOT-LLVM compilation.
- name: Install WASI SDK (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$wasiSdkVersion = "25"
$wasiDir = "$env:USERPROFILE\.wasi-sdk"
$clangPath = Join-Path $wasiDir "bin\clang.exe"
if (Test-Path $clangPath) {
Write-Host "WASI SDK already installed at $wasiDir"
} else {
Write-Host "Installing WASI SDK version $wasiSdkVersion..."
$wasiUrl = "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${wasiSdkVersion}/wasi-sdk-${wasiSdkVersion}.0-x86_64-windows.tar.gz"
Invoke-WebRequest -Uri $wasiUrl -OutFile "$env:TEMP\wasi-sdk.tar.gz"
New-Item -ItemType Directory -Force -Path $wasiDir | Out-Null
& "$env:SystemRoot\System32\tar.exe" -xzf "$env:TEMP\wasi-sdk.tar.gz" -C $wasiDir --strip-components=1
Remove-Item "$env:TEMP\wasi-sdk.tar.gz" -Force -ErrorAction SilentlyContinue
Write-Host "WASI SDK installed successfully"
}
echo "WASI_SDK_PATH=$wasiDir" >> $env:GITHUB_ENV
Write-Host "Using WASI SDK at: $wasiDir"

- name: Install psql (Windows)
if: runner.os == 'Windows'
shell: pwsh
Expand All @@ -173,9 +216,14 @@ jobs:
$PSNativeCommandUseErrorActionPreference = $true

cd modules
# the sdk-manifests on windows-latest are messed up, so we need to update them
dotnet workload config --update-mode manifests
dotnet workload update
dotnet workload update --from-previous-sdk
# Explicitly install wasi-experimental for .NET 8 SDK (needed for test_build_csharp_module)
# Create temp global.json to target .NET 8 SDK for workload install
$sdk8Json = '{"sdk":{"version":"8.0.400","rollForward":"latestFeature"}}'
$sdk8Json | Out-File -FilePath global.json -Encoding utf8
dotnet workload install wasi-experimental
Remove-Item global.json

- name: Override NuGet packages
shell: bash
Expand Down Expand Up @@ -314,6 +362,25 @@ jobs:
./emsdk install 4.0.21
./emsdk activate 4.0.21

# Install WASI SDK for .NET 10 NativeAOT-LLVM compilation (idempotent - checks if already exists).
- name: Install WASI SDK
shell: bash
run: |
WASI_SDK_VERSION="29"
WASI_SDK_PATH="/opt/wasi-sdk"
if [ -d "$WASI_SDK_PATH" ] && [ -f "$WASI_SDK_PATH/bin/clang" ]; then
echo "WASI SDK already installed at $WASI_SDK_PATH"
else
echo "Installing WASI SDK version $WASI_SDK_VERSION..."
wget -q "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz"
tar -xzf "wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz"
sudo mv "wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux" "$WASI_SDK_PATH"
rm -f "wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz"
echo "WASI SDK installed successfully"
fi
echo "WASI_SDK_PATH=$WASI_SDK_PATH" >> "$GITHUB_ENV"
echo "Using WASI SDK at: $WASI_SDK_PATH"

- name: Install wasm-bindgen CLI
run: |
REQUIRED_WASM_BINDGEN_VERSION="$(
Expand Down Expand Up @@ -1061,7 +1128,57 @@ jobs:
with:
global-json-file: global.json

- name: Install .NET workloads
run: |
dotnet workload config --update-mode manifests
dotnet workload update --from-previous-sdk
# Explicitly install wasi-experimental for .NET 8 SDK (needed for test_build_csharp_module)
# Create temp global.json to target .NET 8 SDK for workload install
echo '{"sdk":{"version":"8.0.400","rollForward":"latestFeature"}}' > global.json
dotnet workload install wasi-experimental
rm global.json
# Reinstall wasi-experimental for .NET 10 SDK: the .NET 8 install above triggers garbage
# collection that removes the .NET 10 workload packs installed by `workload update`.
# The regression-test server targets net10.0, so we need the .NET 10 packs restored.
dotnet workload install wasi-experimental

# Install native WASI SDK toolchain (needed by WasiApp.Native.targets to compile native files).
- name: Install WASI SDK
run: |
WASI_SDK_VERSION="29"
WASI_SDK_PATH="/opt/wasi-sdk"
if [ -d "$WASI_SDK_PATH" ] && [ -f "$WASI_SDK_PATH/bin/clang" ]; then
echo "WASI SDK already installed at $WASI_SDK_PATH"
else
echo "Installing WASI SDK version $WASI_SDK_VERSION..."
wget -q "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz"
tar -xzf "wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz"
sudo mv "wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux" "$WASI_SDK_PATH"
rm -f "wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz"
echo "WASI SDK installed successfully"
fi
echo "WASI_SDK_PATH=$WASI_SDK_PATH" >> "$GITHUB_ENV"
echo "Using WASI SDK at: $WASI_SDK_PATH"

# Ensure global.json files exist for regression tests (symlinks may not work in CI)
- name: Fix global.json symlinks
run: |
for dir in sdks/csharp/examples~/regression-tests/server \
sdks/csharp/examples~/regression-tests/republishing/server-initial \
sdks/csharp/examples~/regression-tests/republishing/server-republish; do
if [ -L "$dir/global.json" ] && [ ! -f "$dir/global.json" ]; then
echo "Fixing broken symlink at $dir/global.json"
rm -f "$dir/global.json"
fi
if [ ! -f "$dir/global.json" ]; then
echo "Creating $dir/global.json"
echo '{"sdk":{"version":"10.0.100","rollForward":"latestMinor"}}' > "$dir/global.json"
fi
done

- name: Override NuGet packages
env:
EXPERIMENTAL_WASM_AOT: 1
run: |
dotnet pack crates/bindings-csharp/BSATN.Runtime
dotnet pack crates/bindings-csharp/Runtime
Expand Down Expand Up @@ -1156,6 +1273,21 @@ jobs:
- name: Run regression tests
run: |
bash sdks/csharp/tools~/run-regression-tests.sh
# Restore global.json symlinks (we replaced them with files to work around .NET 10 SDK bug)
# server is 5 levels deep from root, republishing dirs are 6 levels deep
if [ -f sdks/csharp/examples~/regression-tests/server/global.json ] && [ ! -L sdks/csharp/examples~/regression-tests/server/global.json ]; then
echo "Restoring symlink at server/global.json"
rm -f sdks/csharp/examples~/regression-tests/server/global.json
ln -s ../../../../../global.json sdks/csharp/examples~/regression-tests/server/global.json
fi
for dir in sdks/csharp/examples~/regression-tests/republishing/server-initial \
sdks/csharp/examples~/regression-tests/republishing/server-republish; do
if [ -f "$dir/global.json" ] && [ ! -L "$dir/global.json" ]; then
echo "Restoring symlink at $dir/global.json"
rm -f "$dir/global.json"
ln -s ../../../../../../global.json "$dir/global.json"
fi
done
tools/check-diff.sh sdks/csharp/examples~/regression-tests || {
echo 'Error: Bindings are dirty. Please run `sdks/csharp/tools~/gen-regression-tests.sh`.'
exit 1
Expand Down
11 changes: 7 additions & 4 deletions crates/bindings-csharp/BSATN.Codegen/Diag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,16 @@ EnumDeclarationSyntax @enum
@enum => @enum.Members[256]
);

public static readonly ErrorDescriptor<INamedTypeSymbol> TaggedEnumInlineTuple =
public static readonly ErrorDescriptor<(
INamedTypeSymbol baseType,
SyntaxNode location
)> TaggedEnumInlineTuple =
new(
group,
"Tagged enum variants must be declared with inline tuples",
baseType =>
$"{baseType} does not have the expected format SpacetimeDB.TaggedEnum<(TVariant1 v1, ..., TVariantN vN)>.",
baseType => baseType
ctx =>
$"{ctx.baseType} does not have the expected format SpacetimeDB.TaggedEnum<(TVariant1 v1, ..., TVariantN vN)>.",
ctx => ctx.location
);

public static readonly ErrorDescriptor<IFieldSymbol> TaggedEnumField =
Expand Down
8 changes: 7 additions & 1 deletion crates/bindings-csharp/BSATN.Codegen/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,13 @@
is not INamedTypeSymbol { IsTupleType: true, TupleElements: var taggedEnumVariants }
)
{
diag.Report(ErrorDescriptor.TaggedEnumInlineTuple, type.BaseType);
diag.Report(
ErrorDescriptor.TaggedEnumInlineTuple,
(
type.BaseType,
(SyntaxNode?)typeSyntax.BaseList?.Types.FirstOrDefault()?.Type ?? typeSyntax
)
);
}

if (fields.FirstOrDefault() is { } field)
Expand Down Expand Up @@ -734,7 +740,7 @@

write = "value.WriteFields(writer);";

var declHashName = (MemberDeclaration decl) => $"___hash{decl.Name}";

Check warning on line 743 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / godot-testsuite

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

Check warning on line 743 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / unity-testsuite

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

Check warning on line 743 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / csharp-testsuite

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

Check warning on line 743 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Linux)

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

Check warning on line 743 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Windows)

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

Check warning on line 743 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / Test Suite

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

getHashCode = $$"""
{{string.Join("\n", bsatnDecls.Select(decl => decl.Type.GetHashCodeStatement(decl.Identifier, declHashName(decl))))}}
Expand Down Expand Up @@ -783,7 +789,7 @@
// If we are a reference type, various equality methods need to take nullable references.
// If we are a value type, everything is pleasantly by-value.
var fullNameMaybeRef = $"{FullName}{(Scope.IsStruct ? "" : "?")}";
var declEqualsName = (MemberDeclaration decl) => $"___eq{decl.Name}";

Check warning on line 792 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / godot-testsuite

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

Check warning on line 792 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / unity-testsuite

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

Check warning on line 792 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / csharp-testsuite

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

Check warning on line 792 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Linux)

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

Check warning on line 792 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Windows)

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

Check warning on line 792 in crates/bindings-csharp/BSATN.Codegen/Type.cs

View workflow job for this annotation

GitHub Actions / Test Suite

Use local function (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0039)

extensions.Contents.Append(
$$"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<RootNamespace>SpacetimeDB</RootNamespace>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-csharp/BSATN.Runtime/BSATN.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<PropertyGroup>
<!-- Note: the binary produced by this package is used in Unity too, which is limited to .NET Standard 2.1. -->
<TargetFrameworks>netstandard2.1;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.1;net8.0;net10.0</TargetFrameworks>
<RootNamespace>SpacetimeDB</RootNamespace>
<!-- You can enable this when debugging codegen problems. Outputs in obj/debug/[version]/generated. -->
<!-- <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> -->
Expand Down
10 changes: 5 additions & 5 deletions crates/bindings-csharp/Codegen.Tests/Codegen.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<RootNamespace>SpacetimeDB.Codegen.Tests</RootNamespace>
<DefaultItemExcludes>$(DefaultItemExcludes);fixtures/**/*</DefaultItemExcludes>
</PropertyGroup>
Expand All @@ -18,10 +18,10 @@

<ItemGroup>
<PackageReference Include="CSharpier.Core" Version="0.28.2" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.10.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="5.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="Verify.SourceGenerators" Version="2.4.3" />
<PackageReference Include="Verify.XUnit" Version="26.4.5" />
Expand Down
42 changes: 21 additions & 21 deletions crates/bindings-csharp/Codegen.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ public static class GeneratorSnapshotTests

record struct StepOutput(string Key, IncrementalStepRunReason Reason, object Value);

class Fixture
private class Fixture
{
private readonly string projectDir;
private readonly CSharpCompilation sampleCompilation;
public CSharpCompilation SampleCompilation { get; }
public CSharpParseOptions ParseOptions { get; }

public Fixture(string projectDir, CSharpCompilation sampleCompilation)
{
this.projectDir = projectDir;
this.sampleCompilation = sampleCompilation;
SampleCompilation = sampleCompilation;
ParseOptions = (CSharpParseOptions)sampleCompilation.SyntaxTrees.First().Options;
}

public CSharpCompilation SampleCompilation => sampleCompilation;

public static async Task<Fixture> Compile(string name)
{
var projectDir = Path.Combine(GetProjectDir(), "fixtures", name);
Expand All @@ -53,7 +53,7 @@ public Task Verify(string fileName, object target) =>

private static CSharpGeneratorDriver CreateDriver(
IIncrementalGenerator generator,
LanguageVersion languageVersion
CSharpParseOptions parseOptions
)
{
return CSharpGeneratorDriver.Create(
Expand All @@ -62,39 +62,39 @@ LanguageVersion languageVersion
disabledOutputs: IncrementalGeneratorOutputKind.None,
trackIncrementalGeneratorSteps: true
),
// Make sure that generated files are parsed with the same language version.
parseOptions: new(languageVersion)
// Make sure generated files are parsed with the same language version and feature flags.
parseOptions: parseOptions
);
}

private async Task<IEnumerable<SyntaxTree>> RunAndCheckGenerator(
IIncrementalGenerator generator
)
{
var driver = CreateDriver(generator, sampleCompilation.LanguageVersion);
var driver = CreateDriver(generator, ParseOptions);

// Store the new driver instance - it contains the results and the cache.
var driverAfterGen = driver.RunGenerators(sampleCompilation);
var driverAfterGen = driver.RunGenerators(SampleCompilation);
var genResult = driverAfterGen.GetRunResult();

// Verify the generated code against the snapshots.
await Verify(generator.GetType().Name, genResult);

CheckCacheWorking(sampleCompilation, driverAfterGen);
CheckCacheWorking(SampleCompilation, driverAfterGen);

return genResult.GeneratedTrees;
}

public GeneratorDriverRunResult RunGeneratorAndGetResult(IIncrementalGenerator generator)
{
var driver = CreateDriver(generator, sampleCompilation.LanguageVersion);
return driver.RunGenerators(sampleCompilation).GetRunResult();
var driver = CreateDriver(generator, ParseOptions);
return driver.RunGenerators(SampleCompilation).GetRunResult();
}

public async Task<CSharpCompilation> RunAndCheckGenerators(
params IIncrementalGenerator[] generators
) =>
sampleCompilation.AddSyntaxTrees(
SampleCompilation.AddSyntaxTrees(
(await Task.WhenAll(generators.Select(RunAndCheckGenerator))).SelectMany(output =>
output
)
Expand Down Expand Up @@ -241,10 +241,7 @@ public static async Task TypeAndModuleGeneratorsOnServer()
// make sure a downstream "user" file that references SpacetimeDB.Local doesn't trigger CS0436.
var userCode =
"namespace User; public sealed class UseLocal { public SpacetimeDB.Local Db; }";
var userTree = CSharpSyntaxTree.ParseText(
userCode,
new CSharpParseOptions(compilationAfterGen.LanguageVersion)
);
var userTree = CSharpSyntaxTree.ParseText(userCode, fixture.ParseOptions);
var compilationWithUserCode = compilationAfterGen.AddSyntaxTrees(userTree);
AssertNoCs0436Diagnostics(compilationWithUserCode);
}
Expand Down Expand Up @@ -332,8 +329,11 @@ public static void @params(ProcedureContext ctx)
}
""";

var parseOptions = new CSharpParseOptions(fixture.SampleCompilation.LanguageVersion);
var tree = CSharpSyntaxTree.ParseText(source, parseOptions, path: "KeywordNames.cs");
var tree = CSharpSyntaxTree.ParseText(
source,
fixture.ParseOptions,
path: "KeywordNames.cs"
);
var compilation = fixture.SampleCompilation.AddSyntaxTrees(tree);

var driver = CSharpGeneratorDriver.Create(
Expand All @@ -345,7 +345,7 @@ public static void @params(ProcedureContext ctx)
disabledOutputs: IncrementalGeneratorOutputKind.None,
trackIncrementalGeneratorSteps: true
),
parseOptions: parseOptions
parseOptions: fixture.ParseOptions
);

var runResult = driver.RunGenerators(compilation).GetRunResult();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down
Loading
Loading