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


C# ImmutableArray.Where方法代码示例

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


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

示例1: AddDocumentFixesAsync

            public override async Task AddDocumentFixesAsync(Document document, ImmutableArray<Diagnostic> diagnostics, Action<CodeAction> addFix, FixAllContext fixAllContext)
            {
                var pragmaActionsBuilder = ImmutableArray.CreateBuilder<IPragmaBasedCodeAction>();
                var pragmaDiagnosticsBuilder = ImmutableArray.CreateBuilder<Diagnostic>();

                foreach (var diagnostic in diagnostics.Where(d => d.Location.IsInSource && !d.IsSuppressed))
                {
                    var span = diagnostic.Location.SourceSpan;
                    var pragmaSuppressions = await _suppressionFixProvider.GetPragmaSuppressionsAsync(document, span, SpecializedCollections.SingletonEnumerable(diagnostic), fixAllContext.CancellationToken).ConfigureAwait(false);
                    var pragmaSuppression = pragmaSuppressions.SingleOrDefault();
                    if (pragmaSuppression != null)
                    {
                        if (fixAllContext is FixMultipleContext)
                        {
                            pragmaSuppression = pragmaSuppression.CloneForFixMultipleContext();
                        }

                        pragmaActionsBuilder.Add(pragmaSuppression);
                        pragmaDiagnosticsBuilder.Add(diagnostic);
                    }
                }

                // Get the pragma batch fix.
                if (pragmaActionsBuilder.Count > 0)
                {
                    var pragmaBatchFix = PragmaBatchFixHelpers.CreateBatchPragmaFix(_suppressionFixProvider, document,
                        pragmaActionsBuilder.ToImmutable(), pragmaDiagnosticsBuilder.ToImmutable(), fixAllContext);

                    addFix(pragmaBatchFix);
                }
            }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:31,代码来源:AbstractSuppressionCodeFixProvider.PragmaWarningBatchFixAllProvider.cs

示例2: SequnceStartsWith

            private bool SequnceStartsWith(ImmutableArray<string> header, List<string> existingHeader)
            {
                // Only try if the existing header is at least as long as the new copyright header
                if (existingHeader.Count >= header.Count())
                {
                    return !header.Where((headerLine, i) => existingHeader[i] != headerLine).Any();
                }

                return false;
            }
开发者ID:chuck-mitchell,项目名称:codeformatter,代码行数:10,代码来源:CopyrightHeaderRule.cs

示例3: AddDocumentFixesAsync

 public override async Task AddDocumentFixesAsync(Document document, ImmutableArray<Diagnostic> diagnostics, Action<CodeAction> addFix, FixAllContext fixAllContext)
 {
     foreach (var diagnosticsForSpan in diagnostics.Where(d => d.Location.IsInSource).GroupBy(d => d.Location.SourceSpan))
     {
         var span = diagnosticsForSpan.First().Location.SourceSpan;
         var pragmaSuppressions = await _suppressionFixProvider.GetPragmaSuppressionsAsync(document, span, diagnosticsForSpan, fixAllContext.CancellationToken).ConfigureAwait(false);
         foreach (var pragmaSuppression in pragmaSuppressions)
         {
             addFix(pragmaSuppression);
         }
     }
 }
开发者ID:noahfalk,项目名称:roslyn,代码行数:12,代码来源:AbstractSuppressionCodeFixProvider.PragmaWarningBatchFixAllProvider.cs

示例4: AddDocumentFixesAsync

                public override async Task AddDocumentFixesAsync(
                    Document document, ImmutableArray<Diagnostic> diagnostics, Action<CodeAction> addFix,
                    FixAllState fixAllState, CancellationToken cancellationToken)
                {
                    // Batch all the pragma remove suppression fixes by executing them sequentially for the document.
                    var pragmaActionsBuilder = ArrayBuilder<IPragmaBasedCodeAction>.GetInstance();
                    var pragmaDiagnosticsBuilder = ArrayBuilder<Diagnostic>.GetInstance();

                    foreach (var diagnostic in diagnostics.Where(d => d.Location.IsInSource && d.IsSuppressed))
                    {
                        var span = diagnostic.Location.SourceSpan;
                        var removeSuppressionFixes = await _suppressionFixProvider.GetSuppressionsAsync(
                            document, span, SpecializedCollections.SingletonEnumerable(diagnostic), cancellationToken).ConfigureAwait(false);
                        var removeSuppressionFix = removeSuppressionFixes.SingleOrDefault();
                        if (removeSuppressionFix != null)
                        {
                            var codeAction = removeSuppressionFix.Action as RemoveSuppressionCodeAction;
                            if (codeAction != null)
                            {
                                if (fixAllState.IsFixMultiple)
                                {
                                    codeAction = codeAction.CloneForFixMultipleContext();
                                }

                                var pragmaRemoveAction = codeAction as PragmaRemoveAction;
                                if (pragmaRemoveAction != null)
                                {
                                    pragmaActionsBuilder.Add(pragmaRemoveAction);
                                    pragmaDiagnosticsBuilder.Add(diagnostic);
                                }
                                else
                                {
                                    addFix(codeAction);
                                }
                            }
                        }
                    }

                    // Get the pragma batch fix.
                    if (pragmaActionsBuilder.Count > 0)
                    {
                        var pragmaBatchFix = PragmaBatchFixHelpers.CreateBatchPragmaFix(
                            _suppressionFixProvider, document,
                            pragmaActionsBuilder.ToImmutableAndFree(),
                            pragmaDiagnosticsBuilder.ToImmutableAndFree(),
                            fixAllState, cancellationToken);

                        addFix(pragmaBatchFix);
                    }
                }
开发者ID:jkotas,项目名称:roslyn,代码行数:50,代码来源:AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction.BatchFixer.cs

示例5: AddCompilationInfo

		public static void AddCompilationInfo(this RunningResults results, ImmutableArray<Diagnostic> diagnostics)
		{
			if (diagnostics.Length == 0)
			{
				return;
			}
			var sb = new StringBuilder();
			var errors = diagnostics.Where(d => d.DefaultSeverity.IsOneOf(DiagnosticSeverity.Error, DiagnosticSeverity.Warning)).ToList();
			foreach (var error in errors)
			{
				sb.Append(error);
			}
			if (errors.Any(e => e.DefaultSeverity == DiagnosticSeverity.Error))
				results.Verdict = Verdict.CompilationError;
			results.CompilationOutput = sb.ToString();
		}
开发者ID:kontur-edu,项目名称:uLearn,代码行数:16,代码来源:RunningResultsExtensions.cs

示例6: AddProjectFixesAsync

                public async override Task AddProjectFixesAsync(Project project, ImmutableArray<Diagnostic> diagnostics, Action<CodeAction> addFix, FixAllContext fixAllContext)
                {
                    foreach (var diagnostic in diagnostics.Where(d => !d.Location.IsInSource && d.IsSuppressed))
                    {
                        var removeSuppressionFixes = await _suppressionFixProvider.GetSuppressionsAsync(project, SpecializedCollections.SingletonEnumerable(diagnostic), fixAllContext.CancellationToken).ConfigureAwait(false);
                        var removeSuppressionCodeAction = removeSuppressionFixes.SingleOrDefault()?.Action as RemoveSuppressionCodeAction;
                        if (removeSuppressionCodeAction != null)
                        {
                            if (fixAllContext is FixMultipleContext)
                            {
                                removeSuppressionCodeAction = removeSuppressionCodeAction.CloneForFixMultipleContext();
                            }

                            addFix(removeSuppressionCodeAction);
                        }
                    }
                }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:17,代码来源:AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction.BatchFixer.cs

示例7: WriteWarnings

        private static void WriteWarnings(ImmutableArray<Diagnostic> diagnostics)
        {
            IEnumerable<Diagnostic> warnings = diagnostics.Where(diagnostic =>
                diagnostic.Severity == DiagnosticSeverity.Warning);

            foreach (Diagnostic diagnostic in warnings)
            {
                Console.Error.WriteLine("WARNING: {0}: {1}", diagnostic.Id, diagnostic.GetMessage());
            }
        }
开发者ID:shcheahgmail,项目名称:DotNetSamples,代码行数:10,代码来源:Program.cs

示例8: MergeDiagnostics

        private ImmutableArray<DiagnosticData> MergeDiagnostics(ImmutableArray<DiagnosticData> liveDiagnostics, ImmutableArray<DiagnosticData> existingDiagnostics)
        {
            ImmutableArray<DiagnosticData>.Builder builder = null;

            if (liveDiagnostics.Length > 0)
            {
                builder = ImmutableArray.CreateBuilder<DiagnosticData>();
                builder.AddRange(liveDiagnostics);
            }

            if (existingDiagnostics.Length > 0)
            {
                builder = builder ?? ImmutableArray.CreateBuilder<DiagnosticData>();
                builder.AddRange(existingDiagnostics.Where(d => d.Severity == DiagnosticSeverity.Hidden));
            }

            return builder == null ? ImmutableArray<DiagnosticData>.Empty : builder.ToImmutable();
        }
开发者ID:noahfalk,项目名称:roslyn,代码行数:18,代码来源:DiagnosticIncrementalAnalyzer_BuildSynchronization.cs

示例9: AssertMultipleFilesOutput

 protected static void AssertMultipleFilesOutput(ImmutableArray<TestFile> input, ImmutableArray<TestFile> output, BuildConstants buildConstants = null, bool ignoreEmptyLines = false) {
     AssertMultipleFilesResult(input, (result, testEnvironment) => {
         Assert.Equal<string>(
             output
                 .Where(x => x.IsInFlow)
                 .Select(x => x.Name)
                 .OrderBy(x => x), 
             result.ToRight().OrderBy(x => x));
         Assert.Equal(input.Length + output.Length, testEnvironment.FileCount);
         AssertFiles(output, testEnvironment, ignoreEmptyLines);
     }, buildConstants);
 }
开发者ID:VitalyTVA,项目名称:MetaSharp,代码行数:12,代码来源:GeneratorTests.cs

示例10: AssertMultipleFilesResult

 static void AssertMultipleFilesResult(ImmutableArray<TestFile> input, Action<GeneratorResult, TestEnvironment> assertion, BuildConstants buildConstants) {
     var testEnvironment = CreateEnvironment(buildConstants);
     input.ForEach(file => testEnvironment.Environment.WriteText(file.Name, file.Text));
     var result = Generator.Generate(input.Where(file => file.IsInFlow).Select(file => file.Name).ToImmutableArray(), testEnvironment.Environment);
     AssertFiles(input, testEnvironment, ignoreEmptyLines: false);
     assertion(result, testEnvironment);
 }
开发者ID:VitalyTVA,项目名称:MetaSharp,代码行数:7,代码来源:GeneratorTests.cs

示例11: ShouldAddExternAlias

 private static bool ShouldAddExternAlias(ImmutableArray<string> aliases, CompilationUnitSyntax root)
 {
     var identifiers = root.DescendantNodes().OfType<ExternAliasDirectiveSyntax>().Select(e => e.Identifier.ToString());
     var externAliases = aliases.Where(a => identifiers.Contains(a));
     return !externAliases.Any();
 }
开发者ID:reidwooten99apps,项目名称:roslyn,代码行数:6,代码来源:CSharpAddImportCodeFixProvider.cs

示例12: ToArgs

 /// <summary>
 /// 
 /// </summary>
 /// <param name="properties"></param>
 /// <returns></returns>
 private static object[] ToArgs(ImmutableArray<ShapeProperty> properties)
 {
     return properties.Where(x => x != null).Select(x => x.Value).ToArray();
 }
开发者ID:monocraft,项目名称:Core2D,代码行数:9,代码来源:XText.cs

示例13: TraceCompilationDiagnostics

        private void TraceCompilationDiagnostics(ImmutableArray<Diagnostic> diagnostics)
        {
            foreach (var diagnostic in diagnostics.Where(d => !d.IsSuppressed))
            {
                TraceLevel level = GetTraceLevelFromDiagnostic(diagnostic);
                TraceWriter.Trace(new TraceEvent(level, diagnostic.ToString()));

                ImmutableArray<Diagnostic> scriptDiagnostics = GetFunctionDiagnostics(diagnostic);

                if (!scriptDiagnostics.IsEmpty)
                {
                    TraceCompilationDiagnostics(scriptDiagnostics);
                }
            }
        }
开发者ID:isaacabraham,项目名称:azure-webjobs-sdk-script,代码行数:15,代码来源:CSharpFunctionInvoker.cs

示例14: TraceCompilationDiagnostics

        internal void TraceCompilationDiagnostics(ImmutableArray<Diagnostic> diagnostics, LogTargets logTarget = LogTargets.All)
        {
            if (logTarget == LogTargets.None)
            {
                return;
            }

            TraceWriter traceWriter = TraceWriter;
            IDictionary<string, object> properties = PrimaryHostTraceProperties;

            if (!logTarget.HasFlag(LogTargets.User))
            {
                traceWriter = Host.TraceWriter;
                properties = PrimaryHostSystemTraceProperties;
            }
            else if (!logTarget.HasFlag(LogTargets.System))
            {
                properties = PrimaryHostUserTraceProperties;
            }

            foreach (var diagnostic in diagnostics.Where(d => !d.IsSuppressed))
            {
                traceWriter.Trace(diagnostic.ToString(), diagnostic.Severity.ToTraceLevel(), properties);
            }
        }
开发者ID:Azure,项目名称:azure-webjobs-sdk-script,代码行数:25,代码来源:DotNetFunctionInvoker.cs

示例15: GetErrors

 private AddTypeCompilerError[] GetErrors(ImmutableArray<Diagnostic> diagnostics)
 {
     return diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error || d.Severity == DiagnosticSeverity.Warning)
         .Select(d => new AddTypeCompilerError
         {
             ErrorText = d.GetMessage(),
             FileName = null,
             Line = d.Location.GetMappedLineSpan().StartLinePosition.Line + 1, // Convert 0-based to 1-based
             IsWarning = !d.IsWarningAsError && d.Severity == DiagnosticSeverity.Warning,
             Column = d.Location.GetMappedLineSpan().StartLinePosition.Character + 1, // Convert 0-based to 1-based
             ErrorNumber = d.Id
         }).ToArray();
 }
开发者ID:40a,项目名称:PowerShell,代码行数:13,代码来源:AddType.cs


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