Skip to content

Cannot shim generic method on abstract base class #46

@Miista

Description

@Miista

MVE:

// Classes
abstract class AbstractBase
{
    public virtual T GetTFromAbstractBase<T>(string input) where T : class => null;
}

class DerivedFromAbstractBase : AbstractBase {}

// Test
var shim = Shim
    .Replace(() => Is.A<AbstractBase>().GetTFromAbstractBase<string>(Is.A<string>()))
    .With((AbstractBase @this, string @string) => "Hello");

PoseContext.Isolate(() =>
  {
      var instance = new DerivedFromAbstractBase();
      var result = instance.GetTFromAbstractBase<string>("");
  },
  shim
);

Rewriting GetTFromAbstractBase results in System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B).

This issue was discovered during #34

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions