Skip to content

Document .NET 11 Assembly.GetCallingAssembly behavior with StackTraceSupport=false - #55213

Open
gewarren with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-assembly-getcallingassembly-behavior
Open

Document .NET 11 Assembly.GetCallingAssembly behavior with StackTraceSupport=false#55213
gewarren with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-assembly-getcallingassembly-behavior

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

.NET 11 Preview 7 changes Assembly.GetCallingAssembly() semantics: Native AOT now supports caller resolution, and both Native AOT and CoreCLR now throw NotSupportedException when stack trace support is disabled. This PR adds the corresponding breaking-change documentation and links it into the .NET 11 compatibility surface.

  • Breaking change article (new)

    • Added docs/core/compatibility/core-libraries/11/assembly-getcallingassembly-stacktracesupport-disabled.md.
    • Captures previous vs. new behavior, scope (behavioral), rationale, mitigation guidance, and affected API (System.Reflection.Assembly.GetCallingAssembly).
  • .NET 11 compatibility index update

    • Added the new entry under Core .NET libraries in docs/core/compatibility/11.md so the change appears in the version rollup.
  • TOC integration

    • Added the new page to docs/core/compatibility/toc.yml under .NET 11 > Core .NET libraries.
  • Related feature-switch guidance

    • Updated docs/core/deploying/trimming/trimming-options.md to note that StackTraceSupport=false causes Assembly.GetCallingAssembly() to throw NotSupportedException in .NET 11+.
using System.Reflection;

try
{
    Assembly caller = Assembly.GetCallingAssembly();
}
catch (NotSupportedException ex)
{
    // StackTraceSupport=false in .NET 11+ can trigger this path.
    Console.WriteLine(ex.Message);
}

Internal previews

File Preview link
docs/core/compatibility/11.md docs/core/compatibility/11
docs/core/compatibility/core-libraries/11/assembly-getcallingassembly-stacktracesupport-disabled.md docs/core/compatibility/core-libraries/11/assembly-getcallingassembly-stacktracesupport-disabled
docs/core/compatibility/toc.yml docs/core/compatibility/toc
docs/core/deploying/trimming/trimming-options.md docs/core/deploying/trimming/trimming-options

Copilot AI review requested due to automatic review settings August 3, 2026 17:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI changed the title [WIP] Fix Assembly.GetCallingAssembly() behavior changes for stack-trace-disabled Document .NET 11 Assembly.GetCallingAssembly behavior with StackTraceSupport=false Aug 3, 2026
Copilot AI requested a review from gewarren August 3, 2026 17:45

@gewarren gewarren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread docs/core/compatibility/toc.yml Outdated
@gewarren
gewarren marked this pull request as ready for review August 3, 2026 22:10
@gewarren
gewarren requested review from a team and adegeo as code owners August 3, 2026 22:10
@gewarren

gewarren commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

@copilot Please respond to feedback.

Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>

## New behavior

Starting in .NET 11, on Native AOT, <xref:System.Reflection.Assembly.GetCallingAssembly?displayProperty=nameWithType> returns the calling assembly by inspecting stack trace data. Starting in .NET 11, on both Native AOT and CoreCLR, the method throws <xref:System.NotSupportedException> if `StackTrace.IsSupported` is `false`, for example when the `StackTraceSupport` feature switch is set to `false`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting to see if StackTrace.IsSupported can be an xref or what exactly it refers to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Breaking change]: Assembly.GetCallingAssembly() behavior changes for stack-trace-disabled scenarios

3 participants