Skip to content

Hiding Methods Cannot Be Mocked #239

@JasonBock

Description

@JasonBock

To reproduce:

"""
using Rocks;

#nullable enable

namespace MockTests
{
	public class Credentials { }

	public class NewCredentials : Credentials { }
			
	public class BaseCopy
	{
		public virtual Credentials Copy() => default;
	}

	public class NewCopy : BaseCopy
	{
		public new NewCredentials Copy() => default;
	}

	public static class Test
	{
		public static void Generate()
		{
			var rock = Rock.Create<NewCopy>();
		}
	}
}
""";

This gives the following error:

error CS0506: 'CreateExpectationsOfNewCopyExtensions.RockNewCopy.Copy()': cannot override inherited member 'NewCopy.Copy()' because it is not marked virtual, abstract, or override

I don't know if the inheritance relationship with the return value types matters, but, Rocks needs to detect that Copy() can't be mocked.

This was found on Amazon.Runtime.SSOImmutableCredentials

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions