uml4net 5.1.0

dotnet add package uml4net --version 5.1.0
                    
NuGet\Install-Package uml4net -Version 5.1.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="uml4net" Version="5.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="uml4net" Version="5.1.0" />
                    
Directory.Packages.props
<PackageReference Include="uml4net" />
                    
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 uml4net --version 5.1.0
                    
#r "nuget: uml4net, 5.1.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 uml4net@5.1.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=uml4net&version=5.1.0
                    
Install as a Cake Addin
#tool nuget:?package=uml4net&version=5.1.0
                    
Install as a Cake Tool

uml4net

Introduction

Uml4net is a suite of dotnet core libraries and tools that are used to deserialize (read) and serialize (write) a UML version 2.5.1 model in XMI 2.5.1 form. Uml4net is typically used to support opinionated template based code-generation and is a part of modeltopia. Uml4net provides a number of libraries that are described in the following sections.

uml4net

The core library that contains all the class definitions as they appear in the UML 2.5.1 specification. Together with uml4net.xmi it provides the capability to read and write UML models and make them available as an in-memory object graph. The derived properties of the metamodel are implemented, and the owner ends of composite associations are kept in sync with the containment.

uml4net.Extensions

The uml4net.Extensions library provides extensions methods to the uml4net library to support code generation. This library is part of the uml4net ecosystem.

uml4net.xmi

The uml4net.xmi library provides an XMI reader implementation to read UML XMI model files and an XMI writer implementation to write UML models to XMI:

  • Reading: references to other documents are resolved, also across documents found on disk or through path maps; stereotype applications are resolved against their profile and their tagged values are typed; content uml4net does not model, such as UML Diagram Interchange, is captured. In strict mode (the default) a document that is not valid XMI 2.5.1 is rejected with an exception that names the element, property and line position; otherwise the problem is logged and reading continues.
  • Writing: a model is written as it was read, including its documentation, MOF tags, stereotype applications and captured content, so that a document survives a read-write cycle. A selected Package can be written as well, where references to elements outside the selected package are either written as href references to the original document or the containing root packages are included in the written document, resulting in a self-contained XMI file. The writer can also write Canonical XMI (XMI 2.5.1 Annex B).

To learn more about how to read and write a UML model, read about it here

uml4net.xmi.Extensions.EnterpriseArchitect

The uml4net.xmi.Extensions.EnterpriseArchitect library is a specific XMI Reader extension to support Enterprise Architect XMI reading.

uml4net.HandleBars

The uml4net.HandleBars library provides HandleBars helpers to support code generation. This library is part of the uml4net ecosystem.

uml4net.Reporting

The uml4net.Reporting library contains reporting generators. This library is part of the uml4net ecosystem.

uml4net.Tools

The uml4net.Tools commandline application is used to generate reports on the content of the UML model. Find the documentation here.

Code Quality

Quality Gate Status Code Smells Coverage Duplicated Lines (%) Lines of Code Maintainability Rating Reliability Rating Security Rating Technical Debt Vulnerabilities

Installation

The packages are available on Nuget at:

Reading a UML model

Reading a UML model is straightforward and is done using an IXmiReader. An instance of IXmiReader is created using the XmiReaderBuilder. Once the reader is available, point it to a UML model you want to read and you're off to the races:

var reader = XmiReaderBuilder.Create()
    .Build();

var xmiReaderResult = reader.Read("path-to-your-model");

var rootPackage = xmiReaderResult.QueryRoot("<xmi:id-of-the-root-package-you-are-interested-in>");

The IXmiReader can be configured with an IXmiReaderSettings, read more about reading an XMI document here

The IXmiReader is able to read and process StereoTypes as they are applied to UML model elements. Read more about that here

Writing a UML model

A UML model is written using an IXmiWriter, which is created using the XmiWriterBuilder. Writing the top-level elements of the document that was read, together with its XmiRoot, writes the whole document back:

var writer = XmiWriterBuilder.Create()
    .Build();

writer.Write(xmiReaderResult.DocumentRootElements, "path-to-the-written-model", xmiReaderResult.XmiRoot);

The IXmiWriter can be configured with an IXmiWriterSettings, for example to write Canonical XMI; read more about writing an XMI document here

Design Decisions

Some choices in uml4net are deliberate and can look surprising at first, such as single-valued composite properties exposed as IContainerList<T>, UnlimitedNatural values as string, or the order in which the writer writes the properties. They are recorded, with their reasons, in design-decisions.md.

Build Status

GitHub actions are used to build and test the uml4net libraries

Branch Build Status
Master Build Status
Development Build Status

UML Documentation

The Object Management Group (OMG) is an international technology standards consortium. It was founded in 1989 with the goal of creating and maintaining vendor-neutral, interoperable, and portable standards for distributed computing. UML is one of the standards provided by OMG at http://www.omg.org/spec/UML/

Software Bill of Materials (SBOM)

As part of our commitment to security and transparency, this project includes a Software Bill of Materials (SBOM) in the associated NuGet packages. The SBOM provides a detailed inventory of the components and dependencies included in the package, allowing you to track and verify the software components, their licenses, and versions.

Why SBOM?

  • Improved Transparency: Gain insight into the open-source and third-party components included in this package.
  • Security Assurance: By providing an SBOM, we enable users to more easily track vulnerabilities associated with the included components.
  • Compliance: SBOMs help ensure compliance with licensing requirements and make it easier to audit the project's dependencies.

You can find the SBOM in the NuGet package itself, which is automatically generated and embedded during the build process.

License

The uml4net libraries are provided to the community under the Apache License 2.0.

Contributions

Contributions to the code-base are welcome. However, before we can accept your contributions we ask any contributor to sign the Contributor License Agreement (CLA) and send this digitally signed to s.gerene@stariongroup.eu. You can find the CLA's in the CLA folder.

Contribution guidelines for this project

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on uml4net:

Package Downloads
uml4net.Extensions

Extension methods for the .NET implementation of the OMG UML v2.5.1 specification.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.1.0 38 10/5/2026
5.0.0 71 10/4/2026
4.3.1 365 9/8/2026
4.3.0 2,232 8/5/2026
4.2.1 2,045 7/1/2026
4.2.0 342 6/29/2026
4.1.7 1,765 4/24/2026
4.1.6 330 4/22/2026
4.1.5 1,650 3/13/2026
4.1.4 420 3/6/2026
4.1.2 1,129 1/23/2026
4.1.1 690 1/4/2026
4.1.0 648 12/29/2025
4.0.3 427 12/20/2025
4.0.2 2,841 11/30/2025
4.0.1 536 11/23/2025
4.0.0 672 11/19/2025
3.0.3 7,952 8/26/2025
3.0.2 816 8/11/2025
3.0.1 482 8/8/2025
Loading failed

[Fix] Namespace::importedMember and getNamesOfMember stop at PackageImport cycles instead of overflowing the stack; fixes #490
         [Fix] ReplyAction::input contains the replyValue pins; fixes #491
         [Fix] ContainerList keeps an element owned while another list of its container holds it, moves it between containers and maintains containment through IList; fixes #492
         [Fix] Property::opposite is null instead of throwing for a property that is not a member end of its association, and uses the owning association; fixes #495
         [Fix] Classifier::directlyUsedInterfaces follows the specification text: Usages from the Classifier to Interfaces; fixes #497
         [Fix] IClassifier.General of Class and its subtypes returns every parent instead of forwarding to superClass; fixes #494