Skip to content

Instantly share code, notes, and snippets.

@algonzalez
Last active October 6, 2021 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save algonzalez/bf0e3b92e16c22bd33b14c53f1d42540 to your computer and use it in GitHub Desktop.
Save algonzalez/bf0e3b92e16c22bd33b14c53f1d42540 to your computer and use it in GitHub Desktop.
Basic .editorconfig with some .NET rules
# see http://editorconfig.org/ for details
# top-most EditorConfig file; stops searching parent directories.
root = true
# Defaults: UTF-8, Windows-style newline,
# 4 space indents,
# newline ending every file,
# trim trailing whitespace
[*]
charset = utf-8
end_of_line = crlf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.{css,htm,html,js,json,jsx,less,sass,scss,svg,ts,tsx,vue}]
indent_size = 2
# trailing whitespace may be relevant
[*.{diff,md,markdown}]
trim_trailing_whitespace = false
# Batch Files
[*.{cmd,bat}]
end_of_line = crlf
# Bash Files
[*.sh]
end_of_line = lf
# Visual Studio solution files
[*.sln]
indent_style= tab
# Visual Studio XML project files
[*.{csproj,vbproj}]
end_of_line = crlf
indent_size = 2
# TODO: .NET extensions to .editorconfig file
# see: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview
[*.cs]
# IDE0017: Use object initializers
dotnet_style_object_initializer = false
# IDE0057: Use range operator `..` in place of Substring
csharp_style_prefer_range_operator = false
# IDE0063: Use simple 'using' statement
csharp_prefer_simple_using_statement = false
# IDE0090: Simplify 'new' expression
csharp_style_implicit_object_creation_when_type_is_apparent = false
# -- TODO: still evaluating/testing
# for other rules, see: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options
# also see: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/
# Consider VS Code setting: "[csharp]": { "editor.formatOnPaste": true, "editor.formatOnSave": true }
csharp_new_line_before_open_brace = namespaces, types, methods, properties
csharp_new_line_before_catch = true
csharp_new_line_before_else = true
csharp_new_line_before_finally = true
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
csharp_style_pattern_local_over_anonymous_function = false
csharp_using_directive_placement = outside_namespace
# Declare as int instead of Int32
dotnet_style_predefined_type_for_locals_parameters_members = true
dotnet_style_predefined_type_for_member_access = true
# Handle usings -- not sure if this is working in VS Code
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment