Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider interface method accessibility when generating the invoker #9019

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Orleans.CodeGenerator/InvokableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public GeneratedInvokableDescription Generate(InvokableMethodDescription invokab

static Accessibility GetAccessibility(IMethodSymbol methodSymbol)
{
Accessibility accessibility = methodSymbol.DeclaredAccessibility;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the type is internal and the method is public, what will the value of DeclaredAccessibilty be?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's gonna be public, which will be downgraded to internal after the loop below.

var t = methodSymbol.ContainingType;
Accessibility accessibility = t.DeclaredAccessibility;
while (t is not null)
{
if ((int)t.DeclaredAccessibility < (int)accessibility)
Expand Down
15 changes: 15 additions & 0 deletions test/DefaultCluster.Tests/CodeGenTests/IRuntimeCodeGenGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ public Task M(string arg)

// End regression test for https://github.com/dotnet/orleans/issues/8991

public interface IGrainWithNonPublicMethods : IGrainWithGuidKey
{
internal class P1;
internal Task M1(P1 arg);

//protected class P2;
//protected Task M2(P2 arg);
Comment on lines +41 to +42
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR does not fix codegen for protected members.

For those I think we should change the body to "throw unreachable" and skip the invoker completely..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Good idea


internal protected class P3;
internal protected Task M3(P3 arg);

//private protected class P4;
//private protected Task M4(P4 arg);
}

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