Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 1.55 KB

File metadata and controls

65 lines (44 loc) · 1.55 KB

XAML Preprocessor

A preprocessor for WPF XAML files that enables conditional compilation using XML comments, providing functionality similar to C#'s #if...#endif preprocessor directives.

Features

  • Use conditional compilation in XAML files
  • Compatible with existing DefineConstants from C# projects
  • Integrates with MSBuild process
  • Supports both true/false conditions
  • Preserves source files (processes intermediate copies)
  • Full UTF-8 with BOM support for XAML compatibility

Usage Example

<!-- fix_issue_001:true -->
<Button Content="New Implementation"/>
<!-- end fix_issue_001:true -->

<!-- fix_issue_001:false -->
<Button Content="Old Implementation"/>
<!-- end fix_issue_001:false -->

Installation

Install via NuGet Package Manager:

Install-Package XamlPreprocessor

Configuration

Define your constants through:

  1. MSBuild command line:
msbuild.exe /p:DefineConstants="fix_issue_001;feature_002"
  1. Or project file (.csproj):
<PropertyGroup>
  <DefineConstants>$(DefineConstants);fix_issue_001;feature_002</DefineConstants>
</PropertyGroup>

How It Works

  1. During build, creates preprocessed copies of XAML files in the intermediate directory
  2. Applies XSLT transformation based on defined constants
  3. Uses preprocessed copies for compilation while preserving source files
  4. Handles proper UTF-8 encoding with BOM for XAML compatibility

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License