Ejemplo n.º 1
0
        /// <summary>
        /// Determines Architecture from sources.
        /// </summary>
        public Architecture AutoDetectArchitecture(List <string> sources, IDictionary <string, Architecture> sourcePlatforms)
        {
            Architecture architecture = Constants.DefaultPlatform;

            try
            {
                if (sources != null && sources.Count > 0)
                {
                    Architecture?finalArch = null;
                    foreach (string source in sources)
                    {
                        Architecture arch;
                        if (IsDotNETAssembly(source))
                        {
                            arch = assemblyMetadataProvider.GetArchitecture(source);
                        }
                        else
                        {
                            //TODO what to do for js, appx and others? Using default for now.
                            arch = Constants.DefaultPlatform;
                        }
                        sourcePlatforms[source] = (Architecture)arch;

                        if (Architecture.AnyCPU.Equals(arch))
                        {
                            // If arch is AnyCPU ignore it.
                            continue;
                        }

                        if (finalArch == null)
                        {
                            finalArch = arch;
                            continue;
                        }

                        if (!finalArch.Equals(arch))
                        {
                            finalArch = Constants.DefaultPlatform;
                            EqtTrace.Info("Conflict in platform architecture, using default platform:{0}", finalArch);
                        }
                    }

                    if (finalArch != null)
                    {
                        architecture = (Architecture)finalArch;
                    }
                }
            }
            catch (Exception ex)
            {
                EqtTrace.Error("Failed to determine platform: {0}, using default: {1}", ex, architecture);
            }
            return(architecture);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines Architecture from sources.
        /// </summary>
        public Architecture AutoDetectArchitecture(List <string> sources, IDictionary <string, Architecture> sourcePlatforms)
        {
            Architecture architecture = Constants.DefaultPlatform;

            try
            {
                if (sources != null && sources.Count > 0)
                {
                    Architecture?finalArch = null;
                    foreach (string source in sources)
                    {
                        Architecture arch;
                        if (IsDotNETAssembly(source))
                        {
                            arch = assemblyMetadataProvider.GetArchitecture(source);
                        }
                        else
                        {
                            // Set AnyCPU for non dotnet test sources (js, py and other). Otherwise warning will
                            // show up if there is mismatch with user provided platform.
                            arch = Architecture.AnyCPU;
                        }
                        sourcePlatforms[source] = (Architecture)arch;

                        if (Architecture.AnyCPU.Equals(arch))
                        {
                            // If arch is AnyCPU ignore it.
                            continue;
                        }

                        if (finalArch == null)
                        {
                            finalArch = arch;
                            continue;
                        }

                        if (!finalArch.Equals(arch))
                        {
                            finalArch = Constants.DefaultPlatform;
                            EqtTrace.Info("Conflict in platform architecture, using default platform:{0}", finalArch);
                        }
                    }

                    if (finalArch != null)
                    {
                        architecture = (Architecture)finalArch;
                    }
                }
            }
            catch (Exception ex)
            {
                EqtTrace.Error("Failed to determine platform: {0}, using default: {1}", ex, architecture);
            }

            if (EqtTrace.IsInfoEnabled)
            {
                EqtTrace.Info("Determined platform for all sources: {0}", architecture);
            }

            return(architecture);
        }