Qml4Net 0.2.0

dotnet add package Qml4Net --version 0.2.0
                    
NuGet\Install-Package Qml4Net -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Qml4Net" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Qml4Net" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Qml4Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Qml4Net --version 0.2.0
                    
#r "nuget: Qml4Net, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Qml4Net@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Qml4Net&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Qml4Net&version=0.2.0
                    
Install as a Cake Tool

Qml4Net

A .NET library for reading and writing QGIS QML (.qml) layer style files.

Ported from qml4dart.

Status

v0.1.0 released — 31 tests passing, 95.6% line coverage.

Features

  • QML Parsing -- Read QGIS .qml layer style files into a typed object model
  • QML Writing -- Serialize the object model back to QML XML
  • Renderer Types -- SingleSymbol, CategorizedSymbol, GraduatedSymbol, RuleRenderer (nested)
  • Symbol Layers -- SimpleMarker, SvgMarker, SimpleLine, SimpleFill, RasterFill
  • Property Formats -- Both new (<Option type="Map">, QGIS >= 3.26) and legacy (<prop k v>)
  • Scale Visibility -- Document-level and rule-level scale-based visibility
  • Zero Dependencies -- Only BCL APIs (System.Xml.Linq)

API

using Qml4Net;

var codec = new QmlCodec();

// Parse QML string
var result = codec.ParseString(qmlXml);
switch (result)
{
    case ReadQmlResult.Success { Document: var doc, Warnings: var warnings }:
        Console.WriteLine($"Renderer: {doc.Renderer.Type}");
        Console.WriteLine($"Symbols: {doc.Renderer.Symbols.Count}");
        foreach (var w in warnings)
            Console.WriteLine($"Warning: {w}");
        break;
    case ReadQmlResult.Failure { Message: var msg }:
        Console.WriteLine($"Error: {msg}");
        break;
}

// Parse QML file (async)
var fileResult = await codec.ParseFileAsync("style.qml");

// Encode to string
var writeResult = codec.EncodeString(doc);
if (writeResult is WriteQmlResult.Success { Xml: var xml })
    Console.WriteLine(xml);

// Encode to file (async)
await codec.EncodeFileAsync("output.qml", doc);

Supported QML Renderer Types

Type XML type Description
SingleSymbol singleSymbol One symbol for all features
CategorizedSymbol categorizedSymbol Features classified by field value
GraduatedSymbol graduatedSymbol Features classified into numeric ranges
RuleRenderer RuleRenderer Filter expressions, supports nesting

Supported Symbol Layer Types

Type XML class Description
SimpleMarker SimpleMarker Point: circle, square, triangle, etc.
SvgMarker SvgMarker SVG-based point markers
SimpleLine SimpleLine Line strokes
SimpleFill SimpleFill Polygon fill with optional outline
RasterFill RasterFill Raster/image pattern fill

Docker Build and Release

The repository includes a multi-stage Dockerfile for building, testing, and publishing.

  • Solution: qml4net.sln
  • Build stages: restore, build, test, pack, push
  • Package output stage: artifacts
  • Coverage gate in test: at least 90% line coverage
  • Public API XML documentation comments are required (CS1591 enforced as error)
docker buildx build --target test -t qml4net:test .
docker buildx build --target artifacts --build-arg PACKAGE_VERSION=0.1.0 -o type=local,dest=./artifacts .
docker buildx build --target push --secret id=nuget_api_key,src=/path/to/nuget-api-key.txt --build-arg PACKAGE_VERSION=0.1.0 .

Notes:

  • push publishes generated .nupkg files to https://api.nuget.org/v3/index.json
  • The preferred credential flow is a BuildKit secret named nuget_api_key
  • NUGET_API_KEY is also supported as a build argument for CI systems that cannot mount secrets

GitHub Actions

  • .github/workflows/ci.yml -- runs on pushes to main and on pull requests
  • .github/workflows/publish-qml4net.yml -- publishes the Qml4Net NuGet package on tags matching Qml4Net-v* or via manual workflow_dispatch

Required GitHub repository setup:

  • Create a repository or environment secret named NUGET_API_KEY
  • If you use GitHub environments, the publish workflow targets the nuget environment
  • Publish tags must use the format Qml4Net-v<semver>, e.g. Qml4Net-v0.1.0

Example release flow:

git tag Qml4Net-v0.1.0
git push origin Qml4Net-v0.1.0

Requirements

  • Target: .NET 10.0 (LTS)

Documentation

  • qml4dart -- Original Dart implementation

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 113 4/5/2026
0.1.2 105 4/5/2026
0.1.1 103 4/5/2026
0.1.0 109 4/5/2026