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.88k stars 352 forks source link

Formatting Removes `file` and `required` keywords #1030

Closed Mike-Logit closed 7 months ago

Mike-Logit commented 7 months ago

Environment

Description

When I run the CodeMaid Format Document command, it removes the newer keywords. I have seen some issues raised about the removal of the required keyword but for me it also removes the file keyword (the newer access modifier). This seems like a problem with reverting to older C# language levels by avoiding these newer keywords.

Steps to recreate

  1. Set your C# language level to 12
  2. Add this code in any C# project:
file class Test
{
    public required string Name { get; set; }
}
  1. Run the CodeMaid formatter

Current behavior

CodeMaid removes the file keyword for internal, and also strips out the required keyword after formatting:

BEFORE FORMATTING: image

AFTER FORMATTING: image

Expected behavior

I want to use the newer file access modifier to scope classes by file instead of scoping them by project, like the internal access modifier does. I also want to maintain the required keyword.

Mike-Logit commented 7 months ago

Sorry, I found another issue that covers this for file: https://github.com/codecadwallader/codemaid/issues/1023 I'm sure I've seen one for required as well so I can close this issue.

Mike-Logit commented 7 months ago

In case anyone lands on this page, the workaround worked for me: https://github.com/codecadwallader/codemaid/issues/879#issuecomment-1381429250

ashrafsabrym commented 2 months ago

Why is this issue closed? The problem still occurs