Skip to content

New Fix Bracket Formatting Of List Analyzer and Fix Provider #1643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

AndreiShenets
Copy link

@AndreiShenets AndreiShenets commented Apr 12, 2025

The PR contains:

  • Setting up indentation for *.xml files and disabling trimming of white spaces for Analyzers.xml. The reason is that when you do changes there IDE introduces undesirable changes in other areas basing on IDE settings as well as trims whitespaces when it is not required
  • added ignoring of .idea folder as my JetBrains Rider creates it and I don't want it in the repo
  • New TargetBracesStyle option for the new analyzer.
  • Added ability to skip search for indentation in parents SyntaxTriviaAnalysis.DetermineIndentation(...). In my case it is not desirable.

The PR is one of the PRs I would like to raise to implement proposed in #1636 changes.

Potential next PRs are:

  • Fix Bracket Formatting in ifs
  • Make Structural Honest

@AndreiShenets
Copy link
Author

@dotnet-policy-service agree

@AndreiShenets
Copy link
Author

Hi @josefpihrt,

I see that the build is failing on `/home/runner/work/roslynator/roslynator/src/CSharp/DetermineParameterTypeHelper.cs(48,46): error RS1024: Use 'SymbolEqualityComparer' when comparing symbols.

The code is not part of my PR and I haven't changed something there.

What am I supposed to do? Should I fix it?

@josefpihrt
Copy link
Collaborator

Yes, please fix it.

@AndreiShenets
Copy link
Author

@josefpihrt please re-run the build

@AndreiShenets
Copy link
Author

@josefpihrt The behavior of the build pipeline looks strange to me. As far as I see, TreatWarningsAsErrors is set to true for the build pipeline. At the same time I see literally hundreds of warnings after build and the pipeline considers only RS1024 as an error, despite its severity is marked as none in .editorconfig. I assume that dotnet build doesn't use .editconfig in combination with TreatWarningsAsErrors but the immediate question comes after, how was it possible to build the solution before? Especially, taking in account that there were no related changes in the repo since the latest release.

Also why TreatWarningsAsErrors enabled only at pipeline time if it leads to failing of it?

Do I miss some configuration or something other?

To unblock PR I fixed the RS1024 warnings but I assume the pipeline will continue to fails. Could you advise if I move to correct direction?

@AndreiShenets
Copy link
Author

AndreiShenets commented May 2, 2025

It might be that new .net, which was released after the latest build, ignores the setting to not build Documentation project. The project is build with WarningsNotAsErrors="1573,1591,RS1024,RS1025,RS1026" when the script is used.

Should I just modify .github/workflows/build.yml and add RS1024,RS1025,RS1026 there as well?

@AndreiShenets
Copy link
Author

@josefpihrt could you please at least restart the build?

@AndreiShenets
Copy link
Author

@josefpihrt please rerun the build again

@AndreiShenets
Copy link
Author

AndreiShenets commented May 25, 2025

Hi @josefpihrt,

The build in my branch fails with a lot of error WHITESPACE: Fix whitespace formatting. Insert '\s\s\s\s' errors. I can reproduce it locally when I follow the build steps. The main branch builds ok. The error is triggered basically for all case blocks of switch statements in the solution. .editorconfig already has csharp_indent_case_contents_when_block=false. My changes don't do anything about case block or at least I don't see it. A test for my analyzer with switch case blocks doesn't fail. I am a bit stack here and don't understand what can cause the issue. Could you probably advise if you have ideas?

@josefpihrt
Copy link
Collaborator

This is really weird. I'd suggest to undo changes made in .editorconfig to see if it helps.

@AndreiShenets
Copy link
Author

@josefpihrt thanks a lot! That helped! The behavior was not weird. I added [*.xml] and [Analyzers.xml] after [*.{cs,csx}]. New line doesn't start new section that applies to any file. So I just did a stupid thing. Basically I declared that all settings apply only to [Analyzers.xml]...

Should be fixed now. Please re-run the build.

@AndreiShenets
Copy link
Author

@josefpihrt could you please re-run it again? The error doesn't look to me meaningful and all works locally.

@josefpihrt
Copy link
Collaborator

I'd suggest to run dotnet format Roslynator.sln --severity info to fix it.

@AndreiShenets
Copy link
Author

@josefpihrt done, please re-run

@AndreiShenets
Copy link
Author

omg, it complains about List<TextChange> textChanges = []; and asks to convert to var textChanges = new List<TextChange>();. But ok, done.

@josefpihrt please re-run

@AndreiShenets
Copy link
Author

@josefpihrt please re-run the build

@AndreiShenets
Copy link
Author

Typos are fixed.

@josefpihrt please re-run the build again

@AndreiShenets
Copy link
Author

@josefpihrt ,

I excluded SyntaxKind.CollectionExpression for Roslyn versions prior to ROSLYN_4_7.

The second error looks strange to me and I am not sure what I can do about it. Let's probably re-run the build to check that it is not a fluke?

Microsoft.NET.Sdk.targets(262,5): error NETSDK1216: Package Microsoft.Net.Sdk.Compilers.Toolset is not downloaded but it is needed because your MSBuild and SDK versions are mismatched. Ensure version 9.0.300 of the package is available in your NuGet source feeds and then run NuGet package restore from Visual Studio or MSBuild.

@AndreiShenets
Copy link
Author

@josefpihrt please re-run

@AndreiShenets
Copy link
Author

@josefpihrt could you please re-run the build?

@josefpihrt
Copy link
Collaborator

@AndreiShenets I'm totally busy at work and have no time to take a look at your MR. Sorry for that.

@AndreiShenets
Copy link
Author

@josefpihrt said to hear that but it is what it is.

Regarding the build, I found that it is an issue with GitHub Actions: actions/runner-images#12303

I added a potential workaround. Please re-run the build to confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants