Skip to content

Commit 41dabab

Browse files
authored
VSCode update editor config (#1668)
1 parent 8389b04 commit 41dabab

File tree

4 files changed

+209
-10
lines changed

4 files changed

+209
-10
lines changed

.editorconfig

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
# .NET coding convention settings for EditorConfig
3+
# https://learn.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference
4+
#
5+
# This file was taken from PowerShell/PowerShell 2024-07-13
6+
# https://github.com/PowerShell/PowerShell/blob/master/.editorconfig
7+
8+
# Top-most EditorConfig file
9+
root = true
10+
11+
[*]
12+
charset = utf-8
13+
# indent_size intentionally not specified in this section
14+
indent_style = space
15+
insert_final_newline = true
16+
17+
# Source code
18+
[*.{cs,ps1,psd1,psm1}]
19+
indent_size = 4
20+
21+
# Shell scripts
22+
[*.sh]
23+
end_of_line = lf
24+
indent_size = 4
25+
26+
# Xml project files
27+
[*.{csproj,resx,ps1xml}]
28+
indent_size = 2
29+
30+
# Data serialization
31+
[*.{json,yaml,yml}]
32+
indent_size = 2
33+
34+
# Markdown
35+
[*.md]
36+
indent_size = 2
37+
38+
# Xml files
39+
[*.{resx,ruleset,stylecop,xml,xsd,xsl}]
40+
indent_size = 2
41+
42+
# Xml config files
43+
[*.{props,targets,config,nuspec}]
44+
indent_size = 2
45+
46+
[*.tsv]
47+
indent_style = tab
48+
49+
# Dotnet code style settings:
50+
[*.cs]
51+
# Sort using and Import directives with System.* appearing first
52+
dotnet_sort_system_directives_first = true
53+
54+
file_header_template = Copyright (c) Microsoft Corporation.\nLicensed under the MIT License.
55+
56+
# Modifier preferences
57+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
58+
59+
# Avoid "this." and "Me." if not necessary
60+
dotnet_style_qualification_for_field = false:suggestion
61+
dotnet_style_qualification_for_property = false:suggestion
62+
dotnet_style_qualification_for_method = false:suggestion
63+
dotnet_style_qualification_for_event = false:suggestion
64+
65+
# Use language keywords instead of framework type names for type references
66+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
67+
dotnet_style_predefined_type_for_member_access = true:suggestion
68+
69+
# Name all constant fields using PascalCase
70+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
71+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
72+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
73+
74+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
75+
dotnet_naming_symbols.constant_fields.required_modifiers = const
76+
77+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
78+
79+
# Static fields should have s_ prefix
80+
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
81+
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
82+
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
83+
84+
dotnet_naming_symbols.static_fields.applicable_kinds = field
85+
dotnet_naming_symbols.static_fields.required_modifiers = static
86+
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
87+
88+
dotnet_naming_style.static_prefix_style.required_prefix = s_
89+
dotnet_naming_style.static_prefix_style.capitalization = camel_case
90+
91+
# Internal and private fields should be _camelCase
92+
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
93+
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
94+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
95+
96+
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
97+
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
98+
99+
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
100+
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
101+
102+
# Suggest more modern language features when available
103+
dotnet_style_object_initializer = true:suggestion
104+
dotnet_style_collection_initializer = true:suggestion
105+
dotnet_style_coalesce_expression = true:suggestion
106+
dotnet_style_null_propagation = true:suggestion
107+
dotnet_style_explicit_tuple_names = true:suggestion
108+
dotnet_style_readonly_field = true:suggestion
109+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
110+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
111+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
112+
dotnet_style_prefer_conditional_expression_over_return = true:silent
113+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
114+
dotnet_style_prefer_auto_properties = true:suggestion
115+
csharp_prefer_simple_default_expression = true:suggestion
116+
117+
dotnet_code_quality_unused_parameters = non_public:suggestion
118+
119+
# CSharp code style settings:
120+
[*.cs]
121+
122+
csharp_preserve_single_line_blocks = true
123+
csharp_preserve_single_line_statements = false
124+
csharp_prefer_braces = true:silent
125+
126+
csharp_prefer_static_local_function = true:suggestion
127+
csharp_prefer_simple_using_statement = false:none
128+
csharp_style_prefer_switch_expression = true:suggestion
129+
csharp_style_prefer_range_operator = false:none
130+
csharp_style_prefer_index_operator = false:none
131+
csharp_style_pattern_local_over_anonymous_function = false:none
132+
133+
csharp_using_directive_placement = outside_namespace:suggestion
134+
135+
# Indentation preferences
136+
csharp_indent_block_contents = true
137+
csharp_indent_braces = false
138+
csharp_indent_case_contents = true
139+
csharp_indent_case_contents_when_block = true
140+
csharp_indent_switch_labels = true
141+
csharp_indent_labels = one_less_than_current
142+
143+
# Only use var when it's obvious what the variable type is
144+
csharp_style_var_for_built_in_types = false:none
145+
csharp_style_var_when_type_is_apparent = false:none
146+
csharp_style_var_elsewhere = false:suggestion
147+
148+
# Expression-bodied members
149+
csharp_style_expression_bodied_local_functions = true:silent
150+
151+
# Prefer method-like constructs to have a block body
152+
csharp_style_expression_bodied_methods = false:none
153+
csharp_style_expression_bodied_constructors = false:none
154+
csharp_style_expression_bodied_operators = false:none
155+
156+
# Prefer property-like constructs to have an expression-body
157+
csharp_style_expression_bodied_properties = true:none
158+
csharp_style_expression_bodied_indexers = true:none
159+
csharp_style_expression_bodied_accessors = true:none
160+
161+
# Suggest more modern language features when available
162+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
163+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
164+
csharp_style_inlined_variable_declaration = true:suggestion
165+
csharp_style_throw_expression = true:suggestion
166+
csharp_style_conditional_delegate_call = true:suggestion
167+
168+
# Space preferences
169+
csharp_space_after_cast = false
170+
csharp_space_after_colon_in_inheritance_clause = true
171+
csharp_space_after_comma = true
172+
csharp_space_after_dot = false
173+
csharp_space_after_keywords_in_control_flow_statements = true
174+
csharp_space_after_semicolon_in_for_statement = true
175+
csharp_space_around_binary_operators = before_and_after
176+
csharp_space_around_declaration_statements = do_not_ignore
177+
csharp_space_before_colon_in_inheritance_clause = true
178+
csharp_space_before_comma = false
179+
csharp_space_before_dot = false
180+
csharp_space_before_open_square_brackets = false
181+
csharp_space_before_semicolon_in_for_statement = false
182+
csharp_space_between_empty_square_brackets = false
183+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
184+
csharp_space_between_method_call_name_and_opening_parenthesis = false
185+
csharp_space_between_method_call_parameter_list_parentheses = false
186+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
187+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
188+
csharp_space_between_method_declaration_parameter_list_parentheses = false
189+
csharp_space_between_parentheses = false
190+
csharp_space_between_square_brackets = false
191+
192+
# Newline settings
193+
csharp_new_line_before_open_brace = all
194+
csharp_new_line_before_else = true
195+
csharp_new_line_before_catch = true
196+
csharp_new_line_before_finally = true
197+
csharp_new_line_before_members_in_object_initializers = true
198+
csharp_new_line_before_members_in_anonymous_types = true
199+
csharp_new_line_between_query_expression_clauses = true

.vscode/extensions.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
44
// List of extensions which should be recommended for users of this workspace.
55
"recommendations": [
6+
"EditorConfig.EditorConfig",
7+
"ms-dotnettools.csdevkit",
68
"ms-dotnettools.csharp",
7-
"ms-vscode.powershell-preview",
8-
"patcx.vscode-nuget-gallery",
9-
"fudge.auto-using"
9+
"ms-vscode.powershell",
10+
"patcx.vscode-nuget-gallery"
1011
],
1112
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
12-
"unwantedRecommendations": [
13-
"ms-vscode.powershell"
14-
]
15-
}
13+
"unwantedRecommendations": []
14+
}

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"console": "externalTerminal",
1818
"stopAtEntry": false,
1919
"logging": {
20-
"engineLogging": false,
20+
"logging.diagnosticsLog.protocolMessages": false,
2121
"moduleLoad": false,
2222
"exceptions": false,
2323
"browserStdOut": false
@@ -30,4 +30,4 @@
3030
"processId": "${command:pickProcess}"
3131
}
3232
]
33-
}
33+
}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"csharp.semanticHighlighting.enabled": true,
3+
"dotnet.automaticallyCreateSolutionInWorkspace": false,
34
"omnisharp.enableEditorConfigSupport": true,
45
"omnisharp.enableRoslynAnalyzers": true
5-
}
6+
}

0 commit comments

Comments
 (0)