Example #1
0
        public void AssertUX(string code, [CallerMemberName] string path = "")
        {
            int caret = 0;
            var assertCodeSnippets = GetAsserts(ref code, ref caret);
            var filePath           = AbsoluteDirectoryPath.Parse(Directory.GetCurrentDirectory()) / new FileName(path);

            var log         = new DummyLogger();
            var context     = Context.CreateContext(filePath, code, caret, new DummySourcePackage());
            var mainPackage = PackageCache.GetPackage(new Log(log.TextWriter), _project);

            mainPackage.SetCacheDirectory((AbsoluteDirectoryPath.Parse(mainPackage.CacheDirectory) / new DirectoryName("UxCompletion")).NativePath);

            var build = new CodeNinjaBuild(log, _project, _editors, mainPackage, mainPackage.References.ToList(), code, filePath);

            build.Execute();

            var suggestions = SuggestionParser.GetSuggestions(build.Compiler, context, caret, new DummyReader());

            if (assertCodeSnippets != null)
            {
                foreach (var codeSnippet in assertCodeSnippets)
                {
                    OnAssert(code, codeSnippet, suggestions, log);
                }
            }
        }
        public static IEnumerable <AbsoluteDirectoryPath> LookForPathInUninstall(string partOfName)
        {
            var registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
            var key         = Registry.LocalMachine.OpenSubKey(registryKey);

            if (key != null)
            {
                foreach (var subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName)))
                {
                    var displayName = subkey.GetValue("DisplayName") as string;
                    if (displayName != null && displayName.Contains(partOfName))
                    {
                        var installLocation = subkey.GetValue("InstallLocation") as string;
                        yield return(AbsoluteDirectoryPath.Parse(installLocation));
                    }
                }
                key.Close();
            }

            registryKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
            key         = Registry.LocalMachine.OpenSubKey(registryKey);
            if (key != null)
            {
                foreach (var subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName)))
                {
                    var displayName = subkey.GetValue("DisplayName") as string;
                    if (displayName != null && displayName.Contains(partOfName))
                    {
                        var installLocation = subkey.GetValue("InstallLocation") as string;
                        yield return(AbsoluteDirectoryPath.Parse(installLocation));
                    }
                }
                key.Close();
            }
        }
Example #3
0
        protected void TestPerformance(string code, [CallerMemberName] string testName = "")
        {
            ConfigureProjectReferences();

            //get calling method info
            StackTrace stackTrace    = new StackTrace();
            var        callingMethod = stackTrace.GetFrame(1).GetMethod();
            var        testAttribute = (PerformanceTestAttribute)callingMethod.GetCustomAttributes(typeof(PerformanceTestAttribute), true)[0];

            var caret    = GetCaret(ref code);
            var filePath = AbsoluteDirectoryPath.Parse(Directory.GetCurrentDirectory()) / new FileName(testName);

            var log         = new DummyLogger();
            var context     = Context.CreateContext(filePath, code, caret, new DummySourcePackage());
            var mainPackage = PackageCache.GetPackage(new Log(log.TextWriter), _project);

            mainPackage.SetCacheDirectory((AbsoluteDirectoryPath.Parse(mainPackage.CacheDirectory) / new DirectoryName("UxCompletion")).NativePath);

            var build = new CodeNinjaBuild(log, _project, _editors, mainPackage, mainPackage.References.ToList(), code, filePath);

            build.Execute();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            SuggestionParser.GetSuggestions(build.Compiler, context, caret, new DummyReader());
            sw.Stop();

            if (_context == null)
            {
                throw new ArgumentNullException("_context");
            }

            _context.Logger.LogTimeEvent(testName, testAttribute.Description, sw.ElapsedMilliseconds / 1000f);
        }
Example #4
0
        public IAbsolutePath ResolveAbsolutePath(string nativePath)
        {
            try
            {
                var absPath = Path.IsPathRooted(nativePath)
                                        ? nativePath
                                        : Path.GetFullPath(nativePath);

                var isDirectory = Directory.Exists(nativePath);

                return(isDirectory
                                        ? (IAbsolutePath)AbsoluteDirectoryPath.Parse(absPath)
                                        : (IAbsolutePath)AbsoluteFilePath.Parse(absPath));
            }
            catch (ArgumentException e)
            {
                throw new InvalidPath(nativePath, e);
            }
            catch (NotSupportedException e)
            {
                throw new InvalidPath(nativePath, e);
            }
            catch (PathTooLongException e)
            {
                throw new InvalidPath(nativePath, e);
            }
        }
        public void SketchListFilePath_OnlyReplacesAtEnd()
        {
            var stupidProjectRoot = AbsoluteDirectoryPath.Parse(Platform.OperatingSystem == OS.Windows ? @"c:\Project.unoproj" : "/Project.unoproj");
            var projectFilePath   = stupidProjectRoot / new FileName("Project.unoproj");
            var sketchPath        = SketchImportUtils.SketchListFilePath(projectFilePath);

            Assert.That(sketchPath, Is.EqualTo(stupidProjectRoot / new FileName("Project.sketchFiles")));
        }
Example #6
0
        public void ParseAndMakeAbsolute_AbsoluteWithRoot()
        {
            var root = Platform.OperatingSystem == OS.Windows ? @"C:\root" : "/root";
            var foo  = Platform.OperatingSystem == OS.Windows ? @"C:\foo" : "/foo";

            Assert.That(
                FilePath.ParseAndMakeAbsolute(foo, AbsoluteDirectoryPath.Parse(root)),
                Is.EqualTo(AbsoluteFilePath.Parse(foo)));
        }
Example #7
0
        public void ParseAndMakeAbsolute_RelativeWithRoot()
        {
            var root     = Platform.OperatingSystem == OS.Windows ? @"C:\root" : "/root";
            var rootPath = AbsoluteDirectoryPath.Parse(root);

            Assert.That(
                FilePath.ParseAndMakeAbsolute("foo", rootPath),
                Is.EqualTo(rootPath / new FileName("foo")));
        }
Example #8
0
        public IEnumerable <AbsoluteDirectoryPath> GetApplications(string identifier)
        {
            var appUrls = LaunchServices.GetApplicationUrlsForBundleIdentifier(new NSString(identifier));

            if (appUrls == null)
            {
                return(Enumerable.Empty <AbsoluteDirectoryPath>());
            }
            return(appUrls.Select(p => AbsoluteDirectoryPath.Parse(p.Path)));
        }
Example #9
0
        static TestBase()
        {
            var unoprojfile         = AbsoluteDirectoryPath.Parse(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)) / ".." / ".." / ".." / "Outracks.CodeCompletion.UXNinja.TestsCommon" / "TestData" / new FileName("Outracks.UXNinja.Tests.Library.unoproj");
            var relativeUnoprojFile = unoprojfile.RelativeTo(DirectoryPath.GetCurrentDirectory());

            _editors = new DummyEditorManager();
            _project = new Project("Test");
            _project.MutablePackageReferences.Clear();
            _project.MutableProjectReferences.Clear();
            _project.MutableProjectReferences.Add(new ProjectReference(new DummySource(), relativeUnoprojFile.NativeRelativePath));
        }
Example #10
0
        /// <exception cref="Exception"></exception>
        /// <exception cref="FailedToCreateOutputDir"></exception>
        public SimulatorUnoProject CreateSimulatorProject(BuildProject args, PreviewTarget target, bool directToDevice, bool quitAfterApkLaunch)
        {
            var project      = AbsoluteFilePath.Parse(args.ProjectPath);
            var buildProject = Project.Load(project.NativePath);
            var projectDir   = project.ContainingDirectory;

            var basePath = AbsoluteDirectoryPath.Parse(buildProject.BuildDirectory) / target.ToString();

            var outputDir = FindOutputDir(args, basePath);

            var preambleDir = outputDir / "preamble";
            var cacheDir    = outputDir / "cache";

            _cacheCleaner.CleanIfNecessary(cacheDir);
            SetCacheDir(buildProject, projectDir, cacheDir);

            var applicationClassName = TypeName.Parse("Outracks.Simulator.GeneratedApplication");
            var applicationClass     = ApplicationClassGenerator.CreateApplicationClass(args, buildProject.Name, applicationClassName);
            var dependencies         = ApplicationClassGenerator.Dependencies;

            AddPreamble(buildProject, preambleDir, projectDir, applicationClass, dependencies);
            AddIcons(buildProject, preambleDir, projectDir);
            ChangePackageName(buildProject);
            ChangeTitle(buildProject, oldTitle => oldTitle + " (preview)");

            var buildOptions = new BuildOptions
            {
                OutputDirectory = outputDir.NativePath,
                Configuration   = BuildConfiguration.Preview,
                MainClass       = applicationClassName.FullName,
                Strip           = target != PreviewTarget.Local,
            };

            foreach (var define in args.Defines.UnionOne("Designer"))
            {
                buildOptions.Defines.Add(define);
            }

            if (target == PreviewTarget.iOS && !directToDevice)
            {
                // 17.12.15 - Prevent double building when exporting to iOS. (Uno bug)
                buildOptions.RunArguments = "debug";
                buildOptions.Native       = false;
            }

            if (quitAfterApkLaunch)
            {
                buildOptions.RunArguments += " -L";
            }

            return(new SimulatorUnoProject(buildProject, buildOptions, "", args.Verbose, args.BuildLibraries));
        }
Example #11
0
 AbsoluteDirectoryPath FindOutputDir(BuildProject args, AbsoluteDirectoryPath basePath)
 {
     if (string.IsNullOrWhiteSpace(args.OutputDir))
     {
         var outputDirWithLock =
             _outputDirGenerator.CreateOrReuseOutputDir(_isHost ? basePath / "PreviewHost" : basePath / "Preview");
         _registerLock(outputDirWithLock.LockFile);
         return(outputDirWithLock.OutputDir);
     }
     else
     {
         return(AbsoluteDirectoryPath.Parse(args.OutputDir));
     }
 }
        static void AssertIfDiffers(MessageDatabase database, string filePathStr)
        {
#if DUMP_MODE
            var relativePath = RelativeFilePath.Parse(filePathStr);
            var dumpPath     = AbsoluteDirectoryPath.Parse("../../") / relativePath;
            database.Dump(dumpPath);
#endif
            var filePath         = AbsoluteFilePath.Parse(filePathStr);
            var originalDatabase = MessageDatabase.From(filePath);
            MessageDatabase.From(filePath);

            var errors = new Subject <string>();
            errors.Subscribe(Console.WriteLine);
            Assert.True(MessageDatabase.IsEqualWhileIgnoreComments(originalDatabase, database, errors), "Looks like you have changed the plugin API");
        }
Example #13
0
        bool ChangeProject(string projectPath)
        {
            _currentProject = Project.Load(projectPath);

            new Shell()
            .Watch(AbsoluteFilePath.Parse(projectPath).ContainingDirectory, "*.unoproj")
            .Where(e => e.Event == FileSystemEvent.Changed || e.Event == FileSystemEvent.Removed)
            .Subscribe(f => _currentProject = null);

            MainPackage = PackageCache.GetPackage(Log.Default, _currentProject);
            MainPackage.SetCacheDirectory((AbsoluteDirectoryPath.Parse(MainPackage.CacheDirectory) / new DirectoryName("CodeCompletion")).NativePath);

            TriggerBuild();

            return(true);
        }
Example #14
0
        public IEnumerable <AbsoluteDirectoryPath> GetPathToApplicationsThatContains(string name)
        {
            foreach (var app in GetApplications(name))
            {
                yield return(app);
            }

            var directories = Directory.GetDirectories("/Applications");

            foreach (var directory in directories)
            {
                if (directory.Contains(name))
                {
                    yield return(AbsoluteDirectoryPath.Parse(directory));
                }
            }
        }
Example #15
0
        public static AbsoluteFilePath GetSystemGuidPath()
        {
            if (Platform.OperatingSystem == OS.Windows)
            {
                return(AbsoluteDirectoryPath.Parse(
                           Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) / "Fusetools" / "Fuse" /
                       new FileName(".user"));
            }
            else if (Platform.OperatingSystem == OS.Mac)
            {
                return(AbsoluteDirectoryPath.Parse(
                           Environment.GetFolderPath(Environment.SpecialFolder.Personal)) / ".fuse" /
                       new FileName(".user"));
            }

            throw new PlatformNotSupportedException("Not implemented on platform: " + Platform.OperatingSystem);
        }
Example #16
0
        static void CopyAllFilesRecursive(AbsoluteDirectoryPath dir, AbsoluteDirectoryPath outDir)
        {
            var files = Directory.GetFiles(dir.NativePath);

            foreach (var file in files)
            {
                File.Copy(file, (outDir / Path.GetFileName(file)).NativePath, true);
            }

            var childrenDirs = Directory.GetDirectories(dir.NativePath);

            foreach (var childrenDir in childrenDirs)
            {
                var childrenOutDir = outDir / new DirectoryName(Path.GetFileName(childrenDir));
                Create(childrenOutDir);
                CopyAllFilesRecursive(AbsoluteDirectoryPath.Parse(childrenDir), childrenOutDir);
            }
        }
Example #17
0
        public static void Shoot(string name)
        {
            try
            {
                var shell = new Shell();

                var dir = AbsoluteDirectoryPath.Parse(Environment.CurrentDirectory).Combine("diagnostics");
                shell.Create(dir);
                var file = dir.Combine(new FileName(name));

                // Not taking screenshots on other platforms than Mac right now,
                // The preview tests running on Windows is not that unstable, so not currently important to do that.
                if (Platform.OperatingSystem != OS.Mac)
                {
                    return;
                }

                var psi = new ProcessStartInfo("screencapture", "\"" + file.NativePath + "\"")
                {
                    UseShellExecute = false,
                    CreateNoWindow  = true
                };
                var p = Process.Start(psi);
                if (p == null)
                {
                    throw new InvalidOperationException("Unable to start screencapture process");
                }

                if (!p.WaitForExit(5000))
                {
                    p.Kill();
                    throw new InvalidOperationException("Timeout while trying to take screenshot");
                }
                if (p.ExitCode != 0)
                {
                    throw new InvalidOperationException("Got exit code " + p.ExitCode + " while trying to take screenshot");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to take screenshot, because: " + e);
            }
        }
Example #18
0
        public IEnumerable <AbsoluteDirectoryPath> GetJdkSearchPaths(IFileSystem fs)
        {
            var defaultInstallLocations = Enumerable.Empty <AbsoluteDirectoryPath>();

            if (Platform.OperatingSystem == OS.Windows)
            {
                var defaultSearchLocation = PathExtensions.GetEnvironmentPath(Environment.SpecialFolder.ProgramFiles)
                                            / new DirectoryName("Java");

                if (fs.Exists(defaultSearchLocation))
                {
                    defaultInstallLocations = fs.GetDirectories(defaultSearchLocation, "jdk*").Reverse();
                }

                return(defaultInstallLocations);
            }
            else if (Platform.OperatingSystem == OS.Mac)
            {
                var javaHome = Environment
                               .GetEnvironmentVariable("JAVA_HOME")
                               .ToOptional()
                               .SelectMany(AbsoluteDirectoryPath.TryParse);

                var defaultSearchLocation = AbsoluteDirectoryPath.Parse("/Library/Java/JavaVirtualMachines");
                if (fs.Exists(defaultSearchLocation))
                {
                    var jdkBaseDirectories = fs.GetDirectories(defaultSearchLocation, "jdk*").Reverse();
                    defaultInstallLocations = jdkBaseDirectories.Select(
                        dir =>
                        dir / new DirectoryName("Contents") / new DirectoryName("Home"));
                }

                return(new[]
                {
                    javaHome,
                }
                       .NotNone()
                       .Concat(defaultInstallLocations));
            }

            throw new PlatformNotSupportedException();
        }
Example #19
0
        public CodeNinjaBuild(ILog logWriter, Project project, IEditorManager editors, SourcePackage mainPackage, List <SourcePackage> referencedPackages, string extraCode = null, AbsoluteFilePath extraSourcePath = null)
        {
            _log = new Log(logWriter.TextWriter);
            _log.MaxErrorCount = 0;

            _logWriter = logWriter;
            _editors   = editors;

            //var newPackages = new List<SourcePackage>();
            //mainPackage = Uno.Build.Packages.PackageResolver.ResolvePackages(_log, project, newPackages);

            AddNotAddedPackages(referencedPackages);
            mainPackage.References.Clear();
            _packages.Each(p => mainPackage.References.Add(p));

            ProjectPackage = mainPackage;

            _extraCode       = extraCode;
            _extraCodeSource = extraSourcePath;

            var configuration = new CodeNinjaBuildTarget();
            var backend       = configuration.CreateBackend();

            var projectDir = project.RootDirectory;
            var rootDir    = AbsoluteDirectoryPath.Parse(Path.Combine(projectDir, ".CodeNinja"));

            _compiler = new Compiler(
                _log,
                backend,
                ProjectPackage,
                new CompilerOptions
            {
                Debug = true,
                CodeCompletionMode = true,
                OutputDirectory    = (rootDir / "Output").ToString(),
                BuildTarget        = new DefaultBuild().Identifier,
                Strip = false
            });

            _projDir   = AbsoluteDirectoryPath.Parse(ProjectPackage.SourceDirectory);
            _filePaths = project.SourceFiles.Select(x => x.UnixPath).Select(RelativeFilePath.Parse).ToList();
        }
Example #20
0
        protected void AssertCode(string code, [CallerMemberName] string path = "")
        {
            int caret = 0;
            var assertCodeSnippets = GetAsserts(ref code, ref caret);

            var ubProject = _project;

            var filePath = AbsoluteDirectoryPath.Parse(Directory.GetCurrentDirectory()) / new FileName(path);

            _log = new DummyLogger();
            var editors     = new DummyEditorManager();
            var mainPackage = new PackageCache(new Log(_log.TextWriter), ubProject.Config).GetPackage(ubProject);

            mainPackage.SetCacheDirectory((AbsoluteDirectoryPath.Parse(mainPackage.CacheDirectory) / new DirectoryName("CodeCompletion")).NativePath);
            var build = new CodeNinjaBuild(_log, ubProject, editors, mainPackage, mainPackage.References.ToList(), code, filePath);

            build.Execute();

            var engine        = new DummyEngine(build.Compiler);
            var codeCompleter = new CodeCompleter(engine.Compiler,
                                                  new Source(build.ProjectPackage, filePath.NativePath),
                                                  new CodeReader(code, caret),
                                                  caret,
                                                  Parser.Parse(code));

            if (codeCompleter.Context.NodePath.Count < 1)
            {
                throw new TestException("Invalid node path was generated for the test case");
            }

            ConfidenceLevel confidenceLevel;
            var             suggestions = codeCompleter.SuggestCompletion("", out confidenceLevel);

            if (assertCodeSnippets != null)
            {
                foreach (var codeSnippet in assertCodeSnippets)
                {
                    OnAssert(code, codeSnippet, suggestions);
                }
            }
        }
Example #21
0
 static AbsoluteDirectoryPath GetApmPath()
 {
     if (Platform.OperatingSystem == OS.Windows)
     {
         var atomPath = ApplicationPaths.AtomPath();
         if (!atomPath.HasValue)
         {
             //It's not possible to detect the Atom path on Windows 7, so show a message in that case
             var os       = Environment.OSVersion;
             var win7Info = (os.Platform == PlatformID.Win32NT && os.Version.Major == 6 && os.Version.Minor == 0)
                                         ? " Note that we are unable to detect the Atom installation path on Windows 7."
                                         : "";
             throw new Exception("Failed to find Atom path. Is Atom installed?" + win7Info);
         }
         return(atomPath.Value / ".." / "bin" / "apm.cmd");
     }
     else
     {
         return(AbsoluteDirectoryPath.Parse("apm"));
     }
 }
Example #22
0
        public void Template03()
        {
            if (Directory.Exists("Foo"))
            {
                Directory.Delete("Foo", true);
            }

            var variableResolver = new VariableResolverDummy(
                new Dictionary <string, string>()
            {
                { "namespace", "Test" },
                { "filename", "Foo" }
            });

            var         root            = AbsoluteDirectoryPath.Parse(Directory.GetCurrentDirectory());
            IFileSystem fileSystem      = null;                                                                                   // TODO
            var         templates       = TemplateLoader.LoadTemplatesFrom(root / "Templates" / "Projects", fileSystem).ToList(); // TODO: real test fs
            var         templateSpawner = new TemplateSpawner(variableResolver, fileSystem);

            templateSpawner.Spawn(templates[2], root / "Foo");
        }
Example #23
0
        Optional <AbsoluteDirectoryPath> SelectDirectorySync(DirectoryDialogOptions options)
        {
            var ofd = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog
            {
                Description            = options.Caption,
                ShowNewFolderButton    = true,
                UseDescriptionForTitle = true,
            };

            if (options.Directory != null)
            {
                ofd.SelectedPath = options.Directory.NativePath;
            }

            var success = _window == null?ofd.ShowDialog() : ofd.ShowDialog(_window);

            var path = ofd.SelectedPath;

            return(success.HasValue && success.Value
                                ? Optional.Some(AbsoluteDirectoryPath.Parse(path))
                                : Optional.None <AbsoluteDirectoryPath>());
        }
Example #24
0
        public static IEnumerable <AbsoluteDirectoryPath> LookForPathInApplications(string fullName)
        {
            var applications = Registry.ClassesRoot.OpenSubKey("Applications");

            if (applications != null)
            {
                foreach (var application in applications.GetSubKeyNames().Select(keyName => applications.OpenSubKey(keyName)))
                {
                    if (application.Name.EndsWith(fullName))
                    {
                        application.GetSubKeyNames().Select(keyName => application.OpenSubKey(keyName));
                        var kjell          = application.OpenSubKey("shell");
                        var open           = kjell.OpenSubKey("open");
                        var command        = open.OpenSubKey("command");
                        var command_string = (string)command.GetValue("");
                        var exe_path       = command_string.Split(" ")[0].Trim('"');
                        yield return(AbsoluteDirectoryPath.Parse(exe_path));
                    }
                }
                applications.Close();
            }
            ;
        }
Example #25
0
 /// <remarks> This function updates the Result property as a side-effect </remarks>
 /// <returns> (Started (LogEvent)* [AssemblyBuilt] Ended)* </returns>
 public IObservable <IBinaryMessage> Build(IObservable <BuildProject> args)
 {
     return(args
            .Switch(a => Observable.Defer(() =>
     {
         var log = new LogSubject(a.Id);
         return Observable
         .Start(
             () =>
         {
             lock (_buildLock)
                 return _simulatorBuilder.TryBuild(a, log.Log);
         })
         .Do(_result.OnNext)
         .SelectMany(result =>
                     result.HasValue
                                                         ? new IBinaryMessage[]
         {
             new AssemblyBuilt {
                 Assembly = AbsoluteFilePath.Parse(result.Value.Assembly)
             },
             new Ended {
                 Command = a, Success = true, BuildDirectory = AbsoluteDirectoryPath.Parse(a.OutputDir)
             },
         }
                                                         : new IBinaryMessage[]
         {
             new Ended {
                 Command = a, Success = false, BuildDirectory = AbsoluteDirectoryPath.Parse(a.OutputDir)
             }
         })
         .StartWith(new Started {
             Command = a
         })
         .Merge(log.Messages);
     })));
 }
Example #26
0
        public async Task SetUp()
        {
            var project = Substitute.For <IProject>();

            project.Classes.Returns(Observable.Return(new IElement[] { }));
            project.RootDirectory.Returns(Observable.Return(AbsoluteDirectoryPath.Parse("/project")));

            var context = Substitute.For <IContext>();

            _root = CreateTree();

            _fileSystem = Substitute.For <IFileSystem>();

            _fileSystem.Exists(Arg.Any <AbsoluteFilePath>())
            .Returns(
                callInfo =>
            {
                var absoluteFilePath = callInfo.Arg <AbsoluteFilePath>();
                var result           = absoluteFilePath == AbsoluteFilePath.Parse("/project/MainView.ux");
                Console.WriteLine("FileSystem.Exists({0}) -> {1}", absoluteFilePath, result);
                return(result);
            });

            var panel = await GetTreeChild("Panel");

            _currentSelection = new BehaviorSubject <IElement>(panel);
            context.CurrentSelection.Returns(_currentSelection.Switch());
            _classExtractor = new MockedClassExtractor();
            _model          = new ExtractClassViewModel(
                context: context,
                suggestedName: "MyPanel",
                allClassNames: Observable.Return(new HashSet <string>(new[] { "MyCircle" })),
                classExtractor: _classExtractor,
                fileSystem: _fileSystem,
                project: project);
            project.Classes.Returns(Observable.Return(new[] { await GetTreeChild("Circle") }));
        }
Example #27
0
 public static AbsoluteDirectoryPath GetEnvironmentPath(Environment.SpecialFolder specialFolder)
 {
     return(AbsoluteDirectoryPath.Parse(Environment.GetFolderPath(specialFolder)));
 }
Example #28
0
        /// <exception cref="BuildFailed"></exception>
        /// <exception cref="FailedToCreateOutputDir"></exception>
        public System.Threading.Tasks.Task <BuildResult> BuildUno(Guid id, BuildProject args, PreviewTarget previewTarget, bool driectToDevice, CancellationToken cancellationToken, bool quitAfterApkLaunch)
        {
            args.Id = id;

            var loggedEvents = new AccumulatingProgress <IBinaryMessage>(_buildEvents);
            var errorList    = new ErrorListAdapter(id, loggedEvents);
            var textWriter   = new TextWriterAdapter(id, loggedEvents);

            var tcs = new TaskCompletionSource <BuildResult>();

            var project = _simulatorBuilder.CreateSimulatorProject(args, previewTarget, driectToDevice, quitAfterApkLaunch);

            var thread = new Thread(
                () =>
            {
                var logger = new Log(errorList, textWriter);
                if (project.IsVerboseBuild)
                {
                    logger.Level = Uno.Logging.LogLevel.Verbose;
                }

                if (project.BuildLibraries)
                {
                    new LibraryBuilder(new Disk(logger), BuildTargets.Package)
                    {
                        Express = true
                    }
                }
                .Build();

                var buildTarget = GetBuildTarget(previewTarget);

                //BuildTarget target;
                //Enum.TryParse(buildTarget.Identifier, true, out target);

                _buildEvents.Report(
                    new Started
                {
                    Command = args
                });

                var faulty = false;
                try
                {
                    var buildResult =
                        new ProjectBuilder(
                            logger,
                            buildTarget,
                            project.Options)
                        .Build(project.Project);

                    if (buildResult.ErrorCount != 0)
                    {
                        _errorHelpers.OnBuildFailed(buildResult);

                        tcs.SetException(new UserCodeContainsErrors());
                    }
                    else
                    {
                        tcs.SetResult(buildResult);
                    }
                }
                catch (Exception e)
                {
                    if (e is ThreadAbortException)
                    {
                        return;
                    }

                    tcs.TrySetException(new InternalBuildError(e));
                    faulty = true;
                }
                finally
                {
                    _buildEvents.Report(
                        new Ended
                    {
                        Command        = args,
                        Success        = !faulty,
                        BuildDirectory = AbsoluteDirectoryPath.Parse(project.Project.OutputDirectory)
                    });
                }
            })
Example #29
0
 public static bool IsInvalid(IAbsolutePath path)
 {
     return(Platform.OperatingSystem == OS.Mac &&
            Platform.OperatingSystemVersion >= Platform.ElCapitan &&
            path.IsOrIsRootedIn(AbsoluteDirectoryPath.Parse("/usr/share")));
 }
Example #30
0
 AbsoluteFilePath GetAbsolutePath(SourcePackage p, RelativeFilePath s)
 {
     return(AbsoluteDirectoryPath.Parse(p.SourceDirectory) / s);
 }