Add mobile build support in System.Runtime.Serialization.
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 30 Mar 2015 18:19:46 +0000 (03:19 +0900)
committerMarek Safar <marek.safar@gmail.com>
Mon, 2 May 2016 22:10:08 +0000 (00:10 +0200)
20 files changed:
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/AppSettings.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/ClassDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/CollectionDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/DataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSet.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/DataMember.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/EnumDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/GenericParameterDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/IDataContractSurrogate.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Json/JsonClassDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Json/JsonCollectionDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Json/JsonDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Json/JsonEnumDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/NetDataContractSerializer.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/PrimitiveDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/SpecialTypeDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/SurrogateDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerReadContextComplex.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableServices.cs

index 62fea4ddb0a70d18cf0e43689caada2fe73cbd45..8bcaf1ce6438061d2d8cf00079dc19efa7ba35dc 100644 (file)
@@ -39,6 +39,7 @@ namespace System.Runtime.Serialization
                     if (!settingsInitalized)
                     {
                         NameValueCollection appSettingsSection = null;
+#if !NO_CONFIGURATION
                         try
                         {
                             appSettingsSection = ConfigurationManager.AppSettings;
@@ -48,13 +49,16 @@ namespace System.Runtime.Serialization
                         }
                         finally
                         {
+#endif
                             if ((appSettingsSection == null) || !int.TryParse(appSettingsSection[MaxMimePartsAppSettingsString], out maxMimeParts))
                             {
                                 maxMimeParts = DefaultMaxMimeParts;
                             }
 
                             settingsInitalized = true;
+#if !NO_CONFIGURATION
                         }
+#endif
                     }
                 }
             }
index ef6fae6b46b9e3630d1a89e20c7a827748b6afe9..4c4b2d33106deeffea0550c27c5007fa9379f9fb 100644 (file)
@@ -41,12 +41,16 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "XmlDictionaryString representing the XML namespaces for members of class."
             + "Statically cached and used from IL generated code.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical]
+#endif
         XmlDictionaryString[] childElementNamespaces;
 
         [Fx.Tag.SecurityNote(Critical = "Holds instance of CriticalHelper which keeps state that is cached statically for serialization. "
             + "Static fields are marked SecurityCritical or readonly to prevent data from being modified or leaked to other components in appdomain.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical]
+#endif
         ClassDataContractCriticalHelper helper;
 
         [Fx.Tag.SecurityNote(Critical = "Initializes SecurityCritical field 'helper'",
@@ -60,7 +64,9 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "Initializes SecurityCritical field 'helper'",
             Safe = "Doesn't leak anything.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecuritySafeCritical]
+#endif
         internal ClassDataContract(Type type)
             : base(new ClassDataContractCriticalHelper(type))
         {
@@ -69,7 +75,9 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "Initializes SecurityCritical field 'helper'",
             Safe = "Doesn't leak anything.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecuritySafeCritical]
+#endif
         ClassDataContract(Type type, XmlDictionaryString ns, string[] memberNames)
             : base(new ClassDataContractCriticalHelper(type, ns, memberNames))
         {
@@ -77,7 +85,9 @@ namespace System.Runtime.Serialization
         }
 
         [Fx.Tag.SecurityNote(Critical = "Initializes SecurityCritical fields; called from all constructors.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical]
+#endif
         void InitClassDataContract()
         {
             this.helper = base.Helper as ClassDataContractCriticalHelper;
@@ -656,7 +666,9 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for (de)serializing classes."
             + " Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical(SecurityCriticalScope.Everything)]
+#endif
         class ClassDataContractCriticalHelper : DataContract.DataContractCriticalHelper
         {
             ClassDataContract baseContract;
index 440aa4dee1faa71e50fa9a3c862f0b4578ee3c51..3867dd5554dfc02beee6ac2df90e3a7191aadd41 100644 (file)
@@ -12,7 +12,9 @@ namespace System.Runtime.Serialization
     using System.Reflection;
     using System.Threading;
     using System.Xml;
+#if !NO_CONFIGURATION
     using System.Runtime.Serialization.Configuration;
+#endif
     using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, DataContract>;
     using System.Security;
     using System.Security.Permissions;
@@ -473,7 +475,9 @@ namespace System.Runtime.Serialization
         }
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for (de)serializing collections. Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical(SecurityCriticalScope.Everything)]
+#endif
         class CollectionDataContractCriticalHelper : DataContract.DataContractCriticalHelper
         {
             static Type[] _knownInterfaces;
index 119197239d535e7888f701cb6cd034205b1ec6e6..7752e536027acb1f872ba15b7c186e02b72a807e 100644 (file)
@@ -11,7 +11,9 @@ namespace System.Runtime.Serialization
     using System.Globalization;
     using System.Reflection;
     using System.Runtime.CompilerServices;
+#if !NO_CONFIGURATION
     using System.Runtime.Serialization.Configuration;
+#endif
     using System.Runtime.Serialization.Diagnostics.Application;
     using System.Security;
     using System.Text;
@@ -388,7 +390,9 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for (de)serializing types."
             + " Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical(SecurityCriticalScope.Everything)]
+#endif
 #if USE_REFEMIT
         public class DataContractCriticalHelper
 #else
@@ -1980,6 +1984,7 @@ namespace System.Runtime.Serialization
             ThrowInvalidDataContractException(SR.GetString(SR.TypeNotSerializable, type), type);
         }
 
+#if !NO_CONFIGURATION
         [Fx.Tag.SecurityNote(Critical = "configSection value is fetched under an elevation; need to protected access to it.")]
         [SecurityCritical]
         static DataContractSerializerSection configSection;
@@ -1995,6 +2000,7 @@ namespace System.Runtime.Serialization
                 return configSection;
             }
         }
+#endif
 
         internal static DataContractDictionary ImportKnownTypeAttributes(Type type)
         {
@@ -2095,6 +2101,7 @@ namespace System.Runtime.Serialization
         [SecuritySafeCritical]
         static void LoadKnownTypesFromConfig(Type type, Dictionary<Type, Type> typesChecked, ref DataContractDictionary knownDataContracts)
         {
+#if !NO_CONFIGURATION
             // Pull known types from config
             if (ConfigSection != null)
             {
@@ -2138,6 +2145,7 @@ namespace System.Runtime.Serialization
                     }
                 }
             }
+#endif
         }
 
         private static void CheckRootTypeInConfigIsGeneric(Type type, ref Type rootType, ref Type[] genArgs)
index b3d0bdc1df2cecd843d8c99710cc08b7c7579347..7c541c25dd70a78b5d4fb8102c36b13a24c8a8c8 100644 (file)
@@ -339,6 +339,7 @@ namespace System.Runtime.Serialization
             ProcessedContracts.Add(dataContract, dataContract);
         }
 
+#if !NO_CODEDOM
         internal ContractCodeDomInfo GetContractCodeDomInfo(DataContract dataContract)
         {
             object info;
@@ -351,6 +352,7 @@ namespace System.Runtime.Serialization
         {
             ProcessedContracts.Add(dataContract, info);
         }
+#endif
         Dictionary<XmlQualifiedName, object> GetReferencedTypes()
         {
             if (referencedTypesDictionary == null)
index a578cd95748c0cf5d43d0d1b92e45af61b474fa9..fa8ba1c2a75c4ccc1d12036a9e178ef20ef82348 100644 (file)
@@ -132,7 +132,9 @@ namespace System.Runtime.Serialization
         }
 
         [Fx.Tag.SecurityNote(Critical = "Critical.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical(SecurityCriticalScope.Everything)]
+#endif
         class CriticalHelper
         {
             DataContract memberTypeContract;
index 15a9ec83a4f830064847675324ad4476c3d57084..f9c411fdf4d2bd0d94e0020f769c799c18617ea7 100644 (file)
@@ -130,7 +130,9 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for (de)serializing enums."
             + " Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical(SecurityCriticalScope.Everything)]
+#endif
         class EnumDataContractCriticalHelper : DataContract.DataContractCriticalHelper
         {
             static Dictionary<Type, XmlQualifiedName> typeToName;
index 577d807dabd38d3e99550d55102e91a422b50077..04092e10f5fbd68a00d827bb52069032222caa24 100644 (file)
@@ -41,7 +41,9 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "Holds state used for deaing with generic parameters."
             + " Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical(SecurityCriticalScope.Everything)]
+#endif
         class GenericParameterDataContractCriticalHelper : DataContract.DataContractCriticalHelper
         {
             int parameterPosition;
index d2213d5acaacbd569fc976a9b7fdb8454a740295..6063e911271b64a59e7e9f016f86d7f14748a972 100644 (file)
@@ -17,7 +17,9 @@ namespace System.Runtime.Serialization
         object GetCustomDataToExport(Type clrType, Type dataContractType);
         void GetKnownCustomDataTypes(Collection<Type> customDataTypes);
         Type GetReferencedTypeOnImport(string typeName, string typeNamespace, object customData);
+#if !NO_CODEDOM
         CodeTypeDeclaration ProcessImportedType(CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit);
+#endif
     }
 
     static class DataContractSurrogateCaller
@@ -68,9 +70,11 @@ namespace System.Runtime.Serialization
                 return null;
             return surrogate.GetReferencedTypeOnImport(typeName, typeNamespace, customData);
         }
+#if !NO_CODEDOM
         internal static CodeTypeDeclaration ProcessImportedType(IDataContractSurrogate surrogate, CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit)
         {
             return surrogate.ProcessImportedType(typeDeclaration, compileUnit);
         }
+#endif
     }
 }
index 2beb3cc7530e64ca958f43a405cecaa15b2724ed..5441be39a0336e2806ac3277fca4c8b516b0225e 100644 (file)
@@ -118,9 +118,11 @@ namespace System.Runtime.Serialization.Json
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for (de)serializing types."
             + "Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
 #pragma warning disable 618 // have not moved to the v4 security model yet
         [SecurityCritical(SecurityCriticalScope.Everything)]
 #pragma warning restore 618
+#endif
         class JsonClassDataContractCriticalHelper : JsonDataContractCriticalHelper
         {
             JsonFormatClassReaderDelegate jsonFormatReaderDelegate;
index 21116d77788677c28fc6cb919d47592fbdda9d71..a4104ec667ee0af7239e058ecd2d0b431cec973f 100644 (file)
@@ -141,9 +141,11 @@ namespace System.Runtime.Serialization.Json
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for (de)serializing types."
             + "Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
 #pragma warning disable 618 // have not moved to the v4 security model yet
         [SecurityCritical(SecurityCriticalScope.Everything)]
 #pragma warning restore 618
+#endif
         class JsonCollectionDataContractCriticalHelper : JsonDataContractCriticalHelper
         {
             JsonFormatCollectionReaderDelegate jsonFormatReaderDelegate;
index deafc369234a1c6805ef9620159a3bb4acf0d11d..c595fce0624e9d7e8d7aeb7bb4b3501d92cb1d04 100644 (file)
@@ -138,9 +138,11 @@ namespace System.Runtime.Serialization.Json
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for (de)serializing types."
             + "Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
 #pragma warning disable 618 // have not moved to the v4 security model yet
         [SecurityCritical(SecurityCriticalScope.Everything)]
 #pragma warning restore 618
+#endif
 #if USE_REFEMIT
         public class JsonDataContractCriticalHelper
 #else
index a615c338810126a098797887244e2d0b8d37b467..b198979c4ba9ddb3f2e2bde7c546e06f53268b8d 100644 (file)
@@ -64,9 +64,11 @@ namespace System.Runtime.Serialization.Json
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for (de)serializing types."
             + "Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
 #pragma warning disable 618 // have not moved to the v4 security model yet
         [SecurityCritical(SecurityCriticalScope.Everything)]
 #pragma warning restore 618
+#endif
         class JsonEnumDataContractCriticalHelper : JsonDataContractCriticalHelper
         {
             bool isULong;
index 068f8206fe32dae0d91a4ba70430b71e45e9762e..c375eea4fe94f88c60058ee5c6de3018066c67b4 100644 (file)
@@ -13,7 +13,9 @@ namespace System.Runtime.Serialization
     using System.Runtime.CompilerServices;
     using System.Runtime.Serialization.Formatters;
     using System.Collections.Generic;
+#if !NO_CONFIGURATION
     using System.Runtime.Serialization.Configuration;
+#endif
     using System.Reflection;
 
     public sealed class NetDataContractSerializer : XmlObjectSerializer, IFormatter
@@ -115,6 +117,9 @@ namespace System.Runtime.Serialization
             {
                 if (unsafeTypeForwardingEnabled == null)
                 {
+#if NO_CONFIGURATION
+                    unsafeTypeForwardingEnabled = false;
+#else
                     NetDataContractSerializerSection section;
                     if (NetDataContractSerializerSection.TryUnsafeGetSection(out section))
                     {
@@ -124,6 +129,7 @@ namespace System.Runtime.Serialization
                     {
                         unsafeTypeForwardingEnabled = false;
                     }
+#endif
                 }
                 Fx.Assert(unsafeTypeForwardingEnabled != null, "unsafeTypeForwardingEnabled should not be null.");
                 return unsafeTypeForwardingEnabled.Value;
index 1ac90a8862152dca01cb26e254811f33fafa8cff..e7a7cbd1b3b6e301182af0d9c51313a26812876c 100644 (file)
@@ -158,7 +158,9 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for for (de)serializing primitives."
             + " Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical(SecurityCriticalScope.Everything)]
+#endif
         class PrimitiveDataContractCriticalHelper : DataContract.DataContractCriticalHelper
         {
             MethodInfo xmlFormatWriterMethod;
index 116d5f2596d32371ce7c1b22634b3e98194b4a39..0a2ba03db3e87dd9a21602ccebae4f0a8769baa0 100644 (file)
@@ -45,7 +45,9 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for for (de)serializing known types like System.Enum, System.ValueType, etc."
             + " Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical(SecurityCriticalScope.Everything)]
+#endif
         class SpecialTypeDataContractCriticalHelper : DataContract.DataContractCriticalHelper
         {
             internal SpecialTypeDataContractCriticalHelper(Type type)
index df79978f00d5895eb5c4fe56702c33849238d564..8c154bf0cd403f05ed4cb493fd86f6ecf3327083 100644 (file)
@@ -101,7 +101,9 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for for (de)serializing with ISerializationSurrogate."
             + " Since it accesses data on the base type that is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical(SecurityCriticalScope.Everything)]
+#endif
         class SurrogateDataContractCriticalHelper : DataContract.DataContractCriticalHelper
         {
             ISerializationSurrogate serializationSurrogate;
index eb4fef4a1cc4a361b10d2f29133628b2e6d2f2cf..9bf77bfd4349f97eaf6eb39b5532714336e5c063 100644 (file)
@@ -174,7 +174,9 @@ namespace System.Runtime.Serialization
 
         [Fx.Tag.SecurityNote(Critical = "Holds all state used for for (de)serializing XML types."
             + " Since the data is cached statically, we lock down access to it.")]
+#if !NO_SECURITY_ATTRIBUTES
         [SecurityCritical(SecurityCriticalScope.Everything)]
+#endif
         class XmlDataContractCriticalHelper : DataContract.DataContractCriticalHelper
         {
             DataContractDictionary knownDataContracts;
index a934c235da787273b57f43d1cec70c18a4a8045e..4479f5055aba66d5e37e3434466d28420ba557a8 100644 (file)
@@ -416,6 +416,7 @@ namespace System.Runtime.Serialization
         {
             if (sourceAssembly != destinationAssembly && !NetDataContractSerializer.UnsafeTypeForwardingEnabled && !sourceAssembly.IsFullyTrusted)
             {
+#if !NO_DESKTOP_SECURITY
                 // We have a TypeForwardedTo attribute
                 if (!destinationAssembly.PermissionSet.IsSubsetOf(sourceAssembly.PermissionSet))
                 {
@@ -438,6 +439,7 @@ namespace System.Runtime.Serialization
                     }
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.CannotDeserializeForwardedType, DataContract.GetClrTypeFullName(resolvedType))));
                 }
+#endif
             }
         }
 
index bf5a3cb3e525bf43470435effd249ac53d7dc5e7..c36cb152e95807dc20cc19a6a001a1b7c2cc8802 100644 (file)
@@ -67,6 +67,7 @@ namespace System.Runtime.Serialization
                         nodes[i].WriteTo(xmlWriter);
         }
 
+#if !MOBILE
         internal static string AddDefaultSchemaMethodName = "AddDefaultSchema";
         public static void AddDefaultSchema(XmlSchemaSet schemas, XmlQualifiedName typeQName)
         {
@@ -76,5 +77,6 @@ namespace System.Runtime.Serialization
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeQName");
             SchemaExporter.AddDefaultXmlType(schemas, typeQName.Name, typeQName.Namespace);
         }
+#endif
     }
 }