dotnet / format

Home for the dotnet-format command
MIT License
1.92k stars 173 forks source link

Support deterministic formatting #879

Open ivanivanyuk1993 opened 3 years ago

ivanivanyuk1993 commented 3 years ago

Is there a way to run formatter deterministically, ignoring all current formatting and letting machine make all formatting decisions, something like https://github.com/google/google-java-format or https://github.com/prettier/prettier

If there isn't, please add it

laktak commented 3 years ago

Yes, please. This would also help with the strange way some brace formatting is completely ignored at the moment.

For example the following is not reformatted at all:

    private static readonly string[] Summaries1 = new[]
  {
      "Freezing", "Bracing", "Chilly"
    };
    private static readonly string[] Summaries2 = new[]
      {
            "Freezing", "Bracing", "Chilly"
                };
JoeRobich commented 3 years ago

Currently we rely on the Roslyn formatter and the Roslyn formatter does not format all types of expressions. For instance, Collection initializers are not formatted because Roslyn doesn't provide formatting options to express all the different requested formatting styles.

With that said, there is a lot of interested in an opinionated formatter that provides consistency instead of configurability (see https://github.com/dotnet/format/issues/246#issuecomment-606087638).