Platform Support and .NET 11
Platform Support and .NET 11
Section titled “Platform Support and .NET 11”This page lists the target frameworks and hosting models the generator supports, what the generated code guarantees under trimming and Native AOT, and what .NET 11 changes. Every “Verified by” entry names a gate that runs on each release; see Release Flow.
What’s new for .NET 11
Section titled “What’s new for .NET 11”ActivitySourceFactory(opt-in).[assembly: ActivitySourceGeneration(..., UseActivitySourceFactory = true)]makes the generated classes create their sources from the injected .NET 11 factory, registered withservices.AddTracing(), instead of a staticActivitySource. See Activities.TSG3023reports the option when the factory type is unavailable.- Static interface members are ignored. C# 15 lets an interface declare non-virtual static members on any runtime.
The generator and analyzer now skip static members everywhere, so a static helper on a telemetry interface is no
longer implemented as an instance method or reported as a duplicate name (
TSG1003). - Validated on .NET 11. The integration tests run on a
net11.0leg. The packed-consumer gate buildsnet11.0Native AOT, Blazor WebAssembly (trimmed and AOT) and Blazor Server consumers of the.nupkg. - No reference to the logging abstractions is needed on
net11.0. .NET 11 shipsMicrosoft.Extensions.Logging.Abstractions,Microsoft.Extensions.Diagnostics.AbstractionsandMicrosoft.Extensions.DependencyInjection.Abstractionsin the shared framework, and NuGet reportsNU1510for an explicit reference. (breaking change)
Support matrix
Section titled “Support matrix”Target frameworks
Section titled “Target frameworks”| Consumer target | Activities | Logging v1 | Logging v2 | Metrics | Meters from IMeterFactory | UseActivitySourceFactory | Verified by |
|---|---|---|---|---|---|---|---|
.NET Framework 4.8 (net48+) | Yes | Yes | Yes¹ | Yes | No (new Meter(...)) | With System.Diagnostics.DiagnosticSource 11+ | Integration tests (net48 leg, Windows), SampleApp.Net48 |
| .NET 8, .NET 9 | Yes | Yes | Yes¹ | Yes | Yes | Not supported² | Integration tests (net8.0, net9.0 legs) |
| .NET 10 | Yes | Yes | Yes¹ | Yes | Yes | With System.Diagnostics.DiagnosticSource 11+ | Integration tests, SampleApp, SampleApp.MultiProject |
| .NET 11 | Yes | Yes | Yes¹ | Yes | Yes | Yes | Integration tests (net11.0 leg), packed-consumer gate |
netstandard2.0 and other TFMs | Not supported: reported as TSG1011 (unsupported target framework). Multi-target the library to net48/net8.0+ instead. | - |
The UseActivitySourceFactory entries for net48 and net10.0 follow from the package’s assets and are not run by a gate; only net11.0 is.
¹ Logging v2 needs Microsoft.Extensions.Telemetry.Abstractions (LoggerMessageHelper); without it the generator
uses v1. See Logging Generation v2.
² The System.Diagnostics.DiagnosticSource 11 package has no net8.0/net9.0 asset. Those targets would get its
netstandard2.0 asset, and the package’s build targets warn that the framework is unsupported.
Build toolchain: Visual Studio 2026 (18.x) or the .NET 10 SDK or later (Roslyn 5.9.0+). The generator itself is a
netstandard2.0 Roslyn component. This repository builds and validates with the .NET 11 SDK pinned in global.json.
Hosting and render models
Section titled “Hosting and render models”| Model | Status | Verified by |
|---|---|---|
| Console / worker / library | Supported | SampleApp.MultiProject (net10.0), packed-consumer Native AOT console (net11.0) |
| ASP.NET Core | Supported | SampleApp API service (net10.0), packed-consumer Blazor Server host (net11.0) |
| .NET Aspire | Supported. Pass TelemetryNames.ActivitySourceNames/MeterNames to your service defaults. | SampleApp AppHost (net10.0) |
| Native AOT | Supported, with no trim or AOT warning from the generated code | Packed-consumer gate (a): published with -warnaserror, then run, and the emitted activities, metrics and logs asserted |
| Blazor WebAssembly, trimmed | Supported | Packed-consumer gate (b): published trimmed with -warnaserror; every generated member must survive ILLink |
Blazor WebAssembly, AOT (RunAOTCompilation) | Supported | Packed-consumer gate (b): every generated method must be AOT-compiled to WebAssembly |
| Blazor Server (interactive server) | Supported | Packed-consumer gate (c): page rendered on a TestServer, telemetry asserted |
| .NET Framework 4.8 applications | Supported | SampleApp.Net48, net48 integration tests |
The packed-consumer gate consumes the .nupkg exactly as a user does, and each of its applications also references a
class library with its own generated telemetry. On every run it exercises both a factory-created (UseActivitySourceFactory)
source and a static one.
Trim and AOT guarantees
Section titled “Trim and AOT guarantees”- No reflection, no dynamic code. The generated classes call
ActivitySource,ILoggerandMeterAPIs directly, with no reflection,Expressioncompilation or runtime code generation. A library built withIsAotCompatible=trueand warnings as errors builds clean, and so does a Native AOT publish with-warnaserror(IL2xxx/IL3xxx). - Nothing from the compiler host reaches your output. The generator, its refactorings and the IL-merged
Purview.SourceGeneratorFramework ship under
analyzers/only. They never appear in an application’sbin,deps.json, publish folder or Blazor_frameworkfolder. Pack validation and the compiler-host leak scan enforce this. - Dependency injection. The generated
Add{Interface}()extension registers the implementation withAddSingleton<TService, TImplementation>(), which the DI container supports under trimming and Native AOT. - Blazor WebAssembly metrics. On .NET 11 the Blazor WebAssembly SDK turns
MetricsSupporton by default (BlazorWebAssemblyDiagnosticsEnabled=true, inMicrosoft.NET.Sdk.BlazorWebAssembly.Current.targets). If you setBlazorWebAssemblyDiagnosticsEnabledorMetricsSupporttofalse, the trimmer removes metrics support. The generated instruments still compile, but record nothing. Earlier SDKs defaultMetricsSupporttofalsefor WebAssembly, so set it totruethere.
.NET 11 features
Section titled “.NET 11 features”| Feature | Generator support | Minimum | Source |
|---|---|---|---|
ActivitySourceFactory, services.AddTracing() | Implemented: UseActivitySourceFactory, diagnostic TSG3023 | net11.0, or System.Diagnostics.DiagnosticSource 11 + Microsoft.Extensions.Diagnostics 11 | What’s new in .NET 11 libraries |
| C# 15 non-virtual static interface members on older runtimes | Implemented: static members are skipped | C# 15 (.NET 11 SDK) | What’s new in C# 15 |
| Logging and diagnostics abstractions in the shared framework | Documented: no reference is needed on net11.0 | net11.0 | Breaking change |
| Blazor WebAssembly diagnostics on by default | Documented above | .NET 11 SDK | Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets in the .NET 11 SDK |
Not yet supported
Section titled “Not yet supported”| Feature | Why it is not supported yet | Source |
|---|---|---|
Generic logging methods (the .NET 11 [LoggerMessage] generator supports them) | Generic interface methods still report TSG1005. Supporting them needs generic implementations across all three targets, not only logging. | What’s new in .NET 11 libraries |
Parity with the new [LoggerMessage] diagnostics for params/scoped and ref struct parameters (SYSLIB1028, SYSLIB1029) | No equivalent TSG rule exists yet. Such parameters are not rejected up front. | DiagnosticDescriptors.cs (release/11.0) |
| C# 15 union types as tag, baggage or log values | A union is a struct implementing IUnion. It is recorded as the boxed struct rather than its case value. Unwrapping it needs a design for each target. | What’s new in C# 15 |
ActivitySourceOptions version, tags and TelemetrySchemaUrl for factory-created sources | Only the name is passed today, matching the static source. | What’s new in .NET 11 libraries |
AddTracing rules from generated registrations | Rules are application configuration, so the generated Add{Interface}() does not call AddTracing(). Call it yourself. | Distributed tracing configuration |
ActivityTraceFlags.RandomTraceId / Activity.HasRandomizedTraceId | Nothing to generate: the runtime sets the flag on the activities it creates, and generated code never rewrites trace flags. | dotnet/runtime#124509 |
New System.Diagnostics.Metrics APIs | .NET 11 adds none. The earlier Gauge<T> (.NET 9) and InstrumentAdvice<T> histogram buckets (.NET 9) are not generated yet either. | What’s new in .NET 11 libraries |
Activity.AddException (.NET 9) | Exception events are built with the OpenTelemetry exception.* tags directly, which works on every target, net48 included. | Activity.AddException |
A Microsoft.Extensions.Telemetry.Abstractions 11 line | None is published yet. Logging v2 uses the 10.x package on every target. | dotnet/extensions releases |