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

Prevent double GetObjectData implementation for badly implemented serializable classes #554

Merged
merged 6 commits into from Jan 20, 2021

Conversation

stakx
Copy link
Member

@stakx stakx commented Jan 6, 2021

Fixes #367. As an additional bonus, gets rid of this:

var methodsToSkip = new List<MethodInfo>(); // TODO: the trick with methodsToSkip is not very nice...

See commit messages and code comments for details.

@stakx stakx added this to the v5.0.0 milestone Jan 6, 2021
@stakx stakx requested a review from jonorossi January 6, 2021 01:14
@stakx stakx force-pushed the bad-serializables branch 2 times, most recently from b4bc444 to afb5ebb Compare January 19, 2021 19:08
@stakx stakx requested a review from jonorossi January 19, 2021 19:17
An overridable `GetObjectData` method inside a `[Serializable]` class
that does not implement `ISerializable` can be handled in two ways:

 1. It can be overridden as part of the `ISerializable` implementation
    that DynamicProxy provides for `[Serializable]` classes.

 2. It can be proxied regularly, like any other overridable method.

Unfortunately, at this time, DynamicProxy does both, i.e. it produces
two `GetObjectData` methods with identical signature in the same proxy
type, which causes verification failure.

The correct behavior is (1): The `ISerializable` implementation should
take precedence over any method proxying, even though proxied methods
are emitted first. (Thus the need for "the trick with methodsToSkip"!)
@stakx stakx merged commit dd97a09 into castleproject:master Jan 20, 2021
@stakx stakx deleted the bad-serializables branch January 20, 2021 07:12
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.

Proxying certain [Serializable] classes produces proxy types that fail PEVerify test
2 participants