-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Scale back [Serializable] on CoreCLR types #11765
Conversation
…erializable as well as adding special handling to MulticastDelegate to prevent serializing delegates (which can't be correctly serialized cross platform/runtime).
CC @dotnet/corert-contrib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I checked the types you removed it from but not which ones you didn't.
@@ -9,7 +9,6 @@ | |||
namespace System | |||
{ | |||
//Marked serializable even though it has no state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is no longer applicable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
@@ -18,9 +18,6 @@ namespace System.Diagnostics.Tracing | |||
/// <summary> | |||
/// Exception that is thrown when an error occurs during EventSource operation. | |||
/// </summary> | |||
#if !ES_BUILD_PCL | |||
[Serializable] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think that this should stay, but under different ifdef. @brianrob ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that the EventSourceException is Serializable because we require all Exceptions to be serializable on the Desktop runtime to support Exceptions traveling across AppDomain boundaries.
EventSource is unusual, in that at least at one time we tried to keep the source code the same on Desktop and CoreCLR (however because shiproom would wanted only changes that were in response to a particular request to change the desktop, the code bases are NOT in sync today). Still it may still be useful to keep open the option of a 'bulk update' (I think it is still true that we COULD simply copy the contents to the desktop and it would be 'correct'. Removing [Serializable] for the desktop build would break that.
I looked and we don't have a #ifdef that means' Desktop. The closest thing we have is 'not coreCLR or Project N or not Portable'
#if !CORECLR && !ES_BUILD_PN && !ES_BUILD_PCL
This is my recommendation. Simply surround the [serialable] with this instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of things to be aware of:
- This is shared source so it will sync to CoreRT and ProjectN as well. You'll want to make sure that you have the proper !CORERT ifdef as well if you care about CoreRT.
- EventSource tests are located in CoreFx. Before you submit, you should request that CoreFX tests be run against this change. These are the trigger phrases you want to use:
@dotnet-bot test Ubuntu x64 corefx_baseline
@dotnet-bot test Windows_NT x64 corefx_baseline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've added @vancem 's suggested ifdef along with !CORERT.
@brianrob , I've been testing this against CoreFX and modified tests appropriately so that it works. That change was dotnet/corefx#20035.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thanks.
@@ -134,7 +132,6 @@ public override int Compare(T x, T y) | |||
// since we want to serialize as ObjectComparer for | |||
// back-compat reasons (see below). | |||
|
|||
[Serializable] | |||
internal sealed class Int32EnumComparer<T> : Comparer<T>, ISerializable where T : struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these need to remain serializable to make the Comparer<T>
serialization work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect so. I seem to remember adding these explicitly in response to a bug, and adding tests for them in corefx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks plausible. I've added them.
@@ -12,7 +12,6 @@ | |||
|
|||
namespace System | |||
{ | |||
[Serializable] | |||
// Holds classes (Empty, Null, Missing) for which we guarantee that there is only ever one instance of. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole file should be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll include that with general ISerializable cleanup (I've updated https://github.com/dotnet/corefx/issues/19119 to include that)
@@ -9,7 +9,6 @@ | |||
|
|||
namespace System.Reflection | |||
{ | |||
[Serializable] | |||
#if CORECLR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole file should be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll include that with general ISerializable cleanup (I've updated dotnet/corefx#19119 to include that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you get rid of this file, you can get rid of
src\System\Reflection\MemberSerializationStringGenerator.cs
too. There are versions of this file in both CoreCLR and CoreRT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked into all changes - LGTM
@dotnet-bot test Windows_NT x64 CoreCLR Perf Tests Correctness |
FYI, the perf correctness failures are tracked by https://github.com/dotnet/coreclr/issues/11856. |
@brianrob , thanks. I'll go ahead and merge then since previous CIs succeeded and #11856 hasn't been fixed yet. |
Removes SerializableAttribute from CoreCLR types not intended to be serializable as well as adding special handling to MulticastDelegate to prevent serializing delegates (which can't be correctly serialized cross platform/runtime). Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Removes SerializableAttribute from CoreCLR types not intended to be serializable as well as adding special handling to MulticastDelegate to prevent serializing delegates (which can't be correctly serialized cross platform/runtime). Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Removes SerializableAttribute from CoreCLR types not intended to be serializable as well as adding special handling to MulticastDelegate to prevent serializing delegates (which can't be correctly serialized cross platform/runtime).
* Scale back [Serializable] on CoreCLR types (#11765) Removes SerializableAttribute from CoreCLR types not intended to be serializable as well as adding special handling to MulticastDelegate to prevent serializing delegates (which can't be correctly serialized cross platform/runtime). * ISerializable cleanup (#11873) Changes to throw PlatformNotSupportedException from ISerializable.GetObjectData and serialization constructors on non-Serializable types. Also removes private serialization constructors and some unneeded code that was used to support serializing non-serializable types. A few tests testing GetObjectData implementations are also removed. For Exception types, we call base instead of throwing from GetObjectData to be consistent with the many Exceptions that don't override GetObjectData * IDeserializationCallback cleanup Throws PlatformNotSupportedException from IDeserializationCallback and IObjectReference implementations on types that are no longer serializable. * Coretype variables renamed back to netfx counterpart for reflection based serialization (#11910) * Variables renamed for reflection based serialization * Make EqualityComparers serialize like desktop * add missing interfaces * TimeZone serializable added * Internal hashtable serializable * Removed TimeZone as serializable type * Remove Lazy<T>'s [Serializable] attribute for 2.0 For performance, Lazy was completely rewritten for .NET Core 2.0 and has an entirely different format than desktop; trying to get it to match the desktop serialization format would require either reverting or providing a complicated custom serialization/deserialization implementation to try to match. Lazy can also wrap an Exception that occurred from trying to instantiate the object, and the only exception types that are serializable as of now in core are the base Exception and AggregateException. As such, we're cutting it from the list of supported types in 2.0. An easy workaround is simply to do what the implementation does: serialize lazy.Value instead of lazy. * tiny fixes to equalitycomparer.cs * Merge pull request #11995 from ViktorHofer/SerializationFollowUp Internal hashtable serialization attribute removed * Fixes deserializaing TimeZoneInfo by putting back the IDeserializationCallback.OnDeserialization method. (#12024)
Apparently, the serialization support for `System.Random` is not present in `netstandard1.3` and even though it was added at some point, it is again removed from the future `netstandard` versions. See the following PR for more info: dotnet/coreclr#11765
Ported to 2.0.0 in #12020 |
Apparently, the serialization support for `System.Random` is not present in `netstandard1.3` and even though it was added at some point, it is again removed from the future `netstandard` versions. See the following PR for more info: dotnet/coreclr#11765
Removes SerializableAttribute from CoreCLR types not intended to be serializable as well as adding special handling to MulticastDelegate to prevent serializing delegates (which can't be correctly serialized cross platform/runtime).
This is the first CoreCLR portion of https://github.com/dotnet/corefx/issues/19119.
Please do not merge until dotnet/corefx#20035 is merged since those are the test changes that match this change.