d2lang-cs 1.0.0

dotnet add package d2lang-cs --version 1.0.0                
NuGet\Install-Package d2lang-cs -Version 1.0.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="d2lang-cs" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add d2lang-cs --version 1.0.0                
#r "nuget: d2lang-cs, 1.0.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.
// Install d2lang-cs as a Cake Addin
#addin nuget:?package=d2lang-cs&version=1.0.0

// Install d2lang-cs as a Cake Tool
#tool nuget:?package=d2lang-cs&version=1.0.0                

d2lang-cs

Banner

An unofficial interface for building D2 diagram files in C# and dotnet.

Installation

dotnet add package d2lang-cs

Usage

using d2;

var umbrella = new D2Shape("alphabet", "Alphabet Inc", Shape.Rectangle);
var company = new D2Shape("google", null, Shape.Rectangle);

company.Add(new D2Shape("gmail", "Gmail", Shape.Rectangle));
company.Add(new D2Shape("meet", "Meet", Shape.Rectangle));
company.Add(new D2Shape("deepmind", "DeepMind", Shape.Rectangle));

company.Icon = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png";

var connection = new D2Connection(company.Name, umbrella.Name, Direction.TO, "BELONGS_TO");

var diagram = new D2Diagram(new[] { umbrella, company }, new[] { connection });

Console.WriteLine(diagram.ToString());

D2 Output

alphabet: Alphabet Inc {
  shape: rectangle
}
google: {
  gmail: Gmail {
    shape: rectangle
  }
  meet: Meet {
    shape: rectangle
  }
  deepmind: DeepMind {
    shape: rectangle
  }
  icon: https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png
  shape: rectangle
}
google -> alphabet: BELONGS_TO

Diagram Output

Diagram

Documentation

Supported

  • Shapes (nodes)
  • Connections (edges)
  • Styles
  • Containers (nodes/links in nodes)
  • Arrow directions
  • Markdown / latex / block strings / code in shapes
  • Shape icons
  • SQL table shapes
  • Class shapes
  • Comments

Inspiration & Thanks

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.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
1.0.0 254 10/30/2023
0.0.1 109 10/30/2023