diff --git a/src/Workspaces/Core/Portable/Diagnostics/DiagnosticAnalysisResult.cs b/src/Workspaces/Core/Portable/Diagnostics/DiagnosticAnalysisResult.cs index 465563c267afb90d63def0f10e0c9e04c907c8a1..7ad318a4b8058fa0c01baa107c9897a9f8662bc0 100644 --- a/src/Workspaces/Core/Portable/Diagnostics/DiagnosticAnalysisResult.cs +++ b/src/Workspaces/Core/Portable/Diagnostics/DiagnosticAnalysisResult.cs @@ -32,6 +32,47 @@ internal struct DiagnosticAnalysisResult private readonly ImmutableDictionary> _nonLocals; private readonly ImmutableArray _others; + private DiagnosticAnalysisResult( + ProjectId projectId, VersionStamp version, ImmutableHashSet documentIds, bool isEmpty, bool fromBuild) + { + ProjectId = projectId; + Version = version; + DocumentIds = documentIds; + IsEmpty = isEmpty; + FromBuild = fromBuild; + + _syntaxLocals = null; + _semanticLocals = null; + _nonLocals = null; + _others = default; + } + + private DiagnosticAnalysisResult( + ProjectId projectId, VersionStamp version, + ImmutableDictionary> syntaxLocals, + ImmutableDictionary> semanticLocals, + ImmutableDictionary> nonLocals, + ImmutableArray others, + ImmutableHashSet documentIds, + bool fromBuild) + { + ProjectId = projectId; + Version = version; + FromBuild = fromBuild; + + _syntaxLocals = syntaxLocals; + _semanticLocals = semanticLocals; + _nonLocals = nonLocals; + _others = others; + + DocumentIds = documentIds; + IsEmpty = false; + + // do after all fields are assigned. + DocumentIds = DocumentIds ?? CreateDocumentIds(); + IsEmpty = DocumentIds.IsEmpty && _others.IsEmpty; + } + public static DiagnosticAnalysisResult CreateEmpty(ProjectId projectId, VersionStamp version) { return new DiagnosticAnalysisResult( @@ -114,47 +155,6 @@ public static DiagnosticAnalysisResult CreateFromBuilder(DiagnosticAnalysisResul builder.DocumentIds); } - private DiagnosticAnalysisResult( - ProjectId projectId, VersionStamp version, ImmutableHashSet documentIds, bool isEmpty, bool fromBuild) - { - ProjectId = projectId; - Version = version; - DocumentIds = documentIds; - IsEmpty = isEmpty; - FromBuild = fromBuild; - - _syntaxLocals = null; - _semanticLocals = null; - _nonLocals = null; - _others = default; - } - - private DiagnosticAnalysisResult( - ProjectId projectId, VersionStamp version, - ImmutableDictionary> syntaxLocals, - ImmutableDictionary> semanticLocals, - ImmutableDictionary> nonLocals, - ImmutableArray others, - ImmutableHashSet documentIds, - bool fromBuild) - { - ProjectId = projectId; - Version = version; - FromBuild = fromBuild; - - _syntaxLocals = syntaxLocals; - _semanticLocals = semanticLocals; - _nonLocals = nonLocals; - _others = others; - - DocumentIds = documentIds; - IsEmpty = false; - - // do after all fields are assigned. - DocumentIds = DocumentIds ?? CreateDocumentIds(); - IsEmpty = DocumentIds.IsEmpty && _others.IsEmpty; - } - // aggregated form means it has aggregated information but no actual data. public bool IsAggregatedForm => _syntaxLocals == null;