Skip to content

Inaccessible Types Used on Constraints Cannot be Mocked #237

@JasonBock

Description

@JasonBock

To reproduce:

var code =
	"""
	using Rocks;
			
	public abstract class ArgumentMapper
	{
		protected interface ISource { }

		protected abstract void NotUsingSource<T>()
			where T : struct, ISource;
	}
	
	public static class Test
	{
		public static void Go()
		{
			var rock = Rock.Create<ArgumentMapper>();
		}
	}
	""";

This will lead to the following error:

error CS0122: 'ArgumentMapper.ISource' is inaccessible due to its protection level

The problem is that T is constrained to a type that the mock cannot see, so this member cannot be mocked. And since it's abstract, the type cannot be mocked.

This was found on ILGPU.Backends.EntryPoints.ArgumentMapper - specifically, MapViewInstance().

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions