// 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;
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 ()
{
versioncompat = AssemblyVersionCompatibility.SameMachine;
}
-#if NET_2_0 || BOOTSTRAP_NET_2_0
[MethodImpl (MethodImplOptions.InternalCall)]
static extern bool ParseName (AssemblyName aname, string assemblyName);
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;
processor_architecture = value;
}
}
-#endif
internal AssemblyName (SerializationInfo si, StreamingContext sc)
{
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 ());
fname.Append (pub_tok[i].ToString ("x2"));
}
}
+
+ if ((Flags & AssemblyNameFlags.Retargetable) != 0)
+ fname.Append (", Retargetable=Yes");
+
return fname.ToString ();
}
}
else if (publicKey == null)
return null;
else {
-#if NET_2_0
if (publicKey.Length == 0)
return new byte [0];
keyToken = ComputePublicKeyToken ();
return keyToken;
-#else
- if (publicKey.Length == 0)
- return null;
-
- keyToken = ComputePublicKeyToken ();
- return keyToken;
-#endif
}
}
private byte [] InternalGetPublicKeyToken ()
{
-#if NET_2_0
if (keyToken != null)
return keyToken;
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 ()
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;
}
return aname;
}
-#if NET_1_1
void _AssemblyName.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException ();
{
throw new NotImplementedException ();
}
-#endif
}
}