Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>2018-08-08 03:02:31 +0300
committerGitHub <noreply@github.com>2018-08-08 03:02:31 +0300
commite76ee238ad4ad320887ce710ede0f26093d4a05c (patch)
tree8569acad7c39da9f0618197f2b5567b3974366c3 /src
parent914360af01f97f5b49c104c5a0b38ea879849d9f (diff)
ReNaming and rearranging the variables to reduce the diff (#6188)
* rearranging properties and reducing diff * ecplicit files added
Diffstat (limited to 'src')
-rw-r--r--src/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs214
1 files changed, 136 insertions, 78 deletions
diff --git a/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs b/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs
index 3dadda396..34b2fbcc3 100644
--- a/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs
+++ b/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs
@@ -6,16 +6,27 @@ using System.Globalization;
using System.Runtime.Serialization;
using System.Configuration.Assemblies;
-using Internal.Reflection.Augments;
-
namespace System.Reflection
{
public sealed class AssemblyName : ICloneable, IDeserializationCallback, ISerializable
{
+ private string _name;
+ private byte[] _publicKey;
+ private byte[] _publicKeyToken;
+ private CultureInfo _cultureInfo;
+ private string _codeBase;
+ private Version _version;
+
+ private StrongNameKeyPair _strongNameKeyPair;
+ private AssemblyHashAlgorithm _hashAlgorithm;
+
+ private AssemblyVersionCompatibility _versionCompatibility;
+ private AssemblyNameFlags _flags;
+
public AssemblyName()
{
- HashAlgorithm = AssemblyHashAlgorithm.None;
- VersionCompatibility = AssemblyVersionCompatibility.SameMachine;
+ _hashAlgorithm = AssemblyHashAlgorithm.None;
+ _versionCompatibility = AssemblyVersionCompatibility.SameMachine;
_flags = AssemblyNameFlags.None;
}
@@ -28,19 +39,55 @@ namespace System.Reflection
runtimeAssemblyName.CopyToAssemblyName(this);
}
- public object Clone()
+ // Set and get the name of the assembly. If this is a weak Name
+ // then it optionally contains a site. For strong assembly names,
+ // the name partitions up the strong name's namespace
+ public string Name
{
- AssemblyName n = new AssemblyName();
- n.Name = Name;
- n._publicKey = (byte[])_publicKey?.Clone();
- n._publicKeyToken = (byte[])_publicKeyToken?.Clone();
- n.CultureInfo = CultureInfo;
- n.Version = (Version)Version?.Clone();
- n._flags = _flags;
- n.CodeBase = CodeBase;
- n.HashAlgorithm = HashAlgorithm;
- n.VersionCompatibility = VersionCompatibility;
- return n;
+ get { return _name; }
+ set { _name = value; }
+ }
+
+ public Version Version
+ {
+ get { return _version; }
+ set { _version = value; }
+ }
+
+ // Locales, internally the LCID is used for the match.
+ public CultureInfo CultureInfo
+ {
+ get { return _cultureInfo; }
+ set { _cultureInfo = value; }
+ }
+
+ public string CultureName
+ {
+ get
+ {
+ return (_cultureInfo == null) ? null : _cultureInfo.Name;
+ }
+ set
+ {
+ _cultureInfo = (value == null) ? null : new CultureInfo(value);
+ }
+ }
+
+ public string CodeBase
+ {
+ get { return _codeBase; }
+ set { _codeBase = value; }
+ }
+
+ public string EscapedCodeBase
+ {
+ get
+ {
+ if (_codeBase == null)
+ return null;
+ else
+ return EscapeCodeBase(_codeBase);
+ }
}
public ProcessorArchitecture ProcessorArchitecture
@@ -83,85 +130,105 @@ namespace System.Reflection
}
}
- public string CultureName
+ // Make a copy of this assembly name.
+ public object Clone()
{
- get
- {
- return CultureInfo?.Name;
- }
- set
- {
- CultureInfo = (value == null) ? null : new CultureInfo(value);
- }
+ AssemblyName name = new AssemblyName();
+ name._name = _name;
+ name._publicKey = (byte[])_publicKey?.Clone();
+ name._publicKeyToken = (byte[])_publicKeyToken?.Clone();
+ name._cultureInfo = _cultureInfo;
+ name._version = (Version)_version?.Clone();
+ name._flags = _flags;
+ name._codeBase = _codeBase;
+ name._hashAlgorithm = _hashAlgorithm;
+ name._versionCompatibility = _versionCompatibility;
+ return name;
}
- public CultureInfo CultureInfo { get; set; }
+ public static AssemblyName GetAssemblyName(string assemblyFile)
+ {
+ throw new PlatformNotSupportedException(SR.Arg_PlatformNotSupported_AssemblyName_GetAssemblyName);
+ }
- public AssemblyNameFlags Flags
+ // The public key that is used to verify an assemblies
+ // inclusion into the namespace. If the public key associated
+ // with the namespace cannot verify the assembly the assembly
+ // will fail to load.
+ public byte[] GetPublicKey()
{
- get { return (AssemblyNameFlags)((uint)_flags & 0xFFFFF10F); }
- set
- {
- _flags &= unchecked((AssemblyNameFlags)0x00000EF0);
- _flags |= (value & unchecked((AssemblyNameFlags)0xFFFFF10F));
- }
+ return _publicKey;
}
- public string FullName
+ public void SetPublicKey(byte[] publicKey)
{
- get
- {
- if (this.Name == null)
- return string.Empty;
- // Do not call GetPublicKeyToken() here - that latches the result into AssemblyName which isn't a side effect we want.
- byte[] pkt = _publicKeyToken ?? AssemblyNameHelpers.ComputePublicKeyToken(_publicKey);
- return AssemblyNameFormatter.ComputeDisplayName(Name, Version, CultureName, pkt, Flags, ContentType);
- }
+ _publicKey = publicKey;
+
+ if (publicKey == null)
+ _flags &= ~AssemblyNameFlags.PublicKey;
+ else
+ _flags |= AssemblyNameFlags.PublicKey;
}
- public string Name { get; set; }
- public Version Version { get; set; }
- public string CodeBase { get; set; }
- public AssemblyHashAlgorithm HashAlgorithm { get; set; }
- public AssemblyVersionCompatibility VersionCompatibility { get; set; }
- public StrongNameKeyPair KeyPair { get; set; }
+ // The compressed version of the public key formed from a truncated hash.
+ // Will throw a SecurityException if _PublicKey is invalid
+ public byte[] GetPublicKeyToken()
+ {
+ if (_publicKeyToken == null)
+ _publicKeyToken = AssemblyNameHelpers.ComputePublicKeyToken(_publicKey);
+ return _publicKeyToken;
+ }
- public string EscapedCodeBase
+ public void SetPublicKeyToken(byte[] publicKeyToken)
{
- get
+ _publicKeyToken = publicKeyToken;
+ }
+
+ // Flags modifying the name. So far the only flag is PublicKey, which
+ // indicates that a full public key and not the compressed version is
+ // present.
+ // Processor Architecture flags are set only through ProcessorArchitecture
+ // property and can't be set or retrieved directly
+ // Content Type flags are set only through ContentType property and can't be
+ // set or retrieved directly
+ public AssemblyNameFlags Flags
+ {
+ get { return (AssemblyNameFlags)((uint)_flags & 0xFFFFF10F); }
+ set
{
- if (CodeBase == null)
- return null;
- else
- return EscapeCodeBase(CodeBase);
+ _flags &= unchecked((AssemblyNameFlags)0x00000EF0);
+ _flags |= (value & unchecked((AssemblyNameFlags)0xFFFFF10F));
}
}
- public byte[] GetPublicKey()
+ public AssemblyHashAlgorithm HashAlgorithm
{
- return _publicKey;
+ get { return _hashAlgorithm; }
+ set { _hashAlgorithm = value; }
}
- public byte[] GetPublicKeyToken()
+ public AssemblyVersionCompatibility VersionCompatibility
{
- if (_publicKeyToken == null)
- _publicKeyToken = AssemblyNameHelpers.ComputePublicKeyToken(_publicKey);
- return _publicKeyToken;
+ get { return _versionCompatibility; }
+ set { _versionCompatibility = value; }
}
- public void SetPublicKey(byte[] publicKey)
+ public StrongNameKeyPair KeyPair
{
- _publicKey = publicKey;
-
- if (publicKey == null)
- _flags &= ~AssemblyNameFlags.PublicKey;
- else
- _flags |= AssemblyNameFlags.PublicKey;
+ get { return _strongNameKeyPair; }
+ set { _strongNameKeyPair = value; }
}
- public void SetPublicKeyToken(byte[] publicKeyToken)
+ public string FullName
{
- _publicKeyToken = publicKeyToken;
+ get
+ {
+ if (this.Name == null)
+ return string.Empty;
+ // Do not call GetPublicKeyToken() here - that latches the result into AssemblyName which isn't a side effect we want.
+ byte[] pkt = _publicKeyToken ?? AssemblyNameHelpers.ComputePublicKeyToken(_publicKey);
+ return AssemblyNameFormatter.ComputeDisplayName(Name, Version, CultureName, pkt, Flags, ContentType);
+ }
}
public override string ToString()
@@ -183,11 +250,6 @@ namespace System.Reflection
throw new PlatformNotSupportedException();
}
- public static AssemblyName GetAssemblyName(string assemblyFile)
- {
- throw new PlatformNotSupportedException(SR.Arg_PlatformNotSupported_AssemblyName_GetAssemblyName);
- }
-
/// <summary>
/// Compares the simple names disregarding Version, Culture and PKT. While this clearly does not
/// match the intent of this api, this api has been broken this way since its debut and we cannot
@@ -210,10 +272,6 @@ namespace System.Reflection
}
internal static string EscapeCodeBase(string codebase) { throw new PlatformNotSupportedException(); }
-
- private AssemblyNameFlags _flags;
- private byte[] _publicKey;
- private byte[] _publicKeyToken;
}
}