Esempio n. 1
0
        private FrameworkVersion GetFrameworkVersionThroughModuleLocation(ModuleDefinition module, TargetPlatform targetPlatform)
        {
            FrameworkVersion frameworkVersion = this.DefaultFrameworkVersion;

            try
            {
                string moduleLocation = module.FullyQualifiedName ?? module.FilePath;

                if (moduleLocation != null)
                {
                    moduleLocation = moduleLocation.ToLowerInvariant();

                    /* AGPL */
                    string[] modulePath = moduleLocation.Split(Path.DirectorySeparatorChar);
                    /* End AGPL */

                    if (SystemInformation.IsInNetCoreSharedAssembliesDir(moduleLocation))
                    {
                        if (modulePath[modulePath.Length - 2].StartsWith("1.0"))
                        {
                            frameworkVersion = FrameworkVersion.NetCoreV1_0;
                        }
                        else if (modulePath[modulePath.Length - 2].StartsWith("1.1"))
                        {
                            frameworkVersion = FrameworkVersion.NetCoreV1_1;
                        }
                        else if (modulePath[modulePath.Length - 2].StartsWith("2.0"))
                        {
                            frameworkVersion = FrameworkVersion.NetCoreV2_0;
                        }
                        else if (modulePath[modulePath.Length - 2].StartsWith("2.1"))
                        {
                            frameworkVersion = FrameworkVersion.NetCoreV2_1;
                        }
                        /* AGPL */
                        else if (modulePath[modulePath.Length - 2].StartsWith("2.2"))
                        {
                            frameworkVersion = FrameworkVersion.NetCoreV2_2;
                        }
                        else if (modulePath[modulePath.Length - 2].StartsWith("3.0"))
                        {
                            frameworkVersion = FrameworkVersion.NetCoreV3_0;
                        }
                        else if (modulePath[modulePath.Length - 2].StartsWith("3.1"))
                        {
                            frameworkVersion = FrameworkVersion.NetCoreV3_1;
                        }
                        else if (modulePath[modulePath.Length - 2].StartsWith("5.0"))
                        {
                            frameworkVersion = FrameworkVersion.NetCoreV5_0;
                        }
                        /* End AGPL */
                    }
                    else if (moduleLocation.StartsWith(SystemInformation.WINRT_METADATA.ToLowerInvariant()) || moduleLocation.StartsWith(SystemInformation.WINDOWS_WINMD_LOCATION.ToLowerInvariant()))
                    {
                        frameworkVersion = FrameworkVersion.WinRT_System;
                    }
                }
            }
            catch
            {
            }

            return(frameworkVersion);
        }