本文整理汇总了C#中DiagnosticBag.Verify方法的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticBag.Verify方法的具体用法?C# DiagnosticBag.Verify怎么用?C# DiagnosticBag.Verify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiagnosticBag
的用法示例。
在下文中一共展示了DiagnosticBag.Verify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DocCommentWriteException
public void DocCommentWriteException()
{
var comp = CreateCompilationWithMscorlib(@"
/// <summary>
/// Doc comment for <see href=""C"" />
/// </summary>
public class C
{
/// <summary>
/// Doc comment for method M
/// </summary>
public void M() { }
}");
var diags = new DiagnosticBag();
var badStream = new BrokenStream();
badStream.BreakHow = BrokenStream.BreakHowType.ThrowOnWrite;
DocumentationCommentCompiler.WriteDocumentationCommentXml(
comp,
null,
badStream,
diags,
default(CancellationToken));
diags.Verify(
// error CS1569: Error writing to XML documentation file: I/O error occurred.
Diagnostic(ErrorCode.ERR_DocFileGen).WithArguments("I/O error occurred.").WithLocation(1, 1));
}
示例2: AssemblyRefs_DuplicateRows
public void AssemblyRefs_DuplicateRows()
{
var compilation = CreateCompilationWithMscorlib(
"class C : C1 { }; class D { }",
new[] { TestReferences.SymbolsTests.Methods.CSMethods });
PEAssemblyBuilder assembly = new PEAssemblyBuilder(
(SourceAssemblySymbol)compilation.Assembly,
EmitOptions.Default,
compilation.Options.OutputKind,
GetDefaultModulePropertiesForSerialization(),
Enumerable.Empty<ResourceDescription>(),
// map all references to a single name:
assembylSymbol => new AssemblyIdentity("foo")
);
// Don't attempt to emit if there were any syntax, declaration, semantic, or emitted errors previously.
DiagnosticBag diagnostics = new DiagnosticBag();
MethodCompiler.CompileMethodBodies(
compilation: compilation,
moduleBeingBuiltOpt: assembly,
generateDebugInfo: false,
hasDeclarationErrors: false,
diagnostics: diagnostics,
filterOpt: null,
cancellationToken: default(CancellationToken));
diagnostics.Verify();
var context = new EmitContext(assembly, null, new DiagnosticBag());
ImmutableArray<byte> image;
using (var stream = new MemoryStream())
{
Cci.PeWriter.WritePeToStream(
context,
compilation.MessageProvider,
stream,
nativePdbWriterOpt: null,
allowMissingMethodBodies: false,
deterministic: false,
cancellationToken: CancellationToken.None);
image = stream.ToImmutable();
}
context.Diagnostics.Verify();
// check that there are no duplicate rows in AssemblyRef table:
PEAssembly emittedAssembly = AssemblyMetadata.CreateFromImage(image).GetAssembly();
var emittedReferences = emittedAssembly.Modules[0].ReferencedAssemblies;
Assert.Equal(1, emittedReferences.Length);
Assert.Equal("foo", emittedReferences[0].Name);
}