├── .gitattributes ├── .github └── workflows │ └── net-workflow.yml ├── .gitignore ├── NetArchTest.eNhancedEdition.sln ├── README.md ├── documentation ├── api.md ├── api.nt ├── readme.nt ├── result.printscreen.png └── slices │ ├── slices.not.png │ ├── slices.ok.png │ └── slices.png ├── license.md ├── samples ├── NetArchTest.SampleLibrary │ ├── Data │ │ ├── IRepository.cs │ │ └── WidgetRepository.cs │ ├── Model │ │ └── Widget.cs │ ├── NetArchTest.SampleLibrary.csproj │ ├── Presentation │ │ └── WidgetController.cs │ └── Services │ │ ├── IWidgetService.cs │ │ └── WidgetService.cs ├── NetArchTest.SampleRules │ ├── CustomRule.cs │ ├── ExamplePolicies.cs │ ├── ExampleRules.cs │ ├── NetArchTest.SampleRules.csproj │ └── Program.cs ├── NetArchTest.SampleTests │ ├── NetArchTest.SampleTests.csproj │ ├── SampleApp_ModuleAlpha_Tests.cs │ └── SampleApp_ModuleOmega_Tests.cs ├── SampleApp.API │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── SampleApp.API.csproj │ ├── SampleApp.API.http │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── SampleApp.BuildingBlocks │ ├── Persistence │ │ └── GenericRepository.cs │ └── SampleApp.BuildingBlocks.csproj ├── SampleApp.ModuleAlpha │ ├── App │ │ └── Users │ │ │ ├── Input │ │ │ ├── CreateUser.cs │ │ │ └── ReadUsers.cs │ │ │ ├── Output │ │ │ └── UserDTO.cs │ │ │ └── UsersService.cs │ ├── Domain │ │ ├── EmailAddress.cs │ │ ├── User.cs │ │ └── UserRole.cs │ ├── Persistence │ │ └── UserManagementDbContext.cs │ ├── SampleApp.ModuleAlpha.csproj │ └── TestUtils.cs ├── SampleApp.ModuleOmega │ ├── App │ │ └── RequestHandlers │ │ │ └── Questions │ │ │ ├── QuestionOnListDTO.cs │ │ │ ├── ReadQuestionsHandler.cs │ │ │ └── ReadQuestionsQuery.cs │ ├── Domain │ │ ├── ITestCreationUoW.cs │ │ └── Questions │ │ │ ├── Answer.cs │ │ │ ├── IQuestionRepository.cs │ │ │ └── Question.cs │ ├── Persistence │ │ ├── Questions │ │ │ └── QuestionRepository.cs │ │ ├── ReadOnlyTestCreationDbContext.cs │ │ ├── TestCreationDbContext.cs │ │ └── TestCreationUoW.cs │ ├── SampleApp.ModuleOmega.csproj │ └── TestUtils.cs └── SampleApp.SharedKernel │ ├── Domain │ └── MembershipLevel.cs │ └── SampleApp.SharedKernel.csproj ├── sources └── NetArchTest │ ├── Assemblies │ ├── AssemblySpec.cs │ ├── DataLoader.cs │ ├── PublicUse │ │ ├── AssemblyContainer.cs │ │ └── TypeContainer.cs │ └── TypeSpec.cs │ ├── Condition.cs │ ├── ConditionList.cs │ ├── Condition_AccessModifiers.cs │ ├── Condition_Dependencies.cs │ ├── Condition_Metrics.cs │ ├── Condition_Names.cs │ ├── Condition_Special.cs │ ├── Condition_Traits.cs │ ├── Condition_Types.cs │ ├── Dependencies │ ├── DataStructures │ │ ├── CachedNamespaceTree.cs │ │ ├── ISearchTree.cs │ │ ├── NamespaceTree.cs │ │ └── TypeReferenceTree.cs │ ├── DependencySearch.cs │ ├── TypeCheckingContext.cs │ ├── TypeCheckingStrategy.cs │ └── TypeParser.cs │ ├── Extensions │ ├── Mono.Cecil │ │ ├── EventDefinitionExtensions.cs │ │ ├── FieldDefinitionExtensions.cs │ │ ├── MethodDefinitionExtensions.cs │ │ ├── PropertyDefinitionExtensions.cs │ │ ├── TypeDefinitionExtensions.GetLOC.cs │ │ ├── TypeDefinitionExtensions.cs │ │ └── TypeReferenceExtensions.cs │ ├── System.Collections.Generic │ │ └── IEnumerableExtensions.cs │ └── System │ │ ├── Runtime.CompilerServices │ │ └── IsExternalInit.cs │ │ ├── StringExtensions.cs │ │ └── TypeExtensions.cs │ ├── Functions │ ├── FunctionDelegates.cs │ ├── FunctionDelegates_AccessModifiers.cs │ ├── FunctionDelegates_Dependencies.cs │ ├── FunctionDelegates_Metrics.cs │ ├── FunctionDelegates_Names.cs │ ├── FunctionDelegates_Special.cs │ ├── FunctionDelegates_Traits.cs │ └── FunctionDelegates_Types.cs │ ├── IAssembly.cs │ ├── ICustomRule.cs │ ├── IDependencyFilter.cs │ ├── IType.cs │ ├── NetArchTest.csproj │ ├── Options.cs │ ├── Policies │ ├── Policy.cs │ ├── PolicyDefinition.cs │ ├── PolicyResult.cs │ ├── PolicyResults.cs │ └── PolicyTest.cs │ ├── Predicate.cs │ ├── PredicateList.cs │ ├── Predicate_AccessModifiers.cs │ ├── Predicate_Dependencies.cs │ ├── Predicate_Metrics.cs │ ├── Predicate_Names.cs │ ├── Predicate_Special.cs │ ├── Predicate_Traits.cs │ ├── Predicate_Types.cs │ ├── Resources │ └── icon.png │ ├── RuleEngine │ ├── ConditionContext.cs │ ├── FunctionSequence.cs │ ├── FunctionSequenceExecutionContext.cs │ ├── PredicateContext.cs │ └── RuleContext.cs │ ├── Slices │ ├── Model │ │ ├── Filters │ │ │ └── HaveDependenciesBetweenSlices.cs │ │ ├── IFilter.cs │ │ ├── Slice.cs │ │ ├── SliceContext.cs │ │ ├── SlicedTypes.cs │ │ ├── Slicer.cs │ │ └── TypeTestResult.cs │ ├── SliceCondition.cs │ ├── SliceConditionList.cs │ ├── SlicePredicate.cs │ └── SlicePredicateList.cs │ ├── TestResult.cs │ ├── Types.cs │ ├── Utils.cs │ └── xKey.snk └── tests ├── NetArchTest.CrossAssemblyTest.A ├── BaseClassFromA.cs ├── ClassCustomAttributeFromA.cs └── NetArchTest.CrossAssemblyTest.A.csproj ├── NetArchTest.CrossAssemblyTest.B ├── AnotherDerivedClassFromB.cs ├── DerivedClassCustomAttributeFromB.cs ├── DerivedClassFromB.cs └── NetArchTest.CrossAssemblyTest.B.csproj ├── NetArchTest.Rules.UnitTests ├── ConditionListTests.cs ├── ConditionTests.cs ├── ConditionTests_AccessModifiers.cs ├── ConditionTests_Dependencies.cs ├── ConditionTests_Metrics.cs ├── ConditionTests_Names.cs ├── ConditionTests_Special.cs ├── ConditionTests_Traits.cs ├── ConditionTests_Types.cs ├── DependencySearch │ ├── DependencyLocationTests.cs │ ├── DependencyTypeTests.cs │ ├── ScalabilityTests.cs │ ├── SearchTypeTests.cs │ ├── Utils │ │ └── DependencySearchUtils.cs │ └── VariousTests.cs ├── NetArchTest.UnitTests.csproj ├── PolicyDefinitionTests.cs ├── PredicateListTests.cs ├── PredicateTests.cs ├── PredicateTests_AccessModifiers.cs ├── PredicateTests_Dependencies.cs ├── PredicateTests_Metrics.cs ├── PredicateTests_Names.cs ├── PredicateTests_Special.cs ├── PredicateTests_Traits.cs ├── PredicateTests_Types.cs ├── SlicesTests.cs ├── TestDoubles │ └── CustomRuleExample.cs ├── TestFixtures │ ├── AccessModifiersFixture.cs │ ├── AllTypesFixture.cs │ ├── DependenciesFixture.cs │ ├── NamesFixture.cs │ ├── SpecialFixture.cs │ ├── TraitsFixture.cs │ ├── TypesFixture.cs │ └── TypesInCurrentDomainFixture.cs ├── TypesTests.cs └── xKey.snk └── NetArchTest.TestStructure ├── AccessModifiers ├── InternalClass.cs └── PublicClass.cs ├── AssemblyInfo.cs ├── Constructors ├── DefaultConstructor.cs ├── InternalConstructor.cs ├── PrivateConstructor.cs ├── PublicConstructor.cs ├── PublicConstructorOneArgument.cs └── StaticConstructor.cs ├── CustomAttributes ├── AttributePresent.cs ├── Attributes │ ├── ClassCustomAttribute.cs │ ├── GenericCustomAttribute.cs │ └── InheritClassCustomAttribute.cs ├── InheritAttributePresent.cs └── NoAttributes.cs ├── Dependencies ├── Examples │ ├── AnotherExampleDependency.cs │ ├── AttributeDependency.cs │ ├── BaseCtorCall.cs │ ├── DisposableDependency.cs │ ├── ExampleDep.cs │ ├── ExampleDependency.cs │ ├── ExampleDependencyInPartiallyMatchingNamespace.cs │ ├── ExampleStaticGenericClass.cs │ ├── ExceptionDependency.cs │ ├── Factory.cs │ ├── GenericClass.cs │ ├── IGenericInterface.cs │ ├── IgnoreCaseExampleDependency.cs │ ├── NestedDependencyTree.cs │ ├── StaticGenericDependency.cs │ └── StructDependency.cs ├── Implementation │ ├── HasAnotherDependency.cs │ ├── HasDependencies.cs │ ├── HasDependency.cs │ └── NoDependency.cs ├── Search │ ├── DependencyLocation │ │ ├── AsyncMethod.cs │ │ ├── AttributeOnClass.cs │ │ ├── AttributeOnEvent.cs │ │ ├── AttributeOnField.cs │ │ ├── AttributeOnMethod.cs │ │ ├── AttributeOnParameter.cs │ │ ├── AttributeOnProperty.cs │ │ ├── AttributeOnReturnValue.cs │ │ ├── ConstructorPrivate.cs │ │ ├── ConstructorPublic.cs │ │ ├── DefaultInterfaceMethod.cs │ │ ├── DelegateDeclaration.cs │ │ ├── EventAdd.cs │ │ ├── EventPublic.cs │ │ ├── EventRemove.cs │ │ ├── FieldPrivate.cs │ │ ├── FieldPublic.cs │ │ ├── GenericConstraintClass.cs │ │ ├── GenericConstraintMethod.cs │ │ ├── GenericMethodTypeArgument.cs │ │ ├── GenericMethodTypeArgumentOneOpenOneClosedTypeArgument.cs │ │ ├── ImplementedInterface.cs │ │ ├── IndexerPublic.cs │ │ ├── InheritedBaseClass.cs │ │ ├── InstructionCtor.cs │ │ ├── InstructionStaticClassTypeArgument.cs │ │ ├── InstructionStaticMethodTypeArgument.cs │ │ ├── InstructionThrow.cs │ │ ├── LambdaCapturedVariable.cs.cs │ │ ├── MethodArgument.cs │ │ ├── MethodParameter.cs │ │ ├── MethodPrivateBody.cs │ │ ├── MethodReturnType.cs │ │ ├── PInvoke.cs │ │ ├── PropertyGetter.cs │ │ ├── PropertyPrivate.cs │ │ ├── PropertyPublic.cs │ │ ├── PropertySetter.cs │ │ ├── StaticLocalFunction.cs │ │ ├── SwitchPatternMatching.cs │ │ ├── TryCatch.cs │ │ ├── TryCatchBlock.cs │ │ ├── TryCatchExceptionFilter.cs │ │ ├── TryFinallyBlock.cs │ │ ├── UsingStatement.cs │ │ └── Yield.cs │ ├── DependencyType │ │ ├── Array.cs │ │ ├── ArrayJagged.cs │ │ ├── ArrayMultidimensional.cs │ │ ├── ArrayOfGenerics.cs │ │ ├── ArrayOfGenericsTypeArgument.cs │ │ ├── ConstStringFieldValue.cs │ │ ├── MethodParameterIn.cs │ │ ├── MethodParameterOut.cs │ │ ├── MethodParameterRef.cs │ │ ├── NestedDependencyClass.cs │ │ ├── NestedDependencyClassGeneric.cs │ │ ├── NestedDependencyClassGenericLevel2Generic.cs │ │ ├── NestedDependencyClassLevel2Generic.cs │ │ ├── Pointer.cs │ │ ├── PointerNot.cs │ │ ├── StaticGenericClass.cs │ │ ├── Variable.cs │ │ ├── VariableGeneric.cs │ │ ├── VariableGenericTypeArgument.cs │ │ ├── VariableGenericTypeArgumentNested.cs │ │ ├── VariableRef.cs │ │ ├── VariableRefArrayOfGenericsTypeArgument.cs │ │ ├── VariableRefGenericTypeArgument.cs │ │ └── VariableTuple.cs │ ├── GenericMethodGenericParameter.cs │ └── IndirectReference.cs └── TypeOfSearch │ ├── Classes.cs │ └── Dependencies.cs ├── FalsePositives ├── ClassMatchingExample.cs ├── ModuleAsNamespacePrefix │ └── ExampleClass.cs ├── NamespaceMatch │ ├── PatternMatch.cs │ └── PatternMatchToo.cs ├── NamespaceMatchToo │ └── ExampleClass.cs ├── NamespaceMatchingExample.cs └── SystemAsNamespacePrefix │ └── ExampleClass.cs ├── File ├── Correct │ └── IncorrectSourceFileNameType.cs ├── Incorrect │ └── CorrectSourceFileNameType.cs ├── SourceFileNameType.cs └── Tests │ └── CorrectSourceFileNameTypeTests.cs ├── Inheritance ├── BaseClass.cs ├── DerivedClass.cs ├── DerivedDerivedClass.cs └── NotDerivedClass.cs ├── Interfaces ├── DoesNotImplementInterface.cs ├── IExample.cs └── ImplementsExampleInterface.cs ├── Metrics ├── ClassLarge.cs └── ClassSmall.cs ├── Mutability ├── ImmutableTypes.cs └── MutableTypes.cs ├── NameMatching ├── Namespace1 │ ├── ClassA1.cs │ ├── ClassA2.cs │ └── ClassB1.cs ├── Namespace2 │ ├── ClassA3.cs │ └── Namespace3 │ │ └── ClassB2.cs ├── Namespace3 │ ├── A │ │ ├── SomeThing.cs │ │ └── SomethingElse.cs │ └── B │ │ ├── SomeEntity.cs │ │ └── SomeIdentity.cs └── NamespaceGeneric │ ├── Namespace1 │ └── ClassA1.cs │ └── NamespaceA │ └── ClassG1.cs ├── Names ├── Namespace1 │ ├── ClassA1.cs │ ├── ClassA2.cs │ └── ClassB1.cs └── Namespace2 │ ├── ClassA1.cs │ └── ClassG1.cs ├── NetArchTest.TestStructure.csproj ├── Nullable ├── NonNullableClass1.cs ├── NonNullableClass2.cs ├── NonNullableClass3.cs ├── NonNullableClass4.cs └── NullableClass.cs ├── Slices ├── InvalidTree.cs └── ValidTree.cs ├── Stateless ├── StatefulTypes.cs └── StatelessTypes.cs ├── Traits ├── AbstractClass.cs ├── GenericClass.cs ├── PlainClass.cs ├── SealedClass.cs └── StaticClass.cs └── Types ├── ExampleClass.cs ├── ExampleDelegate.cs ├── ExampleEnum.cs ├── ExampleRecordClass.cs ├── ExampleRecordStruct.cs ├── ExampleStruct.cs └── IExampleInterface.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/net-workflow.yml: -------------------------------------------------------------------------------- 1 | name: net-workflow 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v3 17 | 18 | - name: Setup .NET 19 | uses: actions/setup-dotnet@v3 20 | with: 21 | dotnet-version: | 22 | 3.1.x 23 | 8.0.x 24 | 25 | - name: Restore dependencies 26 | run: dotnet restore 27 | 28 | - name: Build 29 | run: dotnet build --no-restore 30 | 31 | - name: Test 32 | run: dotnet test --no-build --verbosity normal 33 | -------------------------------------------------------------------------------- /documentation/api.nt: -------------------------------------------------------------------------------- 1 | {{- config.AddGeneratedFilesToVSProject = false 2 | capture output 3 | types_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^Types$" 4 | predicate_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^Predicate" 5 | condition_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^Condition" 6 | testresult_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^TestResult" 7 | itype_type = data.Interfaces | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^IType" 8 | iassembly_type = data.Interfaces | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^IAssembly" 9 | options_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^Options" 10 | 11 | all_types = types_type | Array.Concat predicate_type | Array.Concat condition_type | Array.Concat testresult_type | Array.Concat itype_type | Array.Concat iassembly_type | Array.Concat options_type 12 | }} 13 | 14 | 15 | {{- for type in all_types }} 16 | ## {{ type.Name }} 17 | 18 | {{- for method in type.Methods | Symbols.ThatArePublic | Symbols.ThatAreStatic | Array.Sort "Name" }} 19 | - [{{method.Name}}](#{{type.BareName}}{{method.BareName}}) 20 | {{- end }} 21 | {{~ for method in type.Methods | Symbols.ThatArePublic | Symbols.ThatAreNotStatic | Array.Sort "Name" }} 22 | * [{{method.Name}}](#{{type.BareName}}{{method.BareName}}) 23 | {{- end }} 24 | {{- for prop in type.Properties | Symbols.ThatArePublic | Symbols.ThatAreNotStatic | Array.Sort "Name" }} 25 | * [{{prop.Name}}](#{{type.BareName}}{{prop.BareName}}) 26 | {{- end }} 27 | {{ end}} 28 | 29 | 30 | 31 | {{- for type in all_types }} 32 | ## {{ type.Name }} 33 | 34 | {{- for method in type.Methods | Symbols.ThatArePublic | Array.Sort "Name" }} 35 | ### {{type.BareName}}.{{method.Name}} 36 | ```csharp 37 | {{method.FullName}} 38 | ``` 39 | {{ method.DocComment.Summary | String.StripNewlines }} 40 | {{- end }} 41 | 42 | {{- for prop in type.Properties | Symbols.ThatArePublic | Symbols.ThatAreNotStatic | Array.Sort "Name" }} 43 | ### {{type.BareName}}.{{prop.Name}} 44 | ```csharp 45 | {{prop.FullName}} 46 | ``` 47 | {{~ prop.DocComment.Summary | String.StripNewlines }} 48 | {{- end }} 49 | {{ end}} 50 | 51 | 52 | 53 | 54 | 55 | {{ 56 | end 57 | Save output "api.md" 58 | -}} -------------------------------------------------------------------------------- /documentation/result.printscreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeVeSpl/NetArchTest.eNhancedEdition/7f29bdf5f24368dccad27b8e3ec52a807e813504/documentation/result.printscreen.png -------------------------------------------------------------------------------- /documentation/slices/slices.not.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeVeSpl/NetArchTest.eNhancedEdition/7f29bdf5f24368dccad27b8e3ec52a807e813504/documentation/slices/slices.not.png -------------------------------------------------------------------------------- /documentation/slices/slices.ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeVeSpl/NetArchTest.eNhancedEdition/7f29bdf5f24368dccad27b8e3ec52a807e813504/documentation/slices/slices.ok.png -------------------------------------------------------------------------------- /documentation/slices/slices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeVeSpl/NetArchTest.eNhancedEdition/7f29bdf5f24368dccad27b8e3ec52a807e813504/documentation/slices/slices.png -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 NetArchTest.eNhancedEdition 4 | 5 | Copyright (c) 2018 Ben Morris (www.ben-morris.com) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleLibrary/Data/IRepository.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.SampleLibrary.Data 2 | { 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | public interface IRepository where T : class 7 | { 8 | Task> ListAsync(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleLibrary/Data/WidgetRepository.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.SampleLibrary.Data 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | using NetArchTest.SampleLibrary.Model; 7 | 8 | public class WidgetRepository : IRepository, IDisposable 9 | { 10 | public async Task> ListAsync() 11 | { 12 | // Dummy reference used to demonstrate a dependency on System.Data 13 | var table = new System.Data.DataTable(); 14 | 15 | return await Task.FromResult>( 16 | new List 17 | { 18 | new Widget{ Id = 1, Name = "Widget 1", Invalid = false }, 19 | new Widget{ Id = 2, Name = "Widget 2", Invalid = true } 20 | }); 21 | } 22 | 23 | public void Dispose() 24 | { 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleLibrary/Model/Widget.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.SampleLibrary.Model 2 | { 3 | public class Widget 4 | { 5 | public int Id 6 | { get; set; } 7 | 8 | public string Name 9 | { get; set; } 10 | 11 | public bool Invalid 12 | { get; set; } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleLibrary/NetArchTest.SampleLibrary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleLibrary/Presentation/WidgetController.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.SampleLibrary.Presentation 2 | { 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using NetArchTest.SampleLibrary.Services; 6 | 7 | public class WidgetController 8 | { 9 | protected readonly IWidgetService _service; 10 | 11 | protected readonly string _field; 12 | 13 | public WidgetController(IWidgetService service) 14 | { 15 | _service = service; 16 | } 17 | 18 | public async Task ListSomeWidgetsAsync() 19 | { 20 | var widgets = await _service.GetWidgetsAsync(); 21 | return (string.Join(", ", widgets.Select(w => w.Name))); 22 | } 23 | 24 | public string AProperty { get; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleLibrary/Services/IWidgetService.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.SampleLibrary.Services 2 | { 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | using NetArchTest.SampleLibrary.Model; 6 | 7 | public interface IWidgetService 8 | { 9 | Task> GetWidgetsAsync(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleLibrary/Services/WidgetService.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.SampleLibrary.Services 2 | { 3 | using NetArchTest.SampleLibrary.Data; 4 | using NetArchTest.SampleLibrary.Model; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | public sealed class WidgetService : IWidgetService 9 | { 10 | private readonly IRepository _repository; 11 | 12 | public WidgetService(IRepository repository) 13 | { 14 | _repository = repository; 15 | } 16 | 17 | public async Task> GetWidgetsAsync() 18 | { 19 | return await _repository.ListAsync(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleRules/CustomRule.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.SampleRules 2 | { 3 | using Mono.Cecil; 4 | using NetArchTest.Rules; 5 | 6 | /// 7 | /// A custom rule that can be used to extend NetArchTest. 8 | /// 9 | public class CustomRule : ICustomRule 10 | { 11 | /// 12 | /// This method will be executed against every type - so take care over external look-ups, etc 13 | /// 14 | public bool MeetsRule(TypeDefinition type) 15 | { 16 | return true; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleRules/NetArchTest.SampleRules.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleRules/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetArchTest.SampleRules 4 | { 5 | internal class Program 6 | { 7 | private static void Main(string[] args) 8 | { 9 | ExampleRules.Run(); 10 | ExamplePolicies.Run(); 11 | Console.ReadKey(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /samples/NetArchTest.SampleTests/NetArchTest.SampleTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | disable 6 | enable 7 | 8 | false 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /samples/NetArchTest.SampleTests/SampleApp_ModuleAlpha_Tests.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using MediatR; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using NetArchTest.Rules; 5 | using SampleApp.ModuleAlpha; 6 | 7 | namespace NetArchTest.SampleTests 8 | { 9 | [TestClass] 10 | public class SampleApp_ModuleAlpha_Tests 11 | { 12 | static readonly Assembly AssemblyUnderTest = typeof(TestUtils).Assembly; 13 | 14 | [TestMethod] 15 | public void PersistenceIsNotAccessibleFromOutsideOfModuleExceptOfDbContext() 16 | { 17 | var result = Types.InAssembly(AssemblyUnderTest) 18 | .That() 19 | .ResideInNamespace("SampleApp.ModuleAlpha.Persistence") 20 | .And() 21 | .DoNotHaveNameEndingWith("DbContext") 22 | .Should() 23 | .NotBePublic() 24 | .GetResult(); 25 | 26 | Assert.IsTrue(result.IsSuccessful); 27 | } 28 | 29 | [TestMethod] 30 | public void DomainIsIndependent() 31 | { 32 | var result = Types.InAssembly(AssemblyUnderTest) 33 | .That() 34 | .ResideInNamespace("SampleApp.ModuleAlpha.Domain") 35 | .ShouldNot() 36 | .HaveDependencyOtherThan( 37 | "System", 38 | "SampleApp.ModuleAlpha.Domain", 39 | "SampleApp.SharedKernel.Domain", 40 | "SampleApp.BuildingBlocks.Domain" 41 | ) 42 | .GetResult(); 43 | 44 | Assert.IsTrue(result.IsSuccessful, "Domain has lost its independence!"); 45 | } 46 | 47 | } 48 | } -------------------------------------------------------------------------------- /samples/NetArchTest.SampleTests/SampleApp_ModuleOmega_Tests.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using MediatR; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using NetArchTest.Rules; 5 | using SampleApp.ModuleOmega; 6 | 7 | 8 | namespace NetArchTest.SampleTests 9 | { 10 | [TestClass] 11 | public class SampleApp_ModuleOmega_Tests 12 | { 13 | static readonly Assembly AssemblyUnderTest = typeof(TestUtils).Assembly; 14 | 15 | [TestMethod] 16 | public void RequestHandlersShouldBeSealed() 17 | { 18 | var result = Types.InAssembly(AssemblyUnderTest) 19 | .That() 20 | .ImplementInterface(typeof(IRequestHandler<,>)) 21 | .Should() 22 | .BeSealed() 23 | .GetResult(); 24 | 25 | Assert.IsTrue(result.IsSuccessful); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /samples/SampleApp.API/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace SampleApp.API.Controllers 4 | { 5 | [ApiController] 6 | [Route("[controller]")] 7 | public class WeatherForecastController : ControllerBase 8 | { 9 | private static readonly string[] Summaries = new[] 10 | { 11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 12 | }; 13 | 14 | private readonly ILogger _logger; 15 | 16 | public WeatherForecastController(ILogger logger) 17 | { 18 | _logger = logger; 19 | } 20 | 21 | [HttpGet] 22 | public IEnumerable Get() 23 | { 24 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 25 | { 26 | Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), 27 | TemperatureC = Random.Shared.Next(-20, 55), 28 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] 29 | }) 30 | .ToArray(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /samples/SampleApp.API/Program.cs: -------------------------------------------------------------------------------- 1 | namespace SampleApp.API 2 | { 3 | public class Program 4 | { 5 | public static void Main(string[] args) 6 | { 7 | var builder = WebApplication.CreateBuilder(args); 8 | 9 | // Add services to the container. 10 | 11 | builder.Services.AddControllers(); 12 | 13 | var app = builder.Build(); 14 | 15 | // Configure the HTTP request pipeline. 16 | 17 | app.UseHttpsRedirection(); 18 | 19 | app.UseAuthorization(); 20 | 21 | 22 | app.MapControllers(); 23 | 24 | app.Run(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/SampleApp.API/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:5195", 8 | "sslPort": 44313 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "weatherforecast", 17 | "applicationUrl": "http://localhost:5275", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "https": { 23 | "commandName": "Project", 24 | "dotnetRunMessages": true, 25 | "launchBrowser": true, 26 | "launchUrl": "weatherforecast", 27 | "applicationUrl": "https://localhost:7234;http://localhost:5275", 28 | "environmentVariables": { 29 | "ASPNETCORE_ENVIRONMENT": "Development" 30 | } 31 | }, 32 | "IIS Express": { 33 | "commandName": "IISExpress", 34 | "launchBrowser": true, 35 | "launchUrl": "weatherforecast", 36 | "environmentVariables": { 37 | "ASPNETCORE_ENVIRONMENT": "Development" 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /samples/SampleApp.API/SampleApp.API.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/SampleApp.API/SampleApp.API.http: -------------------------------------------------------------------------------- 1 | @SampleApp.API_HostAddress = http://localhost:5275 2 | 3 | GET {{SampleApp.API_HostAddress}}/weatherforecast/ 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /samples/SampleApp.API/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | namespace SampleApp.API 2 | { 3 | public class WeatherForecast 4 | { 5 | public DateOnly Date { get; set; } 6 | 7 | public int TemperatureC { get; set; } 8 | 9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 10 | 11 | public string? Summary { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/SampleApp.API/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /samples/SampleApp.API/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /samples/SampleApp.BuildingBlocks/Persistence/GenericRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.EntityFrameworkCore; 7 | 8 | namespace SampleApp.BuildingBlocks.Persistence 9 | { 10 | public abstract class GenericRepository where TEntity : class 11 | where TContext : DbContext 12 | { 13 | protected readonly TContext context; 14 | 15 | 16 | public GenericRepository(TContext context) 17 | { 18 | this.context = context; 19 | } 20 | 21 | 22 | public void Add(TEntity entity) 23 | { 24 | context.Set().Add(entity); 25 | } 26 | public TEntity GetById(long id) 27 | { 28 | return context.Set().Find(id); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /samples/SampleApp.BuildingBlocks/SampleApp.BuildingBlocks.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleAlpha/App/Users/Input/CreateUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleApp.ModuleAlpha.App.Users.Input 8 | { 9 | public class CreateUser 10 | { 11 | public string Name { get; set; } = String.Empty; 12 | public string EmailAddress { get; set; } = String.Empty; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleAlpha/App/Users/Input/ReadUsers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleApp.ModuleAlpha.App.Users.Input 8 | { 9 | public class ReadUsers 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleAlpha/App/Users/Output/UserDTO.cs: -------------------------------------------------------------------------------- 1 | using SampleApp.ModuleAlpha.Domain; 2 | using SampleApp.SharedKernel.Domain; 3 | 4 | namespace SampleApp.ModuleAlpha.App.Users.Output 5 | { 6 | public class UserDTO 7 | { 8 | public long UserId { get; set; } 9 | public string? Name { get; set; } 10 | public string EmailAddress { get; set; } = String.Empty; 11 | 12 | public UserRole Role { get; set; } 13 | public MembershipLevel MembershipLevel { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleAlpha/App/Users/UsersService.cs: -------------------------------------------------------------------------------- 1 | using SampleApp.ModuleAlpha.App.Users.Input; 2 | using SampleApp.ModuleAlpha.App.Users.Output; 3 | 4 | namespace SampleApp.ModuleAlpha.App.Users 5 | { 6 | internal sealed class UsersService 7 | { 8 | 9 | public async Task CreateUser(CreateUser createUser) 10 | { 11 | return 69; 12 | } 13 | 14 | 15 | public async Task> GetUsers(ReadUsers readUsers) 16 | { 17 | var result = new List(); 18 | return result; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleAlpha/Domain/EmailAddress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleApp.ModuleAlpha.Domain 8 | { 9 | public sealed class EmailAddress 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleAlpha/Domain/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Mail; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace SampleApp.ModuleAlpha.Domain 9 | { 10 | public sealed class User 11 | { 12 | public string? Name { get; set; } 13 | public EmailAddress EmailAddress { get; set; } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleAlpha/Domain/UserRole.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleApp.ModuleAlpha.Domain 8 | { 9 | public enum UserRole 10 | { 11 | Regular, 12 | Admin 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleAlpha/Persistence/UserManagementDbContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.EntityFrameworkCore; 7 | using SampleApp.ModuleAlpha.Domain; 8 | 9 | namespace SampleApp.ModuleAlpha.Persistence 10 | { 11 | public class UserManagementDbContext 12 | { 13 | public DbSet Users { get; private set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleAlpha/SampleApp.ModuleAlpha.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleAlpha/TestUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | [assembly: InternalsVisibleTo("NetArchTest.SampleTests")] 9 | namespace SampleApp.ModuleAlpha 10 | { 11 | internal class TestUtils 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/App/RequestHandlers/Questions/QuestionOnListDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleApp.ModuleOmega.App.RequestHandlers.Questions 8 | { 9 | internal class QuestionOnListDTO 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/App/RequestHandlers/Questions/ReadQuestionsHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using MediatR; 7 | using SampleApp.ModuleOmega.Persistence; 8 | 9 | namespace SampleApp.ModuleOmega.App.RequestHandlers.Questions 10 | { 11 | internal sealed class ReadQuestionsHandler : IRequestHandler> 12 | { 13 | private readonly ReadOnlyTestCreationDbContext context; 14 | 15 | public ReadQuestionsHandler(ReadOnlyTestCreationDbContext context) 16 | { 17 | this.context = context; 18 | } 19 | 20 | 21 | public async Task> Handle(ReadQuestionsQuery query, CancellationToken cancellationToken) 22 | { 23 | 24 | 25 | return null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/App/RequestHandlers/Questions/ReadQuestionsQuery.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using MediatR; 7 | 8 | namespace SampleApp.ModuleOmega.App.RequestHandlers.Questions 9 | { 10 | internal class ReadQuestionsQuery : IRequest> 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/Domain/ITestCreationUoW.cs: -------------------------------------------------------------------------------- 1 | using SampleApp.ModuleOmega.Domain.Questions; 2 | 3 | namespace SampleApp.ModuleOmega.Domain 4 | { 5 | internal interface ITestCreationUoW 6 | { 7 | IQuestionRepository Questions { get; } 8 | 9 | Task Save(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/Domain/Questions/Answer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleApp.ModuleOmega.Domain.Questions 8 | { 9 | internal sealed class Answer 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/Domain/Questions/IQuestionRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleApp.ModuleOmega.Domain.Questions 8 | { 9 | internal interface IQuestionRepository 10 | { 11 | Question GetByIdWithAnswers(long id); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/Domain/Questions/Question.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleApp.ModuleOmega.Domain.Questions 8 | { 9 | internal sealed class Question 10 | { 11 | private readonly List _answers = new List(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/Persistence/Questions/QuestionRepository.cs: -------------------------------------------------------------------------------- 1 | using SampleApp.BuildingBlocks.Persistence; 2 | using SampleApp.ModuleOmega.Domain.Questions; 3 | 4 | namespace SampleApp.ModuleOmega.Persistence.Questions 5 | { 6 | internal sealed class QuestionRepository : GenericRepository, IQuestionRepository 7 | { 8 | public QuestionRepository(TestCreationDbContext context) : base(context) 9 | { 10 | 11 | } 12 | 13 | 14 | public Question GetByIdWithAnswers(long id) 15 | { 16 | return null; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/Persistence/ReadOnlyTestCreationDbContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.EntityFrameworkCore; 7 | 8 | namespace SampleApp.ModuleOmega.Persistence 9 | { 10 | internal sealed class ReadOnlyTestCreationDbContext : TestCreationDbContext 11 | { 12 | 13 | 14 | public ReadOnlyTestCreationDbContext(DbContextOptions options) : base(options) 15 | { 16 | ChangeTracker.LazyLoadingEnabled = false; 17 | ChangeTracker.AutoDetectChangesEnabled = false; 18 | ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; 19 | } 20 | 21 | protected override void OnModelCreating(ModelBuilder modelBuilder) 22 | { 23 | base.OnModelCreating(modelBuilder); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/Persistence/TestCreationDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.ChangeTracking; 3 | using SampleApp.ModuleOmega.Domain.Questions; 4 | 5 | namespace SampleApp.ModuleOmega.Persistence 6 | { 7 | internal class TestCreationDbContext : DbContext 8 | { 9 | public DbSet Questions { get; protected set; } 10 | 11 | 12 | public TestCreationDbContext(DbContextOptions options) : base(options) 13 | { 14 | ChangeTracker.DeleteOrphansTiming = CascadeTiming.OnSaveChanges; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/Persistence/TestCreationUoW.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.EntityFrameworkCore.ChangeTracking; 7 | using Microsoft.EntityFrameworkCore; 8 | using SampleApp.ModuleOmega.Domain; 9 | using SampleApp.ModuleOmega.Domain.Questions; 10 | 11 | namespace SampleApp.ModuleOmega.Persistence 12 | { 13 | internal sealed class TestCreationUoW : ITestCreationUoW, IDisposable 14 | { 15 | private readonly TestCreationDbContext context; 16 | private readonly Lazy questions; 17 | 18 | 19 | public IQuestionRepository Questions { get => questions.Value; } 20 | 21 | 22 | public Task Save() 23 | { 24 | return context.SaveChangesAsync(); 25 | } 26 | 27 | 28 | 29 | 30 | 31 | public void Dispose() 32 | { 33 | context.Dispose(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/SampleApp.ModuleOmega.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /samples/SampleApp.ModuleOmega/TestUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | [assembly: InternalsVisibleTo("NetArchTest.SampleTests")] 9 | namespace SampleApp.ModuleOmega 10 | { 11 | internal class TestUtils 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/SampleApp.SharedKernel/Domain/MembershipLevel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleApp.SharedKernel.Domain 8 | { 9 | public enum MembershipLevel 10 | { 11 | Regular, 12 | Silver, 13 | Gold 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/SampleApp.SharedKernel/SampleApp.SharedKernel.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sources/NetArchTest/Assemblies/AssemblySpec.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Mono.Cecil; 4 | using NetArchTest.Assemblies.PublicUse; 5 | using NetArchTest.Rules; 6 | 7 | namespace NetArchTest.Assemblies 8 | { 9 | internal sealed class AssemblySpec 10 | { 11 | private AssemblyDefinition assemblyDefinition; 12 | private IReadOnlyList typeDefinitions; 13 | private List referenced = new List(); 14 | 15 | public string FullName => assemblyDefinition.FullName; 16 | 17 | 18 | 19 | public AssemblySpec(AssemblyDefinition assemblyDefinition, IEnumerable typeDefinitions) 20 | { 21 | this.assemblyDefinition = assemblyDefinition; 22 | this.typeDefinitions = typeDefinitions.ToArray(); 23 | } 24 | 25 | public void AddRef(AssemblySpec assemblySpec) 26 | { 27 | referenced.Add(assemblySpec); 28 | } 29 | 30 | public IEnumerable GetTypes() 31 | { 32 | return typeDefinitions.Select(x => new TypeSpec(x)); 33 | } 34 | 35 | 36 | 37 | public IAssembly CreateWrapper() 38 | { 39 | return new AssemblyContainer(assemblyDefinition); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sources/NetArchTest/Assemblies/PublicUse/AssemblyContainer.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Mono.Cecil; 3 | using NetArchTest.Rules; 4 | 5 | namespace NetArchTest.Assemblies.PublicUse 6 | { 7 | [DebuggerDisplay("{FullName}")] 8 | internal sealed class AssemblyContainer : IAssembly 9 | { 10 | [DebuggerBrowsable(DebuggerBrowsableState.Never)] 11 | private readonly AssemblyDefinition _monoAssemblyDefinition; 12 | 13 | 14 | public string FullName => _monoAssemblyDefinition.FullName; 15 | 16 | 17 | public AssemblyContainer(AssemblyDefinition assemblyDefinition) 18 | { 19 | _monoAssemblyDefinition = assemblyDefinition; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sources/NetArchTest/Assemblies/PublicUse/TypeContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using Mono.Cecil; 4 | using NetArchTest.Rules; 5 | 6 | namespace NetArchTest.Assemblies.PublicUse 7 | { 8 | [DebuggerDisplay("{FullName}")] 9 | internal sealed class TypeContainer : IType 10 | { 11 | [DebuggerBrowsable(DebuggerBrowsableState.Never)] 12 | private readonly TypeDefinition _monoTypeDefinition; 13 | [DebuggerBrowsable(DebuggerBrowsableState.Never)] 14 | private readonly Lazy _reflactionType; 15 | [DebuggerBrowsable(DebuggerBrowsableState.Never)] 16 | private readonly Lazy _sourceFilePath; 17 | 18 | 19 | public Type ReflectionType => _reflactionType.Value; 20 | public string FullName => _monoTypeDefinition.FullName; 21 | public string Name => _monoTypeDefinition.Name; 22 | public string Explanation { get; } 23 | public string SourceFilePath => _sourceFilePath.Value; 24 | 25 | 26 | internal TypeContainer(TypeDefinition monoTypeDefinition, string explanation) 27 | { 28 | _monoTypeDefinition = monoTypeDefinition; 29 | _reflactionType = new Lazy(() => 30 | { 31 | try 32 | { 33 | return _monoTypeDefinition.ToType(); 34 | } 35 | catch 36 | { 37 | } 38 | return null; 39 | }); 40 | _sourceFilePath = new Lazy(() => _monoTypeDefinition.GetFilePath()); 41 | Explanation = explanation; 42 | } 43 | 44 | 45 | public static implicit operator Type(TypeContainer type) 46 | { 47 | return type.ReflectionType; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Assemblies/TypeSpec.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using Mono.Cecil; 4 | using NetArchTest.Assemblies.PublicUse; 5 | 6 | namespace NetArchTest.Assemblies 7 | { 8 | [DebuggerDisplay("TypeSpec: {FullName}")] 9 | internal sealed class TypeSpec 10 | { 11 | private readonly Lazy _sourceFilePath; 12 | 13 | public TypeDefinition Definition { get; } 14 | public string FullName => Definition.FullName; 15 | // Only for use by FunctionSequence 16 | internal bool IsSelectedInMarkPhase { get; set; } 17 | // Can be use by any function 18 | internal bool IsPassing { get; set; } 19 | public string Explanation { get; set; } 20 | public string SourceFilePath => _sourceFilePath.Value; 21 | 22 | 23 | public TypeSpec(TypeDefinition definition) 24 | { 25 | Definition = definition; 26 | _sourceFilePath = new Lazy(() => Definition.GetFilePath()); 27 | } 28 | 29 | 30 | 31 | public TypeContainer CreateWrapper() 32 | { 33 | return new TypeContainer(Definition, Explanation); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /sources/NetArchTest/ConditionList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NetArchTest.RuleEngine; 4 | 5 | namespace NetArchTest.Rules 6 | { 7 | /// 8 | /// A set of conditions and types that have have conjunctions (i.e. "and", "or") and executors (i.e. Types(), GetResult()) applied to them. 9 | /// 10 | public sealed class ConditionList 11 | { 12 | private readonly RuleContext rule; 13 | 14 | 15 | internal ConditionList(RuleContext rule) 16 | { 17 | this.rule = rule; 18 | } 19 | 20 | 21 | /// 22 | /// Specifies that any subsequent condition should be treated as an "and" condition. 23 | /// 24 | /// An set of conditions that can be applied to a list of classes. 25 | /// And() has higher priority than Or() and it is computed first. 26 | public Condition And() 27 | { 28 | return new Condition(rule); 29 | } 30 | 31 | /// 32 | /// Specifies that any subsequent conditions should be treated as part of an "or" condition. 33 | /// 34 | /// An set of conditions that can be applied to a list of classes. 35 | public Condition Or() 36 | { 37 | // Create a new group of functions - this has the effect of creating an "or" condition 38 | rule.ConditionContext.Sequence.CreateGroup(); 39 | return new Condition(rule); 40 | } 41 | 42 | 43 | /// 44 | /// Returns an indication of whether all the selected types satisfy the conditions. 45 | /// 46 | /// An indication of whether the conditions are true, along with a list of types failing the check if they are not. 47 | public TestResult GetResult(Options options = null) 48 | { 49 | return rule.GetResult(options); 50 | } 51 | 52 | /// 53 | /// Returns the list of types that satisfy the conditions. 54 | /// 55 | /// A list of types. 56 | public IEnumerable GetTypes(Options options = null) 57 | { 58 | return rule.GetTypes(options); 59 | } 60 | 61 | 62 | internal IEnumerable GetReflectionTypes(Options options = null) 63 | { 64 | return rule.GetReflectionTypes(options); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Condition_Metrics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using NetArchTest.Functions; 5 | 6 | namespace NetArchTest.Rules 7 | { 8 | public sealed partial class Condition 9 | { 10 | /// 11 | /// Selects types that have more logical lines of code than a given number 12 | /// 13 | /// An updated set of conditions that can be applied to a list of types. 14 | public ConditionList HaveNumberOfLinesOfCodeGreaterThan(int number) 15 | { 16 | AddFunctionCall((context, inputTypes) => FunctionDelegates.HaveNumberOfLinesOfCodeFewerThan(context, inputTypes, number, false)); 17 | return CreateConditionList(); 18 | } 19 | 20 | /// 21 | /// Selects types that have fewer logical lines of code than a given number 22 | /// 23 | /// An updated set of conditions that can be applied to a list of types. 24 | public ConditionList HaveNumberOfLinesOfCodeLowerThan(int number) 25 | { 26 | AddFunctionCall((context, inputTypes) => FunctionDelegates.HaveNumberOfLinesOfCodeFewerThan(context, inputTypes, number, true)); 27 | return CreateConditionList(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sources/NetArchTest/Dependencies/DataStructures/CachedNamespaceTree.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.Dependencies.DataStructures 2 | { 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using Mono.Cecil; 6 | 7 | internal class CachedNamespaceTree : ISearchTree 8 | { 9 | /// The list of dependencies being searched for. 10 | private readonly NamespaceTree _searchTree; 11 | 12 | public int TerminatedNodesCount { get => _searchTree.TerminatedNodesCount; } 13 | 14 | 15 | public CachedNamespaceTree(IEnumerable dependencies) 16 | { 17 | _searchTree = new NamespaceTree(dependencies, true); 18 | } 19 | 20 | 21 | /// 22 | /// Searching search tree is costly (it requires a lot of operations on strings like SubString, IndexOf). 23 | /// For a given type we always get the same answer, so let us cache what search tree returns. 24 | /// 25 | private readonly TypeReferenceTree _cachedAnswersFromSearchTree = new TypeReferenceTree(); 26 | public IEnumerable GetAllMatchingNames(TypeReference type) 27 | { 28 | var node = _cachedAnswersFromSearchTree.GetNode(type); 29 | if (node.value == null) 30 | { 31 | node.value = _searchTree.GetAllMatchingNames(type).ToArray(); 32 | } 33 | return node.value; 34 | } 35 | 36 | public IEnumerable GetAllMatchingNames(string fullName) 37 | { 38 | return _searchTree.GetAllMatchingNames(fullName).ToArray(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Dependencies/DataStructures/ISearchTree.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.Dependencies.DataStructures 2 | { 3 | using System.Collections.Generic; 4 | using Mono.Cecil; 5 | 6 | internal interface ISearchTree 7 | { 8 | IEnumerable GetAllMatchingNames(TypeReference type); 9 | IEnumerable GetAllMatchingNames(string fullName); 10 | int TerminatedNodesCount { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sources/NetArchTest/Extensions/Mono.Cecil/EventDefinitionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Mono.Cecil 2 | { 3 | internal static class EventDefinitionExtensions 4 | { 5 | public static bool IsReadonly(this EventDefinition propertyDefinition) 6 | { 7 | if (propertyDefinition.AddMethod == null) 8 | { 9 | return true; 10 | } 11 | 12 | return false; 13 | } 14 | public static bool IsReadonlyExternally(this EventDefinition propertyDefinition) 15 | { 16 | if (propertyDefinition.AddMethod?.IsPublic == false) 17 | { 18 | return true; 19 | } 20 | return propertyDefinition.IsReadonly(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sources/NetArchTest/Extensions/Mono.Cecil/FieldDefinitionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Mono.Cecil 2 | { 3 | static internal class FieldDefinitionExtensions 4 | { 5 | public static bool IsReadonly(this FieldDefinition fieldDefinition) 6 | { 7 | return fieldDefinition.IsInitOnly || fieldDefinition.HasConstant || fieldDefinition.IsCompilerControlled; 8 | } 9 | public static bool IsReadonlyExternally(this FieldDefinition fieldDefinition) 10 | { 11 | if (!fieldDefinition.IsPublic) 12 | { 13 | return true; 14 | } 15 | return fieldDefinition.IsReadonly(); 16 | } 17 | 18 | 19 | public static bool IsNullable(this FieldDefinition fieldDefinition) 20 | { 21 | return fieldDefinition.FieldType.IsNullable(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Extensions/Mono.Cecil/MethodDefinitionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.CodeDom.Compiler; 2 | using System.Linq; 3 | using System.Runtime.CompilerServices; 4 | using Mono.Cecil; 5 | 6 | namespace NetArchTest.Extensions.Mono.Cecil 7 | { 8 | internal static class MethodDefinitionExtensions 9 | { 10 | public static bool IsGeneratedCode(this MethodDefinition method) 11 | { 12 | if (method == null) 13 | return false; 14 | 15 | if (method.HasCustomAttributes == false) 16 | return false; 17 | 18 | return method.CustomAttributes.Any(x => x?.AttributeType?.FullName == typeof(CompilerGeneratedAttribute).FullName || x?.AttributeType?.FullName == typeof(GeneratedCodeAttribute).FullName); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Extensions/Mono.Cecil/PropertyDefinitionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Mono.Cecil 2 | { 3 | static internal class PropertyDefinitionExtensions 4 | { 5 | public static bool IsReadonly(this PropertyDefinition propertyDefinition) 6 | { 7 | if (propertyDefinition.SetMethod == null) 8 | { 9 | return true; 10 | } 11 | else 12 | { 13 | if (propertyDefinition.IsInitOnly()) 14 | { 15 | return true; 16 | } 17 | } 18 | 19 | return false; 20 | } 21 | public static bool IsReadonlyExternally(this PropertyDefinition propertyDefinition) 22 | { 23 | if (propertyDefinition.SetMethod?.IsPublic == false) 24 | { 25 | return true; 26 | } 27 | return propertyDefinition.IsReadonly(); 28 | } 29 | 30 | public static bool IsInitOnly(this PropertyDefinition propertyDefinition) 31 | { 32 | return propertyDefinition.SetMethod?.ReturnType.FullName == "System.Void modreq(System.Runtime.CompilerServices.IsExternalInit)"; 33 | } 34 | 35 | 36 | public static bool IsNullable(this PropertyDefinition propertyDefinition) 37 | { 38 | return propertyDefinition.PropertyType.IsNullable(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Extensions/Mono.Cecil/TypeDefinitionExtensions.GetLOC.cs: -------------------------------------------------------------------------------- 1 | using Mono.Cecil; 2 | 3 | namespace NetArchTest.Extensions.Mono.Cecil 4 | { 5 | public static partial class TypeDefinitionExtensions 6 | { 7 | internal static int GetNumberOfLogicalLinesOfCode(this TypeDefinition type) 8 | { 9 | int count = 0; 10 | 11 | if (type.HasMethods) 12 | { 13 | foreach (var method in type.Methods) 14 | { 15 | if (!method.HasBody) continue; 16 | if (method.IsGeneratedCode()) continue; 17 | if (method.DeclaringType.Module.HasSymbols == false) continue; 18 | 19 | var methodLLOC = CountLogicalLinesOfCode(method); 20 | count += methodLLOC; 21 | } 22 | } 23 | 24 | return count; 25 | } 26 | 27 | 28 | private static int CountLogicalLinesOfCode(MethodDefinition method) 29 | { 30 | int count = 0; 31 | int lastLine = int.MinValue; 32 | 33 | foreach (var instruction in method.Body.Instructions) 34 | { 35 | var sequencePoint = method.DebugInformation.GetSequencePoint(instruction); 36 | if (sequencePoint == null) 37 | continue; 38 | 39 | int line = sequencePoint.StartLine; 40 | // special value for PDB (so that debuggers can ignore a line) 41 | if (line == 0xFEEFEE) 42 | continue; 43 | 44 | if (line > lastLine) 45 | count++; 46 | 47 | lastLine = line; 48 | } 49 | return count; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Extensions/System.Collections.Generic/IEnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace System.Collections.Generic 2 | { 3 | internal static class IEnumerableExtensions 4 | { 5 | public static void ForEach(this IEnumerable list, Action action) 6 | { 7 | foreach (T item in list) 8 | { 9 | action(item); 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Extensions/System/Runtime.CompilerServices/IsExternalInit.cs: -------------------------------------------------------------------------------- 1 | namespace System.Runtime.CompilerServices 2 | { 3 | internal static class IsExternalInit { } 4 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Extensions/System/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace System 6 | { 7 | internal static class StringExtensions 8 | { 9 | public static string RemoveGenericPart(this string name) 10 | { 11 | if (string.IsNullOrEmpty(name)) 12 | return name; 13 | 14 | int index = name.LastIndexOf('`'); 15 | if (index > 0) 16 | { 17 | return name.Substring(0, index); 18 | } 19 | return name; 20 | } 21 | 22 | 23 | public static string RuntimeNameToReflectionName(this string cliName) 24 | { 25 | // Nested types have a forward slash that should be replaced with "+" 26 | // C++ template instantiations contain comma separator for template arguments, 27 | // getting address operators and pointer type designations which should be prefixed by backslash 28 | var fullName = cliName.Replace("/", "+") 29 | .Replace(",", "\\,") 30 | .Replace("&", "\\&") 31 | .Replace("*", "\\*"); 32 | return fullName; 33 | } 34 | 35 | public static string ReflectionNameToRuntimeName(this string typeName) 36 | { 37 | var fullName = typeName.Replace("+", "/"); 38 | return fullName; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /sources/NetArchTest/Extensions/System/TypeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Mono.Cecil; 3 | using NetArchTest.Dependencies; 4 | 5 | namespace System 6 | { 7 | static internal class TypeExtensions 8 | { 9 | public static TypeDefinition ToTypeDefinition(this Type type) 10 | { 11 | var reflectionAssembly = Assembly.GetAssembly(type); 12 | var assemblyDef = AssemblyDefinition.ReadAssembly(reflectionAssembly.Location); 13 | 14 | foreach (var module in assemblyDef.Modules) 15 | { 16 | var typeRef = module.GetType(type.FullName, true); 17 | var typeDef = typeRef?.Resolve(); 18 | if (typeDef is not null) return typeDef; 19 | } 20 | 21 | return null; 22 | } 23 | 24 | public static string GetNormalizedFullName(this Type type) 25 | { 26 | var name = type.Name; 27 | var fullName = type.FullName; 28 | var toString = type.ToString(); 29 | var assemblyQualifiedName = type.AssemblyQualifiedName; 30 | 31 | var monoName = TypeParser.ParseReflectionNameToRuntimeName(type.FullName); 32 | 33 | if (type.IsGenericType && type.ContainsGenericParameters == false) 34 | { 35 | //return toString.ReflectionNameToRuntimeName(); 36 | } 37 | 38 | return monoName; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Functions/FunctionDelegates_Metrics.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using NetArchTest.Assemblies; 4 | using NetArchTest.Extensions.Mono.Cecil; 5 | using NetArchTest.RuleEngine; 6 | 7 | namespace NetArchTest.Functions 8 | { 9 | internal static partial class FunctionDelegates 10 | { 11 | 12 | internal static IEnumerable HaveNumberOfLinesOfCodeFewerThan(FunctionSequenceExecutionContext context, IEnumerable input, int number, bool condition) 13 | { 14 | if (condition) 15 | { 16 | return input.Where(c => c.Definition.GetNumberOfLogicalLinesOfCode() < number); 17 | } 18 | else 19 | { 20 | return input.Where(c => !(c.Definition.GetNumberOfLogicalLinesOfCode() < number)); 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Functions/FunctionDelegates_Traits.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Mono.Cecil; 4 | using Mono.Cecil.Rocks; 5 | using NetArchTest.Assemblies; 6 | 7 | namespace NetArchTest.Functions 8 | { 9 | internal static partial class FunctionDelegates 10 | { 11 | // Modifiers & Generic 12 | 13 | internal static IEnumerable BeAbstract(IEnumerable input, bool condition) 14 | { 15 | if (condition) 16 | { 17 | return input.Where(c => ClassIsAbstract(c.Definition)); 18 | } 19 | else 20 | { 21 | return input.Where(c => !ClassIsAbstract(c.Definition)); 22 | } 23 | 24 | static bool ClassIsAbstract(TypeDefinition c) => c.IsAbstract && !c.IsSealed; 25 | } 26 | 27 | internal static IEnumerable BeStatic(IEnumerable input, bool condition) 28 | { 29 | if (condition) 30 | { 31 | return input.Where(ClassIsStatic); 32 | } 33 | else 34 | { 35 | return input.Where(c => !ClassIsStatic(c)); 36 | } 37 | 38 | static bool ClassIsStatic(TypeSpec c) => c.Definition.IsAbstract && c.Definition.IsSealed && !c.Definition.IsInterface && !c.Definition.GetConstructors().Any(m => m.IsPublic); 39 | } 40 | 41 | internal static IEnumerable BeSealed(IEnumerable input, bool condition) 42 | { 43 | if (condition) 44 | { 45 | return input.Where(c => ClassIsSealed(c.Definition)); 46 | } 47 | else 48 | { 49 | return input.Where(c => !ClassIsSealed(c.Definition)); 50 | } 51 | 52 | static bool ClassIsSealed(TypeDefinition c) => !c.IsAbstract && c.IsSealed; 53 | } 54 | 55 | internal static IEnumerable BeGeneric(IEnumerable input, bool condition) 56 | { 57 | if (condition) 58 | { 59 | return input.Where(c => c.Definition.HasGenericParameters); 60 | } 61 | else 62 | { 63 | return input.Where(c => !c.Definition.HasGenericParameters); 64 | } 65 | } 66 | 67 | // todo 68 | 69 | internal static IEnumerable BeRecord(IEnumerable input, bool condition) 70 | { 71 | if (condition) 72 | { 73 | return Enumerable.Empty(); 74 | } 75 | else 76 | { 77 | return Enumerable.Empty(); 78 | } 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Functions/FunctionDelegates_Types.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Mono.Cecil; 4 | using NetArchTest.Assemblies; 5 | 6 | namespace NetArchTest.Functions 7 | { 8 | internal static partial class FunctionDelegates 9 | { 10 | internal static IEnumerable BeClass(IEnumerable input, bool condition) 11 | { 12 | if (condition) 13 | { 14 | return input.Where(c => IsClass(c.Definition)); 15 | } 16 | else 17 | { 18 | return input.Where(c => !IsClass(c.Definition)); 19 | } 20 | 21 | static bool IsClass(TypeDefinition c) => c.IsClass && !c.IsValueType && !c.IsDelegate(); 22 | } 23 | 24 | internal static IEnumerable BeDelegate(IEnumerable input, bool condition) 25 | { 26 | if (condition) 27 | { 28 | return input.Where(c => c.Definition.IsDelegate()); 29 | } 30 | else 31 | { 32 | return input.Where(c => !c.Definition.IsDelegate()); 33 | } 34 | } 35 | 36 | internal static IEnumerable BeEnum(IEnumerable input, bool condition) 37 | { 38 | if (condition) 39 | { 40 | return input.Where(c => c.Definition.IsEnum); 41 | } 42 | else 43 | { 44 | return input.Where(c => !c.Definition.IsEnum); 45 | } 46 | } 47 | 48 | internal static IEnumerable BeInterface(IEnumerable input, bool condition) 49 | { 50 | if (condition) 51 | { 52 | return input.Where(c => c.Definition.IsInterface); 53 | } 54 | else 55 | { 56 | return input.Where(c => !c.Definition.IsInterface); 57 | } 58 | } 59 | 60 | internal static IEnumerable BeStruct(IEnumerable input, bool condition) 61 | { 62 | if (condition) 63 | { 64 | return input.Where(c => c.Definition.IsStruct()); 65 | } 66 | else 67 | { 68 | return input.Where(c => !c.Definition.IsStruct()); 69 | } 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /sources/NetArchTest/IAssembly.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.Rules 6 | { 7 | /// 8 | /// Assembly wrapper. 9 | /// 10 | public interface IAssembly 11 | { 12 | /// 13 | /// FullName of the assembly 14 | /// 15 | string FullName { get; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sources/NetArchTest/ICustomRule.cs: -------------------------------------------------------------------------------- 1 | using Mono.Cecil; 2 | 3 | namespace NetArchTest.Rules 4 | { 5 | /// 6 | /// An externally defined rule that can be applied as a condition or a predicate. 7 | /// 8 | public interface ICustomRule 9 | { 10 | /// 11 | /// Tests whether the supplied type meets the rule. 12 | /// 13 | /// The type to be tested. 14 | /// The result of the test. 15 | bool MeetsRule(TypeDefinition type); 16 | } 17 | 18 | 19 | 20 | /// 21 | /// An externally defined rule that can be applied as a condition or a predicate. 22 | /// 23 | public interface ICustomRule2 24 | { 25 | /// 26 | /// Tests whether the supplied type meets the rule. 27 | /// 28 | /// The type to be tested. 29 | /// The result of the test. 30 | CustomRuleResult MeetsRule(TypeDefinition type); 31 | } 32 | 33 | 34 | public class CustomRuleResult 35 | { 36 | public bool IsMet { get; init; } 37 | 38 | public string Explanation { get; init; } 39 | 40 | 41 | public CustomRuleResult(bool isMet, string explanation = null) 42 | { 43 | IsMet = isMet; 44 | Explanation = explanation; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /sources/NetArchTest/IDependencyFilter.cs: -------------------------------------------------------------------------------- 1 | using Mono.Cecil; 2 | 3 | namespace NetArchTest.Rules 4 | { 5 | /// 6 | /// An externally defined filter that can be used to decided if a dependency should be checked by DependencySearch engine or not 7 | /// 8 | public interface IDependencyFilter 9 | { 10 | /// 11 | /// Tests whether the supplied type should be checked by DependencySearch engine or not 12 | /// 13 | /// The type to be tested. 14 | /// The result of the test. 15 | bool ShouldDependencyBeChecked(TypeReference dependency); 16 | } 17 | } -------------------------------------------------------------------------------- /sources/NetArchTest/IType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetArchTest.Rules 4 | { 5 | /// 6 | /// Type wrapper. 7 | /// 8 | public interface IType 9 | { 10 | /// 11 | /// System.Type 12 | /// 13 | /// 14 | /// This property may be null if the test project does not have a direct dependency on the type. 15 | /// 16 | Type ReflectionType { get; } 17 | 18 | /// 19 | /// FullName of the type 20 | /// 21 | string FullName { get; } 22 | 23 | /// 24 | /// Name of the type 25 | /// 26 | string Name { get; } 27 | 28 | /// 29 | /// It contains explanation why this Type has failed dependecy search. 30 | /// 31 | string Explanation { get; } 32 | 33 | /// 34 | /// Path to the source file where type is defined. 35 | /// 36 | /// 37 | /// This property may be null if assembly debug symbols (PDB) were not loaded correctly or given type does not have any instructions inside. 38 | /// 39 | string SourceFilePath { get; } 40 | } 41 | } -------------------------------------------------------------------------------- /sources/NetArchTest/NetArchTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | 1.4.5 6 | NeVeSpl 7 | NetArchTest.eNhancedEdition 8 | A fluent API for .Net Standard that can enforce architectural rules in unit tests. Improved version, built upon NetArchTest.Rules v1.3.2. 9 | (c) NetArchTest.eNhancedEdition 10 | https://github.com/NeVeSpl/NetArchTest.eNhancedEdition/blob/master/LICENSE 11 | https://github.com/NeVeSpl/NetArchTest.eNhancedEdition 12 | Resources\icon.png 13 | https://github.com/NeVeSpl/NetArchTest.eNhancedEdition 14 | test architecture dependencies archtest 15 | true 16 | true 17 | NetArchTest.eNhancedEdition 18 | MIT 19 | 11 20 | README.md 21 | True 22 | xKey.snk 23 | 24 | 25 | 26 | 27 | True 28 | \ 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | True 39 | \ 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /sources/NetArchTest/Options.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetArchTest.Rules 4 | { 5 | /// 6 | /// User Options allows to configure how NetArchTest engine works. 7 | /// 8 | public record class Options 9 | { 10 | public static readonly Options Default = new Options(); 11 | 12 | 13 | /// 14 | /// Allows to specify how strings will be compared, default: InvariantCultureIgnoreCase 15 | /// 16 | public StringComparison Comparer { get; init; } = StringComparison.InvariantCultureIgnoreCase; 17 | 18 | 19 | /// 20 | /// Determines if dependency analysis should look for dependency in string field constant, default: false 21 | /// 22 | public bool SerachForDependencyInFieldConstant { get; init; } = false; 23 | } 24 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Policies/Policy.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.Policies 2 | { 3 | using System; 4 | using NetArchTest.Rules; 5 | 6 | /// 7 | /// An aggregate of rules and results that can be used for reporting. 8 | /// 9 | public sealed class Policy 10 | { 11 | /// The simple name of the policy. 12 | private string _name; 13 | 14 | /// A detailed description of the policy. 15 | private string _description; 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | private Policy(string name, string description) 21 | { 22 | _name = name; 23 | _description = description; 24 | } 25 | 26 | /// 27 | /// Defines a policy that aggregates a set of rules together for reporting. 28 | /// 29 | public static Policy Define(string name, string description) 30 | { 31 | return new Policy(name, description); 32 | } 33 | 34 | /// 35 | /// Sets the types that the policy will apply to. 36 | /// 37 | public PolicyDefinition For(Func types) 38 | { 39 | if (types == null) 40 | { 41 | throw new ArgumentNullException(); 42 | } 43 | 44 | return new PolicyDefinition(types, _name, _description); 45 | } 46 | 47 | /// 48 | /// Sets the types that the policy will apply to. 49 | /// 50 | public PolicyDefinition For(Types types) 51 | { 52 | if (types == null) 53 | { 54 | throw new ArgumentNullException(); 55 | } 56 | 57 | var func = new Func(() => types); 58 | 59 | return new PolicyDefinition(func, _name, _description); 60 | } 61 | 62 | } 63 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Policies/PolicyResult.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.Policies 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using NetArchTest.Assemblies; 6 | using NetArchTest.Rules; 7 | 8 | /// 9 | /// A single test result for a policy. 10 | /// 11 | public sealed class PolicyResult 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | internal PolicyResult(TestResult result, string name, string description) 17 | { 18 | IsSuccessful = result.IsSuccessful; 19 | FailingTypes = result.FailingTypes; 20 | Name = name; 21 | Description = description; 22 | } 23 | 24 | /// 25 | /// Gets a flag indicating the success or failure of the test. 26 | /// 27 | public bool IsSuccessful { get; private set; } 28 | 29 | /// 30 | /// Gets a collection populated with a list of any types that failed the test. 31 | /// 32 | public IEnumerable FailingTypes { get; private set; } 33 | 34 | /// 35 | /// Gets the simple name associated with the test. 36 | /// 37 | public string Name { get; private set; } 38 | 39 | /// 40 | /// Gets the detailed description associated with the test. 41 | /// 42 | public string Description { get; private set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /sources/NetArchTest/Policies/PolicyResults.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.Policies 2 | { 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | /// 7 | /// A set of results for a policy that has been executed against a list of types. 8 | /// 9 | public sealed class PolicyResults 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | internal PolicyResults(IReadOnlyList results, string name, string description) 15 | { 16 | Results = results; 17 | Name = name; 18 | Description = description; 19 | } 20 | 21 | /// 22 | /// Gets whether or not the policy has any rule violations 23 | /// 24 | public bool HasViolations 25 | { 26 | get 27 | { 28 | return Results.Any(r => !r.IsSuccessful); 29 | } 30 | } 31 | 32 | /// 33 | /// Gets the results of each rule that was added the policy. 34 | /// 35 | public IReadOnlyList Results { get; private set; } 36 | 37 | /// 38 | /// Gets the simple name associated with the policy. 39 | /// 40 | public string Name { get; private set; } 41 | 42 | /// 43 | /// Gets the detailed description associated with the policy. 44 | /// 45 | public string Description { get; private set; } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /sources/NetArchTest/Policies/PolicyTest.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.Policies 2 | { 3 | using System; 4 | using NetArchTest.Rules; 5 | 6 | /// 7 | /// A single test that has been added to a policy. 8 | /// 9 | internal sealed class PolicyTest 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | internal PolicyTest(Func definition, string name, string description) 15 | { 16 | Definition = definition; 17 | Name = name; 18 | Description = description; 19 | } 20 | 21 | /// 22 | /// The definition of the test expressed as a function. 23 | /// 24 | internal Func Definition { get; private set; } 25 | 26 | /// 27 | /// Gets the simple name associated with the test. 28 | /// 29 | internal string Name { get; private set; } 30 | 31 | /// 32 | /// Gets the detailed description associated with the test. 33 | /// 34 | internal string Description { get; private set; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sources/NetArchTest/Predicate_Metrics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using NetArchTest.Functions; 5 | 6 | namespace NetArchTest.Rules 7 | { 8 | public sealed partial class Predicate 9 | { 10 | /// 11 | /// Selects types that have more logical lines of code than a given number 12 | /// 13 | /// An updated set of conditions that can be applied to a list of types. 14 | public PredicateList HaveNumberOfLinesOfCodeGreaterThan(int number) 15 | { 16 | AddFunctionCall((context, inputTypes) => FunctionDelegates.HaveNumberOfLinesOfCodeFewerThan(context, inputTypes, number, false)); 17 | return CreatePredicateList(); 18 | } 19 | 20 | /// 21 | /// Selects types that have fewer logical lines of code than a given number 22 | /// 23 | /// An updated set of conditions that can be applied to a list of types. 24 | public PredicateList HaveNumberOfLinesOfCodeLowerThan(int number) 25 | { 26 | AddFunctionCall((context, inputTypes) => FunctionDelegates.HaveNumberOfLinesOfCodeFewerThan(context, inputTypes, number, true)); 27 | return CreatePredicateList(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeVeSpl/NetArchTest.eNhancedEdition/7f29bdf5f24368dccad27b8e3ec52a807e813504/sources/NetArchTest/Resources/icon.png -------------------------------------------------------------------------------- /sources/NetArchTest/RuleEngine/ConditionContext.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.RuleEngine 2 | { 3 | internal class ConditionContext 4 | { 5 | public FunctionSequence Sequence { get; } = new FunctionSequence(); 6 | public bool Should { get; set; } 7 | 8 | public ConditionContext() 9 | { 10 | 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /sources/NetArchTest/RuleEngine/FunctionSequenceExecutionContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NetArchTest.Assemblies; 3 | using NetArchTest.Rules; 4 | 5 | namespace NetArchTest.RuleEngine 6 | { 7 | internal class FunctionSequenceExecutionContext 8 | { 9 | public IEnumerable AllTypes { get; } 10 | public bool IsFailPathRun { get; } 11 | public IDependencyFilter DependencyFilter { get; } 12 | public Options UserOptions { get; } 13 | 14 | 15 | public FunctionSequenceExecutionContext(IEnumerable allTypes, bool isFailPathRun, Options options = null) 16 | { 17 | AllTypes = allTypes; 18 | UserOptions = options ?? Options.Default; 19 | IsFailPathRun = isFailPathRun; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /sources/NetArchTest/RuleEngine/PredicateContext.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.RuleEngine 2 | { 3 | internal class PredicateContext 4 | { 5 | public FunctionSequence Sequence { get; } = new FunctionSequence(); 6 | 7 | 8 | public PredicateContext() 9 | { 10 | 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/Model/Filters/HaveDependenciesBetweenSlices.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using NetArchTest.Assemblies; 4 | using NetArchTest.Dependencies; 5 | 6 | namespace NetArchTest.Slices.Model 7 | { 8 | internal sealed class HaveDependenciesBetweenSlices : IFilter 9 | { 10 | public IEnumerable Execute(SlicedTypes slicedTypes) 11 | { 12 | var dependencySearch = new DependencySearch(false, false); 13 | var result = new List(slicedTypes.TypeCount); 14 | 15 | for (int i = 0; i < slicedTypes.Slices.Count; i++) 16 | { 17 | var slice = slicedTypes.Slices[i]; 18 | var dependencies = slicedTypes.Slices.Where((_, index) => index != i).Select(x => x.Name).ToList(); 19 | 20 | var foundTypes = dependencySearch.FindTypesThatHaveDependencyOnAny(slice.Types, dependencies).Where(x => x.IsPassing); 21 | var lookup = new HashSet(foundTypes); 22 | 23 | foreach (var type in slice.Types) 24 | { 25 | bool isPassing = lookup.Contains(type); 26 | var typeResult = new TypeTestResult(type, isPassing); 27 | result.Add(typeResult); 28 | } 29 | } 30 | 31 | return result; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/Model/IFilter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NetArchTest.Slices.Model 4 | { 5 | internal interface IFilter 6 | { 7 | IEnumerable Execute(SlicedTypes slicedTypes); 8 | } 9 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/Model/Slice.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NetArchTest.Assemblies; 3 | 4 | namespace NetArchTest.Slices.Model 5 | { 6 | internal sealed class Slice 7 | { 8 | public string Name { get; } 9 | public IEnumerable Types { get; } 10 | 11 | 12 | public Slice(string sliceName, List types) 13 | { 14 | Name = sliceName; 15 | Types = types; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/Model/SliceContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NetArchTest.Assemblies; 3 | 4 | namespace NetArchTest.Slices.Model 5 | { 6 | internal class SliceContext 7 | { 8 | private readonly LoadedData loadedData; 9 | private readonly SlicedTypes slicedTypes; 10 | 11 | public SliceContext(LoadedData loadedData, SlicedTypes slicedTypes) 12 | { 13 | this.loadedData = loadedData; 14 | this.slicedTypes = slicedTypes; 15 | } 16 | 17 | 18 | 19 | public IReadOnlyList GetAssemblies() 20 | { 21 | return loadedData.Assemblies; 22 | } 23 | 24 | public SlicedTypes GetTypes() 25 | { 26 | return slicedTypes; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/Model/SlicedTypes.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NetArchTest.Slices.Model 4 | { 5 | internal sealed class SlicedTypes 6 | { 7 | public int TypeCount { get; } 8 | public IReadOnlyList Slices { get; } 9 | 10 | 11 | public SlicedTypes(int typeCount, List slices) 12 | { 13 | TypeCount = typeCount; 14 | Slices = slices; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/Model/Slicer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Mono.Cecil; 4 | using NetArchTest.Assemblies; 5 | 6 | 7 | namespace NetArchTest.Slices.Model 8 | { 9 | internal sealed class Slicer 10 | { 11 | public SlicedTypes SliceByNamespacePrefix(IEnumerable types, string prefix) 12 | { 13 | string prefixWithDot = ""; 14 | if (!string.IsNullOrEmpty(prefix)) 15 | { 16 | prefixWithDot = prefix; 17 | if (prefixWithDot.Last() != '.') 18 | { 19 | prefixWithDot = prefixWithDot + "."; 20 | } 21 | } 22 | 23 | var groupedTypes = new Dictionary>(); 24 | int typeCount = 0; 25 | 26 | foreach (var type in types) 27 | { 28 | var typeNamespace = type.Definition.GetNamespace(); 29 | if (typeNamespace.StartsWith(prefixWithDot)) 30 | { 31 | ++typeCount; 32 | int nextDotIndex = typeNamespace.IndexOf('.', prefixWithDot.Length); 33 | int startIndex = prefixWithDot.Length; 34 | int endIndex = nextDotIndex > -1 ? nextDotIndex : typeNamespace.Length; 35 | string sliceName = typeNamespace.Substring(0, endIndex); 36 | 37 | if (groupedTypes.TryGetValue(sliceName, out var list)) 38 | { 39 | list.Add(type); 40 | } 41 | else 42 | { 43 | groupedTypes[sliceName] = new List() { type }; 44 | } 45 | } 46 | } 47 | 48 | var slices = groupedTypes.Select((x) => new Slice(x.Key, x.Value)).ToList(); 49 | 50 | return new SlicedTypes(typeCount, slices); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/Model/TypeTestResult.cs: -------------------------------------------------------------------------------- 1 | using NetArchTest.Assemblies; 2 | 3 | namespace NetArchTest.Slices.Model 4 | { 5 | internal sealed class TypeTestResult 6 | { 7 | public TypeSpec TypeSpec { get; } 8 | public bool IsPassing { get; } 9 | 10 | 11 | public TypeTestResult(TypeSpec type, bool isPassing) 12 | { 13 | TypeSpec = type; 14 | IsPassing = isPassing; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/SliceCondition.cs: -------------------------------------------------------------------------------- 1 | using NetArchTest.Assemblies; 2 | using NetArchTest.Slices.Model; 3 | 4 | namespace NetArchTest.Slices 5 | { 6 | /// 7 | /// A set of conditions that can be applied to slices of types. 8 | /// 9 | public sealed class SliceCondition 10 | { 11 | private readonly SliceContext sliceContext; 12 | private readonly bool should; 13 | 14 | 15 | internal SliceCondition(SliceContext sliceContext, bool should) 16 | { 17 | this.sliceContext = sliceContext; 18 | this.should = should; 19 | } 20 | 21 | /// 22 | /// Selects types that have some dependencies on types from other slices. 23 | /// 24 | public SliceConditionList HaveDependenciesBetweenSlices() 25 | { 26 | return new SliceConditionList(sliceContext, new HaveDependenciesBetweenSlices(), should); 27 | } 28 | 29 | /// 30 | /// Selects types that do not have dependencies on types from other slices. 31 | /// 32 | public SliceConditionList NotHaveDependenciesBetweenSlices() 33 | { 34 | return new SliceConditionList(sliceContext, new HaveDependenciesBetweenSlices(), !should); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/SliceConditionList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using NetArchTest.Assemblies; 4 | using NetArchTest.Rules; 5 | using NetArchTest.Slices.Model; 6 | 7 | namespace NetArchTest.Slices 8 | { 9 | /// 10 | /// Executor of condition. 11 | /// 12 | public sealed class SliceConditionList 13 | { 14 | private readonly SliceContext sliceContext; 15 | private readonly IFilter filter; 16 | private readonly bool should; 17 | 18 | 19 | internal SliceConditionList(SliceContext sliceContext, IFilter filter, bool should) 20 | { 21 | this.sliceContext = sliceContext; 22 | this.filter = filter; 23 | this.should = should; 24 | } 25 | 26 | 27 | /// 28 | /// Returns an indication of whether all the selected types satisfy the conditions. 29 | /// 30 | /// An indication of whether the conditions are true, along with a list of types failing the check if they are not. 31 | 32 | public TestResult GetResult() 33 | { 34 | var slicedTypes = sliceContext.GetTypes(); 35 | 36 | var filteredTypes = filter.Execute(slicedTypes); 37 | 38 | if (filteredTypes.Count() != slicedTypes.TypeCount) 39 | { 40 | throw new Exception("Filter returned wrong number of results!"); 41 | } 42 | 43 | bool successIsWhen = should; 44 | bool isSuccessful = filteredTypes.All(x => x.IsPassing == successIsWhen); 45 | 46 | if (isSuccessful) 47 | { 48 | // todo replace Array.Empty() with real data 49 | return new TestResult(sliceContext.GetAssemblies(), Array.Empty(), Array.Empty(), Array.Empty(), true); 50 | } 51 | else 52 | { 53 | var failingTypes = filteredTypes.Where(x => x.IsPassing == !successIsWhen); 54 | return new TestResult(sliceContext.GetAssemblies(), Array.Empty(), Array.Empty(), failingTypes.Select(x => x.TypeSpec), false); 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/SlicePredicate.cs: -------------------------------------------------------------------------------- 1 | using NetArchTest.RuleEngine; 2 | using NetArchTest.Slices.Model; 3 | 4 | namespace NetArchTest.Slices 5 | { 6 | /// 7 | /// Allows dividing types into groups, also called slices. 8 | /// 9 | /// 10 | public sealed class SlicePredicate 11 | { 12 | private readonly RuleContext rule; 13 | 14 | 15 | internal SlicePredicate(RuleContext rule) 16 | { 17 | this.rule = rule; 18 | } 19 | 20 | 21 | /// 22 | /// Divides types into groups/slices according to the prefix pattern. 23 | /// It only selects types which namespaces start with a given prefix, rest of the types are ignored. 24 | /// Groups are defined by the first part of the namespace that comes next after prefix: 25 | /// namespacePrefix.(groupName).restOfNamespace 26 | /// 27 | public SlicePredicateList ByNamespacePrefix(string prefix) 28 | { 29 | var slicer = new Slicer(); 30 | var slicedTypes = slicer.SliceByNamespacePrefix(rule.Execute(null), prefix); 31 | return new SlicePredicateList(new SliceContext(rule.loadedData, slicedTypes)); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Slices/SlicePredicateList.cs: -------------------------------------------------------------------------------- 1 | using NetArchTest.Assemblies; 2 | using NetArchTest.Slices.Model; 3 | 4 | namespace NetArchTest.Slices 5 | { 6 | /// 7 | /// Link between predicate and condition. 8 | /// 9 | public sealed class SlicePredicateList 10 | { 11 | private readonly SliceContext sliceContext; 12 | 13 | 14 | internal SlicePredicateList(SliceContext sliceContext) 15 | { 16 | this.sliceContext = sliceContext; 17 | } 18 | 19 | 20 | /// 21 | /// Links a predicate defining a set of classes to a condition that tests them. 22 | /// 23 | public SliceCondition Should() 24 | { 25 | return new SliceCondition(sliceContext, true); 26 | } 27 | 28 | /// 29 | /// Links a predicate defining a set of classes to a condition that tests them. 30 | /// 31 | public SliceCondition ShouldNot() 32 | { 33 | return new SliceCondition(sliceContext, false); 34 | } 35 | 36 | 37 | internal SlicedTypes GetSlicedTypes() 38 | { 39 | return sliceContext.GetTypes(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /sources/NetArchTest/Utils.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest 2 | { 3 | public class Utils 4 | { 5 | public static string fullnameof() => typeof(T).FullName; 6 | public static string namespaceof() => typeof(T).Namespace; 7 | } 8 | } -------------------------------------------------------------------------------- /sources/NetArchTest/xKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeVeSpl/NetArchTest.eNhancedEdition/7f29bdf5f24368dccad27b8e3ec52a807e813504/sources/NetArchTest/xKey.snk -------------------------------------------------------------------------------- /tests/NetArchTest.CrossAssemblyTest.A/BaseClassFromA.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.CrossAssemblyTest.A 2 | { 3 | public class BaseClassFromA 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /tests/NetArchTest.CrossAssemblyTest.A/ClassCustomAttributeFromA.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.CrossAssemblyTest.A 6 | { 7 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 8 | public class ClassCustomAttributeFromA : Attribute 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NetArchTest.CrossAssemblyTest.A/NetArchTest.CrossAssemblyTest.A.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/NetArchTest.CrossAssemblyTest.B/AnotherDerivedClassFromB.cs: -------------------------------------------------------------------------------- 1 | using NetArchTest.CrossAssemblyTest.A; 2 | 3 | namespace NetArchTest.CrossAssemblyTest.B 4 | { 5 | public class AnotherDerivedClassFromB : BaseClassFromA 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /tests/NetArchTest.CrossAssemblyTest.B/DerivedClassCustomAttributeFromB.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using NetArchTest.CrossAssemblyTest.A; 5 | 6 | namespace NetArchTest.CrossAssemblyTest.B 7 | { 8 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 9 | public class DerivedClassCustomAttributeFromB : ClassCustomAttributeFromA 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/NetArchTest.CrossAssemblyTest.B/DerivedClassFromB.cs: -------------------------------------------------------------------------------- 1 | using NetArchTest.CrossAssemblyTest.A; 2 | 3 | namespace NetArchTest.CrossAssemblyTest.B 4 | { 5 | public class DerivedClassFromB : BaseClassFromA 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /tests/NetArchTest.CrossAssemblyTest.B/NetArchTest.CrossAssemblyTest.B.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/ConditionTests_Metrics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using NetArchTest.TestStructure.Metrics; 7 | using NetArchTest.UnitTests.TestFixtures; 8 | using Xunit; 9 | 10 | namespace NetArchTest.UnitTests 11 | { 12 | public class ConditionTests_Metrics(AllTypesFixture fixture) : IClassFixture 13 | { 14 | 15 | [Fact(DisplayName = "HaveNumberOfLinesOfCodeLowerThan")] 16 | public void HaveNumberOfLinesOfCodeLowerThan() 17 | { 18 | var result = fixture.Types 19 | .That() 20 | .ResideInNamespace(typeof(ClassSmall).Namespace) 21 | .And() 22 | .AreOfType(typeof(ClassSmall)) 23 | .Should() 24 | .HaveNumberOfLinesOfCodeLowerThan(13).GetResult(); 25 | 26 | Assert.True(result.IsSuccessful); 27 | } 28 | 29 | 30 | [Fact(DisplayName = "HaveNumberOfLinesOfCodeGreaterThan")] 31 | public void HaveNumberOfLinesOfCodeGreaterThan() 32 | { 33 | var result = fixture.Types 34 | .That() 35 | .ResideInNamespace(typeof(ClassSmall).Namespace) 36 | .And() 37 | .AreOfType(typeof(ClassLarge)) 38 | .Should() 39 | .HaveNumberOfLinesOfCodeGreaterThan(13).GetResult(); 40 | 41 | Assert.True(result.IsSuccessful); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/NetArchTest.UnitTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | false 6 | 12 7 | True 8 | xKey.snk 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/PredicateTests_Metrics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NetArchTest.TestStructure.Metrics; 3 | using NetArchTest.UnitTests.TestFixtures; 4 | using Xunit; 5 | using static NetArchTest.Utils; 6 | 7 | namespace NetArchTest.UnitTests 8 | { 9 | public class PredicateTests_Metrics(AllTypesFixture fixture) : IClassFixture 10 | { 11 | 12 | [Fact(DisplayName = "HaveNumberOfLinesOfCodeLowerThan")] 13 | public void HaveNumberOfLinesOfCodeLowerThan() 14 | { 15 | var result = fixture.Types 16 | .That() 17 | .ResideInNamespace(namespaceof()) 18 | .And() 19 | .HaveNumberOfLinesOfCodeLowerThan(13) 20 | .GetReflectionTypes(); 21 | 22 | Assert.Single(result); 23 | Assert.Contains(typeof(ClassSmall), result); 24 | } 25 | 26 | [Fact(DisplayName = "HaveNumberOfLinesOfCodeGreaterThan")] 27 | public void HaveNumberOfLinesOfCodeGreaterThan() 28 | { 29 | var result = fixture.Types 30 | .That() 31 | .ResideInNamespace(namespaceof()) 32 | .And() 33 | .HaveNumberOfLinesOfCodeGreaterThan(13) 34 | .GetReflectionTypes(); 35 | 36 | Assert.Single(result); 37 | Assert.Contains(typeof(ClassLarge), result); 38 | } 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/SlicesTests.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using NetArchTest.Rules; 3 | using NetArchTest.Slices; 4 | using NetArchTest.UnitTests.TestFixtures; 5 | using Xunit; 6 | 7 | namespace NetArchTest.UnitTests 8 | { 9 | public class SlicesTests(AllTypesFixture fixture) : IClassFixture 10 | { 11 | [Fact(DisplayName = "Types are divided correctly into slices for a valid tree")] 12 | public void TypesAreDividedCorrectlyIntoSlicesForValidTree() 13 | { 14 | var slicedTypes = (fixture.Types 15 | .Slice() 16 | .ByNamespacePrefix("NetArchTest.TestStructure.Slices.ValidTree") as SlicePredicateList).GetSlicedTypes(); 17 | 18 | Assert.Equal(9, slicedTypes.TypeCount); 19 | Assert.Equal(3, slicedTypes.Slices.Count()); 20 | Assert.Equal(5, slicedTypes.Slices.Where(x => x.Name == "NetArchTest.TestStructure.Slices.ValidTree.FeatureA").First().Types.Count()); 21 | Assert.Equal(3, slicedTypes.Slices.Where(x => x.Name == "NetArchTest.TestStructure.Slices.ValidTree.FeatureB").First().Types.Count()); 22 | Assert.Single(slicedTypes.Slices.Where(x => x.Name == "NetArchTest.TestStructure.Slices.ValidTree.FeatureC").First().Types); 23 | } 24 | 25 | 26 | [Fact(DisplayName = "Valid tree does not have dependencies between slices")] 27 | public void ValidTreeDoesNotHaveDependenciesBetweenSlices() 28 | { 29 | var testResult = fixture.Types 30 | .Slice() 31 | .ByNamespacePrefix("NetArchTest.TestStructure.Slices.ValidTree") 32 | .Should() 33 | .NotHaveDependenciesBetweenSlices() 34 | .GetResult(); 35 | 36 | Assert.True(testResult.IsSuccessful); 37 | } 38 | 39 | [Fact(DisplayName = "Invalid tree has dependencies between slices")] 40 | public void InvalidTreeHasDependenciesBetweenSlices() 41 | { 42 | var testResult = fixture.Types 43 | .Slice() 44 | .ByNamespacePrefix("NetArchTest.TestStructure.Slices.InvalidTree") 45 | .Should() 46 | .NotHaveDependenciesBetweenSlices() 47 | .GetResult(); 48 | 49 | Assert.False(testResult.IsSuccessful); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/TestDoubles/CustomRuleExample.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.UnitTests.TestDoubles 2 | { 3 | using Mono.Cecil; 4 | using NetArchTest.Rules; 5 | using System; 6 | 7 | /// 8 | /// A simple custom rule example that always passes. 9 | /// 10 | public class CustomRuleTestDouble : ICustomRule 11 | { 12 | /// Used by tests to indicate whether the test method has been called. 13 | public bool TestMethodCalled = false; 14 | 15 | /// The delegate that is used for the rule - this allows the test to define the custom rule. 16 | private Func _test; 17 | 18 | public CustomRuleTestDouble(Func test) 19 | { 20 | _test = test; 21 | } 22 | 23 | public bool MeetsRule(TypeDefinition type) 24 | { 25 | TestMethodCalled = true; 26 | return _test(type); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/TestFixtures/AccessModifiersFixture.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using NetArchTest.Rules; 3 | using NetArchTest.TestStructure.AccessModifiers; 4 | 5 | namespace NetArchTest.UnitTests.TestFixtures 6 | { 7 | public class AccessModifiersFixture 8 | { 9 | public Types Types { get; } = Types.InAssembly(Assembly.GetAssembly(typeof(PublicClass))); 10 | } 11 | } -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/TestFixtures/AllTypesFixture.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using NetArchTest.Rules; 3 | using NetArchTest.TestStructure.AccessModifiers; 4 | 5 | namespace NetArchTest.UnitTests.TestFixtures 6 | { 7 | public class AllTypesFixture 8 | { 9 | public Types Types { get; } = Types.InAssembly(Assembly.GetAssembly(typeof(PublicClass))); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/TestFixtures/DependenciesFixture.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using NetArchTest.Rules; 3 | using NetArchTest.TestStructure.Dependencies.Implementation; 4 | 5 | namespace NetArchTest.UnitTests.TestFixtures 6 | { 7 | public class DependenciesFixture 8 | { 9 | public Types Types { get; } = Types.InAssembly(Assembly.GetAssembly(typeof(HasDependency))); 10 | } 11 | } -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/TestFixtures/NamesFixture.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using NetArchTest.Rules; 3 | using NetArchTest.TestStructure.Names.Namespace1; 4 | 5 | namespace NetArchTest.UnitTests.TestFixtures 6 | { 7 | public class NamesFixture 8 | { 9 | public Types Types { get; } = Types.InAssembly(Assembly.GetAssembly(typeof(ClassA1))); 10 | } 11 | } -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/TestFixtures/SpecialFixture.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using NetArchTest.Rules; 3 | using NetArchTest.TestStructure.NameMatching.Namespace1; 4 | 5 | namespace NetArchTest.UnitTests.TestFixtures 6 | { 7 | public class SpecialFixture 8 | { 9 | public Types Types { get; } = Types.InAssembly(Assembly.GetAssembly(typeof(ClassA1))); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/TestFixtures/TraitsFixture.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using NetArchTest.Rules; 3 | using NetArchTest.TestStructure.Traits; 4 | 5 | namespace NetArchTest.UnitTests.TestFixtures 6 | { 7 | public class TraitsFixture 8 | { 9 | public Types Types { get; } = Types.InAssembly(Assembly.GetAssembly(typeof(StaticClass))); 10 | } 11 | } -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/TestFixtures/TypesFixture.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using NetArchTest.Rules; 3 | using NetArchTest.TestStructure.Types; 4 | 5 | namespace NetArchTest.UnitTests.TestFixtures 6 | { 7 | public class TypesFixture 8 | { 9 | public Types Types { get; } = Types.InAssembly(Assembly.GetAssembly(typeof(ExampleClass))); 10 | } 11 | } -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/TestFixtures/TypesInCurrentDomainFixture.cs: -------------------------------------------------------------------------------- 1 | using NetArchTest.Rules; 2 | 3 | 4 | namespace NetArchTest.UnitTests.TestFixtures 5 | { 6 | public class TypesInCurrentDomainFixture 7 | { 8 | public Types Types { get; } = Types.InCurrentDomain(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.Rules.UnitTests/xKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeVeSpl/NetArchTest.eNhancedEdition/7f29bdf5f24368dccad27b8e3ec52a807e813504/tests/NetArchTest.Rules.UnitTests/xKey.snk -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/AccessModifiers/InternalClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.AccessModifiers 2 | { 3 | internal class InternalClass 4 | { 5 | internal class InternalClassNested 6 | { 7 | 8 | } 9 | public class PublicClassNested 10 | { 11 | 12 | } 13 | private class PrivateClassNested 14 | { 15 | 16 | } 17 | 18 | protected class ProtectedClassNested 19 | { 20 | 21 | } 22 | 23 | private protected class PrivateProtectedClassNested 24 | { 25 | 26 | } 27 | 28 | protected internal class ProtectedInternalClassNested 29 | { 30 | 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/AccessModifiers/PublicClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.AccessModifiers 2 | { 3 | public class PublicClass 4 | { 5 | internal class InternalClassNested 6 | { 7 | 8 | } 9 | public class PublicClassNested 10 | { 11 | 12 | } 13 | private class PrivateClassNested 14 | { 15 | 16 | } 17 | 18 | protected class ProtectedClassNested 19 | { 20 | 21 | } 22 | 23 | private protected class PrivateProtectedClassNested 24 | { 25 | 26 | } 27 | 28 | protected internal class ProtectedInternalClassNested 29 | { 30 | 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | [assembly: InternalsVisibleTo("NetArchTest.UnitTests")] 3 | 4 | namespace System.Runtime.CompilerServices 5 | { 6 | internal static class IsExternalInit { } 7 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Constructors/DefaultConstructor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Constructors 6 | { 7 | internal class DefaultConstructor 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Constructors/InternalConstructor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Constructors 6 | { 7 | internal class InternalConstructor 8 | { 9 | internal InternalConstructor() 10 | { 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Constructors/PrivateConstructor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Constructors 6 | { 7 | internal class PrivateConstructor 8 | { 9 | 10 | 11 | private PrivateConstructor() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Constructors/PublicConstructor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Constructors 6 | { 7 | internal class PublicConstructor 8 | { 9 | public PublicConstructor() 10 | { 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Constructors/PublicConstructorOneArgument.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Constructors 6 | { 7 | internal class PublicConstructorOneArgument 8 | { 9 | 10 | 11 | public PublicConstructorOneArgument(int a) 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Constructors/StaticConstructor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Constructors 6 | { 7 | internal class StaticConstructor 8 | { 9 | StaticConstructor() 10 | { 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/CustomAttributes/AttributePresent.cs: -------------------------------------------------------------------------------- 1 | using NetArchTest.CrossAssemblyTest.A; 2 | using NetArchTest.CrossAssemblyTest.B; 3 | using NetArchTest.TestStructure.CustomAttributes.Attributes; 4 | 5 | namespace NetArchTest.TestStructure.CustomAttributes 6 | { 7 | [ClassCustom] 8 | [ClassCustomAttribute.ClassNestedCustom] 9 | [ClassCustomAttribute.ClassNestedCustomAttribute.ClassNestedNestedCustom] 10 | [GenericCustom] 11 | [ClassCustomAttributeFromA] 12 | public class AttributePresent 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/CustomAttributes/Attributes/ClassCustomAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.CustomAttributes 2 | { 3 | using System; 4 | 5 | /// 6 | /// Example class level custom attribute. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 9 | public class ClassCustomAttribute : Attribute 10 | { 11 | 12 | 13 | public class ClassNestedCustomAttribute : Attribute 14 | { 15 | 16 | 17 | public class ClassNestedNestedCustomAttribute : Attribute 18 | { 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/CustomAttributes/Attributes/GenericCustomAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.CustomAttributes.Attributes 6 | { 7 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 8 | public class GenericCustomAttribute : Attribute 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/CustomAttributes/Attributes/InheritClassCustomAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.CustomAttributes 2 | { 3 | using System; 4 | 5 | /// 6 | /// Example class level custom attribute that inherits form other custom attribute. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 9 | public class InheritClassCustomAttribute : ClassCustomAttribute 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/CustomAttributes/InheritAttributePresent.cs: -------------------------------------------------------------------------------- 1 | using NetArchTest.CrossAssemblyTest.B; 2 | 3 | namespace NetArchTest.TestStructure.CustomAttributes 4 | { 5 | [InheritClassCustom] 6 | [DerivedClassCustomAttributeFromB] 7 | public class InheritAttributePresent 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/CustomAttributes/NoAttributes.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.CustomAttributes 2 | { 3 | public class NoAttributes 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/AnotherExampleDependency.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Examples 2 | { 3 | /// 4 | /// An example class used in tests that identify dependencies. 5 | /// 6 | public class AnotherExampleDependency 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/AttributeDependency.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetArchTest.TestStructure.Dependencies.Examples 4 | { 5 | /// 6 | /// An example attribute used in tests that identify dependencies. 7 | /// 8 | [AttributeUsage(AttributeTargets.All, Inherited = false)] 9 | class AttributeDependency : Attribute 10 | { 11 | public AttributeDependency() 12 | { 13 | 14 | } 15 | public AttributeDependency(object obj) 16 | { 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/BaseCtorCall.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Examples 2 | { 3 | public struct Id 4 | { 5 | } 6 | 7 | public static class StaticType 8 | { 9 | public static readonly Id SomeId; 10 | } 11 | 12 | public abstract class BaseCtorCallBase 13 | { 14 | #pragma warning disable 219 15 | protected BaseCtorCallBase(params Id[] ids) 16 | { 17 | } 18 | #pragma warning restore 219 19 | } 20 | 21 | public class BaseCtorCall : BaseCtorCallBase 22 | { 23 | public BaseCtorCall() : 24 | base(StaticType.SomeId) 25 | { 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/DisposableDependency.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetArchTest.TestStructure.Dependencies.Examples 4 | { 5 | /// 6 | /// An example class used in tests that identify dependencies. 7 | /// 8 | class DisposableDependency : IDisposable 9 | { 10 | public void Dispose() 11 | { 12 | throw new NotImplementedException(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/ExampleDep.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Examples 2 | { 3 | /// 4 | /// An example class used in negative tests that identify dependencies. 5 | /// Its name partially matches the 'ExampleDependency' which is actually referenced by test types. 6 | /// 7 | public class ExampleDep 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/ExampleDependency.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Examples 2 | { 3 | /// 4 | /// An example class used in tests that identify dependencies. 5 | /// 6 | public class ExampleDependency 7 | { 8 | } 9 | 10 | public class ExampleDependency 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/ExampleDependencyInPartiallyMatchingNamespace.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Example 2 | { 3 | /// 4 | /// An example class used in negative tests that identify dependencies. 5 | /// Its namespace partially matches the 'Examples' containing 'ExampleDependency' which is actually referenced by test types. 6 | /// 7 | public class ExampleDependencyInPartiallyMatchingNamespace 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/ExampleStaticGenericClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Examples 2 | { 3 | public static class ExampleStaticGenericClass 4 | { 5 | public static void Foo() 6 | { 7 | 8 | } 9 | public static void Foo() 10 | { 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/ExceptionDependency.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetArchTest.TestStructure.Dependencies.Examples 4 | { 5 | /// 6 | /// An example exception used in tests that identify dependencies. 7 | /// 8 | class ExceptionDependency : Exception 9 | { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/Factory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Dependencies.Examples 6 | { 7 | public static class Factory 8 | { 9 | private static ExampleDependency dependency; 10 | private static GenericClass dependencyGeneric; 11 | private static GenericClass[] dependencyArrayOfGenerics; 12 | private static GenericClass dependencyGenericDouble; 13 | private static GenericClass[] dependencyArrayOfDoubles; 14 | 15 | public static ref ExampleDependency Create() 16 | { 17 | return ref dependency; 18 | } 19 | 20 | 21 | public static ref GenericClass CreateGenericDouble() 22 | { 23 | return ref dependencyGenericDouble; 24 | } 25 | 26 | public static ref GenericClass CreateGeneric() 27 | { 28 | return ref dependencyGeneric; 29 | } 30 | public static ref GenericClass[] CreateArrayOfGenerics() 31 | { 32 | return ref dependencyArrayOfGenerics; 33 | } 34 | public static ref GenericClass[] CreateArrayOfDoubles() 35 | { 36 | return ref dependencyArrayOfDoubles; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/GenericClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Examples 2 | { 3 | public class GenericClass 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/IGenericInterface.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Dependencies.Examples 6 | { 7 | interface IGenericInterface 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/IgnoreCaseExampleDependency.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Examples 2 | { 3 | public class ExampleDEPENDENCY 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/NestedDependencyTree.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Examples 2 | { 3 | /// 4 | /// An example class used in tests that identify nested dependencies. 5 | /// 6 | public class NestedDependencyTree 7 | { 8 | public class NestedLevel1 9 | { 10 | public class NestedLevel2 11 | { 12 | public class NestedDependency 13 | { 14 | 15 | } 16 | 17 | public class NestedDependency 18 | { 19 | 20 | } 21 | } 22 | 23 | public class NestedLevel2 24 | { 25 | public class NestedDependency 26 | { 27 | 28 | } 29 | 30 | public class NestedDependency 31 | { 32 | 33 | } 34 | } 35 | } 36 | 37 | 38 | public class NestedLevel1 39 | { 40 | public class NestedLevel2 41 | { 42 | public class NestedDependency 43 | { 44 | 45 | } 46 | 47 | public class NestedDependency 48 | { 49 | 50 | } 51 | } 52 | 53 | public class NestedLevel2 54 | { 55 | public class NestedDependency 56 | { 57 | 58 | } 59 | 60 | public class NestedDependency 61 | { 62 | 63 | } 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/StaticGenericDependency.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Examples 2 | { 3 | public static class StaticGenericDependency 4 | { 5 | public static void Foo() 6 | { 7 | 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Examples/StructDependency.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetArchTest.TestStructure.Dependencies.Examples 4 | { 5 | /// 6 | /// An example struct used in tests that identify dependencies. 7 | /// 8 | struct StructDependency 9 | { 10 | 11 | } 12 | 13 | struct StructDependency 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Implementation/HasAnotherDependency.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Implementation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | public class HasAnotherDependency 6 | { 7 | public AnotherExampleDependency anotherDependency { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Implementation/HasDependencies.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Implementation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | public class HasDependencies 6 | { 7 | public ExampleDependency dependency { get; set; } 8 | public AnotherExampleDependency anotherDependency { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Implementation/HasDependency.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Implementation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | public class HasDependency 6 | { 7 | public ExampleDependency dependency { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Implementation/NoDependency.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Implementation 2 | { 3 | class NoDependency 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/AsyncMethod.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in an asynchronous method definition. 8 | /// 9 | public class AsyncMethod 10 | { 11 | public async Task ExampleMethod() 12 | { 13 | var test = new ExampleDependency(); 14 | await Task.CompletedTask; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/AttributeOnClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency as an attribute. 8 | /// 9 | [AttributeDependency()] 10 | public class AttributeOnClass 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/AttributeOnEvent.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | using NetArchTest.TestStructure.Dependencies.Examples; 6 | 7 | /// 8 | /// Example class that includes a dependency as an attribute. 9 | /// 10 | public class AttributeOnEvent 11 | { 12 | [AttributeDependency()] 13 | #pragma warning disable 67 14 | private event Action foo; 15 | #pragma warning restore 67 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/AttributeOnField.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency as an attribute. 8 | /// 9 | public class AttributeOnField 10 | { 11 | [AttributeDependency()] 12 | #pragma warning disable 169 13 | private int field; 14 | #pragma warning restore 169 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/AttributeOnMethod.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency as an attribute. 8 | /// 9 | public class AttributeOnMethod 10 | { 11 | [AttributeDependency()] 12 | private void method() 13 | { 14 | 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/AttributeOnParameter.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency as an attribute. 8 | /// 9 | public class AttributeOnParameter 10 | { 11 | private void method([AttributeDependency()]int foo) 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/AttributeOnProperty.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency as an attribute. 8 | /// 9 | public class AttributeOnProperty 10 | { 11 | [AttributeDependency()] 12 | private int Field { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/AttributeOnReturnValue.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency as an attribute. 8 | /// 9 | public class AttributeOnReturnValue 10 | { 11 | [return : AttributeDependency()] 12 | private int method() 13 | { 14 | return 7; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/ConstructorPrivate.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a private constructor definition. 7 | /// 8 | public class ConstructorPrivate 9 | { 10 | private ConstructorPrivate() 11 | { 12 | var test = new ExampleDependency(); 13 | } 14 | 15 | public static ConstructorPrivate GetInstance() 16 | { 17 | return new ConstructorPrivate(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/ConstructorPublic.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a public constructor definition. 7 | /// 8 | public class ConstructorPublic 9 | { 10 | public ConstructorPublic() 11 | { 12 | var test = new ExampleDependency(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/DefaultInterfaceMethod.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example interface that includes a dependency in default method. 7 | /// 8 | public interface DefaultInterfaceMethodBody 9 | { 10 | public void ExampleMethod() 11 | { 12 | var test = new ExampleDependency(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/DelegateDeclaration.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example delegate that includes a dependency. 8 | /// 9 | public delegate int DelegateDeclaration(ExampleDependency x, int y); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/EventAdd.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in an event add accessor. 8 | /// 9 | public class EventAdd 10 | { 11 | public event EventHandler ExampleProperty 12 | { 13 | add 14 | { 15 | #pragma warning disable 219 16 | ExampleDependency test = null; 17 | #pragma warning restore 219 18 | } 19 | remove 20 | { 21 | 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/EventPublic.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in a public event definition. 8 | /// 9 | public class EventPublic 10 | { 11 | #pragma warning disable 67 12 | public event Action ExampleProperty; 13 | #pragma warning restore 67 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/EventRemove.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in an event add accessor. 8 | /// 9 | public class EventRemove 10 | { 11 | public event EventHandler ExampleProperty 12 | { 13 | add 14 | { 15 | 16 | } 17 | remove 18 | { 19 | #pragma warning disable 219 20 | ExampleDependency test = null; 21 | #pragma warning restore 219 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/FieldPrivate.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a private field definition. 7 | /// 8 | public class FieldPrivate 9 | { 10 | #pragma warning disable 169 11 | private ExampleDependency Example; 12 | #pragma warning restore 169 13 | public FieldPrivate() 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/FieldPublic.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a public field definition. 7 | /// 8 | public class FieldPublic 9 | { 10 | public ExampleDependency Example; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/GenericConstraintClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | /// 8 | /// Example class that includes a dependency as a generic class constraint. 9 | /// 10 | public class GenericConstraintClass where T : ExampleDependency, new() 11 | { 12 | #pragma warning disable 169 13 | private List> foo; 14 | #pragma warning restore 169 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/GenericConstraintMethod.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | using System.Collections.Generic; 5 | 6 | /// 7 | /// Example class that includes a dependency as a generic method constraint. 8 | /// 9 | public class GenericConstraintMethod 10 | { 11 | void Method(T foo) where T : ExampleDependency 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/GenericMethodTypeArgument.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that has dependency as second type argument on the generic method invocation type argument list 7 | /// 8 | public class GenericMethodTypeArgument 9 | { 10 | public void ExampleMethod() 11 | { 12 | GenericMethod(); 13 | } 14 | 15 | private T2 GenericMethod() where T2 : new() 16 | { 17 | return new T2(); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/GenericMethodTypeArgumentOneOpenOneClosedTypeArgument.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that has dependency as second type argument on the generic method invocation type argument list 7 | /// 8 | public class GenericMethodTypeArgumentOneOpenOneClosedTypeArgument 9 | { 10 | public void ExampleMethod() 11 | { 12 | GenericMethod(); 13 | } 14 | 15 | private T2 GenericMethod() where T2 : new() 16 | { 17 | return new T2(); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/ImplementedInterface.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that implements dependency. 7 | /// 8 | class ImplementedInterface : IGenericInterface 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/IndexerPublic.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a public indexer definition. 7 | /// 8 | public class IndexerPublic 9 | { 10 | public ExampleDependency this[int i] 11 | { 12 | get { return null; } 13 | set { } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/InheritedBaseClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that inherits from a dependency. 7 | /// 8 | public class InheritedBaseClass : ExampleDependency 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/InstructionCtor.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in an instruction invocation. 7 | /// 8 | public class InstructionCtor 9 | { 10 | public void ExampleMethod() 11 | { 12 | object dep = new ExampleDependency(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/InstructionStaticClassTypeArgument.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in an instruction invocation. 7 | /// 8 | public class InstructionStaticClassTypeArgument 9 | { 10 | public InstructionStaticClassTypeArgument() 11 | { 12 | ExampleStaticGenericClass.Foo(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/InstructionStaticMethodTypeArgument.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in an instruction invocation. 7 | /// 8 | public class InstructionStaticMethodTypeArgument 9 | { 10 | public InstructionStaticMethodTypeArgument() 11 | { 12 | ExampleStaticGenericClass.Foo(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/InstructionThrow.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in an instruction invocation. 7 | /// 8 | public class InstructionThrow 9 | { 10 | public void ExampleMethod() 11 | { 12 | throw new ExceptionDependency(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/LambdaCapturedVariable.cs.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | using NetArchTest.TestStructure.Dependencies.Examples; 6 | 7 | /// 8 | /// Example class that includes a dependency in a captured variable by lambda closure. 9 | /// 10 | public class LambdaCapturedVariable 11 | { 12 | public Func ExampleMethod() 13 | { 14 | ExampleDependency test = null; 15 | return () => test; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/MethodArgument.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency as a method argument. 7 | /// 8 | public class MethodArgument 9 | { 10 | public MethodArgument() 11 | { 12 | ExampleMethod(new ExampleDependency()); 13 | } 14 | 15 | 16 | private void ExampleMethod(object parameter) 17 | { 18 | 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/MethodParameter.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency as a method parameter. 7 | /// 8 | public class MethodParameter 9 | { 10 | private void ExampleMethod(ExampleDependency exampleDependency) 11 | { 12 | 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/MethodPrivateBody.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a private method definition. 7 | /// 8 | public class MethodPrivateBody 9 | { 10 | private void ExampleMethod() 11 | { 12 | var test = new ExampleDependency(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/MethodReturnType.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in the return type of a method. 7 | /// 8 | public class MethodReturnType 9 | { 10 | private ExampleDependency ExampleMethod() 11 | { 12 | return null; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/PInvoke.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Runtime.InteropServices; 4 | using System.Threading.Tasks; 5 | using NetArchTest.TestStructure.Dependencies.Examples; 6 | 7 | /// 8 | /// Example class that includes a dependency in a P/Invoke. 9 | /// 10 | public class PInvoke 11 | { 12 | [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] 13 | private static extern int MessageBox(ExampleDependency hWnd); 14 | 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/PropertyGetter.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a public property definition. 7 | /// 8 | public class PropertyGetter 9 | { 10 | public object ExampleProperty 11 | { 12 | get { return new ExampleDependency(); } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/PropertyPrivate.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a private property definition. 7 | /// 8 | public class PropertyPrivate 9 | { 10 | private ExampleDependency ExampleProperty 11 | { 12 | get { return null; } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/PropertyPublic.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a public property definition. 7 | /// 8 | public class PropertyPublic 9 | { 10 | public ExampleDependency ExampleProperty 11 | { 12 | get { return null; } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/PropertySetter.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a public property definition. 7 | /// 8 | public class PropertySetter 9 | { 10 | public object ExampleProperty 11 | { 12 | set { var foo = value as ExampleDependency; } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/StaticLocalFunction.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in a static local function body. 8 | /// 9 | public class StaticLocalFunction 10 | { 11 | public void ExampleMethod() 12 | { 13 | 14 | #pragma warning disable 8321 15 | static void LocalFunction() 16 | { 17 | var y = new ExampleDependency(); 18 | } 19 | #pragma warning restore 8321 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/SwitchPatternMatching.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | using NetArchTest.TestStructure.Dependencies.Examples; 6 | 7 | /// 8 | /// Example class that includes a dependency in switch pattern matching. 9 | /// 10 | class SwitchPatternMatching 11 | { 12 | public SwitchPatternMatching() 13 | { 14 | var foo = new Object(); 15 | switch (foo) 16 | { 17 | case ExampleDependency _: 18 | break; 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/TryCatch.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | using NetArchTest.TestStructure.Dependencies.Examples; 6 | 7 | /// 8 | /// Example class that includes a dependency in a catch. 9 | /// 10 | public class TryCatch 11 | { 12 | public void ExampleMethod() 13 | { 14 | try 15 | { 16 | 17 | } 18 | #pragma warning disable 168 19 | catch (ExceptionDependency ex) 20 | #pragma warning restore 168 21 | { 22 | 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/TryCatchBlock.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | using NetArchTest.TestStructure.Dependencies.Examples; 6 | 7 | /// 8 | /// Example class that includes a dependency in a catch. 9 | /// 10 | public class TryCatchBlock 11 | { 12 | public void ExampleMethod() 13 | { 14 | try 15 | { 16 | 17 | } 18 | catch (Exception ex) 19 | { 20 | object foo = ex as ExceptionDependency; 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/TryCatchExceptionFilter.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | using NetArchTest.TestStructure.Dependencies.Examples; 6 | 7 | /// 8 | /// Example class that includes a dependency in an exception filter. 9 | /// 10 | public class TryCatchExceptionFilter 11 | { 12 | public void ExampleMethod() 13 | { 14 | try 15 | { 16 | 17 | } 18 | catch (Exception ex) when (ex is ExceptionDependency) 19 | { 20 | 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/TryFinallyBlock.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | using NetArchTest.TestStructure.Dependencies.Examples; 6 | 7 | /// 8 | /// Example class that includes a dependency in a finally. 9 | /// 10 | public class TryFinallyBlock 11 | { 12 | public void ExampleMethod() 13 | { 14 | try 15 | { 16 | 17 | } 18 | finally 19 | { 20 | #pragma warning disable 219 21 | ExampleDependency foo = null; 22 | #pragma warning restore 219 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/UsingStatement.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Collections.Generic; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in using statement. 8 | /// 9 | class UsingStatement 10 | { 11 | public UsingStatement() 12 | { 13 | using (var foo = new DisposableDependency()) 14 | { 15 | 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyLocation/Yield.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyLocation 2 | { 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | using NetArchTest.TestStructure.Dependencies.Examples; 6 | 7 | /// 8 | /// Example class that includes a dependency in a yield return statement. 9 | /// 10 | public class Yield 11 | { 12 | public IEnumerable ExampleMethod() 13 | { 14 | yield return 7; 15 | yield return new ExampleDependency(); 16 | yield return 77; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/Array.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes an array dependency 8 | /// 9 | public class Array 10 | { 11 | public void ExampleMethod() 12 | { 13 | #pragma warning disable 219 14 | ExampleDependency[] test = null; 15 | #pragma warning restore 219 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/ArrayJagged.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes an array dependency 8 | /// 9 | public class ArrayJagged 10 | { 11 | public void ExampleMethod() 12 | { 13 | #pragma warning disable 219 14 | ExampleDependency[][] test = null; 15 | #pragma warning restore 219 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/ArrayMultidimensional.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes an array dependency 8 | /// 9 | public class ArrayMultidimensional 10 | { 11 | public void ExampleMethod() 12 | { 13 | #pragma warning disable 219 14 | ExampleDependency[,] test = null; 15 | #pragma warning restore 219 16 | 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/ArrayOfGenerics.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes an array dependency 8 | /// 9 | public class ArrayOfGenerics 10 | { 11 | public void ExampleMethod() 12 | { 13 | #pragma warning disable 219 14 | ExampleDependency[] test1 = null; 15 | ExampleDependency[] test2 = null; 16 | #pragma warning restore 219 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/ArrayOfGenericsTypeArgument.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes an array dependency 8 | /// 9 | public class ArrayOfGenericsTypeArgument 10 | { 11 | public void ExampleMethod() 12 | { 13 | #pragma warning disable 219 14 | GenericClass[] test1 = null; 15 | GenericClass[] test2 = null; 16 | #pragma warning restore 219 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/ConstStringFieldValue.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | public class ConstStringFieldValue 6 | { 7 | #pragma warning disable 219 8 | private const string FullTypeName = "NetArchTest.TestStructure.Dependencies.Search.DependencyType.Array"; 9 | private ExampleDependency dummy = null; 10 | #pragma warning restore 219 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/MethodParameterIn.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in an instruction invocation. 7 | /// 8 | public class MethodParameterIn 9 | { 10 | public void Foo(in ExampleDependency example) 11 | { 12 | 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/MethodParameterOut.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in an instruction invocation. 7 | /// 8 | public class MethodParameterOut 9 | { 10 | public void Foo(out ExampleDependency example) 11 | { 12 | example = null; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/MethodParameterRef.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in method's parameter passed by reference. 7 | /// 8 | public class MethodParameterRef 9 | { 10 | public void Foo(ref ExampleDependency example) 11 | { 12 | 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/NestedDependencyClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a nested class from difrent class. 7 | /// 8 | public class NestedDependencyClass 9 | { 10 | private void ExampleMethod() 11 | { 12 | #pragma warning disable 219 13 | NestedDependencyTree.NestedLevel1.NestedLevel2.NestedDependency foo = null; 14 | #pragma warning restore 219 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/NestedDependencyClassGeneric.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a nested class from difrent class. 7 | /// 8 | public class NestedDependencyClassGeneric 9 | { 10 | private void ExampleMethod() 11 | { 12 | #pragma warning disable 219 13 | NestedDependencyTree.NestedLevel1.NestedLevel2.NestedDependency foo = null; 14 | #pragma warning restore 219 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/NestedDependencyClassGenericLevel2Generic.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a nested class from difrent class. 7 | /// 8 | public class NestedDependencyClassGenericLevel2Generic 9 | { 10 | private void ExampleMethod() 11 | { 12 | #pragma warning disable 219 13 | NestedDependencyTree.NestedLevel1.NestedLevel2.NestedDependency foo = null; 14 | #pragma warning restore 219 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/NestedDependencyClassLevel2Generic.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in a nested class from difrent class. 7 | /// 8 | public class NestedDependencyClassLevel2Generic 9 | { 10 | private void ExampleMethod() 11 | { 12 | #pragma warning disable 219 13 | NestedDependencyTree.NestedLevel1.NestedLevel2.NestedDependency foo = null; 14 | #pragma warning restore 219 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/Pointer.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in pointer declaration. 8 | /// 9 | public class Pointer 10 | { 11 | public Pointer() 12 | { 13 | unsafe 14 | { 15 | StructDependency* test = null; 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/PointerNot.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that does not include a dependency in pointer declaration. 8 | /// 9 | public class PointerNot 10 | { 11 | public PointerNot() 12 | { 13 | unsafe 14 | { 15 | #pragma warning disable 168 16 | StructDependency test; 17 | #pragma warning restore 168 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/StaticGenericClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in an instruction invocation. 7 | /// 8 | public class StaticGenericClass 9 | { 10 | public StaticGenericClass() 11 | { 12 | StaticGenericDependency.Foo(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/Variable.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in variable declaration. 8 | /// 9 | public class Variable 10 | { 11 | public Variable() 12 | { 13 | #pragma warning disable 219 14 | ExampleDependency test = null; 15 | #pragma warning restore 219 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/VariableGeneric.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes a dependency in an instruction invocation. 7 | /// 8 | public class VariableGeneric 9 | { 10 | public VariableGeneric() 11 | { 12 | #pragma warning disable 219 13 | ExampleDependency dependecy = null; 14 | #pragma warning restore 219 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/VariableGenericTypeArgument.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Collections.Generic; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in variable declaration. 8 | /// 9 | public class VariableGenericTypeArgument 10 | { 11 | public VariableGenericTypeArgument() 12 | { 13 | #pragma warning disable 219 14 | GenericClass test = null; 15 | #pragma warning restore 219 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/VariableGenericTypeArgumentNested.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Collections.Generic; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in variable declaration. 8 | /// 9 | public class VariableGenericTypeArgumentNested 10 | { 11 | public VariableGenericTypeArgumentNested() 12 | { 13 | #pragma warning disable 219 14 | GenericClass> test = null; 15 | #pragma warning restore 219 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/VariableRef.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in variable declaration. 8 | /// 9 | public class VariableRef 10 | { 11 | public VariableRef() 12 | { 13 | ref ExampleDependency test = ref Factory.Create(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/VariableRefArrayOfGenericsTypeArgument.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in variable declaration. 8 | /// 9 | public class VariableRefArrayOfGenericsTypeArgument 10 | { 11 | public VariableRefArrayOfGenericsTypeArgument() 12 | { 13 | ref GenericClass test1 = ref Factory.CreateGenericDouble(); 14 | ref GenericClass[] test2 = ref Factory.CreateArrayOfDoubles(); 15 | ref GenericClass[] test3 = ref Factory.CreateArrayOfGenerics(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/VariableRefGenericTypeArgument.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System.Threading.Tasks; 4 | using NetArchTest.TestStructure.Dependencies.Examples; 5 | 6 | /// 7 | /// Example class that includes a dependency in variable declaration. 8 | /// 9 | public class VariableRefGenericTypeArgument 10 | { 11 | public VariableRefGenericTypeArgument() 12 | { 13 | ref GenericClass test1 = ref Factory.CreateGenericDouble(); 14 | ref GenericClass test2 = ref Factory.CreateGeneric(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/DependencyType/VariableTuple.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search.DependencyType 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using NetArchTest.TestStructure.Dependencies.Examples; 6 | 7 | /// 8 | /// Example class that includes a dependency in variable declaration. 9 | /// 10 | public class VariableTuple 11 | { 12 | public VariableTuple() 13 | { 14 | #pragma warning disable 219 15 | Tuple test = null; 16 | #pragma warning restore 219 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/GenericMethodGenericParameter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Dependencies.Search 6 | { 7 | internal class GenericMethodGenericParameter 8 | { 9 | public static void Deconstruct(KeyValuePair tuple, T1[] key, out T2 value) 10 | { 11 | key = null; 12 | value = tuple.Value; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/Search/IndirectReference.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.Search 2 | { 3 | using NetArchTest.TestStructure.Dependencies.Examples; 4 | 5 | /// 6 | /// Example class that includes an indirect reference to a dependency in an different class. 7 | /// 8 | public class IndirectReference 9 | { 10 | public void ExampleMethod() 11 | { 12 | var test = new ReferringType(); 13 | } 14 | } 15 | 16 | public class ReferringType 17 | { 18 | public void Example() 19 | { 20 | var reference = new ExampleDependency(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/TypeOfSearch/Classes.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.TypeOfSearch 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using NetArchTest.TestStructure.Dependencies.TypeOfSearch.D1; 8 | using NetArchTest.TestStructure.Dependencies.TypeOfSearch.D2; 9 | using NetArchTest.TestStructure.Dependencies.TypeOfSearch.D3; 10 | 11 | #pragma warning disable 169 12 | 13 | public class Class_A 14 | { 15 | string stringField = "I am not a dependency!"; 16 | 17 | public static void LetUsCreateSomeAnonymousTypes() 18 | { 19 | var numbers = Enumerable.Range(0, 1); 20 | var result = from x in numbers 21 | join z in numbers on x equals z 22 | select (x, z); 23 | } 24 | 25 | 26 | public static int LetUsUseSwitchExpressionWithMoreThan7(string element) 27 | { 28 | return element switch 29 | { 30 | "one" => 1, 31 | "two" => 2, 32 | "three" => 3, 33 | "four" => 4, 34 | "five" => 5, 35 | "six" => 6, 36 | "seven" => 7, 37 | _ => 8, 38 | }; 39 | } 40 | } 41 | 42 | public class Class_B 43 | { 44 | Dependency_3 dp3; 45 | } 46 | 47 | public class Class_C 48 | { 49 | Dependency_2 dp2; 50 | } 51 | 52 | public class Class_D 53 | { 54 | Dependency_2 dp2; 55 | Dependency_3 dp3; 56 | } 57 | 58 | public class Class_E 59 | { 60 | Dependency_1 dp1; 61 | } 62 | 63 | public class Class_F 64 | { 65 | Dependency_1 dp1; 66 | Dependency_3 dp3; 67 | } 68 | 69 | public class Class_G 70 | { 71 | Dependency_1 dp1; 72 | Dependency_2 dp2; 73 | } 74 | 75 | public class Class_H 76 | { 77 | Dependency_1 dp1; 78 | Dependency_2 dp2; 79 | Dependency_3 dp3; 80 | } 81 | 82 | #pragma warning restore 169 83 | 84 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Dependencies/TypeOfSearch/Dependencies.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Dependencies.TypeOfSearch 2 | { 3 | 4 | namespace D1 5 | { 6 | public class Dependency_1 7 | { 8 | 9 | } 10 | } 11 | 12 | namespace D2 13 | { 14 | public class Dependency_2 15 | { 16 | 17 | } 18 | } 19 | 20 | namespace D3 21 | { 22 | public class Dependency_3 23 | { 24 | 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/FalsePositives/ClassMatchingExample.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.FalsePositives 2 | { 3 | public class ClassMatchingExample 4 | { 5 | private readonly NamespaceMatch.PatternMatchToo dependency; 6 | 7 | public ClassMatchingExample() 8 | { 9 | dependency = new NamespaceMatch.PatternMatchToo(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/FalsePositives/ModuleAsNamespacePrefix/ExampleClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace ModuleAsNamespacePrefix 6 | { 7 | class ExampleClass 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/FalsePositives/NamespaceMatch/PatternMatch.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.FalsePositives.NamespaceMatch 2 | { 3 | public class PatternMatch 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/FalsePositives/NamespaceMatch/PatternMatchToo.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.FalsePositives.NamespaceMatch 2 | { 3 | public class PatternMatchToo 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/FalsePositives/NamespaceMatchToo/ExampleClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.FalsePositives.NamespaceMatchToo 2 | { 3 | public class ExampleClass 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/FalsePositives/NamespaceMatchingExample.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.FalsePositives 2 | { 3 | public class ImplementationExample 4 | { 5 | private NamespaceMatchToo.ExampleClass dependency; 6 | 7 | public ImplementationExample() 8 | { 9 | dependency = new NamespaceMatchToo.ExampleClass(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/FalsePositives/SystemAsNamespacePrefix/ExampleClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SystemAsNamespacePrefix 6 | { 7 | class ExampleClass 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/File/Correct/IncorrectSourceFileNameType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.File.Correct 6 | { 7 | internal class IncorrectSourceFileNameTypeFoo 8 | { 9 | public IncorrectSourceFileNameTypeFoo() 10 | { 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/File/Incorrect/CorrectSourceFileNameType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.File.Incorrect.Yabadabado 6 | { 7 | internal class CorrectSourceFileNameType 8 | { 9 | public CorrectSourceFileNameType() 10 | { 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/File/SourceFileNameType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.File 6 | { 7 | internal class SourceFileNameType 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/File/Tests/CorrectSourceFileNameTypeTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.File.Tests 6 | { 7 | internal class CorrectSourceFileNameTypeTests 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Inheritance/BaseClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Inheritance 2 | { 3 | public class BaseClass 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Inheritance/DerivedClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Inheritance 2 | { 3 | public class DerivedClass : BaseClass 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Inheritance/DerivedDerivedClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Inheritance 2 | { 3 | public class DerivedDerivedClass : DerivedClass 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Inheritance/NotDerivedClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Inheritance 2 | { 3 | public class NotDerivedClass 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Interfaces/DoesNotImplementInterface.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Interfaces 2 | { 3 | public class DoesNotImplementInterface 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Interfaces/IExample.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Interfaces 2 | { 3 | public interface IExample 4 | { 5 | } 6 | 7 | 8 | 9 | public interface IGenericExample : IExample 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Interfaces/ImplementsExampleInterface.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Interfaces 2 | { 3 | public class ImplementsExampleInterface : IExample 4 | { 5 | } 6 | 7 | 8 | public class ImplementsGenericExampleInterface : IGenericExample 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Metrics/ClassSmall.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Metrics 6 | { 7 | internal class ClassSmall 8 | { 9 | // This method was generated by GPT-4 Turbo :D 10 | public static string Foo(string s) 11 | { 12 | if (string.IsNullOrEmpty(s)) 13 | { 14 | return s; 15 | } 16 | 17 | string[] words = s.Split(); 18 | 19 | StringBuilder result = new StringBuilder(); 20 | 21 | foreach (string word in words) 22 | { 23 | result.Append(char.ToUpper(word[0]) + word.Substring(1) + " "); 24 | } 25 | 26 | return result.ToString().Trim(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Mutability/ImmutableTypes.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Mutability 2 | { 3 | public class ImmutableClass_PropertyOnlyGet 4 | { 5 | public object GetOnlyProperty { get; } 6 | } 7 | public class ImmutableClass_PropertyInit 8 | { 9 | public object GetOnlyProperty { get; init; } 10 | } 11 | 12 | public class ImmutableClass_FieldConst 13 | { 14 | public const object constField = null; 15 | } 16 | public class ImmutableClass_FieldReadonly 17 | { 18 | public readonly object readonlyField; 19 | } 20 | 21 | public class ImmutableClass_FieldReadonlyPrivate 22 | { 23 | #pragma warning disable 169 24 | private readonly object privateField; 25 | #pragma warning restore 169 26 | } 27 | 28 | public record class ImmutableRecord(int Property) 29 | { 30 | } 31 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Mutability/MutableTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetArchTest.TestStructure.Mutability 4 | { 5 | public class MutableClass_PublicProperty 6 | { 7 | public object Property { get; set; } 8 | } 9 | 10 | public class MutableClass_PublicPropertyPrivateSet 11 | { 12 | public object Property { get; private set; } 13 | } 14 | 15 | public class MutableClass_PublicField 16 | { 17 | public object field; 18 | } 19 | 20 | public class MutableClass_PrivateField 21 | { 22 | private object field; 23 | } 24 | 25 | public class MutableClass_PublicEvent 26 | { 27 | public event Action Event; 28 | } 29 | 30 | public record struct MutableRecord(int Property) 31 | { 32 | } 33 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/Namespace1/ClassA1.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.NameMatching.Namespace1 2 | { 3 | public class ClassA1 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/Namespace1/ClassA2.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.NameMatching.Namespace1 2 | { 3 | public class ClassA2 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/Namespace1/ClassB1.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.NameMatching.Namespace1 2 | { 3 | public class ClassB1 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/Namespace2/ClassA3.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.NameMatching.Namespace2 2 | { 3 | public class ClassA3 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/Namespace2/Namespace3/ClassB2.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3 2 | { 3 | class ClassB2 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/Namespace3/A/SomeThing.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.NameMatching.Namespace3.A 2 | { 3 | public class SomeThing 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/Namespace3/A/SomethingElse.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.NameMatching.Namespace3.A 2 | { 3 | public class SomethingElse 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/Namespace3/B/SomeEntity.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.NameMatching.Namespace3.B 2 | { 3 | public class SomeEntity 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/Namespace3/B/SomeIdentity.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.NameMatching.Namespace3.B 2 | { 3 | public class SomeIdentity 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/NamespaceGeneric/Namespace1/ClassA1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.NameMatching.NamespaceGeneric.Namespace1 6 | { 7 | public class ClassA1 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NameMatching/NamespaceGeneric/NamespaceA/ClassG1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.NameMatching.NamespaceGeneric.NamespaceA 6 | { 7 | internal class ClassG1 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Names/Namespace1/ClassA1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Names.Namespace1 6 | { 7 | internal class ClassA1 8 | { 9 | 10 | 11 | public class Nested 12 | { 13 | 14 | } 15 | } 16 | 17 | internal class CLASSa1 18 | { 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Names/Namespace1/ClassA2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Names.Namespace1 6 | { 7 | internal class ClassA2 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Names/Namespace1/ClassB1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Names.Namespace1 6 | { 7 | internal class ClassB1 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Names/Namespace2/ClassA1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Names.Namespace2 6 | { 7 | internal class ClassA1 8 | { 9 | 10 | public class Nested1 11 | { 12 | 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Names/Namespace2/ClassG1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Names.Namespace2 6 | { 7 | internal class ClassG1 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/NetArchTest.TestStructure.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.1 5 | 11.0 6 | 7 | 8 | 9 | true 10 | false 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Nullable/NonNullableClass1.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Nullable { 2 | 3 | /// 4 | /// An example class that has has non-nullable (i.e.null simple value typed) members. 5 | /// 6 | public class NonNullableClass1 { 7 | public int _nonNullableIntField; 8 | 9 | public int? NullableIntProperty {get; set;} 10 | } 11 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Nullable/NonNullableClass2.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Nullable { 2 | 3 | /// 4 | /// An example class that has has non-nullable (i.e.null simple value typed) members. 5 | /// 6 | public class NonNullableClass2 { 7 | public int? _nullableIntField; 8 | 9 | public int NonNullableIntProperty {get; set;} 10 | } 11 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Nullable/NonNullableClass3.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Nullable { 2 | 3 | /// 4 | /// An example class that has has non-nullable (i.e.null simple value typed) members. 5 | /// 6 | public class NonNullableClass3 { 7 | public TestEnum EnumProperty {get; set;} 8 | 9 | public enum TestEnum { 10 | red, 11 | blue, 12 | green 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Nullable/NonNullableClass4.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Nullable { 2 | 3 | /// 4 | /// An example class that has has non-nullable (i.e.null simple value typed) members. 5 | /// 6 | public class NonNullableClass4 { 7 | public TestStruct StructProperty {get; set;} 8 | 9 | public struct TestStruct { 10 | #pragma warning disable 169 11 | public object nullableObject; 12 | public int nonNullable; 13 | #pragma warning restore 169 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Nullable/NullableClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Nullable { 2 | 3 | /// 4 | /// An example class that has has only nullable members. 5 | /// 6 | public class NullableClass { 7 | public int? _nullableIntField; 8 | 9 | public int? NullableIntProperty {get; set;} 10 | 11 | public object NullableObjectField; 12 | } 13 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Slices/InvalidTree.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Slices 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Dynamic; 6 | using System.Text; 7 | 8 | 9 | namespace InvalidTree 10 | { 11 | namespace FeatureA 12 | { 13 | using NetArchTest.TestStructure.Slices.ValidTree.FeatureA.App; 14 | namespace App 15 | { 16 | using NetArchTest.TestStructure.Slices.ValidTree.FeatureA.Domain; 17 | 18 | class AppService { AggregateRoot root; } 19 | } 20 | namespace Domain 21 | { 22 | class ValueObject { } 23 | class AggregateRoot { ValueObject value; } 24 | } 25 | namespace Infrastructure 26 | { 27 | namespace Persistence 28 | { 29 | using NetArchTest.TestStructure.Slices.InvalidTree.FeatureB; 30 | using NetArchTest.TestStructure.Slices.ValidTree.FeatureA.Domain; 31 | class Repository { DAO dao; } 32 | } 33 | } 34 | class FeatureA : FeatureBase { AppService app; } 35 | } 36 | namespace FeatureB 37 | { 38 | class AppService { DAO dao; } 39 | class DAO { } 40 | class FeatureB : FeatureBase { AppService app; } 41 | } 42 | namespace FeatureC 43 | { 44 | class FeatureC : FeatureBase { } 45 | } 46 | 47 | class FeatureBase 48 | { 49 | 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Slices/ValidTree.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Slices 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Dynamic; 6 | using System.Text; 7 | 8 | 9 | namespace ValidTree 10 | { 11 | namespace FeatureA 12 | { 13 | using NetArchTest.TestStructure.Slices.ValidTree.FeatureA.App; 14 | namespace App 15 | { 16 | using NetArchTest.TestStructure.Slices.ValidTree.FeatureA.Domain; 17 | 18 | class AppService { AggregateRoot root; } 19 | } 20 | namespace Domain 21 | { 22 | class ValueObject { } 23 | class AggregateRoot { ValueObject value; } 24 | } 25 | namespace Infrastructure 26 | { 27 | namespace Persistence 28 | { 29 | using NetArchTest.TestStructure.Slices.ValidTree.FeatureA.Domain; 30 | class Repository { AggregateRoot root; } 31 | } 32 | } 33 | class FeatureA : FeatureBase { AppService app; } 34 | } 35 | namespace FeatureB 36 | { 37 | class AppService { DAO dao; } 38 | class DAO { } 39 | class FeatureB : FeatureBase { AppService app; } 40 | } 41 | namespace FeatureC 42 | { 43 | class FeatureC : FeatureBase { } 44 | } 45 | 46 | class FeatureBase 47 | { 48 | 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Stateless/StatefulTypes.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Stateless 2 | { 3 | internal class StatefulClass_Field 4 | { 5 | public int field; 6 | } 7 | internal record class StatefulRecordClass(int Prop); 8 | 9 | internal record struct StatefulRecordStruct(int Prop); 10 | 11 | internal class StatefulClass_Prop 12 | { 13 | public int Prop { get; set; } 14 | } 15 | 16 | internal class StatefulClass_ReadonlyField 17 | { 18 | public readonly int field = 7; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Stateless/StatelessTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NetArchTest.TestStructure.Stateless 6 | { 7 | internal class StatelessClass_StaticField 8 | { 9 | public static int field; 10 | } 11 | internal class StatelessClass_ConstField 12 | { 13 | public const int field = 7; 14 | } 15 | internal class StatelessClass_StaticReadonlyField 16 | { 17 | public static readonly int field = 7; 18 | } 19 | 20 | internal class StatelessClass_Prop 21 | { 22 | public static int Prop { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Traits/AbstractClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Traits 2 | { 3 | public abstract class AbstractClass 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Traits/GenericClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Traits 2 | { 3 | public class GenericClass 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Traits/PlainClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Traits 2 | { 3 | public class PlainClass 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Traits/SealedClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Traits 2 | { 3 | /// 4 | /// An example class that has been marked as sealed. 5 | /// 6 | public sealed class SealedClass 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Traits/StaticClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Traits 2 | { 3 | public static class StaticClass 4 | { 5 | static StaticClass() 6 | { 7 | 8 | } 9 | 10 | public static bool SampleMethod() => true; 11 | } 12 | } -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Types/ExampleClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Types 2 | { 3 | public class ExampleClass 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Types/ExampleDelegate.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Types 2 | { 3 | internal delegate void ExampleDelegate(); 4 | } 5 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Types/ExampleEnum.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Types 2 | { 3 | public enum ExampleEnum 4 | { 5 | Zero, 6 | One 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Types/ExampleRecordClass.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Types 2 | { 3 | public record class ExampleRecordClass 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Types/ExampleRecordStruct.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Types 2 | { 3 | public record struct ExampleRecordStruct 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Types/ExampleStruct.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Types 2 | { 3 | public struct ExampleStruct 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/NetArchTest.TestStructure/Types/IExampleInterface.cs: -------------------------------------------------------------------------------- 1 | namespace NetArchTest.TestStructure.Types 2 | { 3 | public interface IExampleInterface 4 | { 5 | } 6 | } 7 | --------------------------------------------------------------------------------