codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

C# 10 'required' keyword not preserved during cleanup

Open JustinMinnaar opened this issue 2 years ago • 36 comments

Environment

  • Visual Studio version: 2022 Community
  • CodeMaid version: latest
  • Code language: C#

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

JustinMinnaar avatar Nov 18 '22 06:11 JustinMinnaar

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

codecadwallader avatar Dec 11 '22 17:12 codecadwallader

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

RichardSinden avatar Dec 16 '22 09:12 RichardSinden

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.

tfadler avatar Jan 04 '23 23:01 tfadler

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

Mayron avatar Oct 12 '23 19:10 Mayron

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; }

danh955 avatar Dec 02 '23 00:12 danh955

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

pthivierge-sayona avatar Feb 01 '24 19:02 pthivierge-sayona

any progress on this?

codehunter13 avatar Feb 19 '24 17:02 codehunter13

also waiting on an update for this issue

ph-mosadex avatar Mar 15 '24 12:03 ph-mosadex

Same too

GiaNTizmO avatar Mar 27 '24 15:03 GiaNTizmO

+1

ArturAdam avatar May 16 '24 08:05 ArturAdam

+1

alexandermlharris avatar May 28 '24 08:05 alexandermlharris

+1

mrukas avatar Jun 11 '24 14:06 mrukas

+1

unzeitip avatar Jun 17 '24 10:06 unzeitip

+1

Bush-cat avatar Jul 11 '24 09:07 Bush-cat

Any update on this?

jlanzarotta avatar Jul 17 '24 14:07 jlanzarotta