Skip to content

Conversation

@xtqqczze
Copy link
Contributor

@xtqqczze xtqqczze commented Jan 26, 2020

PR Summary

Reformat source code with dotnet/format according to rules in the .editorconfig file.

dotnet tool install --global dotnet-format --version 3.1.37601
dotnet-format

The following rules were disabled as they resulted in a high number of changes:

csharp_preserve_single_line_statements = false
csharp_new_line_before_open_brace = all

To exclude regressions, we could create a new static test:

# Terminates with a non-zero exit code if any files were formatted
dotnet-format --check --dry-run

PR Context

PR Checklist

Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xtqqczze Please revert changes in .editorconfig. They was needed only locally to allow you to format but we should keep these options as they correspond to our code convention.
(For static test we could use another config file with fewer rules.)

Which rules would you like to see added?

I see many rules in .Net Core and Roslyn .editorconfig-s and we could review them and add some ones to our config. When I added these rules last time I had to remove many because there were a lot of problems. Now the code is cleaner and we can add more rules.

Also please see CodeFactor issues. We need to adjust CodeFactor or formatting options to resolve them.

@xtqqczze
Copy link
Contributor Author

CodeFactor issues are violations of SA1008 due to added space after the delegate keyword. Rule documentation states an opening parenthesis can be preceded by whitespace when it is preceded by "certain C# keywords" but is ambiguous as to whether or not this applies to the delegate keyword. There is an open issue dotnet/roslyn#3257 concerning this behaviour.

We can apply a refactoring to replace the anonymous methods with delegate keyword with lamba expressions and avoid the rule violations. This would be a workaround but is also a recommended refactoring.

@xtqqczze
Copy link
Contributor Author

xtqqczze commented Jan 27, 2020

@iSazonov This PR disables those rules because it is apparent the code is not already in the prescribed style. We could open a new issue to discuss which rules we want for our code convention?

@xtqqczze xtqqczze force-pushed the patch-dotnet-format branch from 75aef8b to 3052d56 Compare January 27, 2020 03:07
@xtqqczze
Copy link
Contributor Author

rebased to restart CI

@iSazonov
Copy link
Collaborator

This PR disables those rules because it is apparent the code is not already in the prescribed style.

We have over 50000 CodeFactor issues but we do not disable the rules because we don't want add new issues.

We could open a new issue to discuss which rules we want for our code convention?

We already have Code Conventions. This allows us add any rules to suggest/force the Code Conventions.

@xtqqczze xtqqczze changed the title [WIP] Reformat code with dotnet-format according to EditorConfig rules Reformat code according to EditorConfig rules Jan 27, 2020
@iSazonov
Copy link
Collaborator

@xtqqczze Please resolve merge conflict.

@xtqqczze xtqqczze force-pushed the patch-dotnet-format branch from 18570c9 to e2fea92 Compare January 30, 2020 10:16
@xtqqczze
Copy link
Contributor Author

@iSazonov rebased and removed commit "Remove duplicate semicolons" This should be part of a seperate PR as the change is unrelated to using the dotnet-format tool.

@xtqqczze
Copy link
Contributor Author

@iSazonov We should make changes to rules in .editorconfig before creating a new dotnet-format PR.

@iSazonov iSazonov added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Jan 30, 2020
@iSazonov iSazonov added this to the 7.1.0-preview.1 milestone Jan 30, 2020
@TravisEz13
Copy link
Member

Please resolve merge conflicts.
Such a large PR may be difficult to get merged.

@xtqqczze xtqqczze force-pushed the patch-dotnet-format branch from e2fea92 to c8ffda3 Compare January 30, 2020 21:15
@xtqqczze
Copy link
Contributor Author

@TravisEz13 rebased

@xtqqczze xtqqczze force-pushed the patch-dotnet-format branch from c8ffda3 to edab15a Compare January 30, 2020 23:15
@xtqqczze
Copy link
Contributor Author

@TravisEz13 rebased, again

@xtqqczze xtqqczze force-pushed the patch-dotnet-format branch from edab15a to 83106fd Compare January 31, 2020 11:18
@xtqqczze
Copy link
Contributor Author

PowerShell-CI-static-analysis failures are in markdown-links and are unrelated.

@TravisEz13 TravisEz13 merged commit a34d0f3 into PowerShell:master Jan 31, 2020
@xtqqczze xtqqczze deleted the patch-dotnet-format branch February 1, 2020 12:23
@ghost
Copy link

ghost commented Mar 26, 2020

🎉v7.1.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants