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

Commit

Permalink
Expose serialization primitives from System.Private.Corelib
Browse files Browse the repository at this point in the history
- Update the model.xml file to expose the serialization primitives from the runtime, e.g. [Serializable], [NonSerialized], ISerializable, etc.
- Tweak how FEATURE_SERIALIZATION is used on some types.  ISerializable and IDeserializationCallback are not ifdef'd based on FEATURE_SERIALIZATION, but their members are, which means there are some types which are implementing the interface but have the implementation of the interface's method ifdef'd.  This commit removes the ifdef'ing of the methods on the interface, and then ifdef's the implementation of the interface on the offending types.
  • Loading branch information
stephentoub committed Jul 21, 2016
1 parent 481c181 commit c6006ee
Show file tree
Hide file tree
Showing 27 changed files with 236 additions and 49 deletions.
90 changes: 90 additions & 0 deletions src/mscorlib/model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6352,6 +6352,9 @@
<Member Name="IsStateAvailable" />
<Member Name="EnsureState" />
</Type>
<Type Name="System.SerializableAttribute">
<Member Name="#ctor" />
</Type>
<Type Name="System.Single">
<Member MemberType="Field" Name="Epsilon" />
<Member MemberType="Field" Name="MaxValue" />
Expand Down Expand Up @@ -9526,11 +9529,98 @@
<Type Name="System.Runtime.Serialization.FormatterServices">
<Member Name="GetUninitializedObject(System.Type)" />
</Type>
<Type Name="System.Runtime.Serialization.OptionalFieldAttribute">
<Member Name="#ctor" />
<Member MemberType="Property" Name="VersionAdded" />
</Type>
<Type Name="System.Runtime.Serialization.SerializationEntry">
<Member MemberType="Property" Name="Value" />
<Member MemberType="Property" Name="Name" />
<Member MemberType="Property" Name="ObjectType" />
</Type>
<Type Name="System.Runtime.Serialization.SerializationException">
<Member Name="#ctor" />
<Member Name="#ctor(System.String)" />
<Member Name="#ctor(System.String,System.Exception)" />
</Type>
<Type Name="System.Runtime.Serialization.SerializationInfo">
<Member Name="#ctor(System.Type,System.Runtime.Serialization.IFormatterConverter)" />
<Member Name="#ctor(System.Type,System.Runtime.Serialization.IFormatterConverter,System.Boolean)" />
<Member Name="SetType(System.Type)" />
<Member Name="GetEnumerator" />
<Member Name="AddValue(System.String,System.Object,System.Type)" />
<Member Name="AddValue(System.String,System.Object)" />
<Member Name="AddValue(System.String,System.Boolean)" />
<Member Name="AddValue(System.String,System.Char)" />
<Member Name="AddValue(System.String,System.SByte)" />
<Member Name="AddValue(System.String,System.Byte)" />
<Member Name="AddValue(System.String,System.Int16)" />
<Member Name="AddValue(System.String,System.UInt16)" />
<Member Name="AddValue(System.String,System.Int32)" />
<Member Name="AddValue(System.String,System.UInt32)" />
<Member Name="AddValue(System.String,System.Int64)" />
<Member Name="AddValue(System.String,System.UInt64)" />
<Member Name="AddValue(System.String,System.Single)" />
<Member Name="AddValue(System.String,System.Double)" />
<Member Name="AddValue(System.String,System.Decimal)" />
<Member Name="AddValue(System.String,System.DateTime)" />
<Member Name="GetValue(System.String,System.Type)" />
<Member Name="GetBoolean(System.String)" />
<Member Name="GetChar(System.String)" />
<Member Name="GetSByte(System.String)" />
<Member Name="GetByte(System.String)" />
<Member Name="GetInt16(System.String)" />
<Member Name="GetUInt16(System.String)" />
<Member Name="GetInt32(System.String)" />
<Member Name="GetUInt32(System.String)" />
<Member Name="GetInt64(System.String)" />
<Member Name="GetUInt64(System.String)" />
<Member Name="GetSingle(System.String)" />
<Member Name="GetDouble(System.String)" />
<Member Name="GetDecimal(System.String)" />
<Member Name="GetDateTime(System.String)" />
<Member Name="GetString(System.String)" />
<Member MemberType="Property" Name="FullTypeName" />
<Member MemberType="Property" Name="AssemblyName" />
<Member MemberType="Property" Name="MemberCount" />
<Member MemberType="Property" Name="ObjectType" />
<Member MemberType="Property" Name="IsFullTypeNameSetExplicit" />
<Member MemberType="Property" Name="IsAssemblyNameSetExplicit" />
</Type>
<Type Name="System.Runtime.Serialization.SerializationInfoEnumerator">
<Member Name="MoveNext" />
<Member Name="Reset" />
<Member Name="System.Collections.IEnumerator.get_Current" />
<Member MemberType="Property" Name="Current" />
<Member MemberType="Property" Name="Name" />
<Member MemberType="Property" Name="Value" />
<Member MemberType="Property" Name="ObjectType" />
</Type>
<Type Name="System.Runtime.Serialization.ISerializable">
<Member Name="GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)" />
</Type>
<Type Name="System.Runtime.Serialization.IFormatterConverter">
<Member Name="Convert(System.Object,System.Type)" />
<Member Name="Convert(System.Object,System.TypeCode)" />
<Member Name="ToBoolean(System.Object)" />
<Member Name="ToChar(System.Object)" />
<Member Name="ToSByte(System.Object)" />
<Member Name="ToByte(System.Object)" />
<Member Name="ToInt16(System.Object)" />
<Member Name="ToUInt16(System.Object)" />
<Member Name="ToInt32(System.Object)" />
<Member Name="ToUInt32(System.Object)" />
<Member Name="ToInt64(System.Object)" />
<Member Name="ToUInt64(System.Object)" />
<Member Name="ToSingle(System.Object)" />
<Member Name="ToDouble(System.Object)" />
<Member Name="ToDecimal(System.Object)" />
<Member Name="ToDateTime(System.Object)" />
<Member Name="ToString(System.Object)" />
</Type>
<Type Name="System.Runtime.Serialization.IDeserializationCallback">
<Member Name="OnDeserialization(System.Object)" />
</Type>
<Type Status="ApiRoot" Name="System.Runtime.Serialization.OnSerializingAttribute">
<Member Name="#ctor" />
</Type>
Expand Down
6 changes: 5 additions & 1 deletion src/mscorlib/src/System/DateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ namespace System {
#if FEATURE_SERIALIZATION
[Serializable]
#endif
public struct DateTime : IComparable, IFormattable, IConvertible, ISerializable, IComparable<DateTime>,IEquatable<DateTime> {
public struct DateTime : IComparable, IFormattable, IConvertible, IComparable<DateTime>, IEquatable<DateTime>
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{

// Number of 100ns ticks per time unit
private const long TicksPerMillisecond = 10000;
Expand Down
9 changes: 6 additions & 3 deletions src/mscorlib/src/System/DateTimeOffset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ namespace System {
#if FEATURE_SERIALIZATION
[Serializable]
#endif
public struct DateTimeOffset : IComparable, IFormattable, ISerializable, IDeserializationCallback,
IComparable<DateTimeOffset>, IEquatable<DateTimeOffset> {

public struct DateTimeOffset : IComparable, IFormattable,
IComparable<DateTimeOffset>, IEquatable<DateTimeOffset>
#if FEATURE_SERIALIZATION
, ISerializable, IDeserializationCallback
#endif
{
// Constants
internal const Int64 MaxOffset = TimeSpan.TicksPerHour * 14;
internal const Int64 MinOffset = -MaxOffset;
Expand Down
7 changes: 5 additions & 2 deletions src/mscorlib/src/System/Decimal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ namespace System {
#endif
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.Versioning.NonVersionable] // This only applies to field layout
public struct Decimal : IFormattable, IComparable, IConvertible, IDeserializationCallback
, IComparable<Decimal>, IEquatable<Decimal> {
public struct Decimal : IFormattable, IComparable, IConvertible, IComparable<Decimal>, IEquatable<Decimal>
#if FEATURE_SERIALIZATION
, IDeserializationCallback
#endif
{

// Sign mask for the flags field. A value of zero in this bit indicates a
// positive Decimal value, and a value of one in this bit indicates a
Expand Down
5 changes: 4 additions & 1 deletion src/mscorlib/src/System/Globalization/TextInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ namespace System.Globalization {
[Serializable]
#endif
[System.Runtime.InteropServices.ComVisible(true)]
public class TextInfo : ICloneable, IDeserializationCallback
public class TextInfo : ICloneable
#if FEATURE_SERIALIZATION
, IDeserializationCallback
#endif
{
//--------------------------------------------------------------------//
// Internal Information //
Expand Down
5 changes: 4 additions & 1 deletion src/mscorlib/src/System/IO/DriveInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ public enum DriveType
[Serializable]
#endif
[ComVisible(true)]
public sealed class DriveInfo : ISerializable
public sealed class DriveInfo
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
private String _name;

Expand Down
5 changes: 4 additions & 1 deletion src/mscorlib/src/System/IntPtr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ namespace System {
[Serializable]
#endif
[System.Runtime.InteropServices.ComVisible(true)]
public struct IntPtr : ISerializable
public struct IntPtr
#if FEATURE_SERIALIZATION
: ISerializable
#endif
{
[SecurityCritical]
unsafe private void* m_value; // The compiler treats void* closest to uint hence explicit casts are required to preserve int behavior
Expand Down
5 changes: 4 additions & 1 deletion src/mscorlib/src/System/Reflection/AssemblyName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ namespace System.Reflection {
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(_AssemblyName))]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyName : _AssemblyName, ICloneable, ISerializable, IDeserializationCallback
public sealed class AssemblyName : _AssemblyName, ICloneable
#if FEATURE_SERIALIZATION
, ISerializable, IDeserializationCallback
#endif
{
//
// READ ME
Expand Down
5 changes: 4 additions & 1 deletion src/mscorlib/src/System/Reflection/Missing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ namespace System.Reflection
[Serializable]
#endif
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class Missing: ISerializable
public sealed class Missing
#if FEATURE_SERIALIZATION
: ISerializable
#endif
{
public static readonly Missing Value = new Missing();

Expand Down
8 changes: 6 additions & 2 deletions src/mscorlib/src/System/Reflection/Pointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ namespace System.Reflection {
[Serializable]
#endif
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class Pointer: ISerializable {
[SecurityCritical]
public sealed class Pointer
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
[SecurityCritical]
unsafe private void* _ptr;
private RuntimeType _ptrType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ namespace System.Runtime.Serialization {
// Interface does not need to be marked with the serializable attribute
[System.Runtime.InteropServices.ComVisible(true)]
public interface IDeserializationCallback {
#if FEATURE_SERIALIZATION
void OnDeserialization(Object sender);
#endif

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ namespace System.Runtime.Serialization {

[System.Runtime.InteropServices.ComVisible(true)]
public interface ISerializable {
#if FEATURE_SERIALIZATION
[System.Security.SecurityCritical] // auto-generated_required
void GetObjectData(SerializationInfo info, StreamingContext context);
#endif
}

}
Expand Down
11 changes: 7 additions & 4 deletions src/mscorlib/src/System/Security/PermissionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ internal enum SpecialPermissionSetFlag
[StrongNameIdentityPermissionAttribute(SecurityAction.InheritanceDemand, Name = "mscorlib", PublicKey = "0x" + AssemblyRef.EcmaPublicKeyFull)]
#endif
[System.Runtime.InteropServices.ComVisible(true)]
public class PermissionSet : ISecurityEncodable, ICollection, IStackWalk, IDeserializationCallback
public class PermissionSet : ISecurityEncodable, ICollection, IStackWalk
#if FEATURE_SERIALIZATION
, IDeserializationCallback
#endif
{
#if _DEBUG
#if _DEBUG
internal static readonly bool debug;
#endif
#endif

[System.Diagnostics.Conditional( "_DEBUG" )]
private static void DEBUG_WRITE(String str) {
#if _DEBUG
Expand Down
10 changes: 8 additions & 2 deletions src/mscorlib/src/System/Text/CodePageEncoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ namespace System.Text
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal sealed class CodePageEncoding : ISerializable, IObjectReference
internal sealed class CodePageEncoding : IObjectReference
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
// Temp stuff
[NonSerialized]
Expand Down Expand Up @@ -109,7 +112,10 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal sealed class Decoder : ISerializable, IObjectReference
internal sealed class Decoder : IObjectReference
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
// Might need this when GetRealObjecting
[NonSerialized]
Expand Down
5 changes: 4 additions & 1 deletion src/mscorlib/src/System/Text/DecoderNLS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ namespace System.Text
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal class DecoderNLS : Decoder, ISerializable
internal class DecoderNLS : Decoder
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
// Remember our encoding
protected Encoding m_encoding;
Expand Down
5 changes: 4 additions & 1 deletion src/mscorlib/src/System/Text/EncoderNLS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ namespace System.Text
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal class EncoderNLS : Encoder, ISerializable
internal class EncoderNLS : Encoder
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
// Need a place for the last left over character, most of our encodings use this
internal char charLeftOver;
Expand Down
10 changes: 8 additions & 2 deletions src/mscorlib/src/System/Text/Encoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,10 @@ internal void ThrowCharsOverflow(DecoderNLS decoder, bool nothingDecoded)
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal class DefaultEncoder : Encoder, ISerializable, IObjectReference
internal class DefaultEncoder : Encoder, IObjectReference
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
private Encoding m_encoding;
[NonSerialized] private bool m_hasInitializedEncoding;
Expand Down Expand Up @@ -1745,7 +1748,10 @@ public unsafe override int GetBytes(char* chars, int charCount,
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal class DefaultDecoder : Decoder, ISerializable, IObjectReference
internal class DefaultDecoder : Decoder, IObjectReference
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
private Encoding m_encoding;
[NonSerialized]
Expand Down
5 changes: 4 additions & 1 deletion src/mscorlib/src/System/Text/ISCIIEncoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ namespace System.Text
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal class ISCIIEncoding : EncodingNLS, ISerializable
internal class ISCIIEncoding : EncodingNLS
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
// Constants
private const int CodeDefault = 0; // 0x40 Default
Expand Down
5 changes: 4 additions & 1 deletion src/mscorlib/src/System/Text/Latin1Encoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ namespace System.Text
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal class Latin1Encoding : EncodingNLS, ISerializable
internal class Latin1Encoding : EncodingNLS
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
// We only use the best-fit table, of which ASCII is a superset for us.
public Latin1Encoding() : base(Encoding.ISO_8859_1)
Expand Down
15 changes: 12 additions & 3 deletions src/mscorlib/src/System/Text/MLangCodePageEncoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ namespace System.Text
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal sealed class MLangCodePageEncoding : ISerializable, IObjectReference
internal sealed class MLangCodePageEncoding : IObjectReference
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
// Temp stuff
[NonSerialized]
Expand Down Expand Up @@ -111,7 +114,10 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal sealed class MLangEncoder : ISerializable, IObjectReference
internal sealed class MLangEncoder : IObjectReference
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
// Might need this when GetRealObjecting
[NonSerialized]
Expand Down Expand Up @@ -151,7 +157,10 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex
#if FEATURE_SERIALIZATION
[Serializable]
#endif
internal sealed class MLangDecoder : ISerializable, IObjectReference
internal sealed class MLangDecoder : IObjectReference
#if FEATURE_SERIALIZATION
, ISerializable
#endif
{
// Might need this when GetRealObjecting
[NonSerialized]
Expand Down
Loading

0 comments on commit c6006ee

Please sign in to comment.