Closed wkthomasvdb closed 9 months ago
I think that an additional check needs to be added in the ClassDiagramGenerator: https://github.com/pierre3/PlantUmlClassDiagramGenerator/blob/5f38665aa54ef998ad4cc98559d6f4fbd7da96d4/src/PlantUmlClassDiagramGenerator.Library/ClassDiagramGenerator.cs#L278
I think I should also check for:
|| type is IdentifierNameSyntax
I'd like to help with this issue. I'm new at working on an open source project, but I have some experience in C#. Can I help and make changes to this project?
I've written the test around the issue, and it is failed. The bug is present. Please, check if the expected result (expected puml) is correct.
The test:
[TestMethod]
public void NullableTestNullableAndNotNullableCustomTypes()
{
var code = File.ReadAllText(Path.Combine("testData", "NullableAndNotNullableCustomType.cs"));
var tree = CSharpSyntaxTree.ParseText(code);
var root = tree.GetRoot();
var output = new StringBuilder();
using (var writer = new StringWriter(output))
{
var gen = new ClassDiagramGenerator(writer, " ", Accessibilities.Private | Accessibilities.Internal
| Accessibilities.Protected | Accessibilities.ProtectedInternal);
gen.Generate(root);
}
var expected = ConvertNewLineCode(File.ReadAllText(Path.Combine("uml", "nullableAndNotNullableCustomType.puml")), Environment.NewLine);
var actual = output.ToString();
Console.Write(actual);
Assert.AreEqual(expected, actual);
}
Input test class: (testData/NullableAndNotNullableCustomType.cs)
public class NullableAndNotNullableCustomType
{
public CustomType NotNullableCustomType { get; set; }
public CustomType? NullableCustomType { get; set; }
}
public class CustomType
{
public string Name { get; set; }
}
Expected puml: (uml/nullableAndNotNullableCustomType.puml)
@startuml
class NullableAndNotNullableCustomType {
+ NotNullableCustomType : CustomType <<get>> <<set>>
+ NullableCustomType : CustomType? <<get>> <<set>>
}
class CustomType {
+ Name : string <<get>> <<set>>
}
NullableAndNotNullableCustomType --> "NotNullableCustomType" CustomType
NullableAndNotNullableCustomType --> "NullableCustomType" CustomType
@enduml
Actual:
@startuml
class NullableAndNotNullableCustomType {
+ NullableCustomType : CustomType? <<get>> <<set>>
}
class CustomType {
+ Name : string <<get>> <<set>>
}
NullableAndNotNullableCustomType --> "NotNullableCustomType" CustomType
@enduml
Hello, fixed it on my fork. But i didn't outputed the properties as they are now in the associations. PR incoming.
This issue has been resolved in version 1.4.0.
https://www.nuget.org/packages/PlantUmlClassDiagramGenerator/1.4.0 https://marketplace.visualstudio.com/items?itemName=pierre3.csharp-to-plantuml
Having the following C# code:
and running the following command:
dotnet puml-gen ./ ./UML -dir -public -createAssociation
I get the following output:
Only the nullable property is outputted. Using version 1.3.4