Skip to content

Commit 02d81da

Browse files
Sergio0694Copilot
andcommitted
Fix incorrect version check order in MVVMToolkitRemoveDuplicateAnalyzers target
MSBuild PropertyGroup elements are evaluated top-to-bottom, with later assignments overwriting earlier ones. The >= 4.12 check was before the >= 4.3 check, so for any Roslyn version >= 4.12 (including 5.0), the 4.12 result would be immediately overwritten by the 4.3 match. This caused the wrong analyzer (roslyn4.3) to be selected instead of the correct one (roslyn4.12). Swap the order so the lower version (4.3) is checked first and the higher version (4.12) is checked last, ensuring the highest compatible analyzer wins. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ea17501 commit 02d81da

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.SourceGenerators.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
removes and removes all analyzers except the highest version that is supported. The fallback is just Roslyn 4.0.
8787
-->
8888
<PropertyGroup>
89-
<MVVMToolkitSelectedRoslynAnalyzerDirectoryName Condition="$([MSBuild]::VersionGreaterThanOrEquals($(MVVMToolkitCurrentCompilerVersion), 4.12))">roslyn4.12</MVVMToolkitSelectedRoslynAnalyzerDirectoryName>
9089
<MVVMToolkitSelectedRoslynAnalyzerDirectoryName Condition="$([MSBuild]::VersionGreaterThanOrEquals($(MVVMToolkitCurrentCompilerVersion), 4.3))">roslyn4.3</MVVMToolkitSelectedRoslynAnalyzerDirectoryName>
90+
<MVVMToolkitSelectedRoslynAnalyzerDirectoryName Condition="$([MSBuild]::VersionGreaterThanOrEquals($(MVVMToolkitCurrentCompilerVersion), 4.12))">roslyn4.12</MVVMToolkitSelectedRoslynAnalyzerDirectoryName>
9191
<MVVMToolkitSelectedRoslynAnalyzerDirectoryName Condition="'$(MVVMToolkitSelectedRoslynAnalyzerDirectoryName)' == ''">roslyn4.0</MVVMToolkitSelectedRoslynAnalyzerDirectoryName>
9292
</PropertyGroup>
9393
<ItemGroup>

0 commit comments

Comments
 (0)