codemaid
codemaid copied to clipboard
"Insert explicit access modifiers on properties" option removes the C#11 'required' keyword
Environment
- Visual Studio version: 2022 Community Preview
- CodeMaid version: 12.0.300
- Code language: C#
Description
When activating "Insert explicit access modifiers on properties", the C# 11 required
keyword is removed.
Steps to recreate
- Create class with required property
internal class MyClass
{
public required string Label { get; init; }
}
- Make sur option is opted-in: Cleaning -> Insert -> Insert explicit access modifiers on properties
- Format / Cleanup document
Current behavior
The required
keyword is removed when cleaning the document.
Expected behavior
The required
keyword should remain present.
Thanks for reporting the issue. There is a known issue with the SDK that underlies the access modifiers which is causing a lot of issues. Please see #879 for more details and a link to the Roslyn SDK issue. The recommended workaround for now is to disable inserting explicit access modifiers.