You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mock generator predicate locals can collide with interface parameter names #7433
Mocking an interface whose parameter names collide with generated predicate-conversion locals can produce invalid C#. Generated locals need unique names so valid interfaces can be mocked.
Reproduction
Declare public interface IService { void Send(string value, string __fa_value); } and generate a mock with Mock.Of<IService>(). The generated predicate overload for value declares a local __fa_value in a method already containing a parameter with that name, producing CS0136.
Expected and actual
Expected: generated locals avoid all parameter names. Actual: EmitSingleFuncOverload prefixes the raw parameter name with __fa_ without checking the other parameters. This naming scheme predates #7415; its reviewer noticed the gap.
Environment
Generator source at c663d1a, src/TUnit.Mocks.SourceGenerator/Builders/MockMembersBuilder.cs, lines 1305–1309. Confirmed by inspecting emitted source construction; compilation reproduction has not been run.
Please allocate collision-free local names for predicate conversions and add a generator regression test.
Audited against main d87516cb9c: the predicate conversion still declares __fa_{rawName} without reserving other parameter names (MockMembersBuilder.cs:1308) and uses that name in the matcher expression. The collision remains independent of #7415; no closing PR was found.
Activity
thomhurst commentedon Nov 3, 2026
Audited against main
d87516cb9c: the predicate conversion still declares__fa_{rawName}without reserving other parameter names (MockMembersBuilder.cs:1308) and uses that name in the matcher expression. The collision remains independent of #7415; no closing PR was found.Fix predicate conversion local collisions (#7433)
Reserve generic parameter names for predicate locals (#7433)
Avoid mock predicate conversion local name collisions (#7655)