Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Avoid marking types as reflected on in CreateSpan#118832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jkotas merged 2 commits intodotnet:mainfromMichalStrehovsky:createspan
Aug 19, 2025

Conversation

@MichalStrehovsky
Copy link
Member

@MichalStrehovskyMichalStrehovsky commentedAug 18, 2025
edited
Loading

This seems to be the only reason why Hello World on Linux still needs support for boxed enums.CreateSpan is used with an enum type in Unix System.Console, which brings a boxed enum into whole program view and we can't undo the damage this causes to the whole program view during compilation anymore (even though we no longer need thetypeof then because RyuJIT always expandsCreateSpan).

ProjectSize beforeSize afterDifference
hello-linux 1221600 1151440-70160
hello-minimal-linux 1069896 999736-70160

This seems to be at least one of the reasons why Hello World on Linux still needs support for boxed enums. `CreateSpan` is used with an enum type in Unix System.Console, which brings a boxed enum into whole program view and we can't undo the damage this causes to the whole program view during compilation anymore (even though we no longer need the `typeof` then because RyuJIT always expands `CreateSpan`).
CopilotAI review requested due to automatic review settingsAugust 18, 2025 05:24
Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes NativeAOT compilation by avoiding unnecessary type reflection marking in theCreateSpan<T> method. The change prevents enum types from being marked as reflected-on whenCreateSpan is called, which was causing unnecessary bloat in Hello World applications on Linux that required support for boxed enums.

Key Changes:

  • Moves thePlatformNotSupportedException throw earlier in the call chain for NativeAOT to avoid executingtypeof(T).TypeHandle
  • Removes the unusedGetSpanDataFrom helper method from the NativeAOT-specific implementation
  • Adds conditional compilation to handle the method differently between NativeAOT and other runtimes

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

FileDescription
RuntimeHelpers.csAdds NativeAOT-specific conditional compilation to throw exception before type reflection occurs
RuntimeHelpers.NativeAot.csRemoves unusedGetSpanDataFrom helper method that was only throwing exceptions

You can also share your feedback on Copilot code review for a chance to win a $100 gift card.Take the survey.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area:@agocke,@MichalStrehovsky,@jkotas
See info inarea-owners.md if you want to be subscribed.

@MichalStrehovsky
Copy link
MemberAuthor

ProjectSize beforeSize afterDifference
hello-linux 1221600 1151440-70160
hello-minimal-linux 1069896 999736-70160

@jkotas
Copy link
Member

/ba-g infrastructure timeout (Mono_MiniJIT_LibrariesTests running for 8 hours)

@jkotasjkotas merged commitd53785b intodotnet:mainAug 19, 2025
141 of 145 checks passed
@MichalStrehovskyMichalStrehovsky deleted the createspan branchAugust 19, 2025 04:14
@MichalStrehovsky
Copy link
MemberAuthor

/backport to release/10.0

@github-actions
Copy link
Contributor

Started backporting torelease/10.0:https://github.com/dotnet/runtime/actions/runs/17083153276

@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsSep 19, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

Copilot code reviewCopilotCopilot left review comments

@jkotasjkotasjkotas approved these changes

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@MichalStrehovsky@jkotas

[8]ページ先頭

©2009-2025 Movatter.jp