提交 3ffbbd83 编写于 作者: C CyrusNajmabadi

Rename type.

上级 a752d1bb
......@@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis.Execution
/// </summary>
internal abstract class CustomAsset : RemotableData
{
public CustomAsset(Checksum checksum, WellKnownSynchronizationKinds kind) : base(checksum, kind)
public CustomAsset(Checksum checksum, WellKnownSynchronizationKind kind) : base(checksum, kind)
{
}
}
......@@ -26,7 +26,7 @@ internal sealed class SimpleCustomAsset : CustomAsset
{
private readonly Action<ObjectWriter, CancellationToken> _writer;
public SimpleCustomAsset(WellKnownSynchronizationKinds kind, Action<ObjectWriter, CancellationToken> writer) :
public SimpleCustomAsset(WellKnownSynchronizationKind kind, Action<ObjectWriter, CancellationToken> writer) :
base(CreateChecksumFromStreamWriter(kind, writer), kind)
{
// unlike SolutionAsset which gets checksum from solution states, this one build one by itself.
......@@ -39,7 +39,7 @@ public override Task WriteObjectToAsync(ObjectWriter writer, CancellationToken c
return SpecializedTasks.EmptyTask;
}
private static Checksum CreateChecksumFromStreamWriter(WellKnownSynchronizationKinds kind, Action<ObjectWriter, CancellationToken> writer)
private static Checksum CreateChecksumFromStreamWriter(WellKnownSynchronizationKind kind, Action<ObjectWriter, CancellationToken> writer)
{
using (var stream = SerializableBytes.CreateWritableStream())
using (var objectWriter = new ObjectWriter(stream))
......@@ -68,7 +68,7 @@ internal sealed class WorkspaceAnalyzerReferenceAsset : CustomAsset
public WorkspaceAnalyzerReferenceAsset(AnalyzerReference reference, Serializer serializer) :
base(
serializer.CreateChecksum(reference, CancellationToken.None),
WellKnownSynchronizationKinds.AnalyzerReference)
WellKnownSynchronizationKind.AnalyzerReference)
{
_reference = reference;
_serializer = serializer;
......
......@@ -32,7 +32,7 @@ public CustomAsset Build(OptionSet options, string language, CancellationToken c
{
cancellationToken.ThrowIfCancellationRequested();
return new SimpleCustomAsset(WellKnownSynchronizationKinds.OptionSet,
return new SimpleCustomAsset(WellKnownSynchronizationKind.OptionSet,
(writer, cancellationTokenOnStreamWriting) =>
_serializer.SerializeOptionSet(options, language, writer, cancellationTokenOnStreamWriting));
}
......
......@@ -15,30 +15,30 @@ public static T[] ReadArray<T>(this ObjectReader reader)
return (T[])reader.ReadValue();
}
public static WellKnownSynchronizationKinds GetWellKnownSynchronizationKind(this object value)
public static WellKnownSynchronizationKind GetWellKnownSynchronizationKind(this object value)
{
switch (value)
{
case SolutionStateChecksums _: return WellKnownSynchronizationKinds.SolutionState;
case ProjectStateChecksums _: return WellKnownSynchronizationKinds.ProjectState;
case DocumentStateChecksums _: return WellKnownSynchronizationKinds.DocumentState;
case ProjectChecksumCollection _: return WellKnownSynchronizationKinds.Projects;
case DocumentChecksumCollection _: return WellKnownSynchronizationKinds.Documents;
case TextDocumentChecksumCollection _: return WellKnownSynchronizationKinds.TextDocuments;
case ProjectReferenceChecksumCollection _: return WellKnownSynchronizationKinds.ProjectReferences;
case MetadataReferenceChecksumCollection _: return WellKnownSynchronizationKinds.MetadataReferences;
case AnalyzerReferenceChecksumCollection _: return WellKnownSynchronizationKinds.AnalyzerReferences;
case SolutionInfo.SolutionAttributes _: return WellKnownSynchronizationKinds.SolutionAttributes;
case ProjectInfo.ProjectAttributes _: return WellKnownSynchronizationKinds.ProjectAttributes;
case DocumentInfo.DocumentAttributes _: return WellKnownSynchronizationKinds.DocumentAttributes;
case CompilationOptions _: return WellKnownSynchronizationKinds.CompilationOptions;
case ParseOptions _: return WellKnownSynchronizationKinds.ParseOptions;
case ProjectReference _: return WellKnownSynchronizationKinds.ProjectReference;
case MetadataReference _: return WellKnownSynchronizationKinds.MetadataReference;
case AnalyzerReference _: return WellKnownSynchronizationKinds.AnalyzerReference;
case TextDocumentState _: return WellKnownSynchronizationKinds.RecoverableSourceText;
case SourceText _: return WellKnownSynchronizationKinds.SourceText;
case OptionSet _: return WellKnownSynchronizationKinds.OptionSet;
case SolutionStateChecksums _: return WellKnownSynchronizationKind.SolutionState;
case ProjectStateChecksums _: return WellKnownSynchronizationKind.ProjectState;
case DocumentStateChecksums _: return WellKnownSynchronizationKind.DocumentState;
case ProjectChecksumCollection _: return WellKnownSynchronizationKind.Projects;
case DocumentChecksumCollection _: return WellKnownSynchronizationKind.Documents;
case TextDocumentChecksumCollection _: return WellKnownSynchronizationKind.TextDocuments;
case ProjectReferenceChecksumCollection _: return WellKnownSynchronizationKind.ProjectReferences;
case MetadataReferenceChecksumCollection _: return WellKnownSynchronizationKind.MetadataReferences;
case AnalyzerReferenceChecksumCollection _: return WellKnownSynchronizationKind.AnalyzerReferences;
case SolutionInfo.SolutionAttributes _: return WellKnownSynchronizationKind.SolutionAttributes;
case ProjectInfo.ProjectAttributes _: return WellKnownSynchronizationKind.ProjectAttributes;
case DocumentInfo.DocumentAttributes _: return WellKnownSynchronizationKind.DocumentAttributes;
case CompilationOptions _: return WellKnownSynchronizationKind.CompilationOptions;
case ParseOptions _: return WellKnownSynchronizationKind.ParseOptions;
case ProjectReference _: return WellKnownSynchronizationKind.ProjectReference;
case MetadataReference _: return WellKnownSynchronizationKind.MetadataReference;
case AnalyzerReference _: return WellKnownSynchronizationKind.AnalyzerReference;
case TextDocumentState _: return WellKnownSynchronizationKind.RecoverableSourceText;
case SourceText _: return WellKnownSynchronizationKind.SourceText;
case OptionSet _: return WellKnownSynchronizationKind.OptionSet;
}
throw ExceptionUtilities.UnexpectedValue(value);
......
......@@ -16,19 +16,19 @@ internal abstract partial class RemotableData
/// <summary>
/// Indicates what kind of object it is
/// <see cref="WellKnownSynchronizationKinds"/> for examples.
/// <see cref="WellKnownSynchronizationKind"/> for examples.
///
/// this will be used in tranportation framework and deserialization service
/// to hand shake how to send over data and deserialize serialized data
/// </summary>
public readonly WellKnownSynchronizationKinds Kind;
public readonly WellKnownSynchronizationKind Kind;
/// <summary>
/// Checksum of this object
/// </summary>
public readonly Checksum Checksum;
public RemotableData(Checksum checksum, WellKnownSynchronizationKinds kind)
public RemotableData(Checksum checksum, WellKnownSynchronizationKind kind)
{
Checksum = checksum;
Kind = kind;
......@@ -47,7 +47,7 @@ public RemotableData(Checksum checksum, WellKnownSynchronizationKinds kind)
private sealed class NullRemotableData : RemotableData
{
public NullRemotableData() :
base(Checksum.Null, WellKnownSynchronizationKinds.Null)
base(Checksum.Null, WellKnownSynchronizationKind.Null)
{
// null object has null kind and null checksum.
// this null object is known to checksum framework and transportation framework to handle null case
......
......@@ -63,21 +63,21 @@ public Checksum CreateChecksum(object value, CancellationToken cancellationToken
switch (kind)
{
case WellKnownSynchronizationKinds.Null:
case WellKnownSynchronizationKind.Null:
return Checksum.Null;
case WellKnownSynchronizationKinds.CompilationOptions:
case WellKnownSynchronizationKinds.ParseOptions:
case WellKnownSynchronizationKinds.ProjectReference:
case WellKnownSynchronizationKind.CompilationOptions:
case WellKnownSynchronizationKind.ParseOptions:
case WellKnownSynchronizationKind.ProjectReference:
return Checksum.Create(kind, value, this);
case WellKnownSynchronizationKinds.MetadataReference:
case WellKnownSynchronizationKind.MetadataReference:
return Checksum.Create(kind, _hostSerializationService.CreateChecksum((MetadataReference)value, cancellationToken));
case WellKnownSynchronizationKinds.AnalyzerReference:
case WellKnownSynchronizationKind.AnalyzerReference:
return Checksum.Create(kind, _hostSerializationService.CreateChecksum((AnalyzerReference)value, cancellationToken));
case WellKnownSynchronizationKinds.SourceText:
case WellKnownSynchronizationKind.SourceText:
return Checksum.Create(kind, ((SourceText)value).GetChecksum());
default:
......@@ -104,37 +104,37 @@ public void Serialize(object value, ObjectWriter writer, CancellationToken cance
switch (kind)
{
case WellKnownSynchronizationKinds.Null:
case WellKnownSynchronizationKind.Null:
// do nothing
return;
case WellKnownSynchronizationKinds.SolutionAttributes:
case WellKnownSynchronizationKinds.ProjectAttributes:
case WellKnownSynchronizationKinds.DocumentAttributes:
case WellKnownSynchronizationKind.SolutionAttributes:
case WellKnownSynchronizationKind.ProjectAttributes:
case WellKnownSynchronizationKind.DocumentAttributes:
((IObjectWritable)value).WriteTo(writer);
return;
case WellKnownSynchronizationKinds.CompilationOptions:
case WellKnownSynchronizationKind.CompilationOptions:
SerializeCompilationOptions((CompilationOptions)value, writer, cancellationToken);
return;
case WellKnownSynchronizationKinds.ParseOptions:
case WellKnownSynchronizationKind.ParseOptions:
SerializeParseOptions((ParseOptions)value, writer, cancellationToken);
return;
case WellKnownSynchronizationKinds.ProjectReference:
case WellKnownSynchronizationKind.ProjectReference:
SerializeProjectReference((ProjectReference)value, writer, cancellationToken);
return;
case WellKnownSynchronizationKinds.MetadataReference:
case WellKnownSynchronizationKind.MetadataReference:
SerializeMetadataReference((MetadataReference)value, writer, cancellationToken);
return;
case WellKnownSynchronizationKinds.AnalyzerReference:
case WellKnownSynchronizationKind.AnalyzerReference:
SerializeAnalyzerReference((AnalyzerReference)value, writer, usePathFromAssembly: true, cancellationToken: cancellationToken);
return;
case WellKnownSynchronizationKinds.SourceText:
case WellKnownSynchronizationKind.SourceText:
SerializeSourceText(storage: null, text: (SourceText)value, writer: writer, cancellationToken: cancellationToken);
return;
......@@ -146,7 +146,7 @@ public void Serialize(object value, ObjectWriter writer, CancellationToken cance
}
}
public T Deserialize<T>(WellKnownSynchronizationKinds kind, ObjectReader reader, CancellationToken cancellationToken)
public T Deserialize<T>(WellKnownSynchronizationKind kind, ObjectReader reader, CancellationToken cancellationToken)
{
using (Logger.LogBlock(FunctionId.Serializer_Deserialize, kind.ToString(), cancellationToken))
{
......@@ -154,39 +154,39 @@ public T Deserialize<T>(WellKnownSynchronizationKinds kind, ObjectReader reader,
switch (kind)
{
case WellKnownSynchronizationKinds.Null:
case WellKnownSynchronizationKind.Null:
return default(T);
case WellKnownSynchronizationKinds.SolutionState:
case WellKnownSynchronizationKinds.ProjectState:
case WellKnownSynchronizationKinds.DocumentState:
case WellKnownSynchronizationKinds.Projects:
case WellKnownSynchronizationKinds.Documents:
case WellKnownSynchronizationKinds.TextDocuments:
case WellKnownSynchronizationKinds.ProjectReferences:
case WellKnownSynchronizationKinds.MetadataReferences:
case WellKnownSynchronizationKinds.AnalyzerReferences:
case WellKnownSynchronizationKind.SolutionState:
case WellKnownSynchronizationKind.ProjectState:
case WellKnownSynchronizationKind.DocumentState:
case WellKnownSynchronizationKind.Projects:
case WellKnownSynchronizationKind.Documents:
case WellKnownSynchronizationKind.TextDocuments:
case WellKnownSynchronizationKind.ProjectReferences:
case WellKnownSynchronizationKind.MetadataReferences:
case WellKnownSynchronizationKind.AnalyzerReferences:
return (T)(object)DeserializeChecksumWithChildren(reader, cancellationToken);
case WellKnownSynchronizationKinds.SolutionAttributes:
case WellKnownSynchronizationKind.SolutionAttributes:
return (T)(object)SolutionInfo.SolutionAttributes.ReadFrom(reader);
case WellKnownSynchronizationKinds.ProjectAttributes:
case WellKnownSynchronizationKind.ProjectAttributes:
return (T)(object)ProjectInfo.ProjectAttributes.ReadFrom(reader);
case WellKnownSynchronizationKinds.DocumentAttributes:
case WellKnownSynchronizationKind.DocumentAttributes:
return (T)(object)DocumentInfo.DocumentAttributes.ReadFrom(reader);
case WellKnownSynchronizationKinds.CompilationOptions:
case WellKnownSynchronizationKind.CompilationOptions:
return (T)(object)DeserializeCompilationOptions(reader, cancellationToken);
case WellKnownSynchronizationKinds.ParseOptions:
case WellKnownSynchronizationKind.ParseOptions:
return (T)(object)DeserializeParseOptions(reader, cancellationToken);
case WellKnownSynchronizationKinds.ProjectReference:
case WellKnownSynchronizationKind.ProjectReference:
return (T)(object)DeserializeProjectReference(reader, cancellationToken);
case WellKnownSynchronizationKinds.MetadataReference:
case WellKnownSynchronizationKind.MetadataReference:
return (T)(object)DeserializeMetadataReference(reader, cancellationToken);
case WellKnownSynchronizationKinds.AnalyzerReference:
case WellKnownSynchronizationKind.AnalyzerReference:
return (T)(object)DeserializeAnalyzerReference(reader, cancellationToken);
case WellKnownSynchronizationKinds.SourceText:
case WellKnownSynchronizationKind.SourceText:
return (T)(object)DeserializeSourceText(reader, cancellationToken);
case WellKnownSynchronizationKinds.OptionSet:
case WellKnownSynchronizationKind.OptionSet:
return (T)(object)DeserializeOptionSet(reader, cancellationToken);
default:
......
......@@ -17,7 +17,7 @@ internal partial class Serializer
private const byte ChecksumKind = 0;
private const byte ChecksumWithChildrenKind = 1;
private static readonly ImmutableDictionary<WellKnownSynchronizationKinds, Func<object[], ChecksumWithChildren>> s_creatorMap = CreateCreatorMap();
private static readonly ImmutableDictionary<WellKnownSynchronizationKind, Func<object[], ChecksumWithChildren>> s_creatorMap = CreateCreatorMap();
public void SerializeChecksumWithChildren(ChecksumWithChildren checksums, ObjectWriter writer, CancellationToken cancellationToken)
{
......@@ -54,7 +54,7 @@ private ChecksumWithChildren DeserializeChecksumWithChildren(ObjectReader reader
{
cancellationToken.ThrowIfCancellationRequested();
var kind = (WellKnownSynchronizationKinds)reader.ReadInt32();
var kind = (WellKnownSynchronizationKind)reader.ReadInt32();
var checksum = Checksum.ReadFrom(reader);
var childrenCount = reader.ReadInt32();
......@@ -84,18 +84,18 @@ private ChecksumWithChildren DeserializeChecksumWithChildren(ObjectReader reader
return checksums;
}
private static ImmutableDictionary<WellKnownSynchronizationKinds, Func<object[], ChecksumWithChildren>> CreateCreatorMap()
private static ImmutableDictionary<WellKnownSynchronizationKind, Func<object[], ChecksumWithChildren>> CreateCreatorMap()
{
return ImmutableDictionary<WellKnownSynchronizationKinds, Func<object[], ChecksumWithChildren>>.Empty
.Add(WellKnownSynchronizationKinds.SolutionState, children => new SolutionStateChecksums(children))
.Add(WellKnownSynchronizationKinds.ProjectState, children => new ProjectStateChecksums(children))
.Add(WellKnownSynchronizationKinds.DocumentState, children => new DocumentStateChecksums(children))
.Add(WellKnownSynchronizationKinds.Projects, children => new ProjectChecksumCollection(children))
.Add(WellKnownSynchronizationKinds.Documents, children => new DocumentChecksumCollection(children))
.Add(WellKnownSynchronizationKinds.TextDocuments, children => new TextDocumentChecksumCollection(children))
.Add(WellKnownSynchronizationKinds.ProjectReferences, children => new ProjectReferenceChecksumCollection(children))
.Add(WellKnownSynchronizationKinds.MetadataReferences, children => new MetadataReferenceChecksumCollection(children))
.Add(WellKnownSynchronizationKinds.AnalyzerReferences, children => new AnalyzerReferenceChecksumCollection(children));
return ImmutableDictionary<WellKnownSynchronizationKind, Func<object[], ChecksumWithChildren>>.Empty
.Add(WellKnownSynchronizationKind.SolutionState, children => new SolutionStateChecksums(children))
.Add(WellKnownSynchronizationKind.ProjectState, children => new ProjectStateChecksums(children))
.Add(WellKnownSynchronizationKind.DocumentState, children => new DocumentStateChecksums(children))
.Add(WellKnownSynchronizationKind.Projects, children => new ProjectChecksumCollection(children))
.Add(WellKnownSynchronizationKind.Documents, children => new DocumentChecksumCollection(children))
.Add(WellKnownSynchronizationKind.TextDocuments, children => new TextDocumentChecksumCollection(children))
.Add(WellKnownSynchronizationKind.ProjectReferences, children => new ProjectReferenceChecksumCollection(children))
.Add(WellKnownSynchronizationKind.MetadataReferences, children => new MetadataReferenceChecksumCollection(children))
.Add(WellKnownSynchronizationKind.AnalyzerReferences, children => new AnalyzerReferenceChecksumCollection(children));
}
}
}
......@@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Execution
/// </summary>
internal abstract class SolutionAsset : RemotableData
{
protected SolutionAsset(Checksum checksum, WellKnownSynchronizationKinds kind)
protected SolutionAsset(Checksum checksum, WellKnownSynchronizationKind kind)
: base(checksum, kind)
{
}
......@@ -64,7 +64,7 @@ internal sealed class SourceTextAsset : SolutionAsset
private readonly Serializer _serializer;
public SourceTextAsset(Checksum checksum, TextDocumentState state, Serializer serializer) :
base(checksum, WellKnownSynchronizationKinds.SourceText)
base(checksum, WellKnownSynchronizationKind.SourceText)
{
_state = state;
_serializer = serializer;
......
......@@ -3,7 +3,7 @@
namespace Microsoft.CodeAnalysis.Serialization
{
// TODO: Kind might not actually needed. see whether we can get rid of this
internal enum WellKnownSynchronizationKinds
internal enum WellKnownSynchronizationKind
{
Null,
......
......@@ -66,7 +66,7 @@ public static async Task<Checksum> GetSourceSymbolsChecksumAsync(Project project
allChecksums.Add(compilationOptionsChecksum);
allChecksums.Add(parseOptionsChecksum);
var checksum = Checksum.Create(WellKnownSynchronizationKinds.SymbolTreeInfo, allChecksums);
var checksum = Checksum.Create(WellKnownSynchronizationKind.SymbolTreeInfo, allChecksums);
return checksum;
}
finally
......
......@@ -89,7 +89,7 @@ private void WriteFormatAndChecksum(ObjectWriter writer, string formatVersion)
var parseOptionsChecksum = ChecksumCache.GetOrCreate(
parseOptions, _ => serializer.CreateChecksum(parseOptions, cancellationToken));
return Checksum.Create(WellKnownSynchronizationKinds.SyntaxTreeIndex, new[] { textChecksum, parseOptionsChecksum });
return Checksum.Create(WellKnownSynchronizationKind.SyntaxTreeIndex, new[] { textChecksum, parseOptionsChecksum });
}
private async Task<bool> SaveAsync(
......
......@@ -12,11 +12,11 @@ namespace Microsoft.CodeAnalysis.Serialization
/// </summary>
internal abstract class ChecksumCollection : ChecksumWithChildren, IEnumerable<Checksum>
{
protected ChecksumCollection(WellKnownSynchronizationKinds kind, Checksum[] checksums) : this(kind, (object[])checksums)
protected ChecksumCollection(WellKnownSynchronizationKind kind, Checksum[] checksums) : this(kind, (object[])checksums)
{
}
protected ChecksumCollection(WellKnownSynchronizationKinds kind, object[] checksums) : base(kind, checksums)
protected ChecksumCollection(WellKnownSynchronizationKind kind, object[] checksums) : base(kind, checksums)
{
}
......@@ -38,36 +38,36 @@ IEnumerator IEnumerable.GetEnumerator()
internal class ProjectChecksumCollection : ChecksumCollection
{
public ProjectChecksumCollection(Checksum[] checksums) : this((object[])checksums) { }
public ProjectChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKinds.ProjectChecksumCollection, checksums) { }
public ProjectChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKind.ProjectChecksumCollection, checksums) { }
}
internal class DocumentChecksumCollection : ChecksumCollection
{
public DocumentChecksumCollection(Checksum[] checksums) : this((object[])checksums) { }
public DocumentChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKinds.DocumentChecksumCollection, checksums) { }
public DocumentChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKind.DocumentChecksumCollection, checksums) { }
}
internal class TextDocumentChecksumCollection : ChecksumCollection
{
public TextDocumentChecksumCollection(Checksum[] checksums) : this((object[])checksums) { }
public TextDocumentChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKinds.TextDocumentChecksumCollection, checksums) { }
public TextDocumentChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKind.TextDocumentChecksumCollection, checksums) { }
}
internal class ProjectReferenceChecksumCollection : ChecksumCollection
{
public ProjectReferenceChecksumCollection(Checksum[] checksums) : this((object[])checksums) { }
public ProjectReferenceChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKinds.ProjectReferenceChecksumCollection, checksums) { }
public ProjectReferenceChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKind.ProjectReferenceChecksumCollection, checksums) { }
}
internal class MetadataReferenceChecksumCollection : ChecksumCollection
{
public MetadataReferenceChecksumCollection(Checksum[] checksums) : this((object[])checksums) { }
public MetadataReferenceChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKinds.MetadataReferenceChecksumCollection, checksums) { }
public MetadataReferenceChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKind.MetadataReferenceChecksumCollection, checksums) { }
}
internal class AnalyzerReferenceChecksumCollection : ChecksumCollection
{
public AnalyzerReferenceChecksumCollection(Checksum[] checksums) : this((object[])checksums) { }
public AnalyzerReferenceChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKinds.AnalyzerReferenceChecksumCollection, checksums) { }
public AnalyzerReferenceChecksumCollection(object[] checksums) : base(WellKnownSynchronizationKind.AnalyzerReferenceChecksumCollection, checksums) { }
}
}
......@@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Serialization
/// </summary>
internal abstract class ChecksumWithChildren : IChecksummedObject
{
public ChecksumWithChildren(WellKnownSynchronizationKinds kind, params object[] children)
public ChecksumWithChildren(WellKnownSynchronizationKind kind, params object[] children)
{
Checksum = CreateChecksum(kind, children);
Children = children;
......@@ -20,7 +20,7 @@ public ChecksumWithChildren(WellKnownSynchronizationKinds kind, params object[]
public IReadOnlyList<object> Children { get; }
private static Checksum CreateChecksum(WellKnownSynchronizationKinds kind, object[] children)
private static Checksum CreateChecksum(WellKnownSynchronizationKind kind, object[] children)
{
// given children must be either Checksum or Checksums (collection of a checksum)
return Checksum.Create(kind, children.Select(c => c as Checksum ?? ((ChecksumCollection)c).Checksum));
......
......@@ -24,7 +24,7 @@ public static Checksum Create(Stream stream)
}
}
public static Checksum Create(WellKnownSynchronizationKinds kind, IObjectWritable @object)
public static Checksum Create(WellKnownSynchronizationKind kind, IObjectWritable @object)
{
using (var stream = SerializableBytes.CreateWritableStream())
using (var objectWriter = new ObjectWriter(stream))
......@@ -36,7 +36,7 @@ public static Checksum Create(WellKnownSynchronizationKinds kind, IObjectWritabl
}
}
public static Checksum Create(WellKnownSynchronizationKinds kind, IEnumerable<Checksum> checksums)
public static Checksum Create(WellKnownSynchronizationKind kind, IEnumerable<Checksum> checksums)
{
using (var stream = SerializableBytes.CreateWritableStream())
using (var writer = new ObjectWriter(stream))
......@@ -52,7 +52,7 @@ public static Checksum Create(WellKnownSynchronizationKinds kind, IEnumerable<Ch
}
}
public static Checksum Create(WellKnownSynchronizationKinds kind, ImmutableArray<byte> bytes)
public static Checksum Create(WellKnownSynchronizationKind kind, ImmutableArray<byte> bytes)
{
using (var stream = SerializableBytes.CreateWritableStream())
using (var writer = new ObjectWriter(stream))
......@@ -68,7 +68,7 @@ public static Checksum Create(WellKnownSynchronizationKinds kind, ImmutableArray
}
}
public static Checksum Create<T>(WellKnownSynchronizationKinds kind, T value, Serializer serializer)
public static Checksum Create<T>(WellKnownSynchronizationKind kind, T value, Serializer serializer)
{
using (var stream = SerializableBytes.CreateWritableStream())
using (var objectWriter = new ObjectWriter(stream))
......
......@@ -235,7 +235,7 @@ Checksum IChecksummedObject.Checksum
{
if (_lazyChecksum == null)
{
_lazyChecksum = Checksum.Create(WellKnownSynchronizationKinds.DocumentAttributes, this);
_lazyChecksum = Checksum.Create(WellKnownSynchronizationKind.DocumentAttributes, this);
}
return _lazyChecksum;
......
......@@ -475,7 +475,7 @@ Checksum IChecksummedObject.Checksum
{
if (_lazyChecksum == null)
{
_lazyChecksum = Checksum.Create(WellKnownSynchronizationKinds.ProjectAttributes, this);
_lazyChecksum = Checksum.Create(WellKnownSynchronizationKind.ProjectAttributes, this);
}
return _lazyChecksum;
......
......@@ -139,7 +139,7 @@ Checksum IChecksummedObject.Checksum
{
if (_lazyChecksum == null)
{
_lazyChecksum = Checksum.Create(WellKnownSynchronizationKinds.SolutionAttributes, this);
_lazyChecksum = Checksum.Create(WellKnownSynchronizationKind.SolutionAttributes, this);
}
return _lazyChecksum;
......
......@@ -16,7 +16,7 @@ internal sealed class SolutionStateChecksums : ChecksumWithChildren
{
}
public SolutionStateChecksums(params object[] children) : base(WellKnownSynchronizationKinds.SolutionStateChecksums, children)
public SolutionStateChecksums(params object[] children) : base(WellKnownSynchronizationKind.SolutionStateChecksums, children)
{
}
......@@ -94,7 +94,7 @@ internal class ProjectStateChecksums : ChecksumWithChildren
{
}
public ProjectStateChecksums(params object[] children) : base(WellKnownSynchronizationKinds.ProjectStateChecksums, children)
public ProjectStateChecksums(params object[] children) : base(WellKnownSynchronizationKind.ProjectStateChecksums, children)
{
}
......@@ -228,7 +228,7 @@ internal class DocumentStateChecksums : ChecksumWithChildren
{
}
public DocumentStateChecksums(params object[] children) : base(WellKnownSynchronizationKinds.DocumentStateChecksums, children)
public DocumentStateChecksums(params object[] children) : base(WellKnownSynchronizationKind.DocumentStateChecksums, children)
{
}
......
......@@ -368,7 +368,7 @@
<Compile Include="Execution\CustomAsset.cs" />
<Compile Include="Execution\CustomAssetBuilder.cs" />
<Compile Include="Execution\SolutionAsset.cs" />
<Compile Include="Execution\WellKnownSynchronizationKinds.cs" />
<Compile Include="Execution\WellKnownSynchronizationKind.cs" />
<Compile Include="Experiments\IExperimentationService.cs" />
<Compile Include="FindSymbols\Declarations\DeclarationFinder.cs" />
<Compile Include="FindSymbols\Declarations\DeclarationFinder_AllDeclarations.cs" />
......
......@@ -39,7 +39,7 @@ internal static Solution CreateFullSolution(HostServices hostServices = null)
internal static async Task VerifyAssetAsync(ISolutionSynchronizationService service, SolutionStateChecksums solutionObject)
{
await VerifyAssetSerializationAsync<SolutionInfo.SolutionAttributes>(
service, solutionObject.Info, WellKnownSynchronizationKinds.SolutionAttributes,
service, solutionObject.Info, WellKnownSynchronizationKind.SolutionAttributes,
(v, k, s) => SolutionAsset.Create(s.CreateChecksum(v, CancellationToken.None), v, s)).ConfigureAwait(false);
foreach (var projectChecksum in solutionObject.Projects)
......@@ -52,15 +52,15 @@ internal static async Task VerifyAssetAsync(ISolutionSynchronizationService serv
internal static async Task VerifyAssetAsync(ISolutionSynchronizationService service, ProjectStateChecksums projectObject)
{
var info = await VerifyAssetSerializationAsync<ProjectInfo.ProjectAttributes>(
service, projectObject.Info, WellKnownSynchronizationKinds.ProjectAttributes,
service, projectObject.Info, WellKnownSynchronizationKind.ProjectAttributes,
(v, k, s) => SolutionAsset.Create(s.CreateChecksum(v, CancellationToken.None), v, s)).ConfigureAwait(false);
await VerifyAssetSerializationAsync<CompilationOptions>(
service, projectObject.CompilationOptions, WellKnownSynchronizationKinds.CompilationOptions,
service, projectObject.CompilationOptions, WellKnownSynchronizationKind.CompilationOptions,
(v, k, s) => SolutionAsset.Create(s.CreateChecksum(v, CancellationToken.None), v, s));
await VerifyAssetSerializationAsync<ParseOptions>(
service, projectObject.ParseOptions, WellKnownSynchronizationKinds.ParseOptions,
service, projectObject.ParseOptions, WellKnownSynchronizationKind.ParseOptions,
(v, k, s) => SolutionAsset.Create(s.CreateChecksum(v, CancellationToken.None), v, s));
foreach (var checksum in projectObject.Documents)
......@@ -72,21 +72,21 @@ internal static async Task VerifyAssetAsync(ISolutionSynchronizationService serv
foreach (var checksum in projectObject.ProjectReferences)
{
await VerifyAssetSerializationAsync<ProjectReference>(
service, checksum, WellKnownSynchronizationKinds.ProjectReference,
service, checksum, WellKnownSynchronizationKind.ProjectReference,
(v, k, s) => SolutionAsset.Create(s.CreateChecksum(v, CancellationToken.None), v, s));
}
foreach (var checksum in projectObject.MetadataReferences)
{
await VerifyAssetSerializationAsync<MetadataReference>(
service, checksum, WellKnownSynchronizationKinds.MetadataReference,
service, checksum, WellKnownSynchronizationKind.MetadataReference,
(v, k, s) => SolutionAsset.Create(s.CreateChecksum(v, CancellationToken.None), v, s));
}
foreach (var checksum in projectObject.AnalyzerReferences)
{
await VerifyAssetSerializationAsync<AnalyzerReference>(
service, checksum, WellKnownSynchronizationKinds.AnalyzerReference,
service, checksum, WellKnownSynchronizationKind.AnalyzerReference,
(v, k, s) => SolutionAsset.Create(s.CreateChecksum(v, CancellationToken.None), v, s));
}
......@@ -100,19 +100,19 @@ internal static async Task VerifyAssetAsync(ISolutionSynchronizationService serv
internal static async Task VerifyAssetAsync(ISolutionSynchronizationService service, DocumentStateChecksums documentObject)
{
var info = await VerifyAssetSerializationAsync<DocumentInfo.DocumentAttributes>(
service, documentObject.Info, WellKnownSynchronizationKinds.DocumentAttributes,
service, documentObject.Info, WellKnownSynchronizationKind.DocumentAttributes,
(v, k, s) => SolutionAsset.Create(s.CreateChecksum(v, CancellationToken.None), v, s)).ConfigureAwait(false);
await VerifyAssetSerializationAsync<SourceText>(
service, documentObject.Text, WellKnownSynchronizationKinds.SourceText,
service, documentObject.Text, WellKnownSynchronizationKind.SourceText,
(v, k, s) => SolutionAsset.Create(s.CreateChecksum(v, CancellationToken.None), v, s));
}
internal static async Task<T> VerifyAssetSerializationAsync<T>(
ISolutionSynchronizationService service,
Checksum checksum,
WellKnownSynchronizationKinds kind,
Func<T, WellKnownSynchronizationKinds, Serializer, RemotableData> assetGetter)
WellKnownSynchronizationKind kind,
Func<T, WellKnownSynchronizationKind, Serializer, RemotableData> assetGetter)
{
// re-create asset from object
var syncService = (SolutionSynchronizationServiceFactory.Service)service;
......@@ -206,20 +206,20 @@ internal static void ChecksumWithChildrenEqual(ChecksumWithChildren checksums1,
int expectedAdditionalDocumentCount)
{
VerifyChecksumInService(snapshotService, projectObject.Checksum, projectObject.GetWellKnownSynchronizationKind());
VerifyChecksumInService(snapshotService, projectObject.Info, WellKnownSynchronizationKinds.ProjectAttributes);
VerifyChecksumInService(snapshotService, projectObject.CompilationOptions, WellKnownSynchronizationKinds.CompilationOptions);
VerifyChecksumInService(snapshotService, projectObject.ParseOptions, WellKnownSynchronizationKinds.ParseOptions);
VerifyChecksumInService(snapshotService, projectObject.Info, WellKnownSynchronizationKind.ProjectAttributes);
VerifyChecksumInService(snapshotService, projectObject.CompilationOptions, WellKnownSynchronizationKind.CompilationOptions);
VerifyChecksumInService(snapshotService, projectObject.ParseOptions, WellKnownSynchronizationKind.ParseOptions);
VerifyCollectionInService(snapshotService, projectObject.Documents.ToDocumentObjects(snapshotService), expectedDocumentCount);
VerifyCollectionInService(snapshotService, projectObject.ProjectReferences, expectedProjectReferenceCount, WellKnownSynchronizationKinds.ProjectReference);
VerifyCollectionInService(snapshotService, projectObject.MetadataReferences, expectedMetadataReferenceCount, WellKnownSynchronizationKinds.MetadataReference);
VerifyCollectionInService(snapshotService, projectObject.AnalyzerReferences, expectedAnalyzerReferenceCount, WellKnownSynchronizationKinds.AnalyzerReference);
VerifyCollectionInService(snapshotService, projectObject.ProjectReferences, expectedProjectReferenceCount, WellKnownSynchronizationKind.ProjectReference);
VerifyCollectionInService(snapshotService, projectObject.MetadataReferences, expectedMetadataReferenceCount, WellKnownSynchronizationKind.MetadataReference);
VerifyCollectionInService(snapshotService, projectObject.AnalyzerReferences, expectedAnalyzerReferenceCount, WellKnownSynchronizationKind.AnalyzerReference);
VerifyCollectionInService(snapshotService, projectObject.AdditionalDocuments.ToDocumentObjects(snapshotService), expectedAdditionalDocumentCount);
}
internal static void VerifyCollectionInService(ISolutionSynchronizationService snapshotService, ChecksumCollection checksums, int expectedCount, WellKnownSynchronizationKinds expectedItemKind)
internal static void VerifyCollectionInService(ISolutionSynchronizationService snapshotService, ChecksumCollection checksums, int expectedCount, WellKnownSynchronizationKind expectedItemKind)
{
VerifyChecksumInService(snapshotService, checksums.Checksum, checksums.GetWellKnownSynchronizationKind());
Assert.Equal(checksums.Count, expectedCount);
......@@ -244,8 +244,8 @@ internal static void VerifyCollectionInService(ISolutionSynchronizationService s
internal static void VerifySnapshotInService(ISolutionSynchronizationService snapshotService, DocumentStateChecksums documentObject)
{
VerifyChecksumInService(snapshotService, documentObject.Checksum, documentObject.GetWellKnownSynchronizationKind());
VerifyChecksumInService(snapshotService, documentObject.Info, WellKnownSynchronizationKinds.DocumentAttributes);
VerifyChecksumInService(snapshotService, documentObject.Text, WellKnownSynchronizationKinds.SourceText);
VerifyChecksumInService(snapshotService, documentObject.Info, WellKnownSynchronizationKind.DocumentAttributes);
VerifyChecksumInService(snapshotService, documentObject.Text, WellKnownSynchronizationKind.SourceText);
}
internal static void VerifySynchronizationObjectInService<T>(ISolutionSynchronizationService snapshotService, T syncObject) where T : RemotableData
......@@ -253,7 +253,7 @@ internal static void VerifySnapshotInService(ISolutionSynchronizationService sna
VerifyChecksumInService(snapshotService, syncObject.Checksum, syncObject.Kind);
}
internal static void VerifyChecksumInService(ISolutionSynchronizationService snapshotService, Checksum checksum, WellKnownSynchronizationKinds kind)
internal static void VerifyChecksumInService(ISolutionSynchronizationService snapshotService, Checksum checksum, WellKnownSynchronizationKind kind)
{
Assert.NotNull(checksum);
var otherObject = snapshotService.GetRemotableData(checksum, CancellationToken.None);
......@@ -266,7 +266,7 @@ internal static void VerifyChecksumInService(ISolutionSynchronizationService sna
ChecksumEqual(checksumObject1.Checksum, checksumObject1.Kind, checksumObject2.Checksum, checksumObject2.Kind);
}
internal static void ChecksumEqual(Checksum checksum1, WellKnownSynchronizationKinds kind1, Checksum checksum2, WellKnownSynchronizationKinds kind2)
internal static void ChecksumEqual(Checksum checksum1, WellKnownSynchronizationKind kind1, Checksum checksum2, WellKnownSynchronizationKind kind2)
{
Assert.Equal(checksum1, checksum2);
Assert.Equal(kind1, kind2);
......
......@@ -42,7 +42,7 @@ public async Task CreateSolutionSnapshotId_Empty()
VerifySynchronizationObjectInService(snapshotService, solutionSyncObject);
var solutionObject = await snapshotService.GetValueAsync<SolutionStateChecksums>(checksum).ConfigureAwait(false);
VerifyChecksumInService(snapshotService, solutionObject.Info, WellKnownSynchronizationKinds.SolutionAttributes);
VerifyChecksumInService(snapshotService, solutionObject.Info, WellKnownSynchronizationKind.SolutionAttributes);
var projectsSyncObject = snapshotService.GetRemotableData(solutionObject.Projects.Checksum, CancellationToken.None);
VerifySynchronizationObjectInService(snapshotService, projectsSyncObject);
......@@ -78,7 +78,7 @@ public async Task CreateSolutionSnapshotId_Project()
var solutionObject = await snapshotService.GetValueAsync<SolutionStateChecksums>(checksum).ConfigureAwait(false);
VerifyChecksumInService(snapshotService, solutionObject.Info, WellKnownSynchronizationKinds.SolutionAttributes);
VerifyChecksumInService(snapshotService, solutionObject.Info, WellKnownSynchronizationKind.SolutionAttributes);
var projectSyncObject = snapshotService.GetRemotableData(solutionObject.Projects.Checksum, CancellationToken.None);
VerifySynchronizationObjectInService(snapshotService, projectSyncObject);
......@@ -114,8 +114,8 @@ public async Task CreateSolutionSnapshotId()
var solutionObject = await snapshotService.GetValueAsync<SolutionStateChecksums>(syncObject.Checksum).ConfigureAwait(false);
VerifySynchronizationObjectInService(snapshotService, syncObject);
VerifyChecksumInService(snapshotService, solutionObject.Info, WellKnownSynchronizationKinds.SolutionAttributes);
VerifyChecksumInService(snapshotService, solutionObject.Projects.Checksum, WellKnownSynchronizationKinds.Projects);
VerifyChecksumInService(snapshotService, solutionObject.Info, WellKnownSynchronizationKind.SolutionAttributes);
VerifyChecksumInService(snapshotService, solutionObject.Projects.Checksum, WellKnownSynchronizationKind.Projects);
Assert.Equal(solutionObject.Projects.Count, 1);
VerifySnapshotInService(snapshotService, solutionObject.Projects.ToProjectObjects(snapshotService)[0], 1, 0, 0, 0, 0);
......@@ -151,8 +151,8 @@ public async Task CreateSolutionSnapshotId_Full()
var solutionObject = await snapshotService.GetValueAsync<SolutionStateChecksums>(syncObject.Checksum).ConfigureAwait(false);
VerifySynchronizationObjectInService(snapshotService, syncObject);
VerifyChecksumInService(snapshotService, solutionObject.Info, WellKnownSynchronizationKinds.SolutionAttributes);
VerifyChecksumInService(snapshotService, solutionObject.Projects.Checksum, WellKnownSynchronizationKinds.Projects);
VerifyChecksumInService(snapshotService, solutionObject.Info, WellKnownSynchronizationKind.SolutionAttributes);
VerifyChecksumInService(snapshotService, solutionObject.Projects.Checksum, WellKnownSynchronizationKind.Projects);
Assert.Equal(solutionObject.Projects.Count, 2);
......
......@@ -29,7 +29,7 @@ public AssetService(int sessionId, AssetStorage assetStorage)
_assetStorage = assetStorage;
}
public T Deserialize<T>(WellKnownSynchronizationKinds kind, ObjectReader reader, CancellationToken cancellationToken)
public T Deserialize<T>(WellKnownSynchronizationKind kind, ObjectReader reader, CancellationToken cancellationToken)
{
return s_serializer.Deserialize<T>(kind, reader, cancellationToken);
}
......
......@@ -73,7 +73,7 @@ private class JsonRpcAssetSource : AssetSource
var responseChecksum = Checksum.ReadFrom(reader);
Contract.ThrowIfFalse(checksums.Contains(responseChecksum));
var kind = (WellKnownSynchronizationKinds)reader.ReadInt32();
var kind = (WellKnownSynchronizationKind)reader.ReadInt32();
// in service hub, cancellation means simply closed stream
var @object = _owner.RoslynServices.AssetService.Deserialize<object>(kind, reader, cancellationToken);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册