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 353 forks source link

C# 10 'required' keyword not preserved during cleanup #956

Open JustinMinnaar opened 1 year ago

JustinMinnaar commented 1 year ago

Environment

Description

The keyword 'required' is deleted when doing a cleanup.

    public class JProfileIdentifierResult
    {
        public override string ToString() => $"Theory:'{Theory}' Score:'{Score}'";

        public required JProfileIdentifier Identifier { get; init; }
        public required CTheory Theory { get; init; }
        public double Score { get; init; }
    }

Steps to recreate

Set your project to use C# 10 Create a property using the required keyword. Perform a cleanup

codecadwallader commented 1 year ago

Thanks for reporting the issue. There has been a number of SDK issues related to access modifiers and I'm curious if this one is similarly affected. If you disable CodeMaid's option CodeMaid->Options->Cleaning->Insert->Insert explicit access modifiers on properties does that bypass the issue? Related issue #879

RichardSinden commented 1 year ago

I just came across the issue too. Disabling that option does bypass the issue for me.

tfadler commented 1 year ago

Agreed disabling does bypass the issue.

I was spiking with the "file" access modifier and there is a similar problem with it. It changes it to internal.

I had to disable the same setting but for classes.

Not as big of a deal since file access modifier actual use will be rare for most, but I figured I would mention it.

Mayron commented 9 months ago

Thanks, had this issue for a while and finally found this page. Disabling that option fixed the problem but hopefully it'll get fixed soon because its hard to recommend the extension to my fellow devs who never check settings and religiously follow whatever the extension does lol

danh955 commented 7 months ago

Thanks. This works for me. I had formatted the Blazor code and the required keyword gets removed.

[Parameter] public required TicTacToePlayer Player { get; set; }
[Inject] public required TicTacToeEngine Engine { get; set; }
pthivierge-sayona commented 5 months ago

same happened to me. workaround works but still a problem.

codehunter13 commented 5 months ago

any progress on this?

ph-mosadex commented 4 months ago

also waiting on an update for this issue

GiaNTizmO commented 4 months ago

Same too

ArturAdam commented 2 months ago

+1

alexandermlharris commented 1 month ago

+1

mrukas commented 1 month ago

+1

unzeitip commented 1 month ago

+1

Bush-cat commented 2 weeks ago

+1

jlanzarotta commented 1 week ago

Any update on this?