Open dark-dark-darkness opened 1 week ago
Thanks for reporting this, @dark-dark-darkness.
This is caused by the case-insensitive method name comparison here:
which was introduced a long time ago, in https://github.com/castleproject/Core/commit/d1d62269fe4cad4fec24fe69b0fe79c4149569fa.
I'm not sure why StringComparer.OrdinalIgnoreCase
was chosen over StringComparer.Ordinal
– perhaps in consideration of case-insensitive languages like VB.NET or the CLS (Common Language Specification)?
In any case, I tried changing the above line of code to use StringComparer.Ordinal
instead, which broke no tests and fixed the above scenario. So we could probably classify this as a bug, and go ahead and make the method name comparisons case-insensitive.
Any thoughts?
Description
When mocking an interface that contains multiple methods with similar signatures using Moq, an exception is thrown during proxy generation. This issue arises because the proxy generator performs a case-insensitive comparison when determining if methods are duplicates, leading to a conflict even when method names differ only by case.
Moq version: 4.20.72 Castle.Core: 5.1.1 .Net version: net48;net8.0
Program.cs
Exception
The exception message is as follows: