Skip to content

Comments

Remove unsafe code from Guid.TryFormat#121652

Closed
EgorBo wants to merge 4 commits intodotnet:mainfrom
EgorBo:remove-unsafe-guid
Closed

Remove unsafe code from Guid.TryFormat#121652
EgorBo wants to merge 4 commits intodotnet:mainfrom
EgorBo:remove-unsafe-guid

Conversation

@EgorBo
Copy link
Member

@EgorBo EgorBo commented Nov 15, 2025

No description provided.

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 15, 2025
@EgorBo EgorBo added area-System.Runtime reduce-unsafe and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 15, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

internal bool TryFormatCore<TChar>(Span<TChar> destination, out int charsWritten, int flags)
where TChar : unmanaged, IUtfChar<TChar>
{
Span<TChar> dest = destination;
Copy link
Member

Choose a reason for hiding this comment

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

Is there a tracking issue for the need to cache this in a local?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure, I didn't want to advertise it as a hack, it should be fixed by removing the old struct promotion eventually

Copy link
Member

Choose a reason for hiding this comment

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

As far as "hacks" go, this one is probably one of the safest/simplest ones. Certainly better than using Unsafe.Add and friends.

I think it's better to explicitly track this so we know when we can remove it, so users can use it to avoid unsafe code themselves, and so users can know when they can remove their own workarounds.

@tannergooding
Copy link
Member

@EgorBo were you planning on finishing this? I think it was mostly good to go, right?

@EgorBo
Copy link
Member Author

EgorBo commented Jan 5, 2026

@EgorBo were you planning on finishing this? I think it was mostly good to go, right?

Right, it's just that I wanted to land a few bounds-check related JIT opt first to assist it (work-in-progress)

@EgorBo
Copy link
Member Author

EgorBo commented Feb 4, 2026

Will get back to it later

@EgorBo EgorBo closed this Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants