Skip to content

Commit

Permalink
Exclude ExplicitInterfaceImplementation methods
Browse files Browse the repository at this point in the history
  • Loading branch information
alrz authored and ReubenBond committed May 22, 2024
1 parent 3d7343e commit 1357451
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Orleans.CodeGenerator/Model/ProxyInterfaceDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ private List<ProxyMethodDescription> GetMethods()
{
foreach (var method in iface.GetDeclaredInstanceMembers<IMethodSymbol>())
{
if (method.MethodKind == MethodKind.ExplicitInterfaceImplementation)
{
// Explicit implementations can be ignored when generating a proxy.
// Proxies must implement every method explicitly to ensure faithful reproduction of the interface behavior.
// At the calling side, the explicit implementation will be called if it was not overridden by a derived type.
continue;
}

var methodDescription = CodeGenerator.GetProxyMethodDescription(InterfaceType, method: method);
result.Add(methodDescription);
}
Expand Down
22 changes: 22 additions & 0 deletions test/DefaultCluster.Tests/CodeGenTests/IRuntimeCodeGenGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ namespace Tester.CodeGenTests
using Orleans;
using Orleans.Providers;

public interface ISomeInterface<in T>
{
Task M(T arg);
}

public interface IBase : ISomeInterface<object>;

public interface IDerived : IBase, ISomeInterface<string>
{
Task ISomeInterface<object>.M(object obj) => M(obj);
}

public interface ISomeGrainWithExplicitImplementation : IDerived, IGrainWithGuidKey;

public class SomeGrain : Grain, ISomeGrainWithExplicitImplementation
{
public Task M(string arg)
{
throw new NotImplementedException();
}
}

public interface IGrainWithGenericMethods : IGrainWithGuidKey
{
Task<Type[]> GetTypesExplicit<T, U, V>();
Expand Down

0 comments on commit 1357451

Please sign in to comment.