Hi, came across this recently, seems needs a case to handle:
So consider following:
public interface IFoo<T>
{
void SetBar(T bar);
}
public class Foo<T> : IFoo<T>
{
private T _bar;
public void SetBar(T bar)
{
_bar = bar;
}
public T Bar => _bar;
}
public class Bar : Foo<string> { }
public static class FooExtensions
{
public static TFoo With<TFoo, T>(this TFoo foo, T value)
where TFoo : IFoo<T>
{
return foo;
}
}
public static class Usage
{
public static void Test()
{
var foo = new Foo<string>();
foo.With("Hello World");
var bar = new Bar();
bar.With("Hello World from Bar");
}
}
When patch references dll, this results in:
The program '[26244] vvvv.exe' has exited with code 3221225477 (0xc0000005) 'Access violation'.
If AssemblyInfo.cs [assembly: ImportAsIs()] attribute exists, otherwise it imports properly.
Not sure if this is a valid constrain, in first place, not sure what ImportAsIs does, since without it ressolves.
Replacing:
public static class FooExtensions
{
public static IFoo<T> With<T>(this IFoo<T> foo, T value)
{
return foo;
}
}
Imported properly, hover it return IFoo instead of original type
Blockquote
.
TestGenericExtensioner.zip (2.2 KB)