Add all missing sequential layout directives to corlib and system.
[mono.git] / mcs / class / corlib / System.Reflection / AssemblyName.cs
index d37d0d12c1262041c08e51dde9f28536ab229d5c..8e96227d2d292eda1c4e7a36b07fac64f2699cf3 100644 (file)
@@ -49,14 +49,14 @@ namespace System.Reflection {
 // a.  Uniform Resource Identifiers (URI): Generic Syntax
 //     http://www.ietf.org/rfc/rfc2396.txt
 
-#if NET_2_0
        [ComVisible (true)]
        [ComDefaultInterfaceAttribute (typeof (_AssemblyName))]
-#endif
        [Serializable]
        [ClassInterfaceAttribute (ClassInterfaceType.None)]
+       [StructLayout (LayoutKind.Sequential)]
        public sealed class AssemblyName  : ICloneable, ISerializable, IDeserializationCallback, _AssemblyName {
 
+#pragma warning disable 169
                #region Synch with object-internals.h
                string name;
                string codebase;
@@ -69,12 +69,9 @@ namespace System.Reflection {
                byte[] keyToken;
                AssemblyVersionCompatibility versioncompat;
                Version version;
-#if NET_2_0
                ProcessorArchitecture processor_architecture = ProcessorArchitecture.None;
-#else
-               int processor_architecture;
-#endif
                #endregion
+#pragma warning restore 169            
                
                public AssemblyName ()
                {
@@ -82,7 +79,6 @@ namespace System.Reflection {
                        versioncompat = AssemblyVersionCompatibility.SameMachine;
                }
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
                [MethodImpl (MethodImplOptions.InternalCall)]
                static extern bool ParseName (AssemblyName aname, string assemblyName);
                
@@ -92,14 +88,12 @@ namespace System.Reflection {
                                throw new ArgumentNullException ("assemblyName");
                        if (assemblyName.Length < 1)
                                throw new ArgumentException ("assemblyName cannot have zero length.");
-                       
+                               
                        if (!ParseName (this, assemblyName))
                                throw new FileLoadException ("The assembly name is invalid.");
                }
-#endif
                
-#if NET_2_0
-               [MonoTODO ("Not used, as the values are too limited;  Mono supports more")]
+               [MonoLimitation ("Not used, as the values are too limited;  Mono supports more")]
                public ProcessorArchitecture ProcessorArchitecture {
                        get {
                                return processor_architecture;
@@ -108,7 +102,6 @@ namespace System.Reflection {
                                processor_architecture = value;
                        }
                }
-#endif
 
                internal AssemblyName (SerializationInfo si, StreamingContext sc)
                {
@@ -156,13 +149,12 @@ namespace System.Reflection {
                public string FullName {
                        get {
                                if (name == null)
-#if NET_2_0
                                        return string.Empty;
-#else
-                                       return null;
-#endif
                                StringBuilder fname = new StringBuilder ();
-                               fname.Append (name);
+                               if (Char.IsWhiteSpace (name [0]))
+                                       fname.Append ("\"" + name + "\"");
+                               else
+                                       fname.Append (name);
                                if (Version != null) {
                                        fname.Append (", Version=");
                                        fname.Append (Version.ToString ());
@@ -184,6 +176,10 @@ namespace System.Reflection {
                                                        fname.Append (pub_tok[i].ToString ("x2"));
                                        }
                                }
+
+                               if ((Flags & AssemblyNameFlags.Retargetable) != 0)
+                                       fname.Append (", Retargetable=Yes");
+
                                return fname.ToString ();
                        }
                }
@@ -239,7 +235,6 @@ namespace System.Reflection {
                        else if (publicKey == null)
                                return null;
                        else {
-#if NET_2_0
                                if (publicKey.Length == 0)
                                        return new byte [0];
 
@@ -248,13 +243,6 @@ namespace System.Reflection {
 
                                keyToken = ComputePublicKeyToken ();
                                return keyToken;
-#else
-                               if (publicKey.Length == 0)
-                                       return null;
-
-                               keyToken = ComputePublicKeyToken ();
-                               return keyToken;
-#endif
                        }
                }
 
@@ -298,7 +286,6 @@ namespace System.Reflection {
 
                private byte [] InternalGetPublicKeyToken ()
                {
-#if NET_2_0
                        if (keyToken != null)
                                return keyToken;
 
@@ -312,29 +299,6 @@ namespace System.Reflection {
                                throw new  SecurityException ("The public key is not valid.");
 
                        return ComputePublicKeyToken ();
-#else
-                       if ((Flags & AssemblyNameFlags.PublicKey) != 0) {
-                               if (publicKey == null)
-                                       return null;
-                               if (publicKey.Length == 0)
-                                       return new byte [0];
-                       }
-
-                       if (keyToken != null && publicKey == null)
-                               return keyToken;
-
-                       if (publicKey == null)
-                               return null;
-
-                       if (publicKey.Length == 0)
-                               return new byte [0];
-
-                       if (keyToken != null && keyToken.Length == 0)
-                               return ComputePublicKeyToken ();
-
-                       keyToken = ComputePublicKeyToken ();
-                       return keyToken;
-#endif
                }
 
                private byte [] ComputePublicKeyToken ()
@@ -348,24 +312,24 @@ namespace System.Reflection {
                        return token;
                }
 
-#if NET_2_0
                [MonoTODO]
                public static bool ReferenceMatchesDefinition (AssemblyName reference, AssemblyName definition)
                {
+                       if (reference == null)
+                               throw new ArgumentNullException ("reference");
+                       if (definition == null)
+                               throw new ArgumentNullException ("definition");
+                       if (reference.Name != definition.Name)
+                               return false;
                        throw new NotImplementedException ();
                }
-#endif
 
                public void SetPublicKey (byte[] publicKey) 
                {
-#if NET_2_0
                        if (publicKey == null)
                                flags ^= AssemblyNameFlags.PublicKey;
                        else
                                flags |= AssemblyNameFlags.PublicKey;
-#else
-                       flags |= AssemblyNameFlags.PublicKey;
-#endif
                        this.publicKey = publicKey;
                }
 
@@ -429,7 +393,6 @@ namespace System.Reflection {
                        return aname;
                }
 
-#if NET_1_1
                void _AssemblyName.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
                {
                        throw new NotImplementedException ();
@@ -450,6 +413,5 @@ namespace System.Reflection {
                {
                        throw new NotImplementedException ();
                }
-#endif
        }
 }