Skip to content

Simplify null-filtering and null-conditional patterns in recent WinUI additions - #10345

Merged
Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/simplify-winui-null-patterns
Jul 30, 2026
Merged

Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/simplify-winui-null-patterns

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Fixes #10344.

The [code-simplifier] agentic workflow could not open its own PR (GitHub Actions is not permitted to create pull requests in this repo), so this PR carries the same change.

Simplifies two spots added by #10330 (Support testing unpackaged WinUI apps under Microsoft.Testing.Platform). No behavioral change.

Changes

  • src/Platform/Microsoft.Testing.Extensions.PackagedApp/AppxManifestInfo.cs — replaced the .Where(x => x is not null).Select(x => x!) null-filtering pair with the idiomatic .OfType<AppxApplicationInfo>(), which filters and narrows the type in one step and drops the null-forgiving operator.
  • src/TestFramework/TestFramework.Extensions/Attributes/WinUI_UITestMethodAttribute.cs — replaced the local-variable + ternary body of GetApplicationType with assembly.GetCustomAttribute<WinUITestTargetAttribute>()?.ApplicationType, matching the repo's preferred ?. style.

Verification

Built both affected projects (.\build.cmd -projects ...) — succeeded with 0 warnings / 0 errors across all target frameworks, including the WinUI TFM net8.0-windows10.0.18362.0 that actually compiles WinUI_UITestMethodAttribute.cs.

… additions

- Replace .Where(x => x is not null).Select(x => x!) with .OfType<T>() in AppxManifestInfo.ReadFromManifest
- Replace multi-step GetApplicationType body with a null-conditional expression

Fixes #10344

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e1823176-45ef-46a2-83fa-a73f927879c6
Copilot AI review requested due to automatic review settings July 30, 2026 14:57

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.

Pull request overview

Simplifies recently added WinUI code without changing behavior.

Changes:

  • Uses OfType<AppxApplicationInfo>() for null filtering and type narrowing.
  • Uses null-conditional access when retrieving the WinUI application type.
Show a summary per file
File Description
AppxManifestInfo.cs Simplifies application filtering.
WinUI_UITestMethodAttribute.cs Simplifies nullable attribute access.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Medium

@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.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

Review Summary

Clean simplification PR — no issues found across all 22 dimensions.

Dimension Verdict
1. Algorithmic Correctness ✅ .OfType<T>() is semantically equivalent to .Where(x => x is not null).Select(x => x!) when the source is IEnumerable<T?>. The null-conditional ?.ApplicationType returns null when either the attribute or the property is null — same as the original ternary.
2. Threading & Concurrency N/A
3. Security & IPC Contract Safety N/A
4. Public API & Binary Compatibility ✅ No public API surface change.
5. Performance & Allocations ✅ .OfType<T>() avoids one delegate allocation vs the chained .Where().Select().
6. Cross-TFM Compatibility ✅ Both OfType and ?. are available on all target frameworks.
7–22. Remaining dimensions N/A — no new types, no resource strings, no tests modified, no build changes, no CLI options.

Verdict: All clear. Both simplifications are correct, idiomatic, and introduce no behavioral change.

@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jul 30, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit c07728f into main Jul 30, 2026
28 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/simplify-winui-null-patterns branch July 30, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[code-simplifier] Simplify null-filtering and null-conditional patterns in recent WinUI additions

4 participants