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
24 changes: 0 additions & 24 deletions ArchUnitNET/Domain/PlantUml/Export/PlantUmlFileBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public PlantUmlFileBuilder WithDependenciesFrom(
{
_sliceList = slices.Distinct().ToList();
AssertDistinctNames();
RemovePatternInappropriateSlices();
AssignCommonNamespaces();

if (generationOptions == null)
Expand Down Expand Up @@ -340,7 +339,6 @@ public PlantUmlFileBuilder WithDependenciesFromFocusOn(
package = package.Remove(package.Length - 1);
}

RemovePatternInappropriateSlices();
AssignCommonNamespaces();

var focusedSlices = new HashSet<string>(
Expand Down Expand Up @@ -448,28 +446,6 @@ GenerationOptions generationOptions
);
}

private void RemovePatternInappropriateSlices()
{
if (_sliceList.Any(slice => slice.CountOfAsteriskInPattern == null))
{
return;
}

for (var i = _sliceList.Count - 1; i >= 0; i--)
{
var dots = 0;

// The description is never qualified, so its dots are those below the namespace
// the pattern matched before its capture group.
dots += _sliceList[i].Description.Count(c => c == '.');

if (dots >= _sliceList[i].CountOfAsteriskInPattern)
{
_sliceList.RemoveAt(i);
}
}
}

private void RemoveDuplicatedArrowsIfExist()
{
for (var i = _dependencies.Count - 1; i >= 0; i--)
Expand Down
2 changes: 0 additions & 2 deletions ArchUnitNET/Domain/Slice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public Slice(SliceIdentifier identifier, IEnumerable<IType> types)

public string Description => Identifier.Description;

public int? CountOfAsteriskInPattern => Identifier.CountOfAsteriskInPattern;

/// <summary>
/// Whether diagrams nest this slice in packages even if
/// <see cref="PlantUml.Export.GenerationOptions.NestSlicesInPackages"/> is not set, which
Expand Down
35 changes: 19 additions & 16 deletions ArchUnitNET/Domain/SliceIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@ namespace ArchUnitNET.Domain
/// <summary>
/// Identifies a slice by its parts: for a slice pattern, the values its capture groups
/// captured, in group order. Two identifiers are the same slice exactly when their parts are
/// equal and both are ignored or both are not.
/// equal and both are ignored or both are not. See
/// <see cref="Fluent.Slices.SliceRuleInitializer"/>.
/// </summary>
public class SliceIdentifier : IHasDescription
{
/// <summary>
/// Groups identifiers by slice membership; see <see cref="CompareTo"/>.
/// </summary>
public static readonly SliceIdentifierComparer Comparer = new SliceIdentifierComparer();

/// <summary>
/// Whether the type that produced this identifier failed to match the pattern and is
/// therefore left out of the rule.
/// </summary>
public readonly bool Ignored;

private SliceIdentifier(
IReadOnlyList<string> parts,
bool ignored,
int? countOfAsteriskInPattern = null
)
private SliceIdentifier(IReadOnlyList<string> parts, bool ignored)
{
Parts = parts;
Ignored = ignored;
CountOfAsteriskInPattern = countOfAsteriskInPattern;
}

/// <summary>
/// What identifies the slice: for a slice pattern, the values its capture groups
/// captured, in group order. "App.(**)" over "App.Orders.Web" gives
/// <c>[Orders.Web]</c>.
/// captured, in group order. "App.(*).(*)" over "App.Orders.Http" gives
/// <c>[Orders, Http]</c>, and so does "App.(*)..(*)" over "App.Orders.Web.Http".
/// </summary>
public IReadOnlyList<string> Parts { get; }

Expand All @@ -39,8 +43,6 @@ private SliceIdentifier(
/// </summary>
public string Description => "Slice " + string.Join(" - ", Parts);

public readonly int? CountOfAsteriskInPattern;

/// <summary>
/// Creates an identifier for a slice with a single part, the same slice as
/// <c>Of(new[] { part })</c>.
Expand All @@ -49,12 +51,9 @@ private SliceIdentifier(
/// The slice's only part: a custom <c>SliceAssignment</c> that returns identifiers with the
/// same part for two types puts them into the same slice.
/// </param>
/// <param name="countOfAsteriskInPattern">
/// The number of "(*)" groups in the pattern, if the slice comes from one.
/// </param>
public static SliceIdentifier Of(string part, int? countOfAsteriskInPattern = null)
public static SliceIdentifier Of(string part)
{
return new SliceIdentifier(CheckParts(new[] { part }), false, countOfAsteriskInPattern);
return Of(new[] { part });
}

/// <summary>
Expand All @@ -68,6 +67,10 @@ public static SliceIdentifier Of(IEnumerable<string> parts)
return new SliceIdentifier(CheckParts(parts), false);
}

/// <summary>
/// Creates the identifier for a type that did not match the pattern. All such types
/// share one slice, which the rule then leaves out.
/// </summary>
public static SliceIdentifier Ignore()
{
return new SliceIdentifier(new[] { "Ignored" }, true);
Expand Down
Loading
Loading