-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add XAML unit testing guidelines #32788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.