Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy light-up code from System.Reflection.Metadata et.al. #56587

Merged
merged 7 commits into from
Sep 16, 2021

Conversation

teo-tsirpanis
Copy link
Contributor

System.Reflection.Metadata used to target frameworks that lacked features like memory-mapped files, the Encoding.GetString overload that takes a pointer, and the FileStream class. In these cases, it would opportunistically use them through reflection or fall back to other slower paths.

Because these old frameworks are no longer targeted and almost all these APIs are now universally available (except the Stream.Read overload that takes a span), this PR removes most of this so-called "light-up" code.

@stephentoub
Copy link
Member

cc: @tmat

@teo-tsirpanis
Copy link
Contributor Author

I also replaced the implementation of BitArithmetic.CountBits with one that calls BitOperations.PopCount on .NET.

@teo-tsirpanis teo-tsirpanis changed the title Remove legacy light-up code from System.Reflection.Metadata. Remove legacy light-up code from System.Reflection.Metadata et.al. Jul 30, 2021
{
private static bool IsReadFileAvailable => Path.DirectorySeparatorChar == '\\';
private static bool IsWindows => Path.DirectorySeparatorChar == '\\';
Copy link
Member

Choose a reason for hiding this comment

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

RuntimeInformation.IsOSPlatform(OSPlatform.Windows)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That also works but I kept using DirectorySeparatorChar because the check is simpler (we compare two characters vs two strings), and RuntimeInformation would require referencing another assembly from S.R.M for just one API (I guess?).

Copy link
Member

Choose a reason for hiding this comment

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

it's a one time cost, not sure about the implementation detail. either way, treat as optional

Copy link
Member

@krwq krwq left a comment

Choose a reason for hiding this comment

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

LGTM although might be a good idea for @tmat to review as well

Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

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

:shipit:

@jeffhandley jeffhandley added this to the 7.0.0 milestone Aug 19, 2021
@marek-safar marek-safar merged commit db9c3f1 into dotnet:main Sep 16, 2021
@teo-tsirpanis teo-tsirpanis deleted the srm-lightup-remove branch September 16, 2021 10:31
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

6 participants