Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive XAML unit testing guidelines to help developers write consistent tests for the Controls.Xaml.UnitTests project. The documentation covers file naming conventions, basic test patterns, and handling of invalid code generation scenarios. Additionally, the PR includes improvements to the SourceGen test infrastructure by adding compilation error validation and fixes a bug in CompiledBindingMarkup.cs where the wrong flag was being checked for TargetNullValue binding expressions.
Key changes:
- Added XAML unit testing guidelines document with naming conventions and test patterns
- Enhanced SourceGeneratorDriver to validate generated code compiles without errors
- Fixed bug in compiled bindings where
FallbackValueflag was incorrectly used instead ofTargetNullValue - Added test case for issue #32606 validating TargetNullValue with nullable path scenarios
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| .github/instructions/xaml-unittests.instructions.md | New documentation providing XAML unit testing conventions and patterns |
| src/Controls/tests/SourceGen.UnitTests/SourceGeneratorDriver.cs | Added compilation validation and new overload for single AdditionalFile; improved reference initialization |
| src/Controls/tests/SourceGen.UnitTests/InitializeComponent/XStaticUnresolvedType.cs | Added assertNoCompilationErrors parameter to tests expecting invalid generated code |
| src/Controls/tests/SourceGen.UnitTests/InitializeComponent/UnresolvedType.cs | Added assertNoCompilationErrors parameter to test expecting invalid generated code |
| src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SourceGenXamlInitializeComponentTests.cs | Added assertNoCompilationErrors parameter to RunGenerator method |
| src/Controls/tests/SourceGen.UnitTests/InitializeComponent/LineInfoTests.cs | Removed trailing whitespace |
| src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CompiledBindings.cs | Added new test for issue #32606 validating TargetNullValue with nullable paths |
| src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CircularReferenceExtension.cs | Updated to use collection expression syntax |
| src/Controls/src/SourceGen/RDSourceConverter.cs | Changed to verbatim string literals for URIs to handle backslashes |
| src/Controls/src/SourceGen/NodeSGExtensions.cs | Changed to verbatim string literal for URI construction |
| src/Controls/src/SourceGen/KnownMarkups.cs | Changed to verbatim string literal for URI construction |
| src/Controls/src/SourceGen/CompiledBindingMarkup.cs | Fixed bug: changed FallbackValue flag check to TargetNullValue flag check |
src/Controls/tests/SourceGen.UnitTests/SourceGeneratorDriver.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/SourceGen.UnitTests/SourceGeneratorDriver.cs
Outdated
Show resolved
Hide resolved
0dd358a to
44cdae5
Compare
jfversluis
approved these changes
Nov 25, 2025
This was referenced Dec 16, 2025
Merged
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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!
Description of Change
Add developer documentation for writing XAML unit tests in Controls.Xaml.UnitTests project.
This provides a reference guide for writing consistent XAML unit tests that follow existing patterns in the codebase.
Issues Fixed
N/A - This is proactive documentation, not fixing a specific issue.