To Reproduce
var code =
"""
using Rocks;
[assembly: Rock(typeof(IServiceDerived), BuildType.Create | BuildType.Make)]
public interface IOutBase { }
public interface IOutDerived : IOutBase { }
public interface IServiceBase
{
void TryGet<T>(out T value) where T : IOutBase;
}
public interface IServiceDerived : IServiceBase
{
new void TryGet<T>(out T value) where T : IOutDerived;
}
""";
Expected behavior
Mock code is generated with errors.
Actual behavior
The following error occurs:
// Rocks\Rocks.RockGenerator\IServiceDerived_Rock_Create.g.cs(49,15): error CS0425:
The constraints for type parameter 'T' of method 'IServiceDerivedCreateExpectations.Mock.TryGet<T>(out T)' must match the constraints for type parameter 'T' of interface method 'IServiceBase.TryGet<T>(out T)'. Consider using an explicit interface implementation instead.
Additional context
This can be fixed if the base type is generated explicitly:
public class SD : IServiceDerived
{
public void TryGet<T>(out T value) where T : IOutDerived
{
throw new NotImplementedException();
}
void IServiceBase.TryGet<T>(out T value)
{
throw new NotImplementedException();
}
}
This was found by trying to duplicate this issue in NSubstitute.
To Reproduce
Expected behavior
Mock code is generated with errors.
Actual behavior
The following error occurs:
Additional context
This can be fixed if the base type is generated explicitly:
This was found by trying to duplicate this issue in NSubstitute.