6
6
using System . Linq ;
7
7
using CommunityToolkit . Mvvm . SourceGenerators . ComponentModel . Models ;
8
8
using CommunityToolkit . Mvvm . SourceGenerators . Extensions ;
9
+ using CommunityToolkit . Mvvm . SourceGenerators . Input . Models ;
9
10
using CommunityToolkit . Mvvm . SourceGenerators . Models ;
10
11
using Microsoft . CodeAnalysis ;
11
12
using Microsoft . CodeAnalysis . CSharp ;
@@ -32,22 +33,22 @@ public ObservableRecipientGenerator()
32
33
/// <inheritdoc/>
33
34
private protected override ObservableRecipientInfo ? ValidateTargetTypeAndGetInfo ( INamedTypeSymbol typeSymbol , AttributeData attributeData , Compilation compilation , out ImmutableArray < DiagnosticInfo > diagnostics )
34
35
{
35
- ImmutableArray < DiagnosticInfo > . Builder builder = ImmutableArray . CreateBuilder < DiagnosticInfo > ( ) ;
36
+ diagnostics = ImmutableArray < DiagnosticInfo > . Empty ;
36
37
37
38
ObservableRecipientInfo ? info = null ;
38
39
39
40
// Check if the type already inherits from ObservableRecipient
40
41
if ( typeSymbol . InheritsFromFullyQualifiedName ( "global::CommunityToolkit.Mvvm.ComponentModel.ObservableRecipient" ) )
41
42
{
42
- builder . Add ( DuplicateObservableRecipientError , typeSymbol , typeSymbol ) ;
43
+ diagnostics = ImmutableArray . Create ( DiagnosticInfo . Create ( DuplicateObservableRecipientError , typeSymbol , typeSymbol ) ) ;
43
44
44
45
goto End ;
45
46
}
46
47
47
48
// Check if the type already inherits [ObservableRecipient]
48
49
if ( typeSymbol . InheritsAttributeWithFullyQualifiedName ( "global::CommunityToolkit.Mvvm.ComponentModel.ObservableRecipientAttribute" ) )
49
50
{
50
- builder . Add ( InvalidAttributeCombinationForObservableRecipientAttributeError , typeSymbol , typeSymbol ) ;
51
+ diagnostics = ImmutableArray . Create ( DiagnosticInfo . Create ( InvalidAttributeCombinationForObservableRecipientAttributeError , typeSymbol , typeSymbol ) ) ;
51
52
52
53
goto End ;
53
54
}
@@ -60,7 +61,7 @@ public ObservableRecipientGenerator()
60
61
a . AttributeClass ? . HasFullyQualifiedName ( "global::CommunityToolkit.Mvvm.ComponentModel.INotifyPropertyChangedAttribute" ) == true &&
61
62
! a . HasNamedArgument ( "IncludeAdditionalHelperMethods" , false ) ) )
62
63
{
63
- builder . Add ( MissingBaseObservableObjectFunctionalityError , typeSymbol , typeSymbol ) ;
64
+ diagnostics = ImmutableArray . Create ( DiagnosticInfo . Create ( MissingBaseObservableObjectFunctionalityError , typeSymbol , typeSymbol ) ) ;
64
65
65
66
goto End ;
66
67
}
@@ -84,8 +85,6 @@ public ObservableRecipientGenerator()
84
85
hasOnDeactivatedMethod ) ;
85
86
86
87
End :
87
- diagnostics = builder . ToImmutable ( ) ;
88
-
89
88
return info ;
90
89
}
91
90
0 commit comments