Esempio n. 1
0
        public static void LaunchLogoAppOnPrimaryDevice(PlatformName platform)
        {
            new ConsoleLogger();
            AppInfo app = AppBuilderTestExtensions.TryGetAlreadyBuiltApp("LogoApp", platform);

            app.LaunchAppOnPrimaryDevice();
        }
        public static void TestAndExecuteNoDevice(string swiftCode, CodeElementCollection <ICodeElement> callingCode,
                                                  string expectedOutput, string testName = null,
                                                  PlatformName platform       = PlatformName.None,
                                                  UnicodeMapper unicodeMapper = null)
        {
            SetInvokingTestNameIfUnset(ref testName, out string nameSpace);

            using (var provider = new DisposableTempDirectory()) {
                var compiler = Utils.CompileSwift(swiftCode, provider, nameSpace);

                var libName           = $"lib{nameSpace}.dylib";
                var tempDirectoryPath = Path.Combine(provider.DirectoryPath, "BuildDir");
                Directory.CreateDirectory(tempDirectoryPath);
                File.Copy(Path.Combine(compiler.DirectoryPath, libName), Path.Combine(tempDirectoryPath, libName));

                Utils.CompileToCSharp(provider, tempDirectoryPath, nameSpace, unicodeMapper: unicodeMapper);

                CSFile csFile = TestRunningCodeGenerator.GenerateTestEntry(callingCode, testName, nameSpace, platform);
                csFile.Namespaces.Add(CreateManagedConsoleRedirect());
                CodeWriter.WriteToFile(Path.Combine(tempDirectoryPath, "NameNotImportant.cs"), csFile);

                var sourceFiles = Directory.GetFiles(tempDirectoryPath, "*.cs");
                Compiler.CSCompile(tempDirectoryPath, sourceFiles, "NameNotImportant.exe", platform: platform);

                CopyTestReferencesTo(tempDirectoryPath, platform);

                var output = Execute(tempDirectoryPath, "NameNotImportant.exe", platform);
                Assert.AreEqual(expectedOutput, output);
            }
        }
        public static void SetPlatform(PlatformName platform)
        {
            string assemblyName;

            switch (platform)
            {
            case PlatformName.Desktop:
            {
                assemblyName = PlatformHelper.DesktopAssembly;
                break;
            }

            case PlatformName.Android:
            {
                assemblyName = PlatformHelper.AndroidAssembly;
                break;
            }

            case PlatformName.Ios:
            {
                assemblyName = PlatformHelper.IosAssembly;
                break;
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(platform), platform, null);
            }
            if (string.IsNullOrEmpty(assemblyName))
            {
                throw new InvalidOperationException("Unknown Platform");
            }
            PlatformHelper.LoadSpecificAssembly(assemblyName);
        }
 public UnavailableAttribute(PlatformName platform,
                             PlatformArchitecture architecture = PlatformArchitecture.All,
                             string message = null)
     : base(AvailabilityKind.Unavailable,
            platform, null, architecture, message)
 {
 }
Esempio n. 5
0
        private bool IsPartOfUE4XcodeHelperTarget(XcodeSourceFile SourceFile)
        {
            string FileExtension = Path.GetExtension(SourceFile.FilePath);

            if (IsSourceCode(FileExtension))            // || GetFileType(FileExtension) == "sourcecode.c.h") @todo: It seemed that headers need to be added to project for live issues detection to work in them
            {
                foreach (string PlatformName in Enum.GetNames(typeof(UnrealTargetPlatform)))
                {
                    string AltName = PlatformName == "Win32" || PlatformName == "Win64" ? "windows" : PlatformName.ToLower();
                    if ((SourceFile.FilePath.ToLower().Contains("/" + PlatformName.ToLower() + "/") || SourceFile.FilePath.ToLower().Contains("/" + AltName + "/")) && PlatformName != "Mac")
                    {
                        // UE4XcodeHelper is Mac only target, so skip other platforms files
                        return(false);
                    }
                    else if (SourceFile.FilePath.EndsWith("SimplygonMeshReduction.cpp") || SourceFile.FilePath.EndsWith("MeshBoneReduction.cpp") || SourceFile.FilePath.EndsWith("Android.cpp") ||
                             SourceFile.FilePath.EndsWith("Amazon.cpp") || SourceFile.FilePath.EndsWith("FacebookModule.cpp") || SourceFile.FilePath.EndsWith("SDL_angle.c") ||
                             SourceFile.FilePath.Contains("VisualStudioSourceCodeAccess") || SourceFile.FilePath.Contains("AndroidDevice") || SourceFile.FilePath.Contains("IOSDevice") ||
                             SourceFile.FilePath.Contains("WindowsDevice") || SourceFile.FilePath.Contains("WindowsMoviePlayer") || SourceFile.FilePath.EndsWith("IOSTapJoy.cpp"))
                    {
                        // @todo: We need a way to filter out files that use SDKs we don't have
                        return(false);
                    }
                }

                return(true);
            }

            return(false);
        }
        public void CGFloatVirtual(PlatformName platform)
        {
            var swiftCode = @"
import Foundation
import CoreGraphics

open class ItsACGFloat {
    open var value:CGFloat = 0
    public init (with: CGFloat) {
        value = with
    }
    open func getValue () -> CGFloat {
        return value
    }
}
";

            var cgfID   = new CSIdentifier("cgf");
            var cgfDecl = CSVariableDeclaration.VarLine(CSSimpleType.Var, cgfID, new CSFunctionCall("ItsACGFloat", true,
                                                                                                    new CSCastExpression(new CSSimpleType("nfloat"), CSConstant.Val(42.5))));
            var printer     = CSFunctionCall.ConsoleWriteLine(new CSFunctionCall("cgf.GetValue", false));
            var callingCode = CSCodeBlock.Create(cgfDecl, printer);

            TestRunning.TestAndExecute(swiftCode, callingCode, "42.5\n", platform: platform);
        }
Esempio n. 7
0
        static SLImportModules ImportsForPlatform(PlatformName platform, TypeDefinition [] types)
        {
            var imports     = new SLImportModules();
            var modulesUsed = new HashSet <string> ();

            foreach (var type in types)
            {
                var moduleName = type.Namespace;
                var name       = "ThisShouldNeverGetFiltered";
                if (TypeAggregator.FilterModuleAndName(platform, type.Namespace, ref name))
                {
                    TypeAggregator.RemapModuleAndName(platform, ref moduleName, ref name, TypeType.None);
                    if (String.IsNullOrEmpty(moduleName))
                    {
                        continue;
                    }
                    if (modulesUsed.Contains(moduleName))
                    {
                        continue;
                    }
                    modulesUsed.Add(moduleName);
                    imports.Add(new SLImport(moduleName));
                }
            }
            return(imports);
        }
        public static void CopyTestReferencesTo(string targetDirectory, PlatformName platform = PlatformName.None)
        {
            IEnumerable <string> references = null;

            switch (platform)
            {
            case PlatformName.macOS:
                references = testMacRuntimeAssemblies;
                break;

            case PlatformName.iOS:
                references = testiOSRuntimeAssemblies;
                break;

            case PlatformName.None:
                return;

            default:
                throw new NotImplementedException(platform.ToString());
            }

            foreach (var path in references)
            {
                if (!File.Exists(path))
                {
                    throw new ArgumentException($"Unable to find required assembly {path}.");
                }
                File.Copy(path, Path.Combine(targetDirectory, Path.GetFileName(path)));
            }
        }
Esempio n. 9
0
        public static string GetAppExtension(PlatformName platform)
        {
            switch (platform)
            {
            case PlatformName.Windows:
                return(".exe");

            case PlatformName.Windows8:
                return(".appx");

            case PlatformName.WindowsPhone7:
                return(".xap");

            case PlatformName.Android:
                return(".apk");

            case PlatformName.IOS:
                return(".ipa");

            case PlatformName.Web:
                return(".zip");

            default:
                return(".none");
            }
        }
Esempio n. 10
0
        public void CallAVirtualInACtor(PlatformName platform)
        {
            string swiftCode =
                @"import Foundation
open class VirtInInit : NSObject {
	private var theValue:Int = 0;
	public init (value:Int) {
		super.init()
		setValue (value: value)
	}
	open func setValue (value: Int) {
		theValue = value
	}
	open func getValue () -> Int {
		return theValue;
	}
}
";
            var clDecl  = CSVariableDeclaration.VarLine(CSSimpleType.Var, "cl", new CSFunctionCall("VirtInInit", true, CSConstant.Val(5)));
            var printer = CSFunctionCall.ConsoleWriteLine(new CSFunctionCall("cl.GetValue", false));
            var setter  = CSFunctionCall.FunctionCallLine("cl.SetValue", CSConstant.Val(7));

            var callingCode = CSCodeBlock.Create(clDecl, printer, setter, printer);

            TestRunning.TestAndExecute(swiftCode, callingCode, "5\n7\n", platform: platform);
        }
Esempio n. 11
0
        public void VirtualOpenPropStruct(PlatformName platform)
        {
            string swiftCode =
                $"import Foundation\nopen class AnotherOpenVirtualClass{platform} {{\n\tpublic init () {{ }}\n\topen var OSVersion = OperatingSystemVersion (majorVersion: 1, minorVersion:2, patchVersion: 3)\n}}\n";

            // var cl = new AnotherVirtualClass ();
            // var vers = cl.OSVersion;
            // Console.WriteLine(vers);
            // vers.Major = 5;
            // cl.OSVersion = vers;
            // vers = cl.OSVersion;
            // Console.WriteLine(vers);
            var versID    = new CSIdentifier("vers");
            var clID      = new CSIdentifier("cl");
            var osverExpr = clID.Dot(new CSIdentifier("OSVersion"));
            var clDecl    = CSVariableDeclaration.VarLine(CSSimpleType.Var, clID, new CSFunctionCall($"AnotherOpenVirtualClass{platform}", true));
            var versDecl  = CSVariableDeclaration.VarLine(CSSimpleType.Var, versID, osverExpr);
            var printer   = CSFunctionCall.ConsoleWriteLine(versID);
            var setMajor  = CSAssignment.Assign(versID.Dot(new CSIdentifier("Major")), CSConstant.Val(5));
            var setOSVer  = CSAssignment.Assign(osverExpr, versID);
            var resetVer  = CSAssignment.Assign(versID, osverExpr);

            var callingCode = CSCodeBlock.Create(clDecl, versDecl, printer, setMajor, setOSVer, resetVer, printer);

            TestRunning.TestAndExecute(swiftCode, callingCode, "1.2.3\n5.2.3\n", platform: platform);
        }
Esempio n. 12
0
        public void TestMultiOverride(PlatformName platform)
        {
            var swiftCode   = @"
open class FirstClass {
	public init () { }
	open func firstFunc () -> Int {
	    return 42
	}
}

open class SecondClass : FirstClass {
	public override init () { }

	open func secondFunc () -> Int {
	    return 17
	}
}
";
            var declID      = new CSIdentifier("cl");
            var decl        = CSVariableDeclaration.VarLine(CSSimpleType.Var, declID, new CSFunctionCall("SecondClass", true));
            var printer     = CSFunctionCall.ConsoleWriteLine(new CSFunctionCall($"{declID.Name}.FirstFunc", false));
            var callingCode = CSCodeBlock.Create(decl, printer);

            TestRunning.TestAndExecute(swiftCode, callingCode, "42\n", "TestMultiOverride", platform: platform);
        }
Esempio n. 13
0
 public AvailabilityBaseAttribute(PlatformName platform, Version version, PlatformArchitecture architecture, string message)
 {
     Platform     = platform;
     Version      = version;
     Message      = message;
     Architecture = architecture;
 }
Esempio n. 14
0
        public IPhoneSdkVersion GetMinimumExtensionVersion(PlatformName platform, string extension)
        {
            var         key = GetPlatformKey(platform);
            PDictionary minExtensionVersions;

            if (versions.TryGetValue("MinExtensionVersion", out minExtensionVersions))
            {
                PDictionary extensions;

                if (minExtensionVersions.TryGetValue(key, out extensions))
                {
                    PString value;

                    if (extensions.TryGetValue(extension, out value))
                    {
                        IPhoneSdkVersion version;

                        if (IPhoneSdkVersion.TryParse(value.Value, out version))
                        {
                            return(version);
                        }
                    }
                }
            }

            return(IPhoneSdkVersion.V8_0);
        }
Esempio n. 15
0
        private bool IsDetectedPlatform(
            DetectorContext ctx,
            IPlatformDetector platformDetector,
            out Tuple <PlatformName, string> platformResult)
        {
            platformResult = null;
            PlatformName           platformName    = platformDetector.DetectorPlatformName;
            PlatformDetectorResult detectionResult = platformDetector.Detect(ctx);

            if (detectionResult == null)
            {
                _logger.LogInformation($"Platform '{platformName}' was not detected in the given repository.");
                return(false);
            }

            if (string.IsNullOrEmpty(detectionResult.PlatformVersion))
            {
                _logger.LogInformation($"Platform '{platformName}' was detected in the given repository, but " +
                                       $"no versions were detected.");
                platformResult = Tuple.Create(platformName, "Not Detected");
                return(true);
            }

            string detectedVersion = detectionResult.PlatformVersion;

            platformResult = Tuple.Create(platformName, detectedVersion);
            _logger.LogInformation($"platform '{platformName}' was detected with version '{detectedVersion}'.");
            return(true);
        }
        public ApiAvailabilityTest()
        {
            Maximum = Version.Parse(Constants.SdkVersion);
#if __IOS__
            Platform = PlatformName.iOS;
            Minimum  = new Version(6, 0);
#elif __TVOS__
            Platform = PlatformName.TvOS;
            Minimum  = new Version(9, 0);
#elif __WATCHOS__
            Platform = PlatformName.WatchOS;
            Minimum  = new Version(2, 0);
            // Need to special case watchOS 'Maximum' version for OS minor subversions (can't change Constants.SdkVersion)
            //Maximum = new Version (6,2,5);
#else
            Platform = PlatformName.MacOSX;
            Minimum  = new Version(10, 9);
            // Need to special case macOS 'Maximum' version for OS minor subversions (can't change Constants.SdkVersion)
            // Please comment the code below if needed
            Maximum = new Version(11, 1, 0);
#endif
            Filter = (AvailabilityBaseAttribute arg) => {
                return((arg.AvailabilityKind != AvailabilityKind.Introduced) || (arg.Platform != Platform));
            };
        }
Esempio n. 17
0
    public static void AssertSystemVersion(PlatformName platform, int major, int minor, int build = 0, bool throwIfOtherPlatform = true)
    {
        switch (platform)
        {
        case PlatformName.iOS:
            AssertiOSSystemVersion(major, minor, throwIfOtherPlatform);
            break;

        case PlatformName.MacOSX:
            AssertMacSystemVersion(major, minor, build, throwIfOtherPlatform);
            break;

        case PlatformName.TvOS:
            AsserttvOSSystemVersion(major, minor, throwIfOtherPlatform);
            break;

        case PlatformName.WatchOS:
            AssertWatchOSSystemVersion(major, minor, throwIfOtherPlatform);
            break;

        case PlatformName.MacCatalyst:
            AssertMacCatalystSystemVersion(major, minor, build, throwIfOtherPlatform);
            break;

        default:
            throw new Exception($"Unknown platform: {platform}");
        }
    }
Esempio n. 18
0
        public IList <IPhoneSdkVersion> GetKnownSdkVersions(PlatformName platform)
        {
            var         list = new List <IPhoneSdkVersion> ();
            var         key  = GetPlatformKey(platform);
            PDictionary knownVersions;

            if (versions.TryGetValue("KnownVersions", out knownVersions))
            {
                PArray array;

                if (knownVersions.TryGetValue(key, out array))
                {
                    foreach (var knownVersion in array.OfType <PString> ())
                    {
                        IPhoneSdkVersion version;

                        if (IPhoneSdkVersion.TryParse(knownVersion.Value, out version))
                        {
                            list.Add(version);
                        }
                    }
                }
            }

            return(list);
        }
Esempio n. 19
0
        public static AppInfo GetMockAppInfo(string appName, PlatformName platform,
                                             string directory = "")
        {
            string filePath = Path.Combine(directory, appName + GetAppFileExtension(platform));

            return(AppInfoExtensions.CreateAppInfo(filePath, platform, Guid.NewGuid(), DateTime.Now));
        }
Esempio n. 20
0
        private static void DetectPaths(PlatformName pn)
        {
            string path1 = null;
            string path2 = null;

            if (pn == PlatformName.Windows) {
                path1 = Platform.GetPath(PathType.Desktop);
                SetValue(registry[Id.SHORTCUT_PATH_1_DETECT], path1);
                SetValue(registry[Id.SHORTCUT_PATH_1_INPUT], path1);
                path2 = Platform.GetPath(PathType.WindowsStartMenu);
                SetValue(registry[Id.SHORTCUT_PATH_2_DETECT], path2);
                SetValue(registry[Id.SHORTCUT_PATH_2_INPUT], path2);
            } else if (pn == PlatformName.Unix) {
                path1 = Platform.GetPath(PathType.UnixGlobalXDGApplications);
                SetValue(registry[Id.SHORTCUT_PATH_1_DETECT], path1);
                path2 =  Platform.GetPath(PathType.UnixLocalXDGApplications);
                SetValue(registry[Id.SHORTCUT_PATH_2_DETECT], path2);
                SetValue(registry[Id.SHORTCUT_PATH_2_INPUT], path2);
            }

            if (Directory.Exists(path1))
                MarkGood(registry[Id.SHORTCUT_PATH_1_DETECT]);
            else
                MarkError(registry[Id.SHORTCUT_PATH_1_DETECT]);

            if (Directory.Exists(path2))
                MarkGood(registry[Id.SHORTCUT_PATH_2_DETECT]);
            else
                MarkError(registry[Id.SHORTCUT_PATH_2_DETECT]);
        }
Esempio n. 21
0
        static SLAttribute AvailableAttributeFromAttributeType(PlatformName platform, CustomAttribute customAttribute)
        {
            if (!customAttribute.HasConstructorArguments)
            {
                return(null);
            }
            var argsValues = new List <string> ();

            foreach (var arg in customAttribute.ConstructorArguments)
            {
                if (arg.Type.Name != "Byte")
                {
                    break;
                }
                argsValues.Add(arg.Value.ToString());
            }
            if (argsValues.Count == 0)
            {
                return(null);
            }
            if (argsValues.Count == 1)
            {
                argsValues.Add("0");
            }
            return(AvailableAttributeFromComponents(platform, argsValues));
        }
        public ApiAvailabilityTest()
        {
            Maximum = Version.Parse(Constants.SdkVersion);
#if __MACCATALYST__
            Platform = PlatformName.MacCatalyst;
            Minimum  = Xamarin.SdkVersions.MinMacCatalystVersion;
#elif __IOS__
            Platform = PlatformName.iOS;
            Minimum  = Xamarin.SdkVersions.MiniOSVersion;
#elif __TVOS__
            Platform = PlatformName.TvOS;
            Minimum  = Xamarin.SdkVersions.MinTVOSVersion;
#elif __WATCHOS__
            Platform = PlatformName.WatchOS;
            Minimum  = Xamarin.SdkVersions.MinWatchOSVersion;
#elif MONOMAC
            Platform = PlatformName.MacOSX;
            Minimum  = Xamarin.SdkVersions.MinOSXVersion;
#else
                        #error No Platform Defined
#endif

            Filter = (AvailabilityBaseAttribute arg) => {
                return((arg.AvailabilityKind != AvailabilityKind.Introduced) || (arg.Platform != Platform));
            };
        }
 public ObsoletedAttribute(PlatformName platform, int majorVersion, int minorVersion, int subminorVersion,
                           PlatformArchitecture architecture = PlatformArchitecture.None,
                           string message = null)
     : base(AvailabilityKind.Obsoleted,
            platform, new Version(majorVersion, minorVersion, subminorVersion),
            architecture, message)
 {
 }
Esempio n. 24
0
		private void TrySendBuildRequestToServer(string solutionFilePath,
			string projectNameInSolution, PlatformName platform, bool isRebuildOfCodeForced)
		{
			codeSolutionPathOfBuildingApp = UserSolutionPath;
			RaisePropertyChangedForIsBuildActionExecutable();
			SendBuildRequestToTheServer(solutionFilePath, projectNameInSolution, platform,
				isRebuildOfCodeForced);
		}
Esempio n. 25
0
        public static void LaunchLogoAppOnEmulatorDevice(PlatformName platform)
        {
            new ConsoleLogger();
            AppInfo app      = AppBuilderTestExtensions.TryGetAlreadyBuiltApp("LogoApp", platform);
            Device  emulator = app.AvailableDevices.FirstOrDefault(device => device.IsEmulator);

            app.LaunchAppOnDevice(emulator);
        }
Esempio n. 26
0
 private void TrySendBuildRequestToServer(string solutionFilePath,
                                          string projectNameInSolution, PlatformName platform, bool isRebuildOfCodeForced)
 {
     codeSolutionPathOfBuildingApp = UserSolutionPath;
     RaisePropertyChangedForIsBuildActionExecutable();
     SendBuildRequestToTheServer(solutionFilePath, projectNameInSolution, platform,
                                 isRebuildOfCodeForced);
 }
Esempio n. 27
0
        public string GetSelectedVenue()
        {
            if (PlatformName.Equals(MobilePlatform.IOS))
            {
                return(VenuePicker.FindElement(MobileBy.AccessibilityId("VenueInformation")).GetAttribute("value"));
            }

            return(VenuePicker.FindElement(By.Id("android:id/text1")).Text);
        }
Esempio n. 28
0
        public string GetResult()
        {
            if (PlatformName.Equals(MobilePlatform.IOS))
            {
                return(new Wait(Driver).WaitUntilElementContainsValue(Result, TimeSpan.FromSeconds(10)));
            }

            return(new Wait(Driver).WaitUntilElementContainsText(Result, TimeSpan.FromSeconds(10)));
        }
Esempio n. 29
0
        static Dictionary <string, string> TLFunctionsForFile(string path, PlatformName platform)
        {
            var result = new Dictionary <string, string> ();

            using (var stm = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                TLFunctionsForStream(stm, platform, result);
            }
            return(result);
        }
        public static bool ImportAndMerge(PlatformName platformName, TypeDatabase peerDatabase, ErrorHandling errors)
        {
            Ex.ThrowOnNull(peerDatabase, nameof(peerDatabase));
            var initialErrorCount = errors.ErrorCount;
            var newDb             = ImportFrom(platformName, errors, peerDatabase);

            peerDatabase.Merge(newDb, errors);
            return(initialErrorCount != errors.ErrorCount);
        }
Esempio n. 31
0
        public IEnumerable <string> GetVenueItemLabels()
        {
            if (PlatformName.Equals(MobilePlatform.IOS))
            {
                return(VenueItems.Select(item => item.GetAttribute("label")));
            }

            return(VenueItems.Select(item => item.Text));
        }
Esempio n. 32
0
 protected AppInfo(string fullAppDataFilePath, Guid appGuid, PlatformName platform,
                   DateTime buildDate)
 {
     FilePath  = fullAppDataFilePath;
     AppGuid   = appGuid;
     Name      = Path.GetFileNameWithoutExtension(fullAppDataFilePath);
     Platform  = platform;
     BuildDate = buildDate;
 }
Esempio n. 33
0
 protected AppInfo(string fullAppDataFilePath, Guid appGuid, PlatformName platform,
     DateTime buildDate)
 {
     FilePath = fullAppDataFilePath;
     AppGuid = appGuid;
     Name = Path.GetFileNameWithoutExtension(fullAppDataFilePath);
     Platform = platform;
     BuildDate = buildDate;
 }
Esempio n. 34
0
		public AppBuildRequest(string solutionFileName, string projectName, PlatformName platform,
			byte[] serializedCodeData)
		{
			SolutionFileName = solutionFileName;
			ProjectName = projectName;
			ContentProjectName = projectName;
			Platform = platform;
			PackedCodeData = serializedCodeData;
			ValidateData();
		}
Esempio n. 35
0
 internal AvailabilityBaseAttribute(
     AvailabilityKind availabilityKind,
     PlatformName platform,
     Version version,
     PlatformArchitecture architecture,
     string message)
 {
     AvailabilityKind = availabilityKind;
     Platform = platform;
     Version = version;
     Architecture = architecture;
     Message = message;
 }
Esempio n. 36
0
		// ncrunch: no coverage end

		private void SendBuildRequestToServer(string solutionFilePath,
			string projectNameInSolution, PlatformName platform, bool isRebuildOfCodeForced)
		{
			try
			{
				TrySendBuildRequestToServer(solutionFilePath, projectNameInSolution, platform,
					isRebuildOfCodeForced);
			}
			// ncrunch: no coverage start
			catch (Exception ex)
			{
				OnAppBuildMessageRecieved(GetErrorMessage(ex));
			}
			// ncrunch: no coverage end
		}
Esempio n. 37
0
 //this should be a factory with a plugin system
 public static AppInfo CreateAppInfo(string appFilePath, PlatformName platform, Guid appGuid,
     DateTime buildDate)
 {
     switch (platform)
     {
         case PlatformName.Windows:
             return new WindowsAppInfo(appFilePath, appGuid, buildDate);
         case PlatformName.WindowsPhone7:
             return new WP7AppInfo(appFilePath, appGuid, buildDate);
         case PlatformName.Android:
             return new AndroidAppInfo(appFilePath, appGuid, buildDate);
         case PlatformName.Web:
             return new WebAppInfo(appFilePath, appGuid, buildDate);
         default:
             throw new UnsupportedPlatfromForAppInfo(appFilePath, platform);
     }
 }
		public static string GetAppExtension(PlatformName platform)
		{
			switch (platform)
			{
			case PlatformName.Windows:
				return ".exe";
			case PlatformName.Windows8:
				return ".appx";
			case PlatformName.WindowsPhone7:
				return ".xap";
			case PlatformName.Android:
				return ".apk";
			case PlatformName.IOS:
				return ".ipa";
			case PlatformName.Web:
				return ".zip";
			default:
				return ".none";
			}
		}
Esempio n. 39
0
 public string GetString(PlatformName pn, Controller.Id id)
 {
     return dict[pn.ToString() + id.ToString()];
 }
Esempio n. 40
0
 private static void ShortcutUninstall(PlatformName pn, bool flag, string path)
 {
     ShortcutInstaller si = new ShortcutInstaller(Controller.AsmInfo);
     if ((flag) && (path != null) && (path != string.Empty)) {
         try {
             if (pn == PlatformName.Windows) {
                 si.RemoveWindowsShortcut(path);
             } else {
                 si.RemoveUnixShortcut(path);
             }
             Controller.Report(new Message(Result.OK, "Removed shortcut in: " + path));
         } catch {
             Controller.Report(new Message(Result.Fail, "Failed to remove shortcut in: " + path));
         }
     }
 }
Esempio n. 41
0
		public UnknownDeviceAppInfo(string fullAppDataFilePath, Guid appGuid, PlatformName platform,
			DateTime buildDate)
			: base(fullAppDataFilePath, appGuid, platform, buildDate) {}
Esempio n. 42
0
 public UnsupportedPlatfromForAppInfo(string appFilePath, PlatformName platform)
     : base(platform + ": " + appFilePath)
 {
 }
		// ReSharper restore UnusedMember.Local

		public SupportedPlatformsResult(PlatformName[] platforms)
		{
			Platforms = platforms;
		}
Esempio n. 44
0
        static Platform()
        {
            PortableExecutableKinds peKinds;
            typeof(object).Module.GetPEKind(out peKinds, out Architecture);

            Version osVersion;
            switch (Environment.OSVersion.Platform)
            {
                case PlatformID.Win32Windows: // Win9x supported?
                case PlatformID.Win32S: // Win16 NTVDM on Win x86?
                case PlatformID.Win32NT: // Windows NT
                    Kind = PlatformKind.Win32;
                    Name = PlatformName.Windows;

                    /* osVersion = Environment.OSVersion.Version;
                    if (osVersion.Major <= 4) {
                        // WinNT 4
                    } else if (osVersion.Major <= 5) {
                        // Win2000, WinXP
                    } else if (osVersion.Major <= 6) {
                        // WinVista, Win7, Win8.x
                        if (osVersion.Major == 0) {
                        }
                    } else {
                        // info: technet .. msdn .. microsoft research

                    } */
                    break;

                case PlatformID.WinCE:
                    // case PlatformID.Xbox:
                    Kind = PlatformKind.Win32;
                    Name = PlatformName.Windows;
                    break;

                case PlatformID.Unix:
                    // TODO: older MS.NET frameworks say Unix for MacOSX ?
                    Kind = PlatformKind.Posix;
                    Name = PlatformName.Posix;
                    break;

                case PlatformID.MacOSX:
                    Kind = PlatformKind.Posix;
                    Name = PlatformName.MacOSX;
                    break;

                default:
                    if ((int)Environment.OSVersion.Platform == 128)
                    {
                        // Mono formerly used 128 for MacOSX
                        Kind = PlatformKind.Posix;
                        Name = PlatformName.MacOSX;
                    }

                    break;
            }

            // TODO: Detect and distinguish available Compilers and Runtimes

            /* switch (Kind) {

            case PlatformKind.Windows:
                LibraryFileNameFormat = Platform.Windows.LibraryFileNameFormat;
                OpenPtr = Platform.Windows.OpenPtr;
                LoadProcedure = Platform.Windows.LoadProcedure;
                ReleasePtr = Platform.Windows.ReleasePtr;
                GetLastLibraryError = Platform.Windows.GetLastLibraryError;
                break;

            case PlatformKind.Posix:
                LibraryFileNameFormat = Platform.Posix.LibraryFileNameFormat;
                OpenPtr = Platform.Posix.OpenPtr;
                LoadProcedure = Platform.Posix.LoadProcedure;
                ReleasePtr = Platform.Posix.ReleasePtr;
                GetLastLibraryError = Platform.Posix.GetLastLibraryError;
                break;

            case PlatformKind.Unknown:
            default:
                throw new PlatformNotSupportedException ();
            } */

            IsMono = Type.GetType("Mono.Runtime") != null;

            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
            IsMonoTouch = assemblies.Any(a => a.GetName().Name.Equals("MonoTouch", StringComparison.InvariantCultureIgnoreCase));
            IsMonoMac = assemblies.Any(a => a.GetName().Name.Equals("MonoMac", StringComparison.InvariantCultureIgnoreCase));
            IsXamarinIOS = assemblies.Any(a => a.GetName().Name.Equals("Xamarin.iOS", StringComparison.InvariantCultureIgnoreCase));
            IsXamarinAndroid = assemblies.Any(a => a.GetName().Name.Equals("Xamarin.Android", StringComparison.InvariantCultureIgnoreCase));

            if (IsMonoMac)
            {
                Kind = PlatformKind.Posix;
                Name = PlatformName.MacOSX;
            }

            if (IsXamarinIOS || IsMonoTouch)
            {
                // Kind = PlatformKind.__Internal;
                // Name = PlatformName.__Internal;

                Is__Internal = true;
            }

            SetupImplementation(typeof(Platform));
        }
Esempio n. 45
0
        static Platform()
        {
            PortableExecutableKinds peKinds;
            typeof(object).Module.GetPEKind(out peKinds, out Architecture);

            Version osVersion;
            switch (Environment.OSVersion.Platform)
            {

                case PlatformID.Win32Windows: // Win9x supported?
                case PlatformID.Win32S: // Win16 NTVDM on Win x86?
                case PlatformID.Win32NT: // Windows NT
                    Kind = PlatformKind.Win32;
                    Name = PlatformName.Windows;

                    /* osVersion = Environment.OSVersion.Version;
                    if (osVersion.Major <= 4) {
                        // WinNT 4
                    } else if (osVersion.Major <= 5) {
                        // Win2000, WinXP
                    } else if (osVersion.Major <= 6) {
                        // WinVista, Win7, Win8.x
                        if (osVersion.Major == 0) {
                        }
                    } else {
                        // info: technet .. msdn .. microsoft research

                    } */
                    break;

                case PlatformID.WinCE:
                    // case PlatformID.Xbox:
                    Kind = PlatformKind.Win32;
                    Name = PlatformName.Windows;
                    break;

                case PlatformID.Unix:
                    Kind = PlatformKind.Posix;
                    // TODO: older MS.NET frameworks say Unix for MacOSX ?
                    Name = PlatformName.Posix;
                    break;

                case PlatformID.MacOSX:
                    Kind = PlatformKind.Posix;
                    Name = PlatformName.MacOSX;
                    break;

                default:
                    if ((int)Environment.OSVersion.Platform == 128)
                    {
                        // Mono formerly used 128 for MacOSX
                        Kind = PlatformKind.Posix;
                        Name = PlatformName.MacOSX;
                    }

                    break;
            }

            // TODO: Detect and distinguish available Compilers and Runtimes

            /* switch (Kind) {

            case PlatformKind.Windows:
                LibraryFileNameFormat = Platform.Windows.LibraryFileNameFormat;
                OpenPtr = Platform.Windows.OpenPtr;
                LoadProcedure = Platform.Windows.LoadProcedure;
                ReleasePtr = Platform.Windows.ReleasePtr;
                GetLastLibraryError = Platform.Windows.GetLastLibraryError;
                break;

            case PlatformKind.Posix:
                LibraryFileNameFormat = Platform.Posix.LibraryFileNameFormat;
                OpenPtr = Platform.Posix.OpenPtr;
                LoadProcedure = Platform.Posix.LoadProcedure;
                ReleasePtr = Platform.Posix.ReleasePtr;
                GetLastLibraryError = Platform.Posix.GetLastLibraryError;
                break;

            case PlatformKind.Unknown:
            default:
                throw new PlatformNotSupportedException ();
            } */
            SetupPlatformImplementation(typeof(Platform));
        }
Esempio n. 46
0
		private void SendBuildRequestToTheServer(string solutionFilePath, string projectNameInSolution,
			PlatformName platform, bool isRebuildOfCodeForced)
		{
			var projectData = new CodePacker(solutionFilePath, projectNameInSolution);
			var request = new AppBuildRequest(Path.GetFileName(solutionFilePath), projectNameInSolution,
				platform, projectData.GetPackedData());
			request.IsRebuildOfCodeForced = isRebuildOfCodeForced;
			request.ContentProjectName = GetContentProject(projectNameInSolution);
			Service.Send(request, false);
		}
Esempio n. 47
0
 public ObsoletedAttribute(PlatformName platform,
     PlatformArchitecture architecture = PlatformArchitecture.None,
     string message = null)
     : base(AvailabilityKind.Obsoleted, platform, null, architecture, message)
 {
 }
Esempio n. 48
0
        public ObsoletedAttribute(PlatformName platform, int majorVersion, int minorVersion, int subminorVersion,
            PlatformArchitecture architecture = PlatformArchitecture.None,
            string message = null)
            : base(AvailabilityKind.Obsoleted,
				platform, new Version (majorVersion, minorVersion, subminorVersion),
				architecture, message)
        {
        }
Esempio n. 49
0
 private void TrySendBuildRequestToServer(string solutionFilePath,
     string projectNameInSolution, PlatformName platform, bool isRebuildOfCodeForced)
 {
     try
     {
         codeSolutionPathOfBuildingApp = UserSolutionPath;
         RaisePropertyChangedForIsBuildActionExecutable();
         SendBuildRequestToServer(solutionFilePath, projectNameInSolution, platform,
             isRebuildOfCodeForced);
     }
     // ncrunch: no coverage start
     catch (Exception ex)
     {
         OnAppBuildMessageRecieved(GetErrorMessage(ex));
     }
     // ncrunch: no coverage end
 }
Esempio n. 50
0
		public AppBuildResult(string projectName, PlatformName platform)
		{
			ProjectName = projectName;
			Platform = platform;
		}
Esempio n. 51
0
 private void SetString(PlatformName pn, Controller.Id id, string s)
 {
     if (dict == null) {
         dict = new Dictionary<string,string>();
     }
     dict.Add(pn.ToString() + id.ToString(), s);
 }
Esempio n. 52
0
        public UnavailableAttribute(PlatformName platform,
            PlatformArchitecture architecture = PlatformArchitecture.All,
            string message = null)
            : base(AvailabilityKind.Unavailable,
				platform, null, architecture, message)
        {
        }
		public void PlatformShouldUseCorrectFileExtension(PlatformName platform, string extension)
		{
			Assert.AreEqual(platform, PlatformNameExtensions.GetPlatformFromFileExtension(extension));
			Assert.AreEqual(extension, PlatformNameExtensions.GetAppExtension(platform));
		}
Esempio n. 54
0
			public AppInfoWithMockDevice(PlatformName platform, string appName = "AppInfoWithMockDevice")
				: base(appName, Guid.Empty, platform, DateTime.Now) { }
Esempio n. 55
0
		private static AppInfo GetMockAppInfo(string appName,
			PlatformName platform = PlatformName.Windows)
		{
			return AppBuilderTestExtensions.GetMockAppInfo(appName, platform);
		}