-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fix alignment padding and add test for saving managed resources #110915
base: main
Are you sure you want to change the base?
Conversation
private static void SamplePrivateMethod () | ||
{ | ||
} | ||
private static void SamplePrivateMethod() |
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.
Whitespace-only changes to this file
Tagging subscribers to this area: @dotnet/area-system-reflection-emit |
...libraries/System.Reflection.Emit/tests/PersistedAssemblyBuilder/AssemblySaveResourceTests.cs
Show resolved
Hide resolved
What was the alignment issue that you have mentioned in #110686 (comment) originally? |
I pushed a new commit for that. I assume the best practice here is to not modify the incoming blob directly to add the padding, so the alignment is done when writing. Also, the Assert checked on 4-byte alignment, but the unused const had 8, so I'm assuming 8. I'll also double-check to see what Roslyn does. |
@@ -147,14 +148,16 @@ public int CalculateOffsetToMappedFieldDataStream() | |||
|
|||
internal int ComputeOffsetToDebugDirectory() | |||
{ | |||
Debug.Assert(MetadataSize % 4 == 0); | |||
Debug.Assert(ResourceDataSize % 4 == 0); | |||
Debug.Assert(MetadataSize % MetadataSizes.StreamAlignment == 0); |
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.
Not 100% sure if this is the intent (4 byte alignment across the various sections); I think we could remove this Assert since they should all be aligned anyway
@@ -40,8 +41,8 @@ internal sealed class ManagedTextSection | |||
public int MetadataSize { get; } | |||
|
|||
/// <summary> | |||
/// The size of managed resource data stream. | |||
/// Aligned to <see cref="ManagedResourcesDataAlignment"/>. | |||
/// The size of managed resource data stream (unaligned). |
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.
@tmat Could you please take a look at the changes in this file? How are the alignment requirements expected to be handled by ManagedPEBuilder
?
Fix alignment Assert and add tests for #110686.