本文整理汇总了C#中Roslyn.Utilities.ObjectWriter类的典型用法代码示例。如果您正苦于以下问题:C# ObjectWriter类的具体用法?C# ObjectWriter怎么用?C# ObjectWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectWriter类属于Roslyn.Utilities命名空间,在下文中一共展示了ObjectWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTo
internal override void WriteTo(ObjectWriter writer)
{
base.WriteTo(writer);
writer.WriteValue(_child0);
writer.WriteValue(_child1);
writer.WriteValue(_child2);
}
示例2: WriteTo
public void WriteTo(ObjectWriter writer)
{
writer.WriteString(SerializationFormat);
writer.WriteBoolean(_isCaseSensitive);
writer.WriteInt32(_hashFunctionCount);
_bitArray.WriteTo(writer);
}
示例3: SerializeChecksumObjectWithChildrenAsync
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);
}
}
示例4: WriteTo
internal void WriteTo(ObjectWriter writer)
{
writer.WriteInt32(WordSpan.Start);
writer.WriteInt32(WordSpan.Length);
writer.WriteInt32(EdgeCount);
writer.WriteInt32(FirstEdgeIndex);
}
示例5: WriteBitArray
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);
}
}
}
示例6: WriteObjectToAsync
public override async Task WriteObjectToAsync(ObjectWriter writer, CancellationToken cancellationToken)
{
var text = await _state.GetTextAsync(cancellationToken).ConfigureAwait(false);
// TODO: make TextDocumentState to implement ISupportTemporaryStorage?
_serializer.SerializeSourceText(_state.Storage as ITemporaryStorageWithName, text, writer, cancellationToken);
}
示例7: WriteTo
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);
}
}
}
}
示例8: SerializeChecksumWithChildren
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);
}
}
示例9: WriteTo
public override void WriteTo(OptionSet options, ObjectWriter writer, CancellationToken cancellationToken)
{
WriteOptionSetTo(options, LanguageNames.CSharp, writer, cancellationToken);
WriteOptionTo(options, CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, writer, cancellationToken);
WriteOptionTo(options, CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, writer, cancellationToken);
WriteOptionTo(options, CSharpCodeStyleOptions.UseImplicitTypeWherePossible, writer, cancellationToken);
}
示例10: WriteTo
public void WriteTo(ObjectWriter writer)
{
writer.WriteInt32(DeclaredSymbolInfos.Length);
foreach (var declaredSymbolInfo in DeclaredSymbolInfos)
{
declaredSymbolInfo.WriteTo(writer);
}
}
示例11: WriteTo
public override void WriteTo(CompilationOptions options, ObjectWriter writer, CancellationToken cancellationToken)
{
WriteCompilationOptionsTo(options, writer, cancellationToken);
var csharpOptions = (CSharpCompilationOptions)options;
writer.WriteValue(csharpOptions.Usings.ToArray());
writer.WriteBoolean(csharpOptions.AllowUnsafe);
}
示例12: WriteTo
public override void WriteTo(ObjectWriter writer)
{
writer.WriteInt32(DeclaredSymbolInfos.Count());
foreach (var declaredSymbolInfo in DeclaredSymbolInfos)
{
declaredSymbolInfo.WriteTo(writer);
}
}
示例13: SerializeOptionSet
// this is temporary solution until option is supported in compiler layer natively
// this won't serialize all options but some we pre-selected
public void SerializeOptionSet(OptionSet options, string language, ObjectWriter writer, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
writer.WriteString(language);
var serializationService = GetOptionsSerializationService(language);
serializationService.WriteTo(options, writer, cancellationToken);
}
示例14: CreateChecksumFromStreamWriter
private static Checksum CreateChecksumFromStreamWriter(string kind, Action<ObjectWriter, CancellationToken> writer)
{
using (var stream = SerializableBytes.CreateWritableStream())
using (var objectWriter = new ObjectWriter(stream))
{
objectWriter.WriteString(kind);
writer(objectWriter, CancellationToken.None);
return Checksum.Create(stream);
}
}
示例15: WriteTo
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);
}