Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Remove Obsolete Fluent Syntax Methods
Signed-off-by: Alexander Linne <[email protected]>
  • Loading branch information
alexanderlinne committed Sep 26, 2025
commit 077d4ea06228d57847c2da6943e81a54698e8403
29 changes: 0 additions & 29 deletions ArchUnitNET/Domain/Extensions/AttributeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,11 @@ namespace ArchUnitNET.Domain.Extensions
{
public static class AttributeExtensions
{
[Obsolete(
"Either HasAttribute() without the useRegularExpressions parameter or HasAttributeMatching() should be used"
)]
public static bool HasAttribute(
this IHasAttributes a,
string pattern,
bool useRegularExpressions
)
{
return a.Attributes.Any(attribute =>
attribute.FullNameMatches(pattern, useRegularExpressions)
);
}

public static bool HasAttribute(this IHasAttributes a, string fullName)
{
return a.Attributes.Any(attribute => attribute.FullNameEquals(fullName));
}

[Obsolete(
"Either OnlyHasAttributes() without the useRegularExpressions parameter or OnlyHasAttributesMatching() should be used"
)]
public static bool OnlyHasAttributes(
this IHasAttributes a,
string pattern,
bool useRegularExpressions
)
{
return a.Attributes.IsNullOrEmpty()
|| a.Attributes.All(attribute =>
attribute.FullNameMatches(pattern, useRegularExpressions)
);
}

public static bool HasAttributeMatching(this IHasAttributes a, string pattern)
{
return a.Attributes.Any(attribute => attribute.FullNameMatches(pattern));
Expand Down
39 changes: 0 additions & 39 deletions ArchUnitNET/Domain/Extensions/DependencyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,6 @@ namespace ArchUnitNET.Domain.Extensions
{
public static class DependencyExtensions
{
[Obsolete(
"Either CallsMethod() without the useRegularExpressions parameter or CallsMethodMatching() should be used"
)]
public static bool CallsMethod(
this IHasDependencies type,
string pattern,
bool useRegularExpressions
)
{
return type.GetCalledMethods()
.Any(member => member.FullNameMatches(pattern, useRegularExpressions));
}

public static bool CallsMethod(this IHasDependencies type, string fullName)
{
return type.GetCalledMethods().Any(member => member.FullNameEquals(fullName));
Expand All @@ -44,19 +31,6 @@ public static IEnumerable<FieldMember> GetAccessedFieldMembers(this IHasDependen
.Select(dependency => (FieldMember)dependency.TargetMember);
}

[Obsolete(
"Either DependsOnType() without the useRegularExpressions parameter or DependsOnTypeMatching() should be used"
)]
public static bool DependsOn(
this IHasDependencies c,
string pattern,
bool useRegularExpressions = false
)
{
return c.GetTypeDependencies()
.Any(d => d.FullNameMatches(pattern, useRegularExpressions));
}

public static bool DependsOnType(this IHasDependencies c, string fullName)
{
return c.GetTypeDependencies().Any(d => d.FullNameEquals(fullName));
Expand All @@ -67,19 +41,6 @@ public static bool DependsOnTypeMatching(this IHasDependencies c, string pattern
return c.GetTypeDependencies().Any(d => d.FullNameMatches(pattern));
}

[Obsolete(
"Either OnlyDependsOnType() without the useRegularExpressions parameter or OnlyDependsOnTypesMatching() should be used"
)]
public static bool OnlyDependsOn(
this IHasDependencies c,
string pattern,
bool useRegularExpressions = false
)
{
return c.GetTypeDependencies()
.All(d => d.FullNameMatches(pattern, useRegularExpressions));
}

public static bool OnlyDependsOnType(this IHasDependencies c, string fullName)
{
return c.GetTypeDependencies().All(d => d.FullNameEquals(fullName));
Expand Down
44 changes: 0 additions & 44 deletions ArchUnitNET/Domain/Extensions/MemberExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ namespace ArchUnitNET.Domain.Extensions
{
public static class MemberExtensions
{
[Obsolete(
"Either IsDeclaredIn() without the useRegularExpressions parameter or IsDeclaredInTypeMatching() should be used"
)]
public static bool IsDeclaredIn(
this IMember member,
string pattern,
bool useRegularExpressions
)
{
return member.DeclaringType.FullNameMatches(pattern, useRegularExpressions);
}

public static bool IsDeclaredIn(this IMember member, string fullName)
{
return member.DeclaringType.FullNameEquals(fullName);
Expand Down Expand Up @@ -70,22 +58,6 @@ public static bool HasMethodCallDependencies(
return member.GetMethodCallDependencies(getBackwardsDependencies).Any();
}

[Obsolete(
"Either IsCalledByType() without the useRegularExpressions parameter or IsCalledByTypeMatching() should be used"
)]
public static bool IsCalledBy(
this MethodMember member,
string pattern,
bool useRegularExpressions = false
)
{
return member
.GetMethodCallDependencies(true)
.Any(dependency =>
dependency.Origin.FullNameMatches(pattern, useRegularExpressions)
);
}

public static bool IsCalledByType(this MethodMember member, string fullName)
{
return member
Expand All @@ -108,22 +80,6 @@ public static IEnumerable<IType> GetCallingTypes(this MethodMember member)
.Distinct();
}

[Obsolete(
"Either HasDependencyInMethodBodyToType() without the useRegularExpressions parameter or HasDependencyInMethodBodyToTypeMatching() should be used"
)]
public static bool HasDependencyInMethodBodyTo(
this MethodMember member,
string pattern,
bool useRegularExpressions = false
)
{
return member
.GetBodyTypeMemberDependencies()
.Any(dependency =>
dependency.Target.FullNameMatches(pattern, useRegularExpressions)
);
}

public static bool HasDependencyInMethodBodyToType(
this MethodMember member,
string fullName
Expand Down
34 changes: 0 additions & 34 deletions ArchUnitNET/Domain/Extensions/NamingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,6 @@ public static bool NameContains(
return cls.Name.IndexOf(pattern, stringComparison) >= 0;
}

[Obsolete(
"Either NameEquals() or NameMatches() without the useRegularExpressions parameter should be used"
)]
public static bool NameMatches(
this IHasName cls,
string pattern,
bool useRegularExpressions
)
{
if (useRegularExpressions)
{
return pattern != null && Regex.IsMatch(cls.Name, pattern);
}

return string.Equals(cls.Name, pattern, StringComparison.OrdinalIgnoreCase);
}

public static bool NameEquals(this IHasName cls, string name)
{
return string.Equals(cls.Name, name, StringComparison.OrdinalIgnoreCase);
Expand All @@ -63,23 +46,6 @@ public static bool NameMatches(this IHasName cls, string pattern)
return pattern != null && Regex.IsMatch(cls.Name, pattern);
}

[Obsolete(
"Either FullNameEquals() or FullNameMatches() without the useRegularExpressions parameter should be used"
)]
public static bool FullNameMatches(
this IHasName cls,
string pattern,
bool useRegularExpressions
)
{
if (useRegularExpressions)
{
return pattern != null && Regex.IsMatch(cls.FullName, pattern);
}

return string.Equals(cls.FullName, pattern, StringComparison.OrdinalIgnoreCase);
}

public static bool FullNameEquals(this IHasName cls, string fullName)
{
return string.Equals(cls.FullName, fullName, StringComparison.OrdinalIgnoreCase);
Expand Down
78 changes: 0 additions & 78 deletions ArchUnitNET/Domain/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,6 @@ public static bool ImplementsInterface(this IType type, Interface intf)
);
}

[Obsolete(
"Either ImplementsInterface() without the useRegularExpressions parameter or ImplementsInterfaceMatching() should be used"
)]
public static bool ImplementsInterface(
this IType type,
string pattern,
bool useRegularExpressions
)
{
if (type is GenericParameter)
{
return false;
}

return type.ImplementedInterfaces.Any(implementedInterface =>
implementedInterface.FullNameMatches(pattern, useRegularExpressions)
);
}

public static bool ImplementsInterface(this IType type, string fullName)
{
if (type is GenericParameter)
Expand Down Expand Up @@ -74,26 +55,6 @@ public static bool IsAssignableTo(this IType type, IType assignableToType)
return type.GetAssignableTypes().Contains(assignableToType);
}

[Obsolete(
"Either IsAssignableTo() without the useRegularExpressions parameter or IsAssignableToTypeMatching() should be used"
)]
public static bool IsAssignableTo(
this IType type,
string pattern,
bool useRegularExpressions
)
{
if (type is GenericParameter genericParameter)
{
return genericParameter.TypeConstraints.All(t =>
t.IsAssignableTo(pattern, useRegularExpressions)
);
}

return type.GetAssignableTypes()
.Any(t => t.FullNameMatches(pattern, useRegularExpressions));
}

public static bool IsAssignableTo(this IType type, string fullName)
{
if (type is GenericParameter genericParameter)
Expand Down Expand Up @@ -278,18 +239,6 @@ public static Attribute GetAttributeOfType(this IType type, Class attributeClass
);
}

[Obsolete(
"Either ResidesInNamespace() without the useRegularExpressions parameter or ResidesInNamespaceMatching() should be used"
)]
public static bool ResidesInNamespace(
this IType e,
string pattern,
bool useRegularExpressions
)
{
return e.Namespace.FullNameMatches(pattern, useRegularExpressions);
}

public static bool ResidesInNamespace(this IType e, string fullName)
{
return e.Namespace.FullNameEquals(fullName);
Expand All @@ -300,18 +249,6 @@ public static bool ResidesInNamespaceMatching(this IType e, string pattern)
return e.Namespace.FullNameMatches(pattern);
}

[Obsolete(
"Either ResidesInAssembly() without the useRegularExpressions parameter or ResidesInAssemblyMatching() should be used"
)]
public static bool ResidesInAssembly(
this IType e,
string pattern,
bool useRegularExpressions
)
{
return e.Assembly.FullNameMatches(pattern, useRegularExpressions);
}

public static bool ResidesInAssembly(this IType e, string fullName)
{
return e.Assembly.FullNameEquals(fullName);
Expand All @@ -322,21 +259,6 @@ public static bool ResidesInAssemblyMatching(this IType e, string pattern)
return e.Assembly.FullNameMatches(pattern);
}

[Obsolete(
"Either IsDeclaredAsFieldIn() without the useRegularExpressions parameter or IsDeclaredAsFieldInTypeMatching() should be used"
)]
public static bool IsDeclaredAsFieldIn(
this IType type,
string pattern,
bool useRegularExpressions
)
{
return type.GetFieldTypeDependencies(true)
.Any(dependency =>
dependency.Target.FullNameMatches(pattern, useRegularExpressions)
);
}

public static bool IsDeclaredAsFieldIn(this IType type, string fullName)
{
return type.GetFieldTypeDependencies(true)
Expand Down
35 changes: 0 additions & 35 deletions ArchUnitNET/Domain/PlantUml/Export/DependencyFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ public static Func<ITypeDependency, bool> FocusOn(IEnumerable<IType> types)
};
}

[Obsolete(
"Another overload of this method should be used. This will be removed in a future update."
)]
public static Func<ITypeDependency, bool> FocusOn(
string pattern,
bool useRegularExpressions = false
)
{
return dependency =>
dependency.Target.FullNameMatches(pattern, useRegularExpressions)
^ dependency.Origin.FullNameMatches(pattern, useRegularExpressions);
}

public static Func<ITypeDependency, bool> HasOrigin(IType type)
{
return dependency => dependency.Origin.Equals(type);
Expand All @@ -73,17 +60,6 @@ public static Func<ITypeDependency, bool> HasOrigin(IEnumerable<IType> types)
return dependency => types.Contains(dependency.Origin);
}

[Obsolete(
"Another overload of this method should be used. This will be removed in a future update."
)]
public static Func<ITypeDependency, bool> HasOrigin(
string pattern,
bool useRegularExpressions = false
)
{
return dependency => dependency.Origin.FullNameMatches(pattern, useRegularExpressions);
}

public static Func<ITypeDependency, bool> HasTarget(IType type)
{
return dependency => dependency.Target.Equals(type);
Expand All @@ -93,16 +69,5 @@ public static Func<ITypeDependency, bool> HasTarget(IEnumerable<IType> types)
{
return dependency => types.Contains(dependency.Target);
}

[Obsolete(
"Another overload of this method should be used. This will be removed in a future update."
)]
public static Func<ITypeDependency, bool> HasTarget(
string pattern,
bool useRegularExpressions = false
)
{
return dependency => dependency.Target.FullNameMatches(pattern, useRegularExpressions);
}
}
}
Loading
Loading