Open
Description
Describe the bug
If an ObservableProperty
is created in two ViewModels, a parent and child, then the parent property gets hidden and the warning is blocked from the user.
Regression
No response
Steps to reproduce
For this code:
public partial class ParentViewModel : ObservableObject
{
[ObservableProperty] private int _someValue;
public int AnotherValue { get; set; }
}
public partial class DerivedViewModel : ParentViewModel
{
[ObservableProperty] private int _someValue;
public int AnotherValue { get; set; }
}
The following warning is generated:
> 'DerivedViewModel.AnotherValue' hides inherited member 'ParentViewModel.AnotherValue'. Use the new keyword if hiding was intended.
Expected behavior
The following warning should also be generated:
'DerivedViewModel.SomeValue' hides inherited member 'ParentViewModel.SomeValue'. Use the new keyword if hiding was intended.
Screenshots
No response
IDE and version
VS 2022
IDE version
17.3.0
Nuget packages
- CommunityToolkit.Common
- CommunityToolkit.Diagnostics
- CommunityToolkit.HighPerformance
- CommunityToolkit.Mvvm (aka MVVM Toolkit)
Nuget package version(s)
8.0.0
Additional context
This is due to warnings being disabled with
#pragma warning disable
Fix options:
-
The pragma is enabled for this warning
- Pros: Warning might alert the user to unintended functionality
- Cons: User can't suppress the warning
-
Option 1 plus
ObservableProperty
is modified to accept a parameter that says whether hiding is desired- Pros: The warning is exposed and can be suppressed
- Cons: May not be worth the complication
Help us help you
Yes, I'd like to be assigned to work on this item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment