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

Scale back [Serializable] on CoreCLR types #11765

Merged
merged 2 commits into from
May 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/mscorlib/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3287,6 +3287,9 @@
<data name="Serialization_DateTimeTicksOutOfRange" xml:space="preserve">
<value>Invalid serialized DateTime data. Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.</value>
</data>
<data name="Serialization_DelegatesNotSupported" xml:space="preserve">
<value>Serializing delegates is not supported on this platform.</value>
</data>
<data name="Serialization_InsufficientDeserializationState" xml:space="preserve">
<value>Insufficient state to deserialize the object. Missing field '{0}'. More information is needed.</value>
</data>
Expand Down
3 changes: 1 addition & 2 deletions src/mscorlib/System.Private.CoreLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@
<Compile Include="$(BclSourcesRoot)\System\Currency.cs" />
<Compile Include="$(BclSourcesRoot)\System\Decimal.cs" />
<Compile Include="$(BclSourcesRoot)\System\DefaultBinder.CanConvert.cs" />
<Compile Include="$(BclSourcesRoot)\System\DelegateSerializationHolder.cs" />
<Compile Include="$(BclSourcesRoot)\System\Double.cs" />
<Compile Include="$(BclSourcesRoot)\System\Empty.cs" />
<Compile Include="$(BclSourcesRoot)\System\Enum.cs" />
Expand Down Expand Up @@ -734,4 +733,4 @@
<Win32Resource Condition="'$(GenerateNativeVersionInfo)'=='true'">$(IntermediateOutputPath)\System.Private.CoreLib.res</Win32Resource>
</PropertyGroup>
<Import Project="GenerateCompilerResponseFile.targets" />
</Project>
</Project>
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/ApplicationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace System
// ApplicationException extends but adds no new functionality to
// RecoverableException.
//
[Serializable]
public class ApplicationException : Exception
{
// Creates a new ApplicationException with its message string set to
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/ArgumentException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace System
// the contract of the method. Ideally it should give a meaningful error
// message describing what was wrong and which parameter is incorrect.
//
[Serializable]
public class ArgumentException : SystemException
{
private String _paramName;
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/ArgumentNullException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace System
// The ArgumentException is thrown when an argument
// is null when it shouldn't be.
//
[Serializable]
public class ArgumentNullException : ArgumentException
{
// Creates a new ArgumentNullException with its message
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/ArgumentOutOfRangeException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace System
{
// The ArgumentOutOfRangeException is thrown when an argument
// is outside the legal range for that argument.
[Serializable]
public class ArgumentOutOfRangeException : ArgumentException
{
private Object _actualValue;
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/ArithmeticException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace System
// The ArithmeticException is thrown when overflow or underflow
// occurs.
//
[Serializable]
public class ArithmeticException : SystemException
{
// Creates a new ArithmeticException with its message string set to
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/ArrayTypeMismatchException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace System
// The ArrayMismatchException is thrown when an attempt to store
// an object of the wrong type within an array occurs.
//
[Serializable]
public class ArrayTypeMismatchException : SystemException
{
// Creates a new ArrayMismatchException with its message string set to
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/AttributeUsageAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
namespace System
{
/* By default, attributes are inherited and multiple attributes are not allowed */
[Serializable]
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
public sealed class AttributeUsageAttribute : Attribute
{
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/BadImageFormatException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace System
{
[Serializable]
public partial class BadImageFormatException : SystemException
{
private String _fileName; // The name of the corrupt PE file.
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/CLSCompliantAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace System
{
[Serializable]
[AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
public sealed class CLSCompliantAttribute : Attribute
{
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/CharEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace System
{
[Serializable]
public sealed class CharEnumerator : IEnumerator, IEnumerator<char>, IDisposable, ICloneable
{
private String _str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace System.Collections.Generic
{
[Serializable]
public class KeyNotFoundException : SystemException
{
public KeyNotFoundException()
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/CurrentSystemTimeZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
namespace System
{
[Obsolete("System.CurrentSystemTimeZone has been deprecated. Please investigate the use of System.TimeZoneInfo.Local instead.")]
[Serializable]
internal partial class CurrentSystemTimeZone : TimeZone
{
// Standard offset in ticks to the Universal time if
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/DBNull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace System
{
[Serializable]
public sealed class DBNull : ISerializable, IConvertible
{
private DBNull()
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/DataMisalignedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace System
{
[Serializable]
public sealed class DataMisalignedException : SystemException
{
public DataMisalignedException()
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/DefaultBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace System
{
//Marked serializable even though it has no state.
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

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

Removed

[Serializable]
#if CORECLR
internal
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace System.Diagnostics
{
[Serializable]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
public sealed class ConditionalAttribute : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Member

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 ?

Copy link

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.

Copy link
Member

@brianrob brianrob May 23, 2017

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:

  1. 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.
  2. 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

Copy link
Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Great. Thanks.

#endif
public class EventSourceException : Exception
{
/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/DivideByZeroException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace System
{
[Serializable]
public class DivideByZeroException : ArithmeticException
{
public DivideByZeroException()
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/DllNotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

namespace System
{
[Serializable]
public class DllNotFoundException : TypeLoadException
{
public DllNotFoundException()
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/DuplicateWaitObjectException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace System
// The DuplicateWaitObjectException is thrown when an object
// appears more than once in the list of objects to WaitAll or WaitAny.
//
[Serializable]
public class DuplicateWaitObjectException : ArgumentException
{
private static volatile String s_duplicateWaitObjectMessage = null;
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/EntryPointNotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

namespace System
{
[Serializable]
public class EntryPointNotFoundException : TypeLoadException
{
public EntryPointNotFoundException()
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/EventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
namespace System
{
// The base class for all event classes.
[Serializable]
public class EventArgs
{
public static readonly EventArgs Empty = new EventArgs();
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/ExecutionEngineException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
namespace System
{
[Obsolete("This type previously indicated an unspecified fatal error in the runtime. The runtime no longer raises this exception so this type is obsolete.")]
[Serializable]
public sealed class ExecutionEngineException : SystemException
{
public ExecutionEngineException()
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/FieldAccessException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace System
{
[Serializable]
public class FieldAccessException : MemberAccessException
{
public FieldAccessException()
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/FlagsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace System
// should be treated as a bitfield (or set of flags).
// An IDE may use this information to provide a richer
// development experience.
[Serializable]
[AttributeUsage(AttributeTargets.Enum, Inherited = false)]
public class FlagsAttribute : Attribute
{
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/FormatException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace System
{
[Serializable]
public class FormatException : SystemException
{
public FormatException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace System.Globalization
** ChineseLunisolar 1901/01/01 2100/12/29
*/

[Serializable]
public class ChineseLunisolarCalendar : EastAsianLunisolarCalendar
{
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace System.Globalization
{
[Serializable]
public class CultureNotFoundException : ArgumentException
{
private string _invalidCultureName; // unrecognized culture name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ internal enum DateTimeFormatFlags
}


[Serializable]
public sealed class DateTimeFormatInfo : IFormatProvider, ICloneable
{
// cache for the invariant culture.
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/Globalization/DaylightTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace System.Globalization
{
// This class represents a starting/ending time for a period of daylight saving time.
[Serializable]
public class DaylightTime
{
private readonly DateTime _start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace System.Globalization
{
[Serializable]
public abstract class EastAsianLunisolarCalendar : Calendar
{
internal const int LeapMonth = 0;
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/Globalization/HebrewCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ namespace System.Globalization
// Gregorian to Hebrew Lunar from 1583 to 2239.


[Serializable]
public class HebrewCalendar : Calendar
{
public static readonly int HebrewEra = 1;
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/Globalization/HijriCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ namespace System.Globalization
** Hijri 0001/01/01 9666/04/03
*/

[Serializable]
public partial class HijriCalendar : Calendar
{
public static readonly int HijriEra = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace System.Globalization
============================================================================*/


[Serializable]
public partial class JapaneseCalendar : Calendar
{
internal static readonly DateTime calendarMinValue = new DateTime(1868, 9, 8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace System.Globalization
** JapaneseLunisolar 1960/01/01 2049/12/29
*/

[Serializable]
public class JapaneseLunisolarCalendar : EastAsianLunisolarCalendar
{
//
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/Globalization/JulianCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace System.Globalization
//* Gregorian 0001/01/01 9999/12/31
//* Julia 0001/01/03 9999/10/19

[Serializable]
public class JulianCalendar : Calendar
{
public static readonly int JulianEra = 1;
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/Globalization/KoreanCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace System.Globalization
============================================================================*/


[Serializable]
public class KoreanCalendar : Calendar
{
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace System.Globalization
** KoreanLunisolar 918/01/01 2050/13/29
*/

[Serializable]
public class KoreanLunisolarCalendar : EastAsianLunisolarCalendar
{
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ namespace System.Globalization
// CurrencySymbol "$" String used as local monetary symbol.
//

[Serializable]
sealed public class NumberFormatInfo : IFormatProvider, ICloneable
{
// invariantInfo is constant irrespective of your current culture.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace System.Globalization
** Persian 0001/01/01 9378/10/13
*/

[Serializable]
public class PersianCalendar : Calendar
{
public static readonly int PersianEra = 1;
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/Globalization/SortKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

namespace System.Globalization
{
[Serializable]
public partial class SortKey
{
//--------------------------------------------------------------------//
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/Globalization/StringInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

namespace System.Globalization
{
[Serializable]
public class StringInfo
{
[OptionalField(VersionAdded = 2)]
Expand Down
1 change: 0 additions & 1 deletion src/mscorlib/shared/System/Globalization/TaiwanCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace System.Globalization
** Taiwan 01/01/01 8088/12/31
============================================================================*/

[Serializable]
public class TaiwanCalendar : Calendar
{
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace System.Globalization
** TaiwanLunisolar 1912/01/01 2050/13/29
*/

[Serializable]
public class TaiwanLunisolarCalendar : EastAsianLunisolarCalendar
{
// Since
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace System.Globalization
** Thai 0544/01/01 10542/12/31
============================================================================*/

[Serializable]
public class ThaiBuddhistCalendar : Calendar
{
// Initialize our era info.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace System.Globalization
** UmAlQura 1318/01/01 1500/12/30
*/

[Serializable]
public partial class UmAlQuraCalendar : Calendar
{
internal const int MinCalendarYear = 1318;
Expand Down
Loading