perf: avoid LINQ chains in TestDependency equality and MethodDataSourceAttribute method matching by thomhurst · Pull Request #6092 · thomhurst/TUnit (original) (raw)

@thomhurst

Replace Select/SequenceEqual iterator allocations with manual loops in TestDependency.Matches and MethodDataSourceAttribute method resolution. Both are hot paths (dependency graph build, per-candidate data source resolution). Behavior is preserved, including null-argument matching semantics.

Closes #6061

[claude[bot]](/apps/claude)

@thomhurst

…urce

Exact-type comparison missed derived-type/interface arguments (e.g. List arg vs IList param). IsAssignableFrom mirrors what the call accepts.

[claude[bot]](/apps/claude)

@thomhurst

The IsAssignableFrom scan widened matching so competing overloads (e.g. GetData(object) and GetData(string) with Arguments=["hello"]) both matched, making SingleOrDefault throw InvalidOperationException.

Delegate to Type.GetMethod(name, flags, binder, Type[], modifiers) when all arguments are non-null: the default binder applies normal overload resolution (most-specific wins) while still honouring derived-type/interface widening (List arg -> IList param), preserving this PR's bug-fix. Null arguments have no runtime type, so fall back to the name-only lookup.

[claude[bot]](/apps/claude)

@thomhurst

GetMethod(name, flags) returns null (not throws) when the name is ambiguous, so a parameterless data-source method coexisting with other overloads silently resolved to null. Route the zero-argument case through the same binder GetMethod(name, flags, binder, Type[], modifiers) path: the empty Type[] selects the parameterless overload even when other-arity overloads share the name. Null-argument fallback unchanged.

[claude[bot]](/apps/claude)

@thomhurst thomhurst deleted the perf/issue-6061-linq-chains branch

May 28, 2026 23:21

This was referenced

May 29, 2026

This was referenced

Jun 13, 2026

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})