Coder Social home page Coder Social logo

dll2mmd's Introduction

dll2mmd

What is dll2mmd

Dll2mmd is a dotnet tool for generating mermaid.js class-diagram from assemblies.

Installing dll2mmd

  1. Install .Net SDK 6.0 or later.

  2. Install dll2mmd as a global dotnet tool.

    $ dotnet tool install --global dll2mmd
    You can invoke the tool using the following command: dll2mmd
    Tool 'dll2mmd' (version '1.0.5') was successfully installed.

Usage

Description:
  Generate mermaid.js class-diagram from .net dll files.

Usage:
  dll2mmd [options]

Options:
  -o, --output <output>           Output file. [default: output.md]
  -ns, --namespace <namespace>    Namespace from which to fetch classes. []
  -f, --files <files> (REQUIRED)  Dll files from which to fetch classes.
  -t, --type-names <type-names>   Name of specific classes to form the diagram. []
  --ignore-dependency             If true, only dependency of inheritance and implementation would be generated.
  --version                       Show version information
  -?, -h, --help                  Show help and usage information

Example

  1. Generate Zoo.dll by compiling following file.

    namespace Zoo;
    public interface IAnimal
    {
        string Name { get; set; }
        IFood FavorateFood { get; set; }
        void Speak();
    }
    
    public abstract class Mammal : IAnimal
    {
        public string Name { get; set; }
        public IFood FavorateFood { get; set; }
    
        public abstract void Speak();
    
        protected Mammal(string name, IFood favorateFood)
        {
            Name = name;
            FavorateFood = favorateFood;
        }
    }
    
    public class Cat : Mammal
    {
        public Cat(string name, IFood favorateFood) : base(name, favorateFood) {}
        public override void Speak()
        {
            Console.WriteLine("meow");
        }
    }
    
    public class Dog : Mammal
    {
        public Dog(string name, IFood favorateFood) : base(name, favorateFood) { }
        public override void Speak()
        {
            Console.WriteLine("woof");
        }
    }
    
    public interface IFood
    {
        string Taste { get; set; }
    }
    
    public class Fish : IFood, IAnimal
    {
        public string Taste { get; set; }
        public string Name { get; set; }
        public IFood FavorateFood { get; set; }
    
        public Fish(string taste, string name, IFood favorateFood)
        {
            Taste = taste;
            Name = name;
            FavorateFood = favorateFood;
        }
        public void Speak()
        {
            Console.WriteLine("...");
        }
    }
    
    public class Bone : IFood
    {
        public string Taste { get; set; }
        public Bone(string taste)
        {
            Taste = taste;
        }
    }
  2. Run dll2mmd to generate output.md from Zoo.dll.

    $ dll2mmd -f Zoo.dll
  3. output.md

    classDiagram
    
    class IAnimal
    IAnimal : +String Name
    IAnimal : +IFood FavorateFood
    IAnimal : +Speak() Void
    
    class Mammal
    Mammal : +String Name
    Mammal : +IFood FavorateFood
    Mammal : +Speak() Void
    
    class Cat
    Cat : +String Name
    Cat : +IFood FavorateFood
    Cat : +Speak() Void
    
    class Dog
    Dog : +String Name
    Dog : +IFood FavorateFood
    Dog : +Speak() Void
    
    class IFood
    IFood : +String Taste
    
    class Fish
    Fish : +String Taste
    Fish : +String Name
    Fish : +IFood FavorateFood
    Fish : +Speak() Void
    
    class Bone
    Bone : +String Taste
    
    
    IAnimal <|.. Mammal
    Mammal <|-- Cat
    Mammal <|-- Dog
    IFood <|.. Fish
    IAnimal <|.. Fish
    IFood <|.. Bone
    
    
    Loading

dll2mmd's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dll2mmd's Issues

Add an option to hide inherited properties

When I create a diagram that includes a parent class with many properties and methods and multiple classes that inherit from it, I would like to have an option to hide all inherited members on the child classes in the diagram (unless they are explicitly overridden). This would make it easier to see which child classes implement/override specific inherited members.

I would also like it if abstract classes and abstract members were annotated in the diagram output as documented on Mermaid.js

(If this option already exists, it should be documented in the --help response and readme)

Example Input:

public abstract class AbstractParent
{
    public virtual string String { get; set; }

    public abstract int Int { get; set; }
    public virtual DateTime DateTime { get; set; }
    public abstract void Method();
}

public class ConcreteChild : AbstractParent
{
    public override int Int { get; set; }
    public override void Method() { }
}

public class ConcreteGrandChild : ConcreteChild
{
    public override string String { get; set; }
}

Current Output:

classDiagram

class AbstractParent
AbstractParent : +String String
AbstractParent : +Int Int
AbstractParent : +DateTime DateTime
AbstractParent : +Method() Void

class ConcreteChild
ConcreteChild : +Int Int
ConcreteChild : +String String
ConcreteChild : +DateTime DateTime
ConcreteChild : +Method() Void

class ConcreteGrandChild
ConcreteGrandChild : +String String
ConcreteGrandChild : +Int Int
ConcreteGrandChild : +DateTime DateTime
ConcreteGrandChild : +Method() Void


AbstractParent <|-- ConcreteChild
ConcreteChild <|-- ConcreteGrandChild

Loading

Desired output with "Hide Inherited" option enabled and <<abstract>> mermaid notation:

classDiagram

class AbstractParent
<<abract>> AbstractParent
AbstractParent : +String String
AbstractParent : +Int Int*
AbstractParent : +DateTime DateTime
AbstractParent : +Method() Void*

class ConcreteChild
ConcreteChild : +Int Int
ConcreteChild : +Method() Void

class ConcreteGrandChild
ConcreteGrandChild : +String String


AbstractParent <|-- ConcreteChild
ConcreteChild <|-- ConcreteGrandChild

Loading

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.