forked from dotnet/format
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeAnalysisResult.cs
28 lines (23 loc) · 955 Bytes
/
CodeAnalysisResult.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.
using System.Collections.Generic;
using NonBlocking;
namespace Microsoft.CodeAnalysis.Tools.Analyzers
{
internal class CodeAnalysisResult
{
private readonly ConcurrentDictionary<Project, List<Diagnostic>> _dictionary
= new ConcurrentDictionary<Project, List<Diagnostic>>();
internal void AddDiagnostic(Project project, Diagnostic diagnostic)
{
_ = _dictionary.AddOrUpdate(project,
addValueFactory: (key) => new List<Diagnostic>() { diagnostic },
updateValueFactory: (key, list) =>
{
list.Add(diagnostic);
return list;
});
}
public IReadOnlyDictionary<Project, List<Diagnostic>> Diagnostics
=> _dictionary;
}
}