diff --git a/documentation/api.md b/documentation/api.md index bcb13b7..944a380 100644 --- a/documentation/api.md +++ b/documentation/api.md @@ -20,6 +20,8 @@ * [AreEnums](#PredicateAreEnums) * [AreGeneric](#PredicateAreGeneric) * [AreImmutable](#PredicateAreImmutable) +* [AreImmutableExternally](#PredicateAreImmutableExternally) +* [AreInheritedByAnyType](#PredicateAreInheritedByAnyType) * [AreInterfaces](#PredicateAreInterfaces) * [AreInternal](#PredicateAreInternal) * [AreMutable](#PredicateAreMutable) @@ -29,9 +31,11 @@ * [AreNotDelegates](#PredicateAreNotDelegates) * [AreNotEnums](#PredicateAreNotEnums) * [AreNotGeneric](#PredicateAreNotGeneric) +* [AreNotInheritedByAnyType](#PredicateAreNotInheritedByAnyType) * [AreNotInterfaces](#PredicateAreNotInterfaces) * [AreNotInternal](#PredicateAreNotInternal) * [AreNotNested](#PredicateAreNotNested) +* [AreNotOfType](#PredicateAreNotOfType) * [AreNotPrivate](#PredicateAreNotPrivate) * [AreNotPrivateProtected](#PredicateAreNotPrivateProtected) * [AreNotProtected](#PredicateAreNotProtected) @@ -40,16 +44,20 @@ * [AreNotSealed](#PredicateAreNotSealed) * [AreNotStatic](#PredicateAreNotStatic) * [AreNotStructures](#PredicateAreNotStructures) +* [AreOfType](#PredicateAreOfType) * [ArePrivate](#PredicateArePrivate) * [ArePrivateProtected](#PredicateArePrivateProtected) * [AreProtected](#PredicateAreProtected) * [AreProtectedInternal](#PredicateAreProtectedInternal) * [ArePublic](#PredicateArePublic) * [AreSealed](#PredicateAreSealed) +* [AreStateless](#PredicateAreStateless) * [AreStatic](#PredicateAreStatic) * [AreStructures](#PredicateAreStructures) * [DoNotHaveCustomAttribute](#PredicateDoNotHaveCustomAttribute) +* [DoNotHaveCustomAttribute](#PredicateDoNotHaveCustomAttribute) * [DoNotHaveCustomAttributeOrInherit](#PredicateDoNotHaveCustomAttributeOrInherit) +* [DoNotHaveCustomAttributeOrInherit](#PredicateDoNotHaveCustomAttributeOrInherit) * [DoNotHaveDependencyOnAll](#PredicateDoNotHaveDependencyOnAll) * [DoNotHaveDependencyOnAny](#PredicateDoNotHaveDependencyOnAny) * [DoNotHaveName](#PredicateDoNotHaveName) @@ -57,13 +65,17 @@ * [DoNotHaveNameMatching](#PredicateDoNotHaveNameMatching) * [DoNotHaveNameStartingWith](#PredicateDoNotHaveNameStartingWith) * [DoNotImplementInterface](#PredicateDoNotImplementInterface) +* [DoNotImplementInterface](#PredicateDoNotImplementInterface) * [DoNotInherit](#PredicateDoNotInherit) +* [DoNotInherit](#PredicateDoNotInherit) * [DoNotResideInNamespace](#PredicateDoNotResideInNamespace) * [DoNotResideInNamespaceContaining](#PredicateDoNotResideInNamespaceContaining) * [DoNotResideInNamespaceEndingWith](#PredicateDoNotResideInNamespaceEndingWith) * [DoNotResideInNamespaceMatching](#PredicateDoNotResideInNamespaceMatching) * [HaveCustomAttribute](#PredicateHaveCustomAttribute) +* [HaveCustomAttribute](#PredicateHaveCustomAttribute) * [HaveCustomAttributeOrInherit](#PredicateHaveCustomAttributeOrInherit) +* [HaveCustomAttributeOrInherit](#PredicateHaveCustomAttributeOrInherit) * [HaveDependencyOnAll](#PredicateHaveDependencyOnAll) * [HaveDependencyOnAny](#PredicateHaveDependencyOnAny) * [HaveDependencyOtherThan](#PredicateHaveDependencyOtherThan) @@ -73,9 +85,13 @@ * [HaveNameStartingWith](#PredicateHaveNameStartingWith) * [HaveSomeNonNullableMembers](#PredicateHaveSomeNonNullableMembers) * [ImplementInterface](#PredicateImplementInterface) +* [ImplementInterface](#PredicateImplementInterface) * [Inherit](#PredicateInherit) +* [Inherit](#PredicateInherit) +* [MeetCustomRule](#PredicateMeetCustomRule) * [MeetCustomRule](#PredicateMeetCustomRule) * [OnlyHaveDependencyOn](#PredicateOnlyHaveDependencyOn) +* [OnlyHaveNonNullableMembers](#PredicateOnlyHaveNonNullableMembers) * [OnlyHaveNullableMembers](#PredicateOnlyHaveNullableMembers) * [ResideInNamespace](#PredicateResideInNamespace) * [ResideInNamespaceContaining](#PredicateResideInNamespaceContaining) @@ -99,30 +115,41 @@ * [BeEnums](#ConditionBeEnums) * [BeGeneric](#ConditionBeGeneric) * [BeImmutable](#ConditionBeImmutable) +* [BeImmutableExternally](#ConditionBeImmutableExternally) * [BeInterfaces](#ConditionBeInterfaces) * [BeInternal](#ConditionBeInternal) * [BeMutable](#ConditionBeMutable) * [BeNested](#ConditionBeNested) +* [BeOfType](#ConditionBeOfType) * [BePrivate](#ConditionBePrivate) * [BePrivateProtected](#ConditionBePrivateProtected) * [BeProtected](#ConditionBeProtected) * [BeProtectedInternal](#ConditionBeProtectedInternal) * [BePublic](#ConditionBePublic) * [BeSealed](#ConditionBeSealed) +* [BeStateless](#ConditionBeStateless) * [BeStatic](#ConditionBeStatic) * [BeStructures](#ConditionBeStructures) * [HaveCustomAttribute](#ConditionHaveCustomAttribute) +* [HaveCustomAttribute](#ConditionHaveCustomAttribute) * [HaveCustomAttributeOrInherit](#ConditionHaveCustomAttributeOrInherit) +* [HaveCustomAttributeOrInherit](#ConditionHaveCustomAttributeOrInherit) * [HaveDependencyOnAll](#ConditionHaveDependencyOnAll) * [HaveDependencyOnAny](#ConditionHaveDependencyOnAny) * [HaveDependencyOtherThan](#ConditionHaveDependencyOtherThan) +* [HaveMatchingTypeWithName](#ConditionHaveMatchingTypeWithName) * [HaveName](#ConditionHaveName) * [HaveNameEndingWith](#ConditionHaveNameEndingWith) * [HaveNameMatching](#ConditionHaveNameMatching) * [HaveNameStartingWith](#ConditionHaveNameStartingWith) * [HaveSomeNonNullableMembers](#ConditionHaveSomeNonNullableMembers) +* [HaveSourceFileNameMatchingName](#ConditionHaveSourceFileNameMatchingName) +* [HaveSourceFilePathMatchingNamespace](#ConditionHaveSourceFilePathMatchingNamespace) * [ImplementInterface](#ConditionImplementInterface) +* [ImplementInterface](#ConditionImplementInterface) * [Inherit](#ConditionInherit) +* [Inherit](#ConditionInherit) +* [MeetCustomRule](#ConditionMeetCustomRule) * [MeetCustomRule](#ConditionMeetCustomRule) * [NotBeAbstract](#ConditionNotBeAbstract) * [NotBeClasses](#ConditionNotBeClasses) @@ -132,6 +159,7 @@ * [NotBeInterfaces](#ConditionNotBeInterfaces) * [NotBeInternal](#ConditionNotBeInternal) * [NotBeNested](#ConditionNotBeNested) +* [NotBeOfType](#ConditionNotBeOfType) * [NotBePrivate](#ConditionNotBePrivate) * [NotBePrivateProtected](#ConditionNotBePrivateProtected) * [NotBeProtected](#ConditionNotBeProtected) @@ -141,7 +169,9 @@ * [NotBeStatic](#ConditionNotBeStatic) * [NotBeStructures](#ConditionNotBeStructures) * [NotHaveCustomAttribute](#ConditionNotHaveCustomAttribute) +* [NotHaveCustomAttribute](#ConditionNotHaveCustomAttribute) * [NotHaveCustomAttributeOrInherit](#ConditionNotHaveCustomAttributeOrInherit) +* [NotHaveCustomAttributeOrInherit](#ConditionNotHaveCustomAttributeOrInherit) * [NotHaveDependencyOnAll](#ConditionNotHaveDependencyOnAll) * [NotHaveDependencyOnAny](#ConditionNotHaveDependencyOnAny) * [NotHaveName](#ConditionNotHaveName) @@ -149,12 +179,15 @@ * [NotHaveNameMatching](#ConditionNotHaveNameMatching) * [NotHaveNameStartingWith](#ConditionNotHaveNameStartingWith) * [NotImplementInterface](#ConditionNotImplementInterface) +* [NotImplementInterface](#ConditionNotImplementInterface) * [NotInherit](#ConditionNotInherit) +* [NotInherit](#ConditionNotInherit) * [NotResideInNamespace](#ConditionNotResideInNamespace) * [NotResideInNamespaceContaining](#ConditionNotResideInNamespaceContaining) * [NotResideInNamespaceEndingWith](#ConditionNotResideInNamespaceEndingWith) * [NotResideInNamespaceMatching](#ConditionNotResideInNamespaceMatching) * [OnlyHaveDependencyOn](#ConditionOnlyHaveDependencyOn) +* [OnlyHaveNonNullableMembers](#ConditionOnlyHaveNonNullableMembers) * [OnlyHaveNullableMembers](#ConditionOnlyHaveNullableMembers) * [ResideInNamespace](#ConditionResideInNamespace) * [ResideInNamespaceContaining](#ConditionResideInNamespaceContaining) @@ -179,6 +212,7 @@ * [FullName](#ITypeFullName) * [Name](#ITypeName) * [ReflectionType](#ITypeReflectionType) +* [SourceFilePath](#ITypeSourceFilePath) ## Options @@ -266,7 +300,17 @@ Selects types that have generic parameters. ```csharp PredicateList Predicate.AreImmutable() ``` -Selects types that are immutable. +Selects types that are immutable, and their state cannot be changed after creation. (shallow immutability). Stronger constraint than AreImmutableExternally() +### Predicate.AreImmutableExternally +```csharp +PredicateList Predicate.AreImmutableExternally() +``` +Selects types that are immutable from the outside of the given type. (shallow immutability). Weaker constraint than AreImmutable() +### Predicate.AreInheritedByAnyType +```csharp +PredicateList Predicate.AreInheritedByAnyType() +``` +Selects types that are inherited by any type ### Predicate.AreInterfaces ```csharp PredicateList Predicate.AreInterfaces() @@ -312,6 +356,11 @@ Selects types that are not enums. PredicateList Predicate.AreNotGeneric() ``` Selects types that do not have generic parameters. +### Predicate.AreNotInheritedByAnyType +```csharp +PredicateList Predicate.AreNotInheritedByAnyType() +``` +Selects types that are not inherited by any type ### Predicate.AreNotInterfaces ```csharp PredicateList Predicate.AreNotInterfaces() @@ -327,6 +376,11 @@ Selects types that are not declared as internal. PredicateList Predicate.AreNotNested() ``` Selects types that are not nested. +### Predicate.AreNotOfType +```csharp +PredicateList Predicate.AreNotOfType(params Type[] type) +``` +Selects types that are not exactly of given type. (inheritance is not considered) ### Predicate.AreNotPrivate ```csharp PredicateList Predicate.AreNotPrivate() @@ -367,6 +421,11 @@ Selects types that are not static. PredicateList Predicate.AreNotStructures() ``` Selects types that are not structures. +### Predicate.AreOfType +```csharp +PredicateList Predicate.AreOfType(params Type[] type) +``` +Selects types that are exactly of given type. (inheritance is not considered) ### Predicate.ArePrivate ```csharp PredicateList Predicate.ArePrivate() @@ -397,6 +456,11 @@ Selects types that have public scope. PredicateList Predicate.AreSealed() ``` Selects types according that are marked as sealed. +### Predicate.AreStateless +```csharp +PredicateList Predicate.AreStateless() +``` +Selects types that are stateless, they do not have instance state ### Predicate.AreStatic ```csharp PredicateList Predicate.AreStatic() @@ -412,11 +476,21 @@ Selects types that are structures. PredicateList Predicate.DoNotHaveCustomAttribute(Type attribute) ``` Selects types that are not decorated with a specific custom attribute. +### Predicate.DoNotHaveCustomAttribute +```csharp +PredicateList Predicate.DoNotHaveCustomAttribute() +``` +Selects types that are not decorated with a specific custom attribute. ### Predicate.DoNotHaveCustomAttributeOrInherit ```csharp PredicateList Predicate.DoNotHaveCustomAttributeOrInherit(Type attribute) ``` Selects types that are not decorated with a specific custom attribute or derived one. +### Predicate.DoNotHaveCustomAttributeOrInherit +```csharp +PredicateList Predicate.DoNotHaveCustomAttributeOrInherit() +``` +Selects types that are not decorated with a specific custom attribute or derived one. ### Predicate.DoNotHaveDependencyOnAll ```csharp PredicateList Predicate.DoNotHaveDependencyOnAll(params string[] dependencies) @@ -434,7 +508,7 @@ PredicateList Predicate.DoNotHaveName(params string[] name) Selects types that do not have a particular name. ### Predicate.DoNotHaveNameEndingWith ```csharp -PredicateList Predicate.DoNotHaveNameEndingWith(string end) +PredicateList Predicate.DoNotHaveNameEndingWith(params string[] end) ``` Selects types whose names do not end with the specified text. ### Predicate.DoNotHaveNameMatching @@ -452,11 +526,21 @@ Selects types whose names do not start with the specified text. PredicateList Predicate.DoNotImplementInterface(Type interfaceType) ``` Selects types that do not implement a particular interface. +### Predicate.DoNotImplementInterface +```csharp +PredicateList Predicate.DoNotImplementInterface() +``` +Selects types that do not implement a particular interface. ### Predicate.DoNotInherit ```csharp PredicateList Predicate.DoNotInherit(Type type) ``` Selects types that do not inherit a particular type. +### Predicate.DoNotInherit +```csharp +PredicateList Predicate.DoNotInherit() +``` +Selects types that do not inherit a particular type. ### Predicate.DoNotResideInNamespace ```csharp PredicateList Predicate.DoNotResideInNamespace(string name) @@ -482,11 +566,21 @@ Selects types whose namespaces do not match a regular expression. PredicateList Predicate.HaveCustomAttribute(Type attribute) ``` Selects types that are decorated with a specific custom attribute. +### Predicate.HaveCustomAttribute +```csharp +PredicateList Predicate.HaveCustomAttribute() +``` +Selects types that are decorated with a specific custom attribute. ### Predicate.HaveCustomAttributeOrInherit ```csharp PredicateList Predicate.HaveCustomAttributeOrInherit(Type attribute) ``` Selects types that are decorated with a specific custom attribute or derived one. +### Predicate.HaveCustomAttributeOrInherit +```csharp +PredicateList Predicate.HaveCustomAttributeOrInherit() +``` +Selects types that are decorated with a specific custom attribute or derived one. ### Predicate.HaveDependencyOnAll ```csharp PredicateList Predicate.HaveDependencyOnAll(params string[] dependencies) @@ -509,7 +603,7 @@ PredicateList Predicate.HaveName(params string[] name) Selects types that have a specific name. ### Predicate.HaveNameEndingWith ```csharp -PredicateList Predicate.HaveNameEndingWith(string end) +PredicateList Predicate.HaveNameEndingWith(params string[] end) ``` Selects types whose names end with the specified text. ### Predicate.HaveNameMatching @@ -532,21 +626,41 @@ Selects types that have some non-nullable members. PredicateList Predicate.ImplementInterface(Type interfaceType) ``` Selects types that implement a particular interface. +### Predicate.ImplementInterface +```csharp +PredicateList Predicate.ImplementInterface() +``` +Selects types that implement a particular interface. ### Predicate.Inherit ```csharp PredicateList Predicate.Inherit(Type type) ``` Selects types that inherit a particular type. +### Predicate.Inherit +```csharp +PredicateList Predicate.Inherit() +``` +Selects types that inherit a particular type. ### Predicate.MeetCustomRule ```csharp PredicateList Predicate.MeetCustomRule(ICustomRule rule) ``` Selects types that meet a custom rule. +### Predicate.MeetCustomRule +```csharp +PredicateList Predicate.MeetCustomRule(Func rule) +``` +Selects types that meet a custom rule. ### Predicate.OnlyHaveDependencyOn ```csharp PredicateList Predicate.OnlyHaveDependencyOn(params string[] dependencies) ``` Selects types that have a dependency on any of the supplied types and cannot have any other dependency. +### Predicate.OnlyHaveNonNullableMembers +```csharp +PredicateList Predicate.OnlyHaveNonNullableMembers() +``` +Selects types that have only non-nullable members. ### Predicate.OnlyHaveNullableMembers ```csharp PredicateList Predicate.OnlyHaveNullableMembers() @@ -635,7 +749,12 @@ Selects types that have generic parameters. ```csharp ConditionList Condition.BeImmutable() ``` -Selects types that are immutable. +Selects types that are immutable, and their state cannot be changed after creation. (shallow immutability). Stronger constraint than AreImmutableExternally() +### Condition.BeImmutableExternally +```csharp +ConditionList Condition.BeImmutableExternally() +``` +Selects types that are immutable from the outside of the given type. (shallow immutability). Weaker constraint than AreImmutable() ### Condition.BeInterfaces ```csharp ConditionList Condition.BeInterfaces() @@ -656,6 +775,11 @@ Selects types that are mutable. ConditionList Condition.BeNested() ``` Selects types that are nested. +### Condition.BeOfType +```csharp +ConditionList Condition.BeOfType(params Type[] type) +``` +Selects types that are exactly of given type. (inheritance is not considered) ### Condition.BePrivate ```csharp ConditionList Condition.BePrivate() @@ -686,6 +810,11 @@ Selects types that are have public scope. ConditionList Condition.BeSealed() ``` Selects types according that are marked as sealed. +### Condition.BeStateless +```csharp +ConditionList Condition.BeStateless() +``` +Selects types that are stateless, they do not have instance state ### Condition.BeStatic ```csharp ConditionList Condition.BeStatic() @@ -701,11 +830,21 @@ Selects types that are structures. ConditionList Condition.HaveCustomAttribute(Type attribute) ``` Selects types are decorated with a specific custom attribut. +### Condition.HaveCustomAttribute +```csharp +ConditionList Condition.HaveCustomAttribute() +``` +Selects types are decorated with a specific custom attribut. ### Condition.HaveCustomAttributeOrInherit ```csharp ConditionList Condition.HaveCustomAttributeOrInherit(Type attribute) ``` Selects types that are decorated with a specific custom attribute or derived one. +### Condition.HaveCustomAttributeOrInherit +```csharp +ConditionList Condition.HaveCustomAttributeOrInherit() +``` +Selects types that are decorated with a specific custom attribute or derived one. ### Condition.HaveDependencyOnAll ```csharp ConditionList Condition.HaveDependencyOnAll(params string[] dependencies) @@ -721,6 +860,11 @@ Selects types that have a dependency on any of the supplied types. ConditionList Condition.HaveDependencyOtherThan(params string[] dependencies) ``` Selects types that have a dependency other than any of the given dependencies. +### Condition.HaveMatchingTypeWithName +```csharp +ConditionList Condition.HaveMatchingTypeWithName(Func getMatchingTypeName) +``` +For each type, check if a matching type with the given name exists. ### Condition.HaveName ```csharp ConditionList Condition.HaveName(string name) @@ -746,16 +890,41 @@ Selects types whose names start with the specified text. ConditionList Condition.HaveSomeNonNullableMembers() ``` Selects types according to whether they have nullable members. +### Condition.HaveSourceFileNameMatchingName +```csharp +ConditionList Condition.HaveSourceFileNameMatchingName() +``` +For each type, check if the name is consistent with its source file name. +### Condition.HaveSourceFilePathMatchingNamespace +```csharp +ConditionList Condition.HaveSourceFilePathMatchingNamespace() +``` +For each type, check if the namespace is consistent with its source file path. ### Condition.ImplementInterface ```csharp ConditionList Condition.ImplementInterface(Type interfaceType) ``` Selects types that implement a particular interface. +### Condition.ImplementInterface +```csharp +ConditionList Condition.ImplementInterface() +``` +Selects types that implement a particular interface. ### Condition.Inherit ```csharp ConditionList Condition.Inherit(Type type) ``` Selects types that inherit a particular type. +### Condition.Inherit +```csharp +ConditionList Condition.Inherit() +``` +Selects types that inherit a particular type. +### Condition.MeetCustomRule +```csharp +ConditionList Condition.MeetCustomRule(Func rule) +``` +Selects types that meet a custom rule. ### Condition.MeetCustomRule ```csharp ConditionList Condition.MeetCustomRule(ICustomRule rule) @@ -801,6 +970,11 @@ Selects types that are not internal. ConditionList Condition.NotBeNested() ``` Selects types that are not nested. +### Condition.NotBeOfType +```csharp +ConditionList Condition.NotBeOfType(params Type[] type) +``` +Selects types that are not exactly of given type. (inheritance is not considered) ### Condition.NotBePrivate ```csharp ConditionList Condition.NotBePrivate() @@ -846,11 +1020,21 @@ Selects types that are not structures. ConditionList Condition.NotHaveCustomAttribute(Type attribute) ``` Selects types that are not decorated with a specific custom attribute. +### Condition.NotHaveCustomAttribute +```csharp +ConditionList Condition.NotHaveCustomAttribute() +``` +Selects types that are not decorated with a specific custom attribute. ### Condition.NotHaveCustomAttributeOrInherit ```csharp ConditionList Condition.NotHaveCustomAttributeOrInherit(Type attribute) ``` Selects types are not decorated with a specific custom attribute or derived one. +### Condition.NotHaveCustomAttributeOrInherit +```csharp +ConditionList Condition.NotHaveCustomAttributeOrInherit() +``` +Selects types are not decorated with a specific custom attribute or derived one. ### Condition.NotHaveDependencyOnAll ```csharp ConditionList Condition.NotHaveDependencyOnAll(params string[] dependencies) @@ -886,11 +1070,21 @@ Selects types whose names do not start with the specified text. ConditionList Condition.NotImplementInterface(Type interfaceType) ``` Selects types that do not implement a particular interface. +### Condition.NotImplementInterface +```csharp +ConditionList Condition.NotImplementInterface() +``` +Selects types that do not implement a particular interface. ### Condition.NotInherit ```csharp ConditionList Condition.NotInherit(Type type) ``` Selects types that do not inherit a particular type. +### Condition.NotInherit +```csharp +ConditionList Condition.NotInherit() +``` +Selects types that do not inherit a particular type. ### Condition.NotResideInNamespace ```csharp ConditionList Condition.NotResideInNamespace(string name) @@ -916,6 +1110,11 @@ Selects types that do not reside in a namespace matching a regular expression. ConditionList Condition.OnlyHaveDependencyOn(params string[] dependencies) ``` Selects types that have a dependency on any of the supplied types and cannot have any other dependency. +### Condition.OnlyHaveNonNullableMembers +```csharp +ConditionList Condition.OnlyHaveNonNullableMembers() +``` +Selects types according to whether they have only non-nullable members. ### Condition.OnlyHaveNullableMembers ```csharp ConditionList Condition.OnlyHaveNullableMembers() @@ -997,6 +1196,11 @@ Name of the type ReflectionType ``` System.Type +### IType.SourceFilePath +```csharp +SourceFilePath +``` +Path to the source file where type is defined. ## Options ### Options.Comparer diff --git a/src/NetArchTest.Rules/NetArchTest.csproj b/src/NetArchTest.Rules/NetArchTest.csproj index 511b8e0..580a79a 100644 --- a/src/NetArchTest.Rules/NetArchTest.csproj +++ b/src/NetArchTest.Rules/NetArchTest.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 1.3.8 + 1.3.9 NeVeSpl NetArchTest.eNhancedEdition A fluent API for .Net Standard that can enforce architectural rules in unit tests. Improved version, built upon NetArchTest.Rules v1.3.2.