Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3959042
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:40:52+00:00 2026-05-20T02:40:52+00:00

I’m following up on my earlier question: Mono.Cecil: call base class' method from other

  • 0

I’m following up on my earlier question: Mono.Cecil: call base class' method from other assembly.
I’m doing the same thing, but if my base class is generic it doesn’t work.

//in Assembly A
class BaseVM<T> {}

//in Assembly B
class MyVM : Base<SomeModel> {
 [NotifyProperty]
 public string Something {get;set;}
}

It weaves the following code:

L_000e: call instance void [AssemblyA]Base`1::RaisePropertyChanged(string)

instead of

L_000e: call instance void [AssemblyA]Base`1<class SomeModel>::RaisePropertyChanged(string)

What is there to change?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:40:53+00:00Added an answer on May 20, 2026 at 2:40 am

    In your previous post you indicate that you’re using code like:

    TypeDefinition type = ...;
    TypeDefintion baseType = type.BaseType.Resolve ();
    MethodDefinition baseMethod = baseType.Methods.First (m => ...);
    MethodReference baseMethodReference = type.Module.Import (baseMethod);
    il.Emit (OpCodes.Call, baseMethodReference);
    

    Obviously, this is not suitable for generics:

    When you Resolve () the .BaseType, you’re losing the generic instantiation information. You need to recreate the appropriate method call with the proper generic information from the base type.

    To simplify things, let’s use the following methods, taken from the Cecil test suite:

    public static TypeReference MakeGenericType (this TypeReference self, params TypeReference [] arguments)
    {
        if (self.GenericParameters.Count != arguments.Length)
            throw new ArgumentException ();
    
        var instance = new GenericInstanceType (self);
        foreach (var argument in arguments)
            instance.GenericArguments.Add (argument);
    
        return instance;
    }
    
    public static MethodReference MakeGeneric (this MethodReference self, params TypeReference [] arguments)
    {
        var reference = new MethodReference(self.Name,self.ReturnType) {
            DeclaringType = self.DeclaringType.MakeGenericType (arguments),
            HasThis = self.HasThis,
            ExplicitThis = self.ExplicitThis,
            CallingConvention = self.CallingConvention,
        };
    
        foreach (var parameter in self.Parameters)
            reference.Parameters.Add (new ParameterDefinition (parameter.ParameterType));
    
        foreach (var generic_parameter in self.GenericParameters)
            reference.GenericParameters.Add (new GenericParameter (generic_parameter.Name, reference));
    
        return reference;
    }
    

    With those, you can rewrite your code as:

    TypeDefinition type = ...;
    TypeDefintion baseTypeDefinition = type.BaseType.Resolve ();
    MethodDefinition baseMethodDefinition = baseTypeDefinition.Methods.First (m => ...);
    MethodReference baseMethodReference = type.Module.Import (baseMethodDefinition);
    if (type.BaseType.IsGenericInstance) {
        var baseTypeInstance = (GenericInstanceType) type.BaseType;
        baseMethodReference = baseMethodReference.MakeGeneric (baseTypeInstance.GenericArguments.ToArray ());
    }
    
    il.Emit (OpCodes.Call, baseMethodReference);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.