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
If either the expected value or actual value or both are a value-typed expression, Assert.AreSame or Is.SameAs are guaranteed to fail because C# will implicitly convert the value type to a new boxed instance. It doesn't make sense to use AreSame/SameAs unless the types of the passed expressions are both reference types.
It would make sense to offer a fix to change SameAs to EqualTo since that was probably the intent.
Should show an error or warning on SameAs:
classC{voidM(){varx=3;
Assert.That(x, Is.SameAs(3));// Also this
Assert.That((object)x, Is.SameAs(3));// Also this
Assert.That(x, Is.SameAs((object)3));}}
Should not show an error or warning because the expressions are both reference-typed:
Motivation: nunit/nunit#3614 (comment)
If either the expected value or actual value or both are a value-typed expression,
Assert.AreSame
orIs.SameAs
are guaranteed to fail because C# will implicitly convert the value type to a new boxed instance. It doesn't make sense to use AreSame/SameAs unless the types of the passed expressions are both reference types.It would make sense to offer a fix to change SameAs to EqualTo since that was probably the intent.
Should show an error or warning on
SameAs
:Should not show an error or warning because the expressions are both reference-typed:
The text was updated successfully, but these errors were encountered: