Skip to content

Introduce a way to opt-out of source info in Diagnostics StackFrame  #34910

Open
@eerhardt

Description

@eerhardt

The source line info support for System.Diagnostics.StackTrace/StackFrame comes with a noticeable cost for workloads which are size sensitive and don't contain PDB information anyway.

With change #32023, we added a PreserveDependency attribute here:

// This is necessary because linker can't add new assemblies to the closure when recognizing Type.GetType
// so the code below is actually recognized by linker, but fails to resolve the type since the System.Diagnostics.StackTrace
// is not always part of the closure linker works on.
// PreserveDependencyAttribute on the other hand can pull in additional assemblies.
[PreserveDependency("GetSourceLineInfo", "System.Diagnostics.StackTraceSymbols", "System.Diagnostics.StackTrace")]
[PreserveDependency(".ctor()", "System.Diagnostics.StackTraceSymbols", "System.Diagnostics.StackTrace")]
internal void InitializeSourceInfo(int iSkip, bool fNeedFileInfo, Exception? exception)

As noted in the PR, the change added ~200K to the "Console Hello World" app, bringing in the following assemblies, which were not needed before:

image

We should consider adding a feature switch (dotnet/designs#99) or similar functionality to allow app developers to opt-out of this behavior.

cc @vitek-karas @jkotas @stephentoub @marek-safar

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions