Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter count mismatch with indexer #4591

Closed
georg-eckert-zeiss opened this issue Dec 19, 2023 · 4 comments · Fixed by #4608
Closed

Parameter count mismatch with indexer #4591

georg-eckert-zeiss opened this issue Dec 19, 2023 · 4 comments · Fixed by #4608
Assignees
Labels
Milestone

Comments

@georg-eckert-zeiss
Copy link

Hi there,
for code as simple as this I get an error. (see the stacktrace)

[Test]
public void Test_Accessor()
{
  var a = new X();
  var b = new X();

  Assert.That( a, Is.Not.EqualTo( b ) );
}
		
public class X
{
  private readonly Guid _ID = Guid.NewGuid();

  public Guid? this[ Guid characteristicUuid ] => _ID;
}

Stack trace

System.Reflection.TargetParameterCountException : Parameter count mismatch.
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at NUnit.Framework.Constraints.Comparers.PropertiesComparer.Equal(Object x, Object y, Tolerance& tolerance, ComparisonState state, NUnitEqualityComparer equalityComparer)
   at NUnit.Framework.Constraints.NUnitEqualityComparer.AreEqual(Object x, Object y, Tolerance& tolerance, ComparisonState state)
   at NUnit.Framework.Constraints.NUnitEqualityComparer.AreEqual(Object x, Object y, Tolerance& tolerance)
   at NUnit.Framework.Constraints.EqualConstraint.ApplyTo[TActual](TActual actual)
   at NUnit.Framework.Constraints.NotConstraint.ApplyTo[TActual](TActual actual)
   at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression, NUnitString message, String actualExpression, String constraintExpression)
   at My.TestClass.Test_Accessor() in C:\TestClass.cs:line 007
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

Is this a bug?

Best regards.

@manfred-brands
Copy link
Member

Yes it is.
Related to #4572

@georg-eckert-zeiss
Copy link
Author

georg-eckert-zeiss commented Dec 19, 2023

Didn't find that one. Thanks. I stumbled upon it using Is.EquivalentTo and was able to narrow it down to this example. Therefore I cannot easily use Is.SameAs as a workaround. But as long as it is a known issue, it's fine.

@georg-eckert-zeiss
Copy link
Author

georg-eckert-zeiss commented Jan 29, 2024

🥳 Great. Looking forward to the patch release.

@OsirisTerje
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants