belav / csharpier

CSharpier is an opinionated code formatter for c#.
https://csharpier.com
MIT License
1.43k stars 99 forks source link

CSharpier deletes arguments of primary constructor on struct #1067

Open superdweebie opened 11 months ago

superdweebie commented 11 months ago
public struct Test(string arg1)
{
    public string Arg1 { get; } = arg1;
}

becomes:

public struct Test
{
    public string Arg1 { get; } = arg1;
}
superdweebie commented 11 months ago

I've had to turn CSharpier off after migrating to .Net 8 due to this issue.

belav commented 11 months ago

Sorry about missing that primary constructor case, I can hopefully get a fix out today after work.

superdweebie commented 11 months ago

Thanks for sharing your work with the world. No stress from me.

belav commented 11 months ago

It looks like this did make it into 0.26.0, are you perhaps on an older version?

See https://github.com/belav/csharpier/issues/969

superdweebie commented 11 months ago

I installed via Visual Studio Extensions. It says I have version 1.4.8. It also says there are no updates available. Should I install via command line instead?

belav commented 11 months ago

The extension is versioned separately from CSharpier itself. People working on multiple projects with teams may have each project on a different version of csharpier.

You probably are using the version of CSharpier that was available when you installed the extension. Figuring out a way to show that info to the user and/or a way to update CSharpier from the extension has been on my list for a while but I haven't had time to get to it.

Assuming you have it installed globally you can run dotnet tool update -g csharpier Then restart the IDE, it caches some information about what version of csharpier to use for files in directories.