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

Switch to explicit implementation for redeclared events #618

Merged
merged 5 commits into from May 14, 2022

Conversation

stakx
Copy link
Member

@stakx stakx commented May 12, 2022

This fixes #590. I've added most of the information gathered in that issue to the commit messages.

stakx added 5 commits May 12, 2022 10:22
The test being added here fails PEVerify with "Event has a duplicate".
The failing test from the previous commit causes the following metadata
to be emitted:

    .property instance class [mscorlib]System.Action`1<bool> Property()
    {
        .get instance class [mscorlib]System.Action`1<bool>
                         Castle.Proxies.IDerivedProxy::get_Property()
    }

    .property instance class [mscorlib]System.Action Property()
    {
        .get instance class [mscorlib]System.Action
                         Castle.Proxies.IDerivedProxy::get_Property()
    }

Obviously we need to switch to explicit implementation for one of these
events in order to avoid a name collision. We do that by changing the
"collision detection" such that it does not take into account events'
return types; only their name matters.
Since events and properties have very similar metadata, the same issue
we just solved for events might be present for properties; let's test
this suspicion.
This might be a PEVerify bug.

Given that the C# compiler would force us to implement either the base
or derived property explicitly (in a class implementing `IDerived`),
let's do the same in DynamicProxy. Use the same approach as for events.
@stakx stakx changed the title Switch to explicit impl for redeclared events Switch to explicit implementation for redeclared events May 12, 2022
@stakx
Copy link
Member Author

stakx commented May 13, 2022

@jonorossi, this is fairly trivial and shouldn't hold any surprises, so feel free to review or not review as time permits. I may go ahead and merge this in about 2 weeks' time.

Copy link
Member

@jonorossi jonorossi left a comment

Choose a reason for hiding this comment

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

Love the commit messages.

@jonorossi jonorossi added this to the vNext milestone May 14, 2022
@jonorossi jonorossi merged commit bcf05dc into castleproject:master May 14, 2022
@stakx stakx deleted the bugfix/redeclared-events branch May 14, 2022 12:06
@stakx
Copy link
Member Author

stakx commented May 14, 2022

Love the commit messages.

Thanks! I wanted to make the PR easily reviewable in isolation, since it's been a while and it can be difficult to remember (or having to look up) all relevant details of past discussions. It's been a good Git exercise; I might try to do this more often in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DynamicProxy emits invalid metadata for redeclared event
2 participants