Skip to content

Add a code fix that makes QueryProperty types partial - #40677

Merged
kubaflo merged 25 commits into
mainfrom
simonrozsival-query-property-make-partial
Dec 1, 2026
Merged

kubaflo merged 25 commits into
mainfrom
simonrozsival-query-property-make-partial

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 4a9b444152e010f5bcc72b7a5a4b987ab65128ac

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ 66 QueryProperty generator and fixer tests pass, including generated-declaration regressions.
↑ 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

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

This .NET 12 change follows #40676, which has been merged to main and 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.

  • The generator reports a missing partial modifier, 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.
  • The fixer adds partial to 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.
  • Fix All offers Document, Project and Solution scopes. IDE hosts do not pass source-generator diagnostics to 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.
  • Keep the fixer in its own Microsoft.Maui.Controls.SourceGen.CodeFixes assembly because generator assemblies must not reference Roslyn Workspaces (RS1038).
  • Include focused tests for classes, records, containing types, inherited attributes, split and mixed declarations across documents, generated declarations, Fix All, and unsupported reasons with and without partial.
  • Package the fixer with Controls Build.Tasks and load it through Microsoft.Maui.Controls.targets.

Issues Fixed

Fixes #

Let AI finish this PR

  • Let the MAUI agent address review feedback and fix remaining issues on this PR. Maintainers still decide whether it is merged. For PRs from forks, keep "Allow edits by maintainers" on so the agent can push to your branch; otherwise it opens a follow-up PR that keeps your commits.

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 under buildTransitive/netstandard2.0, and Microsoft.Maui.Controls.targets adds both as Analyzer items.
  • The VS Code Roslyn language server, loading the analyzers from the packed nupkg, offered "Make type partial" and applied the single fix and Document, Project and Solution Fix All across two projects, split declarations, a linked file, an unsaved edit and a generated containing declaration. Suppressed MAUI1200 and an unsupported init-only property were left unchanged.
  • Earlier, dotnet build of Controls.SourceGen.csproj and Controls.SourceGen.CodeFixes.csproj (--no-incremental) passed with 0 warnings.
  • An earlier Roslyn AdhocWorkspace smoke test loaded the analyzers from the packed nupkg through AnalyzerFileReference, discovered the fixer, and applied Solution Fix All across three files. This simulated host provided generator diagnostics to Fix All.
  • Earlier, a project importing the packed Microsoft.Maui.Controls.targets with _MauiBindingInterceptorsSupport=false built successfully.
  • Not checked: Visual Studio and OmniSharp themselves (neither is installed here).

simonrozsival and others added 14 commits November 26, 2026 21:04
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

Copy link
Copy Markdown
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.

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 2 findings

Reviewed commit 2cefa57.

See inline comments for details.

…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>
@github-actions

This comment has been minimized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo

This comment has been minimized.

simonrozsival and others added 3 commits November 30, 2026 19:18
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>
@simonrozsival
simonrozsival marked this pull request as ready for review November 30, 2026 18:29
Copilot AI balanced review requested due to automatic review settings November 30, 2026 18:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Selected Tests

@kubaflo — AI-selected UI tests and device tests (GPT-6.2 Sol + MAI Code 2) for commit aaf9104b.

Result NOTHING TO RUN Platforms none Tests 0 UI, 0 device Commit aaf9104b


🧪 Test selection — click to expand
Suite Result Selected Build
UI tests ➖ nothing to run none —
Device tests ➖ nothing to run none —
🧪 UI tests — nothing to run

ℹ️ The AI found no changes relevant to UI tests, so no maui-pr-uitests run was queued.

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.

🧪 Running — nothing

No UI tests run for this PR.

🧪 Device tests — nothing to run

ℹ️ The AI found no changes relevant to device tests, so no maui-pr-devicetests run was queued.

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.

🧪 Running — nothing

No device tests run for this PR.

⏭️ Skipped — what neither suite runs

UI tests — 77 categories, 4 platforms

Platforms not run: Android, iOS, MacCatalyst, Windows

Each skipped platform and category is listed as a maui-pr-uitests (skipped) … status on this commit. Use /azp run maui-pr-uitests for the full suite.

Device tests — 105 categories, 4 platforms

Platforms not run: Android, iOS, MacCatalyst, Windows

Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.

🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)

UI tests

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol MAI Code 2
Android — —
iOS — —
MacCatalyst — —
Windows — —

GPT-6.2 Sol — No UI tests selected: the QueryProperty change adds an IDE fix without changing generated navigation code for supported types.

  • QueryPropertyGenerator changes MAUI1200 diagnostics, not the generated code for supported types.
  • Build.Tasks ships and registers an IDE-only fixer; no UI app behavior or UI tests changed.

MAI Code 2 — QueryProperty source-generator/code-fix packaging change; no UI or device runtime behavior needs coverage.

  • QueryPropertyGenerator changes diagnostic metadata and generation gating, with code-fix assembly packaging added.
  • The new Roslyn code-fix edits type declarations in developer source and is covered by source-generator/code-fix unit tests.
  • No controls, handlers, platform code, UI tests, or runtime behavior changed; UI suites are deliberately omitted.

Device tests

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol MAI Code 2
Android — —
iOS — —
MacCatalyst — —
Windows — —

GPT-6.2 Sol — No device tests selected: the change is limited to Roslyn diagnostics and IDE code fixes.

  • SourceGen.UnitTests covers the partial modifier fix and Fix All.
  • No device test files, runtime handlers, or Shell query-assignment code changed.

MAI Code 2 — Compile-time Roslyn QueryProperty generator and code-fix changes only; no device tests are affected.

  • Generator diagnostics and the new code-fix operate during compilation/IDE editing, not at application runtime.
  • Packaging and solution changes add the code-fix analyzer but do not alter device handlers or platform behavior.
  • No device tests or runtime APIs changed; existing unit coverage is the appropriate validation.

Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — No more findings

Reviewed commit aaf9104.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it label Nov 30, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) label Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added s/autopilot-waiting-for-maintainer-review MAUI Autopilot finished: expert review clean and tests passed; waiting for maintainer review and removed s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) labels Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

MAUI Autopilot — Ready for maintainer review

Results
Expert review No more findings on aaf9104
Tests No UI or device tests affected
Review threads 3 resolved

Base automatically changed from simonrozsival-remove-query-property-reflection to main November 30, 2026 22:26
simonrozsival and others added 3 commits December 1, 2026 12:07
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>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment on lines +67 to +68
if (document.Project.Solution.GetDocument(reference.SyntaxTree) is null or SourceGeneratedDocument)
return null;
@kubaflo
kubaflo merged commit 117ed6d into main Dec 1, 2026
6 of 7 checks passed
@kubaflo
kubaflo deleted the simonrozsival-query-property-make-partial branch December 1, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s/autopilot-waiting-for-maintainer-review MAUI Autopilot finished: expert review clean and tests passed; waiting for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants