Imported Upstream version 5.2.0.175

Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-06-07 13:16:24 +00:00
parent 4bdbaf4a88
commit 966bba02bb
8776 changed files with 346420 additions and 149650 deletions

View File

@@ -1,14 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30501.0
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Private.DataContractSerialization", "src\System.Private.DataContractSerialization.csproj", "{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{9618597D-FDAE-42CB-B368-80DB80EA1E37}"
ProjectSection(SolutionItems) = preProject
.nuget\packages.Windows_NT.config = .nuget\packages.Windows_NT.config
EndProjectSection
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E107E9C1-E893-4E87-987E-04EF0DCEAEFD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -16,12 +12,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Release|Any CPU.Build.0 = Debug|Any CPU
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6B4C1660-D158-4820-BE1C-D7A29CEBEC9B} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
EndGlobalSection
EndGlobal

View File

@@ -5,5 +5,7 @@
<AssemblyVersion>4.1.3.0</AssemblyVersion>
<IsNETCoreApp>true</IsNETCoreApp>
<IsNETCoreAppRef>false</IsNETCoreAppRef>
<IsUAP>true</IsUAP>
<IsUAPRef>false</IsUAPRef>
</PropertyGroup>
</Project>

View File

@@ -3,7 +3,8 @@
<PropertyGroup>
<BuildConfigurations>
netcoreapp;
uap;
uap-Windows_NT;
uapaot-Windows_NT;
</BuildConfigurations>
</PropertyGroup>
</Project>
</Project>

View File

@@ -1,64 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
@@ -823,7 +764,7 @@
<value>Only one root element is permitted per document.</value>
</data>
<data name="XmlOnlyWhitespace" xml:space="preserve">
<value>Only white space characters can be written with this method.</value>
<value>Only whitespace characters can be written with this method.</value>
</data>
<data name="XmlOnlySingleValue" xml:space="preserve">
<value>Only a single typed value may be written inside an attribute or content.</value>
@@ -870,30 +811,6 @@
<data name="XmlWriterClosed" xml:space="preserve">
<value>The XmlWriter is closed.</value>
</data>
<data name="ObjectSerializer_DictionaryNotSupported" xml:space="preserve">
<value>An internal error has occurred. JSON dictionary type {0} not supported.</value>
</data>
<data name="ObjectDeserializer_BadEscape" xml:space="preserve">
<value>Invalid escape code encountered in a JSON string.</value>
</data>
<data name="ObjectDeserializer_IllegalPrimitive" xml:space="preserve">
<value>'{0}' is not a valid JSON primitive. This error can also occur when extraneous data is present after the JSON data.</value>
</data>
<data name="ObjectDeserializer_InvalidArrayExtraComma" xml:space="preserve">
<value>JSON array ended with a trailing comma.</value>
</data>
<data name="ObjectDeserializer_InvalidMemberName" xml:space="preserve">
<value>Invalid member name encountered in a JSON object.</value>
</data>
<data name="ObjectDeserializer_StringNotQuoted" xml:space="preserve">
<value>An internal error has occurred. JSON string not properly quoted.</value>
</data>
<data name="ObjectDeserializer_UnexpectedToken" xml:space="preserve">
<value>Unexpected character encountered in JSON. Expected '{1}', got '{0}'.</value>
</data>
<data name="ObjectDeserializer_UnterminatedString" xml:space="preserve">
<value>Unterminated JSON string encountered. JSON strings must start with a single or double quote character and end with the same character.</value>
</data>
<data name="XmlObjectAssignedToIncompatibleInterface" xml:space="preserve">
<value>'{0}' is an XML type and cannot be serialized when assigned to an interface type that does not implement IXmlSerializable ('{1}'.)</value>
</data>
@@ -909,19 +826,7 @@
<data name="JsonUnsupportedForIsReference" xml:space="preserve">
<value>The type '{0}' cannot be serialized to JSON because its IsReference setting is '{1}'. The JSON format does not support references because there is no standardized format for representing references. To enable serialization, disable the IsReference setting on the type or an appropriate parent class of the type.</value>
</data>
<data name="JsonCircularReferenceDetected" xml:space="preserve">
<value>A circular reference has been detected when serializing an object of type {0} to JSON. Circular references are not supported in the JSON format.</value>
</data>
<data name="PartialTrustDataContractMemberGetNotPublic" xml:space="preserve">
<value>The data contract type '{0}' cannot be serialized because the member '{1}' is not public. Making the member public will fix this error. Alternatively, you can make it internal, and use the InternalsVisibleToAttribute attribute on your assembly in order to enable serialization of internal members - see documentation for more details. Be aware that doing so has certain security implications.</value>
</data>
<data name="PartialTrustDataContractMemberSetNotPublic" xml:space="preserve">
<value>The data contract type '{0}' cannot be deserialized because the member '{1}' is not public. Making the member public will fix this error. Alternatively, you can make it internal, and use the InternalsVisibleToAttribute attribute on your assembly in order to enable serialization of internal members - see documentation for more details. Be aware that doing so has certain security implications.</value>
</data>
<data name="UnknownDataContract" xml:space="preserve">
<value>Unknown data contract: '{0}'.</value>
</data>
<data name="SerializationCodeIsMissingForType" xml:space="preserve">
<data name="SerializationCodeIsMissingForType" xml:space="preserve">
<value>Type '{0}' cannot be serialized, serialization code for the type is missing. Consult the SDK documentation for adding it as a root serialization type.</value>
</data>
<data name="InvalidXmlDeserializingExtensionData" xml:space="preserve">
@@ -930,9 +835,6 @@
<data name="InvalidStateInExtensionDataReader" xml:space="preserve">
<value>An internal error has occurred. ExtensionDataReader is in an invalid state.</value>
</data>
<data name="InvalidDataNode" xml:space="preserve">
<value>'{0}' is an invalid data node when deserializing extension data.</value>
</data>
<data name="JsonTypeNotSupportedByDataContractJsonSerializer" xml:space="preserve">
<value>DataContractJsonSerializer does not support objects of type '{0}'.</value>
</data>
@@ -1030,7 +932,7 @@
<value>WriteStartElement can be called at only the start of a document or immediately after calling WriteEndElement.</value>
</data>
<data name="JsonOnlyWhitespace" xml:space="preserve">
<value>Unexpected character '{0}'. '{1}' can write only white space characters.</value>
<value>Unexpected character '{0}'. '{1}' can write only whitespace characters.</value>
</data>
<data name="JsonWriterClosed" xml:space="preserve">
<value>The writer is closed.</value>
@@ -1098,9 +1000,6 @@
<data name="UnknownXmlType" xml:space="preserve">
<value>Type '{0}' is not a valid XML type.</value>
</data>
<data name="TypeNotSerializableViaReflection" xml:space="preserve">
<value>Cannot serialize type {0} via reflection. Required type metadata was missing.</value>
</data>
<data name="DupContractInDataContractSet" xml:space="preserve">
<value>DataContract with name '{0}' and namespace '{1}' cannot be added to DataContractSet since another contract with the same data contract name is already present and the contracts are not equivalent.</value>
</data>
@@ -1161,9 +1060,6 @@
<data name="SerializationInfo_ConstructorNotFound" xml:space="preserve">
<value>The constructor with parameters (SerializationInfo, StreamingContext) is not found in ISerializable type '{0}'.</value>
</data>
<data name="PartialTrustISerializableNoPublicConstructor" xml:space="preserve">
<value>The ISerializable type '{0}' cannot be deserialized in partial trust because it does not have a public constructor with parameters (SerializationInfo, StreamingContext).</value>
</data>
<data name="ChangingFullTypeNameNotSupported" xml:space="preserve">
<value>DataContractJsonSerializer does not support the setting of the FullTypeName of the object to be serialized to a value other than the default FullTypeName. Attempted to serialize object with full type name '{0}' and default full type name '{1}'.</value>
</data>

View File

@@ -11,21 +11,22 @@
<DebugSymbols>true</DebugSymbols>
<PlatformTarget>AnyCPU</PlatformTarget>
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION</DefineConstants>
<DefineConstants Condition="'$(TargetGroup)'=='uap101aot'">$(DefineConstants);NET_NATIVE</DefineConstants>
<DefineConstants Condition="'$(TargetGroup)' == 'uapaot'">$(DefineConstants);uapaot</DefineConstants>
<!-- We do not want to block reflection for this assembly -->
<BlockReflectionAttribute Condition="'$(TargetGroup)'=='uap101aot'">false</BlockReflectionAttribute>
<BlockReflectionAttribute Condition="'$(TargetGroup)'=='uapaot'">false</BlockReflectionAttribute>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uapaot-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uapaot-Windows_NT-Release|AnyCPU'" />
<PropertyGroup>
<RuntimeSerializationSources>System\Runtime\Serialization</RuntimeSerializationSources>
<JsonSources>System\Runtime\Serialization\Json</JsonSources>
<XmlSources>System\Xml</XmlSources>
<TextSources>System\Text</TextSources>
<NetNative>$(DefineConstants.Contains('NET_NATIVE'))</NetNative>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(CommonPath)\System\HResults.cs">
@@ -52,7 +53,7 @@
<Compile Include="$(RuntimeSerializationSources)\Globals.cs" />
<Compile Include="$(RuntimeSerializationSources)\GenericParameterDataContract.cs" />
<Compile Include="$(RuntimeSerializationSources)\HybridObjectCache.cs" />
<Compile Include="$(RuntimeSerializationSources)\InvalidDataContract.cs" Condition="$(NetNative)" />
<Compile Include="$(RuntimeSerializationSources)\InvalidDataContract.cs" Condition="'$(TargetGroup)' == 'uapaot'" />
<Compile Include="$(RuntimeSerializationSources)\ObjectToIdCache.cs" />
<Compile Include="$(RuntimeSerializationSources)\ObjectReferenceStack.cs" />
<Compile Include="$(RuntimeSerializationSources)\PrimitiveDataContract.cs" />
@@ -76,7 +77,7 @@
<Compile Include="$(RuntimeSerializationSources)\KnownTypeDataContractResolver.cs" />
<Compile Include="$(RuntimeSerializationSources)\XmlObjectSerializerReadContextComplex.cs" />
<Compile Include="$(RuntimeSerializationSources)\XmlObjectSerializerWriteContextComplex.cs" />
<Compile Include="$(RuntimeSerializationSources)\BitFlagsGenerator.cs" Condition="!$(NetNative)" />
<Compile Include="$(RuntimeSerializationSources)\BitFlagsGenerator.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
<Compile Include="$(RuntimeSerializationSources)\DataContractSurrogateCaller.cs" />
<Compile Include="$(RuntimeSerializationSources)\DataContractSerializerExtensions.cs" />
<Compile Include="$(RuntimeSerializationSources)\XmlSerializableServices.cs" />
@@ -141,7 +142,7 @@
<Compile Include="$(JsonSources)\IXmlJsonWriterInitializer.cs" />
<Compile Include="$(JsonSources)\ByteArrayHelperWithString.cs" />
<Compile Include="$(JsonSources)\JsonEncodingStreamWrapper.cs" />
<Compile Include="$(JsonSources)\JsonFormatGeneratorStatics.cs" Condition="!$(NetNative)" />
<Compile Include="$(JsonSources)\JsonFormatGeneratorStatics.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
<Compile Include="System\Runtime\Serialization\AccessorBuilder.cs" />
<Compile Include="$(CommonPath)\System\CodeDom\CodeTypeReference.cs" />
<Compile Include="$(CommonPath)\System\CodeDom\CodeTypeReferenceCollection.cs" />
@@ -161,8 +162,7 @@
<Compile Include="System\Runtime\Serialization\XsdDataContractExporter.cs" />
<Compile Include="System\Xml\IFragmentCapableXmlDictionaryWriter.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='uap101aot'">
<TargetingPackReference Include="System.Private.CoreLib.Augments" />
<ItemGroup Condition="'$(TargetGroup)'=='uapaot'">
<EmbeddedResource Include="$(MsBuildThisFileDirectory)Resources\$(AssemblyName).rd.xml" />
</ItemGroup>
<ItemGroup>

View File

@@ -92,7 +92,7 @@ namespace System.Runtime.Serialization
private static Getter CreateGetterInternal<DeclaringType, PropertyType>(PropertyInfo propInfo)
{
if (typeof(DeclaringType).GetTypeInfo().IsGenericType && typeof(DeclaringType).GetGenericTypeDefinition() == typeof(KeyValue<,>))
if (typeof(DeclaringType).IsGenericType && typeof(DeclaringType).GetGenericTypeDefinition() == typeof(KeyValue<,>))
{
if (propInfo.Name == "Key")
{
@@ -110,7 +110,7 @@ namespace System.Runtime.Serialization
}
}
if (typeof(DeclaringType).GetTypeInfo().IsValueType)
if (typeof(DeclaringType).IsValueType)
{
var getMethod = propInfo.GetMethod.CreateDelegate<StructGetDelegate<DeclaringType, PropertyType>>();
@@ -133,7 +133,7 @@ namespace System.Runtime.Serialization
private static Setter CreateSetterInternal<DeclaringType, PropertyType>(PropertyInfo propInfo)
{
if(typeof(DeclaringType).GetTypeInfo().IsGenericType && typeof(DeclaringType).GetGenericTypeDefinition() == typeof(KeyValue<,>))
if(typeof(DeclaringType).IsGenericType && typeof(DeclaringType).GetGenericTypeDefinition() == typeof(KeyValue<,>))
{
if(propInfo.Name == "Key")
{
@@ -151,7 +151,7 @@ namespace System.Runtime.Serialization
}
}
if (typeof(DeclaringType).GetTypeInfo().IsValueType)
if (typeof(DeclaringType).IsValueType)
{
var setMethod = propInfo.SetMethod.CreateDelegate<StructSetDelegate<DeclaringType, PropertyType>>();

View File

@@ -18,7 +18,7 @@ namespace System.Runtime.Serialization
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, DataContract>;
using System.Linq;
#if USE_REFEMIT || NET_NATIVE
#if USE_REFEMIT || uapaot
public sealed class ClassDataContract : DataContract
#else
internal sealed class ClassDataContract : DataContract
@@ -36,7 +36,7 @@ namespace System.Runtime.Serialization
private bool _isScriptObject;
#if NET_NATIVE
#if uapaot
public ClassDataContract() : base(new ClassDataContractCriticalHelper())
{
InitClassDataContract();
@@ -129,7 +129,7 @@ namespace System.Runtime.Serialization
get { return _helper.ExtensionDataSetMethod; }
}
#if !NET_NATIVE
#if !uapaot
public override DataContractDictionary KnownDataContracts
{
get
@@ -149,7 +149,7 @@ namespace System.Runtime.Serialization
{ return _helper.IsNonAttributedType; }
}
#if NET_NATIVE
#if uapaot
public bool HasDataContract
{
get
@@ -242,7 +242,7 @@ namespace System.Runtime.Serialization
return true;
}
#if NET_NATIVE
#if uapaot
private XmlFormatClassWriterDelegate _xmlFormatWriterDelegate;
public XmlFormatClassWriterDelegate XmlFormatWriterDelegate
#else
@@ -251,7 +251,7 @@ namespace System.Runtime.Serialization
{
get
{
#if NET_NATIVE
#if uapaot
if (DataContractSerializer.Option == SerializationOption.CodeGenOnly
|| (DataContractSerializer.Option == SerializationOption.ReflectionAsBackup && _xmlFormatWriterDelegate != null))
{
@@ -274,13 +274,13 @@ namespace System.Runtime.Serialization
}
set
{
#if NET_NATIVE
#if uapaot
_xmlFormatWriterDelegate = value;
#endif
}
}
#if NET_NATIVE
#if uapaot
private XmlFormatClassReaderDelegate _xmlFormatReaderDelegate;
public XmlFormatClassReaderDelegate XmlFormatReaderDelegate
#else
@@ -289,7 +289,7 @@ namespace System.Runtime.Serialization
{
get
{
#if NET_NATIVE
#if uapaot
if (DataContractSerializer.Option == SerializationOption.CodeGenOnly
|| (DataContractSerializer.Option == SerializationOption.ReflectionAsBackup && _xmlFormatReaderDelegate != null))
{
@@ -312,7 +312,7 @@ namespace System.Runtime.Serialization
}
set
{
#if NET_NATIVE
#if uapaot
_xmlFormatReaderDelegate = value;
#endif
}
@@ -340,7 +340,7 @@ namespace System.Runtime.Serialization
{
Type declaringType = memberContract.MemberInfo.DeclaringType;
DataContract.ThrowInvalidDataContractException(
SR.Format((declaringType.GetTypeInfo().IsEnum ? SR.DupEnumMemberValue : SR.DupMemberName),
SR.Format((declaringType.IsEnum ? SR.DupEnumMemberValue : SR.DupMemberName),
existingMemberContract.MemberInfo.Name,
memberContract.MemberInfo.Name,
DataContract.GetClrTypeFullName(declaringType),
@@ -354,7 +354,7 @@ namespace System.Runtime.Serialization
internal static XmlDictionaryString GetChildNamespaceToDeclare(DataContract dataContract, Type childType, XmlDictionary dictionary)
{
childType = DataContract.UnwrapNullableType(childType);
if (!childType.GetTypeInfo().IsEnum && !Globals.TypeOfIXmlSerializable.IsAssignableFrom(childType)
if (!childType.IsEnum && !Globals.TypeOfIXmlSerializable.IsAssignableFrom(childType)
&& DataContract.GetBuiltInDataContract(childType) == null && childType != Globals.TypeOfDBNull)
{
string ns = DataContract.GetStableName(childType).Namespace;
@@ -366,7 +366,7 @@ namespace System.Runtime.Serialization
private static bool IsArraySegment(Type t)
{
return t.GetTypeInfo().IsGenericType && (t.GetGenericTypeDefinition() == typeof(ArraySegment<>));
return t.IsGenericType && (t.GetGenericTypeDefinition() == typeof(ArraySegment<>));
}
/// <SecurityNote>
@@ -381,7 +381,7 @@ namespace System.Runtime.Serialization
if (type.IsArray)
return false;
if (type.GetTypeInfo().IsEnum)
if (type.IsEnum)
return false;
if (type.IsGenericParameter)
@@ -393,7 +393,7 @@ namespace System.Runtime.Serialization
if (type.IsPointer)
return false;
if (type.GetTypeInfo().IsDefined(Globals.TypeOfCollectionDataContractAttribute, false))
if (type.IsDefined(Globals.TypeOfCollectionDataContractAttribute, false))
return false;
Type[] interfaceTypes = type.GetInterfaces();
@@ -413,15 +413,15 @@ namespace System.Runtime.Serialization
if (Globals.TypeOfISerializable.IsAssignableFrom(type))
return false;
if (type.GetTypeInfo().IsDefined(Globals.TypeOfDataContractAttribute, false))
if (type.IsDefined(Globals.TypeOfDataContractAttribute, false))
return false;
if (type.GetTypeInfo().IsValueType)
if (type.IsValueType)
{
return type.GetTypeInfo().IsVisible;
return type.IsVisible;
}
else
{
return (type.GetTypeInfo().IsVisible &&
return (type.IsVisible &&
type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, Array.Empty<Type>()) != null);
}
}
@@ -448,9 +448,8 @@ namespace System.Runtime.Serialization
private static string GetGeneralTypeName(Type type)
{
TypeInfo typeInfo = type.GetTypeInfo();
return typeInfo.IsGenericType && !typeInfo.IsGenericParameter
? typeInfo.GetGenericTypeDefinition().FullName
return type.IsGenericType && !type.IsGenericParameter
? type.GetGenericTypeDefinition().FullName
: type.FullName;
}
@@ -763,7 +762,7 @@ namespace System.Runtime.Serialization
EnsureMethodsImported();
return;
}
Type baseType = type.GetTypeInfo().BaseType;
Type baseType = type.BaseType;
_isISerializable = (Globals.TypeOfISerializable.IsAssignableFrom(type));
SetIsNonAttributedType(type);
if (_isISerializable)
@@ -774,7 +773,7 @@ namespace System.Runtime.Serialization
baseType = null;
}
SetKeyValuePairAdapterFlags(type);
this.IsValueType = type.GetTypeInfo().IsValueType;
this.IsValueType = type.IsValueType;
if (baseType != null && baseType != Globals.TypeOfObject && baseType != Globals.TypeOfValueType && baseType != Globals.TypeOfUri)
{
DataContract baseContract = DataContract.GetDataContract(baseType);
@@ -901,7 +900,7 @@ namespace System.Runtime.Serialization
isReference = dataContractAttribute.IsReference;
}
if (isReference && type.GetTypeInfo().IsValueType)
if (isReference && type.IsValueType)
{
DataContract.ThrowInvalidDataContractException(
SR.Format(SR.ValueTypeCannotHaveIsReference,
@@ -1096,7 +1095,7 @@ namespace System.Runtime.Serialization
private bool SetIfGetOnlyCollection(DataMember memberContract)
{
//OK to call IsCollection here since the use of surrogated collection types is not supported in get-only scenarios
if (CollectionDataContract.IsCollection(memberContract.MemberType, false /*isConstructorRequired*/) && !memberContract.MemberType.GetTypeInfo().IsValueType)
if (CollectionDataContract.IsCollection(memberContract.MemberType, false /*isConstructorRequired*/) && !memberContract.MemberType.IsValueType)
{
memberContract.IsGetOnlyCollection = true;
return true;
@@ -1362,7 +1361,7 @@ namespace System.Runtime.Serialization
internal bool HasDataContract
{
get { return _hasDataContract; }
#if NET_NATIVE
#if uapaot
set { _hasDataContract = value; }
#endif
}
@@ -1380,7 +1379,7 @@ namespace System.Runtime.Serialization
private void SetKeyValuePairAdapterFlags(Type type)
{
if (type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == Globals.TypeOfKeyValuePairAdapter)
if (type.IsGenericType && type.GetGenericTypeDefinition() == Globals.TypeOfKeyValuePairAdapter)
{
_isKeyValuePairAdapter = true;
_keyValuePairGenericArguments = type.GetGenericArguments();
@@ -1438,7 +1437,7 @@ namespace System.Runtime.Serialization
Type type = UnderlyingType;
if (type.GetTypeInfo().IsValueType)
if (type.IsValueType)
return null;
ConstructorInfo ctor = type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, Array.Empty<Type>());
@@ -1552,7 +1551,7 @@ namespace System.Runtime.Serialization
internal static DataMemberComparer Singleton = new DataMemberComparer();
}
#if !NET_NATIVE
#if !uapaot
/// <summary>
/// Get object type for Xml/JsonFormmatReaderGenerator
/// </summary>
@@ -1561,7 +1560,7 @@ namespace System.Runtime.Serialization
get
{
Type type = UnderlyingType;
if (type.GetTypeInfo().IsValueType && !IsNonAttributedType)
if (type.IsValueType && !IsNonAttributedType)
{
type = Globals.TypeOfValueType;
}

View File

@@ -13,7 +13,7 @@ using System.IO;
using System.Security;
using System.Diagnostics;
#if !NET_NATIVE
#if !uapaot
namespace System.Runtime.Serialization
{
internal class CodeGenerator
@@ -60,7 +60,7 @@ namespace System.Runtime.Serialization
}
}
#if !NET_NATIVE
#if !uapaot
private static MethodInfo s_objectToString;
private static MethodInfo ObjectToString
{
@@ -106,7 +106,7 @@ namespace System.Runtime.Serialization
{
if (s_serializationModule == null)
{
s_serializationModule = typeof(CodeGenerator).GetTypeInfo().Module; // could to be replaced by different dll that has SkipVerification set to false
s_serializationModule = typeof(CodeGenerator).Module; // could to be replaced by different dll that has SkipVerification set to false
}
return s_serializationModule;
}
@@ -124,7 +124,7 @@ namespace System.Runtime.Serialization
private enum CodeGenTrace { None, Save, Tron };
private CodeGenTrace _codeGenTrace;
#if !NET_NATIVE
#if !uapaot
private LocalBuilder _stringFormatArray;
#endif
@@ -373,7 +373,7 @@ namespace System.Runtime.Serialization
{
Type type = GetVariableType(value);
TypeCode typeCode = type.GetTypeCode();
if ((typeCode == TypeCode.Object && type.GetTypeInfo().IsValueType) ||
if ((typeCode == TypeCode.Object && type.IsValueType) ||
typeCode == TypeCode.DateTime || typeCode == TypeCode.Decimal)
{
LoadDefaultValue(type);
@@ -548,7 +548,7 @@ namespace System.Runtime.Serialization
internal void Call(MethodInfo methodInfo)
{
if (methodInfo.IsVirtual && !methodInfo.DeclaringType.GetTypeInfo().IsValueType)
if (methodInfo.IsVirtual && !methodInfo.DeclaringType.IsValueType)
{
if (_codeGenTrace != CodeGenTrace.None)
EmitSourceInstruction("Callvirt " + methodInfo.ToString() + " on type " + methodInfo.DeclaringType.ToString());
@@ -637,7 +637,7 @@ namespace System.Runtime.Serialization
private static bool IsStruct(Type objType)
{
return objType.GetTypeInfo().IsValueType && !objType.GetTypeInfo().IsPrimitive;
return objType.IsValueType && !objType.IsPrimitive;
}
internal Type LoadMember(MemberInfo memberInfo)
@@ -722,7 +722,7 @@ namespace System.Runtime.Serialization
internal void LoadDefaultValue(Type type)
{
if (type.GetTypeInfo().IsValueType)
if (type.IsValueType)
{
switch (type.GetTypeCode())
{
@@ -931,7 +931,7 @@ namespace System.Runtime.Serialization
Ldtoken((Type)o);
Call(GetTypeFromHandle);
}
else if (valueType.GetTypeInfo().IsEnum)
else if (valueType.IsEnum)
{
if (_codeGenTrace != CodeGenTrace.None)
EmitSourceComment("Ldc " + o.GetType() + "." + o);
@@ -1072,7 +1072,7 @@ namespace System.Runtime.Serialization
internal void LdlocAddress(LocalBuilder localBuilder)
{
if (localBuilder.LocalType.GetTypeInfo().IsValueType)
if (localBuilder.LocalType.IsValueType)
Ldloca(localBuilder);
else
Ldloc(localBuilder);
@@ -1105,7 +1105,7 @@ namespace System.Runtime.Serialization
internal void LdargAddress(ArgBuilder argBuilder)
{
if (argBuilder.ArgType.GetTypeInfo().IsValueType)
if (argBuilder.ArgType.IsValueType)
Ldarga(argBuilder);
else
Ldarg(argBuilder);
@@ -1222,7 +1222,7 @@ namespace System.Runtime.Serialization
internal void Ldelem(Type arrayElementType)
{
if (arrayElementType.GetTypeInfo().IsEnum)
if (arrayElementType.IsEnum)
{
Ldelem(Enum.GetUnderlyingType(arrayElementType));
}
@@ -1286,7 +1286,7 @@ namespace System.Runtime.Serialization
internal void Stelem(Type arrayElementType)
{
if (arrayElementType.GetTypeInfo().IsEnum)
if (arrayElementType.IsEnum)
Stelem(Enum.GetUnderlyingType(arrayElementType));
else
{
@@ -1462,9 +1462,9 @@ namespace System.Runtime.Serialization
{
if (target == source)
return;
if (target.GetTypeInfo().IsValueType)
if (target.IsValueType)
{
if (source.GetTypeInfo().IsValueType)
if (source.IsValueType)
{
OpCode opCode = GetConvOpCode(target.GetTypeCode());
if (opCode.Equals(OpCodes.Nop))
@@ -1487,7 +1487,7 @@ namespace System.Runtime.Serialization
}
else if (target.IsAssignableFrom(source))
{
if (source.GetTypeInfo().IsValueType)
if (source.IsValueType)
{
if (isAddress)
Ldobj(source);
@@ -1498,7 +1498,7 @@ namespace System.Runtime.Serialization
{
Castclass(target);
}
else if (target.GetTypeInfo().IsInterface || source.GetTypeInfo().IsInterface)
else if (target.IsInterface || source.IsInterface)
{
Castclass(target);
}
@@ -1620,7 +1620,7 @@ namespace System.Runtime.Serialization
If(Cmp.NotEqualTo);
}
#if !NET_NATIVE
#if !uapaot
internal void BeginWhileCondition()
{
Label startWhile = DefineLabel();
@@ -1660,7 +1660,7 @@ namespace System.Runtime.Serialization
{
if (type != Globals.TypeOfString)
{
if (type.GetTypeInfo().IsValueType)
if (type.IsValueType)
{
Box(type);
}

View File

@@ -109,7 +109,7 @@ namespace System.Runtime.Serialization
get { return _key; }
set { _key = (K)value; }
}
object IKeyValue.Value
{
get { return _value; }
@@ -117,7 +117,7 @@ namespace System.Runtime.Serialization
}
}
#if NET_NATIVE
#if uapaot
public enum CollectionKind : byte
#else
internal enum CollectionKind : byte
@@ -135,16 +135,16 @@ namespace System.Runtime.Serialization
Array,
}
#if USE_REFEMIT || NET_NATIVE
#if USE_REFEMIT || uapaot
public sealed class CollectionDataContract : DataContract
#else
internal sealed class CollectionDataContract : DataContract
#endif
{
private XmlDictionaryString _collectionItemName;
private XmlDictionaryString _childElementNamespace;
private DataContract _itemContract;
private CollectionDataContractCriticalHelper _helper;
@@ -330,7 +330,7 @@ namespace System.Runtime.Serialization
{ return _helper.InvalidCollectionInSharedContractMessage; }
}
#if NET_NATIVE
#if uapaot
private XmlFormatCollectionWriterDelegate _xmlFormatWriterDelegate;
public XmlFormatCollectionWriterDelegate XmlFormatWriterDelegate
#else
@@ -339,7 +339,7 @@ namespace System.Runtime.Serialization
{
get
{
#if NET_NATIVE
#if uapaot
if (DataContractSerializer.Option == SerializationOption.CodeGenOnly
|| (DataContractSerializer.Option == SerializationOption.ReflectionAsBackup && _xmlFormatWriterDelegate != null))
{
@@ -362,13 +362,13 @@ namespace System.Runtime.Serialization
}
set
{
#if NET_NATIVE
#if uapaot
_xmlFormatWriterDelegate = value;
#endif
}
}
#if NET_NATIVE
#if uapaot
private XmlFormatCollectionReaderDelegate _xmlFormatReaderDelegate;
public XmlFormatCollectionReaderDelegate XmlFormatReaderDelegate
#else
@@ -377,7 +377,7 @@ namespace System.Runtime.Serialization
{
get
{
#if NET_NATIVE
#if uapaot
if (DataContractSerializer.Option == SerializationOption.CodeGenOnly
|| (DataContractSerializer.Option == SerializationOption.ReflectionAsBackup && _xmlFormatReaderDelegate != null))
{
@@ -400,13 +400,13 @@ namespace System.Runtime.Serialization
}
set
{
#if NET_NATIVE
#if uapaot
_xmlFormatReaderDelegate = value;
#endif
}
}
#if NET_NATIVE
#if uapaot
private XmlFormatGetOnlyCollectionReaderDelegate _xmlFormatGetOnlyCollectionReaderDelegate;
public XmlFormatGetOnlyCollectionReaderDelegate XmlFormatGetOnlyCollectionReaderDelegate
#else
@@ -415,7 +415,7 @@ namespace System.Runtime.Serialization
{
get
{
#if NET_NATIVE
#if uapaot
if (DataContractSerializer.Option == SerializationOption.CodeGenOnly
|| (DataContractSerializer.Option == SerializationOption.ReflectionAsBackup && _xmlFormatGetOnlyCollectionReaderDelegate != null))
{
@@ -428,7 +428,7 @@ namespace System.Runtime.Serialization
{
if (_helper.XmlFormatGetOnlyCollectionReaderDelegate == null)
{
if (UnderlyingType.GetTypeInfo().IsInterface && (Kind == CollectionKind.Enumerable || Kind == CollectionKind.Collection || Kind == CollectionKind.GenericEnumerable))
if (UnderlyingType.IsInterface && (Kind == CollectionKind.Enumerable || Kind == CollectionKind.Collection || Kind == CollectionKind.GenericEnumerable))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.GetOnlyCollectionMustHaveAddMethod, GetClrTypeFullName(UnderlyingType))));
}
@@ -443,7 +443,7 @@ namespace System.Runtime.Serialization
}
set
{
#if NET_NATIVE
#if uapaot
_xmlFormatGetOnlyCollectionReaderDelegate = value;
#endif
}
@@ -581,7 +581,7 @@ namespace System.Runtime.Serialization
{
if (getEnumeratorMethod == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.CollectionMustHaveGetEnumeratorMethod, DataContract.GetClrTypeFullName(type))));
if (addMethod == null && !type.GetTypeInfo().IsInterface)
if (addMethod == null && !type.IsInterface)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.CollectionMustHaveAddMethod, DataContract.GetClrTypeFullName(type))));
if (itemType == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.CollectionMustHaveItemType, DataContract.GetClrTypeFullName(type))));
@@ -773,13 +773,13 @@ namespace System.Runtime.Serialization
case CollectionKind.GenericCollection:
case CollectionKind.GenericList:
{
var buildIncrementCollectionCountDelegate = s_buildIncrementCollectionCountDelegateMethod.MakeGenericMethod(ItemType);
var buildIncrementCollectionCountDelegate = BuildIncrementCollectionCountDelegateMethod.MakeGenericMethod(ItemType);
_incrementCollectionCountDelegate = (IncrementCollectionCountDelegate)buildIncrementCollectionCountDelegate.Invoke(null, Array.Empty<object>());
}
break;
case CollectionKind.GenericDictionary:
{
var buildIncrementCollectionCountDelegate = s_buildIncrementCollectionCountDelegateMethod.MakeGenericMethod(Globals.TypeOfKeyValuePair.MakeGenericType(ItemType.GetGenericArguments()));
var buildIncrementCollectionCountDelegate = BuildIncrementCollectionCountDelegateMethod.MakeGenericMethod(Globals.TypeOfKeyValuePair.MakeGenericType(ItemType.GetGenericArguments()));
_incrementCollectionCountDelegate = (IncrementCollectionCountDelegate)buildIncrementCollectionCountDelegate.Invoke(null, Array.Empty<object>());
}
break;
@@ -793,14 +793,27 @@ namespace System.Runtime.Serialization
_incrementCollectionCountDelegate(xmlWriter, obj, context);
}
private static MethodInfo s_buildIncrementCollectionCountDelegateMethod = typeof(CollectionDataContractCriticalHelper).GetMethod(nameof(BuildIncrementCollectionCountDelegate), Globals.ScanAllMembers);
private static MethodInfo s_buildIncrementCollectionCountDelegateMethod;
private static MethodInfo BuildIncrementCollectionCountDelegateMethod
{
get
{
if (s_buildIncrementCollectionCountDelegateMethod == null)
{
s_buildIncrementCollectionCountDelegateMethod = typeof(CollectionDataContractCriticalHelper).GetMethod(nameof(BuildIncrementCollectionCountDelegate), Globals.ScanAllMembers);
}
return s_buildIncrementCollectionCountDelegateMethod;
}
}
private static IncrementCollectionCountDelegate BuildIncrementCollectionCountDelegate<T>()
{
return (xmlwriter, obj, context) =>
{
context.IncrementCollectionCountGeneric<T>(xmlwriter, (ICollection<T>)obj);
};
}
@@ -816,11 +829,11 @@ namespace System.Runtime.Serialization
if (_createGenericDictionaryEnumeratorDelegate == null)
{
var keyValueTypes = ItemType.GetGenericArguments();
var buildCreateGenericDictionaryEnumerator = s_buildCreateGenericDictionaryEnumerator.MakeGenericMethod(keyValueTypes[0], keyValueTypes[1]);
var buildCreateGenericDictionaryEnumerator = BuildCreateGenericDictionaryEnumerato.MakeGenericMethod(keyValueTypes[0], keyValueTypes[1]);
_createGenericDictionaryEnumeratorDelegate = (CreateGenericDictionaryEnumeratorDelegate)buildCreateGenericDictionaryEnumerator.Invoke(null, Array.Empty<object>());
}
enumerator = _createGenericDictionaryEnumeratorDelegate(enumerator);
enumerator = _createGenericDictionaryEnumeratorDelegate(enumerator);
}
else if (Kind == CollectionKind.Dictionary)
{
@@ -864,7 +877,7 @@ namespace System.Runtime.Serialization
else
{
var enumeratorType = GetEnumeratorMethod.ReturnType;
if (enumeratorType.GetTypeInfo().IsGenericType)
if (enumeratorType.IsGenericType)
{
MethodInfo getCurrentMethod = enumeratorType.GetMethod(Globals.GetCurrentMethodName, BindingFlags.Instance | BindingFlags.Public, Array.Empty<Type>());
enumeratorReturnType = getCurrentMethod.ReturnType;
@@ -878,7 +891,21 @@ namespace System.Runtime.Serialization
return enumeratorReturnType;
}
private static MethodInfo s_buildCreateGenericDictionaryEnumerator = typeof(CollectionDataContractCriticalHelper).GetMethod(nameof(BuildCreateGenericDictionaryEnumerator), Globals.ScanAllMembers);
private static MethodInfo s_buildCreateGenericDictionaryEnumerator;
private static MethodInfo BuildCreateGenericDictionaryEnumerato
{
get
{
if (s_buildCreateGenericDictionaryEnumerator == null)
{
s_buildCreateGenericDictionaryEnumerator = typeof(CollectionDataContractCriticalHelper).GetMethod(nameof(BuildCreateGenericDictionaryEnumerator), Globals.ScanAllMembers);
}
return s_buildCreateGenericDictionaryEnumerator;
}
}
private static CreateGenericDictionaryEnumeratorDelegate BuildCreateGenericDictionaryEnumerator<K, V>()
{
return (enumerator) =>
@@ -890,11 +917,11 @@ namespace System.Runtime.Serialization
private DataContract GetSharedTypeContract(Type type)
{
if (type.GetTypeInfo().IsDefined(Globals.TypeOfCollectionDataContractAttribute, false))
if (type.IsDefined(Globals.TypeOfCollectionDataContractAttribute, false))
{
return this;
}
if (type.GetTypeInfo().IsDefined(Globals.TypeOfDataContractAttribute, false))
if (type.IsDefined(Globals.TypeOfDataContractAttribute, false))
{
return new ClassDataContract(type);
}
@@ -903,7 +930,7 @@ namespace System.Runtime.Serialization
internal static bool IsCollectionInterface(Type type)
{
if (type.GetTypeInfo().IsGenericType)
if (type.IsGenericType)
type = type.GetGenericTypeDefinition();
return ((IList<Type>)KnownInterfaces).Contains(type);
}
@@ -989,14 +1016,12 @@ namespace System.Runtime.Serialization
internal static MethodInfo GetTargetMethodWithName(string name, Type type, Type interfaceType)
{
Type t = type.GetInterfaces().Where(it => it.Equals(interfaceType)).FirstOrDefault();
if (t == null)
return null;
return t.GetMethod(name);
return t?.GetMethod(name);
}
private static bool IsArraySegment(Type t)
{
return t.GetTypeInfo().IsGenericType && (t.GetGenericTypeDefinition() == typeof(ArraySegment<>));
return t.IsGenericType && (t.GetGenericTypeDefinition() == typeof(ArraySegment<>));
}
private static bool IsCollectionOrTryCreate(Type type, bool tryCreate, out DataContract dataContract, out Type itemType, bool constructorRequired)
@@ -1011,11 +1036,11 @@ namespace System.Runtime.Serialization
}
MethodInfo addMethod, getEnumeratorMethod;
bool hasCollectionDataContract = IsCollectionDataContract(type);
Type baseType = type.GetTypeInfo().BaseType;
Type baseType = type.BaseType;
bool isBaseTypeCollection = (baseType != null && baseType != Globals.TypeOfObject
&& baseType != Globals.TypeOfValueType && baseType != Globals.TypeOfUri) ? IsCollection(baseType) : false;
if (type.GetTypeInfo().IsDefined(Globals.TypeOfDataContractAttribute, false))
if (type.IsDefined(Globals.TypeOfDataContractAttribute, false))
{
return HandleIfInvalidCollection(type, tryCreate, hasCollectionDataContract, isBaseTypeCollection,
SR.CollectionTypeCannotHaveDataContract, null, ref dataContract);
@@ -1031,16 +1056,16 @@ namespace System.Runtime.Serialization
return HandleIfInvalidCollection(type, tryCreate, hasCollectionDataContract, isBaseTypeCollection,
SR.CollectionTypeIsNotIEnumerable, null, ref dataContract);
}
if (type.GetTypeInfo().IsInterface)
if (type.IsInterface)
{
Type interfaceTypeToCheck = type.GetTypeInfo().IsGenericType ? type.GetGenericTypeDefinition() : type;
Type interfaceTypeToCheck = type.IsGenericType ? type.GetGenericTypeDefinition() : type;
Type[] knownInterfaces = KnownInterfaces;
for (int i = 0; i < knownInterfaces.Length; i++)
{
if (knownInterfaces[i] == interfaceTypeToCheck)
{
addMethod = null;
if (type.GetTypeInfo().IsGenericType)
if (type.IsGenericType)
{
Type[] genericArgs = type.GetGenericArguments();
if (interfaceTypeToCheck == Globals.TypeOfIDictionaryGeneric)
@@ -1090,7 +1115,7 @@ namespace System.Runtime.Serialization
}
}
ConstructorInfo defaultCtor = null;
if (!type.GetTypeInfo().IsValueType)
if (!type.IsValueType)
{
defaultCtor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Array.Empty<Type>());
if (defaultCtor == null && constructorRequired)
@@ -1106,7 +1131,7 @@ namespace System.Runtime.Serialization
Type[] interfaceTypes = type.GetInterfaces();
foreach (Type interfaceType in interfaceTypes)
{
Type interfaceTypeToCheck = interfaceType.GetTypeInfo().IsGenericType ? interfaceType.GetGenericTypeDefinition() : interfaceType;
Type interfaceTypeToCheck = interfaceType.IsGenericType ? interfaceType.GetGenericTypeDefinition() : interfaceType;
Type[] knownInterfaces = KnownInterfaces;
for (int i = 0; i < knownInterfaces.Length; i++)
{
@@ -1136,7 +1161,7 @@ namespace System.Runtime.Serialization
{
if (multipleDefinitions)
knownInterfaceType = Globals.TypeOfIEnumerable;
itemType = knownInterfaceType.GetTypeInfo().IsGenericType ? knownInterfaceType.GetGenericArguments()[0] : Globals.TypeOfObject;
itemType = knownInterfaceType.IsGenericType ? knownInterfaceType.GetGenericArguments()[0] : Globals.TypeOfObject;
GetCollectionMethods(type, knownInterfaceType, new Type[] { itemType },
false /*addMethodOnInterface*/,
out getEnumeratorMethod, out addMethod);
@@ -1160,7 +1185,7 @@ namespace System.Runtime.Serialization
{
case CollectionKind.GenericDictionary:
addMethodTypeArray = knownInterfaceType.GetGenericArguments();
bool isOpenGeneric = knownInterfaceType.GetTypeInfo().IsGenericTypeDefinition
bool isOpenGeneric = knownInterfaceType.IsGenericTypeDefinition
|| (addMethodTypeArray[0].IsGenericParameter && addMethodTypeArray[1].IsGenericParameter);
itemType = isOpenGeneric ? Globals.TypeOfKeyValue : Globals.TypeOfKeyValue.MakeGenericType(addMethodTypeArray);
break;
@@ -1198,7 +1223,7 @@ namespace System.Runtime.Serialization
internal static bool IsCollectionDataContract(Type type)
{
return type.GetTypeInfo().IsDefined(Globals.TypeOfCollectionDataContractAttribute, false);
return type.IsDefined(Globals.TypeOfCollectionDataContractAttribute, false);
}
private static bool HandleIfInvalidCollection(Type type, bool tryCreate, bool hasCollectionDataContract, bool createContractWithException, string message, string param, ref DataContract dataContract)
@@ -1285,7 +1310,7 @@ namespace System.Runtime.Serialization
private static bool IsKnownInterface(Type type)
{
Type typeToCheck = type.GetTypeInfo().IsGenericType ? type.GetGenericTypeDefinition() : type;
Type typeToCheck = type.IsGenericType ? type.GetGenericTypeDefinition() : type;
foreach (Type knownInterfaceType in KnownInterfaces)
{
if (typeToCheck == knownInterfaceType)
@@ -1440,7 +1465,7 @@ namespace System.Runtime.Serialization
{
// IsGetOnlyCollection value has already been used to create current collectiondatacontract, value can now be reset.
context.IsGetOnlyCollection = false;
#if NET_NATIVE
#if uapaot
if (XmlFormatGetOnlyCollectionReaderDelegate == null)
{
throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, UnderlyingType.ToString()));

View File

@@ -1 +1 @@
1e3ef7e2698265c8509ca37af00ed0cdc28ee70c
cabcd377a64462c95dfe88419af95a281abe71a6

View File

@@ -36,7 +36,7 @@ namespace System.Runtime.Serialization
private static SerializationOption _option = SerializationOption.ReflectionAsBackup;
private static bool _optionAlreadySet;
public static SerializationOption Option
internal static SerializationOption Option
{
get { return _option; }
set
@@ -83,7 +83,7 @@ namespace System.Runtime.Serialization
Initialize(type, rootName, rootNamespace, knownTypes, int.MaxValue, false, false, null, false);
}
#if NET_NATIVE
#if uapaot
public DataContractSerializer(Type type, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences)
#else
internal DataContractSerializer(Type type, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences)
@@ -390,7 +390,7 @@ namespace System.Runtime.Serialization
internal static DataContract GetDataContract(DataContract declaredTypeContract, Type declaredType, Type objectType)
{
if (declaredType.GetTypeInfo().IsInterface && CollectionDataContract.IsCollectionInterface(declaredType))
if (declaredType.IsInterface && CollectionDataContract.IsCollectionInterface(declaredType))
{
return declaredTypeContract;
}
@@ -425,7 +425,7 @@ namespace System.Runtime.Serialization
if (dataContractResolver == null)
dataContractResolver = this.DataContractResolver;
#if NET_NATIVE
#if uapaot
// Give the root contract a chance to initialize or pre-verify the read
RootContract.PrepareToRead(xmlReader);
#endif

View File

@@ -13,7 +13,7 @@ using System.Security;
namespace System.Runtime.Serialization
{
#if NET_NATIVE
#if uapaot
public class DataMember
#else
internal class DataMember

View File

@@ -16,7 +16,7 @@ using System.Linq;
namespace System.Runtime.Serialization
{
#if NET_NATIVE
#if uapaot
public sealed class EnumDataContract : DataContract
#else
internal sealed class EnumDataContract : DataContract
@@ -118,7 +118,7 @@ namespace System.Runtime.Serialization
this.StableName = DataContract.GetStableName(type, out _hasDataContract);
Type baseType = Enum.GetUnderlyingType(type);
ImportBaseType(baseType);
IsFlags = type.GetTypeInfo().IsDefined(Globals.TypeOfFlagsAttribute, false);
IsFlags = type.IsDefined(Globals.TypeOfFlagsAttribute, false);
ImportDataMembers();
XmlDictionary dictionary = new XmlDictionary(2 + Members.Count);

View File

@@ -13,7 +13,7 @@ namespace System.Runtime.Serialization
{
private IList<ExtensionDataMember> _members;
#if USE_REFEMIT
#if USE_REFEMIT || uapaot
public ExtensionDataObject()
#else
internal ExtensionDataObject()
@@ -21,7 +21,7 @@ namespace System.Runtime.Serialization
{
}
#if USE_REFEMIT
#if USE_REFEMIT || uapaot
public IList<ExtensionDataMember> Members
#else
internal IList<ExtensionDataMember> Members
@@ -32,7 +32,7 @@ namespace System.Runtime.Serialization
}
}
#if USE_REFEMIT
#if USE_REFEMIT || uapaot
public class ExtensionDataMember
#else
internal class ExtensionDataMember
@@ -67,7 +67,7 @@ namespace System.Runtime.Serialization
}
}
#if USE_REFEMIT
#if USE_REFEMIT || uapaot
public interface IDataNode
#else
internal interface IDataNode

View File

@@ -530,7 +530,7 @@ namespace System.Runtime.Serialization
}
}
#if USE_REFEMIT
#if USE_REFEMIT || uapaot
public class AttributeData
#else
internal class AttributeData
@@ -542,7 +542,7 @@ namespace System.Runtime.Serialization
public string value;
}
#if USE_REFEMIT
#if USE_REFEMIT || uapaot
public class ElementData
#else
internal class ElementData

View File

@@ -519,7 +519,7 @@ namespace System.Runtime.Serialization
private static Type s_typeOfXmlDataNode;
internal static Type TypeOfXmlDataNode => s_typeOfXmlDataNode ?? (s_typeOfXmlDataNode = typeof (XmlDataNode));
#if NET_NATIVE
#if uapaot
private static Type s_typeOfSafeSerializationManager;
private static bool s_typeOfSafeSerializationManagerSet;
internal static Type TypeOfSafeSerializationManager
@@ -528,7 +528,7 @@ namespace System.Runtime.Serialization
{
if (!s_typeOfSafeSerializationManagerSet)
{
s_typeOfSafeSerializationManager = TypeOfInt.GetTypeInfo().Assembly.GetType("System.Runtime.Serialization.SafeSerializationManager");
s_typeOfSafeSerializationManager = TypeOfInt.Assembly.GetType("System.Runtime.Serialization.SafeSerializationManager");
s_typeOfSafeSerializationManagerSet = true;
}
return s_typeOfSafeSerializationManager;

View File

@@ -42,9 +42,9 @@ namespace System.Runtime.Serialization
_referencedObjectDictionary = new Dictionary<string, object>();
_referencedObjectDictionary.Add(id, null);
}
else if (!_referencedObjectDictionary.ContainsKey(id))
else
{
_referencedObjectDictionary.Add(id, null);
_referencedObjectDictionary.TryAdd(id, null);
}
if (_objectDictionary != null)

View File

@@ -944,9 +944,9 @@ namespace System.Runtime.Serialization.Json
Type typeToCheck = knownType;
while (CollectionDataContract.IsCollection(typeToCheck, out itemType))
{
if (itemType.GetTypeInfo().IsGenericType && (itemType.GetGenericTypeDefinition() == Globals.TypeOfKeyValue))
if (itemType.IsGenericType && (itemType.GetGenericTypeDefinition() == Globals.TypeOfKeyValue))
{
itemType = Globals.TypeOfKeyValuePair.MakeGenericType(itemType.GetTypeInfo().GenericTypeArguments);
itemType = Globals.TypeOfKeyValuePair.MakeGenericType(itemType.GenericTypeArguments);
}
this.knownTypeList.Add(itemType);
typeToCheck = itemType;

View File

@@ -34,19 +34,19 @@ namespace System.Runtime.Serialization.Json
{
tempDelegate = new ReflectionJsonClassReader(TraditionalClassDataContract).ReflectionReadClass;
}
#if NET_NATIVE
#if uapaot
else if (DataContractSerializer.Option == SerializationOption.ReflectionAsBackup)
{
tempDelegate = JsonDataContract.TryGetReadWriteDelegatesFromGeneratedAssembly(TraditionalClassDataContract).ClassReaderDelegate;
tempDelegate = JsonDataContract.TryGetReadWriteDelegatesFromGeneratedAssembly(TraditionalClassDataContract)?.ClassReaderDelegate;
tempDelegate = tempDelegate ?? new ReflectionJsonClassReader(TraditionalClassDataContract).ReflectionReadClass;
if (tempDelegate == null)
throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalClassDataContract.UnderlyingType.ToString()));
}
#endif
else
else
{
#if NET_NATIVE
#if uapaot
tempDelegate = JsonDataContract.GetReadWriteDelegatesFromGeneratedAssembly(TraditionalClassDataContract).ClassReaderDelegate;
#else
tempDelegate = new JsonFormatReaderGenerator().GenerateClassReader(TraditionalClassDataContract);
@@ -77,7 +77,7 @@ namespace System.Runtime.Serialization.Json
{
tempDelegate = new ReflectionJsonFormatWriter().ReflectionWriteClass;
}
#if NET_NATIVE
#if uapaot
else if (DataContractSerializer.Option == SerializationOption.ReflectionAsBackup)
{
tempDelegate = JsonDataContract.TryGetReadWriteDelegatesFromGeneratedAssembly(TraditionalClassDataContract)?.ClassWriterDelegate;
@@ -89,7 +89,7 @@ namespace System.Runtime.Serialization.Json
#endif
else
{
#if NET_NATIVE
#if uapaot
tempDelegate = JsonDataContract.GetReadWriteDelegatesFromGeneratedAssembly(TraditionalClassDataContract).ClassWriterDelegate;
#else
tempDelegate = new JsonFormatWriterGenerator().GenerateClassWriter(TraditionalClassDataContract);

View File

@@ -33,10 +33,10 @@ namespace System.Runtime.Serialization.Json
{
tempDelegate = new ReflectionJsonCollectionReader().ReflectionReadCollection;
}
#if NET_NATIVE
#if uapaot
else if (DataContractSerializer.Option == SerializationOption.ReflectionAsBackup)
{
tempDelegate = JsonDataContract.TryGetReadWriteDelegatesFromGeneratedAssembly(TraditionalCollectionDataContract).CollectionReaderDelegate;
tempDelegate = JsonDataContract.TryGetReadWriteDelegatesFromGeneratedAssembly(TraditionalCollectionDataContract)?.CollectionReaderDelegate;
tempDelegate = tempDelegate ?? new ReflectionJsonCollectionReader().ReflectionReadCollection;
if (tempDelegate == null)
@@ -45,7 +45,7 @@ namespace System.Runtime.Serialization.Json
#endif
else
{
#if NET_NATIVE
#if uapaot
tempDelegate = JsonDataContract.GetReadWriteDelegatesFromGeneratedAssembly(TraditionalCollectionDataContract).CollectionReaderDelegate;
#else
tempDelegate = new JsonFormatReaderGenerator().GenerateCollectionReader(TraditionalCollectionDataContract);
@@ -72,7 +72,7 @@ namespace System.Runtime.Serialization.Json
if (_helper.JsonFormatGetOnlyReaderDelegate == null)
{
CollectionKind kind = this.TraditionalCollectionDataContract.Kind;
if (this.TraditionalDataContract.UnderlyingType.GetTypeInfo().IsInterface && (kind == CollectionKind.Enumerable || kind == CollectionKind.Collection || kind == CollectionKind.GenericEnumerable))
if (this.TraditionalDataContract.UnderlyingType.IsInterface && (kind == CollectionKind.Enumerable || kind == CollectionKind.Collection || kind == CollectionKind.GenericEnumerable))
{
throw new InvalidDataContractException(SR.Format(SR.GetOnlyCollectionMustHaveAddMethod, DataContract.GetClrTypeFullName(this.TraditionalDataContract.UnderlyingType)));
}
@@ -82,10 +82,10 @@ namespace System.Runtime.Serialization.Json
{
tempDelegate = new ReflectionJsonCollectionReader().ReflectionReadGetOnlyCollection;
}
#if NET_NATIVE
#if uapaot
else if (DataContractSerializer.Option == SerializationOption.ReflectionAsBackup)
{
tempDelegate = JsonDataContract.TryGetReadWriteDelegatesFromGeneratedAssembly(TraditionalCollectionDataContract).GetOnlyCollectionReaderDelegate;
tempDelegate = JsonDataContract.TryGetReadWriteDelegatesFromGeneratedAssembly(TraditionalCollectionDataContract)?.GetOnlyCollectionReaderDelegate;
tempDelegate = tempDelegate ?? new ReflectionJsonCollectionReader().ReflectionReadGetOnlyCollection;
if (tempDelegate == null)
@@ -94,7 +94,7 @@ namespace System.Runtime.Serialization.Json
#endif
else
{
#if NET_NATIVE
#if uapaot
tempDelegate = JsonDataContract.GetReadWriteDelegatesFromGeneratedAssembly(TraditionalCollectionDataContract).GetOnlyCollectionReaderDelegate;
#else
tempDelegate = new JsonFormatReaderGenerator().GenerateGetOnlyCollectionReader(TraditionalCollectionDataContract);
@@ -125,10 +125,10 @@ namespace System.Runtime.Serialization.Json
{
tempDelegate = new ReflectionJsonFormatWriter().ReflectionWriteCollection;
}
#if NET_NATIVE
#if uapaot
else if (DataContractSerializer.Option == SerializationOption.ReflectionAsBackup)
{
tempDelegate = JsonDataContract.TryGetReadWriteDelegatesFromGeneratedAssembly(TraditionalCollectionDataContract).CollectionWriterDelegate;
tempDelegate = JsonDataContract.TryGetReadWriteDelegatesFromGeneratedAssembly(TraditionalCollectionDataContract)?.CollectionWriterDelegate;
tempDelegate = tempDelegate ?? new ReflectionJsonFormatWriter().ReflectionWriteCollection;
if (tempDelegate == null)
@@ -137,7 +137,7 @@ namespace System.Runtime.Serialization.Json
#endif
else
{
#if NET_NATIVE
#if uapaot
tempDelegate = JsonDataContract.GetReadWriteDelegatesFromGeneratedAssembly(TraditionalCollectionDataContract).CollectionWriterDelegate;
#else
tempDelegate = new JsonFormatWriterGenerator().GenerateCollectionWriter(TraditionalCollectionDataContract);

Some files were not shown because too many files have changed in this diff Show More