Add MVVM Toolkit code fixer for Roslyn 5.0 - #1171
Merged
Merged
Conversation
Add a new CommunityToolkit.Mvvm.CodeFixers.Roslyn5000.csproj targeting net10.0 with ImplicitUsings and Nullable enabled, and include the project in dotnet.slnx. This adds a Roslyn5000-specific CodeFixers project to the solution so it can be built and discovered by the solution tooling.
Replace inline project properties in the Roslyn5000 csproj with imports of the shared props and projitems to centralize configuration. Also add a new conditional DefineConstants in CommunityToolkit.Mvvm.CodeFixers.props to define ROSLYN_5_0_0_OR_GREATER when MvvmToolkitSourceGeneratorRoslynVersion >= 5.0.0, enabling feature flags for Roslyn 5.0.
Use the Roslyn 5+ API when available to determine the C# language version. Add a conditional compilation branch that calls Compilation.HasLanguageVersionAtLeastEqualTo(LanguageVersion.CSharp14) when ROSLYN_5_0_0_OR_GREATER is defined, and fall back to the previous IsLanguageVersionPreview() check otherwise. This avoids generating invalid code on older Roslyn builds while correctly detecting C#14+ in newer toolchains.
Add a ProjectReference to CommunityToolkit.Mvvm.CodeFixers.Roslyn5000 (ReferenceOutputAssembly="false") and update the packaged analyzer entry for roslyn5.0 to point at the Roslyn5000 DLL. This ensures the Roslyn 5.0 code fixers are built and included in the package analyzers folder for roslyn5.0 compatibility.
Update unit tests to run against different C# language versions: add DataRow(LanguageVersion.Preview) to each test and, under ROSLYN_5_0_0_OR_GREATER, add DataRow(LanguageVersion.CSharp14). Change test methods to accept a LanguageVersion parameter and use it when constructing CSharpCodeFixTest (replace hardcoded LanguageVersion.Preview). Conditional compilation preserves compatibility with older Roslyn targets.
This was referenced Mar 24, 2026
This was referenced Aug 24, 2026
This was referenced Aug 31, 2026
Open
RootMeanSqr
pushed a commit
to RootMeanSqr/xsd-editor
that referenced
this pull request
Sep 4, 2026
Updated [CommunityToolkit.Mvvm](https://github.com/CommunityToolkit/dotnet) from 8.4.0 to 8.4.2. <details> <summary>Release notes</summary> _Sourced from [CommunityToolkit.Mvvm's releases](https://github.com/CommunityToolkit/dotnet/releases)._ ## 8.4.2 ## What's Changed * Fix incorrect version check order in MVVMToolkitRemoveDuplicateAnalyzers target by @Sergio0694 in CommunityToolkit/dotnet#1174 **Full Changelog**: CommunityToolkit/dotnet@v8.4.1...v8.4.2 ## 8.4.1 This release of the .NET Community Toolkit updates the MVVM Toolkit analyzers and source generator to Roslyn 5.0, so they can work with C# 14 out of the box. This means that `[ObservableProperty]` on partial properties no longer needs `preview` language version 🎉 ## What's Changed 🆕 * Migrate workflow to GitHub Actions by @Sergio0694 in CommunityToolkit/dotnet#1105 * Remove extra dash in `--no-build` argument in dotnet test invokation by @echoix in CommunityToolkit/dotnet#1132 * Bump unit tests from .NET 7 to .NET 9 by @Sergio0694 in CommunityToolkit/dotnet#1085 * Migrate solution to '.slnx' format by @Sergio0694 in CommunityToolkit/dotnet#1133 * Remove .NET 7 TFM by @Sergio0694 in CommunityToolkit/dotnet#1134 * fix object.Equals for EquatableArray by @JamesYFC in CommunityToolkit/dotnet#1120 * Handle 'CanExecute' with method overrides by @Sergio0694 in CommunityToolkit/dotnet#1081 * Migrate to new MSTest APIs to prepare for 4.0.x by @Sergio0694 in CommunityToolkit/dotnet#1136 * Update MSTest to latest by @Sergio0694 in CommunityToolkit/dotnet#1137 * Update NuGet packages and Windows SDK props by @Sergio0694 in CommunityToolkit/dotnet#1047 * Update to .NET 10 SDK, add .NET 10 TFM to test projects by @Sergio0694 in CommunityToolkit/dotnet#1144 * Fix C# language version checks for `[ObservableProperty]` by @Sergio0694 in CommunityToolkit/dotnet#1140 * Eliminate this = default shortcut when height * width = 0 by @marcin-krystianc in CommunityToolkit/dotnet#1130 * Support nested blocks in semi-auto property analyzer, add tests by @Youssef1313 in CommunityToolkit/dotnet#1025 * Update .NET SDK and NuGet dependencies by @Sergio0694 in CommunityToolkit/dotnet#1155 * Update Roslyn 5.0 analyzer and code fixer paths by @Sergio0694 in CommunityToolkit/dotnet#1156 * Update analyzers for C# 14.0 language version checks by @Sergio0694 in CommunityToolkit/dotnet#1159 * Fix deterministic builds, improve GitHub links by @Sergio0694 in CommunityToolkit/dotnet#1170 * Add MVVM Toolkit code fixer for Roslyn 5.0 by @Sergio0694 in CommunityToolkit/dotnet#1171 ## New Contributors * @echoix made their first contribution in CommunityToolkit/dotnet#1132 * @JamesYFC made their first contribution in CommunityToolkit/dotnet#1120 * @marcin-krystianc made their first contribution in CommunityToolkit/dotnet#1130 **Full Changelog**: CommunityToolkit/dotnet@v8.4.0...v8.4.1 Commits viewable in [compare view](CommunityToolkit/dotnet@v8.4.0...v8.4.2). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new multi-targeted code fixer for the MVVM Toolkit, so that it works correctly with C# 14.