Repository navigation
Simplify null-filtering and null-conditional patterns in recent WinUI additions - #10345
Merged
Amaury Levé (Evangelink) merged 1 commit intoJul 30, 2026
Merged
Conversation
… 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
Contributor
There was a problem hiding this comment.
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
Contributor
There was a problem hiding this comment.
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.
Petr Pokorny (0101)
approved these changes
Jul 30, 2026
Amaury Levé (Evangelink)
deleted the
dev/amauryleve/simplify-winui-null-patterns
branch
July 30, 2026 17:12
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.
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 ofGetApplicationTypewithassembly.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 TFMnet8.0-windows10.0.18362.0that actually compilesWinUI_UITestMethodAttribute.cs.