本文整理汇总了C#中CSharpCompilation.SerializeToDeltaStreams方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpCompilation.SerializeToDeltaStreams方法的具体用法?C# CSharpCompilation.SerializeToDeltaStreams怎么用?C# CSharpCompilation.SerializeToDeltaStreams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSharpCompilation
的用法示例。
在下文中一共展示了CSharpCompilation.SerializeToDeltaStreams方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitDifference
internal static EmitDifferenceResult EmitDifference(
CSharpCompilation compilation,
EmitBaseline baseline,
IEnumerable<SemanticEdit> edits,
Func<ISymbol, bool> isAddedSymbol,
Stream metadataStream,
Stream ilStream,
Stream pdbStream,
ICollection<MethodDefinitionHandle> updatedMethods,
CompilationTestData testData,
CancellationToken cancellationToken)
{
Guid moduleVersionId;
try
{
moduleVersionId = baseline.OriginalMetadata.GetModuleVersionId();
}
catch (BadImageFormatException)
{
// TODO:
// return MakeEmitResult(success: false, diagnostics: ..., baseline: null);
throw;
}
var diagnostics = DiagnosticBag.GetInstance();
var emitOptions = EmitOptions.Default;
string runtimeMDVersion = compilation.GetRuntimeMetadataVersion(emitOptions, diagnostics);
var serializationProperties = compilation.ConstructModuleSerializationProperties(emitOptions, runtimeMDVersion, moduleVersionId);
var manifestResources = SpecializedCollections.EmptyEnumerable<ResourceDescription>();
var moduleBeingBuilt = new PEDeltaAssemblyBuilder(
compilation.SourceAssembly,
emitOptions: emitOptions,
outputKind: compilation.Options.OutputKind,
serializationProperties: serializationProperties,
manifestResources: manifestResources,
previousGeneration: baseline,
edits: edits,
isAddedSymbol: isAddedSymbol);
if (testData != null)
{
moduleBeingBuilt.SetMethodTestData(testData.Methods);
testData.Module = moduleBeingBuilt;
}
var definitionMap = moduleBeingBuilt.PreviousDefinitions;
var changes = moduleBeingBuilt.Changes;
EmitBaseline newBaseline = null;
if (compilation.Compile(
moduleBeingBuilt,
win32Resources: null,
xmlDocStream: null,
emittingPdb: true,
diagnostics: diagnostics,
filterOpt: changes.RequiresCompilation,
cancellationToken: cancellationToken))
{
// Map the definitions from the previous compilation to the current compilation.
// This must be done after compiling above since synthesized definitions
// (generated when compiling method bodies) may be required.
var mappedBaseline = MapToCompilation(compilation, moduleBeingBuilt);
newBaseline = compilation.SerializeToDeltaStreams(
moduleBeingBuilt,
mappedBaseline,
definitionMap,
changes,
metadataStream,
ilStream,
pdbStream,
updatedMethods,
diagnostics,
testData?.SymWriterFactory,
cancellationToken);
}
return new EmitDifferenceResult(
success: newBaseline != null,
diagnostics: diagnostics.ToReadOnlyAndFree(),
baseline: newBaseline);
}