Skip to content

Commit 6eac647

Browse files
committed
BenMorris/NetArchTest#152 - Predicate.ResideInNamespace take into account a string comparer specified by the user
1 parent 11369b1 commit 6eac647

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Assert.True(result.IsSuccessful);
297297
```
298298

299299
Available options:
300-
- [Comparer](documentation/api.md#optionscomparer) - allows to specify how strings will be compared, default: InvariantCultureIgnoreCase (it only affects: Predicate.HaveName, Predicate.HaveNameStartingWith, Predicate.HaveNameEndingWith)
300+
- [Comparer](documentation/api.md#optionscomparer) - allows to specify how strings will be compared, default: InvariantCultureIgnoreCase (it only affects: Predicate.HaveName, Predicate.HaveNameStartingWith, Predicate.HaveNameEndingWith, Predicate.ResideInNamespace)
301301

302302
- [SerachForDependencyInFieldConstant](documentation/api.md#optionsserachfordependencyinfieldconstant) - determines if dependency analysis should look for dependency in string field constant, default: false
303303

documentation/readme.nt

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ Assert.True(result.IsSuccessful);
248248
```
249249

250250
Available options:
251-
- [Comparer](documentation/api.md#optionscomparer) - allows to specify how strings will be compared, default: InvariantCultureIgnoreCase (it only affects: Predicate.HaveName, Predicate.HaveNameStartingWith, Predicate.HaveNameEndingWith)
251+
- [Comparer](documentation/api.md#optionscomparer) - allows to specify how strings will be compared, default: InvariantCultureIgnoreCase (it only affects: Predicate.HaveName, Predicate.HaveNameStartingWith, Predicate.HaveNameEndingWith, Predicate.ResideInNamespace)
252252

253253
- [SerachForDependencyInFieldConstant](documentation/api.md#optionsserachfordependencyinfieldconstant) - determines if dependency analysis should look for dependency in string field constant, default: false
254254

sources/NetArchTest/Condition_Names.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public ConditionList NotHaveNameEndingWith(string end)
133133
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
134134
public ConditionList ResideInNamespace(string name)
135135
{
136-
AddFunctionCall(x => FunctionDelegates.ResideInNamespace(x, name, true));
136+
AddFunctionCall((context, x) => FunctionDelegates.ResideInNamespace(context, x, name, true));
137137
return CreateConditionList();
138138
}
139139

@@ -144,7 +144,7 @@ public ConditionList ResideInNamespace(string name)
144144
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
145145
public ConditionList NotResideInNamespace(string name)
146146
{
147-
AddFunctionCall(x => FunctionDelegates.ResideInNamespace(x, name, false));
147+
AddFunctionCall((context, x) => FunctionDelegates.ResideInNamespace(context, x, name, false));
148148
return CreateConditionList();
149149
}
150150

sources/NetArchTest/Functions/FunctionDelegates_Names.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ internal static IEnumerable<TypeSpec> HaveNameEndingWith(FunctionSequenceExecuti
8383
}
8484

8585

86-
internal static IEnumerable<TypeSpec> ResideInNamespace(IEnumerable<TypeSpec> input, string name, bool condition)
86+
internal static IEnumerable<TypeSpec> ResideInNamespace(FunctionSequenceExecutionContext context, IEnumerable<TypeSpec> input, string name, bool condition)
8787
{
8888
if (condition)
8989
{
90-
return input.Where(c => c.Definition.GetNamespace().StartsWith(name, StringComparison.InvariantCultureIgnoreCase));
90+
return input.Where(c => c.Definition.GetNamespace().StartsWith(name, context.UserOptions.Comparer));
9191
}
9292
else
9393
{
94-
return input.Where(c => !c.Definition.GetNamespace().StartsWith(name, StringComparison.InvariantCultureIgnoreCase));
94+
return input.Where(c => !c.Definition.GetNamespace().StartsWith(name, context.UserOptions.Comparer));
9595
}
9696
}
9797

sources/NetArchTest/Predicate_Names.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public PredicateList DoNotHaveNameEndingWith(params string[] end)
133133
/// <returns>An updated set of predicates that can be applied to a list of types.</returns>
134134
public PredicateList ResideInNamespace(string name)
135135
{
136-
AddFunctionCall(x => FunctionDelegates.ResideInNamespace(x, name, true));
136+
AddFunctionCall((context, x) => FunctionDelegates.ResideInNamespace(context, x, name, true));
137137
return CreatePredicateList();
138138
}
139139

@@ -144,7 +144,7 @@ public PredicateList ResideInNamespace(string name)
144144
/// <returns>An updated set of predicates that can be applied to a list of types.</returns>
145145
public PredicateList DoNotResideInNamespace(string name)
146146
{
147-
AddFunctionCall(x => FunctionDelegates.ResideInNamespace(x, name, false));
147+
AddFunctionCall((context, x) => FunctionDelegates.ResideInNamespace(context, x, name, false));
148148
return CreatePredicateList();
149149
}
150150

0 commit comments

Comments
 (0)