Skip to content

Commit c9f242e

Browse files
authored
EditorConfig file added and documented (#203)
1 parent b9df3b9 commit c9f242e

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

Diff for: .editorconfig

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# EditorConfig for Visual Studio 2022: https://learn.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2022
2+
3+
# This is a top-most .editorconfig file
4+
root = true
5+
6+
#=====================================================
7+
#
8+
# Settings for all file types
9+
#
10+
#=====================================================
11+
[*]
12+
13+
# Generic EditorConfig settings
14+
indent_style = space
15+
indent_size = 4
16+
end_of_line = crlf
17+
charset = utf-8-bom
18+
trim_trailing_whitespace = true
19+
insert_final_newline = true
20+
21+
# Visual Studio spell checker
22+
spelling_languages = en-us
23+
spelling_checkable_types = strings,identifiers,comments
24+
spelling_error_severity = information
25+
spelling_exclusion_path = spelling_exclusion.dic

Diff for: content/contributing/cs-coding-style.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# C# Coding Style
1+
# C# Coding Style
22

33
For non code files (xml etc) our current best guidance is consistency. When editing files, keep new code and changes consistent with the style in the files. For new files, it should conform to the style for that component. Last, if there's a completely new component, anything that is reasonably broadly accepted is fine.
44

55
The general rule we follow is "use Visual Studio defaults". For details check the [Naming Guidelines](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/naming-guidelines) of .NET guide.
66

77
1. We use [Allman style](https://en.wikipedia.org/wiki/Indent_style#Allman_style) braces, where each brace begins on a new line. Even a single line statement block should go with braces and nested in other statement blocks that use braces.
88
2. We use four spaces of indentation (no tabs).
9-
3. We use `_camelCase` for internal and private fields and use `readonly` where possible. Prefix static fields can be used with `s_` and thread static fields with `t_`. When used on static fields, `readonly` should come after `static` (i.e. `static readonly` not `readonly static`).
9+
3. We use `_camelCase` for internal and private fields and use `readonly` where possible. Prefix static fields with `s_` and thread static fields with `t_`. When used on static fields, `readonly` should come after `static` (i.e. `static readonly` not `readonly static`).
1010
4. We avoid `this.` unless absolutely necessary.
1111
5. We always specify the visibility, even if it's the default (i.e.
1212
`private string _foo` not `string _foo`). Visibility should be the first modifier (i.e.
@@ -32,7 +32,9 @@ The general rule we follow is "use Visual Studio defaults". For details check th
3232
18. Don't forget the header, the 2 lines simplified version can be used.
3333
19. Try to avoid abbreviation, always use longer names when possible and where it does make sense. It is acceptable for very known ones to use them like HTTP for example. Also, if using abbreviations, the names should follow the the pattern. For example, if you are using `HTTP` in a name of a function called `Something`, it will then be `HttpSomething`. This goes as well for namespaces, classes, properties, variable names.
3434

35-
We have provided a Visual Studio 2013 vssettings file `nnnnn.vssettings` at the root of each repository, enabling C# auto-formatting conforming to the above guidelines. Note that rules 7 and 8 are not covered by the vssettings, since these are not rules currently supported by VS formatting.
35+
We have provided an EditorConfig file `.editorconfig` at the root of each repository that contains the code style rules. If a repository does not yet have the `.editorconfig` file, it should be copied from the project source [here](https://github.com/nanoframework/.github/blob/main/VS%20templates%2Bconfig/.editorconfig). Which should be kept up to date. Note that there is also a spelling exclusion file along with it: spelling_exclusion.dic.
36+
37+
The EditorConfig also configures the Visual Studio spell checker. The spell checker is not enabled by default; it can be turned on/off by a button on the toolbar (the button with text *abc* and a green checkmark) or via the menu *Edit | Advanced | Toggle Spell Checker*. At the moment it can analyse the C#, C++ and markdown files that are open in he IDE. Code files typically contain jargon that is not recognised, e.g., the name of a communication protocol. If the spell checker flags such a word, choose to ignore it. The word will be added to the `spelling_exclusion.dic` file at the root of the repository.
3638

3739
## Example File
3840

Diff for: spelling_exclusion.dic

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nano
2+
intellisense
3+
nanoff

0 commit comments

Comments
 (0)