codecadwallader / codemaid

CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
http://www.codemaid.net
GNU Lesser General Public License v3.0
1.89k stars 356 forks source link

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

Open mrecuerda opened 2 years ago

mrecuerda commented 2 years ago

Environment

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; }
    }
  2. Make sur option is opted-in: Cleaning -> Insert -> Insert explicit access modifiers on properties
  3. Format / Cleanup document

Current behavior

The required keyword is removed when cleaning the document.

Expected behavior

The required keyword should remain present.

codecadwallader commented 1 year ago

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.