whisper.net icon indicating copy to clipboard operation
whisper.net copied to clipboard

feat: add pre-commit hook and format all files

Open NripeshN opened this issue 9 months ago • 6 comments

NripeshN avatar May 04 '24 17:05 NripeshN

In general, I prefer and wrote new lines before open brace: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options#csharp_new_line_before_open_brace

Can we keep that rule, so that the PR will be easier to review and be consistent with the way how the code was written?

sandrohanea avatar May 05 '24 17:05 sandrohanea

In general, I prefer and wrote new lines before open brace: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options#csharp_new_line_before_open_brace

Can we keep that rule, so that the PR will be easier to review and be consistent with the way how the code was written?

@sandrohanea Does it seem fine now?

NripeshN avatar May 05 '24 20:05 NripeshN

In general, I prefer and wrote new lines before open brace: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options#csharp_new_line_before_open_brace Can we keep that rule, so that the PR will be easier to review and be consistent with the way how the code was written?

@sandrohanea Does it seem fine now?

Thanks for the quick fix and answer. It's still strange that a lot of changes for spacing are generated and if pressing format (Ctrl + K + D ) in Visual Studio will format it the default way for C# (4 spaces instead of tab, etc).

Is it possible to configure this format to use the same format as default VS and not generate changes when Ctrl + K + D will be pressed in VS?

sandrohanea avatar May 05 '24 21:05 sandrohanea

It's not only about the 4 spaces, but these changes are generated as well from VS vs the clang-format:

image image image

CC: @NripeshN

sandrohanea avatar May 05 '24 21:05 sandrohanea

Thanks for the quick fix and answer. It's still strange that a lot of changes for spacing are generated and if pressing format (Ctrl + K + D ) in Visual Studio will format it the default way for C# (4 spaces instead of tab, etc).

Is it possible to configure this format to use the same format as default VS and not generate changes when Ctrl + K + D will be pressed in VS?

We can create a .clang-format file as per our liking and making VS use that. By default, Visual Studio will use any existing ClangFormat file in your source tree for formatting operations. I am not exactly sure the exact format you'd like but maybe we can start of with an empty file which would use the default pre-commit formatting.

NripeshN avatar May 13 '24 08:05 NripeshN

I would like the default C# formatting as this is mostly a C# repository. Visual Studio is using .editorconfig file for this which we already have. I don't like the idea of having a duplication of formatting rules in both formats unless we'll have a clear benefit. Probably clang-format is not the best tool for this job, and we should use just dotnet format instead that is already configured on the solution and is focused on C#.

sandrohanea avatar May 13 '24 09:05 sandrohanea