Skip to content

Conversation

@StephaneDelcroix
Copy link
Contributor

@StephaneDelcroix StephaneDelcroix commented Nov 21, 2025

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.

  • Document file naming and location conventions (MauiXXXXX pattern in Issues/ folder)
  • Explain basic test pattern with nested Tests class and [Values] XamlInflator
  • Cover XamlC and SourceGen testing with MockCompiler and MockSourceGenerator
  • Document special file extensions (.rt.xaml, .rtsg.xaml, .rtxc.xaml) for invalid codegen scenarios

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.

Copilot AI review requested due to automatic review settings November 21, 2025 08:09
Copilot finished reviewing on behalf of StephaneDelcroix November 21, 2025 08:12
Copy link
Contributor

Copilot AI left a 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 FallbackValue flag was incorrectly used instead of TargetNullValue
  • 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

@StephaneDelcroix StephaneDelcroix force-pushed the dev/stdelc/xaml-unittest-instructions branch from 0dd358a to 44cdae5 Compare November 21, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants