Skip to content

LHQ Model v2 Changes

Peter Šulek edited this page Jan 3, 2026 · 12 revisions

Model Version 1

When launched, the LHQ Editor uses model version 1.

The model version serves the following purposes:

  • It defines the structure of *.lhq JSON-like files.
  • It instructs the LHQ Visual Studio extension to use T4 templates for generating code from *.lhq files.

Note

Due to the reliance on T4 templates, the LHQ extension with *.lhq files and model version 1 is limited to the Visual Studio IDE.


Model Version 2

Starting from version 2025.1 of the LHQ Editor VS2022, a new model version 2 has been introduced. This allows code generation from *.lhq files without requiring the Visual Studio IDE.

Key improvements include:

  • Code generation within Visual Studio IDE is still supported.
  • *.lhq files with model version 1 will continue to use the legacy T4 templates:
    • T4 templates are only applicable within the Visual Studio IDE.
    • When using other applications (e.g., LHQ Editor App, LHQ.Gen.Cmd.exe, or similar), the new modern generator will be automatically employed.
  • *.lhq files with model version 2 will always utilize the new modern generator for code generation.

New Features in Model Version 2

Model version 2 introduces two new options for templates:

  1. Encoding with BOM
    • A flag indicating whether the UTF-8 encoding includes a BOM (Byte Order Mark).
  2. Line Endings (LF or CRLF)
    • Specifies the line endings used when saving generated files to disk.

These options can be configured in the Generate Code Settings section, located in the bottom-right status bar of the editor.

Important

These new options are only supported in model version 2 and later.


Modern Generator

The modern generator leverages Handlebars templates, which are powered by the Handlebars.js engine.

This approach was chosen to enable code generation on multiple platforms (Windows, Linux, macOS) in the future. Additionally, it aims to support various contexts such as browsers, Node.js, CI/CD pipelines, cloud services, and VS Code extensions. These enhancements are planned for upcoming releases.

Note

Currently, only Windows applications are supported. These rely on the ChakraCore engine win-x64 to run the Handlebars.js engine.
Applications for other operating systems and platforms (e.g., Linux, macOS) are not yet available.

The modern generator is now accessible through the following applications:

  1. LHQ Editor VS2022 Extension

    • Available from version 2025.1 onwards.
    • Automatically generates code upon saving the *.lhq file in the editor.
  2. Standalone Desktop Application: LHQ Editor App

    • Download the Lhq.App.Setup.msi installer from releases.
    • Operates independently of Visual Studio.
    • Code generation can occur automatically upon saving or manually via the Generate Code button.
  3. Command-Line Utility: LHQ.Gen.Cmd.exe

    • Installed alongside the Lhq.App.Setup.msi.
    • Enables code generation directly from the command line for input *.lhq files, without a graphical user interface.

Compatibility

The latest LHQ Editor VS2022 versions (2025.1 and later) maintain compatibility with *.lhq files using model version 1. This is achieved through T4 templates for code generation.

For files using model version 2, the modern generator is employed for code generation across all supported platforms and applications, including:

  • VS2022 extension
  • Desktop application
  • Command-line utility

Deprecated T4 Template Files (*.lhq.tt)

Once a *.lhq file is upgraded to model version 2, any associated T4 template files (*.lhq.tt) become obsolete and can be safely deleted.

For example:

  1. An existing model file Strings.lhq uses model version 1.
  2. Upgrade Strings.lhq to model version 2:
    • Update the model.version property manually in the file.
    • Or use the UI in the Project Settings dialog.
  3. Locate the corresponding Strings.lhq.tt file and delete it.

Troubleshooting After Upgrading to Model Version 2

If you encounter issues generating code from *.lhq files after upgrading to model version 2:

  1. Report the issue on the GitHub issues page.
  2. Manually edit the *.lhq file and change the model.version property back to 1.
  3. Revert to the older model version by downloading v2023.1.