orleans: IIncomingGrainCallContext's InterfaceMethod and ImplementationMethod is null

Trying to use IIncomingGrainCallFilter as a centralized logging system. It works properly for most grains/methods, but for at least one (whether I am using a Silo-wide call filter or implement IIncomingGrainCallFilter in the grain itself) inside Invoke method both the InterfaceMethod and ImplementationMethod are null.

Strangely enough, context.Invoke() does work, so it knows what method needs to be called.

The method where it fails is defined as public async Task<Option<SnapshotDetail>> GetSnapshotDetailAsync(short streamMappingId, DateTime timeOfSnapshot, ImageFormat format)

We have a number of other methods returning data wrapped in an Option class that work fine.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 9
  • Comments: 16 (7 by maintainers)

Most upvoted comments

We’ve moved this issue to the Backlog. This means that it is not going to be worked on for the coming release. We review items in the backlog at the end of each milestone/release and depending on the team’s priority we may reconsider this issue for the following milestone.

We are on Orleans 3.x, using Microsoft.Orleans.CodeGenerator.MSBuild and the attribute - it is working as expected on our end.

Thanks for the quick reply!

Note: if you use the [MethodId(x)] workaround, make sure that you use unique method ids within a given interface.

@tiasmt are you using the Microsoft.Orleans.OrleansCodeGenerator.Build package or the Microsoft.Orleans.CodeGenerator.MSBuild package? We recommend using the latter when on Orleans 3.x.

There are some complications with matching interface & implementation methods because type identity isn’t maintained between build and run due to type forwarding in .NET. My recollection is hazy on this, since this is fixed categorically in Orleans 7.x by using a different strategy, but I believe this was especially an issue when building against .NET Standard and then running with .NET Core and when using the reflection-based .Build package (versus the Roslyn-based .MSBuild package).

Workaround

I believe this is not completely fixable on Orleans 3.x. The best option is to:

  • Use the Microsoft.Orleans.CodeGenerator.MSBuild package instead of the Microsoft.Orleans.OrleansCodeGenerator.Build package, and
  • Add [MethodId(x)] attributes to your grain interface methods, making sure that the values are unique. Example:
public interface IMyGrain : IGrainWithStringKey
{
  [MethodId(0)] 
  ValueTask ReticulateSplines();

  [MethodId(1)]
  Task<string> Echo(string input);
}

Seems also methods which uses Immutable<T> as generic becomes null

e.g. Task Add(Immutable<TModel> entity)