Skip to content

Fix Metadata aggregator: removing cumulative sum for GUIDs heap offset #115268

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

fabrimaz
Copy link

@fabrimaz fabrimaz commented May 3, 2025

Removing cumulative sum for GUID heap offsets
Fixes #113910

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label May 3, 2025
Copy link
Contributor

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

@fabrimaz
Copy link
Author

fabrimaz commented May 3, 2025

Run unit-tests on this library:

=== TEST EXECUTION SUMMARY ===
System.Reflection.Metadata.Tests Total: 852, Errors: 0, Failed: 0, Skipped: 1, Time: 5,376s

@@ -153,7 +153,7 @@ private static ImmutableArray<ImmutableArray<int>> CalculateHeapSizes(
userStringSizes[r + 1] = userStringSizes[r] + deltaReaders[r].GetHeapSize(HeapIndex.UserString);
stringSizes[r + 1] = stringSizes[r] + deltaReaders[r].GetHeapSize(HeapIndex.String);
blobSizes[r + 1] = blobSizes[r] + deltaReaders[r].GetHeapSize(HeapIndex.Blob);
guidSizes[r + 1] = guidSizes[r] + deltaReaders[r].GetHeapSize(HeapIndex.Guid) / guidSize;
guidSizes[r + 1] = deltaReaders[r].GetHeapSize(HeapIndex.Guid) / guidSize;
Copy link
Member

Choose a reason for hiding this comment

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

@tmat
Copy link
Member

tmat commented May 6, 2025

It'd be good to have some tests that demonstrate correctness. There are some existing tests for MetadataAggregator, so you can update them. Make sure the test fails without your change and passes with the change.

@fabrimaz
Copy link
Author

fabrimaz commented May 10, 2025

It'd be good to have some tests that demonstrate correctness. There are some existing tests for MetadataAggregator, so you can update them. Make sure the test fails without your change and passes with the change.

Hello! The linked comment was updated :)

The method "CalculateHeapSizes(..)" I edited is private and its result is assigned to a private field directly in the constructor of the class.
Even if I try to unit-test that constructor, I wouldn't be able to easily access the private field from unit-test class to assert its values.

What would you suggest? Should I split the mentioned method in a separate class to enhance testability?

Or else making the method 'internal'?

@fabrimaz fabrimaz requested a review from tmat May 10, 2025 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Reflection.Metadata community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MetadataAggregator.GetGenerationHandle returns incorrect results for Guid heap handles
3 participants