Repository navigation
Configuration
Myra UI Generator can be configured to customize the namespace and XML directory paths for generated code.
The generator supports two configuration methods:
- .editorconfig (Recommended) - Project-wide configuration
- MSBuild Properties - Build-time configuration
Both methods support the same configuration keys:
-
myra_ui_generator.namespace- Namespace for generated classes -
myra_ui_generator.xml_directory- Directory where XML files are located
If no configuration is provided, the generator uses:
-
Namespace:
GeneratedUI -
Directory:
Content/UI
The recommended way to configure the generator is using .editorconfig files. This provides a simple, version-controlled configuration.
Create or update .editorconfig in your project root:
[*.cs]
# Namespace for generated UI classes
myra_ui_generator.namespace = YourNamespace.UI.Generated
# Directory where XML files are located (relative to project root)
myra_ui_generator.xml_directory = Content/UI[*.cs]
myra_ui_generator.namespace = MyGame.UI
myra_ui_generator.xml_directory = Content/UI[*.cs]
myra_ui_generator.namespace = MyGame.UserInterface.Generated
myra_ui_generator.xml_directory = Assets/UserInterfaceIf you have multiple projects with different configurations, you can use project-specific .editorconfig files in each project directory.
The xml_directory setting uses case-insensitive path matching. The generator will find XML files whose paths contain the specified directory string.
Examples:
- Setting:
Content/UI - Matches:
Content/UI/Menu.xml - Matches:
C:/Projects/MyGame/Content/UI/Settings.xml - Matches:
Content\UI\TitleScreen.xml(Windows paths normalized)
Issue: Configuration not being read
Solutions:
- Ensure
.editorconfigis in the project root (same directory as.csproj) - Restart your IDE after creating/modifying
.editorconfig - Rebuild the project (configuration is read at build time)
- Check for syntax errors in
.editorconfig(use proper INI format)
You can also configure the generator using MSBuild properties in your .csproj file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<!-- Generator Configuration -->
<MyraUIGenerator_namespace>MyGame.UI.Generated</MyraUIGenerator_namespace>
<MyraUIGenerator_xml_directory>Content/UI</MyraUIGenerator_xml_directory>
</PropertyGroup>
<!-- Rest of your project file -->
</Project>dotnet build /p:MyraUIGenerator_namespace=MyGame.UI.Generated /p:MyraUIGenerator_xml_directory=Content/UIMSBuild properties use this format:
-
MyraUIGenerator_namespace(replaces dots with underscores) MyraUIGenerator_xml_directory
Use MSBuild properties when:
- You need different configurations for different build configurations (Debug/Release)
- You're using conditional compilation
- You need to set properties dynamically
- You prefer project file configuration over
.editorconfig
The generator checks configuration in this order:
- MSBuild Properties (highest priority)
- .editorconfig Global Options
- .editorconfig Per-File Options
- Default Values (lowest priority)
To verify your configuration is working:
- Build your project
- Check the build output for diagnostic messages:
-
MYRA002: Shows the namespace and directory being used -
MYRA003: Shows how many XML files were found
-
- Check generated files in
obj/Debug/net6.0/generated/(path varies by framework) - Verify the namespace in generated code matches your configuration
Project Structure:
MyGame/
├── MyGame.csproj
├── .editorconfig
└── Content/
└── UI/
├── MainMenu.xml
└── Settings.xml
.editorconfig:
[*.cs]
myra_ui_generator.namespace = MyGame.UI
myra_ui_generator.xml_directory = Content/UIResult: Generated classes in MyGame.UI namespace for XML files in Content/UI/.
Solution Structure:
MyGameSolution/
├── MyGame.Core/
│ ├── MyGame.Core.csproj
│ └── .editorconfig (namespace: MyGame.Core.UI)
├── MyGame.Client/
│ ├── MyGame.Client.csproj
│ └── .editorconfig (namespace: MyGame.Client.UI)
└── Shared/
└── UI/
├── SharedMenu.xml
└── SharedSettings.xml
Each project can have its own .editorconfig with different namespaces.
- Learn about Basic Usage
- See Common Patterns
- Check Troubleshooting if configuration isn't working