Add NO_DYNAMIC_CODEGEN condition. We will be based on (non-emit) reflection.
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 1 Apr 2015 09:06:47 +0000 (18:06 +0900)
committerMarek Safar <marek.safar@gmail.com>
Mon, 2 May 2016 22:10:08 +0000 (00:10 +0200)
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/BitFlagsGenerator.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Json/JsonFormatReaderGenerator.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Json/JsonFormatWriterGenerator.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlDataContract.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatReaderGenerator.cs
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatWriterGenerator.cs

index eaf19ef1282cc7a53384897e88fd8b6516c43a81..b90990a07f30852cf55b636ae5672bcd6463b8c7 100644 (file)
@@ -9,6 +9,7 @@ namespace System.Runtime.Serialization
     using System.Reflection.Emit;
     using System.Security;
 
+#if !NO_DYNAMIC_CODEGEN
     [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview (Critical) - works on CodeGenerator objects, which require Critical access.")]
     class BitFlagsGenerator
     {
@@ -112,5 +113,6 @@ namespace System.Runtime.Serialization
         }
 
     }
+#endif
 }
 
index da94edf99cd2abe33adc4a51fbe41cf96eedbea5..56fe4302995a2b551c7d08365256b212388de5c0 100644 (file)
@@ -6,7 +6,9 @@ namespace System.Runtime.Serialization.Json
     using System;
     using System.Collections.Generic;
     using System.Reflection;
+#if !NO_DYNAMIC_CODEGEN
     using System.Reflection.Emit;
+#endif
     using System.Runtime;
     using System.Runtime.Serialization.Diagnostics.Application;
     using System.Security;
@@ -17,7 +19,7 @@ namespace System.Runtime.Serialization.Json
     delegate object JsonFormatCollectionReaderDelegate(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContextComplexJson context, XmlDictionaryString emptyDictionaryString, XmlDictionaryString itemName, CollectionDataContract collectionContract);
     delegate void JsonFormatGetOnlyCollectionReaderDelegate(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContextComplexJson context, XmlDictionaryString emptyDictionaryString, XmlDictionaryString itemName, CollectionDataContract collectionContract);
 
-    sealed class JsonFormatReaderGenerator
+    sealed partial class JsonFormatReaderGenerator
     {
         [Fx.Tag.SecurityNote(Critical = "Holds instance of CriticalHelper which keeps state that was produced within an assert.")]
         [SecurityCritical]
@@ -102,10 +104,11 @@ namespace System.Runtime.Serialization.Json
             }
         }
 
+#if !NO_DYNAMIC_CODEGEN
         [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - handles all aspects of IL generation including initializing the DynamicMethod."
             + "Changes to how IL generated could affect how data is deserialized and what gets access to data, "
             + "therefore we mark it for review so that changes to generation logic are reviewed.")]
-        class CriticalHelper
+        partial class CriticalHelper
         {
             CodeGenerator ilg;
             LocalBuilder objectLocal;
@@ -1106,6 +1109,7 @@ namespace System.Runtime.Serialization.Json
                 UsingCustomParse
             }
         }
+#endif
     }
 }
 
index 56183c8b246f4d1428b8b540891eae53322b4d9a..a8498cb3deb638931f62fc0fc6a13a9eb58fae6e 100644 (file)
@@ -4,7 +4,9 @@ namespace System.Runtime.Serialization.Json
     using System;
     using System.Collections;
     using System.Reflection;
+#if !NO_DYNAMIC_CODEGEN
     using System.Reflection.Emit;
+#endif
     using System.Runtime.Serialization.Diagnostics.Application;
     using System.Security;
     using System.Security.Permissions;
@@ -13,7 +15,7 @@ namespace System.Runtime.Serialization.Json
     delegate void JsonFormatClassWriterDelegate(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, ClassDataContract dataContract, XmlDictionaryString[] memberNames);
     delegate void JsonFormatCollectionWriterDelegate(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, CollectionDataContract dataContract);
 
-    class JsonFormatWriterGenerator
+    partial class JsonFormatWriterGenerator
     {
         [Fx.Tag.SecurityNote(Critical = "Holds instance of CriticalHelper which keeps state that was produced within an assert.")]
         [SecurityCritical]
@@ -70,10 +72,11 @@ namespace System.Runtime.Serialization.Json
             }
         }
 
+#if !NO_DYNAMIC_CODEGEN
         [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - handles all aspects of IL generation including initializing the DynamicMethod."
             + "Changes to how IL generated could affect how data is deserialized and what gets access to data, "
             + "therefore we mark it for review so that changes to generation logic are reviewed.")]
-        class CriticalHelper
+        partial class CriticalHelper
         {
             CodeGenerator ilg;
             ArgBuilder xmlWriterArg;
@@ -800,5 +803,6 @@ namespace System.Runtime.Serialization.Json
                 ilg.Call(xmlWriterArg, JsonFormatGeneratorStatics.WriteEndElementMethod);
             }
         }
+#endif
     }
 }
index 9bf77bfd4349f97eaf6eb39b5532714336e5c063..143c56b78ad21b2688a294f0d617411405fd3e8e 100644 (file)
@@ -18,7 +18,7 @@ namespace System.Runtime.Serialization
 #if USE_REFEMIT
     public sealed class XmlDataContract : DataContract
 #else
-    internal sealed class XmlDataContract : DataContract
+    internal sealed partial class XmlDataContract : DataContract
 #endif
     {
         [Fx.Tag.SecurityNote(Critical = "Holds instance of CriticalHelper which keeps state that is cached statically for serialization."
@@ -334,6 +334,7 @@ namespace System.Runtime.Serialization
             }
         }
 
+#if !NO_DYNAMIC_CODEGEN
         [Fx.Tag.SecurityNote(Critical = "Calls CodeGenerator.BeginMethod which is SecurityCritical.",
             Safe = "Self-contained: returns the delegate to the generated IL but otherwise all IL generation is self-contained here.")]
         [SecuritySafeCritical]
@@ -372,6 +373,7 @@ namespace System.Runtime.Serialization
             ilg.Ret();
             return (CreateXmlSerializableDelegate)ilg.EndMethod();
         }
+#endif
 
         [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - Calculates whether this Xml type requires MemberAccessPermission for deserialization."
             + " Since this information is used to determine whether to give the generated code access"
index 2474c813c7268d6c912e1abdafbcc254db3568bf..76014506f0eb8d5d4cc0cf1284ab84ec860b916e 100644 (file)
@@ -6,7 +6,9 @@ namespace System.Runtime.Serialization
     using System;
     using System.Collections.Generic;
     using System.Reflection;
+#if !NO_DYNAMIC_CODEGEN
     using System.Reflection.Emit;
+#endif
     using System.Runtime.Serialization.Diagnostics.Application;
     using System.Security;
     using System.Security.Permissions;
@@ -23,7 +25,7 @@ namespace System.Runtime.Serialization
     internal delegate object XmlFormatCollectionReaderDelegate(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context, XmlDictionaryString itemName, XmlDictionaryString itemNamespace, CollectionDataContract collectionContract);
     internal delegate void XmlFormatGetOnlyCollectionReaderDelegate(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context, XmlDictionaryString itemName, XmlDictionaryString itemNamespace, CollectionDataContract collectionContract);
 
-    internal sealed class XmlFormatReaderGenerator
+    internal sealed partial class XmlFormatReaderGenerator
 #endif
     {
         [Fx.Tag.SecurityNote(Critical = "Holds instance of CriticalHelper which keeps state that was produced within an assert.")]
@@ -103,10 +105,11 @@ namespace System.Runtime.Serialization
             }
         }
 
+#if !NO_DYNAMIC_CODEGEN
         [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - Handles all aspects of IL generation including initializing the DynamicMethod."
             + " Changes to how IL generated could affect how data is deserialized and what gets access to data,"
             + " therefore we mark it for review so that changes to generation logic are reviewed.")]
-        class CriticalHelper
+        partial class CriticalHelper
         {
             CodeGenerator ilg;
             LocalBuilder objectLocal;
@@ -226,7 +229,7 @@ namespace System.Runtime.Serialization
                 DemandMemberAccessPermission(memberAccessFlag);
                 collectionContractArg = ilg.GetArg(4);
                 return ilg;
-            }
+             }
 
             void InitArgs()
             {
@@ -945,6 +948,7 @@ namespace System.Runtime.Serialization
             }
 
         }
+#endif
 
         [Fx.Tag.SecurityNote(Critical = "Elevates by calling GetUninitializedObject which has a LinkDemand.",
             Safe = "Marked as such so that it's callable from transparent generated IL. Takes id as parameter which "
index 0fe5d5ecd1c717659a4da2c9c52dcd8fbf3ffcc0..bbb69d3f53cf897409995fec37ff2e2005e135da 100644 (file)
@@ -7,7 +7,9 @@ namespace System.Runtime.Serialization
     using System.Collections;
     using System.Collections.Generic;
     using System.Reflection;
+#if !NO_DYNAMIC_CODEGEN
     using System.Reflection.Emit;
+#endif
     using System.Security;
     using System.Security.Permissions;
     using System.Runtime.Serialization.Diagnostics.Application;
@@ -22,7 +24,7 @@ namespace System.Runtime.Serialization
     internal delegate void XmlFormatClassWriterDelegate(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context, ClassDataContract dataContract);
     internal delegate void XmlFormatCollectionWriterDelegate(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context, CollectionDataContract dataContract);
 
-    internal sealed class XmlFormatWriterGenerator
+    internal sealed partial class XmlFormatWriterGenerator
 #endif
     {
         [Fx.Tag.SecurityNote(Critical = "Holds instance of CriticalHelper which keeps state that was produced within an assert.")]
@@ -81,10 +83,11 @@ namespace System.Runtime.Serialization
             }
         }
 
+#if !NO_DYNAMIC_CODEGEN
         [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - Handles all aspects of IL generation including initializing the DynamicMethod."
             + " Changes to how IL generated could affect how data is serialized and what gets access to data,"
             + " therefore we mark it for review so that changes to generation logic are reviewed.")]
-        class CriticalHelper
+        partial class CriticalHelper
         {
             CodeGenerator ilg;
             ArgBuilder xmlWriterArg;
@@ -837,8 +840,8 @@ namespace System.Runtime.Serialization
             return prefix;
         }
 #endif
-
         }
+#endif
     }
 }