diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs b/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs index 894a1af72..14d087d16 100644 --- a/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs +++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs @@ -1105,6 +1105,89 @@ private void GreetUser(object value) VerifyGeneratedDiagnostics(source, "MVVMTK0023"); } + [TestMethod] + public void InvalidObservablePropertyError_Object() + { + string source = @" + using CommunityToolkit.Mvvm.ComponentModel; + + namespace MyApp + { + public partial class MyViewModel : ObservableObject + { + [ObservableProperty] + public object property; + } + }"; + + VerifyGeneratedDiagnostics(source, "MVVMTK0024"); + } + + [TestMethod] + public void InvalidObservablePropertyError_PropertyChangingEventArgs() + { + string source = @" + using System.ComponentModel; + using CommunityToolkit.Mvvm.ComponentModel; + + namespace MyApp + { + public partial class MyViewModel : ObservableObject + { + [ObservableProperty] + public PropertyChangingEventArgs property; + } + }"; + + VerifyGeneratedDiagnostics(source, "MVVMTK0024"); + } + + [TestMethod] + public void InvalidObservablePropertyError_PropertyChangedEventArgs() + { + string source = @" + using System.ComponentModel; + using CommunityToolkit.Mvvm.ComponentModel; + + namespace MyApp + { + public partial class MyViewModel : ObservableObject + { + [ObservableProperty] + public PropertyChangedEventArgs property; + } + }"; + + VerifyGeneratedDiagnostics(source, "MVVMTK0024"); + } + + [TestMethod] + public void InvalidObservablePropertyError_CustomTypeDerivedFromPropertyChangedEventArgs() + { + string source = @" + using System.ComponentModel; + using CommunityToolkit.Mvvm.ComponentModel; + + namespace MyApp + { + public class MyPropertyChangedEventArgs : PropertyChangedEventArgs + { + public MyPropertyChangedEventArgs(string propertyName) + : base(propertyName) + { + } + } + + public partial class MyViewModel : ObservableObject + { + [ObservableProperty] + public MyPropertyChangedEventArgs property; + } + }"; + + VerifyGeneratedDiagnostics(source, "MVVMTK0024"); + } + /// /// Verifies the output of a source generator. ///