Beispiel #1
0
        protected override void Initialize()
        {
            base.Initialize();
            this.InitializeSqm();

            IServiceProvider serviceProvider = this;

            var activeSolutionBoundTracker = this.GetMefService <IActiveSolutionBoundTracker>();
            var sonarQubeService           = this.GetMefService <ISonarQubeService>();
            var workspace = this.GetMefService <VisualStudioWorkspace>();

            logger = this.GetMefService <ILogger>();
            Debug.Assert(logger != null, "MEF composition error - failed to retrieve a logger");

            var vsSolution = serviceProvider.GetService <SVsSolution, IVsSolution>();

            this.sonarAnalyzerManager = new SonarAnalyzerManager(activeSolutionBoundTracker, sonarQubeService, workspace,
                                                                 vsSolution, logger);

            this.usageAnalyzer = new BoundSolutionAnalyzer(serviceProvider);

            this.commandManager = new PackageCommandManager(serviceProvider.GetService <IMenuCommandService>());
            this.commandManager.Initialize(serviceProvider.GetMefService <ITeamExplorerController>(),
                                           serviceProvider.GetMefService <IProjectPropertyManager>());

            this.deprecationManager = new DeprecationManager(this.GetMefService <IInfoBarManager>(), logger);
        }
Beispiel #2
0
        protected override void Initialize()
        {
            base.Initialize();
            this.InitializeSqm();

            IServiceProvider serviceProvider = this;

            this.sonarAnalyzerManager = new SonarAnalyzerManager(serviceProvider);
            this.usageAnalyzer        = new BoundSolutionAnalyzer(serviceProvider);
            this.commandManager       = new PackageCommandManager(serviceProvider);

            this.commandManager.Initialize();
        }
        protected override void Initialize()
        {
            base.Initialize();
            this.InitializeSqm();

            IServiceProvider serviceProvider = this;

            this.sonarAnalyzerManager = new SonarAnalyzerManager(serviceProvider);
            this.usageAnalyzer = new BoundSolutionAnalyzer(serviceProvider);
            this.commandManager = new PackageCommandManager(serviceProvider);

            this.commandManager.Initialize();
        }
        protected override void Initialize()
        {
            base.Initialize();
            this.InitializeSqm();

            IServiceProvider serviceProvider = this;

            this.sonarAnalyzerManager = new SonarAnalyzerManager(serviceProvider);
            this.suppressionManager   = new SuppressionManager(serviceProvider);
            this.usageAnalyzer        = new BoundSolutionAnalyzer(serviceProvider);

            this.commandManager = new PackageCommandManager(serviceProvider);
            this.commandManager.Initialize();

            this.deprecationManager = new DeprecationManager(this.GetMefService <IInfoBarManager>(),
                                                             this.GetMefService <ISonarLintOutput>());
            this.deprecationManager.Initialize(VisualStudioHelpers.VisualStudioVersion);
        }
        private async System.Threading.Tasks.Task InitOnUIThreadAsync()
        {
            Debug.Assert(ThreadHelper.CheckAccess(), "SonarLint package - expecteding to be called in the UI thread");

            try
            {
                logger = await this.GetMefServiceAsync <ILogger>();

                Debug.Assert(logger != null, "MEF composition error - failed to retrieve a logger");
                logger.WriteLine(Resources.Strings.SL_Initializing);

                this.InitializeSqm();

                IServiceProvider serviceProvider = this;

                var activeSolutionBoundTracker = await this.GetMefServiceAsync <IActiveSolutionBoundTracker>();

                var sonarQubeService = await this.GetMefServiceAsync <ISonarQubeService>();

                var workspace = await this.GetMefServiceAsync <VisualStudioWorkspace>();


                var vsSolution = serviceProvider.GetService <SVsSolution, IVsSolution>();
                this.sonarAnalyzerManager = new SonarAnalyzerManager(activeSolutionBoundTracker, sonarQubeService, workspace,
                                                                     vsSolution, logger);

                this.usageAnalyzer = new BoundSolutionAnalyzer(serviceProvider);

                this.commandManager = new PackageCommandManager(serviceProvider.GetService <IMenuCommandService>());
                this.commandManager.Initialize(serviceProvider.GetMefService <ITeamExplorerController>(),
                                               serviceProvider.GetMefService <IProjectPropertyManager>());

                this.deprecationManager = new DeprecationManager(this.GetMefService <IInfoBarManager>(), logger);

                logger.WriteLine(Resources.Strings.SL_InitializationComplete);
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                // Suppress non-critical exceptions
                logger.WriteLine(Resources.Strings.SL_ERROR, ex.Message);
            }
        }
        public void PackageCommandManager_Initialize()
        {
            // Setup
            var testSubject = new PackageCommandManager(serviceProvider);

            var cmdSet = new Guid(CommonGuids.CommandSet);
            IList<CommandID> allCommands = Enum.GetValues(typeof(PackageCommandId))
                                               .Cast<int>()
                                               .Select(x => new CommandID(cmdSet, x))
                                               .ToList();

            // Act
            testSubject.Initialize();

            // Verify
            Assert.AreEqual(allCommands.Count, menuService.Commands.Count, "Unexpected number of commands");

            IList<CommandID> missingCommands = allCommands.Except(menuService.Commands.Select(x => x.Key)).ToList();
            IEnumerable<string> missingCommandNames = missingCommands.Select(x => Enum.GetName(typeof(PackageCommandId), x));
            Assert.IsTrue(!missingCommands.Any(), $"Missing commands: {string.Join(", ", missingCommandNames)}");
        }
        public void PackageCommandManager_RegisterCommand()
        {
            // Setup
            int cmdId = 42;
            Guid cmdSetGuid = new Guid(CommonGuids.CommandSet);
            CommandID commandIdObject = new CommandID(cmdSetGuid, cmdId);
            var command = new ConfigurableVsCommand(serviceProvider);

            var testSubject = new PackageCommandManager(serviceProvider);

            // Act
            testSubject.RegisterCommand(cmdId, command);

            // Verify
            var registeredCommand = menuService.Commands.Single().Value;
            Assert.AreEqual(commandIdObject, registeredCommand.CommandID, $"Unexpected CommandID");
        }