Skip to content
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

Fixing of RCS1014 via roslynator cli produces output that won't compile #1075

Closed
jamesHargreaves12 opened this issue Apr 20, 2023 · 2 comments

Comments

@jamesHargreaves12
Copy link
Contributor

Issue for #1070 as requested. There is a lot of detail in the description of that PR so I won't duplicate anything that was said there. Here is a minimal example that will reproduce this issue:
Solution2.zip
unzip, dotnet restore
Then run roslynator fix <rest of path>/TestProject1.csproj

Load project '<rest of path>/TestProject1.csproj'
Done loading project '<rest of path>/TestProject1.csproj'
Fix 'TestProject1'
  Compile 'TestProject1'
  Analyze 'TestProject1'
  Found 5 diagnostics in 'TestProject1'
  Fix 5 RCS1014 'Use explicitly/implicitly typed array.'
    UnitTest1.cs(12,13): error CS1501: No overload for method 'Add' takes 10 arguments
  Compile 'TestProject1' iteration 2
    UnitTest1.cs(12,13): error CS1501: No overload for method 'Add' takes 10 arguments
  Analyze 'TestProject1'
  Found 3 diagnostics in 'TestProject1'
    UnitTest1.cs(12,13): error CS1501: No overload for method 'Add' takes 10 arguments
  Fix 3 RCS1014 'Use explicitly/implicitly typed array.'
    UnitTest1.cs(12,13): error CS1501: No overload for method 'Add' takes 10 arguments
  Compile 'TestProject1' iteration 3
    UnitTest1.cs(12,13): error CS1501: No overload for method 'Add' takes 10 arguments
  Analyze 'TestProject1'
  Found 1 diagnostic in 'TestProject1'
    UnitTest1.cs(12,13): error CS1501: No overload for method 'Add' takes 10 arguments
  Fix 1 RCS1014 'Use explicitly/implicitly typed array.'
    UnitTest1.cs(12,13): error CS1501: No overload for method 'Add' takes 10 arguments
  Compile 'TestProject1' iteration 4
    UnitTest1.cs(12,13): error CS1501: No overload for method 'Add' takes 10 arguments
  Analyze 'TestProject1'
Done fixing project '<rest of path>/TestProject1.csproj' in 00:05.77

Fixed diagnostics:
  9 RCS1014 Use explicitly/implicitly typed array.

9 diagnostics fixed

(The resulting UnitTest1.cs won't compile)

Product and Version Used:
MacOS BigSur (Intel), net7.0, the latest version of Roslynator master.

@josefpihrt
Copy link
Collaborator

I'm able to reproduce the bug 👍.

It's interesting that the bug does not occur when a fix is applied from IDE. So I have a suspicion that the bug is somewhere in Roslynator CLI code that applies the fix. So far I was not able to find it so the custom fix all provider may be the solution.

@josefpihrt
Copy link
Collaborator

fixed with #1070

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

No branches or pull requests

2 participants