public async Task SymlinkedFilesHaveProperdocumentRegistration()
        {
            if (Platform.IsWindows)
            {
                Assert.Ignore("Symlinks not supported on Windows");
            }

            FilePath solFile = Util.GetSampleProjectPath("symlinked-source-file", "test-symlinked-file", "test-symlinked-file.sln");

            var solutionDirectory = Path.GetDirectoryName(solFile);
            var dataFile          = Path.Combine(solutionDirectory, "SymlinkedFileData.txt");
            var data              = File.ReadAllLines(dataFile);
            var symlinkFileName   = Path.Combine(solutionDirectory, data [0]);
            var symlinkFileSource = Path.GetFullPath(Path.Combine(solutionDirectory, data [1]));

            File.Delete(symlinkFileName);
            Process.Start("ln", $"-s '{symlinkFileSource}' '{symlinkFileName}'").WaitForExit();

            using (var sol = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile))
                using (var ws = await TypeSystemServiceTestExtensions.LoadSolution(sol)) {
                    var project = sol.GetAllProjects().Single();

                    foreach (var file in project.Files)
                    {
                        Assert.IsNotNull(TypeSystemService.GetDocumentId(project, file.FilePath.ResolveLinks()));
                        if (file.FilePath.FileName.EndsWith("SymlinkedFile.cs", StringComparison.Ordinal))
                        {
                            Assert.IsNull(TypeSystemService.GetDocumentId(project, file.FilePath));
                        }
                    }
                }
        }
Example #2
0
            public DocumentId GetActiveDocument()
            {
                var document = IdeApp.Workbench?.ActiveDocument;

                if (document == null)
                {
                    return(null);
                }
                return(TypeSystemService.GetDocumentId(document.Project, document.FileName));
            }