Skip to content

Commit

Permalink
Update formatting config (#5377)
Browse files Browse the repository at this point in the history
  • Loading branch information
Théo Penavaire authored Aug 18, 2021
1 parent b6cf854 commit a8abe4c
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 37 deletions.
49 changes: 49 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,52 @@ indent_size = 4
end_of_line = crlf
trim_trailing_whitespace = true
insert_final_newline = false

# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules
[*.cs]
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# indentation options
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = one_less_than_current
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = false
# spacing
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
#csharp_space_between_parentheses = control_flow_statements, type_casts, expressions
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_after_comma = true
csharp_space_before_comma = false
csharp_space_after_dot = false
csharp_space_before_dot = false
csharp_space_after_semicolon_in_for_statement = true
csharp_space_before_semicolon_in_for_statement = false
csharp_space_around_declaration_statements = false
csharp_space_before_open_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_square_brackets = false
# wrap options
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
# using directives
#csharp_using_directive_placement = outside_namespace
# dotnet options
#dotnet_sort_system_directives_first = true

#dotnet_separate_import_directive_groups = false
3 changes: 2 additions & 1 deletion .repoconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[version]
repoconfig=5
repoconfig=7
minimum-unity-meta=47

[format]
path-ignore=<<EOT
Expand Down
72 changes: 37 additions & 35 deletions .yamato/_formatting.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
# Documentation: https://internaldocs.hq.unity3d.com/unity-meta/

formatting:
name: Formatting
agent:
type: Unity::VM
image: package-ci/ubuntu:v1.3.1-719011
flavor: b1.small
commands:
- "echo -e \"[extensions]\nlargefiles=\n\" > ~/.hgrc"
- hg clone -u stable http://hg-mirror-slo.hq.unity3d.com/unity-extra/unity-meta ~/unity-meta
- perl ~/unity-meta/Tools/Format/format.pl --reporoot $(pwd) --preview .
- cat ./format.patch
- perl ~/unity-meta/Tools/Format/format.pl --reporoot $(pwd) --dry-run . # Run a 2nd time to actually "fail" the job if there are formatting diffs (--preview always exits with 0)
timeout: 1
triggers:
expression: pull_request.target eq "master"
artifacts:
diff:
paths:
- format.patch
name: Formatting
agent:
type: Unity::VM
image: package-ci/ubuntu:v1.3.1-719011
flavor: b1.small
commands:
- "echo -e \"[extensions]\nlargefiles=\n\" > ~/.hgrc"
- hg clone -u beta http://hg-mirror-slo.hq.unity3d.com/unity-extra/unity-meta ~/unity-meta
- perl ~/unity-meta/Tools/Format/format.pl --nobackups .
- git diff --output ./format.patch
- cat ./format.patch
- | # Checking if there is a diff, to fail the job if yes (-s check means does the file contain something)
if [ -s format.patch ]; then exit 1; fi
timeout: 1
triggers:
expression: pull_request.target eq "master"
artifacts:
diff:
paths:
- format.patch

formatting_apply:
name: Formatting (Apply requested changes)
agent:
type: Unity::VM
image: package-ci/ubuntu:v1.3.1-719011
flavor: b1.small
commands:
- git config --global user.name "[email protected]"
- git config --global user.email "[email protected]"
- git checkout $GIT_BRANCH
- git pull origin $GIT_BRANCH # In case the job was not run on the latest commit, attempt to get it. There may be situations with merge conflicts, in that case wait for everyone to push their changes and then only run the formatting job on HEAD.
- "echo -e \"[extensions]\nlargefiles=\n\" > ~/.hgrc"
- hg clone -u stable http://hg-mirror-slo.hq.unity3d.com/unity-extra/unity-meta ~/unity-meta
- perl ~/unity-meta/Tools/Format/format.pl --reporoot $(pwd) --nobackups .
- git add .
- git commit -m "Apply formatting changes"
- git push --set-upstream origin $GIT_BRANCH
timeout: 1
name: Formatting (Apply requested changes)
agent:
type: Unity::VM
image: package-ci/ubuntu:v1.3.1-719011
flavor: b1.small
commands:
- git config --global user.name "[email protected]"
- git config --global user.email "[email protected]"
- git checkout $GIT_BRANCH
- git pull origin $GIT_BRANCH # In case the job was not run on the latest commit, attempt to get it. There may be situations with merge conflicts, in that case wait for everyone to push their changes and then only run the formatting job on HEAD.
- "echo -e \"[extensions]\nlargefiles=\n\" > ~/.hgrc"
- hg clone -u beta http://hg-mirror-slo.hq.unity3d.com/unity-extra/unity-meta ~/unity-meta
- perl ~/unity-meta/Tools/Format/format.pl --nobackups .
- git add .
- git commit -m "Apply formatting changes"
- git push --set-upstream origin $GIT_BRANCH
timeout: 1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override void OnInitialize(InitializeConverterContext ctx, Action callbac
{
var context = Search.SearchService.CreateContext("asset", "urp:convert-readonly");

Search.SearchService.Request(context, (c, items) =>
Search.SearchService.Request(context, (c, items) =>
{
// we're going to do this step twice in order to get them ordered, but it should be fast
var orderedRequest = items.OrderBy(req =>
Expand Down

0 comments on commit a8abe4c

Please sign in to comment.