diff --git a/ArchUnitNET/Domain/Extensions/AttributeExtensions.cs b/ArchUnitNET/Domain/Extensions/AttributeExtensions.cs index 4e60e4fd3..8fb08ce03 100644 --- a/ArchUnitNET/Domain/Extensions/AttributeExtensions.cs +++ b/ArchUnitNET/Domain/Extensions/AttributeExtensions.cs @@ -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)); diff --git a/ArchUnitNET/Domain/Extensions/DependencyExtensions.cs b/ArchUnitNET/Domain/Extensions/DependencyExtensions.cs index c0a3dca4f..9dab4273a 100644 --- a/ArchUnitNET/Domain/Extensions/DependencyExtensions.cs +++ b/ArchUnitNET/Domain/Extensions/DependencyExtensions.cs @@ -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)); @@ -44,19 +31,6 @@ public static IEnumerable 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)); @@ -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)); diff --git a/ArchUnitNET/Domain/Extensions/MemberExtensions.cs b/ArchUnitNET/Domain/Extensions/MemberExtensions.cs index bc13093a0..294980c49 100644 --- a/ArchUnitNET/Domain/Extensions/MemberExtensions.cs +++ b/ArchUnitNET/Domain/Extensions/MemberExtensions.cs @@ -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); @@ -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 @@ -108,22 +80,6 @@ public static IEnumerable 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 diff --git a/ArchUnitNET/Domain/Extensions/NamingExtensions.cs b/ArchUnitNET/Domain/Extensions/NamingExtensions.cs index 88d767a2e..69a71f529 100644 --- a/ArchUnitNET/Domain/Extensions/NamingExtensions.cs +++ b/ArchUnitNET/Domain/Extensions/NamingExtensions.cs @@ -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); @@ -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); diff --git a/ArchUnitNET/Domain/Extensions/TypeExtensions.cs b/ArchUnitNET/Domain/Extensions/TypeExtensions.cs index d3c47566a..a3779b0a6 100644 --- a/ArchUnitNET/Domain/Extensions/TypeExtensions.cs +++ b/ArchUnitNET/Domain/Extensions/TypeExtensions.cs @@ -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) @@ -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) @@ -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); @@ -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); @@ -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) diff --git a/ArchUnitNET/Domain/PlantUml/Export/DependencyFilters.cs b/ArchUnitNET/Domain/PlantUml/Export/DependencyFilters.cs index b04f9e3a9..add3ab4f6 100644 --- a/ArchUnitNET/Domain/PlantUml/Export/DependencyFilters.cs +++ b/ArchUnitNET/Domain/PlantUml/Export/DependencyFilters.cs @@ -50,19 +50,6 @@ public static Func FocusOn(IEnumerable types) }; } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static Func FocusOn( - string pattern, - bool useRegularExpressions = false - ) - { - return dependency => - dependency.Target.FullNameMatches(pattern, useRegularExpressions) - ^ dependency.Origin.FullNameMatches(pattern, useRegularExpressions); - } - public static Func HasOrigin(IType type) { return dependency => dependency.Origin.Equals(type); @@ -73,17 +60,6 @@ public static Func HasOrigin(IEnumerable 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 HasOrigin( - string pattern, - bool useRegularExpressions = false - ) - { - return dependency => dependency.Origin.FullNameMatches(pattern, useRegularExpressions); - } - public static Func HasTarget(IType type) { return dependency => dependency.Target.Equals(type); @@ -93,16 +69,5 @@ public static Func HasTarget(IEnumerable 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 HasTarget( - string pattern, - bool useRegularExpressions = false - ) - { - return dependency => dependency.Target.FullNameMatches(pattern, useRegularExpressions); - } } } diff --git a/ArchUnitNET/Fluent/Syntax/Elements/GivenObjectsThat.cs b/ArchUnitNET/Fluent/Syntax/Elements/GivenObjectsThat.cs index e2d11a5cf..4f52ba5f5 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/GivenObjectsThat.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/GivenObjectsThat.cs @@ -15,31 +15,6 @@ public abstract class GivenObjectsThat protected GivenObjectsThat(IArchRuleCreator ruleCreator) : base(ruleCreator) { } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Are(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction Are(string pattern, bool useRegularExpressions = false) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.Are(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Are(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction Are( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.Are(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction Are( ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects @@ -63,31 +38,6 @@ public TGivenRuleTypeConjunction Are(IObjectProvider objects) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction CallAny(string pattern, bool useRegularExpressions = false) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.CallAny(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction CallAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.CallAny(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction CallAny( MethodMember method, params MethodMember[] moreMethods @@ -111,34 +61,6 @@ public TGivenRuleTypeConjunction CallAny(IObjectProvider methods) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction DependOnAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DependOnAny(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction DependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DependOnAny(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction DependOnAny(Type firstType, params Type[] moreTypes) { _ruleCreator.AddPredicate( @@ -190,34 +112,6 @@ string description return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction OnlyDependOn( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.OnlyDependOn(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction OnlyDependOn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.OnlyDependOn(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction OnlyDependOn(Type firstType, params Type[] moreTypes) { _ruleCreator.AddPredicate( @@ -252,40 +146,6 @@ public TGivenRuleTypeConjunction OnlyDependOn(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction HaveAnyAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.HaveAnyAttributes( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction HaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.HaveAnyAttributes( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction HaveAnyAttributes( Type firstAttribute, params Type[] moreAttributes @@ -338,40 +198,6 @@ public TGivenRuleTypeConjunction HaveAnyAttributes(IEnumerable attributes) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction OnlyHaveAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.OnlyHaveAttributes( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction OnlyHaveAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.OnlyHaveAttributes( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction OnlyHaveAttributes( Type firstAttribute, params Type[] moreAttributes @@ -448,42 +274,6 @@ params object[] moreArgumentValues return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TGivenRuleTypeConjunction HaveAttributeWithArguments( - string attribute, - IEnumerable argumentValues - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.HaveAttributeWithArguments( - attribute, - argumentValues - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TGivenRuleTypeConjunction HaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.HaveAttributeWithArguments( - attribute, - firstArgumentValue, - moreArgumentValues - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction HaveAttributeWithArguments( Attribute attribute, IEnumerable argumentValues @@ -570,42 +360,6 @@ public TGivenRuleTypeConjunction HaveAnyAttributesWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TGivenRuleTypeConjunction HaveAttributeWithNamedArguments( - string attribute, - IEnumerable<(string, object)> attributeArguments - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.HaveAttributeWithNamedArguments( - attribute, - attributeArguments - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TGivenRuleTypeConjunction HaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.HaveAttributeWithNamedArguments( - attribute, - firstAttributeArgument, - moreAttributeArguments - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction HaveAttributeWithNamedArguments( Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -666,17 +420,6 @@ public TGivenRuleTypeConjunction HaveAttributeWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Either HaveName() without the useRegularExpressions parameter or HaveNameMatching() should be used" - )] - public TGivenRuleTypeConjunction HaveName(string pattern, bool useRegularExpressions) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.HaveName(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction HaveName(string name) { _ruleCreator.AddPredicate(ObjectPredicatesDefinition.HaveName(name)); @@ -691,17 +434,6 @@ public TGivenRuleTypeConjunction HaveNameMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either HaveFullName() without the useRegularExpressions parameter or HaveFullNameMatching() should be used" - )] - public TGivenRuleTypeConjunction HaveFullName(string pattern, bool useRegularExpressions) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.HaveFullName(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction HaveFullName(string fullName) { _ruleCreator.AddPredicate(ObjectPredicatesDefinition.HaveFullName(fullName)); @@ -786,31 +518,6 @@ public TGivenRuleTypeConjunction ArePrivateProtected() //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNot(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction AreNot(string pattern, bool useRegularExpressions = false) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.AreNot(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNot(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction AreNot( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.AreNot(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction AreNot( ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects @@ -834,34 +541,6 @@ public TGivenRuleTypeConjunction AreNot(IObjectProvider objects) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction DoNotCallAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotCallAny(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction DoNotCallAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotCallAny(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction DoNotCallAny( MethodMember method, params MethodMember[] moreMethods @@ -885,40 +564,6 @@ public TGivenRuleTypeConjunction DoNotCallAny(IObjectProvider meth return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotDependOnAny(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction DoNotDependOnAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotDependOnAny( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotDependOnAny(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction DoNotDependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotDependOnAny( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction DoNotDependOnAny(Type firstType, params Type[] moreTypes) { _ruleCreator.AddPredicate( @@ -959,40 +604,6 @@ public TGivenRuleTypeConjunction DoNotDependOnAny(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction DoNotHaveAnyAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotHaveAnyAttributes( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction DoNotHaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotHaveAnyAttributes( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction DoNotHaveAnyAttributes( Type firstAttribute, params Type[] moreAttributes @@ -1073,78 +684,6 @@ params object[] moreArgumentValues return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TGivenRuleTypeConjunction DoNotHaveAttributeWithArguments( - string attribute, - IEnumerable argumentValues - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotHaveAttributeWithArguments( - attribute, - argumentValues - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TGivenRuleTypeConjunction DoNotHaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotHaveAttributeWithArguments( - attribute, - firstArgumentValue, - moreArgumentValues - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TGivenRuleTypeConjunction DoNotHaveAttributeWithNamedArguments( - string attribute, - IEnumerable<(string, object)> attributeArguments - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotHaveAttributeWithNamedArguments( - attribute, - attributeArguments - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TGivenRuleTypeConjunction DoNotHaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotHaveAttributeWithNamedArguments( - attribute, - firstAttributeArgument, - moreAttributeArguments - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction DoNotHaveAttributeWithArguments( Attribute attribute, IEnumerable argumentValues @@ -1291,17 +830,6 @@ public TGivenRuleTypeConjunction DoNotHaveAttributeWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Either DoNotHaveName() without the useRegularExpressions parameter or DoNotHaveNameMatching() should be used" - )] - public TGivenRuleTypeConjunction DoNotHaveName(string pattern, bool useRegularExpressions) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotHaveName(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction DoNotHaveName(string name) { _ruleCreator.AddPredicate(ObjectPredicatesDefinition.DoNotHaveName(name)); @@ -1316,23 +844,6 @@ public TGivenRuleTypeConjunction DoNotHaveNameMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either DoNotHaveFullName() without the useRegularExpressions parameter or DoNotHaveFullNameMatching() should be used" - )] - public TGivenRuleTypeConjunction DoNotHaveFullName( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.AddPredicate( - ObjectPredicatesDefinition.DoNotHaveFullName( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction DoNotHaveFullName(string fullName) { _ruleCreator.AddPredicate( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/IObjectConditions.cs b/ArchUnitNET/Fluent/Syntax/Elements/IObjectConditions.cs index bb424414f..aa7ef0c7c 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/IObjectConditions.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/IObjectConditions.cs @@ -11,41 +11,14 @@ public interface IObjectConditions { TReturnType Exist(); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Be(Types().That().HaveFullName()) instead" - )] - TReturnType Be(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Be(Types().That().HaveFullName()) instead" - )] - TReturnType Be(IEnumerable patterns, bool useRegularExpressions = false); TReturnType Be(ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects); TReturnType Be(IEnumerable objects); TReturnType Be(IObjectProvider objects); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - TReturnType CallAny(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - TReturnType CallAny(IEnumerable patterns, bool useRegularExpressions = false); TReturnType CallAny(MethodMember method, params MethodMember[] moreMethods); TReturnType CallAny(IEnumerable methods); TReturnType CallAny(IObjectProvider methods); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - TReturnType DependOnAny(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - TReturnType DependOnAny(IEnumerable patterns, bool useRegularExpressions = false); TReturnType DependOnAny(IType firstType, params IType[] moreTypes); TReturnType DependOnAny(Type firstType, params Type[] moreTypes); TReturnType DependOnAny(IObjectProvider types); @@ -62,51 +35,18 @@ TReturnType FollowCustomCondition( string failDescription ); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - TReturnType OnlyDependOn(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - TReturnType OnlyDependOn(IEnumerable patterns, bool useRegularExpressions = false); TReturnType OnlyDependOn(IType firstType, params IType[] moreTypes); TReturnType OnlyDependOn(Type firstType, params Type[] moreTypes); TReturnType OnlyDependOn(IObjectProvider types); TReturnType OnlyDependOn(IEnumerable types); TReturnType OnlyDependOn(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType HaveAnyAttributes(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType HaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType HaveAnyAttributes(Attribute firstAttribute, params Attribute[] moreAttributes); TReturnType HaveAnyAttributes(Type firstAttribute, params Type[] moreAttributes); TReturnType HaveAnyAttributes(IObjectProvider attributes); TReturnType HaveAnyAttributes(IEnumerable attributes); TReturnType HaveAnyAttributes(IEnumerable attributes); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType OnlyHaveAttributes(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType OnlyHaveAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType OnlyHaveAttributes(Attribute firstAttribute, params Attribute[] moreAttributes); TReturnType OnlyHaveAttributes(Type firstAttribute, params Type[] moreAttributes); TReturnType OnlyHaveAttributes(IObjectProvider attributes); @@ -118,22 +58,6 @@ TReturnType HaveAnyAttributesWithArguments( params object[] moreArgumentValues ); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType HaveAttributeWithArguments( - string attribute, - IEnumerable argumentValues - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType HaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ); TReturnType HaveAttributeWithArguments( Attribute attribute, IEnumerable argumentValues @@ -157,22 +81,6 @@ TReturnType HaveAnyAttributesWithNamedArguments( params (string, object)[] moreAttributeArguments ); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType HaveAttributeWithNamedArguments( - string attribute, - IEnumerable<(string, object)> attributeArguments - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType HaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ); TReturnType HaveAttributeWithNamedArguments( Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -192,17 +100,9 @@ TReturnType HaveAttributeWithNamedArguments( params (string, object)[] moreAttributeArguments ); - [Obsolete( - "Either HaveName() without the useRegularExpressions parameter or HaveNameMatching() should be used" - )] - TReturnType HaveName(string pattern, bool useRegularExpressions); TReturnType HaveName(string name); TReturnType HaveNameMatching(string pattern); - [Obsolete( - "Either HaveFullName() without the useRegularExpressions parameter or HaveFullNameMatching() should be used" - )] - TReturnType HaveFullName(string pattern, bool useRegularExpressions); TReturnType HaveFullName(string fullName); TReturnType HaveFullNameMatching(string pattern); TReturnType HaveNameStartingWith(string pattern); @@ -220,62 +120,20 @@ TReturnType HaveAttributeWithNamedArguments( TReturnType NotExist(); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBe(Types().That().HaveFullName()) instead" - )] - TReturnType NotBe(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBe(Types().That().HaveFullName()) instead" - )] - TReturnType NotBe(IEnumerable patterns, bool useRegularExpressions = false); TReturnType NotBe(ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects); TReturnType NotBe(IEnumerable objects); TReturnType NotBe(IObjectProvider objects); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - TReturnType NotCallAny(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - TReturnType NotCallAny(IEnumerable patterns, bool useRegularExpressions = false); TReturnType NotCallAny(MethodMember method, params MethodMember[] moreMethods); TReturnType NotCallAny(IEnumerable methods); TReturnType NotCallAny(IObjectProvider methods); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotDependOnAny(Types().That().HaveFullName()) instead" - )] - TReturnType NotDependOnAny(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotDependOnAny(Types().That().HaveFullName()) instead" - )] - TReturnType NotDependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType NotDependOnAny(IType firstType, params IType[] moreTypes); TReturnType NotDependOnAny(Type firstType, params Type[] moreTypes); TReturnType NotDependOnAny(IObjectProvider types); TReturnType NotDependOnAny(IEnumerable types); TReturnType NotDependOnAny(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType NotHaveAnyAttributes(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType NotHaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType NotHaveAnyAttributes( Attribute firstAttribute, params Attribute[] moreAttributes @@ -333,17 +191,9 @@ TReturnType NotHaveAttributeWithNamedArguments( params (string, object)[] moreAttributeArguments ); - [Obsolete( - "Either NotHaveName() without the useRegularExpressions parameter or NotHaveNameMatching() should be used" - )] - TReturnType NotHaveName(string pattern, bool useRegularExpressions); TReturnType NotHaveName(string name); TReturnType NotHaveNameMatching(string pattern); - [Obsolete( - "Either NotHaveFullName() without the useRegularExpressions parameter or NotHaveFullNameMatching() should be used" - )] - TReturnType NotHaveFullName(string pattern, bool useRegularExpressions); TReturnType NotHaveFullName(string fullName); TReturnType NotHaveFullNameMatching(string pattern); TReturnType NotHaveNameStartingWith(string pattern); diff --git a/ArchUnitNET/Fluent/Syntax/Elements/IObjectPredicates.cs b/ArchUnitNET/Fluent/Syntax/Elements/IObjectPredicates.cs index baec6c04c..53e6e43d1 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/IObjectPredicates.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/IObjectPredicates.cs @@ -9,41 +9,14 @@ namespace ArchUnitNET.Fluent.Syntax.Elements public interface IObjectPredicates where TRuleType : ICanBeAnalyzed { - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Are(Types().That().HaveFullName()) instead" - )] - TReturnType Are(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Are(Types().That().HaveFullName()) instead" - )] - TReturnType Are(IEnumerable patterns, bool useRegularExpressions = false); TReturnType Are(ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects); TReturnType Are(IEnumerable objects); TReturnType Are(IObjectProvider objects); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - TReturnType CallAny(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - TReturnType CallAny(IEnumerable patterns, bool useRegularExpressions = false); TReturnType CallAny(MethodMember method, params MethodMember[] moreMethods); TReturnType CallAny(IEnumerable methods); TReturnType CallAny(IObjectProvider methods); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - TReturnType DependOnAny(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - TReturnType DependOnAny(IEnumerable patterns, bool useRegularExpressions = false); TReturnType DependOnAny(Type firstType, params Type[] moreTypes); TReturnType DependOnAny(IType firstType, params IType[] moreTypes); TReturnType DependOnAny(IObjectProvider types); @@ -52,51 +25,18 @@ public interface IObjectPredicates TReturnType FollowCustomPredicate(IPredicate predicate); TReturnType FollowCustomPredicate(Func predicate, string description); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - TReturnType OnlyDependOn(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - TReturnType OnlyDependOn(IEnumerable patterns, bool useRegularExpressions = false); TReturnType OnlyDependOn(Type firstType, params Type[] moreTypes); TReturnType OnlyDependOn(IType firstType, params IType[] moreTypes); TReturnType OnlyDependOn(IObjectProvider types); TReturnType OnlyDependOn(IEnumerable types); TReturnType OnlyDependOn(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType HaveAnyAttributes(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType HaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType HaveAnyAttributes(Attribute firstAttribute, params Attribute[] moreAttributes); TReturnType HaveAnyAttributes(Type firstAttribute, params Type[] moreAttributes); TReturnType HaveAnyAttributes(IObjectProvider attributes); TReturnType HaveAnyAttributes(IEnumerable attributes); TReturnType HaveAnyAttributes(IEnumerable attributes); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType OnlyHaveAttributes(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType OnlyHaveAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType OnlyHaveAttributes(Attribute firstAttribute, params Attribute[] moreAttributes); TReturnType OnlyHaveAttributes(Type firstAttribute, params Type[] moreAttributes); TReturnType OnlyHaveAttributes(IObjectProvider attributes); @@ -108,22 +48,6 @@ TReturnType HaveAnyAttributesWithArguments( params object[] moreArgumentValues ); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType HaveAttributeWithArguments( - string attribute, - IEnumerable argumentValues - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType HaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ); TReturnType HaveAttributeWithArguments( Attribute attribute, IEnumerable argumentValues @@ -147,22 +71,6 @@ TReturnType HaveAnyAttributesWithNamedArguments( params (string, object)[] moreAttributeArguments ); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType HaveAttributeWithNamedArguments( - string attribute, - IEnumerable<(string, object)> attributeArguments - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType HaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ); TReturnType HaveAttributeWithNamedArguments( Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -182,17 +90,9 @@ TReturnType HaveAttributeWithNamedArguments( params (string, object)[] moreAttributeArguments ); - [Obsolete( - "Either HaveName() without the useRegularExpressions parameter or HaveNameMatching() should be used" - )] - TReturnType HaveName(string pattern, bool useRegularExpressions); TReturnType HaveName(string name); TReturnType HaveNameMatching(string pattern); - [Obsolete( - "Either HaveFullName() without the useRegularExpressions parameter or HaveFullNameMatching() should be used" - )] - TReturnType HaveFullName(string pattern, bool useRegularExpressions); TReturnType HaveFullName(string fullName); TReturnType HaveFullNameMatching(string pattern); TReturnType HaveNameStartingWith(string pattern); @@ -208,62 +108,20 @@ TReturnType HaveAttributeWithNamedArguments( //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNot(Types().That().HaveFullName()) instead" - )] - TReturnType AreNot(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNot(Types().That().HaveFullName()) instead" - )] - TReturnType AreNot(IEnumerable patterns, bool useRegularExpressions = false); TReturnType AreNot(ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects); TReturnType AreNot(IEnumerable objects); TReturnType AreNot(IObjectProvider objects); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - TReturnType DoNotCallAny(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - TReturnType DoNotCallAny(IEnumerable patterns, bool useRegularExpressions = false); TReturnType DoNotCallAny(MethodMember method, params MethodMember[] moreMethods); TReturnType DoNotCallAny(IEnumerable methods); TReturnType DoNotCallAny(IObjectProvider methods); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotDependOnAny(Types().That().HaveFullName()) instead" - )] - TReturnType DoNotDependOnAny(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotDependOnAny(Types().That().HaveFullName()) instead" - )] - TReturnType DoNotDependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType DoNotDependOnAny(Type firstType, params Type[] moreTypes); TReturnType DoNotDependOnAny(IType firstType, params IType[] moreTypes); TReturnType DoNotDependOnAny(IObjectProvider types); TReturnType DoNotDependOnAny(IEnumerable types); TReturnType DoNotDependOnAny(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType DoNotHaveAnyAttributes(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - TReturnType DoNotHaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType DoNotHaveAnyAttributes( Attribute firstAttribute, params Attribute[] moreAttributes @@ -278,22 +136,6 @@ TReturnType DoNotHaveAnyAttributesWithArguments( params object[] moreArgumentValues ); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType DoNotHaveAttributeWithArguments( - string attribute, - IEnumerable argumentValues - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType DoNotHaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ); TReturnType DoNotHaveAttributeWithArguments( Attribute attribute, IEnumerable argumentValues @@ -320,22 +162,6 @@ TReturnType DoNotHaveAnyAttributesWithNamedArguments( params (string, object)[] moreAttributeArguments ); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType DoNotHaveAttributeWithNamedArguments( - string attribute, - IEnumerable<(string, object)> attributeArguments - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - TReturnType DoNotHaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ); TReturnType DoNotHaveAttributeWithNamedArguments( Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -355,17 +181,9 @@ TReturnType DoNotHaveAttributeWithNamedArguments( params (string, object)[] moreAttributeArguments ); - [Obsolete( - "Either DoNotHaveName() without the useRegularExpressions parameter or DoNotHaveNameMatching() should be used" - )] - TReturnType DoNotHaveName(string pattern, bool useRegularExpressions); TReturnType DoNotHaveName(string name); TReturnType DoNotHaveNameMatching(string pattern); - [Obsolete( - "Either DoNotHaveFullName() without the useRegularExpressions parameter or DoNotHaveFullNameMatching() should be used" - )] - TReturnType DoNotHaveFullName(string pattern, bool useRegularExpressions); TReturnType DoNotHaveFullName(string fullName); TReturnType DoNotHaveFullNameMatching(string pattern); TReturnType DoNotHaveNameStartingWith(string pattern); diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/GivenMembersThat.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/GivenMembersThat.cs index d3796a48e..e88287bd3 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/GivenMembersThat.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/GivenMembersThat.cs @@ -15,34 +15,6 @@ public class GivenMembersThat public GivenMembersThat(IArchRuleCreator ruleCreator) : base(ruleCreator) { } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction AreDeclaredIn( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MemberPredicatesDefinition.AreDeclaredIn(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction AreDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MemberPredicatesDefinition.AreDeclaredIn(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction AreDeclaredIn(IType firstType, params IType[] moreTypes) { _ruleCreator.AddPredicate( @@ -97,40 +69,6 @@ public TGivenRuleTypeConjunction AreImmutable() //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction AreNotDeclaredIn( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MemberPredicatesDefinition.AreNotDeclaredIn( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction AreNotDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MemberPredicatesDefinition.AreNotDeclaredIn( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction AreNotDeclaredIn(IType firstType, params IType[] moreTypes) { _ruleCreator.AddPredicate( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/IMemberConditions.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/IMemberConditions.cs index 7cfdb6216..370ec5df2 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/IMemberConditions.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/IMemberConditions.cs @@ -8,15 +8,6 @@ public interface IMemberConditions : IObjectConditions where TRuleType : ICanBeAnalyzed { - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeDeclaredIn(Types().That().HaveFullName()) instead" - )] - TReturnType BeDeclaredIn(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeDeclaredIn(Types().That().HaveFullName()) instead" - )] - TReturnType BeDeclaredIn(IEnumerable patterns, bool useRegularExpressions = false); TReturnType BeDeclaredIn(IType firstType, params IType[] moreTypes); TReturnType BeDeclaredIn(Type firstType, params Type[] moreTypes); TReturnType BeDeclaredIn(IObjectProvider types); @@ -26,18 +17,6 @@ public interface IMemberConditions TReturnType BeImmutable(); //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeDeclaredIn(Types().That().HaveFullName()) instead" - )] - TReturnType NotBeDeclaredIn(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeDeclaredIn(Types().That().HaveFullName()) instead" - )] - TReturnType NotBeDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType NotBeDeclaredIn(IType firstType, params IType[] moreTypes); TReturnType NotBeDeclaredIn(Type firstType, params Type[] moreTypes); TReturnType NotBeDeclaredIn(IObjectProvider types); diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/IMemberPredicates.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/IMemberPredicates.cs index 7eab31bcc..c98f5bb7d 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/IMemberPredicates.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/IMemberPredicates.cs @@ -8,18 +8,6 @@ public interface IMemberPredicates : IObjectPredicates where TRuleType : ICanBeAnalyzed { - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreDeclaredIn(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction AreDeclaredIn(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreDeclaredIn(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction AreDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ); TRuleTypeConjunction AreDeclaredIn(IType firstType, params IType[] moreTypes); TRuleTypeConjunction AreDeclaredIn(Type firstType, params Type[] moreTypes); TRuleTypeConjunction AreDeclaredIn(IObjectProvider types); @@ -30,18 +18,6 @@ TRuleTypeConjunction AreDeclaredIn( //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotDeclaredIn(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction AreNotDeclaredIn(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotDeclaredIn(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction AreNotDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ); TRuleTypeConjunction AreNotDeclaredIn(IType firstType, params IType[] moreTypes); TRuleTypeConjunction AreNotDeclaredIn(Type firstType, params Type[] moreTypes); TRuleTypeConjunction AreNotDeclaredIn(IObjectProvider types); diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MemberConditionsDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MemberConditionsDefinition.cs index 0a946c023..c27397554 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MemberConditionsDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MemberConditionsDefinition.cs @@ -11,70 +11,6 @@ namespace ArchUnitNET.Fluent.Syntax.Elements.Members public static class MemberConditionsDefinition where TRuleType : IMember { - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeDeclaredIn(Types().That().HaveFullName()) instead" - )] - public static ICondition BeDeclaredIn( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - member => member.IsDeclaredIn(pattern, useRegularExpressions), - member => "is declared in " + member.DeclaringType.FullName, - "be declared in types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeDeclaredIn(Types().That().HaveFullName()) instead" - )] - public static ICondition BeDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(TRuleType ruleType) - { - return patternList.Any(pattern => - ruleType.IsDeclaredIn(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "be declared in no type (always false)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(obj => !obj.Equals(firstPattern)) - .Distinct() - .Aggregate( - "be declared in types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition( - Condition, - member => "is declared in " + member.DeclaringType.FullName, - description - ); - } - public static ICondition BeDeclaredIn(IType firstType, params IType[] moreTypes) { var types = new List { firstType }; @@ -258,70 +194,6 @@ public static RelationCondition BeDeclaredInTypesThat() //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeDeclaredIn(Types().That().HaveFullName()) instead" - )] - public static ICondition NotBeDeclaredIn( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - member => !member.IsDeclaredIn(pattern, useRegularExpressions), - member => "is declared in " + member.DeclaringType.FullName, - "not be declared in types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeDeclaredIn(Types().That().HaveFullName()) instead" - )] - public static ICondition NotBeDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(TRuleType ruleType) - { - return patternList.All(pattern => - !ruleType.IsDeclaredIn(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "not be declared in no type (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(obj => !obj.Equals(firstPattern)) - .Distinct() - .Aggregate( - "not be declared in types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition( - Condition, - member => "is declared in " + member.DeclaringType.FullName, - description - ); - } - public static ICondition NotBeDeclaredIn( IType firstType, params IType[] moreTypes diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MemberPredicatesDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MemberPredicatesDefinition.cs index c703aa395..92ad451b3 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MemberPredicatesDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MemberPredicatesDefinition.cs @@ -11,65 +11,6 @@ namespace ArchUnitNET.Fluent.Syntax.Elements.Members public static class MemberPredicatesDefinition where T : IMember { - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreDeclaredIn(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreDeclaredIn( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - member => member.IsDeclaredIn(pattern, useRegularExpressions), - "are declared in types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreDeclaredIn(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(T ruleType) - { - return patternList.Any(pattern => - ruleType.IsDeclaredIn(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "are declared in no type (always false)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(obj => !obj.Equals(firstPattern)) - .Distinct() - .Aggregate( - "are declared in types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Condition, description); - } - public static IPredicate AreDeclaredIn(IType firstType, params IType[] moreTypes) { var types = new List { firstType }; @@ -195,65 +136,6 @@ public static IPredicate AreImmutable() //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotDeclaredIn(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreNotDeclaredIn( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - member => !member.IsDeclaredIn(pattern, useRegularExpressions), - "are not declared in types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotDeclaredIn(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreNotDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(T ruleType) - { - return patternList.All(pattern => - !ruleType.IsDeclaredIn(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "are not declared in no type (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(obj => !obj.Equals(firstPattern)) - .Distinct() - .Aggregate( - "are not declared in types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Condition, description); - } - public static IPredicate AreNotDeclaredIn(IType firstType, params IType[] moreTypes) { var types = new List { firstType }; diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MembersShould.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MembersShould.cs index 2b1061917..90c608ea6 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MembersShould.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MembersShould.cs @@ -16,34 +16,6 @@ public class MembersShould public MembersShould(IArchRuleCreator ruleCreator) : base(ruleCreator) { } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction BeDeclaredIn( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MemberConditionsDefinition.BeDeclaredIn(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction BeDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MemberConditionsDefinition.BeDeclaredIn(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction BeDeclaredIn(IType firstType, params IType[] moreTypes) { _ruleCreator.AddCondition( @@ -115,40 +87,6 @@ public ShouldRelateToTypesThat< //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotBeDeclaredIn( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MemberConditionsDefinition.NotBeDeclaredIn( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotBeDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MemberConditionsDefinition.NotBeDeclaredIn( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotBeDeclaredIn(IType firstType, params IType[] moreTypes) { _ruleCreator.AddCondition( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/GivenMethodMembersThat.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/GivenMethodMembersThat.cs index 9c1d19c74..fa588e565 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/GivenMethodMembersThat.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/GivenMethodMembersThat.cs @@ -23,34 +23,6 @@ public GivenMethodMembersConjunction AreVirtual() return new GivenMethodMembersConjunction(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreCalledBy(Types().That().HaveFullName()) instead" - )] - public GivenMethodMembersConjunction AreCalledBy( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.AreCalledBy(pattern, useRegularExpressions) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreCalledBy(Types().That().HaveFullName()) instead" - )] - public GivenMethodMembersConjunction AreCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.AreCalledBy(patterns, useRegularExpressions) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - public GivenMethodMembersConjunction AreCalledBy(IType firstType, params IType[] moreTypes) { _ruleCreator.AddPredicate( @@ -85,40 +57,6 @@ public GivenMethodMembersConjunction AreCalledBy(IEnumerable types) return new GivenMethodMembersConjunction(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public GivenMethodMembersConjunction HaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.HaveDependencyInMethodBodyTo( - pattern, - useRegularExpressions - ) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public GivenMethodMembersConjunction HaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.HaveDependencyInMethodBodyTo( - patterns, - useRegularExpressions - ) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - public GivenMethodMembersConjunction HaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -167,34 +105,6 @@ public GivenMethodMembersConjunction HaveDependencyInMethodBodyTo(IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.HaveReturnType(patterns, useRegularExpressions) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - public GivenMethodMembersConjunction HaveReturnType( IType firstType, params IType[] moreTypes @@ -246,34 +156,6 @@ public GivenMethodMembersConjunction AreNotVirtual() return new GivenMethodMembersConjunction(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotCalledBy(Types().That().HaveFullName()) instead" - )] - public GivenMethodMembersConjunction AreNotCalledBy( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.AreNotCalledBy(pattern, useRegularExpressions) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotCalledBy(Types().That().HaveFullName()) instead" - )] - public GivenMethodMembersConjunction AreNotCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.AreNotCalledBy(patterns, useRegularExpressions) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - public GivenMethodMembersConjunction AreNotCalledBy( IType firstType, params IType[] moreTypes @@ -311,40 +193,6 @@ public GivenMethodMembersConjunction AreNotCalledBy(IEnumerable types) return new GivenMethodMembersConjunction(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public GivenMethodMembersConjunction DoNotHaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.DoNotHaveDependencyInMethodBodyTo( - pattern, - useRegularExpressions - ) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public GivenMethodMembersConjunction DoNotHaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.DoNotHaveDependencyInMethodBodyTo( - patterns, - useRegularExpressions - ) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - public GivenMethodMembersConjunction DoNotHaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -400,37 +248,6 @@ IEnumerable types return new GivenMethodMembersConjunction(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveReturnType(Types().That().HaveFullName()) instead" - )] - public GivenMethodMembersConjunction DoNotHaveReturnType( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.DoNotHaveReturnType(pattern, useRegularExpressions) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveReturnType(Types().That().HaveFullName()) instead" - )] - public GivenMethodMembersConjunction DoNotHaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - MethodMemberPredicatesDefinition.DoNotHaveReturnType( - patterns, - useRegularExpressions - ) - ); - return new GivenMethodMembersConjunction(_ruleCreator); - } - public GivenMethodMembersConjunction DoNotHaveReturnType( IType firstType, params IType[] moreTypes diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IMethodMemberConditions.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IMethodMemberConditions.cs index bdd5be49f..c95b97342 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IMethodMemberConditions.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IMethodMemberConditions.cs @@ -11,54 +11,18 @@ public interface IMethodMemberConditions TReturnType BeConstructor(); TReturnType BeVirtual(); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeCalledBy(Types().That().HaveFullName()) instead" - )] - TReturnType BeCalledBy(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeCalledBy(Types().That().HaveFullName()) instead" - )] - TReturnType BeCalledBy(IEnumerable patterns, bool useRegularExpressions = false); TReturnType BeCalledBy(IType firstType, params IType[] moreTypes); TReturnType BeCalledBy(Type type, params Type[] moreTypes); TReturnType BeCalledBy(IObjectProvider types); TReturnType BeCalledBy(IEnumerable types); TReturnType BeCalledBy(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - TReturnType HaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - TReturnType HaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType HaveDependencyInMethodBodyTo(IType firstType, params IType[] moreTypes); TReturnType HaveDependencyInMethodBodyTo(Type type, params Type[] moreTypes); TReturnType HaveDependencyInMethodBodyTo(IObjectProvider types); TReturnType HaveDependencyInMethodBodyTo(IEnumerable types); TReturnType HaveDependencyInMethodBodyTo(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveReturnType(Types().That().HaveFullName()) instead" - )] - TReturnType HaveReturnType(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveReturnType(Types().That().HaveFullName()) instead" - )] - TReturnType HaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType HaveReturnType(IType firstType, params IType[] moreTypes); TReturnType HaveReturnType(IEnumerable types); TReturnType HaveReturnType(IObjectProvider types); @@ -70,54 +34,18 @@ TReturnType HaveReturnType( TReturnType BeNoConstructor(); TReturnType NotBeVirtual(); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeCalledBy(Types().That().HaveFullName()) instead" - )] - TReturnType NotBeCalledBy(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeCalledBy(Types().That().HaveFullName()) instead" - )] - TReturnType NotBeCalledBy(IEnumerable patterns, bool useRegularExpressions = false); TReturnType NotBeCalledBy(IType firstType, params IType[] moreTypes); TReturnType NotBeCalledBy(Type type, params Type[] moreTypes); TReturnType NotBeCalledBy(IObjectProvider types); TReturnType NotBeCalledBy(IEnumerable types); TReturnType NotBeCalledBy(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - TReturnType NotHaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - TReturnType NotHaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType NotHaveDependencyInMethodBodyTo(IType firstType, params IType[] moreTypes); TReturnType NotHaveDependencyInMethodBodyTo(Type type, params Type[] moreTypes); TReturnType NotHaveDependencyInMethodBodyTo(IObjectProvider types); TReturnType NotHaveDependencyInMethodBodyTo(IEnumerable types); TReturnType NotHaveDependencyInMethodBodyTo(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveReturnType(Types().That().HaveFullName()) instead" - )] - TReturnType NotHaveReturnType(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveReturnType(Types().That().HaveFullName()) instead" - )] - TReturnType NotHaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType NotHaveReturnType(IType firstType, params IType[] moreTypes); TReturnType NotHaveReturnType(IEnumerable types); TReturnType NotHaveReturnType(IObjectProvider types); diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IMethodMemberPredicates.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IMethodMemberPredicates.cs index d85532ca9..434fb7542 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IMethodMemberPredicates.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IMethodMemberPredicates.cs @@ -11,40 +11,12 @@ public interface IMethodMemberPredicates TRuleTypeConjunction AreConstructors(); TRuleTypeConjunction AreVirtual(); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreCalledBy(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction AreCalledBy(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreCalledBy(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction AreCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ); TRuleTypeConjunction AreCalledBy(IType firstType, params IType[] moreTypes); TRuleTypeConjunction AreCalledBy(Type type, params Type[] moreTypes); TRuleTypeConjunction AreCalledBy(IObjectProvider types); TRuleTypeConjunction AreCalledBy(IEnumerable types); TRuleTypeConjunction AreCalledBy(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction HaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction HaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ); - TRuleTypeConjunction HaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -54,18 +26,6 @@ params IType[] moreTypes TRuleTypeConjunction HaveDependencyInMethodBodyTo(IEnumerable types); TRuleTypeConjunction HaveDependencyInMethodBodyTo(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveReturnType(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction HaveReturnType(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveReturnType(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction HaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ); TRuleTypeConjunction HaveReturnType(IType firstType, params IType[] moreTypes); TRuleTypeConjunction HaveReturnType(IEnumerable types); TRuleTypeConjunction HaveReturnType(IObjectProvider types); @@ -77,40 +37,12 @@ TRuleTypeConjunction HaveReturnType( TRuleTypeConjunction AreNoConstructors(); TRuleTypeConjunction AreNotVirtual(); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotCalledBy(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction AreNotCalledBy(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotCalledBy(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction AreNotCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ); TRuleTypeConjunction AreNotCalledBy(IType firstType, params IType[] moreTypes); TRuleTypeConjunction AreNotCalledBy(Type type, params Type[] moreTypes); TRuleTypeConjunction AreNotCalledBy(IObjectProvider types); TRuleTypeConjunction AreNotCalledBy(IEnumerable types); TRuleTypeConjunction AreNotCalledBy(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction DoNotHaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction DoNotHaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ); - TRuleTypeConjunction DoNotHaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -120,21 +52,6 @@ params IType[] moreTypes TRuleTypeConjunction DoNotHaveDependencyInMethodBodyTo(IEnumerable types); TRuleTypeConjunction DoNotHaveDependencyInMethodBodyTo(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveReturnType(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction DoNotHaveReturnType( - string pattern, - bool useRegularExpressions = false - ); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveReturnType(Types().That().HaveFullName()) instead" - )] - TRuleTypeConjunction DoNotHaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ); TRuleTypeConjunction DoNotHaveReturnType(IType firstType, params IType[] moreTypes); TRuleTypeConjunction DoNotHaveReturnType(IEnumerable types); TRuleTypeConjunction DoNotHaveReturnType(IObjectProvider types); diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberConditionsDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberConditionsDefinition.cs index 4b419aae0..096b92a7a 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberConditionsDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberConditionsDefinition.cs @@ -37,83 +37,6 @@ public static ICondition BeVirtual() ); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeCalledBy(Types().That().HaveFullName()) instead" - )] - public static ICondition BeCalledBy( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - member => member.IsCalledBy(pattern, useRegularExpressions), - "be called by types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"", - "is called by a type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeCalledBy(Types().That().HaveFullName()) instead" - )] - public static ICondition BeCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(MethodMember ruleType) - { - return patternList.Any(pattern => - ruleType.IsCalledBy(pattern, useRegularExpressions) - ); - } - - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = "be called by one of no types (always false)"; - failDescription = "is not called by one of no types (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "be called by types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - failDescription = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "is not called by types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static ICondition BeCalledBy(IType firstType, params IType[] moreTypes) { var types = new List { firstType }; @@ -288,84 +211,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public static ICondition HaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - member => member.HasDependencyInMethodBodyTo(pattern, useRegularExpressions), - "have dependencies in method body to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"", - "does not have dependencies in method body to a type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public static ICondition HaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(MethodMember ruleType) - { - return patternList.Any(pattern => - ruleType.HasDependencyInMethodBodyTo(pattern, useRegularExpressions) - ); - } - - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = "have dependency in method body to one of no types (always false)"; - failDescription = - "does not have dependencies in method body to one of no types (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "have dependencies in method body to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - failDescription = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "does not have dependencies in method body to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static ICondition HaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -573,68 +418,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveReturnType(Types().That().HaveFullName()) instead" - )] - public static ICondition HaveReturnType( - string pattern, - bool useRegularExpressions = false - ) - { - var description = - "have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\""; - - var failDescription = - "does not have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\""; - - return new SimpleCondition( - member => member.ReturnType.FullNameMatches(pattern, useRegularExpressions), - description, - failDescription - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveReturnType(Types().That().HaveFullName()) instead" - )] - public static ICondition HaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternsArray = patterns.ToArray(); - var description = - "have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + string.Join("\" or \"", patternsArray) - + "\""; - - var failDescription = - "does not have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + string.Join("\" or \"", patternsArray) - + "\""; - - bool Condition(MethodMember member) - { - return patternsArray.Any(pattern => - member.ReturnType.FullNameMatches(pattern, useRegularExpressions) - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static ICondition HaveReturnType( IType firstType, params IType[] moreTypes @@ -746,99 +529,6 @@ public static ICondition NotBeVirtual() ); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeCalledBy(Types().That().HaveFullName()) instead" - )] - public static ICondition NotBeCalledBy( - string pattern, - bool useRegularExpressions = false - ) - { - ConditionResult Condition(MethodMember member) - { - var pass = true; - var description = "is called by"; - foreach ( - var type in member - .GetMethodCallDependencies(true) - .Select(dependency => dependency.Origin) - .Distinct() - ) - { - if (type.FullNameMatches(pattern, useRegularExpressions)) - { - description += (pass ? " " : " and ") + type.FullName; - pass = false; - } - } - - return new ConditionResult(member, pass, description); - } - - return new SimpleCondition( - Condition, - "not be called by types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeCalledBy(Types().That().HaveFullName()) instead" - )] - public static ICondition NotBeCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(MethodMember ruleType) - { - return !patternList.Any(pattern => - ruleType.IsCalledBy(pattern, useRegularExpressions) - ); - } - - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = "not be called by one of no types (always true)"; - failDescription = "is called by one of no types (always false)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "not be called by types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - failDescription = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "is called by types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static ICondition NotBeCalledBy( IType firstType, params IType[] moreTypes @@ -1019,101 +709,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public static ICondition NotHaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ) - { - ConditionResult Condition(MethodMember member) - { - var pass = true; - var description = "does have dependencies in method body to"; - foreach ( - var type in member - .GetBodyTypeMemberDependencies() - .Select(dependency => dependency.Target) - .Distinct() - ) - { - if (type.FullNameMatches(pattern, useRegularExpressions)) - { - description += (pass ? " " : " and ") + type.FullName; - pass = false; - } - } - - return new ConditionResult(member, pass, description); - } - - return new SimpleCondition( - Condition, - "not have dependencies in method body to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public static ICondition NotHaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(MethodMember ruleType) - { - return !patternList.Any(pattern => - ruleType.HasDependencyInMethodBodyTo(pattern, useRegularExpressions) - ); - } - - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = - "not have dependencies in method body to one of no types (always true)"; - failDescription = - "does have dependencies in method body to one of no types (always false)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "not have dependencies in method body to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - failDescription = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "does have dependencies in method body to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static ICondition NotHaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -1326,68 +921,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveReturnType(Types().That().HaveFullName()) instead" - )] - public static ICondition NotHaveReturnType( - string pattern, - bool useRegularExpressions = false - ) - { - var description = - "not have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\""; - - var failDescription = - "does have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\""; - - return new SimpleCondition( - member => !member.ReturnType.FullNameMatches(pattern, useRegularExpressions), - description, - failDescription - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveReturnType(Types().That().HaveFullName()) instead" - )] - public static ICondition NotHaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternsArray = patterns.ToArray(); - var description = - "not have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + string.Join("\" or \"", patternsArray) - + "\""; - - var failDescription = - "does have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + string.Join("\" or \"", patternsArray) - + "\""; - - bool Condition(MethodMember member) - { - return patternsArray.All(pattern => - !member.ReturnType.FullNameMatches(pattern, useRegularExpressions) - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static ICondition NotHaveReturnType( IType firstType, params IType[] moreTypes diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberPredicatesDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberPredicatesDefinition.cs index 1c1a8ed31..1e576f656 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberPredicatesDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberPredicatesDefinition.cs @@ -23,65 +23,6 @@ public static IPredicate AreVirtual() return new SimplePredicate(member => member.IsVirtual, "are virtual"); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreCalledBy(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreCalledBy( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - member => member.IsCalledBy(pattern, useRegularExpressions), - "are called by types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreCalledBy(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(MethodMember ruleType) - { - return patternList.Any(pattern => - ruleType.IsCalledBy(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "are called by one of no types (always false)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "are called by types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Condition, description); - } - public static IPredicate AreCalledBy( IType firstType, params IType[] moreTypes @@ -190,65 +131,6 @@ Architecture architecture return new ArchitecturePredicate(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public static IPredicate HaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - member => member.HasDependencyInMethodBodyTo(pattern, useRegularExpressions), - "have dependencies in method body to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public static IPredicate HaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(MethodMember ruleType) - { - return patternList.Any(pattern => - ruleType.HasDependencyInMethodBodyTo(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "have dependencies in method body to one of no types (always false)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "have dependencies in method body to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Condition, description); - } - public static IPredicate HaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -377,49 +259,6 @@ Architecture architecture return new ArchitecturePredicate(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveReturnType(Types().That().HaveFullName()) instead" - )] - public static IPredicate HaveReturnType( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - member => member.ReturnType.FullNameMatches(pattern, useRegularExpressions), - "have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveReturnType(Types().That().HaveFullName()) instead" - )] - public static IPredicate HaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternsArray = patterns.ToArray(); - var description = - "have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + string.Join("\" or \"", patternsArray) - + "\""; - - return new SimplePredicate( - member => - patternsArray.Any(pattern => - member.ReturnType.FullNameMatches(pattern, useRegularExpressions) - ), - description - ); - } - public static IPredicate HaveReturnType( IType firstType, params IType[] moreTypes @@ -502,65 +341,6 @@ public static IPredicate AreNotVirtual() ); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotCalledBy(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreNotCalledBy( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - member => !member.IsCalledBy(pattern, useRegularExpressions), - "are not called by types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotCalledBy(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreNotCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(MethodMember ruleType) - { - return !patternList.Any(pattern => - ruleType.IsCalledBy(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "are not called by one of no types (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "are not called by types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Condition, description); - } - public static IPredicate AreNotCalledBy( IType firstType, params IType[] moreTypes @@ -672,66 +452,6 @@ Architecture architecture return new ArchitecturePredicate(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public static IPredicate DoNotHaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - member => !member.HasDependencyInMethodBodyTo(pattern, useRegularExpressions), - "do not have dependencies in method body to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public static IPredicate DoNotHaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(MethodMember ruleType) - { - return !patternList.Any(pattern => - ruleType.HasDependencyInMethodBodyTo(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = - "do not have dependencies in method body to one of no types (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "do not have dependencies in method body to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Condition, description); - } - public static IPredicate DoNotHaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -865,49 +585,6 @@ Architecture architecture return new ArchitecturePredicate(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveReturnType(Types().That().HaveFullName()) instead" - )] - public static IPredicate DoNotHaveReturnType( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - member => !member.ReturnType.FullNameMatches(pattern, useRegularExpressions), - "do not have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveReturnType(Types().That().HaveFullName()) instead" - )] - public static IPredicate DoNotHaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternsArray = patterns.ToArray(); - var description = - "do not have return type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + string.Join("\" or \"", patternsArray) - + "\""; - - return new SimplePredicate( - member => - patternsArray.All(pattern => - !member.ReturnType.FullNameMatches(pattern, useRegularExpressions) - ), - description - ); - } - public static IPredicate DoNotHaveReturnType( IType firstType, params IType[] moreTypes diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMembersShould.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMembersShould.cs index 9444e7087..30e0b3ef0 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMembersShould.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMembersShould.cs @@ -38,34 +38,6 @@ public MethodMembersShouldConjunction BeVirtual() return new MethodMembersShouldConjunction(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeCalledBy(Types().That().HaveFullName()) instead" - )] - public MethodMembersShouldConjunction BeCalledBy( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.BeCalledBy(pattern, useRegularExpressions) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeCalledBy(Types().That().HaveFullName()) instead" - )] - public MethodMembersShouldConjunction BeCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.BeCalledBy(patterns, useRegularExpressions) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - public MethodMembersShouldConjunction BeCalledBy(IType firstType, params IType[] moreTypes) { _ruleCreator.AddCondition( @@ -98,40 +70,6 @@ public MethodMembersShouldConjunction BeCalledBy(IEnumerable types) return new MethodMembersShouldConjunction(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public MethodMembersShouldConjunction HaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.HaveDependencyInMethodBodyTo( - pattern, - useRegularExpressions - ) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public MethodMembersShouldConjunction HaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.HaveDependencyInMethodBodyTo( - patterns, - useRegularExpressions - ) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - public MethodMembersShouldConjunction HaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -180,34 +118,6 @@ public MethodMembersShouldConjunction HaveDependencyInMethodBodyTo(IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.HaveReturnType(patterns, useRegularExpressions) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - public MethodMembersShouldConjunction HaveReturnType( IType firstType, params IType[] moreTypes @@ -259,34 +169,6 @@ public MethodMembersShouldConjunction NotBeVirtual() return new MethodMembersShouldConjunction(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeCalledBy(Types().That().HaveFullName()) instead" - )] - public MethodMembersShouldConjunction NotBeCalledBy( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.NotBeCalledBy(pattern, useRegularExpressions) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeCalledBy(Types().That().HaveFullName()) instead" - )] - public MethodMembersShouldConjunction NotBeCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.NotBeCalledBy(patterns, useRegularExpressions) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - public MethodMembersShouldConjunction NotBeCalledBy( IType firstType, params IType[] moreTypes @@ -324,40 +206,6 @@ public MethodMembersShouldConjunction NotBeCalledBy(IEnumerable types) return new MethodMembersShouldConjunction(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public MethodMembersShouldConjunction NotHaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.NotHaveDependencyInMethodBodyTo( - pattern, - useRegularExpressions - ) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public MethodMembersShouldConjunction NotHaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.NotHaveDependencyInMethodBodyTo( - patterns, - useRegularExpressions - ) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - public MethodMembersShouldConjunction NotHaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -413,34 +261,6 @@ IEnumerable types return new MethodMembersShouldConjunction(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveReturnType(Types().That().HaveFullName()) instead" - )] - public MethodMembersShouldConjunction NotHaveReturnType( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.NotHaveReturnType(pattern, useRegularExpressions) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveReturnType(Types().That().HaveFullName()) instead" - )] - public MethodMembersShouldConjunction NotHaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - MethodMemberConditionsDefinition.NotHaveReturnType(patterns, useRegularExpressions) - ); - return new MethodMembersShouldConjunction(_ruleCreator); - } - public MethodMembersShouldConjunction NotHaveReturnType( IType firstType, params IType[] moreTypes diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/ShouldRelateToMethodMembersThat.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/ShouldRelateToMethodMembersThat.cs index 4c8bbd00e..bf64ee5a7 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/ShouldRelateToMethodMembersThat.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/ShouldRelateToMethodMembersThat.cs @@ -28,34 +28,6 @@ public TRuleTypeShouldConjunction AreVirtual() return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreCalledBy(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreCalledBy( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.AreCalledBy(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreCalledBy(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.AreCalledBy(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction AreCalledBy(IType firstType, params IType[] moreTypes) { _ruleCreator.ContinueComplexCondition( @@ -96,40 +68,6 @@ public TRuleTypeShouldConjunction AreCalledBy(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction HaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.HaveDependencyInMethodBodyTo( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction HaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.HaveDependencyInMethodBodyTo( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -176,34 +114,6 @@ public TRuleTypeShouldConjunction HaveDependencyInMethodBodyTo(IEnumerable return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveReturnType(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction HaveReturnType( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.HaveReturnType(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveReturnType(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction HaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.HaveReturnType(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveReturnType(IType firstType, params IType[] moreTypes) { _ruleCreator.ContinueComplexCondition( @@ -260,34 +170,6 @@ public TRuleTypeShouldConjunction AreNotVirtual() return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotCalledBy(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreNotCalledBy( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.AreNotCalledBy(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotCalledBy(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreNotCalledBy( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.AreNotCalledBy(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction AreNotCalledBy(IType firstType, params IType[] moreTypes) { _ruleCreator.ContinueComplexCondition( @@ -328,40 +210,6 @@ public TRuleTypeShouldConjunction AreNotCalledBy(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DoNotHaveDependencyInMethodBodyTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.DoNotHaveDependencyInMethodBodyTo( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveDependencyInMethodBodyTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DoNotHaveDependencyInMethodBodyTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.DoNotHaveDependencyInMethodBodyTo( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotHaveDependencyInMethodBodyTo( IType firstType, params IType[] moreTypes @@ -415,37 +263,6 @@ public TRuleTypeShouldConjunction DoNotHaveDependencyInMethodBodyTo(IEnumerable< return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveReturnType(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DoNotHaveReturnType( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.DoNotHaveReturnType(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveReturnType(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DoNotHaveReturnType( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MethodMemberPredicatesDefinition.DoNotHaveReturnType( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotHaveReturnType( IType firstType, params IType[] moreTypes diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/ShouldRelateToMembersThat.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/ShouldRelateToMembersThat.cs index ab3673602..0d9e82fe5 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/ShouldRelateToMembersThat.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/ShouldRelateToMembersThat.cs @@ -15,40 +15,6 @@ public class ShouldRelateToMembersThat ruleCreator) : base(ruleCreator) { } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreDeclaredIn( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MemberPredicatesDefinition.AreDeclaredIn( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MemberPredicatesDefinition.AreDeclaredIn( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction AreDeclaredIn(IType firstType, params IType[] moreTypes) { _ruleCreator.ContinueComplexCondition( @@ -115,40 +81,6 @@ public TRuleTypeShouldConjunction AreImmutable() //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreNotDeclaredIn( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MemberPredicatesDefinition.AreNotDeclaredIn( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotDeclaredIn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreNotDeclaredIn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - MemberPredicatesDefinition.AreNotDeclaredIn( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction AreNotDeclaredIn( IType firstType, params IType[] moreTypes diff --git a/ArchUnitNET/Fluent/Syntax/Elements/ObjectConditionsDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/ObjectConditionsDefinition.cs index 3ee509962..99f8bf2e6 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/ObjectConditionsDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/ObjectConditionsDefinition.cs @@ -19,77 +19,6 @@ public static ICondition Exist() return new ExistsCondition(true); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Be(Types().That().HaveFullName()) instead" - )] - public static ICondition Be(string pattern, bool useRegularExpressions = false) - { - return new SimpleCondition( - obj => obj.FullNameMatches(pattern, useRegularExpressions), - "have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"", - "does not have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Be(Types().That().HaveFullName()) instead" - )] - public static ICondition Be( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = "not exist"; - failDescription = "does exist"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - failDescription = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "does not have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition( - obj => - patternList.Any(pattern => obj.FullNameMatches(pattern, useRegularExpressions)), - description, - failDescription - ); - } - public static ICondition Be(IObjectProvider objectProvider) { var sizedObjectProvider = objectProvider as ISizedObjectProvider; @@ -126,83 +55,6 @@ Architecture architecture ); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - public static ICondition CallAny( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - obj => obj.CallsMethod(pattern, useRegularExpressions), - "calls any method with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"", - "does not call any method with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - public static ICondition CallAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(TRuleType ruleType) - { - return patternList.Any(pattern => - ruleType.CallsMethod(pattern, useRegularExpressions) - ); - } - - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = "call one of no methods (impossible)"; - failDescription = "does not call one of no methods (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "calls any method with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - failDescription = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "does not call any methods with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static ICondition CallAny(IObjectProvider objectProvider) { IEnumerable Condition( @@ -242,87 +94,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - public static ICondition DependOnAny( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - obj => obj.DependsOn(pattern, useRegularExpressions), - "depend on any types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"", - "does not depend on any type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - public static ICondition DependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - bool Condition(TRuleType ruleType, Architecture architecture) - { - return !ruleType.GetTypeDependencies(architecture).IsNullOrEmpty() - && ruleType - .GetTypeDependencies(architecture) - .Any(target => - patternList.Any(pattern => - target.FullNameMatches(pattern, useRegularExpressions) - ) - ); - } - - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = "depend on one of no types (impossible)"; - failDescription = "does not depend on no types (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "depend on any types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - failDescription = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "does not depend any types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new ArchitectureCondition(Condition, description, failDescription); - } - public static ICondition DependOnAny(IObjectProvider objectProvider) { IEnumerable Condition( @@ -380,98 +151,6 @@ string failDescription return new SimpleCondition(condition, description, failDescription); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - public static ICondition OnlyDependOn( - string pattern, - bool useRegularExpressions = false - ) - { - ConditionResult Condition(TRuleType ruleType) - { - var pass = true; - var dynamicFailDescription = "does depend on"; - foreach (var dependency in ruleType.GetTypeDependencies()) - { - if (!dependency.FullNameMatches(pattern, useRegularExpressions)) - { - dynamicFailDescription += pass - ? " " + dependency.FullName - : " and " + dependency.FullName; - pass = false; - } - } - - return new ConditionResult(ruleType, pass, dynamicFailDescription); - } - - return new SimpleCondition( - Condition, - "only depend on types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - public static ICondition OnlyDependOn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - ConditionResult Condition(TRuleType ruleType) - { - var pass = true; - var dynamicFailDescription = "does depend on"; - foreach (var dependency in ruleType.GetTypeDependencies()) - { - if ( - !patternList.Any(pattern => - dependency.FullNameMatches(pattern, useRegularExpressions) - ) - ) - { - dynamicFailDescription += pass - ? " " + dependency.FullName - : " and " + dependency.FullName; - pass = false; - } - } - - return new ConditionResult(ruleType, pass, dynamicFailDescription); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "have no dependencies"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "only depend on types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description); - } - public static ICondition OnlyDependOn(IObjectProvider objectProvider) { IEnumerable Condition( @@ -512,85 +191,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public static ICondition HaveAnyAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - obj => obj.HasAttribute(pattern, useRegularExpressions), - "have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"", - "does not have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public static ICondition HaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(TRuleType ruleType) - { - return ruleType.Attributes.Any(attribute => - patternList.Any(pattern => - attribute.FullNameMatches(pattern, useRegularExpressions) - ) - ); - } - - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = "have one of no attributes (impossible)"; - failDescription = "does not have one of no attributes (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - failDescription = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "does not have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static ICondition HaveAnyAttributes( IObjectProvider objectProvider ) @@ -630,86 +230,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - public static ICondition OnlyHaveAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - obj => obj.OnlyHasAttributes(pattern, useRegularExpressions), - "only have attributes with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"", - "does not only have attributes with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - public static ICondition OnlyHaveAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(TRuleType ruleType) - { - return ruleType.Attributes.IsNullOrEmpty() - || ruleType.Attributes.All(attribute => - patternList.Any(pattern => - attribute.FullNameMatches(pattern, useRegularExpressions) - ) - ); - } - - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = "have no attributes"; - failDescription = "does have attributes"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "only have attributes with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " and \"" + pattern + "\"" - ); - failDescription = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "does not only have attributes with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static ICondition OnlyHaveAttributes( IObjectProvider objectProvider ) @@ -762,20 +282,6 @@ params object[] moreArgumentValues return HaveAnyAttributesWithArguments(argumentValues); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition HaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ) - { - var argumentValues = new List { firstArgumentValue }; - argumentValues.AddRange(moreArgumentValues); - return HaveAttributeWithArguments(attribute, argumentValues); - } - public static ICondition HaveAttributeWithArguments( Attribute attribute, object firstArgumentValue, @@ -808,20 +314,6 @@ public static ICondition HaveAnyAttributesWithNamedArguments( return HaveAnyAttributesWithNamedArguments(attributeArguments); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition HaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ) - { - var attributeArguments = new List<(string, object)> { firstAttributeArgument }; - attributeArguments.AddRange(moreAttributeArguments); - return HaveAttributeWithNamedArguments(attribute, attributeArguments); - } - public static ICondition HaveAttributeWithNamedArguments( Attribute attribute, (string, object) firstAttributeArgument, @@ -922,90 +414,6 @@ bool Condition(TRuleType obj, Architecture architecture) return new ArchitectureCondition(Condition, failDescription, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition HaveAttributeWithArguments( - [NotNull] string attribute, - IEnumerable argumentValues - ) - { - string description, - failDescription; - var argumentValueList = argumentValues?.ToList() ?? new List { null }; - if (argumentValueList.IsNullOrEmpty()) - { - description = "have attribute \"" + attribute + "\""; - failDescription = "does not have attribute \"" + attribute + "\""; - } - else - { - var firstArgument = argumentValueList.First(); - description = argumentValueList - .Where(att => att != firstArgument) - .Aggregate( - "have attribute \"" - + attribute - + "\" with arguments \"" - + firstArgument - + "\"", - (current, argumentValue) => current + " and \"" + argumentValue + "\"" - ); - failDescription = argumentValueList - .Where(att => att != firstArgument) - .Aggregate( - "does not have attribute \"" - + attribute - + "\" with arguments \"" - + firstArgument - + "\"", - (current, argumentValue) => current + " and \"" + argumentValue + "\"" - ); - } - - bool Condition(TRuleType obj, Architecture architecture) - { - foreach (var attributeInstance in obj.AttributeInstances) - { - if (!attributeInstance.Type.FullNameMatches(attribute)) - { - goto NextAttribute; - } - - var attributeArguments = attributeInstance - .AttributeArguments.Select(arg => arg.Value) - .ToList(); - var typeAttributeArguments = attributeArguments - .OfType>() - .Select(t => t.Type) - .Union(attributeArguments.OfType()) - .ToList(); - foreach (var arg in argumentValueList) - { - if (arg is Type argType) - { - if (typeAttributeArguments.All(t => t.FullName != argType.FullName)) - { - goto NextAttribute; - } - } - else if (!attributeArguments.Contains(arg)) - { - goto NextAttribute; - } - } - - return true; - NextAttribute: - ; - } - - return false; - } - - return new ArchitectureCondition(Condition, description, failDescription); - } - public static ICondition HaveAttributeWithArguments( [NotNull] Attribute attribute, IEnumerable argumentValues @@ -1270,100 +678,6 @@ bool Condition(TRuleType obj, Architecture architecture) return new ArchitectureCondition(Condition, failDescription, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition HaveAttributeWithNamedArguments( - [NotNull] string attribute, - IEnumerable<(string, object)> attributeArguments - ) - { - string description, - failDescription; - var argumentList = attributeArguments.ToList(); - if (argumentList.IsNullOrEmpty()) - { - description = "have attribute \"" + attribute + "\""; - failDescription = "does not have attribute \"" + attribute + "\""; - } - else - { - var firstArgument = argumentList.First(); - description = argumentList - .Where(att => att != firstArgument) - .Aggregate( - "have attribute \"" - + attribute - + "\" with named arguments \"" - + firstArgument.Item1 - + "=" - + firstArgument.Item2 - + "\"", - (current, arg) => current + " and \"" + arg.Item1 + "=" + arg.Item2 + "\"" - ); - failDescription = argumentList - .Where(att => att != firstArgument) - .Aggregate( - "does not have attribute \"" - + attribute - + "\" with named arguments \"" - + firstArgument.Item1 - + "=" - + firstArgument.Item2 - + "\"", - (current, arg) => current + " and \"" + arg.Item1 + "=" + arg.Item2 + "\"" - ); - } - - bool Condition(TRuleType obj, Architecture architecture) - { - foreach (var attributeInstance in obj.AttributeInstances) - { - if (!attributeInstance.Type.FullNameMatches(attribute)) - { - goto NextAttribute; - } - - var attributeArgs = attributeInstance - .AttributeArguments.OfType() - .Select(arg => (arg.Name, arg.Value)) - .ToList(); - var typeAttributeArguments = attributeArgs - .Where(arg => arg.Value is ITypeInstance || arg.Value is IType) - .ToList(); - foreach (var arg in argumentList) - { - if (arg.Item2 is Type argType) - { - if ( - typeAttributeArguments.All(t => - t.Name != arg.Item1 - || t.Value is ITypeInstance typeInstance - && typeInstance.Type.FullName != argType.FullName - || t.Value is IType type && type.FullName != argType.FullName - ) - ) - { - goto NextAttribute; - } - } - else if (!attributeArgs.Contains(arg)) - { - goto NextAttribute; - } - } - - return true; - NextAttribute: - ; - } - - return false; - } - - return new ArchitectureCondition(Condition, description, failDescription); - } - public static ICondition HaveAttributeWithNamedArguments( [NotNull] Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -1557,22 +871,6 @@ bool Condition(TRuleType obj, Architecture architecture) return new ArchitectureCondition(Condition, description, failDescription); } - [Obsolete( - "Either HaveName() without the useRegularExpressions parameter or HaveNameMatching() should be used" - )] - public static ICondition HaveName(string pattern, bool useRegularExpressions) - { - return new SimpleCondition( - obj => obj.NameMatches(pattern, useRegularExpressions), - obj => "does have name " + obj.Name, - "have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static ICondition HaveName(string name) { return new SimpleCondition( @@ -1591,22 +889,6 @@ public static ICondition HaveNameMatching(string pattern) ); } - [Obsolete( - "Either HaveFullName() without the useRegularExpressions parameter or HaveFullNameMatching() should be used" - )] - public static ICondition HaveFullName(string pattern, bool useRegularExpressions) - { - return new SimpleCondition( - obj => obj.FullNameMatches(pattern, useRegularExpressions), - obj => "does have full name " + obj.FullName, - "have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static ICondition HaveFullName(string name) { return new SimpleCondition( @@ -1760,65 +1042,6 @@ public static ICondition NotExist() return new ExistsCondition(false); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBe(Types().That().HaveFullName()) instead" - )] - public static ICondition NotBe( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - obj => !obj.FullNameMatches(pattern, useRegularExpressions), - obj => "is " + obj.FullName, - "not have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBe(Types().That().HaveFullName()) instead" - )] - public static ICondition NotBe( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - string description; - if (patternList.IsNullOrEmpty()) - { - description = "exist"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "not have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition( - obj => - patternList.All(pattern => - !obj.FullNameMatches(pattern, useRegularExpressions) - ), - obj => "is " + obj.FullName, - description - ); - } - public static ICondition NotBe(IObjectProvider objectProvider) { IEnumerable Condition( @@ -1852,98 +1075,6 @@ Architecture architecture ); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - public static ICondition NotCallAny( - string pattern, - bool useRegularExpressions = false - ) - { - ConditionResult Condition(TRuleType ruleType) - { - var pass = true; - var dynamicFailDescription = "does call"; - foreach (var dependency in ruleType.GetCalledMethods()) - { - if (dependency.FullNameMatches(pattern, useRegularExpressions)) - { - dynamicFailDescription += pass - ? " " + dependency.FullName - : " and " + dependency.FullName; - pass = false; - } - } - - return new ConditionResult(ruleType, pass, dynamicFailDescription); - } - - return new SimpleCondition( - Condition, - "not call any method with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - public static ICondition NotCallAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - ConditionResult Condition(TRuleType ruleType) - { - var pass = true; - var dynamicFailDescription = "does call"; - foreach (var dependency in ruleType.GetCalledMethods()) - { - if ( - patternList.Any(pattern => - dependency.FullNameMatches(pattern, useRegularExpressions) - ) - ) - { - dynamicFailDescription += pass - ? " " + dependency.FullName - : " and " + dependency.FullName; - pass = false; - } - } - - return new ConditionResult(ruleType, pass, dynamicFailDescription); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "not call no methods (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "not call methods with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description); - } - public static ICondition NotCallAny(IObjectProvider objectProvider) { IEnumerable Condition( @@ -1954,126 +1085,34 @@ Architecture architecture var methodList = objectProvider.GetObjects(architecture).ToList(); var typeList = ruleTypes.ToList(); var failedObjects = typeList - .Where(type => type.GetCalledMethods().Intersect(methodList).Any()) - .ToList(); - foreach (var failedObject in failedObjects) - { - var dynamicFailDescription = "does call"; - var first = true; - foreach (var method in failedObject.GetCalledMethods().Intersect(methodList)) - { - dynamicFailDescription += first - ? " " + method.FullName - : " and " + method.FullName; - first = false; - } - - yield return new ConditionResult(failedObject, false, dynamicFailDescription); - } - - foreach (var passedObject in typeList.Except(failedObjects)) - { - yield return new ConditionResult(passedObject, true); - } - } - - var description = - (objectProvider as ISizedObjectProvider)?.Count == 0 - ? "not call any of no methods (always true)" - : "not call any " + objectProvider.Description; - return new ArchitectureCondition(Condition, description); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotDependOnAny(Types().That().HaveFullName()) instead" - )] - public static ICondition NotDependOnAny( - string pattern, - bool useRegularExpressions = false - ) - { - ConditionResult Condition(TRuleType ruleType) - { - var pass = true; - var dynamicFailDescription = "does depend on"; - foreach (var dependency in ruleType.GetTypeDependencies()) - { - if (dependency.FullNameMatches(pattern, useRegularExpressions)) - { - dynamicFailDescription += pass - ? " " + dependency.FullName - : " and " + dependency.FullName; - pass = false; - } - } - - return new ConditionResult(ruleType, pass, dynamicFailDescription); - } - - return new SimpleCondition( - Condition, - "not depend on any types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotDependOnAny(Types().That().HaveFullName()) instead" - )] - public static ICondition NotDependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - ConditionResult Condition(TRuleType ruleType) - { - var pass = true; - var dynamicFailDescription = "does depend on"; - foreach (var dependency in ruleType.GetTypeDependencies()) + .Where(type => type.GetCalledMethods().Intersect(methodList).Any()) + .ToList(); + foreach (var failedObject in failedObjects) { - if ( - patternList.Any(pattern => - dependency.FullNameMatches(pattern, useRegularExpressions) - ) - ) + var dynamicFailDescription = "does call"; + var first = true; + foreach (var method in failedObject.GetCalledMethods().Intersect(methodList)) { - dynamicFailDescription += pass - ? " " + dependency.FullName - : " and " + dependency.FullName; - pass = false; + dynamicFailDescription += first + ? " " + method.FullName + : " and " + method.FullName; + first = false; } - } - return new ConditionResult(ruleType, pass, dynamicFailDescription); - } + yield return new ConditionResult(failedObject, false, dynamicFailDescription); + } - string description; - if (patternList.IsNullOrEmpty()) - { - description = "not depend on no types (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "not depend on types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); + foreach (var passedObject in typeList.Except(failedObjects)) + { + yield return new ConditionResult(passedObject, true); + } } - return new SimpleCondition(Condition, description); + var description = + (objectProvider as ISizedObjectProvider)?.Count == 0 + ? "not call any of no methods (always true)" + : "not call any " + objectProvider.Description; + return new ArchitectureCondition(Condition, description); } public static ICondition NotDependOnAny(IObjectProvider objectProvider) @@ -2116,85 +1155,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition NotHaveAnyAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - obj => !obj.HasAttribute(pattern, useRegularExpressions), - "not have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"", - "does have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition NotHaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(TRuleType ruleType) - { - return !ruleType.Attributes.Any(attribute => - patternList.Any(pattern => - attribute.FullNameMatches(pattern, useRegularExpressions) - ) - ); - } - - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = "not have one of no attributes (always true)"; - failDescription = "does have one of no attributes (impossible)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "not have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - failDescription = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "does have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static ICondition NotHaveAnyAttributes( IObjectProvider objectProvider ) @@ -2247,20 +1207,6 @@ params object[] moreArgumentValues return NotHaveAnyAttributesWithArguments(argumentValues); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition NotHaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ) - { - var argumentValues = new List { firstArgumentValue }; - argumentValues.AddRange(moreArgumentValues); - return NotHaveAttributeWithArguments(attribute, argumentValues); - } - public static ICondition NotHaveAttributeWithArguments( Attribute attribute, object firstArgumentValue, @@ -2293,20 +1239,6 @@ public static ICondition NotHaveAnyAttributesWithNamedArguments( return NotHaveAnyAttributesWithNamedArguments(attributeArguments); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition NotHaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ) - { - var attributeArguments = new List<(string, object)> { firstAttributeArgument }; - attributeArguments.AddRange(moreAttributeArguments); - return NotHaveAttributeWithNamedArguments(attribute, attributeArguments); - } - public static ICondition NotHaveAttributeWithNamedArguments( Attribute attribute, (string, object) firstAttributeArgument, @@ -2407,90 +1339,6 @@ bool Condition(TRuleType obj, Architecture architecture) return new ArchitectureCondition(Condition, failDescription, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition NotHaveAttributeWithArguments( - [NotNull] string attribute, - IEnumerable argumentValues - ) - { - string description, - failDescription; - var argumentValueList = argumentValues?.ToList() ?? new List { null }; - if (argumentValueList.IsNullOrEmpty()) - { - description = "not have attribute \"" + attribute + "\""; - failDescription = "does have attribute \"" + attribute + "\""; - } - else - { - var firstArgument = argumentValueList.First(); - description = argumentValueList - .Where(att => att != firstArgument) - .Aggregate( - "not have attribute \"" - + attribute - + "\" with arguments \"" - + firstArgument - + "\"", - (current, argumentValue) => current + " and \"" + argumentValue + "\"" - ); - failDescription = argumentValueList - .Where(att => att != firstArgument) - .Aggregate( - "does have attribute \"" - + attribute - + "\" with arguments \"" - + firstArgument - + "\"", - (current, argumentValue) => current + " and \"" + argumentValue + "\"" - ); - } - - bool Condition(TRuleType obj, Architecture architecture) - { - foreach (var attributeInstance in obj.AttributeInstances) - { - if (!attributeInstance.Type.FullNameMatches(attribute)) - { - goto NextAttribute; - } - - var attributeArguments = attributeInstance - .AttributeArguments.Select(arg => arg.Value) - .ToList(); - var typeAttributeArguments = attributeArguments - .OfType>() - .Select(t => t.Type) - .Union(attributeArguments.OfType()) - .ToList(); - foreach (var arg in argumentValueList) - { - if (arg is Type argType) - { - if (typeAttributeArguments.All(t => t.FullName != argType.FullName)) - { - goto NextAttribute; - } - } - else if (!attributeArguments.Contains(arg)) - { - goto NextAttribute; - } - } - - return false; - NextAttribute: - ; - } - - return true; - } - - return new ArchitectureCondition(Condition, description, failDescription); - } - public static ICondition NotHaveAttributeWithArguments( [NotNull] Attribute attribute, IEnumerable argumentValues @@ -2757,100 +1605,6 @@ t.Value is ITypeInstance typeInstance return new ArchitectureCondition(Condition, failDescription, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition NotHaveAttributeWithNamedArguments( - [NotNull] string attribute, - IEnumerable<(string, object)> attributeArguments - ) - { - string description, - failDescription; - var argumentList = attributeArguments.ToList(); - if (argumentList.IsNullOrEmpty()) - { - description = "not have attribute \"" + attribute + "\""; - failDescription = "does have attribute \"" + attribute + "\""; - } - else - { - var firstArgument = argumentList.First(); - description = argumentList - .Where(att => att != firstArgument) - .Aggregate( - "not have attribute \"" - + attribute - + "\" with named arguments \"" - + firstArgument.Item1 - + "=" - + firstArgument.Item2 - + "\"", - (current, arg) => current + " and \"" + arg.Item1 + "=" + arg.Item2 + "\"" - ); - failDescription = argumentList - .Where(att => att != firstArgument) - .Aggregate( - "does have attribute \"" - + attribute - + "\" with named arguments \"" - + firstArgument.Item1 - + "=" - + firstArgument.Item2 - + "\"", - (current, arg) => current + " and \"" + arg.Item1 + "=" + arg.Item2 + "\"" - ); - } - - bool Condition(TRuleType obj, Architecture architecture) - { - foreach (var attributeInstance in obj.AttributeInstances) - { - if (!attributeInstance.Type.FullNameMatches(attribute)) - { - goto NextAttribute; - } - - var attributeArgs = attributeInstance - .AttributeArguments.OfType() - .Select(arg => (arg.Name, arg.Value)) - .ToList(); - var typeAttributeArguments = attributeArgs - .Where(arg => arg.Value is ITypeInstance || arg.Value is IType) - .ToList(); - foreach (var arg in argumentList) - { - if (arg.Item2 is Type argType) - { - if ( - typeAttributeArguments.All(t => - t.Name != arg.Item1 - || t.Value is ITypeInstance typeInstance - && typeInstance.Type.FullName != argType.FullName - || t.Value is IType type && type.FullName != argType.FullName - ) - ) - { - goto NextAttribute; - } - } - else if (!attributeArgs.Contains(arg)) - { - goto NextAttribute; - } - } - - return false; - NextAttribute: - ; - } - - return true; - } - - return new ArchitectureCondition(Condition, failDescription, description); - } - public static ICondition NotHaveAttributeWithNamedArguments( [NotNull] Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -3044,22 +1798,6 @@ bool Condition(TRuleType obj, Architecture architecture) return new ArchitectureCondition(Condition, description, failDescription); } - [Obsolete( - "Either NotHaveName() without the useRegularExpressions parameter or NotHaveNameMatching() should be used" - )] - public static ICondition NotHaveName(string pattern, bool useRegularExpressions) - { - return new SimpleCondition( - obj => !obj.NameMatches(pattern, useRegularExpressions), - obj => "does have name " + obj.Name, - "not have name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static ICondition NotHaveName(string name) { return new SimpleCondition( @@ -3078,25 +1816,6 @@ public static ICondition NotHaveNameMatching(string pattern) ); } - [Obsolete( - "Either NotHaveFullName() without the useRegularExpressions parameter or NotHaveFullNameMatching() should be used" - )] - public static ICondition NotHaveFullName( - string pattern, - bool useRegularExpressions - ) - { - return new SimpleCondition( - obj => !obj.FullNameMatches(pattern, useRegularExpressions), - obj => "does have full name " + obj.FullName, - "not have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static ICondition NotHaveFullName(string fullName) { return new SimpleCondition( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/ObjectPredicatesDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/ObjectPredicatesDefinition.cs index fd7b8960f..5103207be 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/ObjectPredicatesDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/ObjectPredicatesDefinition.cs @@ -14,58 +14,6 @@ namespace ArchUnitNET.Fluent.Syntax.Elements public static class ObjectPredicatesDefinition where T : ICanBeAnalyzed { - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Are(Types().That().HaveFullName()) instead" - )] - public static IPredicate Are(string pattern, bool useRegularExpressions = false) - { - return new SimplePredicate( - obj => obj.FullNameMatches(pattern, useRegularExpressions), - "have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Are(Types().That().HaveFullName()) instead" - )] - public static IPredicate Are( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - string description; - if (patternList.IsNullOrEmpty()) - { - description = "not exist (impossible)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate( - obj => - patternList.Any(pattern => obj.FullNameMatches(pattern, useRegularExpressions)), - description - ); - } - public static IPredicate Are( ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects @@ -117,60 +65,6 @@ IEnumerable Filter(IEnumerable objects, Architecture architecture) return new ArchitecturePredicate(Filter, "are " + objectProvider.Description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - public static IPredicate CallAny(string pattern, bool useRegularExpressions = false) - { - return new SimplePredicate( - obj => obj.CallsMethod(pattern, useRegularExpressions), - "calls any method with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - public static IPredicate CallAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Filter(T type) - { - return patternList.Any(method => type.CallsMethod(method)); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "call one of no methods (impossible)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "call any method with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Filter, description); - } - public static IPredicate CallAny(MethodMember method, params MethodMember[] moreMethods) { var methods = new List { method }; @@ -219,65 +113,6 @@ IEnumerable Filter(IEnumerable objects) return new EnumerablePredicate(Filter, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - public static IPredicate DependOnAny(string pattern, bool useRegularExpressions = false) - { - return new SimplePredicate( - obj => obj.DependsOn(pattern, useRegularExpressions), - "depend on any types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - public static IPredicate DependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Filter(T type) - { - return type.GetTypeDependencies() - .Any(target => - patternList.Any(pattern => - target.FullNameMatches(pattern, useRegularExpressions) - ) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "have no dependencies"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "depend on any types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Filter, description); - } - public static IPredicate DependOnAny(IType firstType, params IType[] moreTypes) { var types = new List { firstType }; @@ -386,65 +221,6 @@ string description return new SimplePredicate(predicate, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - public static IPredicate OnlyDependOn(string pattern, bool useRegularExpressions = false) - { - return new SimplePredicate( - obj => obj.OnlyDependsOn(pattern, useRegularExpressions), - "only depend on types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - public static IPredicate OnlyDependOn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Filter(T type) - { - return type.GetTypeDependencies() - .All(target => - patternList.Any(pattern => - target.FullNameMatches(pattern, useRegularExpressions) - ) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "have no dependencies"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "only depend on types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Filter, description); - } - public static IPredicate OnlyDependOn(IType firstType, params IType[] moreTypes) { var types = new List { firstType }; @@ -549,67 +325,6 @@ IEnumerable Filter(IEnumerable objects, Architecture architecture) return new ArchitecturePredicate(Filter, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public static IPredicate HaveAnyAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - obj => obj.HasAttribute(pattern, useRegularExpressions), - "have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public static IPredicate HaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Filter(T type) - { - return type.Attributes.Any(attribute => - patternList.Any(pattern => - attribute.FullNameMatches(pattern, useRegularExpressions) - ) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "have one of no attributes (impossible)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Filter, description); - } - public static IPredicate HaveAnyAttributes( Attribute firstAttribute, params Attribute[] moreAttributes @@ -701,68 +416,6 @@ IEnumerable Filter(IEnumerable objects, Architecture architecture) return new ArchitecturePredicate(Filter, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - public static IPredicate OnlyHaveAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - obj => obj.OnlyHasAttributes(pattern, useRegularExpressions), - "only have attributes with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - public static IPredicate OnlyHaveAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Filter(T type) - { - return type.Attributes.IsNullOrEmpty() - || type.Attributes.All(attribute => - patternList.Any(pattern => - attribute.FullNameMatches(pattern, useRegularExpressions) - ) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "have no attributes"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "only have attributes with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Filter, description); - } - public static IPredicate OnlyHaveAttributes( Attribute firstAttribute, params Attribute[] moreAttributes @@ -877,20 +530,6 @@ params object[] moreArgumentValues return HaveAnyAttributesWithArguments(argumentValues); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static IPredicate HaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ) - { - var argumentValues = new List { firstArgumentValue }; - argumentValues.AddRange(moreArgumentValues); - return HaveAttributeWithArguments(attribute, argumentValues); - } - public static IPredicate HaveAttributeWithArguments( Attribute attribute, object firstArgumentValue, @@ -923,20 +562,6 @@ public static IPredicate HaveAnyAttributesWithNamedArguments( return HaveAnyAttributesWithNamedArguments(attributeArguments); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static IPredicate HaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ) - { - var attributeArguments = new List<(string, object)> { firstAttributeArgument }; - attributeArguments.AddRange(moreAttributeArguments); - return HaveAttributeWithNamedArguments(attribute, attributeArguments); - } - public static IPredicate HaveAttributeWithNamedArguments( Attribute attribute, (string, object) firstAttributeArgument, @@ -1013,78 +638,6 @@ bool Predicate(T obj, Architecture architecture) return new ArchitecturePredicate(Predicate, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static IPredicate HaveAttributeWithArguments( - [NotNull] string attribute, - IEnumerable argumentValues - ) - { - string description; - var argumentValueList = argumentValues?.ToList() ?? new List { null }; - if (argumentValueList.IsNullOrEmpty()) - { - description = "have attribute \"" + attribute + "\""; - } - else - { - var firstArgument = argumentValueList.First(); - description = argumentValueList - .Where(att => att != firstArgument) - .Aggregate( - "have attribute \"" - + attribute - + "\" with arguments \"" - + firstArgument - + "\"", - (current, argumentValue) => current + " and \"" + argumentValue + "\"" - ); - } - - bool Predicate(T obj, Architecture architecture) - { - foreach (var attributeInstance in obj.AttributeInstances) - { - if (!attributeInstance.Type.FullNameMatches(attribute)) - { - goto NextAttribute; - } - - var attributeArguments = attributeInstance - .AttributeArguments.Select(arg => arg.Value) - .ToList(); - var typeAttributeArguments = attributeArguments - .OfType>() - .Select(t => t.Type) - .Union(attributeArguments.OfType()) - .ToList(); - foreach (var arg in argumentValueList) - { - if (arg is Type argType) - { - if (typeAttributeArguments.All(t => t.FullName != argType.FullName)) - { - goto NextAttribute; - } - } - else if (!attributeArguments.Contains(arg)) - { - goto NextAttribute; - } - } - - return true; - NextAttribute: - ; - } - - return false; - } - - return new ArchitecturePredicate(Predicate, description); - } - public static IPredicate HaveAttributeWithArguments( [NotNull] Attribute attribute, IEnumerable argumentValues @@ -1299,11 +852,8 @@ bool Predicate(T obj, Architecture architecture) return new ArchitecturePredicate(Predicate, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] public static IPredicate HaveAttributeWithNamedArguments( - [NotNull] string attribute, + [NotNull] Attribute attribute, IEnumerable<(string, object)> attributeArguments ) { @@ -1311,7 +861,7 @@ public static IPredicate HaveAttributeWithNamedArguments( var argumentList = attributeArguments.ToList(); if (argumentList.IsNullOrEmpty()) { - description = "have attribute \"" + attribute + "\""; + description = "have attribute \"" + attribute.FullName + "\""; } else { @@ -1320,7 +870,7 @@ public static IPredicate HaveAttributeWithNamedArguments( .Where(att => att != firstArgument) .Aggregate( "have attribute \"" - + attribute + + attribute.FullName + "\" with named arguments \"" + firstArgument.Item1 + "=" @@ -1330,11 +880,11 @@ public static IPredicate HaveAttributeWithNamedArguments( ); } - bool Predicate(T obj, Architecture architecture) + bool Condition(T obj, Architecture architecture) { foreach (var attributeInstance in obj.AttributeInstances) { - if (!attributeInstance.Type.FullNameMatches(attribute)) + if (!attributeInstance.Type.Equals(attribute)) { goto NextAttribute; } @@ -1362,84 +912,7 @@ bool Predicate(T obj, Architecture architecture) goto NextAttribute; } } - else if (!argumentList.Contains(arg)) - { - goto NextAttribute; - } - } - - return true; - NextAttribute: - ; - } - - return false; - } - - return new ArchitecturePredicate(Predicate, description); - } - - public static IPredicate HaveAttributeWithNamedArguments( - [NotNull] Attribute attribute, - IEnumerable<(string, object)> attributeArguments - ) - { - string description; - var argumentList = attributeArguments.ToList(); - if (argumentList.IsNullOrEmpty()) - { - description = "have attribute \"" + attribute.FullName + "\""; - } - else - { - var firstArgument = argumentList.First(); - description = argumentList - .Where(att => att != firstArgument) - .Aggregate( - "have attribute \"" - + attribute.FullName - + "\" with named arguments \"" - + firstArgument.Item1 - + "=" - + firstArgument.Item2 - + "\"", - (current, arg) => current + " and \"" + arg.Item1 + "=" + arg.Item2 + "\"" - ); - } - - bool Condition(T obj, Architecture architecture) - { - foreach (var attributeInstance in obj.AttributeInstances) - { - if (!attributeInstance.Type.Equals(attribute)) - { - goto NextAttribute; - } - - var attributeArgs = attributeInstance - .AttributeArguments.OfType() - .Select(arg => (arg.Name, arg.Value)) - .ToList(); - var typeAttributeArguments = attributeArgs - .Where(arg => arg.Value is ITypeInstance || arg.Value is IType) - .ToList(); - foreach (var arg in argumentList) - { - if (arg.Item2 is Type argType) - { - if ( - typeAttributeArguments.All(t => - t.Name != arg.Item1 - || t.Value is ITypeInstance typeInstance - && typeInstance.Type.FullName != argType.FullName - || t.Value is IType type && type.FullName != argType.FullName - ) - ) - { - goto NextAttribute; - } - } - else if (!attributeArgs.Contains(arg)) + else if (!attributeArgs.Contains(arg)) { goto NextAttribute; } @@ -1544,17 +1017,6 @@ bool Predicate(T obj, Architecture architecture) return new ArchitecturePredicate(Predicate, description); } - [Obsolete( - "Either HaveName() without the useRegularExpressions parameter or HaveNameMatching() should be used" - )] - public static IPredicate HaveName(string pattern, bool useRegularExpressions) - { - return new SimplePredicate( - obj => obj.NameMatches(pattern, useRegularExpressions), - "have name " + (useRegularExpressions ? "matching " : "") + "\"" + pattern + "\"" - ); - } - public static IPredicate HaveName(string name) { return new SimplePredicate( @@ -1571,21 +1033,6 @@ public static IPredicate HaveNameMatching(string pattern) ); } - [Obsolete( - "Either HaveFullName() without the useRegularExpressions parameter or HaveFullNameMatching() should be used" - )] - public static IPredicate HaveFullName(string pattern, bool useRegularExpressions) - { - return new SimplePredicate( - obj => obj.FullNameMatches(pattern, useRegularExpressions), - "have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static IPredicate HaveFullName(string fullName) { return new SimplePredicate( @@ -1672,60 +1119,6 @@ public static IPredicate ArePrivateProtected() //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNot(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreNot(string pattern, bool useRegularExpressions = false) - { - return new SimplePredicate( - obj => !obj.FullNameMatches(pattern, useRegularExpressions), - "do not have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNot(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreNot( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - string description; - if (patternList.IsNullOrEmpty()) - { - description = "exist (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "do not have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate( - obj => - patternList.All(pattern => - !obj.FullNameMatches(pattern, useRegularExpressions) - ), - description - ); - } - public static IPredicate AreNot( ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects @@ -1774,62 +1167,6 @@ IEnumerable Filter(IEnumerable objects, Architecture architecture) return new ArchitecturePredicate(Filter, "are not " + objectProvider.Description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - public static IPredicate DoNotCallAny(string pattern, bool useRegularExpressions = false) - { - return new SimplePredicate( - obj => !obj.CallsMethod(pattern, useRegularExpressions), - "do not call any methods with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - public static IPredicate DoNotCallAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Filter(T type) - { - return patternList.All(pattern => - !type.CallsMethod(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "do not call one of no methods (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "do not call any methods with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Filter, description); - } - public static IPredicate DoNotCallAny( MethodMember method, params MethodMember[] moreMethods @@ -1881,68 +1218,6 @@ IEnumerable Filter(IEnumerable objects) return new EnumerablePredicate(Filter, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotDependOnAny(Types().That().HaveFullName()) instead" - )] - public static IPredicate DoNotDependOnAny( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - obj => !obj.DependsOn(pattern, useRegularExpressions), - "do not depend on any types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotDependOnAny(Types().That().HaveFullName()) instead" - )] - public static IPredicate DoNotDependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Filter(T type) - { - return type.GetTypeDependencies() - .All(target => - patternList.All(pattern => - target.FullNameMatches(pattern, useRegularExpressions) - ) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "do not depend on no types (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "do not depend on any types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Filter, description); - } - public static IPredicate DoNotDependOnAny(IType firstType, params IType[] moreTypes) { var types = new List { firstType }; @@ -2043,67 +1318,6 @@ IEnumerable Filter(IEnumerable objects, Architecture architecture) return new ArchitecturePredicate(Filter, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public static IPredicate DoNotHaveAnyAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - obj => !obj.HasAttribute(pattern, useRegularExpressions), - "do not have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public static IPredicate DoNotHaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Filter(T type) - { - return !type.Attributes.Any(attribute => - patternList.Any(pattern => - attribute.FullNameMatches(pattern, useRegularExpressions) - ) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "do not have one of no attributes (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(pattern => !pattern.Equals(firstPattern)) - .Distinct() - .Aggregate( - "do not have any attribute with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Filter, description); - } - public static IPredicate DoNotHaveAnyAttributes( Attribute firstAttribute, params Attribute[] moreAttributes @@ -2220,20 +1434,6 @@ params object[] moreArgumentValues return DoNotHaveAnyAttributesWithArguments(argumentValues); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static IPredicate DoNotHaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ) - { - var argumentValues = new List { firstArgumentValue }; - argumentValues.AddRange(moreArgumentValues); - return DoNotHaveAttributeWithArguments(attribute, argumentValues); - } - public static IPredicate DoNotHaveAttributeWithArguments( Attribute attribute, object firstArgumentValue, @@ -2266,20 +1466,6 @@ public static IPredicate DoNotHaveAnyAttributesWithNamedArguments( return DoNotHaveAnyAttributesWithNamedArguments(attributeArguments); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static IPredicate DoNotHaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ) - { - var attributeArguments = new List<(string, object)> { firstAttributeArgument }; - attributeArguments.AddRange(moreAttributeArguments); - return DoNotHaveAttributeWithNamedArguments(attribute, attributeArguments); - } - public static IPredicate DoNotHaveAttributeWithNamedArguments( Attribute attribute, (string, object) firstAttributeArgument, @@ -2358,78 +1544,6 @@ bool Predicate(T obj, Architecture architecture) return new ArchitecturePredicate(Predicate, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static IPredicate DoNotHaveAttributeWithArguments( - [NotNull] string attribute, - IEnumerable argumentValues - ) - { - string description; - var argumentValueList = argumentValues?.ToList() ?? new List { null }; - if (argumentValueList.IsNullOrEmpty()) - { - description = "do not have attribute \"" + attribute + "\""; - } - else - { - var firstArgument = argumentValueList.First(); - description = argumentValueList - .Where(att => att != firstArgument) - .Aggregate( - "do not have attribute \"" - + attribute - + "\" with arguments \"" - + firstArgument - + "\"", - (current, argumentValue) => current + " and \"" + argumentValue + "\"" - ); - } - - bool Predicate(T obj, Architecture architecture) - { - foreach (var attributeInstance in obj.AttributeInstances) - { - if (!attributeInstance.Type.FullNameMatches(attribute)) - { - goto NextAttribute; - } - - var attributeArguments = attributeInstance - .AttributeArguments.Select(arg => arg.Value) - .ToList(); - var typeAttributeArguments = attributeArguments - .OfType>() - .Select(t => t.Type) - .Union(attributeArguments.OfType()) - .ToList(); - foreach (var arg in argumentValueList) - { - if (arg is Type argType) - { - if (typeAttributeArguments.All(t => t.FullName != argType.FullName)) - { - goto NextAttribute; - } - } - else if (!attributeArguments.Contains(arg)) - { - goto NextAttribute; - } - } - - return false; - NextAttribute: - ; - } - - return true; - } - - return new ArchitecturePredicate(Predicate, description); - } - public static IPredicate DoNotHaveAttributeWithArguments( [NotNull] Attribute attribute, IEnumerable argumentValues @@ -2646,86 +1760,6 @@ t.Value is ITypeInstance typeInstance return new ArchitecturePredicate(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static IPredicate DoNotHaveAttributeWithNamedArguments( - [NotNull] string attribute, - IEnumerable<(string, object)> attributeArguments - ) - { - string description; - var argumentList = attributeArguments.ToList(); - if (argumentList.IsNullOrEmpty()) - { - description = "do not have attribute \"" + attribute + "\""; - } - else - { - var firstArgument = argumentList.First(); - description = argumentList - .Where(att => att != firstArgument) - .Aggregate( - "do not have attribute \"" - + attribute - + "\" with named arguments \"" - + firstArgument.Item1 - + "=" - + firstArgument.Item2 - + "\"", - (current, arg) => current + " and \"" + arg.Item1 + "=" + arg.Item2 + "\"" - ); - } - - bool Predicate(T obj, Architecture architecture) - { - foreach (var attributeInstance in obj.AttributeInstances) - { - if (!attributeInstance.Type.FullNameMatches(attribute)) - { - goto NextAttribute; - } - - var attributeArgs = attributeInstance - .AttributeArguments.OfType() - .Select(arg => (arg.Name, arg.Value)) - .ToList(); - var typeAttributeArguments = attributeArgs - .Where(arg => arg.Value is ITypeInstance || arg.Value is IType) - .ToList(); - foreach (var arg in argumentList) - { - if (arg.Item2 is Type argType) - { - if ( - typeAttributeArguments.All(t => - t.Name != arg.Item1 - || t.Value is ITypeInstance typeInstance - && typeInstance.Type.FullName != argType.FullName - || t.Value is IType type && type.FullName != argType.FullName - ) - ) - { - goto NextAttribute; - } - } - else if (!argumentList.Contains(arg)) - { - goto NextAttribute; - } - } - - return false; - NextAttribute: - ; - } - - return true; - } - - return new ArchitecturePredicate(Predicate, description); - } - public static IPredicate DoNotHaveAttributeWithNamedArguments( [NotNull] Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -2891,21 +1925,6 @@ bool Predicate(T obj, Architecture architecture) return new ArchitecturePredicate(Predicate, description); } - [Obsolete( - "Either DoNotHaveName() without the useRegularExpressions parameter or DoNotHaveNameMatching() should be used" - )] - public static IPredicate DoNotHaveName(string pattern, bool useRegularExpressions) - { - return new SimplePredicate( - obj => !obj.NameMatches(pattern, useRegularExpressions), - "do not have name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static IPredicate DoNotHaveName(string name) { return new SimplePredicate( @@ -2922,21 +1941,6 @@ public static IPredicate DoNotHaveNameMatching(string pattern) ); } - [Obsolete( - "Either DoNotHaveFullName() without the useRegularExpressions parameter or DoNotHaveFullNameMatching() should be used" - )] - public static IPredicate DoNotHaveFullName(string pattern, bool useRegularExpressions) - { - return new SimplePredicate( - obj => !obj.FullNameMatches(pattern, useRegularExpressions), - "do not have full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static IPredicate DoNotHaveFullName(string fullName) { return new SimplePredicate( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/ObjectsShould.cs b/ArchUnitNET/Fluent/Syntax/Elements/ObjectsShould.cs index 1d75779f4..036ed1d89 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/ObjectsShould.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/ObjectsShould.cs @@ -28,31 +28,6 @@ public TRuleTypeShouldConjunction Exist() return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Be(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction Be(string pattern, bool useRegularExpressions = false) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.Be(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Be(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction Be( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.Be(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction Be( ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects @@ -84,34 +59,6 @@ public TRuleTypeShouldConjunction Be(IObjectProvider objects) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction CallAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.CallAny(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction CallAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.CallAny(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction CallAny( MethodMember method, params MethodMember[] moreMethods @@ -143,34 +90,6 @@ public TRuleTypeShouldConjunction CallAny(IObjectProvider methods) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DependOnAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.DependOnAny(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.DependOnAny(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DependOnAny(IType firstType, params IType[] moreTypes) { var typeList = new List { firstType }; @@ -254,34 +173,6 @@ string failDescription return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction OnlyDependOn( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.OnlyDependOn(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction OnlyDependOn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.OnlyDependOn(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction OnlyDependOn(IType firstType, params IType[] moreTypes) { var typeList = new List { firstType }; @@ -332,40 +223,6 @@ public TRuleTypeShouldConjunction OnlyDependOn(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction HaveAnyAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.HaveAnyAttributes( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction HaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.HaveAnyAttributes( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveAnyAttributes( Attribute firstAttribute, params Attribute[] moreAttributes @@ -424,40 +281,6 @@ public TRuleTypeShouldConjunction HaveAnyAttributes(IEnumerable attributes return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction OnlyHaveAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.OnlyHaveAttributes( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction OnlyHaveAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.OnlyHaveAttributes( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction OnlyHaveAttributes( Attribute firstAttribute, params Attribute[] moreAttributes @@ -540,42 +363,6 @@ params object[] moreArgumentValues return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction HaveAttributeWithArguments( - string attribute, - IEnumerable argumentValues - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.HaveAttributeWithArguments( - attribute, - argumentValues - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction HaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.HaveAttributeWithArguments( - attribute, - firstArgumentValue, - moreArgumentValues - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveAttributeWithArguments( Attribute attribute, IEnumerable argumentValues @@ -662,42 +449,6 @@ public TRuleTypeShouldConjunction HaveAnyAttributesWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction HaveAttributeWithNamedArguments( - string attribute, - IEnumerable<(string, object)> attributeArguments - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.HaveAttributeWithNamedArguments( - attribute, - attributeArguments - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction HaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.HaveAttributeWithNamedArguments( - attribute, - firstAttributeArgument, - moreAttributeArguments - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveAttributeWithNamedArguments( Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -758,17 +509,6 @@ public TRuleTypeShouldConjunction HaveAttributeWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Either HaveName() without the useRegularExpressions parameter or HaveNameMatching() should be used" - )] - public TRuleTypeShouldConjunction HaveName(string pattern, bool useRegularExpressions) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.HaveName(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveName(string name) { _ruleCreator.AddCondition(ObjectConditionsDefinition.HaveName(name)); @@ -783,17 +523,6 @@ public TRuleTypeShouldConjunction HaveNameMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either HaveFullName() without the useRegularExpressions parameter or HaveFullNameMatching() should be used" - )] - public TRuleTypeShouldConjunction HaveFullName(string pattern, bool useRegularExpressions) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.HaveFullName(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveFullName(string fullName) { _ruleCreator.AddCondition(ObjectConditionsDefinition.HaveFullName(fullName)); @@ -945,31 +674,6 @@ public TRuleTypeShouldConjunction NotExist() return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBe(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotBe(string pattern, bool useRegularExpressions = false) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotBe(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBe(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotBe( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotBe(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotBe( ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects @@ -1001,34 +705,6 @@ public TRuleTypeShouldConjunction NotBe(IObjectProvider objects) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotCallAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotCallAny(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotCallAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotCallAny(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotCallAny( MethodMember method, params MethodMember[] moreMethods @@ -1061,37 +737,6 @@ public TRuleTypeShouldConjunction NotCallAny(IObjectProvider metho return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotDependOnAny(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotDependOnAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotDependOnAny(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotDependOnAny(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotDependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotDependOnAny( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotDependOnAny(IType firstType, params IType[] moreTypes) { var typeList = new List { firstType }; @@ -1142,40 +787,6 @@ public TRuleTypeShouldConjunction NotDependOnAny(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotHaveAnyAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotHaveAnyAttributes( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotHaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotHaveAnyAttributes( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotHaveAnyAttributes( Attribute firstAttribute, params Attribute[] moreAttributes @@ -1262,42 +873,6 @@ params object[] moreArgumentValues return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction NotHaveAttributeWithArguments( - string attribute, - IEnumerable argumentValues - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotHaveAttributeWithArguments( - attribute, - argumentValues - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction NotHaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotHaveAttributeWithArguments( - attribute, - firstArgumentValue, - moreArgumentValues - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotHaveAttributeWithArguments( Attribute attribute, IEnumerable argumentValues @@ -1384,42 +959,6 @@ public TRuleTypeShouldConjunction NotHaveAnyAttributesWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction NotHaveAttributeWithNamedArguments( - string attribute, - IEnumerable<(string, object)> attributeArguments - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotHaveAttributeWithNamedArguments( - attribute, - attributeArguments - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction NotHaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotHaveAttributeWithNamedArguments( - attribute, - firstAttributeArgument, - moreAttributeArguments - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotHaveAttributeWithNamedArguments( Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -1480,17 +1019,6 @@ public TRuleTypeShouldConjunction NotHaveAttributeWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Either NotHaveName() without the useRegularExpressions parameter or NotHaveNameMatching() should be used" - )] - public TRuleTypeShouldConjunction NotHaveName(string pattern, bool useRegularExpressions) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotHaveName(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotHaveName(string name) { _ruleCreator.AddCondition(ObjectConditionsDefinition.NotHaveName(name)); @@ -1505,23 +1033,6 @@ public TRuleTypeShouldConjunction NotHaveNameMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either NotHaveFullName() without the useRegularExpressions parameter or NotHaveFullNameMatching() should be used" - )] - public TRuleTypeShouldConjunction NotHaveFullName( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.AddCondition( - ObjectConditionsDefinition.NotHaveFullName( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotHaveFullName(string fullName) { _ruleCreator.AddCondition( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/ShouldRelateToObjectsThat.cs b/ArchUnitNET/Fluent/Syntax/Elements/ShouldRelateToObjectsThat.cs index b8a7a82e4..529115105 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/ShouldRelateToObjectsThat.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/ShouldRelateToObjectsThat.cs @@ -16,31 +16,6 @@ public class ShouldRelateToObjectsThat ruleCreator) : base(ruleCreator) { } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Are(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction Are(string pattern, bool useRegularExpressions = false) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.Are(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use Are(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction Are( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.Are(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction Are( ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects @@ -68,34 +43,6 @@ public TRuleTypeShouldConjunction Are(IObjectProvider objects) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction CallAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.CallAny(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use CallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction CallAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.CallAny(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction CallAny( MethodMember method, params MethodMember[] moreMethods @@ -123,40 +70,6 @@ public TRuleTypeShouldConjunction CallAny(IObjectProvider methods) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DependOnAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DependOnAny( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DependOnAny(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DependOnAny( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DependOnAny(Type firstType, params Type[] moreTypes) { _ruleCreator.ContinueComplexCondition( @@ -219,40 +132,6 @@ string description return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction OnlyDependOn( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.OnlyDependOn( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyDependOn(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction OnlyDependOn( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.OnlyDependOn( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction OnlyDependOn(Type firstType, params Type[] moreTypes) { _ruleCreator.ContinueComplexCondition( @@ -293,40 +172,6 @@ public TRuleTypeShouldConjunction OnlyDependOn(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction HaveAnyAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.HaveAnyAttributes( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use HaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction HaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.HaveAnyAttributes( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveAnyAttributes( Type firstAttribute, params Type[] moreAttributes @@ -379,40 +224,6 @@ public TRuleTypeShouldConjunction HaveAnyAttributes(IEnumerable attributes return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction OnlyHaveAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.OnlyHaveAttributes( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use OnlyHaveAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction OnlyHaveAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.OnlyHaveAttributes( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction OnlyHaveAttributes( Type firstAttribute, params Type[] moreAttributes @@ -491,42 +302,6 @@ params object[] moreArgumentValues return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction HaveAttributeWithArguments( - string attribute, - IEnumerable argumentValues - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.HaveAttributeWithArguments( - attribute, - argumentValues - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction HaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.HaveAttributeWithArguments( - attribute, - firstArgumentValue, - moreArgumentValues - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveAttributeWithArguments( Attribute attribute, IEnumerable argumentValues @@ -613,42 +388,6 @@ public TRuleTypeShouldConjunction HaveAnyAttributesWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction HaveAttributeWithNamedArguments( - string attribute, - IEnumerable<(string, object)> attributeArguments - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.HaveAttributeWithNamedArguments( - attribute, - attributeArguments - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction HaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.HaveAttributeWithNamedArguments( - attribute, - firstAttributeArgument, - moreAttributeArguments - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveAttributeWithNamedArguments( Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -709,17 +448,6 @@ public TRuleTypeShouldConjunction HaveAttributeWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Either HaveName() without the useRegularExpressions parameter or HaveNameMatching() should be used" - )] - public TRuleTypeShouldConjunction HaveName(string pattern, bool useRegularExpressions) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.HaveName(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveName(string name) { _ruleCreator.ContinueComplexCondition( @@ -736,20 +464,6 @@ public TRuleTypeShouldConjunction HaveNameMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either HaveFullName() without the useRegularExpressions parameter or HaveFullNameMatching() should be used" - )] - public TRuleTypeShouldConjunction HaveFullName(string pattern, bool useRegularExpressions) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.HaveFullName( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction HaveFullName(string fullName) { _ruleCreator.ContinueComplexCondition( @@ -848,31 +562,6 @@ public TRuleTypeShouldConjunction ArePrivateProtected() //Negations - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNot(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreNot(string pattern, bool useRegularExpressions = false) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.AreNot(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNot(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreNot( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.AreNot(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction AreNot( ICanBeAnalyzed firstObject, params ICanBeAnalyzed[] moreObjects @@ -900,40 +589,6 @@ public TRuleTypeShouldConjunction AreNot(IObjectProvider objects return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DoNotCallAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotCallAny( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotCallAny(MethodMembers().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DoNotCallAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotCallAny( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotCallAny( MethodMember method, params MethodMember[] moreMethods @@ -961,40 +616,6 @@ public TRuleTypeShouldConjunction DoNotCallAny(IObjectProvider met return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotDependOnAny(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DoNotDependOnAny( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotDependOnAny( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotDependOnAny(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DoNotDependOnAny( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotDependOnAny( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotDependOnAny(Type firstType, params Type[] moreTypes) { _ruleCreator.ContinueComplexCondition( @@ -1038,40 +659,6 @@ public TRuleTypeShouldConjunction DoNotDependOnAny(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DoNotHaveAnyAttributes( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotHaveAnyAttributes( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use DoNotHaveAnyAttributes(Attributes().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction DoNotHaveAnyAttributes( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotHaveAnyAttributes( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotHaveAnyAttributes( Type firstAttribute, params Type[] moreAttributes @@ -1238,78 +825,6 @@ public TRuleTypeShouldConjunction DoNotHaveAnyAttributesWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction DoNotHaveAttributeWithArguments( - string attribute, - IEnumerable argumentValues - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotHaveAttributeWithArguments( - attribute, - argumentValues - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction DoNotHaveAttributeWithArguments( - string attribute, - object firstArgumentValue, - params object[] moreArgumentValues - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotHaveAttributeWithArguments( - attribute, - firstArgumentValue, - moreArgumentValues - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction DoNotHaveAttributeWithNamedArguments( - string attribute, - IEnumerable<(string, object)> attributeArguments - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotHaveAttributeWithNamedArguments( - attribute, - attributeArguments - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction DoNotHaveAttributeWithNamedArguments( - string attribute, - (string, object) firstAttributeArgument, - params (string, object)[] moreAttributeArguments - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotHaveAttributeWithNamedArguments( - attribute, - firstAttributeArgument, - moreAttributeArguments - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotHaveAttributeWithNamedArguments( Attribute attribute, IEnumerable<(string, object)> attributeArguments @@ -1370,20 +885,6 @@ public TRuleTypeShouldConjunction DoNotHaveAttributeWithNamedArguments( return Create(_ruleCreator); } - [Obsolete( - "Either DoNotHaveName() without the useRegularExpressions parameter or DoNotHaveNameMatching() should be used" - )] - public TRuleTypeShouldConjunction DoNotHaveName(string pattern, bool useRegularExpressions) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotHaveName( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotHaveName(string name) { _ruleCreator.ContinueComplexCondition( @@ -1400,23 +901,6 @@ public TRuleTypeShouldConjunction DoNotHaveNameMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either DoNotHaveFullName() without the useRegularExpressions parameter or DoNotHaveFullNameMatching() should be used" - )] - public TRuleTypeShouldConjunction DoNotHaveFullName( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.ContinueComplexCondition( - ObjectPredicatesDefinition.DoNotHaveFullName( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotHaveFullName(string fullName) { _ruleCreator.ContinueComplexCondition( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Types/GivenTypesThat.cs b/ArchUnitNET/Fluent/Syntax/Elements/Types/GivenTypesThat.cs index 01fc07078..3444079eb 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Types/GivenTypesThat.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Types/GivenTypesThat.cs @@ -31,34 +31,6 @@ public TGivenRuleTypeConjunction Are(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreAssignableTo(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction AreAssignableTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - TypePredicatesDefinition.AreAssignableTo(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreAssignableTo(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction AreAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - TypePredicatesDefinition.AreAssignableTo(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction AreAssignableTo(IType firstType, params IType[] moreTypes) { _ruleCreator.AddPredicate( @@ -145,23 +117,6 @@ public TGivenRuleTypeConjunction AreStructs() return Create(_ruleCreator); } - [Obsolete( - "Use ImplementAnyInterfaces(Interfacs().That().HaveFullName(...)) instead. This will be removed in a future update." - )] - public TGivenRuleTypeConjunction ImplementInterface( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - TypePredicatesDefinition.ImplementInterface( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction ImplementInterface(Interface intf) { _ruleCreator.AddPredicate(TypePredicatesDefinition.ImplementInterface(intf)); @@ -183,23 +138,6 @@ public TGivenRuleTypeConjunction ImplementInterface(Type intf) public TGivenRuleTypeConjunction ImplementAnyInterfaces(IObjectProvider interfaces) => Handle(TypePredicatesDefinition.ImplementAny(interfaces)); // csharpier-ignore-end - [Obsolete( - "Either ResideInNamespace() without the useRegularExpressions parameter or ResideInNamespaceMatching() should be used" - )] - public TGivenRuleTypeConjunction ResideInNamespace( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.AddPredicate( - TypePredicatesDefinition.ResideInNamespace( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction ResideInNamespace(string fullName) { _ruleCreator.AddPredicate( @@ -216,24 +154,6 @@ public TGivenRuleTypeConjunction ResideInNamespaceMatching(string pattern) return Create(_ruleCreator); } - /// Matches the types that reside in the assembly. - /// Name of the assembly to match. - /// Indicates if pattern shall be considered a regular expression. - /// In case of not using regular expression pattern has to be Assembly Full Name. - [Obsolete( - "Either ResideInAssembly() without the useRegularExpressions parameter or ResideInAssemblyMatching() should be used" - )] - public TGivenRuleTypeConjunction ResideInAssembly( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.AddPredicate( - TypePredicatesDefinition.ResideInAssembly(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction ResideInAssembly(string fullName) { _ruleCreator.AddPredicate( @@ -324,40 +244,6 @@ public TGivenRuleTypeConjunction AreNot(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotAssignableTo(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction AreNotAssignableTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - TypePredicatesDefinition.AreNotAssignableTo( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotAssignableTo(Types().That().HaveFullName()) instead" - )] - public TGivenRuleTypeConjunction AreNotAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - TypePredicatesDefinition.AreNotAssignableTo( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction AreNotAssignableTo( IType firstType, params IType[] moreTypes @@ -419,23 +305,6 @@ public TGivenRuleTypeConjunction AreNotStructs() return Create(_ruleCreator); } - [Obsolete( - "Use DoNotImplementAnyInterfaces(Interfaces().That().HaveFullName(...)) instead. This will be removed in a future update." - )] - public TGivenRuleTypeConjunction DoNotImplementInterface( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddPredicate( - TypePredicatesDefinition.DoNotImplementInterface( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction DoNotImplementInterface(Interface intf) { _ruleCreator.AddPredicate( @@ -461,23 +330,6 @@ public TGivenRuleTypeConjunction DoNotImplementInterface(Type intf) public TGivenRuleTypeConjunction DoNotImplementAnyInterfaces(IObjectProvider interfaces) => Handle(TypePredicatesDefinition.DoNotImplementAny(interfaces)); // csharpier-ignore-end - [Obsolete( - "Either DoNotResideInNamespace() without the useRegularExpressions parameter or DoNotResideInNamespaceMatching() should be used" - )] - public TGivenRuleTypeConjunction DoNotResideInNamespace( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.AddPredicate( - TypePredicatesDefinition.DoNotResideInNamespace( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction DoNotResideInNamespace(string fullName) { _ruleCreator.AddPredicate( @@ -494,23 +346,6 @@ public TGivenRuleTypeConjunction DoNotResideInNamespaceMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either DoNotResideInAssembly() without the useRegularExpressions parameter or DoNotResideInAssemblyMatching() should be used" - )] - public TGivenRuleTypeConjunction DoNotResideInAssembly( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.AddPredicate( - TypePredicatesDefinition.DoNotResideInAssembly( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TGivenRuleTypeConjunction DoNotResideInAssembly(string fullName) { _ruleCreator.AddPredicate( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Types/ITypeConditions.cs b/ArchUnitNET/Fluent/Syntax/Elements/Types/ITypeConditions.cs index ff747a679..ef631f0e3 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Types/ITypeConditions.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Types/ITypeConditions.cs @@ -12,18 +12,6 @@ public interface ITypeConditions TReturnType Be(Type firstType, params Type[] moreTypes); TReturnType Be(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeAssignableTo(Types().That().HaveFullName()) instead" - )] - TReturnType BeAssignableTo(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeAssignableTo(Types().That().HaveFullName()) instead" - )] - TReturnType BeAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType BeAssignableTo(IType firstType, params IType[] moreTypes); TReturnType BeAssignableTo(Type type, params Type[] moreTypes); TReturnType BeAssignableTo(IObjectProvider types); @@ -33,10 +21,6 @@ TReturnType BeAssignableTo( TReturnType BeEnums(); TReturnType BeStructs(); - [Obsolete( - "Use ImplementAnyInterfacesThat().HaveFullName(...) instead. This will be removed in a future update." - )] - TReturnType ImplementInterface(string pattern, bool useRegularExpressions = false); TReturnType ImplementInterface(Interface intf); TReturnType ImplementInterface(Type intf); @@ -47,17 +31,9 @@ TReturnType BeAssignableTo( TReturnType ImplementAnyInterfaces(IEnumerable interfaces); TReturnType ImplementAnyInterfaces(IObjectProvider interfaces); - [Obsolete( - "Either ResideInNamespace() without the useRegularExpressions parameter or ResideInNamespaceMatching() should be used" - )] - TReturnType ResideInNamespace(string pattern, bool useRegularExpressions); TReturnType ResideInNamespace(string fullName); TReturnType ResideInNamespaceMatching(string pattern); - [Obsolete( - "Either ResideInAssembly() without the useRegularExpressions parameter or ResideInAssemblyMatching() should be used" - )] - TReturnType ResideInAssembly(string pattern, bool useRegularExpressions); TReturnType ResideInAssembly(string fullName); TReturnType ResideInAssemblyMatching(string pattern); TReturnType ResideInAssembly(Assembly assembly, params Assembly[] moreAssemblies); @@ -76,18 +52,6 @@ params Domain.Assembly[] moreAssemblies TReturnType NotBe(Type firstType, params Type[] moreTypes); TReturnType NotBe(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeAssignableTo(Types().That().HaveFullName()) instead" - )] - TReturnType NotBeAssignableTo(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeAssignableTo(Types().That().HaveFullName()) instead" - )] - TReturnType NotBeAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType NotBeAssignableTo(IType type, params IType[] moreTypes); TReturnType NotBeAssignableTo(Type type, params Type[] moreTypes); TReturnType NotBeAssignableTo(IObjectProvider types); @@ -97,10 +61,6 @@ TReturnType NotBeAssignableTo( TReturnType NotBeEnums(); TReturnType NotBeStructs(); - [Obsolete( - "Use NotImplementAnyInterfacesThat().HaveFullName(...) instead. This will be removed in a future update." - )] - TReturnType NotImplementInterface(string pattern, bool useRegularExpressions = false); TReturnType NotImplementInterface(Interface intf); TReturnType NotImplementInterface(Type intf); @@ -111,19 +71,10 @@ TReturnType NotBeAssignableTo( TReturnType NotImplementAnyInterfaces(IEnumerable interfaces); TReturnType NotImplementAnyInterfaces(IObjectProvider interfaces); - [Obsolete( - "Either NotResideInNamespace() without the useRegularExpressions parameter or NotResideInNamespaceMatching() should be used" - )] - TReturnType NotResideInNamespace(string pattern, bool useRegularExpressions); TReturnType NotResideInNamespace(string fullName); TReturnType NotResideInNamespaceMatching(string pattern); - [Obsolete( - "Either NotResideInAssembly() without the useRegularExpressions parameter or NotResideInAssemblyMatching() should be used" - )] - TReturnType NotResideInAssembly(string fullName); TReturnType NotResideInAssemblyMatching(string pattern); - TReturnType NotResideInAssembly(string pattern, bool useRegularExpressions); TReturnType NotResideInAssembly(Assembly assembly, params Assembly[] moreAssemblies); TReturnType NotResideInAssembly( Domain.Assembly assembly, diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Types/ITypePredicates.cs b/ArchUnitNET/Fluent/Syntax/Elements/Types/ITypePredicates.cs index ca5b2b36f..03449a678 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Types/ITypePredicates.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Types/ITypePredicates.cs @@ -12,18 +12,6 @@ public interface ITypePredicates TReturnType Are(Type firstType, params Type[] moreTypes); TReturnType Are(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreAssignableTo(Types().That().HaveFullName()) instead" - )] - TReturnType AreAssignableTo(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreAssignableTo(Types().That().HaveFullName()) instead" - )] - TReturnType AreAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType AreAssignableTo(IType firstType, params IType[] moreTypes); TReturnType AreAssignableTo(Type type, params Type[] moreTypes); TReturnType AreAssignableTo(IObjectProvider types); @@ -33,10 +21,6 @@ TReturnType AreAssignableTo( TReturnType AreEnums(); TReturnType AreStructs(); - [Obsolete( - "Use ImplementAnyInterfaces(Interfaces().That().HaveFullName(...)) instead. This will be removed in a future update." - )] - TReturnType ImplementInterface(string pattern, bool useRegularExpressions = false); TReturnType ImplementInterface(Interface intf); TReturnType ImplementInterface(Type intf); @@ -47,17 +31,9 @@ TReturnType AreAssignableTo( TReturnType ImplementAnyInterfaces(IEnumerable interfaces); TReturnType ImplementAnyInterfaces(IObjectProvider interfaces); - [Obsolete( - "Either ResideInNamespace() without the useRegularExpressions parameter or ResideInNamespaceMatching() should be used" - )] - TReturnType ResideInNamespace(string pattern, bool useRegularExpressions); TReturnType ResideInNamespace(string fullName); TReturnType ResideInNamespaceMatching(string pattern); - [Obsolete( - "Either ResideInAssembly() without the useRegularExpressions parameter or ResideInAssemblyMatching() should be used" - )] - TReturnType ResideInAssembly(string pattern, bool useRegularExpressions); TReturnType ResideInAssembly(string fullName); TReturnType ResideInAssemblyMatching(string pattern); TReturnType ResideInAssembly(Assembly assembly, params Assembly[] moreAssemblies); @@ -76,18 +52,6 @@ params Domain.Assembly[] moreAssemblies TReturnType AreNot(Type firstType, params Type[] moreTypes); TReturnType AreNot(IEnumerable types); - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotAssignableTo(Types().That().HaveFullName()) instead" - )] - TReturnType AreNotAssignableTo(string pattern, bool useRegularExpressions = false); - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotAssignableTo(Types().That().HaveFullName()) instead" - )] - TReturnType AreNotAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ); TReturnType AreNotAssignableTo(IType type, params IType[] moreTypes); TReturnType AreNotAssignableTo(Type type, params Type[] moreTypes); TReturnType AreNotAssignableTo(IObjectProvider types); @@ -97,10 +61,6 @@ TReturnType AreNotAssignableTo( TReturnType AreNotEnums(); TReturnType AreNotStructs(); - [Obsolete( - "Use DoNotImplementAnyInterfaces(Interfaces().That().HaveFullName(...)) instead. This will be removed in a future update." - )] - TReturnType DoNotImplementInterface(string pattern, bool useRegularExpressions = false); TReturnType DoNotImplementInterface(Interface intf); TReturnType DoNotImplementInterface(Type intf); @@ -111,16 +71,8 @@ TReturnType AreNotAssignableTo( TReturnType DoNotImplementAnyInterfaces(IEnumerable interfaces); TReturnType DoNotImplementAnyInterfaces(IObjectProvider interfaces); - [Obsolete( - "Either DoNotResideInNamespace() without the useRegularExpressions parameter or DoNotResideInNamespaceMatching() should be used" - )] - TReturnType DoNotResideInNamespace(string pattern, bool useRegularExpressions); TReturnType DoNotResideInNamespace(string fullName); - [Obsolete( - "Either DoNotResideInAssembly() without the useRegularExpressions parameter or DoNotResideInAssemblyMatching() should be used" - )] - TReturnType DoNotResideInAssembly(string pattern, bool useRegularExpressions); TReturnType DoNotResideInAssembly(string fullName); TReturnType DoNotResideInAssemblyMatching(string pattern); TReturnType DoNotResideInAssembly(Assembly assembly, params Assembly[] moreAssemblies); diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Types/ShouldRelateToTypesThat.cs b/ArchUnitNET/Fluent/Syntax/Elements/Types/ShouldRelateToTypesThat.cs index ad279b222..7d273560c 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Types/ShouldRelateToTypesThat.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Types/ShouldRelateToTypesThat.cs @@ -33,40 +33,6 @@ public TRuleTypeShouldConjunction Are(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreAssignableTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreAssignableTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - TypePredicatesDefinition.AreAssignableTo( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreAssignableTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - TypePredicatesDefinition.AreAssignableTo( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction AreAssignableTo(IType firstType, params IType[] moreTypes) { _ruleCreator.ContinueComplexCondition( @@ -171,23 +137,6 @@ public TRuleTypeShouldConjunction AreStructs() return Create(_ruleCreator); } - [Obsolete( - "Use ImplementAnyInterfaces(Interfacs().That().HaveFullName(...)) instead. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction ImplementInterface( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - TypePredicatesDefinition.ImplementInterface( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction ImplementInterface(Interface intf) { _ruleCreator.ContinueComplexCondition( @@ -213,23 +162,6 @@ public TRuleTypeShouldConjunction ImplementInterface(Type intf) public TRuleTypeShouldConjunction ImplementAnyInterfaces(IObjectProvider interfaces) => Handle(TypePredicatesDefinition.ImplementAny(interfaces)); // csharpier-ignore-end - [Obsolete( - "Either ResideInNamespace() without the useRegularExpressions parameter or ResideInNamespaceMatching() should be used" - )] - public TRuleTypeShouldConjunction ResideInNamespace( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.ContinueComplexCondition( - TypePredicatesDefinition.ResideInNamespace( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction ResideInNamespace(string fullName) { _ruleCreator.ContinueComplexCondition( @@ -246,23 +178,6 @@ public TRuleTypeShouldConjunction ResideInNamespaceMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either ResideInAssembly() without the useRegularExpressions parameter or ResideInAssemblyMatching() should be used" - )] - public TRuleTypeShouldConjunction ResideInAssembly( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.ContinueComplexCondition( - TypePredicatesDefinition.ResideInAssembly( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction ResideInAssembly(string fullName) { _ruleCreator.ContinueComplexCondition( @@ -359,40 +274,6 @@ public TRuleTypeShouldConjunction AreNot(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotAssignableTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreNotAssignableTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - TypePredicatesDefinition.AreNotAssignableTo( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotAssignableTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction AreNotAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - TypePredicatesDefinition.AreNotAssignableTo( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction AreNotAssignableTo( IType firstType, params IType[] moreTypes @@ -463,23 +344,6 @@ public TRuleTypeShouldConjunction AreNotStructs() return Create(_ruleCreator); } - [Obsolete( - "Use DoNotImplementAnyInterfaces(Interfaces().That().HaveFullName(...)) instead. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction DoNotImplementInterface( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.ContinueComplexCondition( - TypePredicatesDefinition.DoNotImplementInterface( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotImplementInterface(Interface intf) { _ruleCreator.ContinueComplexCondition( @@ -505,23 +369,6 @@ public TRuleTypeShouldConjunction DoNotImplementInterface(Type intf) public TRuleTypeShouldConjunction DoNotImplementAnyInterfaces(IObjectProvider interfaces) => Handle(TypePredicatesDefinition.DoNotImplementAny(interfaces)); // csharpier-ignore-end - [Obsolete( - "Either DoNotResideInNamespace() without the useRegularExpressions parameter or DoNotResideInNamespaceMatching() should be used" - )] - public TRuleTypeShouldConjunction DoNotResideInNamespace( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.ContinueComplexCondition( - TypePredicatesDefinition.DoNotResideInNamespace( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotResideInNamespace(string fullName) { _ruleCreator.ContinueComplexCondition( @@ -538,23 +385,6 @@ public TRuleTypeShouldConjunction DoNotResideInNamespaceMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either DoNotResideInAssembly() without the useRegularExpressions parameter or DoNotResideInAssemblyMatching() should be used" - )] - public TRuleTypeShouldConjunction DoNotResideInAssembly( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.ContinueComplexCondition( - TypePredicatesDefinition.DoNotResideInAssembly( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction DoNotResideInAssembly(string fullName) { _ruleCreator.ContinueComplexCondition( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs index 6d91968a5..19f9793bd 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs @@ -85,87 +85,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeAssignableTo(Types().That().HaveFullName()) instead" - )] - public static ICondition BeAssignableTo( - string pattern, - bool useRegularExpressions = false - ) - { - var description = - "be assignable to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\""; - var failDescription = - "is not assignable to a type with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\""; - return new SimpleCondition( - type => type.IsAssignableTo(pattern, useRegularExpressions), - description, - failDescription - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeAssignableTo(Types().That().HaveFullName()) instead" - )] - public static ICondition BeAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(TRuleType ruleType) - { - return patternList.Any(pattern => - ruleType.IsAssignableTo(pattern, useRegularExpressions) - ); - } - - string description; - string failDescription; - if (patternList.IsNullOrEmpty()) - { - description = "be assignable to no types (always false)"; - failDescription = "is assignable to any type (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "be assignable to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - failDescription = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "is not assignable to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description, failDescription); - } - public static RelationCondition BeTypesThat() { return new RelationCondition( @@ -545,29 +464,6 @@ public static ICondition BeStructs() ); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition ImplementInterface( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - type => type.ImplementsInterface(pattern, useRegularExpressions), - "implement interface with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"", - "does not implement interface with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static ICondition ImplementInterface(Interface intf) { return new SimpleCondition( @@ -677,25 +573,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Either ResideInNamespace() without the useRegularExpressions parameter or ResideInNamespaceMatching() should be used" - )] - public static ICondition ResideInNamespace( - string pattern, - bool useRegularExpressions - ) - { - return new SimpleCondition( - type => type.ResidesInNamespace(pattern, useRegularExpressions), - obj => "does reside in " + obj.Namespace.FullName, - "reside in namespace with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static ICondition ResideInNamespace(string fullName) { return new SimpleCondition( @@ -714,25 +591,6 @@ public static ICondition ResideInNamespaceMatching(string pattern) ); } - [Obsolete( - "Either ResideInAssembly() without the useRegularExpressions parameter or ResideInAssemblyMatching() should be used" - )] - public static ICondition ResideInAssembly( - string pattern, - bool useRegularExpressions - ) - { - return new SimpleCondition( - type => type.ResidesInAssembly(pattern, useRegularExpressions), - obj => "does reside in " + obj.Assembly.FullName, - "reside in assembly with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static ICondition ResideInAssembly(string fullName) { return new SimpleCondition( @@ -997,93 +855,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeAssignableTo(Types().That().HaveFullName()) instead" - )] - public static ICondition NotBeAssignableTo( - string pattern, - bool useRegularExpressions = false - ) - { - ConditionResult Condition(TRuleType ruleType) - { - var pass = true; - var dynamicFailDescription = "is assignable to"; - foreach (var type in ruleType.GetAssignableTypes()) - { - if (type.FullNameMatches(pattern, useRegularExpressions)) - { - dynamicFailDescription += (pass ? " " : " and ") + type.FullName; - pass = false; - } - } - - return new ConditionResult(ruleType, pass, dynamicFailDescription); - } - - var description = - "not be assignable to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\""; - return new SimpleCondition(Condition, description); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeAssignableTo(Types().That().HaveFullName()) instead" - )] - public static ICondition NotBeAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - ConditionResult Condition(TRuleType ruleType) - { - var pass = true; - var dynamicFailDescription = "is assignable to"; - foreach (var type in ruleType.GetAssignableTypes()) - { - if ( - patternList.Any(pattern => - type.FullNameMatches(pattern, useRegularExpressions) - ) - ) - { - dynamicFailDescription += (pass ? " " : " and ") + type.FullName; - pass = false; - } - } - - return new ConditionResult(ruleType, pass, dynamicFailDescription); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "not be assignable to no types (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "not be assignable to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimpleCondition(Condition, description); - } - public static ICondition NotBeAssignableTo( IType firstType, params IType[] moreTypes @@ -1322,29 +1093,6 @@ public static ICondition NotBeStructs() ); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static ICondition NotImplementInterface( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimpleCondition( - type => !type.ImplementsInterface(pattern, useRegularExpressions), - "not implement interface with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"", - "does implement interface with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static ICondition NotImplementInterface(Interface intf) { return new SimpleCondition( @@ -1448,25 +1196,6 @@ Architecture architecture return new ArchitectureCondition(Condition, description); } - [Obsolete( - "Either NotResideInNamespace() without the useRegularExpressions parameter or NotResideInNamespaceMatching() should be used" - )] - public static ICondition NotResideInNamespace( - string pattern, - bool useRegularExpressions - ) - { - return new SimpleCondition( - type => !type.ResidesInNamespace(pattern, useRegularExpressions), - obj => "does reside in " + obj.Namespace.FullName, - "not reside in namespace with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static ICondition NotResideInNamespace(string fullName) { return new SimpleCondition( @@ -1485,25 +1214,6 @@ public static ICondition NotResideInNamespaceMatching(string pattern) ); } - [Obsolete( - "Either NotResideInAssembly() without the useRegularExpressions parameter or NotResideInAssemblyMatching() should be used" - )] - public static ICondition NotResideInAssembly( - string pattern, - bool useRegularExpressions - ) - { - return new SimpleCondition( - type => !type.ResidesInAssembly(pattern, useRegularExpressions), - obj => "does reside in " + obj.Assembly.FullName, - "not reside in assembly with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static ICondition NotResideInAssembly(string fullName) { return new SimpleCondition( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypePredicatesDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypePredicatesDefinition.cs index 455ee5436..4e91be64d 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypePredicatesDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypePredicatesDefinition.cs @@ -64,67 +64,6 @@ IEnumerable Filter(IEnumerable ruleTypes, Architecture architecture) return new ArchitecturePredicate(Filter, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreAssignableTo(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreAssignableTo( - string pattern, - bool useRegularExpressions = false - ) - { - var description = - "are assignable to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\""; - return new SimplePredicate( - type => type.IsAssignableTo(pattern, useRegularExpressions), - description - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreAssignableTo(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(T ruleType) - { - return patternList.Any(pattern => - ruleType.IsAssignableTo(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "are assignable to no types (always false)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "are assignable to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Condition, description); - } - public static IPredicate AreAssignableTo(IType firstType, params IType[] moreTypes) { IEnumerable Condition(IEnumerable ruleTypes) @@ -371,24 +310,6 @@ public static IPredicate AreStructs() return new SimplePredicate(type => type is Struct, "are structs"); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static IPredicate ImplementInterface( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - type => type.ImplementsInterface(pattern, useRegularExpressions), - "implement interface with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static IPredicate ImplementInterface(Interface intf) { return new SimplePredicate( @@ -441,21 +362,6 @@ IEnumerable Condition(IEnumerable ruleTypes, Architecture architecture) return new ArchitecturePredicate(Condition, description); } - [Obsolete( - "Either ResideInNamespace() without the useRegularExpressions parameter or ResideInNamespaceMatching() should be used" - )] - public static IPredicate ResideInNamespace(string pattern, bool useRegularExpressions) - { - return new SimplePredicate( - type => type.ResidesInNamespace(pattern, useRegularExpressions), - "reside in namespace with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static IPredicate ResideInNamespace(string fullName) { return new SimplePredicate( @@ -472,21 +378,6 @@ public static IPredicate ResideInNamespaceMatching(string pattern) ); } - [Obsolete( - "Either ResideInAssembly() without the useRegularExpressions parameter or ResideInAssemblyMatching() should be used" - )] - public static IPredicate ResideInAssembly(string pattern, bool useRegularExpressions) - { - return new SimplePredicate( - type => type.ResidesInAssembly(pattern, useRegularExpressions), - "reside in assembly with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static IPredicate ResideInAssembly(string fullName) { return new SimplePredicate( @@ -630,67 +521,6 @@ IEnumerable Filter(IEnumerable ruleTypes, Architecture architecture) return new ArchitecturePredicate(Filter, description); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotAssignableTo(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreNotAssignableTo( - string pattern, - bool useRegularExpressions = false - ) - { - var description = - "are not assignable to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\""; - return new SimplePredicate( - type => !type.IsAssignableTo(pattern, useRegularExpressions), - description - ); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use AreNotAssignableTo(Types().That().HaveFullName()) instead" - )] - public static IPredicate AreNotAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - var patternList = patterns.ToList(); - - bool Condition(T ruleType) - { - return patternList.All(pattern => - !ruleType.IsAssignableTo(pattern, useRegularExpressions) - ); - } - - string description; - if (patternList.IsNullOrEmpty()) - { - description = "are not assignable to no types (always true)"; - } - else - { - var firstPattern = patternList.First(); - description = patternList - .Where(type => !type.Equals(firstPattern)) - .Distinct() - .Aggregate( - "are not assignable to types with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + firstPattern - + "\"", - (current, pattern) => current + " or \"" + pattern + "\"" - ); - } - - return new SimplePredicate(Condition, description); - } - public static IPredicate AreNotAssignableTo(IType firstType, params IType[] moreTypes) { IEnumerable Condition(IEnumerable ruleTypes) @@ -829,24 +659,6 @@ public static IPredicate AreNotStructs() return new SimplePredicate(cls => !(cls is Struct), "are not structs"); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update." - )] - public static IPredicate DoNotImplementInterface( - string pattern, - bool useRegularExpressions = false - ) - { - return new SimplePredicate( - type => !type.ImplementsInterface(pattern, useRegularExpressions), - "do not implement interface with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static IPredicate DoNotImplementInterface(Interface intf) { return new SimplePredicate( @@ -899,24 +711,6 @@ IEnumerable Condition(IEnumerable ruleTypes, Architecture architecture) return new ArchitecturePredicate(Condition, description); } - [Obsolete( - "Either DoNotResideInNamespace() without the useRegularExpressions parameter or DoNotResideInNamespaceMatching() should be used" - )] - public static IPredicate DoNotResideInNamespace( - string pattern, - bool useRegularExpressions - ) - { - return new SimplePredicate( - type => !type.ResidesInNamespace(pattern, useRegularExpressions), - "do not reside in namespace with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static IPredicate DoNotResideInNamespace(string fullName) { return new SimplePredicate( @@ -933,24 +727,6 @@ public static IPredicate DoNotResideInNamespaceMatching(string pattern) ); } - [Obsolete( - "Either DoNotResideInAssembly() without the useRegularExpressions parameter or DoNotResideInAssemblyMatching() should be used" - )] - public static IPredicate DoNotResideInAssembly( - string pattern, - bool useRegularExpressions - ) - { - return new SimplePredicate( - type => !type.ResidesInAssembly(pattern, useRegularExpressions), - "do not reside in assembly with full name " - + (useRegularExpressions ? "matching " : "") - + "\"" - + pattern - + "\"" - ); - } - public static IPredicate DoNotResideInAssembly(string fullName) { return new SimplePredicate( diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypesShould.cs b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypesShould.cs index e638df57b..c730f3917 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypesShould.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypesShould.cs @@ -31,34 +31,6 @@ public TRuleTypeShouldConjunction Be(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeAssignableTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction BeAssignableTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - TypeConditionsDefinition.BeAssignableTo(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use BeAssignableTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction BeAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - TypeConditionsDefinition.BeAssignableTo(patterns, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public ShouldRelateToTypesThat BeTypesThat() { _ruleCreator.BeginComplexCondition( @@ -156,23 +128,6 @@ public TRuleTypeShouldConjunction BeStructs() return Create(_ruleCreator); } - [Obsolete( - "Use ImplementAnyInterfacesThat().HaveFullName(...) instead. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction ImplementInterface( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - TypeConditionsDefinition.ImplementInterface( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction ImplementInterface(Interface intf) { _ruleCreator.AddCondition(TypeConditionsDefinition.ImplementInterface(intf)); @@ -194,23 +149,6 @@ public TRuleTypeShouldConjunction ImplementInterface(Type intf) public TRuleTypeShouldConjunction ImplementAnyInterfaces(IObjectProvider interfaces) => Handle(TypeConditionsDefinition.ImplementAny(interfaces)); // csharpier-ignore-end - [Obsolete( - "Either ResideInNamespace() without the useRegularExpressions parameter or ResideInNamespaceMatching() should be used" - )] - public TRuleTypeShouldConjunction ResideInNamespace( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.AddCondition( - TypeConditionsDefinition.ResideInNamespace( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction ResideInNamespace(string fullName) { _ruleCreator.AddCondition( @@ -227,20 +165,6 @@ public TRuleTypeShouldConjunction ResideInNamespaceMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either ResideInAssembly() without the useRegularExpressions parameter or ResideInAssemblyMatching() should be used" - )] - public TRuleTypeShouldConjunction ResideInAssembly( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.AddCondition( - TypeConditionsDefinition.ResideInAssembly(pattern, useRegularExpressions) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction ResideInAssembly(string fullName) { _ruleCreator.AddCondition( @@ -362,40 +286,6 @@ public TRuleTypeShouldConjunction NotBe(IEnumerable types) return Create(_ruleCreator); } - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeAssignableTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotBeAssignableTo( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - TypeConditionsDefinition.NotBeAssignableTo( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - - [Obsolete( - "Another overload of this method should be used. This will be removed in a future update. You can use NotBeAssignableTo(Types().That().HaveFullName()) instead" - )] - public TRuleTypeShouldConjunction NotBeAssignableTo( - IEnumerable patterns, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - TypeConditionsDefinition.NotBeAssignableTo( - patterns, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotBeAssignableTo( IType firstType, params IType[] moreTypes @@ -451,23 +341,6 @@ public TRuleTypeShouldConjunction NotBeStructs() return Create(_ruleCreator); } - [Obsolete( - "Use NotImplementAnyInterfacesThat().HaveFullName(...) instead. This will be removed in a future update." - )] - public TRuleTypeShouldConjunction NotImplementInterface( - string pattern, - bool useRegularExpressions = false - ) - { - _ruleCreator.AddCondition( - TypeConditionsDefinition.NotImplementInterface( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotImplementInterface(Interface intf) { _ruleCreator.AddCondition( @@ -493,23 +366,6 @@ public TRuleTypeShouldConjunction NotImplementInterface(Type intf) public TRuleTypeShouldConjunction NotImplementAnyInterfaces(IObjectProvider interfaces) => Handle(TypeConditionsDefinition.NotImplementAny(interfaces)); // csharpier-ignore-end - [Obsolete( - "Either NotResideInNamespace() without the useRegularExpressions parameter or NotResideInNamespaceMatching() should be used" - )] - public TRuleTypeShouldConjunction NotResideInNamespace( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.AddCondition( - TypeConditionsDefinition.NotResideInNamespace( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotResideInNamespace(string fullName) { _ruleCreator.AddCondition( @@ -526,23 +382,6 @@ public TRuleTypeShouldConjunction NotResideInNamespaceMatching(string pattern) return Create(_ruleCreator); } - [Obsolete( - "Either NotResideInAssembly() without the useRegularExpressions parameter or NotResideInAssemblyMatching() should be used" - )] - public TRuleTypeShouldConjunction NotResideInAssembly( - string pattern, - bool useRegularExpressions - ) - { - _ruleCreator.AddCondition( - TypeConditionsDefinition.NotResideInAssembly( - pattern, - useRegularExpressions - ) - ); - return Create(_ruleCreator); - } - public TRuleTypeShouldConjunction NotResideInAssembly(string fullName) { _ruleCreator.AddCondition(