.NET Format

Implements a commit workflow on every commit that runs `dotnet format` to format the source of the project via the rules configured within the editorConfig. This does nothing to assign any formatting, it just enforces the rules already present.
This commit is contained in:
Refringe
2025-05-03 16:40:18 -04:00
parent c8e3c70df3
commit 15b2a73765
3 changed files with 51 additions and 11 deletions
+13 -11
View File
@@ -12,11 +12,12 @@ indent_style = space
indent_size = 4 indent_size = 4
trim_trailing_whitespace = true trim_trailing_whitespace = true
[{*.yaml,*.yml}]
indent_size = 2
[*.json] [*.json]
ij_formatter_enabled = true ij_formatter_enabled = true
indent_style = space
indent_size = 2 indent_size = 2
trim_trailing_whitespace = true
# C# files # C# files
[*.cs] [*.cs]
@@ -29,9 +30,6 @@ csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true csharp_new_line_between_query_expression_clauses = true
# ReSharper properties
resharper_wrap_object_and_collection_initializer_style = chop_always
# Indentation preferences # Indentation preferences
csharp_indent_block_contents = true csharp_indent_block_contents = true
csharp_indent_braces = false csharp_indent_braces = false
@@ -77,13 +75,14 @@ dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
csharp_using_directive_placement = outside_namespace:error csharp_using_directive_placement = outside_namespace:error
dotnet_sort_system_directives_first = true dotnet_sort_system_directives_first = true
csharp_prefer_braces = true:warning csharp_prefer_braces = true:warning
csharp_preserve_single_line_blocks = false
csharp_preserve_single_line_statements = false
csharp_prefer_static_local_function = true:suggestion csharp_prefer_static_local_function = true:suggestion
csharp_prefer_simple_using_statement = false:none csharp_prefer_simple_using_statement = false:none
csharp_style_prefer_switch_expression = true:suggestion csharp_style_prefer_switch_expression = true:suggestion
dotnet_style_readonly_field = true:suggestion dotnet_style_readonly_field = true:suggestion
# csharp_preserve_single_line_blocks = false
# csharp_preserve_single_line_statements = false
# Expression-level preferences # Expression-level preferences
dotnet_style_object_initializer = true:suggestion dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion dotnet_style_collection_initializer = true:suggestion
@@ -105,13 +104,11 @@ csharp_style_expression_bodied_operators = false:warning
csharp_style_expression_bodied_properties = false:warning csharp_style_expression_bodied_properties = false:warning
csharp_style_expression_bodied_indexers = false:warning csharp_style_expression_bodied_indexers = false:warning
csharp_style_expression_bodied_accessors = false:warning csharp_style_expression_bodied_accessors = false:warning
csharp_style_expression_bodied_lambdas = false:warning
csharp_style_expression_bodied_local_functions = false:warning csharp_style_expression_bodied_local_functions = false:warning
csharp_style_expression_bodied_lambdas = true
# Pattern matching # Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion csharp_style_prefer_pattern_matching = false:warning
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
# Null checking preferences # Null checking preferences
csharp_style_throw_expression = true:suggestion csharp_style_throw_expression = true:suggestion
@@ -121,6 +118,7 @@ csharp_style_conditional_delegate_call = true:suggestion
csharp_style_prefer_index_operator = false:none csharp_style_prefer_index_operator = false:none
csharp_style_prefer_range_operator = false:none csharp_style_prefer_range_operator = false:none
csharp_style_pattern_local_over_anonymous_function = false:none csharp_style_pattern_local_over_anonymous_function = false:none
csharp_style_inlined_variable_declaration = true
# Space preferences # Space preferences
csharp_space_after_cast = true csharp_space_after_cast = true
@@ -145,6 +143,10 @@ csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_square_brackets = false csharp_space_between_square_brackets = false
# ReSharper properties
resharper_wrap_object_and_collection_initializer_style = chop_always
resharper_merge_into_pattern_highlighting = none
# Xml project files # Xml project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
indent_size = 2 indent_size = 2
+37
View File
@@ -0,0 +1,37 @@
name: .NET Format
on:
push:
branches:
- develop
pull_request:
branches: ["*"]
branches-ignore:
- main
jobs:
dotnet-format:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.BYPASS_WORKFLOW_PAT }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0
- name: Restore Tool Dependencies
run: dotnet tool install -g csharpier
- name: CSharpier Format
run: csharpier format .
- uses: stefanzweifel/git-auto-commit-action@v6
with:
commit_message: .NET Format Style Fixes
commit_user_name: Format Bot
+1
View File
@@ -2,6 +2,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gifter/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Gifter/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ragfair/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=ragfair/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Randomisable/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Randomisable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=randomistion/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=scav/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=scav/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tarkov/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Tarkov/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Usec/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/UserDictionary/Words/=Usec/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>