Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ insert_final_newline = true

# C# files
[*.cs]
charset = utf-8-bom

#### .NET Coding Conventions ####

Expand Down
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# ReSharper DotSettings files are in Unix Format
*.DotSettings text eol=lf
*.sln text eol=crlf
# .cs files use native line endings (CRLF on Windows, LF on Linux/macOS):
# tests compare raw string literals against messages built with Environment.NewLine,
# so the checkout eol must match the platform. Do not force eol=crlf here.
*.cs text

# Allows checking out and developing in Windows
# while mounting and running tests in Linux
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Build.ApiChecks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nuke.Common;
using Nuke.Common;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Build.Benchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Build.CodeAnalysis.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nuke.Common;
using Nuke.Common;
using Nuke.Common.Tools.SonarScanner;

// ReSharper disable AllUnderscoreLocalParameterName
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Build.CodeCoverage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nuke.Common;
using Nuke.Common;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.ReportGenerator;
using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Build.Compile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using Nuke.Common;
using Nuke.Common.IO;
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Build.MutationTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Build.Pack.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Build.UnitTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Nuke.Common;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Build.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nuke.Common;
using Nuke.Common;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;
using Nuke.Common.Tooling;

[TypeConverter(typeof(TypeConverter<Configuration>))]
Expand Down
78 changes: 39 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ evaluated collection that you can navigate and filter further.
While `In` starts from concrete reflection objects, `Types` selects types *by criteria* — the natural entry
point for architecture rules:

| Source | Returns |
|-----------------------------------------------------------------|---------------------------------------------------------------------------------|
| `Types.InNamespace("ns")` | all types within a namespace and its sub-namespaces (across loaded assemblies) |
| `Types.InAllLoadedAssemblies()` | all types in all currently loaded assemblies |
| `Types.InAssemblies(a1, a2, …)` | all types in the given assemblies |
| `Types.InAssemblyContaining<T>()` / `…(typeof(T))` | all types in the assembly that declares `T` |
| Source | Returns |
|----------------------------------------------------|--------------------------------------------------------------------------------|
| `Types.InNamespace("ns")` | all types within a namespace and its sub-namespaces (across loaded assemblies) |
| `Types.InAllLoadedAssemblies()` | all types in all currently loaded assemblies |
| `Types.InAssemblies(a1, a2, …)` | all types in the given assemblies |
| `Types.InAssemblyContaining<T>()` / `…(typeof(T))` | all types in the assembly that declares `T` |

`Types.InNamespace(…)` searches all loaded assemblies by default; chain one of the same `In*` methods directly
after it to clarify the assembly source (it can only be specified once, before any further filters):
Expand Down Expand Up @@ -267,34 +267,34 @@ outside the namespace.

### Types

| Kind | Filter | Assert (single) | Assert (many) |
|---------------------|-------------------------------------------------|-----------------------------|------------------------------|
| class | `.WhichAreClasses()` / `.Classes()` | `.IsAClass()` | `.AreClasses()` |
| interface | `.WhichAreInterfaces()` / `.Interfaces()` | `.IsAnInterface()` | `.AreInterfaces()` |
| enum | `.WhichAreEnums()` / `.Enums()` | `.IsAnEnum()` | `.AreEnums()` |
| struct | `.WhichAreStructs()` / `.Structs()` | `.IsAStruct()` | `.AreStructs()` |
| record | `.WhichAreRecords()` / `.Records()` | `.IsARecord()` | `.AreRecords()` |
| record struct | `.WhichAreRecordStructs()` / `.RecordStructs()` | `.IsARecordStruct()` | `.AreRecordStructs()` |
| readonly struct | `.WhichAreReadOnly()` | `.IsReadOnly()` | `.AreReadOnly()` |
| ref struct | `.WhichAreRefStructs()` | `.IsARefStruct()` | `.AreRefStructs()` |
| delegate | `.WhichAreDelegates()` | `.IsADelegate()` | `.AreDelegates()` |
| exception | `.WhichAreExceptions()` | `.IsAnException()` | `.AreExceptions()` |
| attribute | `.WhichAreAttributes()` | `.IsAnAttribute()` | `.AreAttributes()` |
| abstract | `.WhichAreAbstract()` / `.Abstract` | `.IsAbstract()` | `.AreAbstract()` |
| sealed | `.WhichAreSealed()` / `.Sealed` | `.IsSealed()` | `.AreSealed()` |
| static | `.WhichAreStatic()` / `.Static` | `.IsStatic()` | `.AreStatic()` |
| generic | `.WhichAreGeneric()` / `.Generic` | `.IsGeneric()` | `.AreGeneric()` |
| nested | `.WhichAreNested()` / `.Nested` | `.IsNested()` | `.AreNested()` |
| inherits from | `.WhichInheritFrom<T>()` | `.InheritsFrom<T>()` | `.InheritFrom<T>()` |
| implements | `.WhichImplement<T>()` | `.Implements<T>()` | `.Implement<T>()` |
| assignable to | `.WhichAreAssignableTo<T>()` | `.IsAssignableTo<T>()` | `.AreAssignableTo<T>()` |
| assignable from | `.WhichAreAssignableFrom<T>()` | `.IsAssignableFrom<T>()` | `.AreAssignableFrom<T>()` |
| instantiable | `.WhichAreInstantiable()` | `.IsInstantiable()` | `.AreInstantiable()` |
| immutable | `.WhichAreImmutable()` | `.IsImmutable()` | `.AreImmutable()` |
| default constructor | `.WhichHaveADefaultConstructor()` | `.HasADefaultConstructor()` | `.HaveADefaultConstructor()` |
| only nullable members | `.WhichOnlyHaveNullableMembers()` | `.OnlyHasNullableMembers()` | `.OnlyHaveNullableMembers()` |
| only non-nullable members | `.WhichOnlyHaveNonNullableMembers()` | `.OnlyHasNonNullableMembers()` | `.OnlyHaveNonNullableMembers()` |
| custom predicate | `.Which(t => …)` | `.Satisfies(t => …)` | `.All().Satisfy(t => …)` |
| Kind | Filter | Assert (single) | Assert (many) |
|---------------------------|-------------------------------------------------|--------------------------------|---------------------------------|
| class | `.WhichAreClasses()` / `.Classes()` | `.IsAClass()` | `.AreClasses()` |
| interface | `.WhichAreInterfaces()` / `.Interfaces()` | `.IsAnInterface()` | `.AreInterfaces()` |
| enum | `.WhichAreEnums()` / `.Enums()` | `.IsAnEnum()` | `.AreEnums()` |
| struct | `.WhichAreStructs()` / `.Structs()` | `.IsAStruct()` | `.AreStructs()` |
| record | `.WhichAreRecords()` / `.Records()` | `.IsARecord()` | `.AreRecords()` |
| record struct | `.WhichAreRecordStructs()` / `.RecordStructs()` | `.IsARecordStruct()` | `.AreRecordStructs()` |
| readonly struct | `.WhichAreReadOnly()` | `.IsReadOnly()` | `.AreReadOnly()` |
| ref struct | `.WhichAreRefStructs()` | `.IsARefStruct()` | `.AreRefStructs()` |
| delegate | `.WhichAreDelegates()` | `.IsADelegate()` | `.AreDelegates()` |
| exception | `.WhichAreExceptions()` | `.IsAnException()` | `.AreExceptions()` |
| attribute | `.WhichAreAttributes()` | `.IsAnAttribute()` | `.AreAttributes()` |
| abstract | `.WhichAreAbstract()` / `.Abstract` | `.IsAbstract()` | `.AreAbstract()` |
| sealed | `.WhichAreSealed()` / `.Sealed` | `.IsSealed()` | `.AreSealed()` |
| static | `.WhichAreStatic()` / `.Static` | `.IsStatic()` | `.AreStatic()` |
| generic | `.WhichAreGeneric()` / `.Generic` | `.IsGeneric()` | `.AreGeneric()` |
| nested | `.WhichAreNested()` / `.Nested` | `.IsNested()` | `.AreNested()` |
| inherits from | `.WhichInheritFrom<T>()` | `.InheritsFrom<T>()` | `.InheritFrom<T>()` |
| implements | `.WhichImplement<T>()` | `.Implements<T>()` | `.Implement<T>()` |
| assignable to | `.WhichAreAssignableTo<T>()` | `.IsAssignableTo<T>()` | `.AreAssignableTo<T>()` |
| assignable from | `.WhichAreAssignableFrom<T>()` | `.IsAssignableFrom<T>()` | `.AreAssignableFrom<T>()` |
| instantiable | `.WhichAreInstantiable()` | `.IsInstantiable()` | `.AreInstantiable()` |
| immutable | `.WhichAreImmutable()` | `.IsImmutable()` | `.AreImmutable()` |
| default constructor | `.WhichHaveADefaultConstructor()` | `.HasADefaultConstructor()` | `.HaveADefaultConstructor()` |
| only nullable members | `.WhichOnlyHaveNullableMembers()` | `.OnlyHasNullableMembers()` | `.OnlyHaveNullableMembers()` |
| only non-nullable members | `.WhichOnlyHaveNonNullableMembers()` | `.OnlyHasNonNullableMembers()` | `.OnlyHaveNonNullableMembers()` |
| custom predicate | `.Which(t => …)` | `.Satisfies(t => …)` | `.All().Satisfy(t => …)` |

`WhichInheritFrom` / `InheritsFrom` consider only the **base-class chain** (not implemented interfaces) and
accept a generic argument or a `Type`, plus an optional `forceDirect` flag to require *direct* inheritance.
Expand Down Expand Up @@ -788,11 +788,11 @@ how to combine them with reusable type selections into a full architecture test

The dependency filters and assertions follow the familiar filter/assert pairing:

| | Filter | Assert (single) | Assert (many) |
|--------------------------|------------------------------|-------------------------|------------------------|
| depends on namespace | `.WhichDependOn("x", …)` | `.DependsOn("x", …)` | `.DependOn("x", …)` |
| does not depend on | `.WhichDoNotDependOn("x", …)`| `.DoesNotDependOn("x", …)` | `.DoNotDependOn("x", …)` |
| depends only on set | `.WhichDependOnlyOn("x", …)` | `.DependsOnlyOn("x", …)`| `.DependOnlyOn("x", …)`|
| | Filter | Assert (single) | Assert (many) |
|------------------------------|-----------------------------------------|-----------------------------------|------------------------------------|
| depends on namespace | `.WhichDependOn("x", …)` | `.DependsOn("x", …)` | `.DependOn("x", …)` |
| does not depend on | `.WhichDoNotDependOn("x", …)` | `.DoesNotDependOn("x", …)` | `.DoNotDependOn("x", …)` |
| depends only on set | `.WhichDependOnlyOn("x", …)` | `.DependsOnlyOn("x", …)` | `.DependOnlyOn("x", …)` |
| has dependencies outside set | `.WhichHaveDependenciesOutside("x", …)` | `.HasDependenciesOutside("x", …)` | `.HaveDependenciesOutside("x", …)` |

```csharp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down
2 changes: 1 addition & 1 deletion Source/aweXpect.Reflection/Collections/Filter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

Expand Down
10 changes: 5 additions & 5 deletions Source/aweXpect.Reflection/Collections/Filtered.Assemblies.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -59,10 +59,6 @@ private Assemblies(Assemblies inner, List<IFilter<Assembly>> filters) : base(inn
_description = inner._description;
}

/// <inheritdoc />
private protected override Assemblies CloneWith(List<IFilter<Assembly>> filters)
=> new(this, filters);

/// <summary>
/// Filters for public types.
/// </summary>
Expand Down Expand Up @@ -165,6 +161,10 @@ public Types Enums(AccessModifiers accessModifier = AccessModifiers.Any)
/// <inheritdoc cref="ILimitedStaticTypeAssemblies.Properties()" />
public Properties Properties() => NewBuilder(MemberFilterState.Empty).Properties();

/// <inheritdoc />
private protected override Assemblies CloneWith(List<IFilter<Assembly>> filters)
=> new(this, filters);

private AssembliesTypeBuilder NewBuilder(MemberFilterState memberState)
=> new(this, memberState, new List<Func<Type, bool>>(), "");

Expand Down
10 changes: 5 additions & 5 deletions Source/aweXpect.Reflection/Collections/Filtered.Constructors.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using aweXpect.Core;
Expand Down Expand Up @@ -50,10 +50,6 @@ private Constructors(Constructors inner, List<IFilter<ConstructorInfo>> filters)
_types = inner._types;
}

/// <inheritdoc />
private protected override Constructors CloneWith(List<IFilter<ConstructorInfo>> filters)
=> new(this, filters);

/// <inheritdoc />
public string GetDescription()
{
Expand All @@ -71,6 +67,10 @@ public string GetDescription()
return description;
}

/// <inheritdoc />
private protected override Constructors CloneWith(List<IFilter<ConstructorInfo>> filters)
=> new(this, filters);

/// <summary>
/// Get all declaring types of the filtered constructors.
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions Source/aweXpect.Reflection/Collections/Filtered.Events.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -53,10 +53,6 @@ private Events(Events inner, List<IFilter<EventInfo>> filters) : base(inner, fil
_types = inner._types;
}

/// <inheritdoc />
private protected override Events CloneWith(List<IFilter<EventInfo>> filters)
=> new(this, filters);

/// <inheritdoc />
public string GetDescription()
{
Expand All @@ -74,6 +70,10 @@ public string GetDescription()
return description;
}

/// <inheritdoc />
private protected override Events CloneWith(List<IFilter<EventInfo>> filters)
=> new(this, filters);

/// <summary>
/// Get all declaring types of the filtered events.
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions Source/aweXpect.Reflection/Collections/Filtered.Fields.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -53,10 +53,6 @@ private Fields(Fields inner, List<IFilter<FieldInfo>> filters) : base(inner, fil
_types = inner._types;
}

/// <inheritdoc />
private protected override Fields CloneWith(List<IFilter<FieldInfo>> filters)
=> new(this, filters);

/// <inheritdoc />
public string GetDescription()
{
Expand All @@ -74,6 +70,10 @@ public string GetDescription()
return description;
}

/// <inheritdoc />
private protected override Fields CloneWith(List<IFilter<FieldInfo>> filters)
=> new(this, filters);

/// <summary>
/// Get all declaring types of the filtered fields.
/// </summary>
Expand Down
14 changes: 7 additions & 7 deletions Source/aweXpect.Reflection/Collections/Filtered.Methods.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -27,7 +27,7 @@ public class Methods : Filtered<MethodInfo, Methods>, IDescribableSubject
/// </summary>
internal Methods(Types types, string description,
MemberScope memberScope = MemberScope.DeclaredOnly)
: this(types, description, memberScope, includeOperators: false)
: this(types, description, memberScope, false)
{
}

Expand Down Expand Up @@ -64,10 +64,6 @@ private Methods(Methods inner, List<IFilter<MethodInfo>> filters) : base(inner,
_includeOperators = inner._includeOperators;
}

/// <inheritdoc />
private protected override Methods CloneWith(List<IFilter<MethodInfo>> filters)
=> new(this, filters);

/// <inheritdoc />
public string GetDescription()
{
Expand All @@ -85,6 +81,10 @@ public string GetDescription()
return description;
}

/// <inheritdoc />
private protected override Methods CloneWith(List<IFilter<MethodInfo>> filters)
=> new(this, filters);

/// <summary>
/// Returns a copy of this collection that additionally includes operator special-name members, so that operator
/// filters work even when operators are not opted in via <c>IncludedSpecialNameMembers</c>.
Expand All @@ -102,7 +102,7 @@ internal Methods WithOperatorsIncluded()
return this;
}

Methods rebuilt = new(_types, _description, _memberScope, includeOperators: true);
Methods rebuilt = new(_types, _description, _memberScope, true);
return rebuilt.CloneWith([.. Filters,]);
}

Expand Down
10 changes: 5 additions & 5 deletions Source/aweXpect.Reflection/Collections/Filtered.Properties.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -53,10 +53,6 @@ private Properties(Properties inner, List<IFilter<PropertyInfo>> filters) : base
_types = inner._types;
}

/// <inheritdoc />
private protected override Properties CloneWith(List<IFilter<PropertyInfo>> filters)
=> new(this, filters);

/// <inheritdoc />
public string GetDescription()
{
Expand All @@ -74,6 +70,10 @@ public string GetDescription()
return description;
}

/// <inheritdoc />
private protected override Properties CloneWith(List<IFilter<PropertyInfo>> filters)
=> new(this, filters);

/// <summary>
/// Get all declaring types of the filtered properties.
/// </summary>
Expand Down
Loading
Loading