@@ -126,8 +126,8 @@ public partial class SampleViewModel : ObservableObject
126
126
127
127
test . FixedState . ExpectedDiagnostics . AddRange ( new [ ]
128
128
{
129
- // /0/Test0.cs(8 ,27): error CS9248: Partial property 'SampleViewModel.Name' must have an implementation part.
130
- DiagnosticResult . CompilerError ( "CS9248" ) . WithSpan ( 8 , 27 , 8 , 31 ) . WithArguments ( "MyApp.SampleViewModel.Name" ) ,
129
+ // /0/Test0.cs(11 ,27): error CS9248: Partial property 'SampleViewModel.Name' must have an implementation part.
130
+ DiagnosticResult . CompilerError ( "CS9248" ) . WithSpan ( 11 , 27 , 11 , 31 ) . WithArguments ( "MyApp.SampleViewModel.Name" ) ,
131
131
} ) ;
132
132
133
133
await test . RunAsync ( ) ;
@@ -175,6 +175,8 @@ public partial class SampleViewModel : ObservableObject
175
175
[field: Test("Targeting field")]
176
176
public partial string Name { get; set; }
177
177
}
178
+
179
+ public class TestAttribute(string text) : Attribute;
178
180
""" ;
179
181
180
182
CSharpCodeFixTest test = new ( LanguageVersion . Preview )
@@ -193,8 +195,8 @@ public partial class SampleViewModel : ObservableObject
193
195
194
196
test . FixedState . ExpectedDiagnostics . AddRange ( new [ ]
195
197
{
196
- // /0/Test0.cs(8 ,27): error CS9248: Partial property 'SampleViewModel.Name' must have an implementation part.
197
- DiagnosticResult . CompilerError ( "CS9248" ) . WithSpan ( 8 , 27 , 8 , 31 ) . WithArguments ( "MyApp.SampleViewModel.Name" ) ,
198
+ // /0/Test0.cs(14 ,27): error CS9248: Partial property 'SampleViewModel.Name' must have an implementation part.
199
+ DiagnosticResult . CompilerError ( "CS9248" ) . WithSpan ( 14 , 27 , 14 , 31 ) . WithArguments ( "MyApp.SampleViewModel.Name" ) ,
198
200
} ) ;
199
201
200
202
await test . RunAsync ( ) ;
@@ -447,29 +449,29 @@ namespace MyApp;
447
449
448
450
public partial class SampleViewModel : ObservableObject
449
451
{
450
- [ObservableAttribute ]
452
+ [ObservableProperty ]
451
453
[Test("This is an attribute")]
452
454
public partial string Prop1 { get; set; }
453
455
454
456
// Single comment
455
- [ObservableAttribute ]
457
+ [ObservableProperty ]
456
458
public partial string Prop2 { get; set; }
457
459
458
460
/// <summary>
459
461
/// This is a property.
460
462
/// </summary>
461
- [ObservableAttribute ]
463
+ [ObservableProperty ]
462
464
public partial string Prop3 { get; set; }
463
465
464
466
/// <summary>
465
467
/// This is another property.
466
468
/// </summary>
467
- [ObservableAttribute ]
469
+ [ObservableProperty ]
468
470
[Test("Another attribute")]
469
471
public partial string Prop4 { get; set; }
470
472
471
473
// Some other single comment
472
- [ObservableAttribute ]
474
+ [ObservableProperty ]
473
475
[Test("Yet another attribute")]
474
476
public partial string Prop5 { get; set; }
475
477
}
@@ -505,8 +507,20 @@ public class TestAttribute(string text) : Attribute;
505
507
506
508
test . FixedState . ExpectedDiagnostics . AddRange ( new [ ]
507
509
{
508
- // /0/Test0.cs(8,27): error CS9248: Partial property 'SampleViewModel.Name' must have an implementation part.
509
- DiagnosticResult . CompilerError ( "CS9248" ) . WithSpan ( 8 , 27 , 8 , 31 ) . WithArguments ( "MyApp.SampleViewModel.Name" ) ,
510
+ // /0/Test0.cs(10,27): error CS9248: Partial property 'SampleViewModel.Prop1' must have an implementation part.
511
+ DiagnosticResult . CompilerError ( "CS9248" ) . WithSpan ( 10 , 27 , 10 , 32 ) . WithArguments ( "MyApp.SampleViewModel.Prop1" ) ,
512
+
513
+ // /0/Test0.cs(14,27): error CS9248: Partial property 'SampleViewModel.Prop2' must have an implementation part.
514
+ DiagnosticResult . CompilerError ( "CS9248" ) . WithSpan ( 14 , 27 , 14 , 32 ) . WithArguments ( "MyApp.SampleViewModel.Prop2" ) ,
515
+
516
+ // /0/Test0.cs(20,27): error CS9248: Partial property 'SampleViewModel.Prop3' must have an implementation part.
517
+ DiagnosticResult . CompilerError ( "CS9248" ) . WithSpan ( 20 , 27 , 20 , 32 ) . WithArguments ( "MyApp.SampleViewModel.Prop3" ) ,
518
+
519
+ // /0/Test0.cs(27,27): error CS9248: Partial property 'SampleViewModel.Prop4' must have an implementation part.
520
+ DiagnosticResult . CompilerError ( "CS9248" ) . WithSpan ( 27 , 27 , 27 , 32 ) . WithArguments ( "MyApp.SampleViewModel.Prop4" ) ,
521
+
522
+ // /0/Test0.cs(32,27): error CS9248: Partial property 'SampleViewModel.Prop5' must have an implementation part.
523
+ DiagnosticResult . CompilerError ( "CS9248" ) . WithSpan ( 32 , 27 , 32 , 32 ) . WithArguments ( "MyApp.SampleViewModel.Prop5" ) ,
510
524
} ) ;
511
525
512
526
await test . RunAsync ( ) ;
0 commit comments