@@ -167,6 +167,43 @@ public async Task DiagnosticData_ExternalAdditionalLocationIsPreserved()
167167 Assert . Equal ( externalAdditionalLocation . UnmappedFileSpan , roundTripAdditionalLocation . UnmappedFileSpan ) ;
168168 }
169169
170+ [ Fact ]
171+ public async Task DiagnosticData_NoneAdditionalLocationIsPreserved ( )
172+ {
173+ using var workspace = new TestWorkspace ( composition : EditorTestCompositions . EditorFeatures ) ;
174+
175+ var additionalDocument = workspace . CurrentSolution . AddProject ( "TestProject" , "TestProject" , LanguageNames . CSharp )
176+ . AddDocument ( "test.cs" , "" , filePath : "test.cs" ) ;
177+
178+ var document = additionalDocument . Project . Documents . Single ( ) ;
179+
180+ var noneAdditionalLocation = new DiagnosticDataLocation ( new FileLinePositionSpan ( "" , default ) ) ;
181+
182+ var diagnosticData = new DiagnosticData (
183+ id : "test1" ,
184+ category : "Test" ,
185+ message : "test1 message" ,
186+ severity : DiagnosticSeverity . Info ,
187+ defaultSeverity : DiagnosticSeverity . Info ,
188+ isEnabledByDefault : true ,
189+ warningLevel : 1 ,
190+ projectId : document . Project . Id ,
191+ customTags : [ ] ,
192+ properties : ImmutableDictionary < string , string > . Empty ,
193+ location : new DiagnosticDataLocation ( new FileLinePositionSpan ( document . FilePath , span : default ) , document . Id ) ,
194+ additionalLocations : [ noneAdditionalLocation ] ,
195+ language : document . Project . Language ) ;
196+
197+ var diagnostic = await diagnosticData . ToDiagnosticAsync ( document . Project , CancellationToken . None ) ;
198+ var roundTripDiagnosticData = DiagnosticData . Create ( diagnostic , document ) ;
199+
200+ var roundTripAdditionalLocation = Assert . Single ( roundTripDiagnosticData . AdditionalLocations ) ;
201+ Assert . Null ( noneAdditionalLocation . DocumentId ) ;
202+ Assert . Null ( roundTripAdditionalLocation . DocumentId ) ;
203+ Assert . Equal ( noneAdditionalLocation . UnmappedFileSpan , roundTripAdditionalLocation . UnmappedFileSpan ) ;
204+ Assert . Same ( diagnostic . AdditionalLocations . Single ( ) , Location . None ) ;
205+ }
206+
170207 [ Fact ]
171208 public async Task DiagnosticData_SourceGeneratedDocumentLocationIsPreserved ( )
172209 {
0 commit comments