-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
The System.Diagnostics.DiagnosticSource 9.0.0 package doesn't appear to be trim safe. Specifically the ActivitySource
class which appears to be missing a constructor in a published app.
If I try to call this constructor in AOT-published code, I get a MissingMethodException
:
Unhandled Exception: System.MissingMethodException: Method not found: 'Void System.Diagnostics.ActivitySource..ctor(System.String)'.
$>d__0.MoveNext() + 0x15
at Internal.Runtime.TypeLoaderExceptionHelper.CreateMissingMethodException(ExceptionStringID, String) + 0x40
at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowMissingMethodException(ExceptionStringID, String) + 0x9
at Program.<
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.StartTStateMachine + 0x3f
at Program.$(String[]) + 0x2f
at Program.(String[] args) + 0x9
Reproduction Steps
-
Create a normal .NET 8 Console App with NativeAOT enabled.
-
Replace Program.cs
using System.Diagnostics;
var a = new ActivitySource("test");
Console.WriteLine(a.ToString());
-
Publish and run
-
App successfully runs to completion. ✔️
-
Install the System.Diagnostics.DiagnosticSource 9.0.0 package
-
Publish and run
-
Application crashes with MissingMethodException ❌
-
Downgrade System.Diagnostics.DiagnosticSource 9.0.0 package to 8.0.1
-
Publish and run
-
App successfully runs to completion. ✔️
Expected behavior
Constructor should be callable in AOT
Actual behavior
Constructor is not callable in AOT
Regression?
8.0.1 works, 9.0.0 does not.
Known Workarounds
No response
Configuration
.NET Version: 8.0
OS: Windows
Arch: x64
Other information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status