public static DiagnosticAnalysisResultMap <DiagnosticAnalyzer, DiagnosticAnalysisResult> ReadDiagnosticAnalysisResults( ObjectReader reader, IDictionary <string, DiagnosticAnalyzer> analyzerMap, Project project, VersionStamp version, CancellationToken cancellationToken) { var diagnosticDataSerializer = new DiagnosticDataSerializer(VersionStamp.Default, VersionStamp.Default); var analysisMap = ImmutableDictionary.CreateBuilder <DiagnosticAnalyzer, DiagnosticAnalysisResult>(); var analysisCount = reader.ReadInt32(); for (var i = 0; i < analysisCount; i++) { var analyzer = analyzerMap[reader.ReadString()]; var syntaxLocalMap = ReadDiagnosticDataMap(reader, diagnosticDataSerializer, project, cancellationToken); var semanticLocalMap = ReadDiagnosticDataMap(reader, diagnosticDataSerializer, project, cancellationToken); var nonLocalMap = ReadDiagnosticDataMap(reader, diagnosticDataSerializer, project, cancellationToken); var others = diagnosticDataSerializer.ReadDiagnosticData(reader, project, document: null, cancellationToken); var analysisResult = DiagnosticAnalysisResult.CreateFromSerialization( project, version, syntaxLocalMap, semanticLocalMap, nonLocalMap, others.NullToEmpty(), documentIds: null); analysisMap.Add(analyzer, analysisResult); } var telemetryMap = ImmutableDictionary.CreateBuilder <DiagnosticAnalyzer, AnalyzerTelemetryInfo>(); var telemetryCount = reader.ReadInt32(); for (var i = 0; i < telemetryCount; i++) { var analyzer = analyzerMap[reader.ReadString()]; var telemetryInfo = ReadTelemetry(reader, cancellationToken); telemetryMap.Add(analyzer, telemetryInfo); } var exceptionMap = ImmutableDictionary.CreateBuilder <DiagnosticAnalyzer, ImmutableArray <DiagnosticData> >(); var exceptionCount = reader.ReadInt32(); for (var i = 0; i < exceptionCount; i++) { var analyzer = analyzerMap[reader.ReadString()]; var exceptions = diagnosticDataSerializer.ReadDiagnosticData(reader, project, document: null, cancellationToken); if (!exceptions.IsDefault) { exceptionMap.Add(analyzer, exceptions); } } return(DiagnosticAnalysisResultMap.Create(analysisMap.ToImmutable(), telemetryMap.ToImmutable(), exceptionMap.ToImmutable())); }
public DiagnosticAnalysisResult ToResult() { return(DiagnosticAnalysisResult.CreateFromSerialization(_project, _version, _syntaxLocals?.ToImmutable() ?? ImmutableDictionary <DocumentId, ImmutableArray <DiagnosticData> > .Empty, _semanticLocals?.ToImmutable() ?? ImmutableDictionary <DocumentId, ImmutableArray <DiagnosticData> > .Empty, _nonLocals?.ToImmutable() ?? ImmutableDictionary <DocumentId, ImmutableArray <DiagnosticData> > .Empty, _others.NullToEmpty(), _documentIds)); }
public static DiagnosticAnalysisResultMap <DiagnosticAnalyzer, DiagnosticAnalysisResult> Deserialize( ObjectReader reader, IDictionary <string, DiagnosticAnalyzer> analyzerMap, Project project, VersionStamp version, CancellationToken cancellationToken) { var diagnosticDataSerializer = new DiagnosticDataSerializer(VersionStamp.Default, VersionStamp.Default); var analysisMap = ImmutableDictionary.CreateBuilder <DiagnosticAnalyzer, DiagnosticAnalysisResult>(); var analysisCount = reader.ReadInt32(); for (var i = 0; i < analysisCount; i++) { var analyzer = analyzerMap[reader.ReadString()]; var syntaxLocalMap = Deserialize(reader, diagnosticDataSerializer, project, cancellationToken); var semanticLocalMap = Deserialize(reader, diagnosticDataSerializer, project, cancellationToken); var nonLocalMap = Deserialize(reader, diagnosticDataSerializer, project, cancellationToken); var others = diagnosticDataSerializer.ReadFrom(reader, project, cancellationToken); var analysisResult = DiagnosticAnalysisResult.CreateFromSerialization( project, version, syntaxLocalMap, semanticLocalMap, nonLocalMap, GetOrDefault(others)); analysisMap.Add(analyzer, analysisResult); } var telemetryMap = ImmutableDictionary.CreateBuilder <DiagnosticAnalyzer, AnalyzerTelemetryInfo>(); var telemetryCount = reader.ReadInt32(); for (var i = 0; i < telemetryCount; i++) { var analyzer = analyzerMap[reader.ReadString()]; var telemetryInfo = Deserialize(reader, cancellationToken); telemetryMap.Add(analyzer, telemetryInfo); } var exceptionMap = ImmutableDictionary.CreateBuilder <DiagnosticAnalyzer, ImmutableArray <DiagnosticData> >(); var exceptionCount = reader.ReadInt32(); for (var i = 0; i < exceptionCount; i++) { var analyzer = analyzerMap[reader.ReadString()]; var exceptions = diagnosticDataSerializer.ReadFrom(reader, project, cancellationToken); exceptionMap.Add(analyzer, GetOrDefault(exceptions)); } return(DiagnosticAnalysisResultMap.Create(analysisMap.ToImmutable(), telemetryMap.ToImmutable(), exceptionMap.ToImmutable())); }