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

Code Fix for NUnit2010 on Ref Structs Creates CS0306 #549

Closed
manfred-brands opened this issue May 24, 2023 · 0 comments · Fixed by #550
Closed

Code Fix for NUnit2010 on Ref Structs Creates CS0306 #549

manfred-brands opened this issue May 24, 2023 · 0 comments · Fixed by #550
Assignees

Comments

@manfred-brands
Copy link
Member

manfred-brands commented May 24, 2023

Relates to #475 where the detected code was actual == expected.
However NUnit2010 is also raised for actual.Equals(expected)
This was addressed partly in #477 but only if the argument was a ref readonly struct not if the instance was one.

[Test]
public void TestMethod()
{
    ReadOnlySpan<char> actual = GetPart();
    Assert.That(actual.Equals(""Text""), Is.True);
}

ReadOnlySpan<char> GetPart() => ""Some Text"".AsSpan(4);

Here the method ReadOnlySpan<char>.Equals(string) is called.

The CodeFix converts this into: Assert.That(actual, Is.EqualTo(expected));
which raises: error CS0306: The type 'ReadOnlySpan<char>' may not be used as a type argument

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

Successfully merging a pull request may close this issue.

2 participants