public static void RemoveAssemblyReference(this  resharper::JetBrains.ProjectModel.IProject project, ResharperAssemblyReference assembly)
        {
#if v600 || v610
            var projectImpl = project as resharper::JetBrains.ProjectModel.Impl.ProjectImpl;
            if (projectImpl == null)
            {
                return;
            }
            projectImpl.DoRemoveReference(assembly);
#else
            project.RemoveModuleReference(assembly);
#endif
        }
Exemple #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));
                }
            });
        }