CommunityToolkit / CommunityToolkit/dotnet
Consider CLS-compliancy
- Dominant language
- C#
- Stars
- 3.8k
- Forks
- 400
- PR merge metrics
- No merged PRs in 30d
Description
### Overview
Currently we have (among others) following properties set in our `Directory.Build.props`:
```xml
AllEnabledByDefault
true
```
Due to [`CA1014`](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1014), we've marked our assemblies with
```csharp
[assembly: CLSCompliant(true)]
```
This we do not want to change.
Previously we've made use of code generation and marked our viewmodels with the `ObservableObjectAttribute`. However, with the newest version, this triggers the analyzer `MVVMTK0033` ("The type XXX is using the [ObservableObject] attribute while having no base type, and it should instead inherit from ObservableObject").
If we follow this advice and inherit from `ObservableObject`, the analyzer [`CS3009`](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs3009) triggers because even tho the class is technically compliant with the common language specification, it is not marked as such.
### API breakdown
I would like to propose marking either the whole assembly as `CLSCompliant` or (at least) marking `ObservableObject` as such.
### Usage example
```csharp
public sealed partial class MyViewModel : ObservableObject {
...
}
```
### Breaking change?
No
### Alternatives
```csharp
[ObservableObject]
#pragma warning disable MVVMTK0033
public sealed partial class MyViewModel {
#pragma warning restore MVVMTK0033
...
}
```
### Additional context
Thank you in advance for considering the inclusion of this.
### Help us help you
Yes, but only if others can assist
Contributor guide
Assessment
This issue has not been assessed yet.