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

Use singular helper when creating checksums #72849

Merged
merged 4 commits into from
Apr 2, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Apr 2, 2024

Extracted from #72494.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner April 2, 2024 19:52
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 2, 2024
@@ -74,6 +74,9 @@ public static Checksum Create(Checksum checksum1, Checksum checksum2)
public static Checksum Create(Checksum checksum1, Checksum checksum2, Checksum checksum3)
=> Create(stackalloc[] { checksum1, checksum2, checksum3 });

public static Checksum Create(Checksum checksum1, Checksum checksum2, Checksum checksum3, Checksum checksum4)
=> Create(stackalloc[] { checksum1, checksum2, checksum3, checksum4 });
Copy link
Member Author

Choose a reason for hiding this comment

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

needed in linked pr.

@@ -205,7 +205,7 @@ private IOptionsSerializationService GetOptionsSerializationService(string langu
=> _lazyLanguageSerializationService.GetOrAdd(languageName, n => _workspaceServices.GetLanguageServices(n).GetRequiredService<IOptionsSerializationService>());

public Checksum CreateParseOptionsChecksum(ParseOptions value)
=> Checksum.Create(value, this);
=> Checksum.Create((value, @this: this), static (tuple, writer) => tuple.@this.SerializeParseOptions(tuple.value, writer));
Copy link
Member Author

Choose a reason for hiding this comment

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

no need for the specialized helper for ParseOptions all the way in teh chcksum layer.

{
foreach (var checksum in checksums)
checksum.WriteTo(writer);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

all these helpers now defer to the helper that takes a callback and passed it an ObjectWriter to write data into (which itself is then checksumed). This is teh same logic as before, just with teh common code of creating the objectwriter and checksum'ing it pushed to the helper.

return Create(stream);
}

public static Checksum Create(ParseOptions value, ISerializerService serializer)
Copy link
Member Author

Choose a reason for hiding this comment

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

this helper went away entirely. the one place that was calling it just inlined its behavior at the callsite.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

@CyrusNajmabadi CyrusNajmabadi merged commit 12659ed into dotnet:main Apr 2, 2024
27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 2, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the checksumUniformity branch April 2, 2024 21:56
@dibarbet dibarbet modified the milestones: Next, 17.11 P1 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants