Skip to content

Commit aa9df8a

Browse files
committed
Fixed reporting for 'MVVMTK0052'
1 parent f080c60 commit aa9df8a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ public sealed class InvalidPartialPropertyLevelObservablePropertyAttributeAnalyz
2727
/// <inheritdoc/>
2828
public override void Initialize(AnalysisContext context)
2929
{
30-
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
30+
// This generator is intentionally also analyzing generated code, because Roslyn will interpret properties
31+
// that have '[GeneratedCode]' on them as being generated (and the same will apply to all partial parts).
32+
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
3133
context.EnableConcurrentExecution();
3234

3335
context.RegisterCompilationStartAction(static context =>

tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/Test_SourceGeneratorsDiagnostics.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,6 @@ public partial string Name
889889
}
890890

891891
[TestMethod]
892-
[Ignore("The symbol callback is not being triggered correctly (see https://github.com/dotnet/roslyn/issues/76166)")]
893892
public async Task InvalidPartialPropertyLevelObservablePropertyAttributeAnalyzer_OnImplementedProperty_GeneratedByAnotherGenerator_Warns()
894893
{
895894
const string source = """
@@ -913,8 +912,7 @@ public partial string Name
913912
}
914913
""";
915914

916-
// This test is having issues, let's invoke the analyzer directly to make it easier to narrow down the problem
917-
await CSharpAnalyzerWithLanguageVersionTest<InvalidPartialPropertyLevelObservablePropertyAttributeAnalyzer>.VerifyAnalyzerAsync(source, LanguageVersion.Preview);
915+
await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration<InvalidPartialPropertyLevelObservablePropertyAttributeAnalyzer>(source, LanguageVersion.Preview);
918916
}
919917

920918
[TestMethod]

0 commit comments

Comments
 (0)