@@ -1820,6 +1820,66 @@ public partial class MyViewModel
18201820 await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration < AsyncVoidReturningRelayCommandMethodAnalyzer > ( source , LanguageVersion . CSharp8 ) ;
18211821 }
18221822
1823+ [ TestMethod ]
1824+ public async Task FieldTargetedObservablePropertyAttribute_InstanceAutoProperty ( )
1825+ {
1826+ string source = """
1827+ using CommunityToolkit.Mvvm.ComponentModel;
1828+
1829+ namespace MyApp
1830+ {
1831+ public partial class SampleViewModel : ObservableObject
1832+ {
1833+ [field: {|MVVMTK0040:ObservableProperty|}]
1834+ public string Name { get; set; }
1835+ }
1836+ }
1837+ """ ;
1838+
1839+ await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration < AutoPropertyWithFieldTargetedObservablePropertyAttributeAnalyzer > ( source , LanguageVersion . CSharp8 ) ;
1840+ }
1841+
1842+ [ TestMethod ]
1843+ public async Task FieldTargetedObservablePropertyAttribute_StaticAutoProperty ( )
1844+ {
1845+ string source = """
1846+ using CommunityToolkit.Mvvm.ComponentModel;
1847+
1848+ namespace MyApp
1849+ {
1850+ public partial class SampleViewModel : ObservableObject
1851+ {
1852+ [field: {|MVVMTK0040:ObservableProperty|}]
1853+ public static string Name { get; set; }
1854+ }
1855+ }
1856+ """ ;
1857+
1858+ await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration < AutoPropertyWithFieldTargetedObservablePropertyAttributeAnalyzer > ( source , LanguageVersion . CSharp8 ) ;
1859+ }
1860+
1861+ [ TestMethod ]
1862+ public async Task FieldTargetedObservablePropertyAttribute_RecordPrimaryConstructorParameter ( )
1863+ {
1864+ string source = """
1865+ using CommunityToolkit.Mvvm.ComponentModel;
1866+
1867+ namespace MyApp
1868+ {
1869+ public partial record SampleViewModel([field: {|MVVMTK0040:ObservableProperty|}] string Name);
1870+ }
1871+
1872+ namespace System.Runtime.CompilerServices
1873+ {
1874+ internal static class IsExternalInit
1875+ {
1876+ }
1877+ }
1878+ """ ;
1879+
1880+ await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration < AutoPropertyWithFieldTargetedObservablePropertyAttributeAnalyzer > ( source , LanguageVersion . CSharp9 ) ;
1881+ }
1882+
18231883 /// <summary>
18241884 /// Verifies the diagnostic errors for a given analyzer, and that all available source generators can run successfully with the input source (including subsequent compilation).
18251885 /// </summary>
0 commit comments