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


C# DiagnosticBag.AsEnumerable方法代码示例

本文整理汇总了C#中DiagnosticBag.AsEnumerable方法的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticBag.AsEnumerable方法的具体用法?C# DiagnosticBag.AsEnumerable怎么用?C# DiagnosticBag.AsEnumerable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DiagnosticBag的用法示例。


在下文中一共展示了DiagnosticBag.AsEnumerable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetErrorMessageAndMissingAssemblyIdentities

        internal string GetErrorMessageAndMissingAssemblyIdentities(DiagnosticBag diagnostics, DiagnosticFormatter formatter, CultureInfo preferredUICulture, AssemblyIdentity linqLibrary, out bool useReferencedModulesOnly, out ImmutableArray<AssemblyIdentity> missingAssemblyIdentities)
        {
            var errors = diagnostics.AsEnumerable().Where(d => d.Severity == DiagnosticSeverity.Error);
            foreach (var error in errors)
            {
                missingAssemblyIdentities = this.GetMissingAssemblyIdentities(error, linqLibrary);
                if (!missingAssemblyIdentities.IsDefault)
                {
                    break;
                }
            }

            if (missingAssemblyIdentities.IsDefault)
            {
                missingAssemblyIdentities = ImmutableArray<AssemblyIdentity>.Empty;
            }

            useReferencedModulesOnly = errors.All(HasDuplicateTypesOrAssemblies);

            var firstError = errors.FirstOrDefault();
            Debug.Assert(firstError != null);

            var simpleMessage = firstError as SimpleMessageDiagnostic;
            return (simpleMessage != null) ?
                simpleMessage.GetMessage() :
                formatter.Format(firstError, preferredUICulture ?? CultureInfo.CurrentUICulture);
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:27,代码来源:EvaluationContextBase.cs

示例2: TestErrors

 public void TestErrors(string code, params string[] errors)
 {
     var compilation = CreateCompilationWithMscorlib(code);
     var method = (SourceMethodSymbol)compilation.GlobalNamespace.GetTypeMembers("C").Single().GetMembers("M").Single();
     var factory = compilation.GetBinderFactory(method.SyntaxTree);
     var bodyBlock = (BlockSyntax)method.BodySyntax;
     var parameterBinderContext = factory.GetBinder(bodyBlock);
     var binder = new ExecutableCodeBinder(bodyBlock.Parent, method, parameterBinderContext);
     var diagnostics = new DiagnosticBag();
     var block = binder.BindEmbeddedBlock(bodyBlock, diagnostics);
     AssertEx.SetEqual(errors, diagnostics.AsEnumerable().Select(DumpDiagnostic));
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:12,代码来源:CompilingTestBase.cs

示例3: GetErrorAndMissingAssemblyIdentities

        internal Diagnostic GetErrorAndMissingAssemblyIdentities(DiagnosticBag diagnostics, out ImmutableArray<AssemblyIdentity> missingAssemblyIdentities)
        {
            var diagnosticsEnumerable = diagnostics.AsEnumerable();
            foreach (Diagnostic diagnostic in diagnosticsEnumerable)
            {
                missingAssemblyIdentities = GetMissingAssemblyIdentities(diagnostic);
                if (!missingAssemblyIdentities.IsDefault)
                {
                    break;
                }
            }

            if (missingAssemblyIdentities.IsDefault)
            {
                missingAssemblyIdentities = ImmutableArray<AssemblyIdentity>.Empty;
            }

            return diagnosticsEnumerable.FirstOrDefault(d => d.Severity == DiagnosticSeverity.Error);
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:19,代码来源:EvaluationContextBase.cs

示例4: RecordBindingDiagnostics

 /// <remarks>
 /// Respects the DocumentationMode at the source location.
 /// </remarks>
 private void RecordBindingDiagnostics(DiagnosticBag bindingDiagnostics, Location sourceLocation)
 {
     if (!bindingDiagnostics.IsEmptyWithoutResolution && ((SyntaxTree)sourceLocation.SourceTree).ReportDocumentationCommentDiagnostics())
     {
         foreach (Diagnostic diagnostic in bindingDiagnostics.AsEnumerable())
         {
             // CONSIDER: Dev11 actually uses the originating location plus the offset into the cref/name,
             // but that just seems silly.
             diagnostics.Add(diagnostic.WithLocation(sourceLocation));
         }
     }
 }
开发者ID:riversky,项目名称:roslyn,代码行数:15,代码来源:DocumentationCommentCompiler.IncludeElementExpander.cs

示例5: HasNonObsoleteError

 private static bool HasNonObsoleteError(DiagnosticBag unusedDiagnostics)
 {
     foreach (Diagnostic diag in unusedDiagnostics.AsEnumerable())
     {
         // CONSIDER: If this check is too slow, we could add a helper to DiagnosticBag
         // that checks for unrealized diagnostics without expanding them.
         switch ((ErrorCode)diag.Code)
         {
             case ErrorCode.ERR_DeprecatedSymbolStr:
             case ErrorCode.ERR_DeprecatedCollectionInitAddStr:
                 break;
             default:
                 if (diag.Severity == DiagnosticSeverity.Error)
                 {
                     return true;
                 }
                 break;
         }
     }
     return false;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:21,代码来源:Binder_Crefs.cs

示例6: TestWarnings

 public void TestWarnings(string code, params string[] expectedWarnings)
 {
     var compilation = CreateCompilationWithMscorlib(code);
     var method = (SourceMethodSymbol)compilation.GlobalNamespace.GetTypeMembers("C").Single().GetMembers("M").Single();
     var factory = compilation.GetBinderFactory(method.SyntaxTree);
     var bodyBlock = (BlockSyntax)method.BodySyntax;
     var parameterBinderContext = factory.GetBinder(bodyBlock);
     var binder = new ExecutableCodeBinder(bodyBlock.Parent, method, parameterBinderContext);
     var block = (BoundBlock)binder.BindStatement(bodyBlock, new DiagnosticBag());
     var actualWarnings = new DiagnosticBag();
     DiagnosticsPass.IssueDiagnostics(compilation, block, actualWarnings, method);
     AssertEx.SetEqual(expectedWarnings, actualWarnings.AsEnumerable().Select(DumpDiagnostic));
 }
开发者ID:noahfalk,项目名称:roslyn,代码行数:13,代码来源:CompilingTestBase.cs

示例7: PreventsSuccessfulDelegateConversion

        /// <remarks>
        /// WARNING: will resolve lazy diagnostics - do not call this before the member lists are completed
        /// or you could trigger infinite recursion.
        /// </remarks>
        internal static bool PreventsSuccessfulDelegateConversion(DiagnosticBag diagnostics)
        {
            foreach (Diagnostic diag in diagnostics.AsEnumerable()) // Checking the code would have resolved them anyway.
            {
                if (ErrorFacts.PreventsSuccessfulDelegateConversion((ErrorCode)diag.Code))
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:16,代码来源:ErrorFacts.cs

示例8: CompilationError

 private void CompilationError(DiagnosticBag diagnostics)
 {
     var resolvedLocalDiagnostics = diagnostics.AsEnumerable();
     var firstError = resolvedLocalDiagnostics.FirstOrDefault(d => d.Severity == DiagnosticSeverity.Error);
     if (firstError != null)
     {
         throw new CompilationErrorException(FormatDiagnostic(firstError, CultureInfo.CurrentCulture),
             (resolvedLocalDiagnostics.AsImmutable()));
     }
 }
开发者ID:daking2014,项目名称:roslyn,代码行数:10,代码来源:Script.cs


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