Prevent double GetObjectData implementation for badly implemented serializable classes#554
Merged
stakx merged 6 commits intocastleproject:masterfrom Jan 20, 2021
Merged
Conversation
stakx
commented
Jan 6, 2021
src/Castle.Core/DynamicProxy/Contributors/ClassProxySerializableContributor.cs
Show resolved
Hide resolved
src/Castle.Core/DynamicProxy/Contributors/ClassProxyWithTargetTargetContributor.cs
Show resolved
Hide resolved
src/Castle.Core/DynamicProxy/Contributors/ClassProxySerializableContributor.cs
Outdated
Show resolved
Hide resolved
jonorossi
requested changes
Jan 19, 2021
src/Castle.Core/DynamicProxy/Contributors/ClassProxySerializableContributor.cs
Outdated
Show resolved
Hide resolved
src/Castle.Core/DynamicProxy/Contributors/ClassProxyWithTargetTargetContributor.cs
Show resolved
Hide resolved
src/Castle.Core/DynamicProxy/Contributors/ClassProxySerializableContributor.cs
Outdated
Show resolved
Hide resolved
b4bc444 to
afb5ebb
Compare
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"!)
afb5ebb to
87b6e58
Compare
jonorossi
approved these changes
Jan 20, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #367. As an additional bonus, gets rid of this:
Core/src/Castle.Core/DynamicProxy/Generators/BaseClassProxyGenerator.cs
Line 112 in 9143de2
See commit messages and code comments for details.