Example #1
0
        public static IDeclaredElement DeclaredElementAsTypeMember(this MockFactory factory, string typename, string member, 
            string location)
        {
            var elt = factory.Create<IDeclaredElement>();
            var typeMember = elt.As<ITypeMember>();

            var module = factory.Create<IAssemblyPsiModule>();

            var file = factory.Create<IAssemblyFile>();

            var path = new FileSystemPath(location);
            var type = factory.Create<ITypeElement>();

            typeMember.Setup(tm => tm.GetContainingType()).Returns(type.Object);
            typeMember.Setup(tm => tm.ShortName).Returns(member);

            type.Setup(t => t.CLRName).Returns(typename);

            file.Setup(f => f.Location).Returns(path);

            module.Setup(m => m.Assembly.GetFiles()).Returns(
                new[] { file.Object });

            typeMember.Setup(te => te.Module).Returns(module.Object);

            return elt.Object;
        }
        public ProductSettingsTracker(Lifetime lifetime, ClientFactory clientFactory, IViewable<ISyncSource> syncSources, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
        {
            myClientFactory = clientFactory;
              mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
              mySettingsStore.Changed.Advise(lifetime, _ => InitClient());

              myRootFolder = FileSystemPath.Parse("ReSharperPlatform");
              InitClient();

              syncSources.View(lifetime, (lt1, source) =>
            source.FilesToSync.View(lt1, (lt2, fileToSync) =>
            {
              SyncFromCloud(fileToSync.Value);

              var fileTrackingLifetime = new SequentialLifetimes(lt2);
              fileToSync.Change.Advise(lt2,
            args =>
            {
              var path = args.Property.Value;
              if (lifetime.IsTerminated || path.IsNullOrEmpty())
              {
                fileTrackingLifetime.TerminateCurrent();
              }
              else
              {
                fileTrackingLifetime.Next(lt =>
                    fileSystemTracker.AdviseFileChanges(lt, path,
                      delta => delta.Accept(new FileChangesVisitor(myClient, myRootFolder))));
              }
            });
            }));
        }
 public void Delete(FileSystemPath path)
 {
     using (var r = Refer(path))
     {
         r.FileSystem.Delete(GetRelativePath(path));
     }
 }
Example #4
0
        public static IDeclaredElement DeclaredElementAsTypeOwner(this MockFactory factory, string typename, 
           string location)
        {
            var elt = factory.Create<IDeclaredElement>();
            var typeOwner = elt.As<ITypeOwner>();
            var type = factory.Create<IType>();
            var declaredType = type.As<IDeclaredType>();
            var typeElement = factory.Create<ITypeElement>();

            typeOwner.SetupGet(tm => tm.Type).Returns(type.Object);

            var module = factory.Create<IAssemblyPsiModule>();

            var file = factory.Create<IAssemblyFile>();

            var path = new FileSystemPath(location);

            declaredType.Setup(dt => dt.GetTypeElement()).Returns(
                typeElement.Object);

            typeElement.Setup(dt => dt.CLRName).Returns(typename);

            file.Setup(f => f.Location).Returns(path);

            module.Setup(m => m.Assembly.GetFiles()).Returns(
                new[] { file.Object });

            typeElement.Setup(dt => dt.Module).Returns(module.Object);

            return elt.Object;
        }
 protected override bool IsArchiveFile(IFileSystem fileSystem, FileSystemPath path)
 {
     return path.IsFile
         && ArchiveExtensions.Contains(path.GetExtension())
         && !HasArchive(path)// HACK: Disable ability to open archives inside archives (SevenZip's stream does not have the ability to trace at the moment).
         ;
 }
Example #6
0
 public void Delete(FileSystemPath path)
 {
     if (path.IsFile)
         System.IO.File.Delete(GetPhysicalPath(path));
     else
         System.IO.Directory.Delete(GetPhysicalPath(path), true);
 }
Example #7
0
 public void AddEntity(FileSystemPath path)
 {
     if (!_entities.Contains(path))
         _entities.Add(path);
     if (!path.IsRoot)
         AddEntity(path.ParentPath);
 }
 public Stream OpenFile(FileSystemPath path, FileAccess access)
 {
     var fs = GetFirst(path);
     if (fs == null)
         throw new FileNotFoundException();
     return fs.OpenFile(path, access);
 }
 public T4OutsideSolutionSourceFile(IProjectFileExtensions projectFileExtensions,
     PsiProjectFileTypeCoordinator projectFileTypeCoordinator, IPsiModule module, FileSystemPath path,
     Func<PsiSourceFileFromPath, bool> validityCheck, Func<PsiSourceFileFromPath, IPsiSourceFileProperties> propertiesFactory,
     DocumentManager documentManager, IModuleReferenceResolveContext resolveContext)
     : base(projectFileExtensions, projectFileTypeCoordinator, module, path, validityCheck, propertiesFactory, documentManager, resolveContext)
 {
 }
Example #10
0
        public void ImplicitConversionBackToString()
        {
            var path = new FileSystemPath(@"relative\path", false, @"c:\");

            string pathString = path;
            pathString.Should().Be(@"c:\relative\path");
        }
Example #11
0
        public static NuSpec Read(FileSystemPath path)
        {
            if (!path.ExistsFile)
            return null;

              NuSpec nuspec = null;

              Logger.CatchSilent(() =>
              {
            using (var stream = path.OpenFileForReading())
            {
              stream.ReadXml(packageReader =>
              {
            if (!packageReader.ReadToDescendant("metadata"))
              return;

            packageReader.ReadElement(metadataReader =>
            {
              if (metadataReader.LocalName != "metadata")
                return;

              nuspec = new NuSpec();
              metadataReader.ReadSubElements(childReader =>
              {
                Action<NuSpec, string> action;
                if (StringActions.TryGetValue(childReader.LocalName, out action))
                  action(nuspec, childReader.ReadElementContentAsString());
              });
            });
              });
            }
              });

              return nuspec;
        }
Example #12
0
        public ProductSettingsTracker(Lifetime lifetime, IProductNameAndVersion product, ClientFactory clientFactory, GlobalPerProductStorage globalPerProductStorage, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
        {
            myClientFactory = clientFactory;
              mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
              mySettingsStore.Changed.Advise(lifetime, _ => InitClient());

              myRootFolder = FileSystemPath.Parse(product.ProductName);
              InitClient();

              var productSettingsPath = globalPerProductStorage.XmlFileStorage.Path;

              SyncFromCloud(productSettingsPath.Value);

              var fileTrackingLifetime = new SequentialLifetimes(lifetime);
              productSettingsPath.Change.Advise(lifetime,
            args =>
            {
              var path = args.Property.Value;
              if (lifetime.IsTerminated || path.IsNullOrEmpty())
              {
            fileTrackingLifetime.TerminateCurrent();
              }
              else
              {
            fileTrackingLifetime.Next(lt => fileSystemTracker.AdviseFileChanges(lt, path, delta => delta.Accept(new FileChangesVisitor(myClient, myRootFolder))));
              }
            });
        }
Example #13
0
        protected Pair<ISolution, IProjectFile> CreateSingleFileSolution(string relativeProjectDirectory, string fileName, string [] systemAssemblies)
        {
            PlatformInfo platformInfo = PlatformManager.Instance.GetPlatformInfo("Standard", Environment.Version);
            string projectDirectory = Path.Combine(testFilesDirectory, relativeProjectDirectory);

            FileSystemPath filePath = new FileSystemPath(Path.Combine(projectDirectory, fileName));
            if(!File.Exists(filePath.ToString()))
                Assert.Fail("File does not exists {0}", filePath);

            ISolution solution =
                SolutionManager.Instance.CreateSolution(
                    new FileSystemPath(Path.Combine(projectDirectory, "TestSolution.sln")));
            IProject project =
                solution.CreateProject(new FileSystemPath(Path.Combine(projectDirectory, "TestProject.csproj")),
                                       ProjectFileType.CSHARP,
                                       platformInfo.PlatformID);

            Arp.Common.Assertions.Assert.CheckNotNull(platformInfo);
            project.AddAssemblyReference(platformInfo.MscorlibPath.ToString());

            if(systemAssemblies != null)
            {
                foreach (string systemAssemblyName in systemAssemblies)
                {
                    string assemblyPath = GetSystemAssemblyPath(platformInfo, systemAssemblyName);
                    project.AddAssemblyReference(assemblyPath);
                }
            }

            IProjectFile file = project.CreateFile(filePath);

            return new Pair<ISolution, IProjectFile>(solution, file);
        }
        public void Move(IFileSystem source, FileSystemPath sourcePath, IFileSystem destination, FileSystemPath destinationPath)
        {
            bool isFile;
            if ((isFile = sourcePath.IsFile) != destinationPath.IsFile)
                throw new ArgumentException("The specified destination-path is of a different type than the source-path.");

            if (isFile)
            {
                using (var sourceStream = source.OpenFile(sourcePath, FileAccess.Read))
                {
                    using (var destinationStream = destination.CreateFile(destinationPath))
                    {
                        byte[] buffer = new byte[BufferSize];
                        int readBytes;
                        while ((readBytes = sourceStream.Read(buffer, 0, buffer.Length)) > 0)
                            destinationStream.Write(buffer, 0, readBytes);
                    }
                }
                source.Delete(sourcePath);
            }
            else
            {
                destination.CreateDirectory(destinationPath);
                foreach (var ep in source.GetEntities(sourcePath).ToArray())
                {
                    var destinationEntityPath = ep.IsFile
                                                    ? destinationPath.AppendFile(ep.EntityName)
                                                    : destinationPath.AppendDirectory(ep.EntityName);
                    Move(source, ep, destination, destinationEntityPath);
                }
                if (!sourcePath.IsRoot)
                    source.Delete(sourcePath);
            }
        }
 public void CreateDirectory(FileSystemPath path)
 {
     using (var r = Refer(path))
     {
         r.FileSystem.CreateDirectory(GetRelativePath(path));
     }
 }
 public static void Move(this IFileSystem sourceFileSystem, FileSystemPath sourcePath, IFileSystem destinationFileSystem, FileSystemPath destinationPath)
 {
     IEntityMover mover;
     if (!EntityMovers.Registration.TryGetSupported(sourceFileSystem.GetType(), destinationFileSystem.GetType(), out mover))
         throw new ArgumentException("The specified combination of file-systems is not supported.");
     mover.Move(sourceFileSystem, sourcePath, destinationFileSystem, destinationPath);
 }
 public bool Exists(FileSystemPath path)
 {
     using (var r = Refer(path))
     {
         var fileSystem = r.FileSystem;
         return fileSystem.Exists(GetRelativePath(path));
     }
 }
        private static Uri GetUri(FileSystemPath documentationRoot, string htmlPath)
        {
            if (documentationRoot.IsEmpty)
                return null;

            var fileSystemPath = documentationRoot/"en"/htmlPath;
            return fileSystemPath.ExistsFile ? fileSystemPath.ToUri() : null;
        }
Example #19
0
 public bool Exists(FileSystemPath path)
 {
     if (path.IsFile)
         return ToEntry(path) != null;
     return GetZipEntries()
         .Select(ToPath)
         .Any(entryPath => entryPath.IsChildOf(path));
 }
 public Stream OpenFile(FileSystemPath path, FileAccess access)
 {
     if (access == FileAccess.Write)
         throw new NotSupportedException();
     if (path.IsDirectory || path.ParentPath != FileSystemPath.Root)
         throw new FileNotFoundException();
     return Assembly.GetManifestResourceStream(path.EntityName);
 }
        private static void AddToAssemblyExplorer(FileSystemPath assemblyPath, ISolution solution)
        {
            var component = solution.TryGetComponent<IAssemblyExplorerManager>();
            if (component == null)
                return;

            component.AddItemsByPath(new[] { assemblyPath });
        }
 public Stream CreateFile(FileSystemPath path)
 {
     if (!path.IsFile)
         throw new ArgumentException("The specified path is no file.", "path");
     if (!_directories.ContainsKey(path.ParentPath))
         throw new DirectoryNotFoundException();
     _directories[path.ParentPath].AddLast(path);
     return new MemoryFileStream(_files[path] = new MemoryFile());
 }
Example #23
0
        public void RelativePathWithResolution()
        {
            const string originalPath = @"relative\path";
            const string rootPath = @"c:\foo";

            var path = new FileSystemPath(originalPath, false /* expand? */, rootPath);
            path.OriginalPath.Should().Be(originalPath);
            path.Path.Should().Be(Path.Combine(rootPath, originalPath));
        }
 public Stream OpenFile(FileSystemPath path, FileAccess access)
 {
     if (!path.IsFile)
         throw new ArgumentException("The specified path is no file.", "path");
     MemoryFile file;
     if (!_files.TryGetValue(path, out file))
         throw new FileNotFoundException();
     return new MemoryFileStream(file);
 }
Example #25
0
        public void AbsolutePathWithResolution()
        {
            const string originalPath = @"c:\absolute\path";
            const string rootPath = @"c:\foo";

            var path = new FileSystemPath(originalPath, false /* expand? */, rootPath);
            path.OriginalPath.Should().Be(originalPath);
            path.Path.Should().Be(originalPath);
        }
 public void CreateDirectory(FileSystemPath path)
 {
     if (Exists(path))
         throw new ArgumentException("The specified directory already exists.");
     var fs = GetFirst(path.ParentPath);
     if (fs == null)
         throw new ArgumentException("The directory-parent does not exist.");
     fs.CreateDirectory(path);
 }
 public ICollection<FileSystemPath> GetEntities(FileSystemPath path)
 {
     if (!path.IsDirectory)
         throw new ArgumentException("The specified path is no directory.", "path");
     LinkedList<FileSystemPath> subentities;
     if (!_directories.TryGetValue(path, out subentities))
         throw new DirectoryNotFoundException();
     return subentities;
 }
 public static void Compile(IFrameworkDetectionHelper frameworkDetectionHelper, FileSystemPath source, FileSystemPath dll,
     string[] references, Version version)
 {
     // The 9.1 tests are using the test nuget packages to allow testing any framework,
     // but there's a bug in the JetBrains.Tests.Platform.NetFramework.Binaries.4.0 package
     // that means csc.exe doesn't work. Use the system 4.x compiler.
     // https://youtrack.jetbrains.com/issue/RSRP-437176
     CompileUtil.CompileCs(new SystemFrameworkLocationHelper(), source, dll, references, false,
         false, version);
 }
Example #29
0
 public void Move(IFileSystem source, FileSystemPath sourcePath, IFileSystem destination, FileSystemPath destinationPath)
 {
     var pSource = (PhysicalFileSystem) source;
     var pDestination = (PhysicalFileSystem) destination;
     var pSourcePath = pSource.GetPhysicalPath(sourcePath);
     var pDestinationPath = pDestination.GetPhysicalPath(destinationPath);
     if (sourcePath.IsFile)
         System.IO.File.Move(pSourcePath, pDestinationPath);
     else
         System.IO.Directory.Move(pSourcePath, pDestinationPath);
 }
 public ICollection<FileSystemPath> GetEntities(FileSystemPath path)
 {
     var entities = new SortedList<FileSystemPath, FileSystemPath>();
     foreach (var fs in FileSystems.Where(fs => fs.Exists(path)))
     {
         foreach (var entity in fs.GetEntities(path))
             if (!entities.ContainsKey(entity))
                 entities.Add(entity, entity);
     }
     return entities.Values;
 }
 public static FileSystemPath GetPathToUpluginFile(FileSystemPath rootFolder) => rootFolder / UPLUGIN_FILENAME;
        private UnrealPluginInstallInfo.InstallDescription GetProjectPluginForUproject(FileSystemPath uprojectLocation,
                                                                                       UnrealPluginInstallInfo installInfo)
        {
            var projectRoot     = uprojectLocation.Directory;
            var upluginLocation = projectRoot / ourPathToProjectPlugin;

            return(GetPluginInfo(upluginLocation, uprojectLocation));
        }
        private List <PackageData> GetPackagesFromManifestJson()
        {
            if (!myManifestPath.ExistsFile)
            {
                // This is not really expected, unless we're on an older Unity that doesn't support package manager
                myLogger.Info("manifest.json does not exist");
                return(null);
            }

            myLogger.Verbose("Getting packages from manifest.json");

            try
            {
                var projectManifest = ManifestJson.FromJson(myManifestPath.ReadAllText2().Text);

                // Now we've deserialised manifest.json, log why we skipped packages-lock.json
                LogWhySkippedPackagesLock(projectManifest);

                var appPath = myUnityVersion.GetActualAppPathForSolution();
                var builtInPackagesFolder = UnityInstallationFinder.GetBuiltInPackagesFolder(appPath);

                // Read the editor's default manifest, which gives us the minimum versions for various packages
                var globalManifestPath = UnityInstallationFinder.GetPackageManagerDefaultManifest(appPath);
                if (globalManifestPath.ExistsFile && myLastReadGlobalManifestPath != globalManifestPath)
                {
                    myLastReadGlobalManifestPath = globalManifestPath;
                    myGlobalManifest             = SafelyReadGlobalManifestFile(globalManifestPath);
                }

                var registry = projectManifest.Registry ?? DefaultRegistryUrl;

                var packages = new Dictionary <string, PackageData>();
                foreach (var(id, version) in projectManifest.Dependencies)
                {
                    if (version.Equals("exclude", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    projectManifest.Lock.TryGetValue(id, out var lockDetails);
                    packages[id] = GetPackageData(id, version, registry, builtInPackagesFolder,
                                                  lockDetails);
                }

                // From observation, Unity treats package folders in the Packages folder as actual packages, even if they're
                // not registered in manifest.json. They must have a */package.json file, in the root of the package itself
                foreach (var child in myPackagesFolder.GetChildDirectories())
                {
                    // The folder name is not reliable to act as ID, so we'll use the ID from package.json. All other
                    // packages get the ID from manifest.json or packages-lock.json. This is assumed to be the same as
                    // the ID in package.json
                    var packageData = GetPackageDataFromFolder(null, child, PackageSource.Embedded);
                    if (packageData != null)
                    {
                        packages[packageData.Id] = packageData;
                    }
                }

                // Calculate the transitive dependencies. Based on observation, we simply go with the highest available
                var packagesToProcess = new List <PackageData>(packages.Values);
                while (packagesToProcess.Count > 0)
                {
                    var foundDependencies = GetPackagesFromDependencies(registry, builtInPackagesFolder,
                                                                        packages, packagesToProcess);
                    foreach (var package in foundDependencies)
                    {
                        packages[package.Id] = package;
                    }

                    packagesToProcess = foundDependencies;
                }

                return(new List <PackageData>(packages.Values));
            }
            catch (Exception e)
            {
                myLogger.LogExceptionSilently(e);
                return(null);
            }
        }
Example #34
0
 public SubFileSystem(IFileSystem fileSystem, FileSystemPath root)
 {
     FileSystem = fileSystem;
     Root       = root;
 }
Example #35
0
 public void Delete(FileSystemPath path)
 {
     FileSystem.Delete(AppendRoot(path));
 }
 public TestDirectoryBasedObjectWithConfiguration(IFileSystem fileSystem, FileSystemPath path, string configurationName, bool autoInit)
     : base(fileSystem, path, configurationName, autoInit)
 {
 }
 public DumpSymbolsFileSignCommand(FileSystemPath outputFilePath, ICollection <FileSystemPath> targetFilePaths)
     : base(outputFilePath, targetFilePaths)
 {
 }
Example #38
0
 public void CreateDirectory(FileSystemPath path)
 {
     FileSystem.CreateDirectory(AppendRoot(path));
 }
        private void InstallPluginIfRequired()
        {
            if (!myUnitySolutionTracker.IsUnityProjectFolder.Value)
            {
                return;
            }

            if (myPluginInstallations.Contains(mySolution.SolutionFilePath))
            {
                return;
            }

            if (!myBoundSettingsStore.GetValue((UnitySettings s) => s.InstallUnity3DRiderPlugin))
            {
                return;
            }

            var versionForSolution = myUnityVersion.GetActualVersionForSolution();

            if (versionForSolution >= new Version("2019.2")) // 2019.2+ would not work fine either without Rider package, and when package is present it loads EditorPlugin directly from Rider installation.
            {
                var installationInfoToRemove = myDetector.GetInstallationInfo(myCurrentVersion, previousInstallationDir: FileSystemPath.Empty);
                if (!installationInfoToRemove.PluginDirectory.IsAbsolute)
                {
                    return;
                }

                var pluginDll = installationInfoToRemove.PluginDirectory.Combine(PluginPathsProvider.BasicPluginDllFile);
                if (pluginDll.ExistsFile)
                {
                    myQueue.Enqueue(() =>
                    {
                        myLogger.Info($"Remove {pluginDll}. Rider package should be used instead.");
                        pluginDll.DeleteFile();
                        FileSystemPath.Parse(pluginDll.FullPath + ".meta").DeleteFile();

                        // jetbrainsDir is usually "Assets\Plugins\Editor\JetBrains", however custom locations were also possible
                        var jetbrainsDir = installationInfoToRemove.PluginDirectory;
                        if (jetbrainsDir.GetChildren().Any() || jetbrainsDir.Name != "JetBrains")
                        {
                            return;
                        }
                        jetbrainsDir.DeleteDirectoryNonRecursive();
                        FileSystemPath.Parse(jetbrainsDir.FullPath + ".meta").DeleteFile();
                        var pluginsEditorDir = jetbrainsDir.Directory;
                        if (pluginsEditorDir.GetChildren().Any() || pluginsEditorDir.Name != "Editor")
                        {
                            return;
                        }
                        pluginsEditorDir.DeleteDirectoryNonRecursive();
                        FileSystemPath.Parse(pluginsEditorDir.FullPath + ".meta").DeleteFile();
                        var pluginsDir = pluginsEditorDir.Directory;
                        if (pluginsDir.GetChildren().Any() || pluginsDir.Name != "Plugins")
                        {
                            return;
                        }
                        pluginsDir.DeleteDirectoryNonRecursive();
                        FileSystemPath.Parse(pluginsDir.FullPath + ".meta").DeleteFile();
                    });
                }
                return;
            }

            // forcing fresh install due to being unable to provide proper setting until InputField is patched in Rider
            // ReSharper disable once ArgumentsStyleNamedExpression
            var installationInfo = myDetector.GetInstallationInfo(myCurrentVersion, previousInstallationDir: FileSystemPath.Empty);

            if (!installationInfo.ShouldInstallPlugin)
            {
                myLogger.Info("Plugin should not be installed.");
                if (installationInfo.ExistingFiles.Count > 0)
                {
                    myLogger.Info("Already existing plugin files:\n{0}",
                                  string.Join("\n", installationInfo.ExistingFiles));
                }

                return;
            }

            QueueInstall(installationInfo);
            myQueue.Enqueue(() =>
            {
                mySolution.Locks.Tasks.StartNew(myLifetime, Scheduling.MainGuard,
                                                () => myRefresher.StartRefresh(RefreshType.Normal));
            });
        }
 public FileSystemPathDoesNotExistException(FileSystemPath path) :
     this(path, "Path does not exists.")
 {
 }
        public bool TryCopyFiles([NotNull] UnityPluginDetector.InstallationInfo installation, out FileSystemPath installedPath)
        {
            installedPath = null;
            try
            {
                installation.PluginDirectory.CreateDirectory();

                return(DoCopyFiles(installation, out installedPath));
            }
            catch (Exception e)
            {
                myLogger.LogException(LoggingLevel.ERROR, e, ExceptionOrigin.OuterWorld, "Plugin installation failed");
                return(false);
            }
        }
 public GetPdbTypeCommand(FileSystemPath symbolsFile)
 {
     _symbolsFile = symbolsFile;
 }
Example #43
0
 public bool Exists(FileSystemPath path)
 {
     return(FileSystem.Exists(AppendRoot(path)));
 }
        private bool DoCopyFiles([NotNull] UnityPluginDetector.InstallationInfo installation, out FileSystemPath installedPath)
        {
            installedPath = null;

            var originPaths = new List <FileSystemPath>();

            originPaths.AddRange(installation.ExistingFiles);

            var backups = originPaths.ToDictionary(f => f, f => f.AddSuffix(".backup"));

            foreach (var originPath in originPaths)
            {
                var backupPath = backups[originPath];
                if (originPath.ExistsFile)
                {
                    originPath.MoveFile(backupPath, true);
                    myLogger.Info($"backing up: {originPath.Name} -> {backupPath.Name}");
                }
                else
                {
                    myLogger.Info($"backing up failed: {originPath.Name} doesn't exist.");
                }
            }

            try
            {
                var editorPluginPathDir  = myPluginPathsProvider.GetEditorPluginPathDir();
                var editorPluginPath     = editorPluginPathDir.Combine(PluginPathsProvider.BasicPluginDllFile);
                var editor56PluginPath   = editorPluginPathDir.Combine(PluginPathsProvider.Unity56PluginDllFile);
                var editorFullPluginPath = editorPluginPathDir.Combine(PluginPathsProvider.FullPluginDllFile);

                var targetPath = installation.PluginDirectory.Combine(editorPluginPath.Name);
                try
                {
                    var versionForSolution = myUnityVersion.GetActualVersionForSolution();
                    if (versionForSolution < new Version("5.6"))
                    {
                        myLogger.Verbose($"Coping {editorPluginPath} -> {targetPath}");
                        editorPluginPath.CopyFile(targetPath, true);
                    }
                    else if (versionForSolution >= new Version("5.6") && versionForSolution < new Version("2017.3"))
                    {
                        myLogger.Verbose($"Coping {editor56PluginPath} -> {editor56PluginPath}");
                        editor56PluginPath.CopyFile(targetPath, true);
                    }
                    else
                    {
                        myLogger.Verbose($"Coping {editorFullPluginPath} -> {targetPath}");
                        editorFullPluginPath.CopyFile(targetPath, true);
                    }
                }
                catch (Exception e)
                {
                    myLogger.LogException(LoggingLevel.ERROR, e, ExceptionOrigin.Assertion,
                                          $"Failed to copy {editorPluginPath} => {targetPath}");
                    RestoreFromBackup(backups);
                }

                foreach (var backup in backups)
                {
                    backup.Value.DeleteFile();
                }

                installedPath = installation.PluginDirectory.Combine(PluginPathsProvider.BasicPluginDllFile);
                return(true);
            }
            catch (Exception e)
            {
                myLogger.LogExceptionSilently(e);

                RestoreFromBackup(backups);

                return(false);
            }
        }
Example #45
0
 /// <summary>
 /// 创建已解析的音频资源
 /// </summary>
 /// <param name="id"></param>
 /// <param name="path"></param>
 public Audio(string id, FileSystemPath path) : base(id, path)
 {
 }
Example #46
0
 protected DumpFilesSignCommandBase(FileSystemPath outputFilePath, IEnumerable <FileSystemPath> targetFilePaths)
 {
     myOutputFilePath  = outputFilePath;
     myTargetFilePaths = targetFilePaths;
 }
 public bool Exists(FileSystemPath path)
 {
     return(path.IsDirectory ? _directories.ContainsKey(path) : _files.ContainsKey(path));
 }
 public static bool PublicIsPathToSuchObject(IFileSystem fileSystem, FileSystemPath path, string configurationFileName)
 {
     return(IsPathToSuchObject(fileSystem, path, configurationFileName));
 }
Example #49
0
 protected abstract string GetFileSignature(FileSystemPath targetFilePath);
Example #50
0
 public Stream OpenFile(FileSystemPath path, FileAccess access)
 {
     return(FileSystem.OpenFile(AppendRoot(path), access));
 }
Example #51
0
 protected FileSystemPath AppendRoot(FileSystemPath path)
 {
     return(Root.AppendPath(path));
 }
 public FileSystemPathDoesNotExistException(FileSystemPath path, string message) :
     base(path, message)
 {
 }
Example #53
0
        public ICollection <FileSystemPath> GetEntities(FileSystemPath path)
        {
            var paths = FileSystem.GetEntities(AppendRoot(path));

            return(new EnumerableCollection <FileSystemPath>(paths.Select(p => RemoveRoot(p)), paths.Count));
        }
Example #54
0
 protected FileSystemPath RemoveRoot(FileSystemPath path)
 {
     return(path.RemoveParent(Root));
 }
        public void ToStringTest()
        {
            string s = "/directorya/";

            Assert.AreEqual(s, FileSystemPath.Parse(s).ToString());
        }
Example #56
0
 public Stream CreateFile(FileSystemPath path)
 {
     return(FileSystem.CreateFile(AppendRoot(path)));
 }
Example #57
0
 public virtual bool Exists(FileSystemPath path) =>
 myFileSystem is DelegatingFileSystemShim shim
 public void RootTest()
 {
     Assert.AreEqual(FileSystemPath.Parse("/"), root);
 }
        public DevExpressProjectTemplatesProvider()
        {
            var assemblyLocation = FileSystemPath.Parse(typeof(DevExpressProjectTemplatesProvider).Assembly.Location);

            myTemplatesDirectoryPath = assemblyLocation.Parent / "templates";
        }
Example #60
0
        private Version TryGetApplicationPathFromEditorInstanceJson(FileSystemPath editorInstanceJsonPath)
        {
            var val = EditorInstanceJson.TryGetValue(editorInstanceJsonPath, "version");

            return(val != null?Parse(val) : null);
        }