Code Monkey home page Code Monkey logo

dotnetgraph's People

Contributors

andreabodo avatar droppers avatar dzaba1 avatar expl0it3r avatar lukascorona avatar vfrz 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotnetgraph's Issues

missing System.Drawing.Color assembly

Hey,
I am using the latest from DotNetGraph from Nuget and compiling into a dotnet v 4.6.2 project.
Getting this error:

[Error  : Unity Log] TypeLoadException: Parent class failed to load, due to: Could not load type of field 'DotNetGraph.Attributes.DotColorAttribute:<Color>k__BackingField' (0) due to: Could not resolve type with token 0100002e (from typeref, class/assembly System.Drawing.Color, netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51) assembly:netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Drawing.Color member:(null) signature:<none>
...
Stack trace:
DotNetGraph.Compiler.DotCompilerWorker.CompileNode (DotNetGraph.Node.DotNode node, System.Int32 indentationLevel) (at <aa62545a0724477d9ad05e69e648d004>:0)
DotNetGraph.Compiler.DotCompilerWorker.CompileGraph () (at <aa62545a0724477d9ad05e69e648d004>:0)
DotNetGraph.Compiler.DotCompilerWorker.Compile () (at <aa62545a0724477d9ad05e69e648d004>:0)
DotNetGraph.Compiler.DotCompiler.Compile (System.IO.TextWriter writer, System.Boolean indented, System.Boolean formatStrings) (at <aa62545a0724477d9ad05e69e648d004>:0)
DotNetGraph.Compiler.DotCompiler.Compile (System.Boolean indented, System.Boolean formatStrings) (at <aa62545a0724477d9ad05e69e648d004>:0)
DotNetGraph.Extensions.DotGraphExtensions.Compile (DotNetGraph.DotGraph graph, System.Boolean indented, System.Boolean formatStrings) (at <aa62545a0724477d9ad05e69e648d004>:0)

Any clue what I can do about this?

Restore minification as an option

One of the previous versions had the option to choose during compilation, whether to minify the diagram or not. It would be great if you allowed generating a non-minified diagram.

Label question

Hello,
Thanks for the great work! very useful !
do you know how i can align to the left, the label in a node
for example i have a multiline text in a label, and when it's displayed, everything is "centered" .. ! and i would like to align all text to the left !
thanks !

Question: Default Styles (or theme)?

Great library -- thanks for sharing it!

Have you given any thought to allowing for default styles or themes so that users don't have to redefine the same styles for each node and edge?

I'm asking because I'm considering integrating your library in with my state management library. Ideally, my users would be able to define a set of styles for states (nodes), transitions (edges), and conditional transitions (specialized nodes and edges) before calling an export method and end up with something like this diagram.

Let me know your thoughts and I might be able to help implement this functionality.

Missing Attribute Pos

Currently the pos attribute is missing, which allows the position of a node to be specified.
I want to add this attribute, but it is specified with a point type, which is simply a string in a specified format:

"%f,%f('!')?" representing the point (x,y). The optional '!' indicates the node position should not change (input-only).

I'm not sure how and where to implement this point type and would therefore appreciate some advice.
In particular, I wonder if the point type should become its own class or is it sufficient if the DotPosAttribute contains the necessary conversion

Edges from port to port

is there a way to use the HTML-attribute "port", so that edges will point from one port to another (e.g., connecting two cells within a big HTML-table), as opposed to connecting the whole node to another one?
e.g.: node1:port1 -> node2:port5

Add support for layouts

GraphViz has support for the following layouts: dot, neato, fdp, sfdp, twopi, circo.

Could it be possible to allow the DotGraph object to be configured with an optional layout style?

Please provide a signed assembly

I am not comfortable shipping assemblies that are not signed, since solutions using such assemblies are more prone to attacks.

From OpenAI:
Signing assemblies is a way to ensure the authenticity and integrity of an assembly. It allows you to verify that an assembly has not been tampered with and that it comes from a trusted source. Signing assemblies can also enable some features, such as putting them in the Global Assembly Cache (GAC) or using them in a strongly named application domain.

There are different ways to sign an assembly with a strong name, such as using Visual Studio, the Assembly Linker tool, or assembly attributes. You need a cryptographic key pair to sign an assembly, which can be generated by tools like sn.exe or Visual Studio.

Some of the benefits of signing assemblies are:

You can prevent name spoofing attacks, where a malicious assembly tries to impersonate another assembly by using the same name and version.
You can ensure that your application only loads the correct version of an assembly, and avoid loading an incompatible or outdated version.
You can use code access security (CAS) policies to grant permissions to assemblies based on their strong names.
You can use the GAC to share assemblies across applications and reduce disk space usage.

Some of the drawbacks of signing assemblies are:

Signed assemblies can only reference other signed assemblies, which can limit your choice of third-party libraries or components.
Signed assemblies are tied to a specific version of an assembly, which can cause problems when you want to update or patch an assembly without recompiling the application.
Signing assemblies can introduce a slight performance overhead due to the verification of the signature.

doesn't support records?

As far as I can tell, this doesn't support records? Is that correct?

I could only manage half a workaround; by using a custom "record" shape, and a manually encoded node label (e.g., <f0> a|<f1> b|<f2> c)) I could handle the nodes, but I can't figure out any way to get it to write edges as "node":f0 -> "node":f1 or node:f0 -> node:f1.

As far as the api goes, edge .From and .To just need to accept optional ports, and nodes need to accept a list of port names and labels (that can be nested in complicated ways, to be fair; they can be grouped in order to switch between horizontal fields and vertical fields).

DotGraph.getNode(string identifier) or DotEdge.From(string identifier).To(string identifier)

As suggestion to easier build bigger graphs without needing to always keep the previously created objects in the code block or pass them along I could think of either:

  1. Adding a function to get a Node from an graph by passing the identifier of the node as string.
  2. Letting everony create DotEdges from identifiers, since the DotNode and DotEdge anyways need to be added independently and in the end the important information would be the identifiers of the nodes you want to create an edge for.

Possible missing features

First of all, thank you for this library, but it seems that some features are missing.

  • Applying default attributes to a node, edge, graph etc. is not possible, since the "Identifier" is automatically encapsulated by double quotes. As a solution, maybe only encapsulate the identifier when it is actually necessary? Although, this makes it impossible to identify a node as "node".
    digraph a {
        // default
       node[shape=box];
    }
    
  • The amount of attributes is very limited, for example setting fontname, xlabel etc. is not possible, see https://graphviz.org/doc/info/attrs.html. I think implementing all of those manually is too much work an unnecessary, so a solution might be an option to add custom attributes? e.g. IDotElement.AddAttribute(string(or DotAttribute enum), object)?
  • It is possible for a style attribute to have multiple values, separated by a comma, e.g. [shape=box style="filled, rounded"]. (marking enums as flags?)
  • Labels can contain HTML, for example to display a table, label=<<TABLE>...</TABLE>>, but since the label value is automatically encapsulated with double quotes this is not possible. Maybe adding a HtmlLabelAttribute?

Missing node identifier produces invalid dot file

The constructor of DotNode takes an optional string identifier parameter. If none is provided, the identifier is set to null. However, if you do not set an identifiert, the compiled dot file is invalid, as the nodes can not be identified.

I see multiple solutions and was wondering what you think would be the preferred one:

  • Make the identifier required
  • If the identifier is not set a unique identifier, e.g. a GUID or using a counter

Since the identifier is not visible in the rendered graph from a dot file and since picking a unique name for each node can be a bit annoying, I'd suggest to leave it optional and just generate GUID if not set.

While we're on the topic of uniqueness, currently there are no checks to ensure that the graph has unique identifiers. So if you add two nodes with the same identifier, only one will be rendered. Any ideas on how to solve this?

Character escaping issue

It would be wonderful if the solution automatically escaped strings used as labels and the title. I mean quote characters, line breaks, and others that I forgot to mention.

What I noticed so far is:

  • diagram title is not quoted automatically when it contains spaces, and this breaks the structure of the compiled diagram,
  • special characters in labels, and probably in the title as well, are not escaped (I did not check quoting when required).

I didn't familiarize with the DOT syntax enough, but from my experience with the library:

  • line breaks have to be manually replaced with \n (some suggest using <br />, but it didn't work for me),
  • quote characters have to be escaped with a backslash " -> \",
  • same case with backslashes: \ -> \\
  • I also escaped labels and title with HttpUtility.HtmlEncode(label) to handle special HTML characters like <, >, national characters (they also caused issues), etc.

Only then did the online visualizer http://www.webgraphviz.com/ stop reporting errors and warnings.

By the way, I love your library, it is so helpful! Cheers!

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.