当前位置: 首页>>代码示例>>C#>>正文


C# DiagnosticBag.Verify方法代码示例

本文整理汇总了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));
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:28,代码来源:XmlDocCommentTests.cs

示例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);
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:52,代码来源:EmitMetadata.cs


注:本文中的DiagnosticBag.Verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。