Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
33 changes: 28 additions & 5 deletions .github/workflows/analyzer-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,47 @@ jobs:
--output $output
& (Join-Path $output 'Orleans.Serialization.TrimmedSmoke')

dependency-injection-trimmed-smoke:
name: Orleans.DependencyInjection trimmed smoke for selected generic DI constructor flows (net10.0)
dependency-injection-smoke:
name: Orleans.DependencyInjection ${{ matrix.mode }} smoke for selected generic DI constructor flows (net10.0)
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- mode: trimmed
native-aot: false
- mode: NativeAOT
native-aot: true
env:
RESULTS_DIRECTORY: Artifacts/AnalyzerAudit/DependencyInjection/${{ matrix.mode }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5
with:
global-json-file: global.json
- name: Publish and run selected generic DI constructor flows trimmed smoke
- name: Publish and run selected generic DI constructor flows smoke
shell: pwsh
run: |
$output = Join-Path $env:RUNNER_TEMP 'orleans-dependency-injection-trimmed-smoke'
$output = Join-Path $env:RUNNER_TEMP 'orleans-dependency-injection-${{ matrix.mode }}-smoke'
New-Item -ItemType Directory -Force $env:RESULTS_DIRECTORY | Out-Null
dotnet publish test/Orleans.DependencyInjection.TrimmedSmoke/Orleans.DependencyInjection.TrimmedSmoke.csproj `
--framework net10.0 `
--configuration Release `
--runtime linux-x64 `
--self-contained true `
--output $output
--output $output `
-bl:$env:RESULTS_DIRECTORY/publish.binlog `
-p:NativeAotSmoke=${{ matrix.native-aot }}
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& (Join-Path $output 'Orleans.DependencyInjection.TrimmedSmoke')
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Upload dependency injection smoke diagnostics
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: dependency-injection-${{ matrix.mode }}-smoke
retention-days: 1
if-no-files-found: warn
path: ${{ env.RESULTS_DIRECTORY }}
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ dotnet test --solution Orleans.slnx --framework net10.0 --filter-trait "Category
dotnet test --project test/Orleans.Core.Tests/Orleans.Core.Tests.csproj --framework net10.0 --filter-class "*MyTestClass*" --filter-method "*MyTestMethod*" --minimum-expected-tests 1
```

### NativeAOT smoke tests

The dependency-injection smoke exercises placement strategy and director registration, keyed service resolution, constructor dependency identity, and lifecycle-driven startup task activation. The static analysis workflow publishes and executes these flows with both trimming and NativeAOT.

To execute the native smoke on Windows, install the [NativeAOT C++ toolchain prerequisites](https://learn.microsoft.com/dotnet/core/deploying/native-aot/), then run:

```console
dotnet publish test\Orleans.DependencyInjection.TrimmedSmoke\Orleans.DependencyInjection.TrimmedSmoke.csproj --framework net10.0 --configuration Release --runtime win-x64 --self-contained true -p:NativeAotSmoke=true --output Artifacts\DependencyInjectionNativeAotSmoke
Artifacts\DependencyInjectionNativeAotSmoke\Orleans.DependencyInjection.TrimmedSmoke.exe
```

`NativeAotSmoke=true` enables `PublishAot` within the smoke project, keeping build-time analyzers and source generators on their managed target frameworks. The executable verifies that runtime code generation is disabled before exercising the selected DI flows. Use `NativeAotSmoke=false` to execute the same flows in a self-contained trimmed application.

### Work on an application with local source

For an application which needs to exercise an unreleased change, reference the relevant project under `src` instead of the published NuGet package. For example, reference `src/Orleans.Core/Orleans.Core.csproj` from the application project and build the application together with the Orleans solution. This lets the debugger step into the local Orleans source.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<IsOrleansFrameworkPart>false</IsOrleansFrameworkPart>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>link</TrimMode>
<PublishAot Condition="'$(NativeAotSmoke)' == 'true'">true</PublishAot>
<DefineConstants Condition="'$(NativeAotSmoke)' == 'true'">$(DefineConstants);NATIVE_AOT_SMOKE</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 6 additions & 1 deletion test/Orleans.DependencyInjection.TrimmedSmoke/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ internal static class Program

private static async Task Main()
{
#if NATIVE_AOT_SMOKE
Ensure(
!System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported,
"The NativeAOT smoke must execute with runtime code generation disabled.");
#endif
ValidateCoreRegistration();
ValidateRuntimeRegistration();
await ValidateStartupTaskActivation();

Console.WriteLine("Selected generic DI constructor flows survived the self-contained trimmed smoke.");
Console.WriteLine("Selected generic DI constructor flows activated successfully.");
}

private static void ValidateCoreRegistration()
Expand Down
Loading