Skip to content

Commit 55ddf70

Browse files
Merge pull request #377 from TNG/feat/remove-obsolete-fluent-syntax-methods
Remove Obsolete Fluent Syntax Methods
2 parents 898cfb0 + 4727b67 commit 55ddf70

34 files changed

+27
-7470
lines changed

ArchUnitNET/Domain/Extensions/AttributeExtensions.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,11 @@ namespace ArchUnitNET.Domain.Extensions
55
{
66
public static class AttributeExtensions
77
{
8-
[Obsolete(
9-
"Either HasAttribute() without the useRegularExpressions parameter or HasAttributeMatching() should be used"
10-
)]
11-
public static bool HasAttribute(
12-
this IHasAttributes a,
13-
string pattern,
14-
bool useRegularExpressions
15-
)
16-
{
17-
return a.Attributes.Any(attribute =>
18-
attribute.FullNameMatches(pattern, useRegularExpressions)
19-
);
20-
}
21-
228
public static bool HasAttribute(this IHasAttributes a, string fullName)
239
{
2410
return a.Attributes.Any(attribute => attribute.FullNameEquals(fullName));
2511
}
2612

27-
[Obsolete(
28-
"Either OnlyHasAttributes() without the useRegularExpressions parameter or OnlyHasAttributesMatching() should be used"
29-
)]
30-
public static bool OnlyHasAttributes(
31-
this IHasAttributes a,
32-
string pattern,
33-
bool useRegularExpressions
34-
)
35-
{
36-
return a.Attributes.IsNullOrEmpty()
37-
|| a.Attributes.All(attribute =>
38-
attribute.FullNameMatches(pattern, useRegularExpressions)
39-
);
40-
}
41-
4213
public static bool HasAttributeMatching(this IHasAttributes a, string pattern)
4314
{
4415
return a.Attributes.Any(attribute => attribute.FullNameMatches(pattern));

ArchUnitNET/Domain/Extensions/DependencyExtensions.cs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,6 @@ namespace ArchUnitNET.Domain.Extensions
77
{
88
public static class DependencyExtensions
99
{
10-
[Obsolete(
11-
"Either CallsMethod() without the useRegularExpressions parameter or CallsMethodMatching() should be used"
12-
)]
13-
public static bool CallsMethod(
14-
this IHasDependencies type,
15-
string pattern,
16-
bool useRegularExpressions
17-
)
18-
{
19-
return type.GetCalledMethods()
20-
.Any(member => member.FullNameMatches(pattern, useRegularExpressions));
21-
}
22-
2310
public static bool CallsMethod(this IHasDependencies type, string fullName)
2411
{
2512
return type.GetCalledMethods().Any(member => member.FullNameEquals(fullName));
@@ -44,19 +31,6 @@ public static IEnumerable<FieldMember> GetAccessedFieldMembers(this IHasDependen
4431
.Select(dependency => (FieldMember)dependency.TargetMember);
4532
}
4633

47-
[Obsolete(
48-
"Either DependsOnType() without the useRegularExpressions parameter or DependsOnTypeMatching() should be used"
49-
)]
50-
public static bool DependsOn(
51-
this IHasDependencies c,
52-
string pattern,
53-
bool useRegularExpressions = false
54-
)
55-
{
56-
return c.GetTypeDependencies()
57-
.Any(d => d.FullNameMatches(pattern, useRegularExpressions));
58-
}
59-
6034
public static bool DependsOnType(this IHasDependencies c, string fullName)
6135
{
6236
return c.GetTypeDependencies().Any(d => d.FullNameEquals(fullName));
@@ -67,19 +41,6 @@ public static bool DependsOnTypeMatching(this IHasDependencies c, string pattern
6741
return c.GetTypeDependencies().Any(d => d.FullNameMatches(pattern));
6842
}
6943

70-
[Obsolete(
71-
"Either OnlyDependsOnType() without the useRegularExpressions parameter or OnlyDependsOnTypesMatching() should be used"
72-
)]
73-
public static bool OnlyDependsOn(
74-
this IHasDependencies c,
75-
string pattern,
76-
bool useRegularExpressions = false
77-
)
78-
{
79-
return c.GetTypeDependencies()
80-
.All(d => d.FullNameMatches(pattern, useRegularExpressions));
81-
}
82-
8344
public static bool OnlyDependsOnType(this IHasDependencies c, string fullName)
8445
{
8546
return c.GetTypeDependencies().All(d => d.FullNameEquals(fullName));

ArchUnitNET/Domain/Extensions/MemberExtensions.cs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ namespace ArchUnitNET.Domain.Extensions
77
{
88
public static class MemberExtensions
99
{
10-
[Obsolete(
11-
"Either IsDeclaredIn() without the useRegularExpressions parameter or IsDeclaredInTypeMatching() should be used"
12-
)]
13-
public static bool IsDeclaredIn(
14-
this IMember member,
15-
string pattern,
16-
bool useRegularExpressions
17-
)
18-
{
19-
return member.DeclaringType.FullNameMatches(pattern, useRegularExpressions);
20-
}
21-
2210
public static bool IsDeclaredIn(this IMember member, string fullName)
2311
{
2412
return member.DeclaringType.FullNameEquals(fullName);
@@ -70,22 +58,6 @@ public static bool HasMethodCallDependencies(
7058
return member.GetMethodCallDependencies(getBackwardsDependencies).Any();
7159
}
7260

73-
[Obsolete(
74-
"Either IsCalledByType() without the useRegularExpressions parameter or IsCalledByTypeMatching() should be used"
75-
)]
76-
public static bool IsCalledBy(
77-
this MethodMember member,
78-
string pattern,
79-
bool useRegularExpressions = false
80-
)
81-
{
82-
return member
83-
.GetMethodCallDependencies(true)
84-
.Any(dependency =>
85-
dependency.Origin.FullNameMatches(pattern, useRegularExpressions)
86-
);
87-
}
88-
8961
public static bool IsCalledByType(this MethodMember member, string fullName)
9062
{
9163
return member
@@ -108,22 +80,6 @@ public static IEnumerable<IType> GetCallingTypes(this MethodMember member)
10880
.Distinct();
10981
}
11082

111-
[Obsolete(
112-
"Either HasDependencyInMethodBodyToType() without the useRegularExpressions parameter or HasDependencyInMethodBodyToTypeMatching() should be used"
113-
)]
114-
public static bool HasDependencyInMethodBodyTo(
115-
this MethodMember member,
116-
string pattern,
117-
bool useRegularExpressions = false
118-
)
119-
{
120-
return member
121-
.GetBodyTypeMemberDependencies()
122-
.Any(dependency =>
123-
dependency.Target.FullNameMatches(pattern, useRegularExpressions)
124-
);
125-
}
126-
12783
public static bool HasDependencyInMethodBodyToType(
12884
this MethodMember member,
12985
string fullName

ArchUnitNET/Domain/Extensions/NamingExtensions.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,6 @@ public static bool NameContains(
3636
return cls.Name.IndexOf(pattern, stringComparison) >= 0;
3737
}
3838

39-
[Obsolete(
40-
"Either NameEquals() or NameMatches() without the useRegularExpressions parameter should be used"
41-
)]
42-
public static bool NameMatches(
43-
this IHasName cls,
44-
string pattern,
45-
bool useRegularExpressions
46-
)
47-
{
48-
if (useRegularExpressions)
49-
{
50-
return pattern != null && Regex.IsMatch(cls.Name, pattern);
51-
}
52-
53-
return string.Equals(cls.Name, pattern, StringComparison.OrdinalIgnoreCase);
54-
}
55-
5639
public static bool NameEquals(this IHasName cls, string name)
5740
{
5841
return string.Equals(cls.Name, name, StringComparison.OrdinalIgnoreCase);
@@ -63,23 +46,6 @@ public static bool NameMatches(this IHasName cls, string pattern)
6346
return pattern != null && Regex.IsMatch(cls.Name, pattern);
6447
}
6548

66-
[Obsolete(
67-
"Either FullNameEquals() or FullNameMatches() without the useRegularExpressions parameter should be used"
68-
)]
69-
public static bool FullNameMatches(
70-
this IHasName cls,
71-
string pattern,
72-
bool useRegularExpressions
73-
)
74-
{
75-
if (useRegularExpressions)
76-
{
77-
return pattern != null && Regex.IsMatch(cls.FullName, pattern);
78-
}
79-
80-
return string.Equals(cls.FullName, pattern, StringComparison.OrdinalIgnoreCase);
81-
}
82-
8349
public static bool FullNameEquals(this IHasName cls, string fullName)
8450
{
8551
return string.Equals(cls.FullName, fullName, StringComparison.OrdinalIgnoreCase);

ArchUnitNET/Domain/Extensions/TypeExtensions.cs

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,6 @@ public static bool ImplementsInterface(this IType type, Interface intf)
1919
);
2020
}
2121

22-
[Obsolete(
23-
"Either ImplementsInterface() without the useRegularExpressions parameter or ImplementsInterfaceMatching() should be used"
24-
)]
25-
public static bool ImplementsInterface(
26-
this IType type,
27-
string pattern,
28-
bool useRegularExpressions
29-
)
30-
{
31-
if (type is GenericParameter)
32-
{
33-
return false;
34-
}
35-
36-
return type.ImplementedInterfaces.Any(implementedInterface =>
37-
implementedInterface.FullNameMatches(pattern, useRegularExpressions)
38-
);
39-
}
40-
4122
public static bool ImplementsInterface(this IType type, string fullName)
4223
{
4324
if (type is GenericParameter)
@@ -74,26 +55,6 @@ public static bool IsAssignableTo(this IType type, IType assignableToType)
7455
return type.GetAssignableTypes().Contains(assignableToType);
7556
}
7657

77-
[Obsolete(
78-
"Either IsAssignableTo() without the useRegularExpressions parameter or IsAssignableToTypeMatching() should be used"
79-
)]
80-
public static bool IsAssignableTo(
81-
this IType type,
82-
string pattern,
83-
bool useRegularExpressions
84-
)
85-
{
86-
if (type is GenericParameter genericParameter)
87-
{
88-
return genericParameter.TypeConstraints.All(t =>
89-
t.IsAssignableTo(pattern, useRegularExpressions)
90-
);
91-
}
92-
93-
return type.GetAssignableTypes()
94-
.Any(t => t.FullNameMatches(pattern, useRegularExpressions));
95-
}
96-
9758
public static bool IsAssignableTo(this IType type, string fullName)
9859
{
9960
if (type is GenericParameter genericParameter)
@@ -278,18 +239,6 @@ public static Attribute GetAttributeOfType(this IType type, Class attributeClass
278239
);
279240
}
280241

281-
[Obsolete(
282-
"Either ResidesInNamespace() without the useRegularExpressions parameter or ResidesInNamespaceMatching() should be used"
283-
)]
284-
public static bool ResidesInNamespace(
285-
this IType e,
286-
string pattern,
287-
bool useRegularExpressions
288-
)
289-
{
290-
return e.Namespace.FullNameMatches(pattern, useRegularExpressions);
291-
}
292-
293242
public static bool ResidesInNamespace(this IType e, string fullName)
294243
{
295244
return e.Namespace.FullNameEquals(fullName);
@@ -300,18 +249,6 @@ public static bool ResidesInNamespaceMatching(this IType e, string pattern)
300249
return e.Namespace.FullNameMatches(pattern);
301250
}
302251

303-
[Obsolete(
304-
"Either ResidesInAssembly() without the useRegularExpressions parameter or ResidesInAssemblyMatching() should be used"
305-
)]
306-
public static bool ResidesInAssembly(
307-
this IType e,
308-
string pattern,
309-
bool useRegularExpressions
310-
)
311-
{
312-
return e.Assembly.FullNameMatches(pattern, useRegularExpressions);
313-
}
314-
315252
public static bool ResidesInAssembly(this IType e, string fullName)
316253
{
317254
return e.Assembly.FullNameEquals(fullName);
@@ -322,21 +259,6 @@ public static bool ResidesInAssemblyMatching(this IType e, string pattern)
322259
return e.Assembly.FullNameMatches(pattern);
323260
}
324261

325-
[Obsolete(
326-
"Either IsDeclaredAsFieldIn() without the useRegularExpressions parameter or IsDeclaredAsFieldInTypeMatching() should be used"
327-
)]
328-
public static bool IsDeclaredAsFieldIn(
329-
this IType type,
330-
string pattern,
331-
bool useRegularExpressions
332-
)
333-
{
334-
return type.GetFieldTypeDependencies(true)
335-
.Any(dependency =>
336-
dependency.Target.FullNameMatches(pattern, useRegularExpressions)
337-
);
338-
}
339-
340262
public static bool IsDeclaredAsFieldIn(this IType type, string fullName)
341263
{
342264
return type.GetFieldTypeDependencies(true)

ArchUnitNET/Domain/PlantUml/Export/DependencyFilters.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,6 @@ public static Func<ITypeDependency, bool> FocusOn(IEnumerable<IType> types)
5050
};
5151
}
5252

53-
[Obsolete(
54-
"Another overload of this method should be used. This will be removed in a future update."
55-
)]
56-
public static Func<ITypeDependency, bool> FocusOn(
57-
string pattern,
58-
bool useRegularExpressions = false
59-
)
60-
{
61-
return dependency =>
62-
dependency.Target.FullNameMatches(pattern, useRegularExpressions)
63-
^ dependency.Origin.FullNameMatches(pattern, useRegularExpressions);
64-
}
65-
6653
public static Func<ITypeDependency, bool> HasOrigin(IType type)
6754
{
6855
return dependency => dependency.Origin.Equals(type);
@@ -73,17 +60,6 @@ public static Func<ITypeDependency, bool> HasOrigin(IEnumerable<IType> types)
7360
return dependency => types.Contains(dependency.Origin);
7461
}
7562

76-
[Obsolete(
77-
"Another overload of this method should be used. This will be removed in a future update."
78-
)]
79-
public static Func<ITypeDependency, bool> HasOrigin(
80-
string pattern,
81-
bool useRegularExpressions = false
82-
)
83-
{
84-
return dependency => dependency.Origin.FullNameMatches(pattern, useRegularExpressions);
85-
}
86-
8763
public static Func<ITypeDependency, bool> HasTarget(IType type)
8864
{
8965
return dependency => dependency.Target.Equals(type);
@@ -93,16 +69,5 @@ public static Func<ITypeDependency, bool> HasTarget(IEnumerable<IType> types)
9369
{
9470
return dependency => types.Contains(dependency.Target);
9571
}
96-
97-
[Obsolete(
98-
"Another overload of this method should be used. This will be removed in a future update."
99-
)]
100-
public static Func<ITypeDependency, bool> HasTarget(
101-
string pattern,
102-
bool useRegularExpressions = false
103-
)
104-
{
105-
return dependency => dependency.Target.FullNameMatches(pattern, useRegularExpressions);
106-
}
10772
}
10873
}

0 commit comments

Comments
 (0)