Giter Site home page Giter Site logo

pierre3 / plantumlclassdiagramgenerator Goto Github PK

View Code? Open in Web Editor NEW
629.0 20.0 129.0 4.03 MB

This is a generator to create a class-diagram of PlantUML from the C# source code.

License: MIT License

C# 96.18% TypeScript 3.55% Smalltalk 0.27%
plantuml c-sharp class-diagram

plantumlclassdiagramgenerator's People

Contributors

0x326 avatar albertogregoriophios avatar chraxo avatar crazytoken avatar crown0815 avatar dependabot[bot] avatar drpepperbianco avatar filippobottega avatar gjuttla avatar incerrygit avatar khalidabuhakmeh avatar msallin avatar pendingchanges avatar pierre3 avatar shawnallen85 avatar shiena avatar thild avatar tyagi avatar vivraan avatar zacch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plantumlclassdiagramgenerator's Issues

Use lines instead of List`1

I created a diagram which looked like this:
image
Everything which is connected goes via List'1. Could there be an option to just use lines like:

ClassA --> "0..*" ClassB

Where "0..*" shows it's a list.

plantuml error due to a string variable containing curly brackets

Perhaps plantuml is causing a parsing error if the {{ }} for the sub-diagram is only on one side.

see also

double opening curly brackets only

input source

class OpeningBracket {
    string str = @"
{{
";
}

puml converted by puml-gen

@startuml
class OpeningBracket {
    str : string = @"
{{
"
}
@enduml

error in plantuml

$ plantuml OpeningBracket.puml
Error line 2 in file: OpeningBracket.puml
Some diagram description contains errors

single closing curly bracket only

input source

class ClosingBracket {
    string str = @"
}
";
}

puml converted by puml-gen

@startuml
class ClosingBracket {
    str : string = @"
}
"
}
@enduml

error in plantuml

$ plantuml ClosingBracket.puml
Error line 5 in file: ClosingBracket.puml
Some diagram description contains errors

Addition of table of contents to the README?

Hello,

Thank you for this tool! I used it to create diagrams for my talk at the ACCU conference last week.

I find myself referring back to the examples here, often.

For this, it would really help if the front page had a table of contents.

I could set this up very quickly using mdsnippets - and if you don't mind a GitHub Action being added, I'd make it so that the ToC would be updated automatically on push, if the headings changed.

https://github.com/SimonCropp/MarkdownSnippets/blob/master/docs/github-action.md

Here's me demoing this at CppCon last year

Would you accept a PR for this? Thanks.

[Feature request] Private variables in VS Code extension

HI,

Currently, the private variables are not created with a - in front of the variable, meaning the proper icons are not showed in the class diagram output eventually. It would be nice to have this as I now do it manually.

Also, Currently when class A owns a variable of class B. The name of the variable is shown at the end of the arrow pointing from A to B. It would be nice to just have it inside the field of A as a variable of type B. so "aclass : B"

excludePaths should allow excluding paths on all folder levels

Current situation

Currently the excludePaths argument filters only the exact specified path and does not allow filtering for all folders on all subfolder levels.

Example:

C:\dev\my-app> puml-gen -excludePaths obj 

This call excludes C:\dev\my-app\obj, but it does not exclude for example C:\dev\my-app\projectAbc\obj.

When using PlantUmlClassDiagramGenerator with a solution that contains multiple projects, this leads to a quite long list of excludePaths. Also, when new projects are added, or an existing project is renamed, then each time the excludePaths have to be adapted.

Proposal

It should be possible to generically filter all folders with a specific name, independent of the subfolder level where it is located.

Therefore wildcard characters should be allowed, such as known from .gitignore. For example to skip all obj folders on all levels the following parameter could be used:

puml-gen -excludePaths **/obj

Benefits:

  • Increases the flexibility.
  • The pattern is widely known.
  • No breaking api change.
  • The change is relatively easy to implement.

I would be happy to provide the implementation, if you agree with such a change.

Simple solution to this error?

I honestly do not know what to do about this error. Any one that knows?

A fatal error occurred. The required library libhostfxr.so could not be found.
If this is a self-contained application, that library should exist in [/home/oscar/.dotnet/tools/.store/plantumlclassdiagramgenerator/1.2.4/plantumlclassdiagramgenerator/1.2.4/tools/net5.0/any/].
If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].

Generated malformed include file

I have this project for which I used the command ". -dir . -excludePaths Cryssage\obj -createAssociation -AllInOne"

And it generated good puml files for everything except the include.puml which looked like this:

image

After every '.' character from a file name it appends the character '\' .

Model Class attributes as class associations

I noticed that attributes are not modelled as class associations, which makes it very hard to see the coherence of generated classes

I'd propose an option to model attributes that have a non-simple class type to model as association,

so

class Foo 
{
  private readonly List<Bar> bars = new List<Bar>();
}

would become

Foo "- bars" --> "*" Bar

Cannot find Graphviz

Hello guys, first, thanks for this project, it's awesome!

I want to generate a plantuml file with all my classes in dotnet core api.

I am getting this error attached. Am I doing something wrong?

image

tks

Doesn't generate a relation of type 'Composition'

I have tried to generate the code for a Composition but it always display a Association diagram.

For this:

    namespace Composition
    {
        public class SecondClientInstaller
        {
            DBLogger logger = new DBLogger();
        }
    
        public class DBLogger
        {
        }
    
    }

we get
@startuml
class SecondClientInstaller {
}
class DBLogger {
}
SecondClientInstaller --> "logger" DBLogger
@enduml

The console app has net48 but with net5 was the same.

Make generic types more readable: MyType`2 => MyType<T1,T2>

Since generic types are suffixed with backtick followed by the number of arguments it makes for difficult reading. This system exists solely to support the compiler, not humans.

Therefore I wish at least an option (if not default behaviour) that generic types are reprinted in a form that we expect from looking at the code.

Instead of:
MyType`2

The output should be:
MyType<T1,T2>

Of course if the actual type names used in the code would be preserved that would be even better, like so:
MyType<TKey,TValue>

All of a sudden you realize that this is probably some kind of dictionary, which you couldn't infer from the two versions above.

Exception when generating html export

Thanks very much for your project!

When exporting my classdiagram with png, it works fine.
But when exporting html I get the following exception (similar for pdf as well):

Error found in diagram include
java.lang.UnsupportedOperationException: HTML
	at net.sourceforge.plantuml.ugraphic.ImageBuilder.createUGraphic(ImageBuilder.java:444)
	at net.sourceforge.plantuml.ugraphic.ImageBuilder.writeImageInternal(ImageBuilder.java:267)
	at net.sourceforge.plantuml.ugraphic.ImageBuilder.writeImageTOBEMOVED(ImageBuilder.java:208)
	at net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek.createFileInternal(CucaDiagramFileMakerSvek.java:142)
	at net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek.createFile(CucaDiagramFileMakerSvek.java:77)
	at net.sourceforge.plantuml.cucadiagram.CucaDiagram.exportDiagramInternal(CucaDiagram.java:651)
	at net.sourceforge.plantuml.classdiagram.ClassDiagram.exportDiagramInternal(ClassDiagram.java:196)
	at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:200)
	at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:140)
	at net.sourceforge.plantuml.SourceStringReader.outputImage(SourceStringReader.java:158)
	at net.sourceforge.plantuml.Pipe.managePipe(Pipe.java:113)
	at net.sourceforge.plantuml.Run.managePipe(Run.java:359)
	at net.sourceforge.plantuml.Run.main(Run.java:166)
Exception in thread "main" java.lang.UnsupportedOperationException: HTML
	at net.sourceforge.plantuml.ugraphic.ImageBuilder.createUGraphic(ImageBuilder.java:444)
	at net.sourceforge.plantuml.ugraphic.ImageBuilder.writeImageInternal(ImageBuilder.java:267)
	at net.sourceforge.plantuml.ugraphic.ImageBuilder.writeImageTOBEMOVED(ImageBuilder.java:208)
	at net.sourceforge.plantuml.UmlDiagram.exportDiagramError(UmlDiagram.java:260)
	at net.sourceforge.plantuml.UmlDiagram.exportDiagramError(UmlDiagram.java:218)
	at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:208)
	at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:140)
	at net.sourceforge.plantuml.SourceStringReader.outputImage(SourceStringReader.java:158)
	at net.sourceforge.plantuml.Pipe.managePipe(Pipe.java:113)
	at net.sourceforge.plantuml.Run.managePipe(Run.java:359)
	at net.sourceforge.plantuml.Run.main(Run.java:166)

Any idea what I am missing?

Can't specify directory path as InputPath

Environment

  • PlantUmlClassDiagramGenerator version: 1.1.0
> dotnet --info
.NET Core SDK (global.json を反映):
 Version:   3.0.100-rc1-014190
 Commit:    c4d43f672d

ランタイム環境:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-rc1-014190\

Host (useful for support):
  Version: 3.0.0-rc1-19456-20
  Commit:  8f5d7b1ba4

Summary

> puml-gen.exe C:\path\to\a\Project\Program.cs

This will generate C:\path\to\a\Project\Program.puml as expected, but following will not.

> puml-gen.exe C:\path\to\a\Project
"C:\path\to\a\Project" does not exist.

Feature Request: Create associations with Nullable types

Current state

public record Foo
{
    public IEnumerable<Bar>? Bars { get; set; }
}

public record Bar
{
    // ...
}

generates:

class Foo <<record>> {
    + Bars: IEnumerable<MdmPhoneModel>?
}
class Bar <<record>> {
    ...
}

Desired state

An association from Foo to Bar is created.

Do we have build which will be suitable for 6.0.3?

It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '5.0.0' (x64) was not found.

  • The following frameworks were found:
    6.0.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:

Just installed vscode plugin...how do I use it?

Just installed vscode plugin...how do I use it?

Can you please include a link to documentation that details how to use the plugin extension in vscode. I have set the input path in the extension plugins. How do I generate the diagram????

Generate one puml file for a set of interfaces and classes related to each other by inheritance

I think for bigger projects it would not be feasible to generate allInOne. On the other side to have one puml for each type, which then only includes its base types does not help either. One would have to manually copy those together. for which one would like to see a complete inheritance diagram.
Therefore I think it would make sense to have a type filter like the fully qualified name of a class or an interface as parameter, with the goal to obtain a diagram with all the classes and interfaces related by inheritance. Later this could be refined to generate for example only recursively inherited classes or base classes.
In order to achieve this, one needs two passes. First generate all the syntax tree objects with their relations. Then starting from the seed class or interface recursively run through the relations to obtain the set to be rendered in puml.
In order for this to work one would need a type dictionary for classes, interfaces, structs, ... where the key is the fully qualified type name.
And also two relations dictionaries, one base->inherited, one inherited->base, where the key is the fully qualified type name, and the value is a list of fully qualified type names. Or one could put both relation-directions in one dictionary.
Anyway, using these dictionaries, one can reduce the types to be rendered, and then in a second pass render only those which remain after the filtering.

[Feature Request] Support for record types

Hi,
I recently tried to incorporate this dotnet tool in my project where I use and target dotnet 5. It seems like the tool doesn't handle records correctly. Whenever I use a record in my source, the output results in an invalid plantuml file.

Consider the following. I've got the following record

    public record ExampleRecord {
      public int AnInt { get; }
      public string AStringValue { get; }
    }

When I pass this through the generator, I get the following PlantUml spec:

+ AnInt : int <<get>>
+ AStringValue : string <<get>>

I would expect record to be handled the same way as classes, at least in the beginning. And by the way the following record notation doesn't output anything at all, which is expected as it's a new notation type that is record specific.

public record ExampleRecord (int AnInt, string AStringValue);

Only nullable properties are outputted

Having the following C# code:

public class Test
{
    public LinkedClass AdditionalData { get; set; }
    public LinkedClass? AdditionalData2 { get; set; }
}

public class LinkedClass
{
    public string Name { get; set; }
}

and running the following command: dotnet puml-gen ./ ./UML -dir -public -createAssociation

I get the following output:

@startuml
class Test {
    + AdditionalData2 : LinkedClass? <<get>> <<set>>
}
class LinkedClass {
    + Name : string <<get>> <<set>>
}
Test --> "AdditionalData" LinkedClass
@enduml

Only the nullable property is outputted.
Using version 1.3.4

VSCode extension not working on Ubuntu 22.04.1 LTS

Problem: when I run the extension via Command Pallete (Ctrl+Shift+P) I don't get the .puml files under the plantuml folder. Actually, I get no output at all even a single error message. I tried it in my laptop with WIndows 11 and it worked fine.

Visual Studio Code version

Version: 1.73.1
Commit: 6261075646f055b99068d3688932416f2346dd3b
Date: 2022-11-09T03:54:53.913Z
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Linux x64 5.15.0-53-generic
Sandboxed: No

Ubuntu Version

OS Name: Ubuntu 22.04.1 LTS
OS Type: 64-bit
GNOME Version: 42.5
WIndowing System: Wayland

dotnet version

dotnet --version
7.0.100

Inheritance

Great work, I was about to start a project like that!

It would be great if we can see the base classes, created with "<|--"

How to use it?

Is there anywhere a documentation how to use it?
I run the command csharp2plantuml.classDiagram in vs code but nothing happend.

What have i to do to get an class diagram from project?

L.G

How read List of Object

Hi, I made few adjustments to the application, including introducing the DateTime type, However, I have difficulties incorporating the List of Object. Maybe you have ideas regarding this issue?

All-in-one diagram

At the moment, when generating a diagram including several classes, each .cs file will be mapped to a .puml file and then an "include.puml" file will be created adding them all. This is all good and fine as long as you are not working with ServerRendering, in which case there is no way to see a diagram integrating all diagrams at once. Is there any plans to add an option in order to create a new "all-included" file?

Support struct type

Currently both class and struct use the type "class" in plantuml even though it supports the use of "struct".

Generating an invalid puml due to the @ prefix

steps to reproduce:

  1. Prepare the source file including the @ prefix

    @startuml
    class @ClassA{
    	    public @IList<@string> @Strings{get;} = new @List<@string>();
    		    public @Type1 @Prop1{get;set;}
    			    public @Type2 @field1;
    }
    
    class @Type1 {
    	    public @int @value1{get;set;}
    }
    
    class @Type2{
    	    public @string @string1{get;set;}
    		    public @ExternalType @Prop2 {get;set;}
    }
    @enduml
  2. Generating .puml with puml-gen

    $ puml-gen .\input.cs -createAssociation
    
    @startuml
    class @ClassA {
    }
    class @Type1 {
    }
    class @Type2 {
    }
    class "@IList`1"<T> {
    }
    @ClassA o-> "@Strings<@string>" "@IList`1"
    @ClassA --> "@Prop1" @Type1
    @ClassA --> "@field1" @Type2
    @Type1 --> "@value1" @int
    @Type2 --> "@string1" @string
    @Type2 --> "@Prop2" @ExternalType
    @enduml
  3. Generating .png with plantuml

    plantuml input.puml
    
  4. The generated .puml contains an error

    Error line 10 in file: input.puml
    Some diagram description contains errors
    

In VSCode, output path is relative to input path, not workspace folder

Thank you for the extension to Visual Studio Code.

The description of the csharp2plantuml.outputPath configuration option states that its value is relative to the workspace folder. However, the actual behavior (from this line) is that the output folder option is relative to the input folder. Please consider resolving the conflict in favor of the documentation, such that the value is relative to the workspace folder.

An option to include class namespaces

Love the tool! I have a feature request that would make my workflow much easier.

I would like to see a flag added that would include the namespace for any class and reference to the output.

For example, instead of:

@startuml
interface IContactNotificationDbDataProvider {
    UpdateNotificationSetReadToTrue(guids:IEnumerable<Guid>) : Task
}
@enduml
@startuml
class ContactNotificationService {
    + <<async>> MarkNotificationsAsRead(guids:IEnumerable<Guid>) : Task
}
class "ILogger`1"<T> {
}
IContactNotificationService <|-- ContactNotificationService
ContactNotificationService --> "_dataProvider" IContactNotificationDbDataProvider
ContactNotificationService --> "_logger<ContactNotificationService>" "ILogger`1"
@enduml

I would prefer:

namespace Notifications {
    namespace Logic {
        namespace Services {
            class ContactNotificationService {
                + <<async>> MarkNotificationsAsRead(guids:IEnumerable<Guid>) : Task
            }
        }
    }
    namespace Model {
        namespace IService {
            interface IContactNotificationService {
                MarkNotificationsAsRead(guids:IEnumerable<Guid>) : Task
            }
        }
    }
}
namespace Microsoft.Extensions.Logging {
    interface ILogger<T> {
    }
}

Notification.Model.IService.IContactNotificationService <|-- Notification.Logic.Services.ContactNotificationService
Notification.Logic.Services.ContactNotificationService --> "_logger<ContactNotificationService>" Microsoft.Extensions.Logging.ILogger

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.