codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

"Insert explicit access modifiers on properties" option removes the C#11 'required' keyword

Open mrecuerda opened this issue 1 year ago • 1 comments

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

  1. Create class with required property
internal class MyClass
{
    public required string Label { get; init; }
}
  1. Make sur option is opted-in: Cleaning -> Insert -> Insert explicit access modifiers on properties
  2. Format / Cleanup document

Current behavior

The required keyword is removed when cleaning the document.

Expected behavior

The required keyword should remain present.

mrecuerda avatar Sep 03 '22 17:09 mrecuerda

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.

codecadwallader avatar Sep 09 '22 12:09 codecadwallader