Skip to content

Commit 7b7283c

Browse files
Add .editorConfig and fix format (#21)
* fix format * format sk sample
1 parent 915b5dc commit 7b7283c

File tree

12 files changed

+419
-21
lines changed

12 files changed

+419
-21
lines changed

.editorConfig

+347
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,347 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Don't use tabs for indentation.
7+
[*]
8+
indent_style = space
9+
# (Please don't specify an indent_size here; that has too many unintended consequences.)
10+
11+
# Code files
12+
[*.{cs,csx,vb,vbx}]
13+
indent_size = 4
14+
insert_final_newline = true
15+
charset = utf-8-bom
16+
17+
# XML project files
18+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
19+
indent_size = 2
20+
21+
# XML config files
22+
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
23+
indent_size = 2
24+
25+
# JSON files
26+
[*.json]
27+
indent_size = 2
28+
insert_final_newline = true
29+
30+
# Powershell files
31+
[*.ps1]
32+
indent_size = 2
33+
34+
# Shell script files
35+
[*.sh]
36+
end_of_line = lf
37+
indent_size = 2
38+
39+
# Dotnet code style settings:
40+
[*.{cs,vb}]
41+
42+
# IDE0055: Fix formatting
43+
dotnet_diagnostic.IDE0055.severity = warning
44+
45+
# Sort using and Import directives with System.* appearing first
46+
dotnet_sort_system_directives_first = true
47+
dotnet_separate_import_directive_groups = false
48+
# Avoid "this." and "Me." if not necessary
49+
dotnet_style_qualification_for_field = false:refactoring
50+
dotnet_style_qualification_for_property = false:refactoring
51+
dotnet_style_qualification_for_method = false:refactoring
52+
dotnet_style_qualification_for_event = false:refactoring
53+
54+
# Use language keywords instead of framework type names for type references
55+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
56+
dotnet_style_predefined_type_for_member_access = true:suggestion
57+
58+
# Suggest more modern language features when available
59+
dotnet_style_object_initializer = true:suggestion
60+
dotnet_style_collection_initializer = true:suggestion
61+
dotnet_style_coalesce_expression = true:suggestion
62+
dotnet_style_null_propagation = true:suggestion
63+
dotnet_style_explicit_tuple_names = true:suggestion
64+
65+
# Whitespace options
66+
dotnet_style_allow_multiple_blank_lines_experimental = false
67+
68+
# Non-private static fields are PascalCase
69+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion
70+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields
71+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style
72+
73+
dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field
74+
dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
75+
dotnet_naming_symbols.non_private_static_fields.required_modifiers = static
76+
77+
dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case
78+
79+
# Non-private readonly fields are PascalCase
80+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion
81+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
82+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style
83+
84+
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
85+
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
86+
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
87+
88+
dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case
89+
90+
# Constants are PascalCase
91+
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
92+
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
93+
dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style
94+
95+
dotnet_naming_symbols.constants.applicable_kinds = field, local
96+
dotnet_naming_symbols.constants.required_modifiers = const
97+
98+
dotnet_naming_style.constant_style.capitalization = pascal_case
99+
100+
# Static fields are camelCase and start with s_
101+
dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion
102+
dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields
103+
dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style
104+
105+
dotnet_naming_symbols.static_fields.applicable_kinds = field
106+
dotnet_naming_symbols.static_fields.required_modifiers = static
107+
108+
dotnet_naming_style.static_field_style.capitalization = camel_case
109+
dotnet_naming_style.static_field_style.required_prefix = s_
110+
111+
# Instance fields are camelCase and start with _
112+
dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion
113+
dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields
114+
dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style
115+
116+
dotnet_naming_symbols.instance_fields.applicable_kinds = field
117+
118+
dotnet_naming_style.instance_field_style.capitalization = camel_case
119+
dotnet_naming_style.instance_field_style.required_prefix = _
120+
121+
# Locals and parameters are camelCase
122+
dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion
123+
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
124+
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
125+
126+
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
127+
128+
dotnet_naming_style.camel_case_style.capitalization = camel_case
129+
130+
# Local functions are PascalCase
131+
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion
132+
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
133+
dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style
134+
135+
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
136+
137+
dotnet_naming_style.local_function_style.capitalization = pascal_case
138+
139+
# By default, name items with PascalCase
140+
dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion
141+
dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
142+
dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style
143+
144+
dotnet_naming_symbols.all_members.applicable_kinds = *
145+
146+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
147+
148+
# error RS2008: Enable analyzer release tracking for the analyzer project containing rule '{0}'
149+
dotnet_diagnostic.RS2008.severity = none
150+
151+
# IDE0073: File header
152+
dotnet_diagnostic.IDE0073.severity = warning
153+
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.\nSee the LICENSE file in the project root for more information.
154+
155+
# IDE0035: Remove unreachable code
156+
dotnet_diagnostic.IDE0035.severity = warning
157+
158+
# IDE0036: Order modifiers
159+
dotnet_diagnostic.IDE0036.severity = warning
160+
161+
# IDE0043: Format string contains invalid placeholder
162+
dotnet_diagnostic.IDE0043.severity = warning
163+
164+
# IDE0044: Make field readonly
165+
dotnet_diagnostic.IDE0044.severity = warning
166+
167+
# RS0016: Only enable if API files are present
168+
dotnet_public_api_analyzer.require_api_files = true
169+
170+
# CSharp code style settings:
171+
[*.cs]
172+
# Newline settings
173+
csharp_new_line_before_open_brace = all
174+
csharp_new_line_before_else = true
175+
csharp_new_line_before_catch = true
176+
csharp_new_line_before_finally = true
177+
csharp_new_line_before_members_in_object_initializers = true
178+
csharp_new_line_before_members_in_anonymous_types = true
179+
csharp_new_line_between_query_expression_clauses = true
180+
181+
# Indentation preferences
182+
csharp_indent_block_contents = true
183+
csharp_indent_braces = false
184+
csharp_indent_case_contents = true
185+
csharp_indent_case_contents_when_block = true
186+
csharp_indent_switch_labels = true
187+
csharp_indent_labels = flush_left
188+
189+
# Whitespace options
190+
csharp_style_allow_embedded_statements_on_same_line_experimental = false
191+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
192+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false
193+
194+
# Prefer "var" everywhere
195+
csharp_style_var_for_built_in_types = true:suggestion
196+
csharp_style_var_when_type_is_apparent = true:suggestion
197+
csharp_style_var_elsewhere = true:suggestion
198+
199+
# Prefer method-like constructs to have a block body
200+
csharp_style_expression_bodied_methods = false:none
201+
csharp_style_expression_bodied_constructors = false:none
202+
csharp_style_expression_bodied_operators = false:none
203+
204+
# Prefer property-like constructs to have an expression-body
205+
csharp_style_expression_bodied_properties = true:none
206+
csharp_style_expression_bodied_indexers = true:none
207+
csharp_style_expression_bodied_accessors = true:none
208+
209+
# Suggest more modern language features when available
210+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
211+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
212+
csharp_style_inlined_variable_declaration = true:suggestion
213+
csharp_style_throw_expression = true:suggestion
214+
csharp_style_conditional_delegate_call = true:suggestion
215+
216+
# Space preferences
217+
csharp_space_after_cast = false
218+
csharp_space_after_colon_in_inheritance_clause = true
219+
csharp_space_after_comma = true
220+
csharp_space_after_dot = false
221+
csharp_space_after_keywords_in_control_flow_statements = true
222+
csharp_space_after_semicolon_in_for_statement = true
223+
csharp_space_around_binary_operators = before_and_after
224+
csharp_space_around_declaration_statements = do_not_ignore
225+
csharp_space_before_colon_in_inheritance_clause = true
226+
csharp_space_before_comma = false
227+
csharp_space_before_dot = false
228+
csharp_space_before_open_square_brackets = false
229+
csharp_space_before_semicolon_in_for_statement = false
230+
csharp_space_between_empty_square_brackets = false
231+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
232+
csharp_space_between_method_call_name_and_opening_parenthesis = false
233+
csharp_space_between_method_call_parameter_list_parentheses = false
234+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
235+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
236+
csharp_space_between_method_declaration_parameter_list_parentheses = false
237+
csharp_space_between_parentheses = false
238+
csharp_space_between_square_brackets = false
239+
240+
# Blocks are allowed
241+
csharp_prefer_braces = true:silent
242+
csharp_preserve_single_line_blocks = true
243+
csharp_preserve_single_line_statements = true
244+
245+
# Currently only enabled for C# due to crash in VB analyzer. VB can be enabled once
246+
# https://github.com/dotnet/roslyn/pull/54259 has been published.
247+
dotnet_style_allow_statement_immediately_after_block_experimental = false
248+
249+
[src/CodeStyle/**.{cs,vb}]
250+
# warning RS0005: Do not use generic CodeAction.Create to create CodeAction
251+
dotnet_diagnostic.RS0005.severity = none
252+
253+
[src/{Analyzers,CodeStyle,Features,Workspaces,EditorFeatures,VisualStudio}/**/*.{cs,vb}]
254+
255+
# IDE0011: Add braces
256+
csharp_prefer_braces = when_multiline:warning
257+
# NOTE: We need the below severity entry for Add Braces due to https://github.com/dotnet/roslyn/issues/44201
258+
dotnet_diagnostic.IDE0011.severity = warning
259+
260+
# IDE0040: Add accessibility modifiers
261+
dotnet_diagnostic.IDE0040.severity = warning
262+
263+
# CONSIDER: Are IDE0051 and IDE0052 too noisy to be warnings for IDE editing scenarios? Should they be made build-only warnings?
264+
# IDE0051: Remove unused private member
265+
dotnet_diagnostic.IDE0051.severity = warning
266+
267+
# IDE0052: Remove unread private member
268+
dotnet_diagnostic.IDE0052.severity = warning
269+
270+
# IDE0059: Unnecessary assignment to a value
271+
dotnet_diagnostic.IDE0059.severity = warning
272+
273+
# IDE0060: Remove unused parameter
274+
dotnet_diagnostic.IDE0060.severity = warning
275+
276+
# CA1012: Abstract types should not have public constructors
277+
dotnet_diagnostic.CA1012.severity = warning
278+
279+
# CA1822: Make member static
280+
dotnet_diagnostic.CA1822.severity = warning
281+
282+
# Prefer "var" everywhere
283+
dotnet_diagnostic.IDE0007.severity = warning
284+
csharp_style_var_for_built_in_types = true:warning
285+
csharp_style_var_when_type_is_apparent = true:warning
286+
csharp_style_var_elsewhere = true:warning
287+
288+
# dotnet_style_allow_multiple_blank_lines_experimental
289+
dotnet_diagnostic.IDE2000.severity = warning
290+
291+
# csharp_style_allow_embedded_statements_on_same_line_experimental
292+
dotnet_diagnostic.IDE2001.severity = warning
293+
294+
# csharp_style_allow_blank_lines_between_consecutive_braces_experimental
295+
dotnet_diagnostic.IDE2002.severity = warning
296+
297+
# dotnet_style_allow_statement_immediately_after_block_experimental
298+
dotnet_diagnostic.IDE2003.severity = warning
299+
300+
# csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental
301+
dotnet_diagnostic.IDE2004.severity = warning
302+
303+
[src/{VisualStudio}/**/*.{cs,vb}]
304+
# CA1822: Make member static
305+
# Not enforced as a build 'warning' for 'VisualStudio' layer due to large number of false positives from https://github.com/dotnet/roslyn-analyzers/issues/3857 and https://github.com/dotnet/roslyn-analyzers/issues/3858
306+
# Additionally, there is a risk of accidentally breaking an internal API that partners rely on though IVT.
307+
dotnet_diagnostic.CA1822.severity = suggestion
308+
309+
[test/**/*.cs]
310+
# IDE0044: Don't force readonly for tests
311+
dotnet_diagnostic.IDE0044.severity = none
312+
dotnet_style_readonly_field = false
313+
314+
# MSML_GeneralName: This name should be PascalCased
315+
dotnet_diagnostic.MSML_GeneralName.severity = none
316+
317+
# MSML_NoBestFriendInternal: Cross-assembly internal access requires referenced item to have Microsoft.ML.BestFriendAttribute attribute.
318+
dotnet_diagnostic.MSML_NoBestFriendInternal.severity = none
319+
320+
# MSML_NoInstanceInitializers: No initializers on instance fields or properties
321+
dotnet_diagnostic.MSML_NoInstanceInitializers.severity = none
322+
323+
[test/Microsoft.ML.CodeAnalyzer.Tests/**.cs]
324+
# BaseTestClass does not apply for analyzer testing.
325+
# MSML_ExtendBaseTestClass: Test classes should be derived from BaseTestClass
326+
dotnet_diagnostic.MSML_ExtendBaseTestClass.severity = none
327+
328+
# The MSML_RelaxTestNaming suppressor for VSTHRD200 is not active for CodeAnalyzer.Tests, so we disable it altogether.
329+
# VSTHRD200: Use "Async" suffix for async methods
330+
dotnet_diagnostic.VSTHRD200.severity = none
331+
332+
[docs/**/*.cs]
333+
# IDE0073: Dont want license file header in samples
334+
dotnet_diagnostic.IDE0073.severity = none
335+
file_header_template = unset
336+
337+
# IDE0044: Don't force readonly for samples
338+
dotnet_diagnostic.IDE0044.severity = none
339+
dotnet_style_readonly_field = false
340+
341+
[test/Microsoft.ML.TestFrameworkCommon/Utility/*.cs]
342+
# IDE0073: Dont want license file header in code we are using from elsewhere
343+
dotnet_diagnostic.IDE0073.severity = none
344+
file_header_template = unset
345+
346+
[**/*.generated.cs]
347+
generated_code = true

Directory.Build.props

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
4+
<PropertyGroup>
5+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
6+
<LangVersion>latest</LangVersion>
7+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
8+
</PropertyGroup>
9+
</Project>

global.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.101",
4+
"rollForward": "latestMinor"
5+
}
6+
}

src/getting-started/azure-openai-sdk/01-HikeBenefitsSummary/Program.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
using Azure;
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Azure;
26
using Azure.AI.OpenAI;
37
using Microsoft.Extensions.Configuration;
48

0 commit comments

Comments
 (0)