Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ArchUnitNET/Domain/PlantUml/Export/GenerationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,14 @@ public class GenerationOptions
public bool IncludeNodesWithoutDependencies { get; set; } = true;
public bool LimitDependencies { get; set; } = false;
public bool C4Style { get; set; } = false;

/// <summary>
/// Whether slice diagrams draw the namespace tree as <c>package</c> blocks and put each
/// slice in the package of the deepest namespace that contains all of its types. A package
/// with no slice of its own and a single child package is merged with it. A slice whose
/// types share no namespace is drawn outside any package. Slices of the obsolete
/// <c>MatchingWithPackages</c> are always nested.
/// </summary>
public bool NestSlicesInPackages { get; set; } = false;
}
}
11 changes: 1 addition & 10 deletions ArchUnitNET/Domain/PlantUml/Export/PlantUmlDependency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,7 @@ public string GetPlantUmlString(RenderOptions renderOptions = null)
return OriginAlias + " -[#green]> " + TargetAlias + Environment.NewLine;

case DependencyType.OneToOneCompact:
if (OriginCountOfDots() == TargetCountOfDots())
{
return "["
+ OriginAlias
+ "] --> ["
+ TargetAlias
+ "]"
+ Environment.NewLine;
}
return "";
return "[" + OriginAlias + "] --> [" + TargetAlias + "]" + Environment.NewLine;

case DependencyType.Circle:
return "["
Expand Down
17 changes: 15 additions & 2 deletions ArchUnitNET/Domain/PlantUml/Export/PlantUmlDiagram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public string GetPlantUmlString(RenderOptions renderOptions)
/// place either, so the id is made from the name with those characters replaced by "_",
/// and suffixed until it clashes with no other name in the diagram. The name itself stays
/// the label, and slices whose names are valid ids keep them.
///
/// A valid name can still be taken by a package: a nested slice named after its own
/// namespace, such as "App.Orders", would share its id with the package "App.Orders" it
/// is drawn in. Such a slice gets a replacement id as well.
/// </remarks>
private static void AssignAliases(IReadOnlyCollection<IPlantUmlElement> elements)
{
Expand All @@ -72,13 +76,22 @@ private static void AssignAliases(IReadOnlyCollection<IPlantUmlElement> elements
// Only slices are declared with an id; a dependency between components that are not
// declared names them in brackets, where PlantUML accepts more.
var sliceNames = slices.Select(slice => slice.ToString()).Distinct().ToList();
var packageIds = new HashSet<string>(
slices.Where(slice => slice.IsNested).SelectMany(slice => slice.PackageIds)
);
var taken = new HashSet<string>(
sliceNames.Concat(dependencies.SelectMany(dep => new[] { dep.Origin, dep.Target }))
sliceNames
.Concat(dependencies.SelectMany(dep => new[] { dep.Origin, dep.Target }))
.Concat(packageIds)
);

// In the order the slices appear, so the same diagram always gets the same ids.
var aliases = new Dictionary<string, string>();
foreach (var name in sliceNames.Where(name => CharactersNotAllowedInId.IsMatch(name)))
foreach (
var name in sliceNames.Where(name =>
CharactersNotAllowedInId.IsMatch(name) || packageIds.Contains(name)
)
)
{
var alias = CharactersNotAllowedInId.Replace(name, "_");
var candidate = alias;
Expand Down
Loading
Loading