-
Notifications
You must be signed in to change notification settings - Fork 470
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
DynamicProxy emits invalid metadata for redeclared event #590
Comments
On second thought, we already have the means to resolve name conflicts for interface members: switching to explicit implementation (see DynamicProxy currently does not switch to explicit implementation for two identically-named events because it only detects a collision when they use the same delegate types.In Core/src/Castle.Core/DynamicProxy/Generators/MetaEvent.cs Lines 131 to 134 in d88e944
If those lines were uncommented, the above test case would pass (as would all the other tests in the test suite). I suspect we have the same fundamental issue with properties: public interface IBase
{
- event Action Event;
+ Action Property { get; }
}
public interface IDerived : IBase
{
- new event Action<bool> Event;
+ new Action<bool> Property { get; }
} resulting in two identically-named properties being generated:
Interestingly, PEVerify does not complain about this. I'm not sure why it deems this fine when identically-named events are not. At the very least, overloading properties by type is a CLS rule violation (see CLS rules 37 and 38 e.g. here). |
Probably a PEVerify bug. There has been other cases in the past where PEVerify hasn't picked invalid IL, but the CLR did. |
We got a report over at devlooped/moq#1175 that appears to be caused by a bug in DynamicProxy. I've derived the following test case:
This will generate a proxy class containing two identically-named events:
...which isn't legal, and PEVerify confirms that:
I haven't thought about possible solutions in detail, but I suspect we would need to resolve this name conflict by renaming one of the two event implementations (ideally the one for the shadowed base type's event) to e.g.
Event_1
.The text was updated successfully, but these errors were encountered: