Repository navigation
Add a code fix that makes QueryProperty types partial - #40677
Conversation
Microsoft.CodeAnalysis.Analyzers 5.12.0 (#40641) adds RS1038, which fails every UI test build because UITest.Analyzers references Microsoft.CodeAnalysis.CSharp.Workspaces for its code fix providers. The analyzer types don't use Workspaces APIs, so the compiler can load and run them without Workspaces; the code fixes are only loaded by IDEs, which provide it. The assembly is test-only and isn't shipped. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
#40387 made the nested _17521CatDetailsPage and _33356CatDetailsPage partial but not their containing Shell types. The QueryProperty generator skips such types, so navigating to them throws at runtime on every platform. On Windows the build also fails with CS0260: the CsWinRT 2.1.2 AOT generator in the pinned Windows SDK projection (10.0.19041.44) emits a partial declaration of the containing type for nested partial classes that implement INotifyPropertyChanged. Newer CsWinRT versions skip types with non-partial containers. ShellSearchControlPage.SearchDetailPage wasn't partial either, so its query property throws at runtime in the same way. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
No call in ApplyLegacyQueryProperties or ValidateGeneratedQueryProperties requires unreferenced code, so ILLink reports IL2121 for the IL2026 suppressions. iOS trimmed builds report IL2121, which fails the RunOniOS_MauiReleaseTrimFull_CoreCLR integration test. The IL2067 and IL2072 suppressions are still used. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
#36581 replaced the Windows ImageProcessor.RotateImageAsync with the shared Graphics-based ImageProcessor, breaking the Windows Essentials device test build (CS0117, followed by WMC0001 because the XAML compiler can't resolve MiddleApp without the C# compile). The Issue38570 test now processes the image through ProcessImageToCacheFileAsync with the options MediaPicker uses for RotateImage = true, and still checks that the stored pixels are rotated exactly once and that the preserved metadata doesn't rotate them again. Processing always writes a new file now, so the unchanged-stream check for orientation 1 no longer applies. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…0 test Disposing the AsStreamForWrite adapter closes the underlying InMemoryRandomAccessStream, so seeking it afterwards threw ObjectDisposedException in all eight Windows cases. Decode and assert inside the adapter's using block, as the original test did. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The two IDE-only code fix providers were the only reason UITest.Analyzers referenced Microsoft.CodeAnalysis.Workspaces, which RS1038 flags. They had no tests. Remove them and the Workspaces reference so the analyzer builds without the suppression. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Revert the removal: the IDE quick fixes for MAUI0001 stay, and RS1038 stays suppressed for this test-only analyzer. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
RS1038 fires when an assembly that contains a DiagnosticAnalyzer references Microsoft.CodeAnalysis.Workspaces. The NUnit category code fix providers need Workspaces, so move them into a new UITest.Analyzers.CodeFixes project. That leaves UITest.Analyzers with compiler-only references and lets us remove the RS1038 suppression. The TestCases projects load both assemblies as analyzers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
QueryProperty is now compile-time only: - Delete QueryPropertyConversion.ApplyLegacyQueryProperties and ValidateGeneratedQueryProperties (and their trimming suppressions). - The IQueryAttributable.ApplyQueryProperties default implementation is empty; ShellContent no longer inspects attributes at runtime. - MAUI1200 is always reported, as an error, instead of a warning gated on EnableTrimAnalyzer. Non-partial types (including subclasses and types nested in non-partial containers) now fail the build. - Drop redundant empty ApplyQueryProperties stubs and make HostApp containers partial so their nested QueryProperty pages are generated. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
MAUI1200 diagnostics caused only by a missing partial modifier now carry a MissingPartial property. A new Microsoft.Maui.Controls.SourceGen.CodeFixes analyzer assembly (kept separate because generators can't reference Workspaces) offers a "Make type partial" fix that adds partial to the type and its non-partial containing types, with Fix All support. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep PR1 focused on removing QueryProperty reflection. The partial-keyword code fix will be added in a follow-up PR stacked on this change. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Offer a code fix for MAUI1200 diagnostics caused by non-partial types, including containing types and subclasses. Keep the fixer in its own Workspaces-referencing assembly and package it with Controls Build.Tasks. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…ocker Run the remaining MAUI1200 checks before marking a diagnostic as fixable, so types with init-only or otherwise unsupported properties no longer get a fix that cannot resolve the error. Make the fix update every non-partial declaration of the type and its containing types across documents, and collect Fix All diagnostics per document for document, project and solution scopes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Merge the compile-time-only parent branch. Fix All now reruns the QueryProperty generator per selected project because IDE hosts do not surface source-generator diagnostics through FixAllContext, skips suppressed diagnostics, and maps locations via the original syntax tree. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the new “Make type partial” code fix.
No open issues 🎉
What changed in this PR
Adds a “Make type partial” IDE code fix to support .NET MAUI 12’s compile-time [QueryProperty] handling. It addresses MAUI1200 when missing partial modifiers are the only generation blocker.
Changes:
- Marks eligible diagnostics as fixable and preserves syntax-tree locations.
- Adds single-fix and Document, Project, and Solution Fix All support across target and containing-type declarations.
- Packages the fixer separately from the generator, integrates it into build configurations, and adds tests and documentation.
| File | Description |
|---|---|
src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj |
References the new code-fix project. |
src/Controls/tests/SourceGen.UnitTests/MakeQueryPropertyTypePartialCodeFixProviderTests.cs |
Tests fixes, scopes, split declarations, suppression, and unsupported cases. |
src/Controls/src/SourceGen/QueryPropertyGenerator.cs |
Identifies fixable diagnostics and preserves source-tree locations. |
src/Controls/src/SourceGen.CodeFixes/MakeQueryPropertyTypePartialCodeFixProvider.cs |
Implements single and Fix All partial-modifier edits. |
src/Controls/src/SourceGen.CodeFixes/Controls.SourceGen.CodeFixes.csproj |
Defines the separate IDE code-fix assembly. |
src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets |
Loads the packaged code-fix assembly. |
src/Controls/src/Build.Tasks/Controls.Build.Tasks.csproj |
Builds and packages the fixer. |
Microsoft.Maui.sln |
Includes the code-fix project and build configurations. |
Microsoft.Maui.BuildTasks.slnf |
Includes the fixer in build-task builds. |
Microsoft.Maui-windows.slnf |
Includes the fixer in Windows builds. |
Microsoft.Maui-vscode.sln |
Includes the fixer in the VS Code solution. |
Microsoft.Maui-mac.slnf |
Includes the fixer in Mac builds. |
Microsoft.Maui-dev.sln |
Includes the fixer in the development solution. |
eng/Microsoft.Maui.Packages.slnf |
Includes the fixer in package builds. |
eng/Microsoft.Maui.Packages-mac.slnf |
Includes the fixer in Mac package builds. |
docs/design/FeatureSwitches.md |
Documents the partial-modifier fix and Fix All support. |
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Selected Tests
🧪 Test selection — click to expand
🧪 UI tests — nothing to runℹ️ The AI found no changes relevant to UI tests, so no GPT-6.2 Sol: No UI tests selected: the QueryProperty change adds an IDE fix without changing generated navigation code for supported types. 🧪 Running — nothingNo UI tests run for this PR. 🧪 Device tests — nothing to runℹ️ The AI found no changes relevant to device tests, so no GPT-6.2 Sol: No device tests selected: the change is limited to Roslyn diagnostics and IDE code fixes. 🧪 Running — nothingNo device tests run for this PR. ⏭️ Skipped — what neither suite runsUI tests — 77 categories, 4 platforms Platforms not run: Android, iOS, MacCatalyst, Windows Each skipped platform and category is listed as a Device tests — 105 categories, 4 platforms Platforms not run: Android, iOS, MacCatalyst, Windows Each skipped platform and project is listed as a 🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)UI testsEach model chose independently; every test that runs was selected by at least one of them.
GPT-6.2 Sol — No UI tests selected: the QueryProperty change adds an IDE fix without changing generated navigation code for supported types.
MAI Code 2 — QueryProperty source-generator/code-fix packaging change; no UI or device runtime behavior needs coverage.
Device testsEach model chose independently; every test that runs was selected by at least one of them.
GPT-6.2 Sol — No device tests selected: the change is limited to Roslyn diagnostics and IDE code fixes.
MAI Code 2 — Compile-time Roslyn QueryProperty generator and code-fix changes only; no device tests are affected.
Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification. |
There was a problem hiding this comment.
Expert Review — No more findings
Reviewed commit aaf9104.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
MAUI Autopilot · round 1 No new commit was needed: the current head already addresses all three open findings and includes regression coverage for each. The targeted test run could not start because .NET SDK initialization failed on this runner. |
MAUI Autopilot — Ready for maintainer reviewResults
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The code fix can modify generated files included as ordinary project documents, causing regeneration to undo the repair; generated-document checks and regression coverage for single-fix and Fix All scenarios are needed.
1 open issue
Review effort: Balanced
| if (document.Project.Solution.GetDocument(reference.SyntaxTree) is null or SourceGeneratedDocument) | ||
| return null; |

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
4a9b444152e010f5bcc72b7a5a4b987ab65128ac↑ The packaged fixer worked in the VS Code Roslyn language server for single fixes and all three Fix All scopes, including a generated containing type.
↓ Visual Studio and OmniSharp were not tested.
↓ CI on the updated head is not yet complete.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Target Branch
mainnet11, for reviewThis .NET 12 change follows #40676, which has been merged to
mainand was stacked on #40674 and #40666. It adds the partial-keyword code fix as the separate second PR in the QueryProperty change.For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
When MAUI1200 is reported because a
[QueryProperty]type or one of its containing types is not partial, offer a "Make type partial" IDE fix when the required declarations can be edited.partialmodifier, marked as fixable, only when that is the sole reason generation is blocked. If anything else also blocks it (init-only or inaccessible setters, unsupported property types, obsolete errors, and so on), that other reason is reported and no fix is offered.partialto every non-partial declaration of the type and of each containing type, including declarations split across documents and mixed partial/non-partial declarations. Already-partial generated declarations are left untouched; if a generated declaration would need editing, the fix is not offered and Fix All skips that diagnostic.FixAllContext, so Fix All reruns the QueryProperty generator once per selected project, skips suppressed diagnostics, and applies one solution-wide edit. Generator diagnostic locations keep the original syntax tree so documents without a file path map correctly.Microsoft.Maui.Controls.SourceGen.CodeFixesassembly because generator assemblies must not reference Roslyn Workspaces (RS1038).partial.Microsoft.Maui.Controls.targets.Issues Fixed
Fixes #
Let AI finish this PR
Validation
dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj --no-restore -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:AssemblyVersion=11.0.0.0 --filter 'FullyQualifiedName~QueryProperty' -v:q: passed, 66/66.dotnet pack src/Controls/src/Build.Tasks/Controls.Build.Tasks.csproj --no-restore -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:AssemblyVersion=11.0.0.0 -o artifacts/queryproperty-verification/packages -v:q: passed. The package contains the generator and code-fix DLLs underbuildTransitive/netstandard2.0, andMicrosoft.Maui.Controls.targetsadds both asAnalyzeritems.dotnet buildofControls.SourceGen.csprojandControls.SourceGen.CodeFixes.csproj(--no-incremental) passed with 0 warnings.AdhocWorkspacesmoke test loaded the analyzers from the packed nupkg throughAnalyzerFileReference, discovered the fixer, and applied Solution Fix All across three files. This simulated host provided generator diagnostics to Fix All.Microsoft.Maui.Controls.targetswith_MauiBindingInterceptorsSupport=falsebuilt successfully.