Skip to content
New issue

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

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

Already on GitHub? # to your account

CSharpUseStringMethodCharOverloadWithSingleCharacters.Fixer.cs fails to compile with newer CodeAnalysis version #7588

Closed
ViktorHofer opened this issue Feb 26, 2025 · 3 comments · Fixed by #7589

Comments

@ViktorHofer
Copy link
Member

ViktorHofer commented Feb 26, 2025

When building roslyn-analyzers from source, live dependencies should be used. Until 8bfe8b8 that was broken though and resulted in an older CodeAnalysis version to be used instead (the repo defined versions).

This is an issue for multiple reasons but the one that concerns me the most is that SBRP needs to keep those ancient package versions "living" and with those, netstandard1.x packages. Therefore, we want to make sure that source-build correctly uses the live version of CodeAnalysis when building source-only.

Now that this flow issue got fixed, dotnet/sdk#47100 shows that when source-building the product (in the VMR), there are two compile errors:

C:\git\roslyn-analyzers\src\NetAnalyzers\CSharp\Microsoft.NetCore.Analyzers\Performance\CSharpUseStringMethodCharOverloadWithSingleCharacters.Fixer.cs(82,67): error CS
1503: Argument 1: cannot convert from 'Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.SyntaxNode>' to 'Microsoft.CodeAnalysis.SeparatedSyntaxList<Mi
crosoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax>' [C:\git\roslyn-analyzers\src\NetAnalyzers\CSharp\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.csproj]
C:\git\roslyn-analyzers\src\NetAnalyzers\VisualBasic\Microsoft.NetCore.Analyzers\Performance\BasicUseStringMethodCharOverloadWithSingleCharacters.Fixer.vb(72,67): erro
r BC30512: Option Strict On disallows implicit conversions from 'SeparatedSyntaxList(Of SyntaxNode)' to 'SeparatedSyntaxList(Of ArgumentSyntax)'. [C:\git\roslyn-analyz
ers\src\NetAnalyzers\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers.vbproj]

Through experimentation I found out that this happens starting with a 4.7.0 version of CodeAnalysis packages. Unfortunately, I couldn't find the actual breaking change though.

@ViktorHofer
Copy link
Member Author

ViktorHofer commented Feb 27, 2025

Repro steps:

git clone https://github.com/dotnet/roslyn-analyzers
cd roslyn-analyzers
Build.cmd /p:MicrosoftCodeAnalysisVersionForNetAnalyzers="4.7.0" -warnAsError 0

For the purpose of this repro, ignore the restore and nullability warnings.


If you want to debug this inside VS, update the MicrosoftCodeAnalysisVersionForNetAnalyzers property in Versions.props.

@ViktorHofer
Copy link
Member Author

cc @CyrusNajmabadi

@sharwell
Copy link
Member

The breaking change was introduced by dotnet/roslyn#19932

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

Successfully merging a pull request may close this issue.

2 participants