• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Utilities.DiagnosticDescription类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.CodeAnalysis.Test.Utilities.DiagnosticDescription的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticDescription类的具体用法?C# DiagnosticDescription怎么用?C# DiagnosticDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DiagnosticDescription类属于Microsoft.CodeAnalysis.Test.Utilities命名空间,在下文中一共展示了DiagnosticDescription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EmitToArray

        internal static ImmutableArray<byte> EmitToArray(
            this Compilation compilation,
            EmitOptions options = null,
            CompilationTestData testData = null,
            DiagnosticDescription[] expectedWarnings = null)
        {
            var stream = new MemoryStream();
            MemoryStream pdbStream = 
                (compilation.Options.OptimizationLevel == OptimizationLevel.Debug) && !CLRHelpers.IsRunningOnMono() 
                ? new MemoryStream() 
                : null;

            var emitResult = compilation.Emit(
                peStream: stream,
                pdbStream: pdbStream,
                xmlDocumentationStream: null,
                win32Resources: null,
                manifestResources: null,
                options: options,
                testData: testData,
                getHostDiagnostics: null,
                cancellationToken: default(CancellationToken));

            Assert.True(emitResult.Success, "Diagnostics:\r\n" + string.Join("\r\n", emitResult.Diagnostics.Select(d => d.ToString())));

            if (expectedWarnings != null)
            {
                emitResult.Diagnostics.Verify(expectedWarnings);
            }

            return stream.ToImmutable();
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:32,代码来源:CompilationExtensions.cs


示例2: VerifyAsync

 protected override Task VerifyAsync(string source, string language, DiagnosticAnalyzer[] analyzers, DiagnosticDescription[] diagnostics, Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException = null, bool logAnalyzerExceptionAsDiagnostics = false, string rootNamespace = null)
 {
     Assert.True(analyzers != null && analyzers.Length > 0, "Must specify at least one diagnostic analyzer to test suppression");
     var compilation = CreateCompilation(source, language, analyzers, rootNamespace);
     compilation.VerifyAnalyzerDiagnostics(analyzers, onAnalyzerException: onAnalyzerException, logAnalyzerExceptionAsDiagnostics: logAnalyzerExceptionAsDiagnostics, expected: diagnostics);
     return Task.FromResult(false);
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:SuppressMessageAttributeCompilerTests.cs


示例3: EmitToArray

        internal static ImmutableArray<byte> EmitToArray(
            this Compilation compilation, 
            bool metadataOnly = false,
            CompilationTestData testData = null, 
            DiagnosticDescription[] expectedWarnings = null)
        {
            var stream = new MemoryStream();

            var emitResult = compilation.Emit(
                peStream: stream,
                outputName: null,
                pdbFilePath: null,
                pdbStream: null,
                xmlDocumentationStream: null,
                cancellationToken: default(CancellationToken),
                win32Resources: null,
                manifestResources: null,
                metadataOnly: metadataOnly,
                testData: testData);

            Assert.True(emitResult.Success, "Diagnostics:\r\n" + string.Join("\r\n, ", emitResult.Diagnostics.Select(d => d.ToString())));

            if (expectedWarnings != null)
            {
                emitResult.Diagnostics.Verify(expectedWarnings);
            }

            return stream.ToImmutable();
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:29,代码来源:CompilationExtensions.cs


示例4: EmitToStream

        public static MemoryStream EmitToStream(this Compilation compilation, EmitOptions options = null, DiagnosticDescription[] expectedWarnings = null)
        {
            var stream = new MemoryStream();
            var emitResult = compilation.Emit(stream, options: options);
            Assert.True(emitResult.Success, "Diagnostics: " + string.Join(", ", emitResult.Diagnostics.Select(d => d.ToString())));

            if (expectedWarnings != null)
            {
                emitResult.Diagnostics.Verify(expectedWarnings);
            }

            stream.Position = 0;
            return stream;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:14,代码来源:CompilationExtensions.cs


示例5: EmitToStream

        public static Stream EmitToStream(this Compilation compilation, bool metadataOnly = false, DiagnosticDescription[] expectedWarnings = null)
        {
            var stream = new MemoryStream();
            var emitResult = metadataOnly ? compilation.EmitMetadataOnly(stream) : compilation.Emit(stream);
            Assert.True(emitResult.Success, "Diagnostics: " + string.Join(", ", emitResult.Diagnostics.Select(d => d.ToString())));

            if (expectedWarnings != null)
            {
                emitResult.Diagnostics.Verify(expectedWarnings);
            }

            stream.Position = 0;
            return stream;
        }
开发者ID:riversky,项目名称:roslyn,代码行数:14,代码来源:CompilationExtensions.cs


示例6: EmitToImageReference

 public static MetadataReference EmitToImageReference(
     this Compilation comp,
     EmitOptions options = null,
     bool embedInteropTypes = false,
     ImmutableArray<string> aliases = default(ImmutableArray<string>),
     DiagnosticDescription[] expectedWarnings = null)
 {
     var image = comp.EmitToArray(options, expectedWarnings: expectedWarnings);
     if (comp.Options.OutputKind == OutputKind.NetModule)
     {
         return ModuleMetadata.CreateFromImage(image).GetReference(display: comp.MakeSourceModuleName());
     }
     else
     {
         return AssemblyMetadata.CreateFromImage(image).GetReference(aliases: aliases, embedInteropTypes: embedInteropTypes, display: comp.MakeSourceAssemblySimpleName());
     }
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:17,代码来源:CompilationExtensions.cs


示例7: Verify

        protected override void Verify(string source, string language, DiagnosticAnalyzer[] analyzers, DiagnosticDescription[] expectedDiagnostics, Func<Exception, DiagnosticAnalyzer, bool> continueOnAnalyzerException = null, string rootNamespace = null)
        {
            using (var workspace = CreateWorkspaceFromFile(source, language, rootNamespace))
            {
                var documentId = workspace.Documents[0].Id;
                var document = workspace.CurrentSolution.GetDocument(documentId);
                var span = document.GetSyntaxRootAsync().Result.FullSpan;

                var actualDiagnostics = new List<Diagnostic>();
                foreach (var analyzer in analyzers)
                {
                    actualDiagnostics.AddRange(DiagnosticProviderTestUtilities.GetAllDiagnostics(analyzer, document, span, donotCatchAnalyzerExceptions: continueOnAnalyzerException == null));
                }

                actualDiagnostics.Verify(expectedDiagnostics);
            }
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:17,代码来源:SuppressMessageAttributeTests.cs


示例8: VerifyAsync

        protected override async Task VerifyAsync(string source, string language, DiagnosticAnalyzer[] analyzers, DiagnosticDescription[] expectedDiagnostics, Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException = null, bool logAnalyzerExceptionAsDiagnostics = true, string rootNamespace = null)
        {
            using (var workspace = await CreateWorkspaceFromFileAsync(source, language, rootNamespace))
            {
                var documentId = workspace.Documents[0].Id;
                var document = workspace.CurrentSolution.GetDocument(documentId);
                var span = (await document.GetSyntaxRootAsync()).FullSpan;

                var actualDiagnostics = new List<Diagnostic>();
                foreach (var analyzer in analyzers)
                {
                    actualDiagnostics.AddRange(
                        await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, document, span, onAnalyzerException, logAnalyzerExceptionAsDiagnostics));
                }

                actualDiagnostics.Verify(expectedDiagnostics);
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:18,代码来源:SuppressMessageAttributeTests.cs


示例9: EmitToArray

        internal static ImmutableArray<byte> EmitToArray(
            this Compilation compilation,
            EmitOptions options = null,
            CompilationTestData testData = null,
            DiagnosticDescription[] expectedWarnings = null,
            Stream pdbStream = null,
            IMethodSymbol debugEntryPoint = null,
            Stream sourceLinkStream = null,
            IEnumerable<EmbeddedText> embeddedTexts = null)
        {
            var peStream = new MemoryStream();

            if (pdbStream == null && compilation.Options.OptimizationLevel == OptimizationLevel.Debug && options?.DebugInformationFormat != DebugInformationFormat.Embedded)
            {
                if (MonoHelpers.IsRunningOnMono())
                {
                    options = (options ?? EmitOptions.Default).WithDebugInformationFormat(DebugInformationFormat.PortablePdb);
                }

                pdbStream = new MemoryStream();
            }

            var emitResult = compilation.Emit(
                peStream: peStream,
                pdbStream: pdbStream,
                xmlDocumentationStream: null,
                win32Resources: null,
                manifestResources: null,
                options: options,
                debugEntryPoint: debugEntryPoint,
                sourceLinkStream: sourceLinkStream,
                embeddedTexts: embeddedTexts,
                testData: testData,
                cancellationToken: default(CancellationToken));

            Assert.True(emitResult.Success, "Diagnostics:\r\n" + string.Join("\r\n", emitResult.Diagnostics.Select(d => d.ToString())));

            if (expectedWarnings != null)
            {
                emitResult.Diagnostics.Verify(expectedWarnings);
            }

            return peStream.ToImmutable();
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:44,代码来源:CompilationExtensions.cs


示例10: EmitToArray

        internal static ImmutableArray<byte> EmitToArray(
            this Compilation compilation, 
            bool metadataOnly = false,
            bool debug = false,
            CompilationTestData testData = null, 
            Guid mvid = default(Guid),
            DiagnosticDescription[] expectedWarnings = null)
        {
            var stream = new MemoryStream();

            if (mvid == default(Guid))
            {
                mvid = Guid.NewGuid();
            }

            var emitResult = compilation.Emit(
                executableStream: stream,
                outputName: null,
                pdbFilePath: debug ? "Compilation.pdb" : null,
                pdbStream: debug ? new MemoryStream() : null,
                xmlDocStream: null,
                cancellationToken: default(CancellationToken),
                win32Resources: null,
                manifestResources: null,
                moduleVersionId: mvid,
                metadataOnly: metadataOnly,
                testData: testData);

            Assert.True(emitResult.Success, "Diagnostics: " + string.Join(", ", emitResult.Diagnostics.Select(d => d.ToString())));

            if (expectedWarnings != null)
            {
                emitResult.Diagnostics.Verify(expectedWarnings);
            }

            return stream.ToImmutable();
        }
开发者ID:riversky,项目名称:roslyn,代码行数:37,代码来源:CompilationExtensions.cs


示例11: VerifyTokenDiagnostics

        // Generate a diagnostic on every token in the specified spans, and verify that only the specified diagnostics are not suppressed
        private void VerifyTokenDiagnostics(string markup, string language, DiagnosticDescription[] diagnostics)
        {
            string source;
            IList<TextSpan> spans;
            MarkupTestFile.GetSpans(markup, out source, out spans);
            Assert.True(spans.Count > 0, "Must specify a span within which to generate diagnostics on each token");

            Verify(source, language, new IDiagnosticAnalyzer[] { new WarningOnTokenAnalyzer(spans) }, diagnostics);
        }
开发者ID:riversky,项目名称:roslyn,代码行数:10,代码来源:SuppressMessageAttributeTests.cs


示例12: Verify

 protected virtual void Verify(string source, string language, IDiagnosticAnalyzer[] analyzers, DiagnosticDescription[] diagnostics, string rootNamespace = null)
 {
     Assert.True(analyzers != null && analyzers.Length > 0, "Must specify at least one diagnostic analyzer to test suppression");
     var compilation = CreateCompilation(source, language, analyzers, rootNamespace);
     compilation.VerifyAnalyzerDiagnostics(analyzers, diagnostics);
 }
开发者ID:riversky,项目名称:roslyn,代码行数:6,代码来源:SuppressMessageAttributeTests.cs


示例13: CS0472WRN_NubExprIsConstBool


//.........这里部分代码省略.........
        W(new Guid?() != g);              // CS0472
        W(new Guid?() == h);              // no error
        W(new Guid?() != h);              // no error

        System.Console.WriteLine();

        W(null == null);                  // No error, because both sides are nullable, but of course
        W(null != null);                  // we could give a warning here as well.

        System.Console.WriteLine();

        //check comparisons with converted constants
        W((E?)1 == null);
        W(null != (E?)1);

        W((int?)1 == null);
        W(null != (int?)1);

        //check comparisons when null is converted 

        W(0 == (int?)null);
        W((int?)null != 0);
 
        W(0 == (E?)null);
        W((E?)null != 0);
    }
}
";

            string expected = @"ftftftftftftftftftftftft
ftftftftftftftftftftftft
tf
ftftftft";
            var fullExpected = new DiagnosticDescription[] {
                // (19,11): warning CS0472: The result of the expression is always 'false' since a value of type 'int' is never equal to 'null' of type 'int?'
                //         W(i == null);            // CS0472
                Diagnostic(ErrorCode.WRN_NubExprIsConstBool, "i == null").WithArguments("false", "int", "int?").WithLocation(19, 11),
                // (20,11): warning CS0472: The result of the expression is always 'true' since a value of type 'int' is never equal to 'null' of type 'int?'
                //         W(i != null);            // CS0472
                Diagnostic(ErrorCode.WRN_NubExprIsConstBool, "i != null").WithArguments("true", "int", "int?").WithLocation(20, 11),
                // (23,11): warning CS8073: The result of the expression is always 'false' since a value of type 'System.Guid' is never equal to 'null' of type 'System.Guid?'
                //         W(g == null);            // CS0472
                Diagnostic(ErrorCode.WRN_NubExprIsConstBool2, "g == null").WithArguments("false", "System.Guid", "System.Guid?").WithLocation(23, 11),
                // (24,11): warning CS8073: The result of the expression is always 'true' since a value of type 'System.Guid' is never equal to 'null' of type 'System.Guid?'
                //         W(g != null);            // CS0472
                Diagnostic(ErrorCode.WRN_NubExprIsConstBool2, "g != null").WithArguments("true", "System.Guid", "System.Guid?").WithLocation(24, 11),
                // (28,11): warning CS0472: The result of the expression is always 'false' since a value of type 'int' is never equal to 'null' of type 'short?'
                //         W(i == default(short?));            // CS0472
                Diagnostic(ErrorCode.WRN_NubExprIsConstBool, "i == default(short?)").WithArguments("false", "int", "short?").WithLocation(28, 11),
                // (29,11): warning CS0472: The result of the expression is always 'true' since a value of type 'int' is never equal to 'null' of type 'short?'
                //         W(i != default(short?));            // CS0472
                Diagnostic(ErrorCode.WRN_NubExprIsConstBool, "i != default(short?)").WithArguments("true", "int", "short?").WithLocation(29, 11),
                // (32,11): warning CS8073: The result of the expression is always 'false' since a value of type 'System.Guid' is never equal to 'null' of type 'System.Guid?'
                //         W(g == default(Guid?));             // CS0472
                Diagnostic(ErrorCode.WRN_NubExprIsConstBool2, "g == default(Guid?)").WithArguments("false", "System.Guid", "System.Guid?").WithLocation(32, 11),
                // (33,11): warning CS8073: The result of the expression is always 'true' since a value of type 'System.Guid' is never equal to 'null' of type 'System.Guid?'
                //         W(g != default(Guid?));             // CS0472
                Diagnostic(ErrorCode.WRN_NubExprIsConstBool2, "g != default(Guid?)").WithArguments("true", "System.Guid", "System.Guid?").WithLocation(33, 11),
                // (37,11): warning CS0472: The result of the expression is always 'false' since a value of type 'int' is never equal to 'null' of type 'sbyte?'
                //         W(i == new sbyte?());            // CS0472
                Diagnostic(ErrorCode.WRN_NubExprIsConstBool, "i == new sbyte?()").WithArguments("false", "int", "sbyte?").WithLocation(37, 11),
                // (38,11): warning CS0472: The result of the expression is always 'true' since a value of type 'int' is never equal to 'null' of type 'sbyte?'
                //         W(i != new sbyte?());            // CS0472
                Diagnostic(ErrorCode.WRN_NubExprIsConstBool, "i != new sbyte?()").WithArguments("true", "int", "sbyte?").WithLocation(38, 11),
                // (41,11): warning CS8073: The result of the expression is always 'false' since a value of type 'System.Guid' is never equal to 'null' of type 'System.Guid?'
                //         W(g == new Guid?());             // CS0472
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:67,代码来源:SemanticErrorTests.cs


示例14: VerifyGeneratedCodeAnalyzerDiagnostics

 private static void VerifyGeneratedCodeAnalyzerDiagnostics(Compilation compilation, DiagnosticDescription[] expected, GeneratedCodeAnalysisFlags? generatedCodeAnalysisFlagsOpt)
 {
     var analyzers = new DiagnosticAnalyzer[] { new GeneratedCodeAnalyzer(generatedCodeAnalysisFlagsOpt) };
     compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, logAnalyzerExceptionAsDiagnostics: false, expected: expected);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:5,代码来源:DiagnosticAnalyzerTests.cs


示例15: TestConcurrentAnalyzer

        public void TestConcurrentAnalyzer()
        {
            if (Environment.ProcessorCount <= 1)
            {
                // Don't test for non-concurrent environment.
                return;
            }

            var builder = new StringBuilder();
            var typeCount = 100;
            var typeNames = new string[typeCount];
            for (int i = 1; i <= typeCount; i++)
            {
                var typeName = $"C{i}";
                typeNames[i - 1] = typeName;
                builder.Append($"\r\nclass {typeName} {{ }}");
            }

            var source = builder.ToString();
            var compilation = GetCompilationWithConcurrentBuildEnabled(source);
            compilation.VerifyDiagnostics();

            // Verify analyzer diagnostics for Concurrent analyzer only.
            var analyzers = new DiagnosticAnalyzer[] { new ConcurrentAnalyzer(typeNames) };
            var expected = new DiagnosticDescription[typeCount];
            for (int i = 0; i < typeCount; i++)
            {
                var typeName = $"C{i + 1}";
                expected[i] = Diagnostic(ConcurrentAnalyzer.Descriptor.Id, typeName)
                    .WithArguments(typeName)
                    .WithLocation(i + 2, 7);
            }

            compilation.VerifyAnalyzerDiagnostics(analyzers, expected: expected);

            // Verify analyzer diagnostics for Concurrent and NonConcurrent analyzer together (latter reports diagnostics only for error cases).
            analyzers = new DiagnosticAnalyzer[] { new ConcurrentAnalyzer(typeNames), new NonConcurrentAnalyzer() };
            compilation.VerifyAnalyzerDiagnostics(analyzers, expected: expected);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:39,代码来源:DiagnosticAnalyzerTests.cs


示例16: VerifyEmitDiagnostics

        // In VB use AssertTheseErrors format for expected diagnostics!
        private static void VerifyEmitDiagnostics(
            CSharpCompilation compilation,
            bool metadataOnlyShouldSucceed,
            DiagnosticDescription[] expectedFullBuildDiagnostics,
            DiagnosticDescription[] expectedMetadataOnlyDiagnostics = null)
        {
            using (var executableStream = new MemoryStream())
            {
                var result = compilation.Emit(executableStream);
                Assert.False(result.Success);
                result.Diagnostics.Verify(expectedFullBuildDiagnostics);
            }

            using (var executableStream = new MemoryStream())
            {
                var result = compilation.Emit(executableStream, options: new EmitOptions(metadataOnly: true));

                if (metadataOnlyShouldSucceed)
                {
                    Assert.True(result.Success);
                    result.Diagnostics.Verify();
                }
                else
                {
                    Assert.False(result.Success);
                    result.Diagnostics.Verify(expectedMetadataOnlyDiagnostics ?? expectedFullBuildDiagnostics);
                }
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:NoPiaEmbedTypes.cs


示例17: CannotEmbedValueTupleImplicitlyReferred

        public void CannotEmbedValueTupleImplicitlyReferred()
        {
            string piaSource = @"
using System;
using System.Runtime.InteropServices;

[assembly: Guid(""f9c2d51d-4f44-45f0-9eda-c9d599b58257"")]
[assembly: ImportedFromTypeLib(""Pia1.dll"")]

public struct S<T> { }

namespace System
{
    public struct ValueTuple<T1, T2>
    {
        public ValueTuple(T1 item1, T2 item2) { }
    }
}

[ComImport()]
[Guid(""f9c2d51d-4f44-45f0-9eda-c9d599b58280"")]
public interface ITest1
{
    (int, int) M();
    S<int> M2();
}";

            var pia = CreateCompilationWithMscorlib(piaSource, options: TestOptions.ReleaseDll, assemblyName: "pia");
            pia.VerifyEmitDiagnostics();

            string source = @"
public interface ITest2 : ITest1 { }
";

            // We should expect errors as generic types cannot be embedded
            // Issue https://github.com/dotnet/roslyn/issues/13200 tracks this
            var expectedDiagnostics = new DiagnosticDescription[]
            {
            };

            var comp1 = CreateCompilationWithMscorlib(source, options: TestOptions.ReleaseDll,
                            references: new MetadataReference[] { pia.ToMetadataReference(embedInteropTypes: true) });
            comp1.VerifyEmitDiagnostics(expectedDiagnostics);

            var comp2 = CreateCompilationWithMscorlib(source, options: TestOptions.ReleaseDll,
                            references: new MetadataReference[] { pia.EmitToImageReference(embedInteropTypes: true) });
            comp2.VerifyEmitDiagnostics(expectedDiagnostics);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:48,代码来源:NoPia.cs


示例18: AppendDiagnosticDescription

 private static void AppendDiagnosticDescription(StringBuilder sb, DiagnosticDescription d)
 {
     Indent(sb, 1);
     sb.Append(d.ToString());
 }
开发者ID:Anniepoh,项目名称:roslyn-analyzers,代码行数:5,代码来源:DiagnosticDescription.cs


示例19: CannotEmbedValueTupleImplicitlyReferred_ByField

        public void CannotEmbedValueTupleImplicitlyReferred_ByField()
        {
            string piaSource = @"
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

[assembly: Guid(""f9c2d51d-4f44-45f0-9eda-c9d599b58257"")]
[assembly: ImportedFromTypeLib(""Pia1.dll"")]

public struct S<T> { }

namespace System
{
    public struct ValueTuple<T1, T2>
    {
        public ValueTuple(T1 item1, T2 item2) { }
    }
}

public struct Test1
{
    public IEnumerable<IEnumerable<(int, int)>> F;
    public IEnumerable<IEnumerable<S<int>>> F2;
}";

            var pia = CreateCompilationWithMscorlib(piaSource, options: TestOptions.ReleaseDll, assemblyName: "pia");
            pia.VerifyEmitDiagnostics();

            string source = @"
public interface ITest2
{
    void M(Test1 x); 
}
";

            var expectedDiagnostics = new DiagnosticDescription[]
            {
                // error CS1768: Type 'ValueTuple<T1, T2>' cannot be embedded because it has a generic argument. Consider setting the 'Embed Interop Types' property to false.
                Diagnostic(ErrorCode.ERR_GenericsUsedInNoPIAType).WithArguments("System.ValueTuple<T1, T2>").WithLocation(1, 1),
                // error CS1768: Type 'S<T>' cannot be embedded because it has a generic argument. Consider setting the 'Embed Interop Types' property to false.
                Diagnostic(ErrorCode.ERR_GenericsUsedInNoPIAType).WithArguments("S<T>").WithLocation(1, 1)
            };

            var comp1 = CreateCompilationWithMscorlib(source, options: TestOptions.ReleaseDll,
                            references: new MetadataReference[] { pia.ToMetadataReference(embedInteropTypes: true) });
            comp1.VerifyEmitDiagnostics(expectedDiagnostics);

            var comp2 = CreateCompilationWithMscorlib(source, options: TestOptions.ReleaseDll,
                            references: new MetadataReference[] { pia.EmitToImageReference(embedInteropTypes: true) });
            comp2.VerifyEmitDiagnostics(expectedDiagnostics);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:52,代码来源:NoPia.cs


示例20: ParseAndValidateFirst

 public static void ParseAndValidateFirst(string text, DiagnosticDescription expectedFirstError)
 {
     var parsedTree = ParseWithRoundTripCheck(text);
     var actualErrors = parsedTree.GetDiagnostics();
     actualErrors.Take(1).Verify(expectedFirstError);
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:6,代码来源:ParserErrorMessageTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Text.SourceText类代码示例发布时间:2022-05-26
下一篇:
C# SolutionCrawler.InvocationReasons类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap