internal void WriteTo(ObjectWriter writer) { writer.WriteInt32(WordSpan.Start); writer.WriteInt32(WordSpan.Length); writer.WriteInt32(EdgeCount); writer.WriteInt32(FirstEdgeIndex); }
internal void WriteTo(ObjectWriter writer) { writer.WriteString(Name); writer.WriteString(ContainerDisplayName); writer.WriteString(FullyQualifiedContainerName); writer.WriteByte((byte)Kind); writer.WriteInt32(Span.Start); writer.WriteInt32(Span.Length); writer.WriteUInt16(ParameterCount); writer.WriteUInt16(TypeParameterCount); }
private static void WriteBitArray(ObjectWriter writer, BitArray bitArray) { // Our serialization format doesn't round-trip bit arrays of non-byte lengths Contract.ThrowIfTrue(bitArray.Length % 8 != 0); writer.WriteInt32(bitArray.Length / 8); // This will hold the byte that we will write out after we process every 8 bits. This is // LSB, so we push bits into it from the MSB. byte b = 0; for (var i = 0; i < bitArray.Length; i++) { if (bitArray[i]) { b = (byte)(0x80 | b >> 1); } else { b >>= 1; } if ((i + 1) % 8 == 0) { // End of a byte, write out the byte writer.WriteByte(b); } } }
public async Task SerializeChecksumObjectWithChildrenAsync(ChecksumObjectWithChildren checksumObject, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); writer.WriteString(checksumObject.Kind); checksumObject.Checksum.WriteTo(writer); writer.WriteInt32(checksumObject.Children.Length); foreach (var child in checksumObject.Children) { var checksum = child as Checksum; if (checksum != null) { writer.WriteByte(ChecksumKind); checksum.WriteTo(writer); continue; } var checksumCollection = child as ChecksumCollection; if (checksumCollection != null) { writer.WriteByte(ChecksumCollectionKind); await SerializeChecksumObjectWithChildrenAsync(checksumCollection, writer, cancellationToken).ConfigureAwait(false); continue; } throw ExceptionUtilities.UnexpectedValue(child); } }
public void SerializeChecksumWithChildren(ChecksumWithChildren checksums, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var kind = checksums.GetWellKnownSynchronizationKind(); writer.WriteString(kind); checksums.Checksum.WriteTo(writer); writer.WriteInt32(checksums.Children.Count); foreach (var child in checksums.Children) { var checksum = child as Checksum; if (checksum != null) { writer.WriteByte(ChecksumKind); checksum.WriteTo(writer); continue; } var checksumCollection = child as ChecksumCollection; if (checksumCollection != null) { writer.WriteByte(ChecksumWithChildrenKind); SerializeChecksumWithChildren(checksumCollection, writer, cancellationToken); continue; } throw ExceptionUtilities.UnexpectedValue(child); } }
public void WriteTo(ObjectWriter writer) { writer.WriteString(SerializationFormat); writer.WriteBoolean(_isCaseSensitive); writer.WriteInt32(_hashFunctionCount); _bitArray.WriteTo(writer); }
public override void WriteTo(ParseOptions options, ObjectWriter writer, CancellationToken cancellationToken) { WriteParseOptionsTo(options, writer, cancellationToken); var csharpOptions = (CSharpParseOptions)options; writer.WriteInt32((int)csharpOptions.LanguageVersion); writer.WriteValue(options.PreprocessorSymbolNames.ToArray()); }
public override void WriteTo(ObjectWriter writer) { writer.WriteInt32(DeclaredSymbolInfos.Count()); foreach (var declaredSymbolInfo in DeclaredSymbolInfos) { declaredSymbolInfo.WriteTo(writer); } }
public void WriteTo(ObjectWriter writer) { writer.WriteInt32(DeclaredSymbolInfos.Length); foreach (var declaredSymbolInfo in DeclaredSymbolInfos) { declaredSymbolInfo.WriteTo(writer); } }
internal void WriteTo(ObjectWriter writer) { writer.WriteInt32(_concatenatedLowerCaseWords.Length); foreach (var c in _concatenatedLowerCaseWords) { writer.WriteChar(c); } writer.WriteInt32(this._nodes.Length); foreach (var node in _nodes) { node.WriteTo(writer); } writer.WriteInt32(this._edges.Length); foreach (var edge in _edges) { edge.WriteTo(writer); } }
internal void WriteTo(ObjectWriter writer) { writer.WriteInt32(_concatenatedLowerCaseWords.Length); foreach (var c in _concatenatedLowerCaseWords) { writer.WriteChar(c); } writer.WriteInt32(_nodes.Length); foreach (var node in _nodes) { node.WriteTo(writer); } writer.WriteInt32(_edges.Length); foreach (var edge in _edges) { edge.WriteTo(writer); } }
public void SerializeSourceText(ITemporaryStorageWithName storage, SourceText text, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); writer.WriteInt32((int)text.ChecksumAlgorithm); writer.WriteString(text.Encoding?.WebName); // TODO: refactor this part in its own abstraction (Bits) that has multiple sub types // rather than using enums if (storage != null && storage.Name != null) { writer.WriteInt32((int)SerializationKinds.MemoryMapFile); writer.WriteString(storage.Name); writer.WriteInt64(storage.Size); return; } writer.WriteInt32((int)SerializationKinds.Bits); writer.WriteString(text.ToString()); }
public void SerializeDocumentSnapshotInfo(DocumentChecksumObjectInfo info, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); SerializeDocumentId(info.Id, writer, cancellationToken); writer.WriteString(info.Name); writer.WriteValue(info.Folders.ToArray()); writer.WriteInt32((int)info.SourceCodeKind); writer.WriteString(info.FilePath); writer.WriteBoolean(info.IsGenerated); }
internal override void WriteTo(ObjectWriter writer) { base.WriteTo(writer); // PERF: Write the array out manually.Profiling shows that this is cheaper than converting to // an array in order to use writer.WriteValue. writer.WriteInt32(this.children.Length); for (var i = 0; i < this.children.Length; i++) { writer.WriteValue(this.children[i].Value); } }
public static void WriteTo(this BitArray bitArray, ObjectWriter writer) { // TODO : think about a way to use pool for byte array. // BitArray will internally allocate another int array. probably need to drop BitArray usage. var bytes = new byte[(bitArray.Length + 7) / 8]; bitArray.CopyTo(bytes, 0); writer.WriteString(SerializationFormat); writer.WriteInt32(bytes.Length); for (var i = 0; i < bytes.Length; i++) { writer.WriteByte(bytes[i]); } }
protected void WriteCompilationOptionsTo(CompilationOptions options, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); writer.WriteInt32((int)options.OutputKind); writer.WriteBoolean(options.ReportSuppressedDiagnostics); writer.WriteString(options.ModuleName); writer.WriteString(options.MainTypeName); writer.WriteString(options.ScriptClassName); writer.WriteInt32((int)options.OptimizationLevel); writer.WriteBoolean(options.CheckOverflow); // REVIEW: is it okay this being not part of snapshot? writer.WriteString(options.CryptoKeyContainer); writer.WriteString(options.CryptoKeyFile); writer.WriteValue(options.CryptoPublicKey.ToArray()); writer.WriteBoolean(options.DelaySign.HasValue); if (options.DelaySign.HasValue) { writer.WriteBoolean(options.DelaySign.Value); } writer.WriteInt32((int)options.Platform); writer.WriteInt32((int)options.GeneralDiagnosticOption); writer.WriteInt32(options.WarningLevel); // REVIEW: I don't think there is a guarantee on ordering of elements in the immutable dictionary. // unfortunately, we need to sort them to make it deterministic writer.WriteInt32(options.SpecificDiagnosticOptions.Count); foreach (var kv in options.SpecificDiagnosticOptions.OrderBy(o => o.Key)) { writer.WriteString(kv.Key); writer.WriteInt32((int)kv.Value); } writer.WriteBoolean(options.ConcurrentBuild); writer.WriteBoolean(options.Deterministic); writer.WriteBoolean(options.PublicSign); // REVIEW: What should I do with these. we probably need to implement either out own one // or somehow share these as service.... // // XmlReferenceResolver xmlReferenceResolver // SourceReferenceResolver sourceReferenceResolver // MetadataReferenceResolver metadataReferenceResolver // AssemblyIdentityComparer assemblyIdentityComparer // StrongNameProvider strongNameProvider }
public static void Serialize(ObjectWriter writer, DiagnosticAnalysisResultMap<string, DiagnosticAnalysisResultBuilder> result, CancellationToken cancellationToken) { var diagnosticSerializer = new DiagnosticDataSerializer(VersionStamp.Default, VersionStamp.Default); var analysisResult = result.AnalysisResult; writer.WriteInt32(analysisResult.Count); foreach (var kv in analysisResult) { writer.WriteString(kv.Key); Serialize(writer, diagnosticSerializer, kv.Value.SyntaxLocals, cancellationToken); Serialize(writer, diagnosticSerializer, kv.Value.SemanticLocals, cancellationToken); Serialize(writer, diagnosticSerializer, kv.Value.NonLocals, cancellationToken); diagnosticSerializer.WriteTo(writer, kv.Value.Others, cancellationToken); } var telemetryInfo = result.TelemetryInfo; writer.WriteInt32(telemetryInfo.Count); foreach (var kv in telemetryInfo) { writer.WriteString(kv.Key); Serialize(writer, kv.Value, cancellationToken); } var exceptions = result.Exceptions; writer.WriteInt32(exceptions.Count); foreach (var kv in exceptions) { writer.WriteString(kv.Key); diagnosticSerializer.WriteTo(writer, kv.Value, cancellationToken); } }
private bool TryWritePortableExecutableReferenceBackedByTemporaryStorageTo( ISupportTemporaryStorage reference, ObjectWriter writer, CancellationToken cancellationToken) { var storages = reference.GetStorages(); if (storages == null) { return false; } using (var pooled = Creator.CreateList<ValueTuple<string, long>>()) { foreach (var storage in storages) { var storage2 = storage as ITemporaryStorageWithName; if (storage2 == null) { return false; } pooled.Object.Add(ValueTuple.Create(storage2.Name, storage2.Size)); } WritePortableExecutableReferenceHeaderTo((PortableExecutableReference)reference, SerializationKinds.MemoryMapFile, writer, cancellationToken); writer.WriteInt32((int)MetadataImageKind.Assembly); writer.WriteInt32(pooled.Object.Count); foreach (var tuple in pooled.Object) { writer.WriteInt32((int)MetadataImageKind.Module); writer.WriteString(tuple.Item1); writer.WriteInt64(tuple.Item2); } return true; } }
private void WriteTo(Metadata metadata, ObjectWriter writer, CancellationToken cancellationToken) { var assemblyMetadata = metadata as AssemblyMetadata; if (assemblyMetadata != null) { writer.WriteInt32((int)assemblyMetadata.Kind); var modules = assemblyMetadata.GetModules(); writer.WriteInt32(modules.Length); foreach (var module in modules) { WriteTo(module, writer, cancellationToken); } return; } WriteTo((ModuleMetadata)metadata, writer, cancellationToken); }
private void WriteTo(MetadataReferenceProperties properties, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); writer.WriteInt32((int)properties.Kind); writer.WriteValue(properties.Aliases.ToArray()); writer.WriteBoolean(properties.EmbedInteropTypes); }
private void WriteMvidTo(ModuleMetadata metadata, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); writer.WriteInt32((int)metadata.Kind); var metadataReader = metadata.GetMetadataReader(); var mvidHandle = metadataReader.GetModuleDefinition().Mvid; var guid = metadataReader.GetGuid(mvidHandle); writer.WriteValue(guid.ToByteArray()); }
private void WriteMvidsTo(PortableExecutableReference reference, ObjectWriter writer, CancellationToken cancellationToken) { var metadata = reference.GetMetadata(); var assemblyMetadata = metadata as AssemblyMetadata; if (assemblyMetadata != null) { writer.WriteInt32((int)assemblyMetadata.Kind); var modules = assemblyMetadata.GetModules(); writer.WriteInt32(modules.Length); foreach (var module in modules) { WriteMvidTo(module, writer, cancellationToken); } return; } WriteMvidTo((ModuleMetadata)metadata, writer, cancellationToken); }
protected void WritePortableExecutableReferenceHeaderTo( PortableExecutableReference reference, SerializationKinds kind, ObjectWriter writer, CancellationToken cancellationToken) { writer.WriteString(nameof(PortableExecutableReference)); writer.WriteInt32((int)kind); WriteTo(reference.Properties, writer, cancellationToken); writer.WriteString(reference.FilePath); }
private void WriteTo(Stream stream, ImmutableArray<DiagnosticData> items, CancellationToken cancellationToken) { using (var writer = new ObjectWriter(stream, cancellationToken: cancellationToken)) { writer.WriteInt32(FormatVersion); AnalyzerVersion.WriteTo(writer); Version.WriteTo(writer); writer.WriteInt32(items.Length); foreach (var item in items) { cancellationToken.ThrowIfCancellationRequested(); writer.WriteString(item.Id); writer.WriteString(item.Category); writer.WriteString(item.Message); writer.WriteString(item.ENUMessageForBingSearch); writer.WriteString(item.Title); writer.WriteString(item.Description); writer.WriteString(item.HelpLink); writer.WriteInt32((int)item.Severity); writer.WriteInt32((int)item.DefaultSeverity); writer.WriteBoolean(item.IsEnabledByDefault); writer.WriteBoolean(item.IsSuppressed); writer.WriteInt32(item.WarningLevel); if (item.HasTextSpan) { // document state writer.WriteInt32(item.TextSpan.Start); writer.WriteInt32(item.TextSpan.Length); } else { // project state writer.WriteInt32(0); writer.WriteInt32(0); } WriteTo(writer, item.DataLocation, cancellationToken); WriteTo(writer, item.AdditionalLocations, cancellationToken); writer.WriteInt32(item.CustomTags.Count); foreach (var tag in item.CustomTags) { writer.WriteString(tag); } writer.WriteInt32(item.Properties.Count); foreach (var property in item.Properties) { writer.WriteString(property.Key); writer.WriteString(property.Value); } } } }
private static void WriteTo(ObjectWriter writer, DiagnosticDataLocation item, CancellationToken cancellationToken) { if (item == null) { writer.WriteBoolean(false); return; } else { writer.WriteBoolean(true); } if (item.SourceSpan.HasValue) { writer.WriteBoolean(true); writer.WriteInt32(item.SourceSpan.Value.Start); writer.WriteInt32(item.SourceSpan.Value.Length); } else { writer.WriteBoolean(false); } writer.WriteString(item.OriginalFilePath); writer.WriteInt32(item.OriginalStartLine); writer.WriteInt32(item.OriginalStartColumn); writer.WriteInt32(item.OriginalEndLine); writer.WriteInt32(item.OriginalEndColumn); writer.WriteString(item.MappedFilePath); writer.WriteInt32(item.MappedStartLine); writer.WriteInt32(item.MappedStartColumn); writer.WriteInt32(item.MappedEndLine); writer.WriteInt32(item.MappedEndColumn); }
private static void WriteTo(ObjectWriter writer, IReadOnlyCollection<DiagnosticDataLocation> additionalLocations, CancellationToken cancellationToken) { writer.WriteInt32(additionalLocations?.Count ?? 0); if (additionalLocations != null) { foreach (var location in additionalLocations) { cancellationToken.ThrowIfCancellationRequested(); WriteTo(writer, location, cancellationToken); } } }
private void WriteTo(ModuleMetadata metadata, ObjectWriter writer, CancellationToken cancellationToken) { writer.WriteInt32((int)metadata.Kind); WriteTo(metadata.GetMetadataReader(), writer, cancellationToken); }
public void WriteTo(AnalyzerReference reference, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var file = reference as AnalyzerFileReference; if (file != null) { writer.WriteString(nameof(AnalyzerFileReference)); writer.WriteInt32((int)SerializationKinds.FilePath); writer.WriteString(file.FullPath); // TODO: remove this kind of host specific knowledge from common layer. // but think moving it to host layer where this implementation detail actually exist. // // analyzer assembly path to load analyzer acts like // snapshot version for analyzer (since it is based on shadow copy) // we can't send over bits and load analyer from memory (image) due to CLR not being able // to find satellite dlls for analyzers. writer.WriteString(GetAnalyzerAssemblyPath(file)); return; } var image = reference as AnalyzerImageReference; if (image != null) { // TODO: think a way to support this or a way to deal with this kind of situation. throw new NotSupportedException(nameof(AnalyzerImageReference)); } var unresolved = reference as UnresolvedAnalyzerReference; if (unresolved != null) { writer.WriteString(nameof(UnresolvedAnalyzerReference)); writer.WriteString(reference.FullPath); return; } throw ExceptionUtilities.UnexpectedValue(reference.GetType()); }
private static async Task WriteToVersionAsync( IPersistentStorage storage, string keyName, VersionStamp projectVersion, VersionStamp semanticVersion, CancellationToken cancellationToken) { using (var stream = SerializableBytes.CreateWritableStream()) using (var writer = new ObjectWriter(stream, cancellationToken: cancellationToken)) { writer.WriteInt32(SerializationFormat); projectVersion.WriteTo(writer); semanticVersion.WriteTo(writer); stream.Position = 0; await storage.WriteStreamAsync(keyName, stream, cancellationToken).ConfigureAwait(false); } }
protected override void WriteTo(ObjectWriter writer) { base.WriteTo(writer); writer.WriteInt32(this.Offset); writer.WriteInt32(this.Width); }
protected virtual void WriteTo(ObjectWriter writer) { writer.WriteValue(_messageProvider); writer.WriteCompressedUInt((uint)_errorCode); writer.WriteInt32((int)_effectiveSeverity); writer.WriteInt32((int)_defaultSeverity); int count = (_arguments != null) ? _arguments.Length : 0; writer.WriteCompressedUInt((uint)count); if (count > 0) { foreach (var arg in _arguments) { writer.WriteString(arg.ToString()); } } }