Skip to content

Commit f74269b

Browse files
committed
Fix formatting in '[ObservableProperty]' diagnostics
1 parent 171ba41 commit f74269b

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/UseObservablePropertyOnPartialPropertyAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public override void Initialize(AnalysisContext context)
7979
.Add(FieldReferenceForObservablePropertyFieldAnalyzer.FieldNameKey, fieldSymbol.Name)
8080
.Add(FieldReferenceForObservablePropertyFieldAnalyzer.PropertyNameKey, ObservablePropertyGenerator.Execute.GetGeneratedPropertyName(fieldSymbol)),
8181
fieldSymbol.ContainingType,
82-
fieldSymbol));
82+
fieldSymbol.Name));
8383
}, SymbolKind.Field);
8484
});
8585
}

tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4110.UnitTests/Test_UsePartialPropertyForObservablePropertyCodeFixer.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ partial class C : ObservableObject
5454
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
5555
test.ExpectedDiagnostics.AddRange(new[]
5656
{
57-
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
58-
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "C.i"),
57+
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
58+
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "i"),
5959
});
6060

6161
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -102,8 +102,8 @@ partial class C : ObservableObject
102102
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
103103
test.ExpectedDiagnostics.AddRange(new[]
104104
{
105-
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
106-
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "C.i"),
105+
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
106+
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "i"),
107107
});
108108

109109
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -152,8 +152,8 @@ partial class C : ObservableObject
152152
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
153153
test.ExpectedDiagnostics.AddRange(new[]
154154
{
155-
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
156-
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "C.i"),
155+
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
156+
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "i"),
157157
});
158158

159159
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -204,8 +204,8 @@ partial class C : ObservableObject
204204
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
205205
test.ExpectedDiagnostics.AddRange(new[]
206206
{
207-
// /0/Test0.cs(6,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
208-
CSharpCodeFixVerifier.Diagnostic().WithSpan(6, 6, 6, 24).WithArguments("C", "C.i"),
207+
// /0/Test0.cs(6,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
208+
CSharpCodeFixVerifier.Diagnostic().WithSpan(6, 6, 6, 24).WithArguments("C", "i"),
209209
});
210210

211211
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -275,8 +275,8 @@ public class TestAttribute(string text) : Attribute;
275275
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
276276
test.ExpectedDiagnostics.AddRange(new[]
277277
{
278-
// /0/Test0.cs(7,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
279-
CSharpCodeFixVerifier.Diagnostic().WithSpan(7, 6, 7, 24).WithArguments("C", "C.i"),
278+
// /0/Test0.cs(7,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
279+
CSharpCodeFixVerifier.Diagnostic().WithSpan(7, 6, 7, 24).WithArguments("C", "i"),
280280
});
281281

282282
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -323,8 +323,8 @@ partial class C : ObservableObject
323323
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
324324
test.ExpectedDiagnostics.AddRange(new[]
325325
{
326-
// /0/Test0.cs(6,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
327-
CSharpCodeFixVerifier.Diagnostic().WithSpan(6, 6, 6, 24).WithArguments("C", "C.i"),
326+
// /0/Test0.cs(6,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
327+
CSharpCodeFixVerifier.Diagnostic().WithSpan(6, 6, 6, 24).WithArguments("C", "i"),
328328
});
329329

330330
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -373,8 +373,8 @@ partial class C : ObservableObject
373373
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
374374
test.ExpectedDiagnostics.AddRange(new[]
375375
{
376-
// /0/Test0.cs(7,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
377-
CSharpCodeFixVerifier.Diagnostic().WithSpan(7, 6, 7, 24).WithArguments("C", "C.i"),
376+
// /0/Test0.cs(7,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
377+
CSharpCodeFixVerifier.Diagnostic().WithSpan(7, 6, 7, 24).WithArguments("C", "i"),
378378
});
379379

380380
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -427,8 +427,8 @@ partial class C : ObservableObject
427427
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
428428
test.ExpectedDiagnostics.AddRange(new[]
429429
{
430-
// /0/Test0.cs(9,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
431-
CSharpCodeFixVerifier.Diagnostic().WithSpan(9, 6, 9, 24).WithArguments("C", "C.i"),
430+
// /0/Test0.cs(9,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
431+
CSharpCodeFixVerifier.Diagnostic().WithSpan(9, 6, 9, 24).WithArguments("C", "i"),
432432
});
433433

434434
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -487,8 +487,8 @@ public void M()
487487
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
488488
test.ExpectedDiagnostics.AddRange(new[]
489489
{
490-
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
491-
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "C.i"),
490+
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
491+
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "i"),
492492
});
493493

494494
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -533,8 +533,8 @@ partial class C : ObservableObject
533533
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
534534
test.ExpectedDiagnostics.AddRange(new[]
535535
{
536-
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
537-
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "C.i"),
536+
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
537+
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "i"),
538538
});
539539

540540
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -584,8 +584,8 @@ partial class C : ObservableObject
584584
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
585585
test.ExpectedDiagnostics.AddRange(new[]
586586
{
587-
// /0/Test0.cs(6,6): info MVVMTK0042: The field C.C.items using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
588-
CSharpCodeFixVerifier.Diagnostic().WithSpan(6, 6, 6, 24).WithArguments("C", "C.items"),
587+
// /0/Test0.cs(6,6): info MVVMTK0042: The field C.items using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
588+
CSharpCodeFixVerifier.Diagnostic().WithSpan(6, 6, 6, 24).WithArguments("C", "items"),
589589
});
590590

591591
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -635,8 +635,8 @@ partial class C : ObservableObject
635635
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
636636
test.ExpectedDiagnostics.AddRange(new[]
637637
{
638-
// /0/Test0.cs(6,6): info MVVMTK0042: The field C.C.items using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
639-
CSharpCodeFixVerifier.Diagnostic().WithSpan(6, 6, 6, 24).WithArguments("C", "C.items"),
638+
// /0/Test0.cs(6,6): info MVVMTK0042: The field C.items using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
639+
CSharpCodeFixVerifier.Diagnostic().WithSpan(6, 6, 6, 24).WithArguments("C", "items"),
640640
});
641641

642642
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -685,8 +685,8 @@ partial class C : ObservableObject
685685
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
686686
test.ExpectedDiagnostics.AddRange(new[]
687687
{
688-
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.C.foo using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
689-
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "C.foo"),
688+
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.foo using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
689+
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "foo"),
690690
});
691691

692692
test.FixedState.ExpectedDiagnostics.AddRange(new[]
@@ -755,8 +755,8 @@ public void M()
755755
test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly);
756756
test.ExpectedDiagnostics.AddRange(new[]
757757
{
758-
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
759-
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "C.i"),
758+
// /0/Test0.cs(5,6): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well)
759+
CSharpCodeFixVerifier.Diagnostic().WithSpan(5, 6, 5, 24).WithArguments("C", "i"),
760760
});
761761

762762
test.FixedState.ExpectedDiagnostics.AddRange(new[]

0 commit comments

Comments
 (0)