Ejemplo n.º 1
0
        bool ListProjects(Func <ExecutionEnvironment> environment, out IEnumerable <ResharperProjectUpdater> projects)
        {
            bool success = false;
            IEnumerable <ResharperProjectUpdater> readProjects = null;

            ResharperLocks.WriteCookie("Listing projects",
                                       () => { success = TryEnumerateProjects(environment, out readProjects); });
            projects = readProjects ?? Enumerable.Empty <ResharperProjectUpdater>();
            return(success);
        }
Ejemplo n.º 2
0
        public void AssembliesUpdated(IEnumerable <Exports.IAssembly> resolvedAssemblies)
        {
            ResharperLocks.WriteCookie("Updating references...",
                                       () =>
            {
                if (_project.ProjectFile == null)
                {
                    return;
                }
                string projectFilePath = _project.ProjectFile.GetPresentableProjectPath();

                var resolvedAssemblyPaths = resolvedAssemblies.Select(x => x.File.Path.FullPath).ToList();

                var owProjectAssemblyReferences = _project.GetAssemblyReferences()
                                                  .Where(x => x.GetProperty(ISWRAP) != null).ToList();

                var owProjectAssemblyReferencePaths = owProjectAssemblyReferences
                                                      .Select(x => x.HintLocation.FullPath).ToList();

                foreach (var path in resolvedAssemblyPaths
                         .Where(x => !owProjectAssemblyReferencePaths.Contains(x) &&
                                _ignoredAssemblies.Any(i => x.Contains(i + ".dll")) == false))
                {
                    ResharperLogger.Debug("Adding reference {0} to {1}", projectFilePath, path);

                    var assembly = _project.AddAssemblyReference(path);
                    assembly.SetProperty(ISWRAP, true);
                }
                foreach (var toRemove in owProjectAssemblyReferencePaths.Where(x => !resolvedAssemblyPaths.Contains(x)))
                {
                    string remove = toRemove;
                    ResharperLogger.Debug("Removing reference {0} to {1}",
                                          projectFilePath,
                                          toRemove);
                    _project.RemoveModuleReference(
                        owProjectAssemblyReferences.First(
                            x => x.HintLocation.FullPath == remove));
                }
            });
        }