Skip to content

Commit

Permalink
refactoring : extract Traits to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
NeVeSpl committed Nov 19, 2023
1 parent 71e51bf commit e62885d
Show file tree
Hide file tree
Showing 6 changed files with 679 additions and 655 deletions.
248 changes: 248 additions & 0 deletions src/NetArchTest.Rules/Condition.Traits.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
using NetArchTest.Functions;

namespace NetArchTest.Rules
{
public sealed partial class Condition
{
/// <summary>
/// Selects types that are marked as abstract.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeAbstract()
{
AddFunctionCall(x => FunctionDelegates.BeAbstract(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that are not marked as abstract.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotBeAbstract()
{
AddFunctionCall(x => FunctionDelegates.BeAbstract(x, false));
return CreateConditionList();
}

/// <summary>
/// Selects types that are classes.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeClasses()
{
AddFunctionCall(x => FunctionDelegates.BeClass(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that are not classes.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotBeClasses()
{
AddFunctionCall(x => FunctionDelegates.BeClass(x, false));
return CreateConditionList();
}

/// <summary>
/// Selects types that have generic parameters.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeGeneric()
{
AddFunctionCall(x => FunctionDelegates.BeGeneric(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that do not have generic parameters.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotBeGeneric()
{
AddFunctionCall(x => FunctionDelegates.BeGeneric(x, false));
return CreateConditionList();
}


/// <summary>
/// Selects types that are interfaces.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeInterfaces()
{
AddFunctionCall(x => FunctionDelegates.BeInterface(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that are not interfaces.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotBeInterfaces()
{
AddFunctionCall(x => FunctionDelegates.BeInterface(x, false));
return CreateConditionList();
}

/// <summary>
/// Selects types that are static.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeStatic()
{
AddFunctionCall(x => FunctionDelegates.BeStatic(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that are not static.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotBeStatic()
{
AddFunctionCall(x => FunctionDelegates.BeStatic(x, false));
return CreateConditionList();
}

/// <summary>
/// Selects types that are nested.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeNested()
{
AddFunctionCall(x => FunctionDelegates.BeNested(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that are nested and public.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeNestedPublic()
{
AddFunctionCall(x => FunctionDelegates.BeNestedPublic(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that are nested and private.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeNestedPrivate()
{
AddFunctionCall(x => FunctionDelegates.BeNestedPrivate(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that are not nested.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotBeNested()
{
AddFunctionCall(x => FunctionDelegates.BeNested(x, false));
return CreateConditionList();
}

/// <summary>
/// Selects types that are not nested and public.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotBeNestedPublic()
{
AddFunctionCall(x => FunctionDelegates.BeNestedPublic(x, false));
return CreateConditionList();
}

/// <summary>
/// Selects types that are not nested and private.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotBeNestedPrivate()
{
AddFunctionCall(x => FunctionDelegates.BeNestedPrivate(x, false));
return CreateConditionList();
}

/// <summary>
/// Selects types that are have public scope.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BePublic()
{
AddFunctionCall(x => FunctionDelegates.BePublic(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that do not have public scope.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotBePublic()
{
AddFunctionCall(x => FunctionDelegates.BePublic(x, false));
return CreateConditionList();
}

/// <summary>
/// Selects types according that are marked as sealed.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeSealed()
{
AddFunctionCall(x => FunctionDelegates.BeSealed(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types according that are not marked as sealed.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList NotBeSealed()
{
AddFunctionCall(x => FunctionDelegates.BeSealed(x, false));
return CreateConditionList();
}

/// <summary>
/// Selects types that are immutable.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeImmutable()
{
AddFunctionCall(x => FunctionDelegates.BeImmutable(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types that are mutable.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList BeMutable()
{
AddFunctionCall(x => FunctionDelegates.BeImmutable(x, false));
return CreateConditionList();
}

/// <summary>
/// Selects types according to whether they have nullable members.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList OnlyHaveNullableMembers()
{
AddFunctionCall(x => FunctionDelegates.HasNullableMembers(x, true));
return CreateConditionList();
}

/// <summary>
/// Selects types according to whether they have nullable members.
/// </summary>
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
public ConditionList HaveSomeNonNullableMembers()
{
AddFunctionCall(x => FunctionDelegates.HasNullableMembers(x, false));
return CreateConditionList();
}
}
}
Loading

0 comments on commit e62885d

Please sign in to comment.