本文整理汇总了C#中ImmutableArray.GroupBy方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.GroupBy方法的具体用法?C# ImmutableArray.GroupBy怎么用?C# ImmutableArray.GroupBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableArray
的用法示例。
在下文中一共展示了ImmutableArray.GroupBy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateLocalDiagnostics_NoLock
private void UpdateLocalDiagnostics_NoLock(DiagnosticAnalyzer analyzer, ImmutableArray<Diagnostic> diagnostics, ref Dictionary<SyntaxTree, Dictionary<DiagnosticAnalyzer, List<Diagnostic>>> lazyLocalDiagnostics)
{
if (diagnostics.IsEmpty)
{
return;
}
lazyLocalDiagnostics = lazyLocalDiagnostics ?? new Dictionary<SyntaxTree, Dictionary<DiagnosticAnalyzer, List<Diagnostic>>>();
foreach (var diagsByTree in diagnostics.GroupBy(d => d.Location.SourceTree))
{
var tree = diagsByTree.Key;
Dictionary<DiagnosticAnalyzer, List<Diagnostic>> allDiagnostics;
if (!lazyLocalDiagnostics.TryGetValue(tree, out allDiagnostics))
{
allDiagnostics = new Dictionary<DiagnosticAnalyzer, List<Diagnostic>>();
lazyLocalDiagnostics[tree] = allDiagnostics;
}
List<Diagnostic> analyzerDiagnostics;
if (!allDiagnostics.TryGetValue(analyzer, out analyzerDiagnostics))
{
analyzerDiagnostics = new List<Diagnostic>();
allDiagnostics[analyzer] = analyzerDiagnostics;
}
analyzerDiagnostics.AddRange(diagsByTree);
}
}
示例2: OnReferenceLocationsChanged
private void OnReferenceLocationsChanged(object sender, ImmutableArray<InlineRenameLocation> renameLocations)
{
int totalFilesCount = renameLocations.GroupBy(s => s.Document).Count();
int totalSpansCount = renameLocations.Length;
UpdateSearchText(totalSpansCount, totalFilesCount);
}
示例3: MakeCompilationActionsByAnalyzer
private static ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<CompilationAnalyzerAction>> MakeCompilationActionsByAnalyzer(ImmutableArray<CompilationAnalyzerAction> compilationActions)
{
var builder = ImmutableDictionary.CreateBuilder<DiagnosticAnalyzer, ImmutableArray<CompilationAnalyzerAction>>();
var actionsByAnalyzers = compilationActions.GroupBy(action => action.Analyzer);
foreach (var analyzerAndActions in actionsByAnalyzers)
{
builder.Add(analyzerAndActions.Key, analyzerAndActions.ToImmutableArray());
}
return builder.ToImmutable();
}
示例4: RaiseProjectDiagnosticsUpdated
private void RaiseProjectDiagnosticsUpdated(Project project, StateSet stateSet, ImmutableArray<DiagnosticData> diagnostics)
{
var group = diagnostics.GroupBy(d => d.DocumentId);
foreach (var kv in group)
{
if (kv.Key == null)
{
RaiseDiagnosticsUpdated(StateType.Project, project.Id, stateSet, new SolutionArgument(project), kv.ToImmutableArrayOrEmpty());
continue;
}
RaiseDiagnosticsUpdated(StateType.Project, kv.Key, stateSet, new SolutionArgument(project.GetDocument(kv.Key)), kv.ToImmutableArrayOrEmpty());
}
}
示例5: RaiseProjectDiagnosticsRemovedIfNeeded
private void RaiseProjectDiagnosticsRemovedIfNeeded(
Project project, StateSet stateSet, ImmutableArray<DiagnosticData> existingItems, ImmutableArray<DiagnosticData> newItems)
{
if (existingItems.Length == 0)
{
return;
}
var removedItems = existingItems.GroupBy(d => d.DocumentId).Select(g => g.Key).Except(newItems.GroupBy(d => d.DocumentId).Select(g => g.Key));
foreach (var documentId in removedItems)
{
if (documentId == null)
{
RaiseDiagnosticsUpdated(StateType.Project, project.Id, stateSet, new SolutionArgument(project), ImmutableArray<DiagnosticData>.Empty);
continue;
}
var document = project.GetDocument(documentId);
var argument = documentId == null ? new SolutionArgument(null, documentId.ProjectId, documentId) : new SolutionArgument(document);
RaiseDiagnosticsUpdated(StateType.Project, documentId, stateSet, argument, ImmutableArray<DiagnosticData>.Empty);
}
}
示例6: GetDocumentDiagnosticsToFixAsync
private static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic>>> GetDocumentDiagnosticsToFixAsync(
ImmutableArray<Diagnostic> diagnostics,
ImmutableArray<Project> projects,
CancellationToken cancellationToken)
{
var treeToDocumentMap = await GetTreeToDocumentMapAsync(projects, cancellationToken).ConfigureAwait(false);
var builder = ImmutableDictionary.CreateBuilder<Document, ImmutableArray<Diagnostic>>();
foreach (var documentAndDiagnostics in diagnostics.GroupBy(d => GetReportedDocument(d, treeToDocumentMap)))
{
cancellationToken.ThrowIfCancellationRequested();
var document = documentAndDiagnostics.Key;
var diagnosticsForDocument = documentAndDiagnostics.ToImmutableArray();
builder.Add(document, diagnosticsForDocument);
}
return builder.ToImmutable();
}
示例7: RaiseEvents
private void RaiseEvents(Project project, ImmutableArray<DiagnosticData> diagnostics)
{
var groups = diagnostics.GroupBy(d => d.DocumentId);
var solution = project.Solution;
var workspace = solution.Workspace;
foreach (var kv in groups)
{
if (kv.Key == null)
{
_owner.RaiseDiagnosticsUpdated(
this, new DiagnosticsUpdatedArgs(
ValueTuple.Create(this, project.Id), workspace, solution, project.Id, null, kv.ToImmutableArrayOrEmpty()));
continue;
}
_owner.RaiseDiagnosticsUpdated(
this, new DiagnosticsUpdatedArgs(
ValueTuple.Create(this, kv.Key), workspace, solution, project.Id, kv.Key, kv.ToImmutableArrayOrEmpty()));
}
}
示例8: RemoveAwaitFromCallersAsync
private async Task<Solution> RemoveAwaitFromCallersAsync(
Solution solution, ImmutableArray<ReferenceLocation> locations, CancellationToken cancellationToken)
{
var currentSolution = solution;
var groupedLocations = locations.GroupBy(loc => loc.Document);
foreach (var group in groupedLocations)
{
currentSolution = await RemoveAwaitFromCallersAsync(
currentSolution, group, cancellationToken).ConfigureAwait(false);
}
return currentSolution;
}