Skip to content

Commit

Permalink
BenMorris/NetArchTest#130 - remove number of type parameters (e.g. `1…
Browse files Browse the repository at this point in the history
…) from the name of generic type
  • Loading branch information
NeVeSpl committed Nov 21, 2023
1 parent de5139a commit fa3b718
Show file tree
Hide file tree
Showing 27 changed files with 1,598 additions and 1,601 deletions.
246 changes: 3 additions & 243 deletions src/NetArchTest.Rules/Condition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,141 +36,9 @@ private void AddFunctionCall(Func<IEnumerable<TypeSpec>, IEnumerable<TypeSpec>>
}


/// <summary>
/// Selects types that have a specific name.
/// </summary>
/// <param name="name">The name of the class to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList HaveName(string name)
{
AddFunctionCall(x => FunctionDelegates.HaveName(x, name, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that do not have a particular name.
/// </summary>
/// <param name="name">The name of the class to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotHaveName(string name)
{
AddFunctionCall(x => FunctionDelegates.HaveName(x, name, false));
return CreateConditionList();
}

/// <summary>
/// Selects types according to a regular expression matching their name.
/// </summary>
/// <param name="pattern">The regular expression pattern to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList HaveNameMatching(string pattern)
{
AddFunctionCall(x => FunctionDelegates.HaveNameMatching(x, pattern, true));
return CreateConditionList();
}

/// <summary>
/// Selects types according to a regular expression that does not match their name.
/// </summary>
/// <param name="pattern">The regular expression pattern to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotHaveNameMatching(string pattern)
{
AddFunctionCall(x => FunctionDelegates.HaveNameMatching(x, pattern, false));
return CreateConditionList();
}

/// <summary>
/// Selects types whose names start with the specified text.
/// </summary>
/// <param name="start">The text to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList HaveNameStartingWith(string start)
{
AddFunctionCall(x => FunctionDelegates.HaveNameStartingWith(x, start, true));
return CreateConditionList();
}

/// <summary>
/// Selects types whose names start with the specified text.
/// </summary>
/// <param name="start">The text to match against.</param>
/// <param name="comparer">The string comparer.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList HaveNameStartingWith(string start, StringComparison comparer)
{
AddFunctionCall(x => FunctionDelegates.HaveNameStartingWith(x, start, true, comparer));
return CreateConditionList();
}

/// <summary>
/// Selects types whose names do not start with the specified text.
/// </summary>
/// <param name="start">The text to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotHaveNameStartingWith(string start)
{
AddFunctionCall(x => FunctionDelegates.HaveNameStartingWith(x, start, false));
return CreateConditionList();
}

/// <summary>
/// Selects types whose names do not start with the specified text.
/// </summary>
/// <param name="start">The text to match against.</param>
/// <param name="comparer">The string comparer.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotHaveNameStartingWith(string start, StringComparison comparer)
{
AddFunctionCall(x => FunctionDelegates.HaveNameStartingWith(x, start, false, comparer));
return CreateConditionList();
}

/// <summary>
/// Selects types whose names do not end with the specified text.
/// </summary>
/// <param name="end">The text to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList HaveNameEndingWith(string end)
{
AddFunctionCall(x => FunctionDelegates.HaveNameEndingWith(x, end, true));
return CreateConditionList();
}

/// <summary>
/// Selects types whose names do not end with the specified text.
/// </summary>
/// <param name="end">The text to match against.</param>
/// <param name="comparer">The string comparer.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList HaveNameEndingWith(string end, StringComparison comparer)
{
AddFunctionCall(x => FunctionDelegates.HaveNameEndingWith(x, end, true, comparer));
return CreateConditionList();
}

/// <summary>
/// Selects types whose names do not end with the specified text.
/// </summary>
/// <param name="end">The text to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotHaveNameEndingWith(string end)
{
AddFunctionCall(x => FunctionDelegates.HaveNameEndingWith(x, end, false));
return CreateConditionList();
}


/// <summary>
/// Selects types whose names do not end with the specified text.
/// </summary>
/// <param name="end">The text to match against.</param>
/// <param name="comparer">The string comparer.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotHaveNameEndingWith(string end, StringComparison comparer)
{
AddFunctionCall(x => FunctionDelegates.HaveNameEndingWith(x, end, false, comparer));
return CreateConditionList();
}


/// <summary>
/// Selects types are decorated with a specific custom attribut.
Expand Down Expand Up @@ -260,115 +128,7 @@ public ConditionList NotImplementInterface(Type interfaceType)
return CreateConditionList();
}

/// <summary>
/// Selects types that reside in a particular namespace.
/// </summary>
/// <param name="name">The namespace to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList ResideInNamespace(string name)
{
AddFunctionCall(x => FunctionDelegates.ResideInNamespace(x, name, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that do not reside in a particular namespace.
/// </summary>
/// <param name="name">The namespace to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotResideInNamespace(string name)
{
AddFunctionCall(x => FunctionDelegates.ResideInNamespace(x, name, false));
return CreateConditionList();
}

/// <summary>
/// Selects types that reside in a namespace matching a regular expression.
/// </summary>
/// <param name="pattern">The regular expression pattern to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList ResideInNamespaceMatching(string pattern)
{
AddFunctionCall(x => FunctionDelegates.ResideInNamespaceMatching(x, pattern, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that do not reside in a namespace matching a regular expression.
/// </summary>
/// <param name="pattern">The regular expression pattern to match against.</param>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotResideInNamespaceMatching(string pattern)
{
AddFunctionCall(x => FunctionDelegates.ResideInNamespaceMatching(x, pattern, false));
return CreateConditionList();
}

/// <summary>
/// Selects types whose namespaces start with a particular name part.
/// </summary>
/// <param name="name">The namespace part to match against.</param>
/// <returns>An updated set of predicates that can be applied to a list of types.</returns>
public ConditionList ResideInNamespaceStartingWith(string name)
{
AddFunctionCall(x => FunctionDelegates.ResideInNamespaceMatching(x, $"^{name}", true));
return CreateConditionList();
}

/// <summary>
/// Selects types whose namespaces start with a particular name part.
/// </summary>
/// <param name="name">The namespace part to match against.</param>
/// <returns>An updated set of predicates that can be applied to a list of types.</returns>
public ConditionList NotResideInNamespaceStartingWith(string name)
{
AddFunctionCall(x => FunctionDelegates.ResideInNamespaceMatching(x, $"^{name}", false));
return CreateConditionList();
}

/// <summary>
/// Selects types whose namespaces end with a particular name part.
/// </summary>
/// <param name="name">The namespace part to match against.</param>
/// <returns>An updated set of predicates that can be applied to a list of types.</returns>
public ConditionList ResideInNamespaceEndingWith(string name)
{
AddFunctionCall(x => FunctionDelegates.ResideInNamespaceMatching(x, $"{name}$", true));
return CreateConditionList();
}

/// <summary>
/// Selects types whose namespaces end with a particular name part.
/// </summary>
/// <param name="name">The namespace part to match against.</param>
/// <returns>An updated set of predicates that can be applied to a list of types.</returns>
public ConditionList NotResideInNamespaceEndingWith(string name)
{
AddFunctionCall(x => FunctionDelegates.ResideInNamespaceMatching(x, $"{name}$", false));
return CreateConditionList();
}

/// <summary>
/// Selects types whose namespaces contain a particular name part.
/// </summary>
/// <param name="name">The namespace part to match against.</param>
/// <returns>An updated set of predicates that can be applied to a list of types.</returns>
public ConditionList ResideInNamespaceContaining(string name)
{
AddFunctionCall(x => FunctionDelegates.ResideInNamespaceMatching(x, $"^.*{name}.*$", true));
return CreateConditionList();
}

/// <summary>
/// Selects types whose namespaces contain a particular name part.
/// </summary>
/// <param name="name">The namespace part to match against.</param>
/// <returns>An updated set of predicates that can be applied to a list of types.</returns>
public ConditionList NotResideInNamespaceContaining(string name)
{
AddFunctionCall(x => FunctionDelegates.ResideInNamespaceMatching(x, $"^.*{name}.*$", false));
return CreateConditionList();
}


/// <summary>
/// Selects types that meet a custom rule.
Expand Down
Loading

0 comments on commit fa3b718

Please sign in to comment.