You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/InvalidClassLevelNotifyDataErrorInfoAttributeAnalyzer.cs
+21-18Lines changed: 21 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -26,30 +26,33 @@ public override void Initialize(AnalysisContext context)
if(context.Symbolis not INamedTypeSymbol{TypeKind:TypeKind.Class,IsImplicitlyDeclared:false}classSymbol)
33
-
{
34
-
return;
35
-
}
36
-
37
-
// Only inspect classes that are using [NotifyDataErrorInfo]
31
+
// Get the symbols for [NotifyDataErrorInfo] and ObservableValidator
38
32
if(context.Compilation.GetTypeByMetadataName("CommunityToolkit.Mvvm.ComponentModel.NotifyDataErrorInfoAttribute")is not INamedTypeSymbolnotifyDataErrorInfoAttributeSymbol||
context.Compilation.GetTypeByMetadataName("CommunityToolkit.Mvvm.ComponentModel.ObservableValidator")is not INamedTypeSymbolobservableValidatorSymbol)
40
34
{
41
35
return;
42
36
}
43
37
44
-
// If the containing type is not valid, emit a diagnostic
45
-
if(context.Compilation.GetTypeByMetadataName("CommunityToolkit.Mvvm.ComponentModel.ObservableValidator")is not INamedTypeSymbolobservableValidatorSymbol||
Copy file name to clipboardExpand all lines: src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/InvalidClassLevelNotifyPropertyChangedRecipientsAttributeAnalyzer.cs
+23-20Lines changed: 23 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -26,32 +26,35 @@ public override void Initialize(AnalysisContext context)
if(context.Symbolis not INamedTypeSymbol{TypeKind:TypeKind.Class,IsImplicitlyDeclared:false}classSymbol)
33
-
{
34
-
return;
35
-
}
36
-
37
-
// Only inspect classes that are using [NotifyPropertyChangedRecipients]
31
+
// Get the symbols for [NotifyPropertyChangedRecipients], ObservableRecipient and [ObservableRecipient]
38
32
if(context.Compilation.GetTypeByMetadataName("CommunityToolkit.Mvvm.ComponentModel.NotifyPropertyChangedRecipientsAttribute")is not INamedTypeSymbolnotifyPropertyChangedRecipientsAttributeSymbol||
context.Compilation.GetTypeByMetadataName("CommunityToolkit.Mvvm.ComponentModel.ObservableRecipient")is not INamedTypeSymbolobservableRecipientSymbol||
34
+
context.Compilation.GetTypeByMetadataName("CommunityToolkit.Mvvm.ComponentModel.ObservableRecipientAttribute")is not INamedTypeSymbolobservableRecipientAttributeSymbol)
40
35
{
41
36
return;
42
37
}
43
38
44
-
// If the containing type is not valid, emit a diagnostic
if(context.Symbolis not INamedTypeSymbol{TypeKind:TypeKind.Class,IsImplicitlyDeclared:false}classSymbol)
43
+
{
44
+
return;
45
+
}
46
+
47
+
// Emit a diagnstic for types that use [NotifyPropertyChangedRecipients] but are neither inheriting from ObservableRecipient nor using [ObservableRecipient]
0 commit comments