microsoft / microsoft/garnet

Specify and enforce code-style using .editorconfig rules

Open
#142 5 comments 1 reaction 1 assignee Claimed by @TalZaccai View on GitHub
enhancement
Dominant language
C#
Stars
12k
Forks
703
Avg merge
2d 19h
Merged PRs (30d)
36

Description

I'm opening this issue to get some input from the maintainers on the possibility of having the projects code-style enforced with .editorconfig rules.

Code-style such as naming conventions are _very subjective_ and it would be nice if contributors could just do project wide ``dotnet format [--verify-no-changes]`` after doing their changes. This would reduce mental overhead of trying to deduce the correct naming for variables and fields (which are currently inconsistent, even across singular files in the project) and make future code reviews easier.

I'm most concerned about the inconsistency of the field and variable naming conventions and would like to suggest bumping all the ``dotnet_naming_rule.*.severity`` rules from ``suggestion`` to ``warning`` and then running ``dotnet format`` for the entire repository. This should avoid the manual work such as https://github.com/microsoft/garnet/pull/84.

#### Couple examples of naming inconsistencies

https://github.com/microsoft/garnet/blob/2aea8fb68f5c58e71652e31a2fafc216fb3e4be8/libs/storage/Tsavorite/cs/src/core/ClientSession/LockableContext.cs#L18-L19

https://github.com/microsoft/garnet/blob/2aea8fb68f5c58e71652e31a2fafc216fb3e4be8/libs/common/LightClient.cs#L31-L37

https://github.com/microsoft/garnet/blob/2aea8fb68f5c58e71652e31a2fafc216fb3e4be8/libs/storage/Tsavorite/cs/src/core/TsavoriteLog/TsavoriteLog.cs#L128-L150

Another thing that makes reading the code harder is the (inconsistenly) missing access and visibility modifiers from fields.

It's nice to see there is already effort to put into enforcing code-style already (see https://github.com/microsoft/garnet/pull/106 etc.) but the naming would be nice to get under control early on 😄

I am _myself_ big fan of [the .NET Runtime code-style](https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/coding-style.md) + file scoped namespaces (applying file scoped namespaces can be done with Visual Studio to the entire solution, but probably wise to time so that it would not cause big conflicts with inprogress PRs)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.