File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -1625,6 +1625,56 @@ public MyViewModel()
16251625 await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration < FieldReferenceForObservablePropertyFieldAnalyzer > ( source , LanguageVersion . CSharp8 ) ;
16261626 }
16271627
1628+ // See https://github.com/CommunityToolkit/dotnet/issues/563
1629+ [ TestMethod ]
1630+ public void InvalidPropertyTargetedAttributeOnObservablePropertyField_MissingUsingDirective ( )
1631+ {
1632+ string source = """
1633+ using System;
1634+ using CommunityToolkit.Mvvm.ComponentModel;
1635+
1636+ namespace MyApp
1637+ {
1638+ public partial class MyViewModel : ObservableObject
1639+ {
1640+ [ObservableProperty]
1641+ [property: MyTest]
1642+ public int number;
1643+ }
1644+ }
1645+
1646+ namespace MyAttributes
1647+ {
1648+ [AttributeUsage(AttributeTargets.Property)]
1649+ public class MyTestAttribute : Attribute
1650+ {
1651+ }
1652+ }
1653+ """ ;
1654+
1655+ VerifyGeneratedDiagnostics < ObservablePropertyGenerator > ( source , "MVVMTK0035" ) ;
1656+ }
1657+
1658+ [ TestMethod ]
1659+ public void InvalidPropertyTargetedAttributeOnObservablePropertyField_TypoInAttributeName ( )
1660+ {
1661+ string source = """
1662+ using CommunityToolkit.Mvvm.ComponentModel;
1663+
1664+ namespace MyApp
1665+ {
1666+ public partial class MyViewModel : ObservableObject
1667+ {
1668+ [ObservableProperty]
1669+ [property: Fbuifbweif]
1670+ public int number;
1671+ }
1672+ }
1673+ """ ;
1674+
1675+ VerifyGeneratedDiagnostics < ObservablePropertyGenerator > ( source , "MVVMTK0035" ) ;
1676+ }
1677+
16281678 /// <summary>
16291679 /// Verifies the diagnostic errors for a given analyzer, and that all available source generators can run successfully with the input source (including subsequent compilation).
16301680 /// </summary>
You can’t perform that action at this time.
0 commit comments