orleans icon indicating copy to clipboard operation
orleans copied to clipboard

MayInterleave attribute throws when in base class

Open cjenp opened this issue 6 years ago • 3 comments

Hi,

i have an abstract base class that has the MayInterleave attribute specified. The public static IsReentrant method is also defined in this class. When i create a class that derives from the base class i get the following error on silo startup

System.InvalidOperationException: 'Class SampleGrain.MyGrain doesn't declare public static method with name IsReentrant specified in MayInterleave attribute'

Im currently solving this problem with adding the IsReentrant method to each derived class and using the new keyword.

From what i can see this could be solved by adding the BindingFlags.FlattenHierarchy flag to the GetMethod() call in GrainTypeData.cs, or am i missing something?

var callbackMethodName = grainType.GetCustomAttribute<MayInterleaveAttribute>().CallbackMethodName;
var method = grainType.GetMethod(callbackMethodName, BindingFlags.Public | BindingFlags.Static);
if (method == null)
      throw new InvalidOperationException($"Class {grainType.FullName} doesn't declare public static method " + $"with name {callbackMethodName} specified in MayInterleave attribute");

cjenp avatar Dec 18 '19 08:12 cjenp

Good find, are you able to submit a PR? I think the search should start from the class which the attribute is defined on and traverse upwards from there

ReubenBond avatar Dec 18 '19 14:12 ReubenBond

Sure, i will make the changes and submit a PR.

cjenp avatar Dec 18 '19 15:12 cjenp

Fixed by #6192 - thanks, @cjenp!

ReubenBond avatar Dec 19 '19 17:12 ReubenBond