sandrohanea / whisper.net

Whisper.net. Speech to text made simple using Whisper Models
MIT License
505 stars 77 forks source link

feat: add pre-commit hook and format all files #193

Open NripeshN opened 2 months ago

sandrohanea commented 2 months ago

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?

NripeshN commented 2 months ago

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?

sandrohanea commented 2 months ago

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 commented 2 months ago

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

NripeshN commented 1 month ago

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.

sandrohanea commented 1 month ago

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#.