codecadwallader/codemaid

Formatting Removes `file` and `required` keywords

Mike-Logit opened this issue · 3 comments

Environment

  • Visual Studio version: 2022 Professional, 17.8.1
  • CodeMaid version: [example 12.0]
  • Code language: C# 12

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.

Sorry, I found another issue that covers this for file: #1023
I'm sure I've seen one for required as well so I can close this issue.

In case anyone lands on this page, the workaround worked for me:
#879 (comment)

Why is this issue closed? The problem still occurs