private IVsReferenceManager GetReferenceManager()
        {
            if (_referenceManager == null)
            {
                _referenceManager = _serviceProvider.GetService(typeof(SVsReferenceManager)) as IVsReferenceManager;
            }

            return(_referenceManager);
        }
        /// <summary>
        /// Show the add analyzer dialog.
        /// </summary>
        public void ShowDialog()
        {
            IVsReferenceManager referenceManager = GetReferenceManager();

            if (referenceManager != null &&
                _tracker.SelectedHierarchy != null)
            {
                referenceManager.ShowReferenceManager(this,
                                                      SolutionExplorerShim.AddAnalyzer,
                                                      null,
                                                      VSConstants.FileReferenceProvider_Guid,
                                                      fForceShowDefaultProvider: false);
            }
        }
 internal AnalyzerReferenceManager(SVsServiceProvider serviceProvider)
 {
     _referenceManager = serviceProvider.GetService(typeof(SVsReferenceManager)) as IVsReferenceManager;
 }
示例#4
0
        private IVsReferenceManager GetReferenceManager()
        {
            if (_referenceManager == null)
            {
                _referenceManager = _serviceProvider.GetService(typeof(SVsReferenceManager)) as IVsReferenceManager;
            }

            return _referenceManager;
        }
示例#5
0
 internal AnalyzerReferenceManager(SVsServiceProvider serviceProvider)
 {
     _referenceManager = serviceProvider.GetService(typeof(SVsReferenceManager)) as IVsReferenceManager;
 }
示例#6
0
        protected virtual IVsReferenceProviderContext CreateFileReferenceProviderContext(IVsReferenceManager mgr)
        {
            var exts = AddReferenceExtensions;

            if (string.IsNullOrEmpty(exts))
            {
                return(null);
            }

            var context = (IVsFileReferenceProviderContext)mgr.CreateProviderContext(VSConstants.FileReferenceProvider_Guid);

            context.BrowseFilter = AddReferenceExtensions.Replace('|', '\0') + "\0";

            var referenceContainer = this.GetReferenceContainer();
            var references         = referenceContainer
                                     .EnumReferences()
                                     .Where(n => !(n is AssemblyReferenceNode) && !(n is ProjectReferenceNode));

            foreach (var reference in references)
            {
                var newReference = (IVsFileReference)context.CreateReference();
                newReference.FullPath          = reference.Url;
                newReference.AlreadyReferenced = true;
                context.AddReference(newReference);
            }

            return(context);
        }
示例#7
0
        protected virtual IVsReferenceProviderContext CreateProjectReferenceProviderContext(IVsReferenceManager mgr)
        {
            var context = (IVsProjectReferenceProviderContext)mgr.CreateProviderContext(VSConstants.ProjectReferenceProvider_Guid);

            context.CurrentProject = this;

            var referenceContainer = this.GetReferenceContainer();
            var references         = referenceContainer
                                     .EnumReferences()
                                     .OfType <ProjectReferenceNode>();

            foreach (var reference in references)
            {
                var newReference = (IVsProjectReference)context.CreateReference();
                newReference.FullPath = reference.Url;
                newReference.Name     = reference.ReferencedProjectName;
                newReference.Identity = reference.ReferencedProjectGuid.ToString("B");
                newReference.ReferenceSpecification = reference.ReferencedProjectGuid.ToString();
                newReference.AlreadyReferenced      = true;
                context.AddReference(newReference);
            }

            return(context);
        }
示例#8
0
        protected virtual IVsReferenceProviderContext CreateAssemblyReferenceProviderContext(IVsReferenceManager mgr)
        {
            var moniker = TargetFrameworkMoniker.FullName;

            if (string.IsNullOrEmpty(moniker))
            {
                return(null);
            }

            var context = (IVsAssemblyReferenceProviderContext)mgr.CreateProviderContext(VSConstants.AssemblyReferenceProvider_Guid);

            context.TargetFrameworkMoniker = moniker;
            context.AssemblySearchPaths    = AssemblySearchPaths;

            var referenceContainer = this.GetReferenceContainer();
            var references         = referenceContainer
                                     .EnumReferences()
                                     .OfType <AssemblyReferenceNode>();

            foreach (var reference in references)
            {
                var newReference = (IVsAssemblyReference)context.CreateReference();
                newReference.FullPath          = reference.Url ?? reference.AssemblyName.ToString();
                newReference.Name              = reference.AssemblyName.Name;
                newReference.AlreadyReferenced = true;
                context.AddReference(newReference);
            }

            return(context);
        }
示例#9
0
        protected virtual IEnumerable <IVsReferenceProviderContext> GetProviderContexts(IVsReferenceManager mgr)
        {
            var ctxt = CreateAssemblyReferenceProviderContext(mgr);

            if (ctxt != null)
            {
                yield return(ctxt);
            }
            ctxt = CreateProjectReferenceProviderContext(mgr);
            if (ctxt != null)
            {
                yield return(ctxt);
            }
            ctxt = CreateFileReferenceProviderContext(mgr);
            if (ctxt != null)
            {
                yield return(ctxt);
            }
        }