File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 6
6
using System . Collections . Immutable ;
7
7
using System . Linq ;
8
8
using Microsoft . CodeAnalysis ;
9
+ using Microsoft . CodeAnalysis . CSharp ;
9
10
using Microsoft . CodeAnalysis . Diagnostics ;
10
11
using static CommunityToolkit . Mvvm . SourceGenerators . Diagnostics . DiagnosticDescriptors ;
11
12
@@ -50,6 +51,12 @@ public override void Initialize(AnalysisContext context)
50
51
return ;
51
52
}
52
53
54
+ // Check that the language version is not high enough, otherwise no diagnostic should be produced
55
+ if ( context . Symbol . DeclaringSyntaxReferences . FirstOrDefault ( ) is not { SyntaxTree . Options : CSharpParseOptions { LanguageVersion : < LanguageVersion . CSharp8 } } )
56
+ {
57
+ return ;
58
+ }
59
+
53
60
ImmutableArray < AttributeData > attributes = context . Symbol . GetAttributes ( ) ;
54
61
55
62
// If the symbol has no attributes, there's nothing left to do
You can’t perform that action at this time.
0 commit comments