Merge pull request #321 from RAOF/aot-cpu-safety
[mono.git] / mcs / class / corlib / System.Reflection.Emit / UnmanagedMarshal.cs
index d5145053adc79f1e9202b1141495332df3099e00..b9ed853e90204e18fb718ece95dd540b415df86f 100644 (file)
@@ -37,12 +37,12 @@ using System;
 
 namespace System.Reflection.Emit {
 
-#if NET_2_0
        [Obsolete ("An alternate API is available: Emit the MarshalAs custom attribute instead.")]
        [ComVisible (true)]
-#endif
        [Serializable]
+       [StructLayout (LayoutKind.Sequential)]
        public sealed class UnmanagedMarshal {
+#pragma warning disable 169, 414
                private int count;
                private UnmanagedType t;
                private UnmanagedType tbase;
@@ -52,6 +52,7 @@ namespace System.Reflection.Emit {
                Type marshaltyperef;
                private int param_num;
                private bool has_size;
+#pragma warning restore 169, 414
                
                private UnmanagedMarshal (UnmanagedType maint, int cnt) {
                        count = cnt;
@@ -104,8 +105,7 @@ namespace System.Reflection.Emit {
                        return new UnmanagedMarshal (unmanagedType, unmanagedType);
                }
 
-               /* this one is missing from the MS implementation */
-               public static UnmanagedMarshal DefineCustom (Type typeref, string cookie, string mtype, Guid id) {
+               internal static UnmanagedMarshal DefineCustom (Type typeref, string cookie, string mtype, Guid id) {
                        UnmanagedMarshal res = new UnmanagedMarshal (UnmanagedType.CustomMarshaler, UnmanagedType.CustomMarshaler);
                        res.mcookie = cookie;
                        res.marshaltype = mtype;
@@ -116,7 +116,7 @@ namespace System.Reflection.Emit {
                                res.guid = id.ToString ();
                        return res;
                }
-
+               
                // sizeConst and sizeParamIndex can be -1 meaning they are not specified
                internal static UnmanagedMarshal DefineLPArrayInternal (UnmanagedType elemType, int sizeConst, int sizeParamIndex) {
                        UnmanagedMarshal res = new UnmanagedMarshal (UnmanagedType.LPArray, elemType);