-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Conversation
...Reflection.Metadata/src/System/Reflection/Internal/MemoryBlocks/StreamMemoryBlockProvider.cs
Show resolved
Hide resolved
...Reflection.Metadata/src/System/Reflection/Internal/MemoryBlocks/StreamMemoryBlockProvider.cs
Outdated
Show resolved
Hide resolved
cc: @tmat |
I also replaced the implementation of |
System.Reflection.Metadata
.System.Reflection.Metadata
et.al.
b2d7001
to
063500b
Compare
{ | ||
private static bool IsReadFileAvailable => Path.DirectorySeparatorChar == '\\'; | ||
private static bool IsWindows => Path.DirectorySeparatorChar == '\\'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
?
There was a problem hiding this comment.
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?).
There was a problem hiding this comment.
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
There was a problem hiding this 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
...Reflection.Metadata/src/System/Reflection/Internal/MemoryBlocks/StreamMemoryBlockProvider.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f898312
to
4582555
Compare
System.Reflection.Metadata
used to target frameworks that lacked features like memory-mapped files, theEncoding.GetString
overload that takes a pointer, and theFileStream
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.