1- // Licensed to the .NET Foundation under one or more agreements.
1+ // Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
44using System ;
55using System . Collections . Generic ;
6+ using System . Collections . Immutable ;
67using System . Runtime . CompilerServices ;
78using Microsoft . AspNetCore . Razor . Language . Syntax ;
89
@@ -24,47 +25,35 @@ private class SpanData
2425 /// </summary>
2526 private static readonly ConditionalWeakTable < SyntaxNode , SpanData > s_spanDataTable = new ( ) ;
2627
27- private static readonly ISet < SyntaxKind > s_transitionSpanKinds = new HashSet < SyntaxKind >
28- {
28+ private static readonly ImmutableHashSet < SyntaxKind > s_transitionSpanKinds = ImmutableHashSet . Create (
2929 SyntaxKind . CSharpTransition ,
30- SyntaxKind . MarkupTransition ,
31- } ;
30+ SyntaxKind . MarkupTransition ) ;
3231
33- private static readonly ISet < SyntaxKind > s_metaCodeSpanKinds = new HashSet < SyntaxKind >
34- {
35- SyntaxKind . RazorMetaCode ,
36- } ;
32+ private static readonly ImmutableHashSet < SyntaxKind > s_metaCodeSpanKinds = ImmutableHashSet . Create (
33+ SyntaxKind . RazorMetaCode ) ;
3734
38- private static readonly ISet < SyntaxKind > s_commentSpanKinds = new HashSet < SyntaxKind >
39- {
35+ private static readonly ImmutableHashSet < SyntaxKind > s_commentSpanKinds = ImmutableHashSet . Create (
4036 SyntaxKind . RazorCommentTransition ,
4137 SyntaxKind . RazorCommentStar ,
42- SyntaxKind . RazorCommentLiteral ,
43- } ;
38+ SyntaxKind . RazorCommentLiteral ) ;
4439
45- private static readonly ISet < SyntaxKind > s_codeSpanKinds = new HashSet < SyntaxKind >
46- {
40+ private static readonly ImmutableHashSet < SyntaxKind > s_codeSpanKinds = ImmutableHashSet . Create (
4741 SyntaxKind . CSharpStatementLiteral ,
4842 SyntaxKind . CSharpExpressionLiteral ,
49- SyntaxKind . CSharpEphemeralTextLiteral ,
50- } ;
43+ SyntaxKind . CSharpEphemeralTextLiteral ) ;
5144
52- private static readonly ISet < SyntaxKind > s_markupSpanKinds = new HashSet < SyntaxKind >
53- {
45+ private static readonly ImmutableHashSet < SyntaxKind > s_markupSpanKinds = ImmutableHashSet . Create (
5446 SyntaxKind . MarkupTextLiteral ,
55- SyntaxKind . MarkupEphemeralTextLiteral ,
56- } ;
47+ SyntaxKind . MarkupEphemeralTextLiteral ) ;
5748
58- private static readonly ISet < SyntaxKind > s_noneSpanKinds = new HashSet < SyntaxKind >
59- {
60- SyntaxKind . UnclassifiedTextLiteral ,
61- } ;
49+ private static readonly ImmutableHashSet < SyntaxKind > s_noneSpanKinds = ImmutableHashSet . Create (
50+ SyntaxKind . UnclassifiedTextLiteral ) ;
6251
63- private static readonly ISet < SyntaxKind > s_allSpanKinds = CreateAllSpanKindsSet ( ) ;
52+ private static readonly ImmutableHashSet < SyntaxKind > s_allSpanKinds = CreateAllSpanKindsSet ( ) ;
6453
65- private static ISet < SyntaxKind > CreateAllSpanKindsSet ( )
54+ private static ImmutableHashSet < SyntaxKind > CreateAllSpanKindsSet ( )
6655 {
67- var set = new HashSet < SyntaxKind > ( ) ;
56+ var set = ImmutableHashSet < SyntaxKind > . Empty . ToBuilder ( ) ;
6857
6958 set . UnionWith ( s_transitionSpanKinds ) ;
7059 set . UnionWith ( s_metaCodeSpanKinds ) ;
@@ -73,7 +62,7 @@ private static ISet<SyntaxKind> CreateAllSpanKindsSet()
7362 set . UnionWith ( s_markupSpanKinds ) ;
7463 set . UnionWith ( s_noneSpanKinds ) ;
7564
76- return set ;
65+ return set . ToImmutable ( ) ;
7766 }
7867
7968 public static SpanContext ? GetSpanContext ( this SyntaxNode node )
0 commit comments