-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[SRM] Refactor reading from streams. #111323
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
45cfc40
Fix reading PE headers from a non-zero offset.
teo-tsirpanis 5a77e60
Update reading PE headers to use an abstraction.
teo-tsirpanis 7dc6eb3
Update `IBinaryReader`'s shape to match `BlobReader`.
teo-tsirpanis c47c2f5
Support reading PE headers from an `AbstractMemoryBlock`.
teo-tsirpanis 2e9d416
Remove the now-unused `MemoryBlockProvider.GetStream` and all code su…
teo-tsirpanis 7dffe10
Use `Stream.ReadExactly` if available and polyfill it otherwise.
teo-tsirpanis 867346d
Simplify memory-mapping files.
teo-tsirpanis f226c09
Clean-up.
teo-tsirpanis 3be8aba
Preserve the stream's original position when prefetching metadata.
teo-tsirpanis 4afb48c
Remove call to `GetEntireImage()` in test where we fetch only the met…
teo-tsirpanis 4d0cd27
Always use a stream to read the headers.
teo-tsirpanis ade8410
Remove `IBinaryReader` and revert related code changes.
teo-tsirpanis 1ee836c
Update src/libraries/System.Reflection.Metadata/src/System/Reflection…
teo-tsirpanis 26d3598
Fix order of methods.
teo-tsirpanis 381f109
Update src/libraries/System.Reflection.Metadata/src/System.Reflection…
teo-tsirpanis 87e98a6
Merge branch 'main' into srm-streams
teo-tsirpanis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
...stem.Reflection.Metadata/src/System/Reflection/Internal/MemoryBlocks/StreamConstraints.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/IBinaryReader.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace System.Reflection | ||
| { | ||
| /// <summary> | ||
| /// Provides an abstraction for reading binary data from a stream. | ||
| /// </summary> | ||
| /// <seealso cref="Metadata.BlobReader"/> | ||
| /// <seealso cref="PortableExecutable.PEBinaryReader"/> | ||
| internal interface IBinaryReader | ||
| { | ||
| public int Offset { get; set; } | ||
|
|
||
| public byte ReadByte(); | ||
|
|
||
| public short ReadInt16(); | ||
|
|
||
| public ushort ReadUInt16(); | ||
|
|
||
| public int ReadInt32(); | ||
|
|
||
| public uint ReadUInt32(); | ||
|
|
||
| public ulong ReadUInt64(); | ||
|
|
||
| /// <summary> | ||
| /// Reads a fixed-length byte block as a null-padded UTF-8 encoded string. | ||
| /// The padding is not included in the returned string. | ||
| /// | ||
| /// Note that it is legal for UTF-8 strings to contain NUL; if NUL occurs | ||
| /// between non-NUL codepoints, it is not considered to be padding and | ||
| /// is included in the result. | ||
| /// </summary> | ||
| public string ReadNullPaddedUTF8(int byteCount); | ||
| } | ||
| } |
124 changes: 0 additions & 124 deletions
124
...tem.Reflection.Metadata/src/System/Reflection/Internal/Utilities/ImmutableMemoryStream.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.