CommunityToolkit / CommunityToolkit/dotnet
Properties generated from private fields do not conflict/trigger CS0108 or any other warning
- Dominant language
- C#
- Stars
- 3.8k
- Forks
- 400
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug
Given two types, where one is derived from the other, adding a private field to the derived type with the same name as a private field on the base type will generate a property on each type's generated partial definition. Because code analysis is disabled on these generated files, no indication is given that the property on the derived type is hiding the property on the base type.
### Regression
_No response_
### Steps to reproduce
The following code should demonstrate the problem:
```csharp
public class TypeA : ObservableObject
{
[ObservableProperty]
private bool _someField; // will generate TypeA.SomeField
}
public class TypeB : TypeA
{
[ObservableProperty]
private bool _someField; // will generate TypeB.SomeField, hiding TypeA.SomeField
}
```
### Expected behavior
Some indication should be given that TypeB._someField causes hiding of the property generated for TypeA, either CS0108 on the field or some MVVM specific warning that explains exactly what is happening.
### Screenshots
_No response_
### IDE and version
VS 2022
### IDE version
17.13.6
### Nuget packages
- [ ] CommunityToolkit.Common
- [ ] CommunityToolkit.Diagnostics
- [ ] CommunityToolkit.HighPerformance
- [x] CommunityToolkit.Mvvm (aka MVVM Toolkit)
### Nuget package version(s)
8.4.0
### Additional context
_No response_
### Help us help you
No, just wanted to report this
Contributor guide
Assessment
This issue has not been assessed yet.