1
- // Licensed to the .NET Foundation under one or more agreements.
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
4
using System ;
@@ -91,7 +91,7 @@ public async Task StartAsync(CancellationToken cancellationToken)
91
91
cancellationToken . ThrowIfCancellationRequested ( ) ;
92
92
93
93
CollectFiles ( ) ;
94
- if ( ! _docsComments . Types . Any ( ) )
94
+ if ( _docsComments . Types . Count == 0 )
95
95
{
96
96
Log . Error ( "No docs files found." ) ;
97
97
return ;
@@ -105,7 +105,7 @@ public async Task StartAsync(CancellationToken cancellationToken)
105
105
/// </summary>
106
106
public async Task MatchSymbolsAsync ( Compilation compilation , bool isMSBuildProject , CancellationToken cancellationToken )
107
107
{
108
- Debug . Assert ( _docsComments . Types . Any ( ) ) ;
108
+ Debug . Assert ( _docsComments . Types . Count != 0 ) ;
109
109
cancellationToken . ThrowIfCancellationRequested ( ) ;
110
110
111
111
Log . Info ( "Looking for symbol locations for all Docs types..." ) ;
@@ -127,13 +127,14 @@ public async Task MatchSymbolsAsync(Compilation compilation, bool isMSBuildProje
127
127
/// </summary>
128
128
public async Task PortAsync ( bool isMSBuildProject , CancellationToken cancellationToken )
129
129
{
130
- Debug . Assert ( _docsComments . Types . Any ( ) ) ;
130
+ Debug . Assert ( _docsComments . Types . Count != 0 ) ;
131
131
cancellationToken . ThrowIfCancellationRequested ( ) ;
132
132
133
133
Log . Info ( $ "Now attempting to port all found symbols...") ;
134
134
foreach ( DocsType docsType in _docsComments . Types . Values )
135
135
{
136
- if ( docsType . SymbolLocations == null || ! docsType . SymbolLocations . Any ( ) )
136
+ Debug . Assert ( docsType . SymbolLocations != null ) ;
137
+ if ( docsType . SymbolLocations . Count == 0 )
137
138
{
138
139
Log . Warning ( $ "No symbols found for '{ docsType . DocId } '. Skipping.") ;
139
140
continue ;
@@ -164,7 +165,11 @@ private static void CollectSymbolLocations(Compilation compilation, DocsType doc
164
165
{
165
166
FindLocationsOfSymbolInResolvedProject ( docsType , compilation ) ;
166
167
167
- if ( docsType . SymbolLocations == null || ! docsType . SymbolLocations . Any ( ) )
168
+ if ( docsType . SymbolLocations == null )
169
+ {
170
+ throw new NullReferenceException ( ) ;
171
+ }
172
+ if ( docsType . SymbolLocations . Count == 0 )
168
173
{
169
174
Log . Error ( $ "No symbols found for docs type '{ docsType . DocId } '.") ;
170
175
}
@@ -245,16 +250,15 @@ private static void FindLocationsOfSymbolInResolvedProject(DocsType docsType, Co
245
250
// Next, filter types that match the current docsType
246
251
IEnumerable < ISymbol > currentTypeSymbols = visitor . AllTypesSymbols . Where ( s => s != null && s . GetDocumentationCommentId ( ) == docsType . DocId ) ;
247
252
253
+ docsType . SymbolLocations ??= new ( ) ;
248
254
foreach ( ISymbol symbol in currentTypeSymbols )
249
255
{
250
- docsType . SymbolLocations = GetSymbolLocations ( compilation , symbol ) ;
256
+ GetSymbolLocations ( docsType . SymbolLocations , compilation , symbol ) ;
251
257
}
252
258
}
253
259
254
- private static List < ResolvedLocation > GetSymbolLocations ( Compilation compilation , ISymbol symbol )
260
+ private static void GetSymbolLocations ( List < ResolvedLocation > resolvedLocations , Compilation compilation , ISymbol symbol )
255
261
{
256
- List < ResolvedLocation > resolvedLocations = new ( ) ;
257
-
258
262
int n = 0 ;
259
263
string docId = symbol . GetDocumentationCommentId ( ) ?? throw new NullReferenceException ( $ "DocID was null for symbol '{ symbol } '") ;
260
264
foreach ( Location location in symbol . Locations )
@@ -289,8 +293,6 @@ private static List<ResolvedLocation> GetSymbolLocations(Compilation compilation
289
293
}
290
294
n ++ ;
291
295
}
292
-
293
- return resolvedLocations ;
294
296
}
295
297
296
298
[ GeneratedRegex ( "src(?<separator>[\\ \\ \\ /]{1})coreclr" ) ]
0 commit comments