Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Remove Serialization Guard public APIs - #38739

Merged
jkotas merged 3 commits into
dotnet:masterfrom
GrabYourPitchforks:serializationguard
Jun 23, 2019
Merged

jkotas merged 3 commits into
dotnet:masterfrom
GrabYourPitchforks:serializationguard

Conversation

@GrabYourPitchforks

Copy link
Copy Markdown
Member

Removes public APIs per https://github.com/dotnet/corefx/issues/36723 and our conversations over email. Also refactors the reflection-based code out of the Process class and into its own standalone file so that it can be shared by future components if needed.

There are no behavioral changes from this PR.

- Also refactors reflection helpers into separate file
@GrabYourPitchforks
GrabYourPitchforks marked this pull request as ready for review June 20, 2019 21:32
@GrabYourPitchforks GrabYourPitchforks added the auto-merge Automatically merge PR once CI passes. label Jun 20, 2019
@ghost

ghost commented Jun 20, 2019

Copy link
Copy Markdown

Hello @GrabYourPitchforks!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.


private static Type GetDeserializationBlockedExceptionType()
{
return typeof(SerializationInfo).Assembly.GetType("System.Runtime.Serialization.DeserializationBlockedException", throwOnError: false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we just use a regular SerializationException for this, and get rid of the DeserializationBlockedException completely?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That would change the control flow of some callers. For example, ObjectManager special-cases the DeserializationBlockedException type and rethrows it rather than allowing a typical TargetInvocationException to escape.

// This will only throw TargetInvocationExceptions, but to provide a better exception for dangerous deserialization, unwrap that
// and re-wrap it in a DeserializationBlockedException (while preserving its stack)
catch (TargetInvocationException outerException) when (outerException.InnerException is DeserializationBlockedException)
{
throw new DeserializationBlockedException(outerException.InnerException);
}

In order to preserve this runtime behavior, would it make sense for us to leave DeserializationBlockedException in (but not exposed via contracts), but have it subclass SerializationException instead of the base Exception type?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this runtime behavior important? There are number of other places that will wrap the exception.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(Correction to my above comment: it seems DeserializationBlockedException already subclasses SerializationException in the implementation. The ref assembly incorrectly shows it as subclassing Exception directly.)

I wouldn't call the existing behavior "important" per se, but I was trying to avoid behavioral changes in this PR. If consensus is that reusing SerializationException directly is the preferred action, and if the behavioral change isn't concerning, we can absolutely piggy-back that on this PR.

@GrabYourPitchforks GrabYourPitchforks removed the auto-merge Automatically merge PR once CI passes. label Jun 22, 2019
@GrabYourPitchforks

Copy link
Copy Markdown
Member Author

With the latest iteration I've removed all references to DeserializationBlockedException entirely from corefx. I still need to remove the type itself, but that'll take place in the coreclr repo.

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@jkotas
jkotas merged commit 8b73a6d into dotnet:master Jun 23, 2019
@GrabYourPitchforks
GrabYourPitchforks deleted the serializationguard branch June 24, 2019 22:19
steveharter pushed a commit to steveharter/dotnet_corefx that referenced this pull request Jun 25, 2019
* Remove Serialization Guard public APIs
- Also refactors reflection helpers into separate file

* PR feedback - remove DeserializationBlockedException refs entirely
@karelz karelz added this to the 3.0 milestone Jul 16, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Remove Serialization Guard public APIs
- Also refactors reflection helpers into separate file

* PR feedback - remove DeserializationBlockedException refs entirely



Commit migrated from dotnet/corefx@8b73a6d
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants