pierre3 / plantumlclassdiagramgenerator Goto Github PK
View Code? Open in Web Editor NEWThis is a generator to create a class-diagram of PlantUML from the C# source code.
License: MIT License
This is a generator to create a class-diagram of PlantUML from the C# source code.
License: MIT License
How to remove "PlantUmlClassDiagramGenerator" ?
Use
I installed "PlantUmlClassDiagramGenerator" last year.
How to find out which version of "PlantUmlClassDiagramGenerator" do I have it installed?
Use
Perhaps plantuml is causing a parsing error if the {{ }}
for the sub-diagram is only on one side.
see also
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
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
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.
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"
subj
Include escape characters in attribute parameter values...
class ClassA
{
public ClassA([PlantUmlAssociation(Name="\"IList<string>\"", Association = "..>")] IList<string> list)
{
}
}
Expected Result
ClassA ..> "IList<string>"
Actual Result
ClassA ..> \"IList<string>\
Can this be solved?
.vscode/extensions/pierre3.csharp-to-plantuml-1.0.0/lib/PlantumlClassDiagramGenerator/PlantUmlClassDiagramGenerator.dll
not found on Linux.
There is a casing typo in PlantumlClassDiagramGenerator.
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.
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:
I would be happy to provide the implementation, if you agree with such a change.
System types are included in the diagrams. I think it would be nice if we could exclude certain namespaces.
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].
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:
After every '.' character from a file name it appends the character '\' .
class Foo
{
[PlantUmlAssociation(Name = "Bar")]
public IEnumerable<Bar>? Bars { get; set; }
class Foo
{
[PlantUmlAssociation(Name = nameof(MdmPhoneModel))]
public IEnumerable<Bar>? Bars { get; set; }
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
Scenario: You have lots of Razor file. They generate partial classes in /obj. The extension creates puml files for them. "/obj" is in their path. They get blocked or flagged by admins.
Out of date with later .NET Core versions
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.
I installed "PlantUmlClassDiagramGenerator" last year.
How to update "PlantUmlClassDiagramGenerator" ?
Use
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.
class GenericsType {
}
class GenericsType<T1> {
}
class GenericsType<T1,T2> {
}
In the plantuml, all of the above classes are interpreted as the same class.
class GenericsType {
}
class GenericsType`1<T1> {
}
class GenericsType`2<T1,T2> {
}
I consider converting to such UML.
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?
> 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
> 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.
public record Foo
{
public IEnumerable<Bar>? Bars { get; set; }
}
public record Bar
{
// ...
}
generates:
class Foo <<record>> {
+ Bars: IEnumerable<MdmPhoneModel>?
}
class Bar <<record>> {
...
}
An association from Foo
to Bar
is created.
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '5.0.0' (x64) was not found.
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?
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????
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.
This would be nice to have, since the <><> is overly verbose for large domain model where all of the have these on all of their attributes.
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);
Names like List`1
causes messy visualisations like following:
Is it possible to generatenames like List`[FieldName]
(eg List`AuditRecords
)? Or maybe there is another way to generate better diagrams?
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
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
Great work, I was about to start a project like that!
It would be great if we can see the base classes, created with "<|--"
Do not work this setting if I set ExcludePath setting.
It seems that "-excludePaths" is missing when expanding the options.
This setting does not seem to be functioning since you added 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
Some generated code such as the one generated in WCF is included in 1 file, so it will be nice to find a way to filter base on name or perhaps even by attribute
The references in the include.puml are wrong when using "." to point to the current directory.
E.g. it produces
!include .\\Sample\Program.\puml
but it should be
!include .\\SwemSample\Program\puml
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?
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?
When generating from a multi-project solution, Would expect the diagrams to produce inside 'Package' boundaries however this is not the case.
Currently both class and struct use the type "class" in plantuml even though it supports the use of "struct".
Hello! Thanks for your work on this tool, its been really helpful for me.
I created a dockerfile which installs java, .NET SDK, graphviz, plantUML and your tool, to make it easier to run a one-off on C# code without needing to setup any dependencies.
https://hub.docker.com/repository/docker/minism/plantuml-csharp
Feel free to link to this somewhere on your README if you'd like.
steps to reproduce:
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
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
Generating .png with plantuml
plantuml input.puml
The generated .puml contains an error
Error line 10 in file: input.puml
Some diagram description contains errors
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.
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
Would it be possible to update this one to support dotnet 6?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.