-
Notifications
You must be signed in to change notification settings - Fork 1.7k
AVRO-3384: Define C# Coding Style Guidelines #1534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
b8601c0
AVRO-3360 Updated XML documentation
d01699a
Revert "AVRO-3360 Updated XML documentation"
83093e1
Merge branch 'apache:master' into master
KyleSchoonover c992da4
Merge branch 'apache:master' into master
KyleSchoonover a99e652
AVRO-3384 Initial check in
759f088
Formatting fix
8383e3d
Additional formatting
c468c18
More formatting
38e3b4c
Added additional rule
56381b7
Completed new line rules
f235b3d
Indentation preferences complete
446affe
Updated header
0b9190e
Additional formatting
2b25fed
More formatting changes
2190042
Added spacing options
c7535da
Updated wrap options
9ffea5a
Additional documentation for styling
8057598
Updated notes
d3c7aa2
Updated more
62e05ad
Added var preferences and Expression-bodied member preferences
972728b
Initial styling rules documented
e8d5bde
Updated naming rules to reflect Roslyn naming rules
99f596f
Added other styling rule callouts.
8c9e9c3
Updated Readme
fa5f7c2
Merge branch 'apache:master' into master
KyleSchoonover 7ebc80e
Updated rule
6989e61
Merge branch 'apache:master' into master
KyleSchoonover 5b4202e
Add header template
93585f3
Microsoft has a bug for semicolon which makes this not work.
d06604a
Merge branch 'apache:master' into master
KyleSchoonover 2b39bb0
Merge branch 'apache:master' into master
KyleSchoonover f8a7611
Merge branch 'apache:master' into master
KyleSchoonover a5fa2ef
Merge branch 'apache:master' into master
KyleSchoonover 0216b4d
Merge branch 'apache:master' into master
KyleSchoonover d97a23c
Merge branch 'apache:master' into master
KyleSchoonover e1db956
Merge branch 'apache:master' into master
KyleSchoonover a72110e
Merge branch 'master' into AVRO-3384
KyleSchoonover ca978e4
Added license
KyleSchoonover 180c8cc
Added note about IDE0055
KyleSchoonover e586782
Merge branch 'apache:master' into master
KyleSchoonover 9ab3fb2
Merge branch 'apache:master' into master
KyleSchoonover 25378bb
Merge branch 'master' into AVRO-3384
KyleSchoonover File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| # C# Styling Rules for Apache.Avro | ||
|
|
||
| The following rules are currently used within the .editorconfig of the Avro solution. Any changes to this documentation should be reflected in the .editorconfig file and vice versa. | ||
|
|
||
| Note that the examples shown are based on the current settings in .editorconfig | ||
|
|
||
| ## New line preferences | ||
|
|
||
| ### csharp_new_line_before_open_brace | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_new_line_before_open_brace) | ||
|
|
||
| This rule concerns whether an open brace { should be placed on the same line as the preceding code, or on a new line. | ||
|
|
||
| **Example** | ||
| ``` | ||
| void MyMethod() | ||
| { | ||
| if (...) | ||
| { | ||
| ... | ||
| } | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_new_line_before_else | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_new_line_before_else) | ||
|
|
||
| **Example** | ||
| ``` | ||
| if (...) { | ||
| ... | ||
| } | ||
| else { | ||
| ... | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_new_line_before_catch | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_new_line_before_catch) | ||
|
|
||
| **Example** | ||
| ``` | ||
| try { | ||
| ... | ||
| } | ||
| catch (Exception e) { | ||
| ... | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_new_line_before_finally | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_new_line_before_finally) | ||
|
|
||
| **Example** | ||
| ``` | ||
| try { | ||
| ... | ||
| } | ||
| catch (Exception e) { | ||
| ... | ||
| } | ||
| finally { | ||
| ... | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_new_line_before_members_in_object_initializers | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_new_line_before_members_in_object_initializers) | ||
|
|
||
| **Example** | ||
| ``` | ||
| var z = new B() | ||
| { | ||
| A = 3, | ||
| B = 4 | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_new_line_before_members_in_anonymous_types | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_new_line_before_members_in_anonymous_types) | ||
|
|
||
| **Example** | ||
| ``` | ||
| var z = new | ||
| { | ||
| A = 3, | ||
| B = 4 | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_new_line_between_query_expression_clauses | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_new_line_between_query_expression_clauses) | ||
|
|
||
| **Example** | ||
| ``` | ||
| var q = from a in e | ||
| from b in e | ||
| select a * b; | ||
| ``` | ||
| --- | ||
|
|
||
| ## Indentation preferences | ||
|
|
||
| ### csharp_indent_case_contents | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_indent_case_contents) | ||
|
|
||
| **Example** | ||
| ``` | ||
| switch(c) { | ||
| case Color.Red: | ||
| Console.WriteLine("The color is red"); | ||
| break; | ||
| case Color.Blue: | ||
| Console.WriteLine("The color is blue"); | ||
| break; | ||
| default: | ||
| Console.WriteLine("The color is unknown."); | ||
| break; | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_indent_switch_labels | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_indent_switch_labels) | ||
|
|
||
| **Example** | ||
| ``` | ||
| switch(c) { | ||
| case Color.Red: | ||
| Console.WriteLine("The color is red"); | ||
| break; | ||
| case Color.Blue: | ||
| Console.WriteLine("The color is blue"); | ||
| break; | ||
| default: | ||
| Console.WriteLine("The color is unknown."); | ||
| break; | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_indent_labels | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_indent_labels) | ||
|
|
||
| Labels are placed at one less indent to the current context | ||
|
|
||
| **Example** | ||
| ``` | ||
| class C | ||
| { | ||
| private string MyMethod(...) | ||
| { | ||
| if (...) { | ||
| goto error; | ||
| } | ||
| error: | ||
| throw new Exception(...); | ||
| } | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_indent_block_contents | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_indent_block_contents) | ||
|
|
||
| **Example** | ||
| ``` | ||
| static void Hello() | ||
| { | ||
| Console.WriteLine("Hello"); | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_indent_braces | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_indent_braces) | ||
|
|
||
| **Example** | ||
| ``` | ||
| static void Hello() | ||
| { | ||
| Console.WriteLine("Hello"); | ||
| } | ||
| ``` | ||
| --- | ||
| ### csharp_indent_case_contents_when_block | ||
| [Reference](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#csharp_indent_case_contents_when_block) | ||
|
|
||
| **Example** | ||
| ``` | ||
| case 0: | ||
| { | ||
| Console.WriteLine("Hello"); | ||
| break; | ||
| } | ||
| ``` | ||
| --- | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.