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

Remove IChecksummedObject type. #74829

Merged
merged 8 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ static void GetStorageInfoFromTemporaryStorage(
// location, so we can create a metadata value wrapping that. This will also let us share the memory
// for that metadata value with our OOP process.
copyStream.Position = 0;
storageHandle = temporaryStorageService.WriteToTemporaryStorage(copyStream, CancellationToken.None);
storageHandle = temporaryStorageService.WriteToTemporaryStorage(copyStream);
}

// Now, read the data from the memory-mapped-file back into a stream that we load into the metadata value.
// The ITemporaryStorageStreamHandle should have given us an UnmanagedMemoryStream
// since this only runs on Windows for VS.
stream = (UnmanagedMemoryStream)storageHandle.ReadFromTemporaryStorage(CancellationToken.None);
stream = (UnmanagedMemoryStream)storageHandle.ReadFromTemporaryStorage();

// stream size must be same as what metadata reader said the size should be.
Contract.ThrowIfFalse(stream.Length == size);
Expand Down
3 changes: 0 additions & 3 deletions src/Workspaces/Core/Portable/Remote/ISerializerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ namespace Microsoft.CodeAnalysis.Serialization;
internal interface ISerializerService : IWorkspaceService
{
void Serialize(object value, ObjectWriter writer, CancellationToken cancellationToken);

void SerializeParseOptions(ParseOptions options, ObjectWriter 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.

didn't need to be on the itnerface. was never called externally.


object Deserialize(WellKnownSynchronizationKind kind, ObjectReader reader, CancellationToken cancellationToken);

Checksum CreateChecksum(object value, CancellationToken cancellationToken);
Expand Down
19 changes: 7 additions & 12 deletions src/Workspaces/Core/Portable/Serialization/SerializerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ public Checksum CreateChecksum(object value, CancellationToken cancellationToken
{
cancellationToken.ThrowIfCancellationRequested();

if (value is IChecksummedObject checksummedObject)
{
return checksummedObject.Checksum;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

existed only to hijack. but we can already do that throuhg normal virtual methods.


switch (kind)
{
case WellKnownSynchronizationKind.CompilationOptions:
Expand All @@ -89,10 +84,10 @@ public Checksum CreateChecksum(object value, CancellationToken cancellationToken
return Checksum.Create(value, this, cancellationToken);

case WellKnownSynchronizationKind.MetadataReference:
return CreateChecksum((MetadataReference)value, cancellationToken);
return CreateChecksum((MetadataReference)value);

case WellKnownSynchronizationKind.AnalyzerReference:
return CreateChecksum((AnalyzerReference)value, cancellationToken);
return CreateChecksum((AnalyzerReference)value);

case WellKnownSynchronizationKind.SerializableSourceText:
throw new InvalidOperationException("Clients can already get a checksum directly from a SerializableSourceText");
Expand Down Expand Up @@ -141,15 +136,15 @@ public void Serialize(object value, ObjectWriter writer, CancellationToken cance
return;

case WellKnownSynchronizationKind.ProjectReference:
SerializeProjectReference((ProjectReference)value, writer, cancellationToken);
SerializeProjectReference((ProjectReference)value, writer);
return;

case WellKnownSynchronizationKind.MetadataReference:
SerializeMetadataReference((MetadataReference)value, writer, cancellationToken);
SerializeMetadataReference((MetadataReference)value, writer);
return;

case WellKnownSynchronizationKind.AnalyzerReference:
SerializeAnalyzerReference((AnalyzerReference)value, writer, cancellationToken: cancellationToken);
SerializeAnalyzerReference((AnalyzerReference)value, writer);
return;

case WellKnownSynchronizationKind.SerializableSourceText:
Expand Down Expand Up @@ -274,8 +269,8 @@ public object Deserialize(WellKnownSynchronizationKind kind, ObjectReader reader
WellKnownSynchronizationKind.CompilationOptions => DeserializeCompilationOptions(reader, cancellationToken),
WellKnownSynchronizationKind.ParseOptions => DeserializeParseOptions(reader, cancellationToken),
WellKnownSynchronizationKind.ProjectReference => DeserializeProjectReference(reader, cancellationToken),
WellKnownSynchronizationKind.MetadataReference => DeserializeMetadataReference(reader, cancellationToken),
WellKnownSynchronizationKind.AnalyzerReference => DeserializeAnalyzerReference(reader, cancellationToken),
WellKnownSynchronizationKind.MetadataReference => DeserializeMetadataReference(reader),
WellKnownSynchronizationKind.AnalyzerReference => DeserializeAnalyzerReference(reader),
WellKnownSynchronizationKind.SerializableSourceText => SerializableSourceText.Deserialize(reader, _storageService.Value, _textService, cancellationToken),
WellKnownSynchronizationKind.SourceGeneratorExecutionVersionMap => SourceGeneratorExecutionVersionMap.Deserialize(reader),
WellKnownSynchronizationKind.FallbackAnalyzerOptions => ReadFallbackAnalyzerOptions(reader),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ private ParseOptions DeserializeParseOptions(ObjectReader reader, CancellationTo
return service.ReadParseOptionsFrom(reader, cancellationToken);
}

private static void SerializeProjectReference(ProjectReference reference, ObjectWriter writer, CancellationToken cancellationToken)
private static void SerializeProjectReference(ProjectReference reference, ObjectWriter writer)
{
cancellationToken.ThrowIfCancellationRequested();

reference.ProjectId.WriteTo(writer);
writer.WriteArray(reference.Aliases, static (w, a) => w.WriteString(a));
writer.WriteBoolean(reference.EmbedInteropTypes);
Expand All @@ -84,27 +82,15 @@ private static ProjectReference DeserializeProjectReference(ObjectReader reader,
return new ProjectReference(projectId, aliases.ToImmutableArrayOrEmpty(), embedInteropTypes);
}

private void SerializeMetadataReference(MetadataReference reference, ObjectWriter writer, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
WriteMetadataReferenceTo(reference, writer, cancellationToken);
}
private void SerializeMetadataReference(MetadataReference reference, ObjectWriter writer)
=> WriteMetadataReferenceTo(reference, writer);

private MetadataReference DeserializeMetadataReference(ObjectReader reader, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
return ReadMetadataReferenceFrom(reader, cancellationToken);
}
private MetadataReference DeserializeMetadataReference(ObjectReader reader)
=> ReadMetadataReferenceFrom(reader);

private void SerializeAnalyzerReference(AnalyzerReference reference, ObjectWriter writer, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
WriteAnalyzerReferenceTo(reference, writer, cancellationToken);
}
private void SerializeAnalyzerReference(AnalyzerReference reference, ObjectWriter writer)
=> WriteAnalyzerReferenceTo(reference, writer);

private AnalyzerReference DeserializeAnalyzerReference(ObjectReader reader, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
return ReadAnalyzerReferenceFrom(reader, cancellationToken);
}
private AnalyzerReference DeserializeAnalyzerReference(ObjectReader reader)
=> ReadAnalyzerReferenceFrom(reader);
}
Loading
Loading