Closed paulirwin closed 7 months ago
Wouldn't it be easier to select the target the C# Version and then to apply all the features available in this version instead of opting in or out from the many features individually?
I've had to work on codebases with the latest C# features but can't use file-scoped namespaces yet because of the amount of files to convert. I think it should still be an option for now.
In Visual Studio you can apply a suggested code fix to the current Document, the whole Project or the whole Solution at once.
@OJacot-Descombes Yep, I'm not saying that doing the actual conversion to file-scoped namespaces would be difficult (Rider supports this as well), I mean that submitting a PR for a few hundred/thousand files where each file touched has almost every line in the file modified would in some projects raise some eyebrows as unnecessary noise and would require team buy-in to adopt that style. Just because you're using the latest version of C#, that doesn't mean that you are using every feature like this.
I would like to consider evaluating whether it's feasible to have EditorConfig support one day. Not sure what that looks like, but that would handle matching the existing codebase's style for things like file-scoped namespaces, whitespace, etc. If anyone felt strongly about adding that I'd welcome a contribution.
I think in a future release I'll make file-scoped namespaces on by default; for now it's easy enough to toggle.
Add an option to output the C# with a file-scoped namespace instead of a classic namespace.