-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repro of files requiring 2 passes of dotnet format to fully format #2086
Comments
Taking a look at the code that didn't fully format on the first pass. Adding braces did not always anchor correctly. This if statement did not get moved to a newline in the first pass, possibly because it is a single line. However, it became multi line when braces were added and is moved in the second pass. |
It appears the repository uses the following setting:
This setting, along with some other non-default settings, have almost no test coverage due to mathematical impossibility described in dotnet/roslyn#12306 (comment). We would likely accept a pull request to dotnet/roslyn to make the formatter work with a single pass, provided it did not result in an overly-complex implementation and included comprehensive test coverage for the alternative configurations. However, keep in mind that achieving these conditions may be exceedingly time consuming and generally impractical for most contributors. |
📝 If this issue reproduces inside Visual Studio using its Format Document operation, the issue needs to be moved to dotnet/roslyn. |
I don't use Visual Studio so can't test this How can this be a "mathematical impossibility", do you mean it's computationally expensive? so far my take away is that it would require infinite lookahead or something similar. |
We have at least 50 options in the C# formatting engine. If each of these options had only two values (some have more), and testing the complete format engine on all coding structures took 1ms (it takes many seconds today), it would take over 35000 years to test all the combinations. |
ah okay so you're saying testing is "impossible", not the option itself, that makes more sense |
here is my repro
https://github.com/float3/dotnet-format-repro
there are 2 cs files here that take two passes to fully format.
repro steps:
The text was updated successfully, but these errors were encountered: