You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Developers can employ EventSource APIs when publishing for AOT targets to be able to use .NET tracing capabilities #43390
EventSource is a common logging abstraction in .NET but it uses reflection to generate the schema for an EventSource definition. The source generator would do this at build time and make using EventSources reflection free.
Reacted by Aleksey Kliger (λgeek), Sad Al Abdullah, Kai Jellinghaus, strangeman375, Chris Gillum, Laurent Keusch, dymo, Ryouko Konpaku, Jure, Soheil Alizadeh and 3 more
changed the title [-]Feature Proposal: Reflection-free EventSource* using Roslyn Source Generators[/-][+]Developers can leverage EventSource API when publishing for AOT targets[/+]on Nov 27, 2020
changed the title [-]Developers can leverage EventSource API when publishing for AOT targets[/-][+]Developers can employ EventSource APIs when publishing for AOT targets to be able to use .NET tracing capabilities[/+]on Nov 27, 2020
A whole lot of startup going into generating EventSource manifests and Guids etc for a standardish ASP.NET Core app with ApplicationInsights, e.g. this is https://themesof.net/
Couldn't fit it all on one screen, here's the rest
For https://themesof.net/ looks like 27 EventSources are created on startup, most of them probably just to check .Log.IsEnabled() and get false back... 😅
With any not in System.Private.CoreLib.dll doing reflection to get the Guid to use
Any payload that uses complex data types in EventSource, that in turn depends on unbound reflection for serialization, will be problematic for NativeAOT applications (primarily due to trimming). The long-term solution is to use a source generator for such cases. These scenarios would cause both Roslyn analyzer (when the application project file indicate intention to use NativeAOT) and ILCompiler to generate warnings, and developers should not ignore these warnings.
All Framework EventSource providers should work without problems, as well as payloads with primitive data types.
Activity
MichalStrehovsky commentedon Oct 14, 2020
EventSource used to have a hookup point for this that was used in .NET Native. It looked like this:
runtime/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
Lines 646 to 663 in dbcea6b
It was nuked in the meantime (latest sources don't have it anymore).
7sharp9 commentedon Nov 17, 2020
How would this be consumed by non C# languages?
[-]Feature Proposal: Reflection-free EventSource* using Roslyn Source Generators[/-][+]Developers can leverage EventSource API when publishing for AOT targets[/+][-]Developers can leverage EventSource API when publishing for AOT targets[/-][+]Developers can employ EventSource APIs when publishing for AOT targets to be able to use .NET tracing capabilities[/+]6 remaining items
benaadams commentedon Mar 10, 2021
A whole lot of startup going into generating EventSource manifests and Guids etc for a standardish ASP.NET Core app with ApplicationInsights, e.g. this is https://themesof.net/
Couldn't fit it all on one screen, here's the rest
benaadams commentedon Mar 10, 2021
For https://themesof.net/ looks like 27
EventSources are created on startup, most of them probably just to check.Log.IsEnabled()and getfalseback... 😅With any not in
System.Private.CoreLib.dlldoing reflection to get theGuidto useiSazonov commentedon Mar 10, 2021
It is an issue for PowerShell startup too.
tommcdon commentedon Jul 23, 2023
@LakshanF @davmason do you know of any unresolved issues related to using EventSource on NativeAOT?
LakshanF commentedon Jul 23, 2023
Any payload that uses complex data types in
EventSource, that in turn depends on unbound reflection for serialization, will be problematic forNativeAOTapplications (primarily due to trimming). The long-term solution is to use a source generator for such cases. These scenarios would cause both Roslyn analyzer (when the application project file indicate intention to useNativeAOT) andILCompilerto generate warnings, and developers should not ignore these warnings.All Framework
EventSourceproviders should work without problems, as well as payloads with primitive data types.