Exemplo n.º 1
0
        // this is equivalent to the Fusion CompareAssemblyIdentity API
        public bool CompareAssemblyIdentity(string assemblyIdentity1, bool unified1, string assemblyIdentity2, bool unified2, out AssemblyComparisonResult result)
        {
#if CORECLR
            return(Fusion.CompareAssemblyIdentityPure(assemblyIdentity1, unified1, assemblyIdentity2, unified2, out result));
#else
            return(useNativeFusion
                                ? Fusion.CompareAssemblyIdentityNative(assemblyIdentity1, unified1, assemblyIdentity2, unified2, out result)
                                : Fusion.CompareAssemblyIdentityPure(assemblyIdentity1, unified1, assemblyIdentity2, unified2, out result));
#endif
        }
Exemplo n.º 2
0
        private static string GetSimpleAssemblyName(string refname)
        {
            int    pos;
            string name;

            if (Fusion.ParseAssemblySimpleName(refname, out pos, out name) != ParseAssemblyResult.OK)
            {
                throw new ArgumentException();
            }
            return(name);
        }
Exemplo n.º 3
0
 // this is equivalent to the Fusion CompareAssemblyIdentity API
 public bool CompareAssemblyIdentity(string assemblyIdentity1, bool unified1, string assemblyIdentity2, bool unified2, out AssemblyComparisonResult result)
 {
     return(Fusion.CompareAssemblyIdentity(assemblyIdentity1, unified1, assemblyIdentity2, unified2, out result));
 }
Exemplo n.º 4
0
        public AssemblyName(string assemblyName)
        {
            if (assemblyName == null)
            {
                throw new ArgumentNullException("assemblyName");
            }
            if (assemblyName == "")
            {
                throw new ArgumentException();
            }
            ParsedAssemblyName parsed;

            switch (Fusion.ParseAssemblyName(assemblyName, out parsed))
            {
            case ParseAssemblyResult.GenericError:
            case ParseAssemblyResult.DuplicateKey:
                throw new FileLoadException();
            }
            if (!ParseVersion(parsed.Version, parsed.Retargetable.HasValue, out version))
            {
                throw new FileLoadException();
            }
            name = parsed.Name;
            if (parsed.Culture != null)
            {
                if (parsed.Culture.Equals("neutral", StringComparison.OrdinalIgnoreCase))
                {
                    culture = "";
                }
                else if (parsed.Culture == "")
                {
                    throw new FileLoadException();
                }
                else
                {
                    culture = new CultureInfo(parsed.Culture).Name;
                }
            }
            if (parsed.PublicKeyToken != null)
            {
                if (parsed.PublicKeyToken.Equals("null", StringComparison.OrdinalIgnoreCase))
                {
                    publicKeyToken = Empty <byte> .Array;
                }
                else if (parsed.PublicKeyToken.Length != 16)
                {
                    throw new FileLoadException();
                }
                else
                {
                    publicKeyToken = ParseKey(parsed.PublicKeyToken);
                }
            }
            if (parsed.Retargetable.HasValue)
            {
                if (parsed.Culture == null || parsed.PublicKeyToken == null || version == null)
                {
                    throw new FileLoadException();
                }
                if (parsed.Retargetable.Value)
                {
                    flags |= AssemblyNameFlags.Retargetable;
                }
            }
            ProcessorArchitecture = parsed.ProcessorArchitecture;
            if (parsed.WindowsRuntime)
            {
                ContentType = AssemblyContentType.WindowsRuntime;
            }
        }
Exemplo n.º 5
0
        public AssemblyName(string assemblyName)
        {
            if (assemblyName == null)
            {
                throw new ArgumentNullException("assemblyName");
            }
            if (assemblyName == "")
            {
                throw new ArgumentException();
            }
            ParsedAssemblyName parsed;

            switch (Fusion.ParseAssemblyName(assemblyName, out parsed))
            {
            case ParseAssemblyResult.GenericError:
            case ParseAssemblyResult.DuplicateKey:
                throw new FileLoadException();
            }
            name = parsed.Name;
            if (parsed.Culture != null)
            {
                if (parsed.Culture.Equals("neutral", StringComparison.InvariantCultureIgnoreCase))
                {
                    culture = "";
                }
                else if (parsed.Culture == "")
                {
                    throw new FileLoadException();
                }
                else
                {
                    culture = new CultureInfo(parsed.Culture).Name;
                }
            }
            if (parsed.Version != null && parsed.Version.Major != 65535 && parsed.Version.Minor != 65535)
            {
                // our Fusion parser returns -1 for build and revision for incomplete version numbers (and we want 65535)
                version = new Version(parsed.Version.Major, parsed.Version.Minor, parsed.Version.Build & 0xFFFF, parsed.Version.Revision & 0xFFFF);
            }
            if (parsed.PublicKeyToken != null)
            {
                if (parsed.PublicKeyToken.Equals("null", StringComparison.InvariantCultureIgnoreCase))
                {
                    publicKeyToken = Empty <byte> .Array;
                }
                else if (parsed.PublicKeyToken.Length != 16)
                {
                    throw new FileLoadException();
                }
                else
                {
                    publicKeyToken = ParseKey(parsed.PublicKeyToken);
                }
            }
            if (parsed.Retargetable.HasValue)
            {
                if (parsed.Culture == null || parsed.PublicKeyToken == null || parsed.Version == null || parsed.Version.Build == -1 || parsed.Version.Revision == -1)
                {
                    throw new FileLoadException();
                }
                if (parsed.Retargetable.Value)
                {
                    flags |= AssemblyNameFlags.Retargetable;
                }
            }
            ProcessorArchitecture = parsed.ProcessorArchitecture;
            if (parsed.WindowsRuntime)
            {
                ContentType = AssemblyContentType.WindowsRuntime;
            }
        }
Exemplo n.º 6
0
        public AssemblyName(string assemblyName)
        {
            if (assemblyName == null)
            {
                throw new ArgumentNullException("assemblyName");
            }
            if (assemblyName == "")
            {
                throw new ArgumentException();
            }
            ParsedAssemblyName parsed;

            switch (Fusion.ParseAssemblyName(assemblyName, out parsed))
            {
            case ParseAssemblyResult.GenericError:
                throw new FileLoadException();

            case ParseAssemblyResult.DuplicateKey:
                throw new System.Runtime.InteropServices.COMException();
            }
            name = parsed.Name;
            if (parsed.Culture != null)
            {
                if (parsed.Culture.Equals("neutral", StringComparison.InvariantCultureIgnoreCase))
                {
                    culture = "";
                }
                else if (parsed.Culture == "")
                {
                    throw new FileLoadException();
                }
                else
                {
                    culture = new CultureInfo(parsed.Culture).Name;
                }
            }
            if (parsed.Version != null && parsed.Version.Major != 65535 && parsed.Version.Minor != 65535)
            {
                // our Fusion parser returns -1 for build and revision for incomplete version numbers (and we want 65535)
                version = new Version(parsed.Version.Major, parsed.Version.Minor, parsed.Version.Build & 0xFFFF, parsed.Version.Revision & 0xFFFF);
            }
            if (parsed.PublicKeyToken != null)
            {
                if (parsed.PublicKeyToken.Equals("null", StringComparison.InvariantCultureIgnoreCase))
                {
                    publicKeyToken = Empty <byte> .Array;
                }
                else if (parsed.PublicKeyToken.Length != 16)
                {
                    throw new FileLoadException();
                }
                else
                {
                    publicKeyToken = new byte[8];
                    for (int i = 0, pos = 0; i < publicKeyToken.Length; i++, pos += 2)
                    {
                        publicKeyToken[i] = (byte)("0123456789abcdef".IndexOf(char.ToLowerInvariant(parsed.PublicKeyToken[pos])) * 16
                                                   + "0123456789abcdef".IndexOf(char.ToLowerInvariant(parsed.PublicKeyToken[pos + 1])));
                    }
                }
            }
            if (parsed.Retargetable.HasValue)
            {
                if (parsed.Culture == null || parsed.PublicKeyToken == null || parsed.Version == null || parsed.Version.Build == -1 || parsed.Version.Revision == -1)
                {
                    throw new FileLoadException();
                }
                if (parsed.Retargetable.Value)
                {
                    flags |= AssemblyNameFlags.Retargetable;
                }
            }
            ProcessorArchitecture = parsed.ProcessorArchitecture;
        }