CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
2.99k stars 294 forks source link

Generating of `[ObservableObject]` fails if interface is declared but not implemented #805

Open ShortDevelopment opened 10 months ago

ShortDevelopment commented 10 months ago

Describe the bug

If a class implements an interface that itself inherits INotifyPropertyChanged or INotifyPropertyChanging but does not implement the interface methods, code-generation aborts.

Current tests only test diagnostics for an implementation of INotifyPropertyChanged / INotifyPropertyChanging: https://github.com/CommunityToolkit/dotnet/blob/7b53ae23dfc6a7fb12d0fc058b89b6e948f48448/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs#L33-L37

Regression

No response

Steps to reproduce

interface IStuff : INotifyPropertyChanged {
   // ...
}

[ObservableObject]
class B : BaseClass, IStuff {
   // No implementation of INotifyPropertyChanged 
   // source generation
}

Expected behavior

The implementation of INotifyPropertyChanged should be generated.

Screenshots

No response

IDE and version

VS 2022

IDE version

No response

Nuget packages

Nuget package version(s)

8.2.2

Additional context

Similar to #620 but slightly different scenario

Help us help you

Yes, I'd like to be assigned to work on this item