-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
System.Net.Http.HttpRequestException is not marked as [Serializable] #42154
Comments
API proposal: namespace System.Net.Http
{
[Serializable] // ADD this attribute
public class HttpRequestException
{
protected HttpRequestException(SerializationInfo info, StreamingContext context); // ADD this ctor
public override void GetObjectData(SerializationInfo info, StreamingContext context); // OVERRIDE this method
}
} This is a request from the Orleans team and matches when we said we'd allow new serialization ctors to be added: (a) it must be an exception-derived type, and (b) the type must exist across both .NET Core and .NET framework. The n.b. Full Framework does not expose the APIs being added here. The I'll create a separate issue to track allowing |
Opened https://github.com/dotnet/designs/issues/158 to track creating safe |
@dotnet/ncl |
@GrabYourPitchforks this class is not sealed, adding an interface is a breaking change no? |
It's not a breaking compile-time change. It's potentially a breaking runtime change in that if somebody marked their subclassed type |
Oh, derp, of course the base type already implements the interface. I'll update the proposal. |
namespace System.Net.Http
{
[Serializable]
public class HttpRequestException
{
protected HttpRequestException(SerializationInfo info, StreamingContext context);
public override void GetObjectData(SerializationInfo info, StreamingContext context);
}
} |
Tagging subscribers to this area: @dotnet/ncl |
Whoever implements this will need to make sure that the type serializes/deserializes correctly in both directions between .NET Core and .NET Framework, otherwise it'll defeat the purpose of this. And to that end, a) there have been several new members added to HttpRequestException in .NET Core, so they'll need to be properly dealt with, and b) the implementation on .NET Framework uses the "safe serialization" mechanism, and I'm not sure that'll "just work". |
@stephentoub You're welcome to assign me |
@GrabYourPitchforks as this missed 6.0, and in 7.0 we expect to disable BinaryFormatter by default and the hypothetical replacement does not depend on ISerializable. is this still relevant? I realize this package ships on .NET Framework as well, but as noted above, it must deserialize on .NET Core too. |
@GrabYourPitchforks thoughts? |
Spoke offline with Steve about this. Since the scenario of cross-serializing between netfx and netcore won't be supported, the "exceptions which exist on both platforms" rule of thumb really doesn't apply, since we really won't be able to support the scenario that rule of thumb was trying to drive at. I'm supportive of just closing this issue as won't-fix. |
#60600 (comment) mentioned by @bartonjs also describes the cross appdomain scenario. Are we consistent, and is our guidance clear? Or is cross appdomain not relevant here? |
That isn't relevant here. |
This issue is related to this issue.
Projects like Orleans require types and especially exceptions to be serializable. Most .NET Core exceptions are already marked as such.
The ask is to mark HttpRequestException as [Serializable] and add the requisite protected ctors.
The text was updated successfully, but these errors were encountered: