Skip to content

Commit 5e6ccc3

Browse files
oroztocilgithub-actions
authored andcommitted
Refactor the interface check to use explicit loop instead of LINQ
1 parent a46b98e commit 5e6ccc3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Validation/gen/Parsers/ValidationsGenerator.TypesParser.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,16 @@ internal static bool HasValidationAttributes(ISymbol symbol, WellKnownTypes well
304304

305305
internal static bool HasIValidatableObjectInterface(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
306306
{
307-
return typeSymbol.AllInterfaces.Any(i =>
308-
SymbolEqualityComparer.Default.Equals(i, wellKnownTypes.Get(WellKnownTypeData.WellKnownType.System_ComponentModel_DataAnnotations_IValidatableObject)));
307+
var validatableObjectSymbol = wellKnownTypes.Get(WellKnownTypeData.WellKnownType.System_ComponentModel_DataAnnotations_IValidatableObject);
308+
309+
foreach (var inter in typeSymbol.AllInterfaces)
310+
{
311+
if (SymbolEqualityComparer.Default.Equals(inter, validatableObjectSymbol))
312+
{
313+
return true;
314+
}
315+
}
316+
317+
return false;
309318
}
310319
}

0 commit comments

Comments
 (0)