Developers enjoy `dotnet format` UXs, in line with VS UXs
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 formatafterdotnet newto format the content - brings
dotnet newcloser 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
--langVersionparameter in SDK templates (?) - considering the feature behind feature flag (env var, option?)
Justification
- UX improvement: Avoids manual step of running
dotnet formatafter the template is run - UX homogeneity: feature parity to Visual Studio UX
- Aligns to .NET modernization OKRs
@baronfel / @JanKrivanek please feel free to put more info if needed
related: https://github.com/dotnet/templating/issues/4798; https://github.com/dotnet/templating/issues/1248
As mentioned in #4798:
The problem with that is that
dotnet formatdoesn't support files like .csproj .sln, .cshtml .razor, or other template files likeappsettings.json, etc.I wonder if
dotnet formatshould add support for basic EditorConfig formatting in all (most) file types.
I've opened https://github.com/dotnet/format/issues/1798.
Seems this is still triaged into 8.0. Can we look at this for an upcoming SDK release?
We should remove that assignment - we need to triage this again now that templating has moved teams.