Merge pull request #321 from RAOF/aot-cpu-safety
[mono.git] / mcs / class / corlib / System.Reflection.Emit / UnmanagedMarshal.cs
index d0cff0903a44ad2b0331b69ac1e3062cfa6f2c2d..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,19 +105,18 @@ 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;
                        res.marshaltyperef = typeref;
                        if (id == Guid.Empty)
-                               res.guid = "";
+                               res.guid = String.Empty;
                        else
                                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);