templating icon indicating copy to clipboard operation
templating copied to clipboard

Developers enjoy `dotnet format` UXs, in line with VS UXs

Open vlada-shubina opened this issue 1 year ago • 5 comments

Background

After the template is generated by dotnet new, it might not match formatting defined in .editorconfig in the output location. Visual Studio applies .editorconfig rules to generated files, making behavior different Audience: users

Technical details

Raw thoughts

  • optionally run dotnet format after dotnet new to format the content
  • brings dotnet new closer to Visual Studio behavior
  • respect global and local (repo) editorconfig
  • this allows to set the preference on language features as: top-level statements, namespaces etc
  • performance might be an issue
    • consider sharing the result of MSBuild evaluation to dotnet format if performed
  • may remove the need of supporting --langVersion parameter in SDK templates (?)
  • considering the feature behind feature flag (env var, option?)

Justification

  • UX improvement: Avoids manual step of running dotnet format after the template is run
  • UX homogeneity: feature parity to Visual Studio UX
  • Aligns to .NET modernization OKRs

vlada-shubina avatar Oct 25 '22 15:10 vlada-shubina

@baronfel / @JanKrivanek please feel free to put more info if needed

vlada-shubina avatar Oct 25 '22 15:10 vlada-shubina

related: https://github.com/dotnet/templating/issues/4798; https://github.com/dotnet/templating/issues/1248

vlada-shubina avatar Oct 25 '22 15:10 vlada-shubina

As mentioned in #4798:

The problem with that is that dotnet format doesn't support files like .csproj .sln, .cshtml .razor, or other template files like appsettings.json, etc.

I wonder if dotnet format should add support for basic EditorConfig formatting in all (most) file types.


I've opened https://github.com/dotnet/format/issues/1798.

glen-84 avatar Aug 25 '23 17:08 glen-84

Seems this is still triaged into 8.0. Can we look at this for an upcoming SDK release?

DamianEdwards avatar Jan 18 '24 19:01 DamianEdwards

We should remove that assignment - we need to triage this again now that templating has moved teams.

baronfel avatar Jan 18 '24 19:01 baronfel