@@ -35,7 +35,7 @@ public void AddComment(ICommentLine comment)
3535
3636 class LocationComparer : IComparer < Location >
3737 {
38- public int Compare ( Location l1 , Location l2 ) => CommentProcessor . Compare ( l1 , l2 ) ;
38+ public int Compare ( Location ? l1 , Location ? l2 ) => CommentProcessor . Compare ( l1 , l2 ) ;
3939 }
4040
4141 /// <summary>
@@ -44,8 +44,12 @@ class LocationComparer : IComparer<Location>
4444 /// <param name="l1">First location</param>
4545 /// <param name="l2">Second location</param>
4646 /// <returns><0 if l1 before l2, >0 if l1 after l2, else 0.</returns>
47- static int Compare ( Location l1 , Location l2 )
47+ static int Compare ( Location ? l1 , Location ? l2 )
4848 {
49+ if ( object . ReferenceEquals ( l1 , l2 ) ) return 0 ;
50+ if ( l1 == null ) return - 1 ;
51+ if ( l2 == null ) return 1 ;
52+
4953 int diff = l1 . SourceTree == l2 . SourceTree ? 0 : l1 . SourceTree . FilePath . CompareTo ( l2 . SourceTree . FilePath ) ;
5054 if ( diff != 0 ) return diff ;
5155 diff = l1 . SourceSpan . Start - l2 . SourceSpan . Start ;
@@ -243,7 +247,7 @@ CommentBindingCallback cb
243247 /// Process comments up until nextElement.
244248 /// Group comments into blocks, and associate blocks with elements.
245249 /// </summary>
246- ///
250+ ///
247251 /// <param name="commentEnumerator">Enumerator for all comments in the program.</param>
248252 /// <param name="nextElement">The next element in the list.</param>
249253 /// <param name="elementStack">A stack of nested program elements.</param>
@@ -261,7 +265,7 @@ CommentBindingCallback cb
261265 // Iterate comments until the commentEnumerator has gone past nextElement
262266 while ( nextElement == null || Compare ( commentEnumerator . Current . Value . Location , nextElement . Value . Key ) < 0 )
263267 {
264- if ( block is null )
268+ if ( block is null )
265269 block = new CommentBlock ( commentEnumerator . Current . Value ) ;
266270
267271 if ( ! block . CombinesWith ( commentEnumerator . Current . Value ) )
@@ -284,7 +288,7 @@ CommentBindingCallback cb
284288 }
285289 }
286290
287- if ( ! ( block is null ) )
291+ if ( ! ( block is null ) )
288292 GenerateBindings ( block , elementStack , nextElement , cb ) ;
289293
290294 return true ;
0 commit comments