예제 #1
0
        public async Task <Version?> GetVSVersionAsync(IVsService <IVsAppId> vsAppIdService)
        {
            await _threadingService.SwitchToUIThread();

            IVsAppId?vsAppId = await vsAppIdService.GetValueAsync();

            Assumes.Present(vsAppId);

            if (ErrorHandler.Succeeded(vsAppId.GetProperty((int)VSAPropID.VSAPROPID_ProductSemanticVersion, out object oVersion)) &&
                oVersion is string semVersion)
            {
                // This is a semantic version string. We only care about the non-semantic version part
                int index = semVersion.IndexOfAny(Delimiter.PlusAndMinus);
                if (index != -1)
                {
                    semVersion = semVersion.Substring(0, index);
                }

                if (Version.TryParse(semVersion, out Version vsVersion))
                {
                    return(vsVersion);
                }
            }

            return(null);
        }
 #pragma warning disable CS8618 // InitializeAsync handles this case
 public Instance(IProjectThreadingService threadingService, IVsService <SVsThreadedWaitDialogFactory, IVsThreadedWaitDialogFactory> threadedWaitDialogFactoryService)
 #pragma warning restore CS8618 // Non-nullable field is uninitialized.
     : base(threadingService.JoinableTaskContext)
 {
     _threadingService = threadingService;
     _threadedWaitDialogFactoryService = threadedWaitDialogFactoryService;
 }
 public RenamerProjectTreeActionHandler(
     UnconfiguredProject unconfiguredProject,
     IUnconfiguredProjectVsServices projectVsServices,
     [Import(typeof(VisualStudioWorkspace))] Workspace workspace,
     IEnvironmentOptions environmentOptions,
     IUserNotificationServices userNotificationServices,
     IRoslynServices roslynServices,
     IWaitIndicator waitService,
     IVsOnlineServices vsOnlineServices,
     IProjectThreadingService threadingService,
     IVsUIService <IVsExtensibility, IVsExtensibility3> extensibility,
     IVsService <SVsOperationProgress, IVsOperationProgressStatusService> operationProgressService,
     IVsService <SVsSettingsPersistenceManager, ISettingsManager> settingsManagerService)
 {
     _unconfiguredProject      = unconfiguredProject;
     _projectVsServices        = projectVsServices;
     _workspace                = workspace;
     _environmentOptions       = environmentOptions;
     _userNotificationServices = userNotificationServices;
     _roslynServices           = roslynServices;
     _waitService              = waitService;
     _vsOnlineServices         = vsOnlineServices;
     _threadingService         = threadingService;
     _extensibility            = extensibility;
     _operationProgressService = operationProgressService;
     _settingsManagerService   = settingsManagerService;
 }
 public VisualStudioWaitIndicator(UnconfiguredProject unconfiguredProject,
                                  IProjectThreadingService threadingService,
                                  IVsService <SVsThreadedWaitDialogFactory, IVsThreadedWaitDialogFactory> waitDialogFactoryService)
     : base(threadingService.JoinableTaskContext)
 {
     _threadingService         = threadingService;
     _waitDialogFactoryService = waitDialogFactoryService;
 }
 public GenerateNuGetPackageTopLevelBuildMenuCommand(
     UnconfiguredProject project,
     IProjectThreadingService threadingService,
     IVsService <SVsSolutionBuildManager, IVsSolutionBuildManager2> vsSolutionBuildManagerService,
     GeneratePackageOnBuildPropertyProvider generatePackageOnBuildPropertyProvider)
     : base(project, threadingService, vsSolutionBuildManagerService, generatePackageOnBuildPropertyProvider)
 {
 }
 internal override AbstractGenerateNuGetPackageCommand CreateInstanceCore(
     UnconfiguredProject project,
     IProjectThreadingService threadingService,
     IVsService <SVsSolutionBuildManager, IVsSolutionBuildManager2> vsSolutionBuildManagerService,
     GeneratePackageOnBuildPropertyProvider generatePackageOnBuildPropertyProvider)
 {
     return(new GenerateNuGetPackageProjectContextMenuCommand(project, threadingService, vsSolutionBuildManagerService, generatePackageOnBuildPropertyProvider));
 }
 public RegistryBasedDebuggerSettings(
     IRegistry registry,
     IVsService <SVsShell, IVsShell> shell,
     IVsShellUtilitiesHelper shellUtilitiesHelper)
 {
     _registry             = registry;
     _shell                = shell;
     _shellUtilitiesHelper = shellUtilitiesHelper;
 }
 public VisualStudioRefactorNotifyService(UnconfiguredProject unconfiguredProject,
                                          IProjectThreadingService threadingService,
                                          IVsService <SDTE, DTE> dte,
                                          IVsService <SVsSolution, IVsSolution> solutionService)
     : base(threadingService.JoinableTaskContext)
 {
     _dte             = dte;
     _solutionService = solutionService;
 }
예제 #9
0
 public ProjectDebuggerProvider(ConfiguredProject configuredProject, ILaunchSettingsProvider launchSettingsProvider,
                                OrderPrecedenceImportCollection <IDebugProfileLaunchTargetsProvider> providers,
                                IVsService <SVsShellDebugger, IVsDebugger4> vsDebuggerService)
     : base(configuredProject)
 {
     ProfileLaunchTargetsProviders = providers;
     _vsDebuggerService            = vsDebuggerService;
     LaunchSettingsProvider        = launchSettingsProvider;
 }
            internal static async Task <UndoScope> CreateAsync(IVsService <DTE> dte,
                                                               IProjectThreadingService threadingService,
                                                               string renameOperationName,
                                                               CancellationToken token = default)
            {
                var undo = new UndoScope(renameOperationName, dte, threadingService);
                await undo.StartUndoAsync(token);

                return(undo);
            }
        public VsContainedLanguageComponentsFactory(IVsService <SAsyncServiceProvider, IOleAsyncServiceProvider> serviceProvider,
                                                    IUnconfiguredProjectVsServices projectVsServices,
                                                    IActiveWorkspaceProjectContextHost projectContextHost)
        {
            _serviceProvider    = serviceProvider;
            _projectVsServices  = projectVsServices;
            _projectContextHost = projectContextHost;

            _containedLanguageFactory = new AsyncLazy <IVsContainedLanguageFactory?>(GetContainedLanguageFactoryAsync, projectVsServices.ThreadingService.JoinableTaskFactory);
        }
예제 #12
0
        public ProjectDebuggerProvider(ConfiguredProject configuredProject, ILaunchSettingsProvider launchSettingsProvider, IVsService <SVsShellDebugger, IVsDebugger4> vsDebuggerService)
            : base(configuredProject)
        {
            LaunchSettingsProvider = launchSettingsProvider;
            _vsDebuggerService     = vsDebuggerService;

            // We want it sorted so that higher numbers come first (is the default for these collections but explicitly expressed here)
            ProfileLaunchTargetsProviders = new OrderPrecedenceImportCollection <IDebugProfileLaunchTargetsProvider>(ImportOrderPrecedenceComparer.PreferenceOrder.PreferredComesFirst,
                                                                                                                     configuredProject.UnconfiguredProject);
        }
예제 #13
0
 private StartupProjectRegistrar CreateInstance(
     IVsService <SVsStartupProjectsListService, IVsStartupProjectsListService> startupProjectsListService,
     ActiveConfiguredProject <StartupProjectRegistrar.DebuggerLaunchProviders> launchProviders)
 {
     return(new StartupProjectRegistrar(
                startupProjectsListService,
                IProjectThreadingServiceFactory.Create(),
                IActiveConfiguredProjectSubscriptionServiceFactory.CreateInstance(),
                launchProviders));
 }
 public StartupProjectRegistrar(
     IVsService <SVsStartupProjectsListService, IVsStartupProjectsListService> startupProjectsListService,
     IProjectThreadingService threadingService,
     IActiveConfiguredProjectSubscriptionService activeConfiguredProjectSubscriptionService,
     ActiveConfiguredProject <DebuggerLaunchProviders> launchProviders)
 {
     _startupProjectsListService = startupProjectsListService;
     _threadingService           = threadingService;
     _activeConfiguredProjectSubscriptionService = activeConfiguredProjectSubscriptionService;
     _launchProviders = launchProviders;
 }
예제 #15
0
 public DesignTimeInputsFileWatcher(UnconfiguredProject project,
                                    IUnconfiguredProjectServices unconfiguredProjectServices,
                                    IProjectThreadingService threadingService,
                                    IDesignTimeInputsDataSource designTimeInputsDataSource,
                                    IVsService <SVsFileChangeEx, IVsAsyncFileChangeEx> fileChangeService)
     : base(unconfiguredProjectServices, synchronousDisposal: false, registerDataSource: false)
 {
     _threadingService           = threadingService;
     _designTimeInputsDataSource = designTimeInputsDataSource;
     _fileChangeService          = fileChangeService;
 }
        public LaunchProfilesDebugLaunchProvider(
            ConfiguredProject configuredProject,
            ILaunchSettingsProvider launchSettingsProvider,
            IVsService <IVsDebuggerLaunchAsync> vsDebuggerService)
            : base(configuredProject)
        {
            _launchSettingsProvider = launchSettingsProvider;
            _vsDebuggerService      = vsDebuggerService;

            LaunchTargetsProviders = new OrderPrecedenceImportCollection <IDebugProfileLaunchTargetsProvider>(projectCapabilityCheckProvider: configuredProject.UnconfiguredProject);
        }
예제 #17
0
        public VsContainedLanguageComponentsFactory(IVsService <SAsyncServiceProvider, IOleAsyncServiceProvider> serviceProvider,
                                                    IUnconfiguredProjectVsServices projectVsServices,
                                                    IProjectHostProvider projectHostProvider,
                                                    ILanguageServiceHost languageServiceHost)
        {
            _serviceProvider     = serviceProvider;
            _projectVsServices   = projectVsServices;
            _projectHostProvider = projectHostProvider;
            _languageServiceHost = languageServiceHost;

            _containedLanguageFactory = new AsyncLazy <IVsContainedLanguageFactory>(GetContainedLanguageFactoryAsync, projectVsServices.ThreadingService.JoinableTaskFactory);
        }
예제 #18
0
 internal Renamer(IUnconfiguredProjectVsServices projectVsServices,
                  IUnconfiguredProjectTasksService unconfiguredProjectTasksService,
                  VisualStudioWorkspace workspace,
                  IVsService <Shell.Interop.SDTE, EnvDTE.DTE> dte,
                  IEnvironmentOptions environmentOptions,
                  IUserNotificationServices userNotificationServices,
                  IRoslynServices roslynServices,
                  IWaitIndicator waitService,
                  IRefactorNotifyService refactorNotifyService)
     : this(projectVsServices, unconfiguredProjectTasksService, workspace as Workspace, dte, environmentOptions, userNotificationServices, roslynServices, waitService, refactorNotifyService)
 {
 }
        public async Task <string?> GetRegistryRootAsync(IVsService <IVsShell> vsShellService)
        {
            await _threadingService.SwitchToUIThread();

            IVsShell shell = await vsShellService.GetValueAsync();

            if (ErrorHandler.Succeeded(shell.GetProperty((int)__VSSPROPID.VSSPROPID_VirtualRegistryRoot, out object value)))
            {
                return(value as string);
            }

            return(null);
        }
        public ImplicitlyTriggeredDebugBuildManager(
            IProjectThreadingService threadingService,
            IProjectSystemOptionsWithChanges options,
            IVsService <SVsSolutionBuildManager, IVsSolutionBuildManager3> solutionBuildManagerService,
#pragma warning disable CS0618 // Type or member is obsolete - IImplicitlyTriggeredBuildManager is marked obsolete as it may eventually be replaced with a different API.
            IImplicitlyTriggeredBuildManager implicitlyTriggeredBuildManager)
#pragma warning restore CS0618 // Type or member is obsolete
            : base(threadingService.JoinableTaskContext)
        {
            _options = options;
            _solutionBuildManagerService     = solutionBuildManagerService;
            _implicitlyTriggeredBuildManager = implicitlyTriggeredBuildManager;
        }
예제 #21
0
        public async Task <string?> GetLocalAppDataFolderAsync(IVsService <IVsShell> vsShellService)
        {
            await _threadingService.SwitchToUIThread();

            IVsShell?shell = await vsShellService.GetValueAsync();

            if (ErrorHandler.Succeeded(shell !.GetProperty((int)__VSSPROPID4.VSSPROPID_LocalAppDataDir, out object objDataFolder)) && objDataFolder is string appDataFolder)
            {
                return(appDataFolder);
            }

            return(null);
        }
예제 #22
0
        public LaunchProfilesDebugLaunchProvider(
            IProjectThreadingService threadingService,
            ConfiguredProject configuredProject,
            ILaunchSettingsProvider launchSettingsProvider,
            IVsService <SVsShellDebugger, IVsDebugger4> vsDebuggerService)
            : base(configuredProject)
        {
            _threadingService       = threadingService;
            _launchSettingsProvider = launchSettingsProvider;
            _vsDebuggerService      = vsDebuggerService;

            LaunchTargetsProviders = new OrderPrecedenceImportCollection <IDebugProfileLaunchTargetsProvider>(projectCapabilityCheckProvider: configuredProject.UnconfiguredProject);
        }
 public StartupProjectRegistrar(
     UnconfiguredProject project,
     IVsService <SVsStartupProjectsListService, IVsStartupProjectsListService> startupProjectsListService,
     IProjectThreadingService threadingService,
     ISafeProjectGuidService projectGuidService,
     IActiveConfiguredProjectSubscriptionService projectSubscriptionService,
     ActiveConfiguredProject <DebuggerLaunchProviders> launchProviders)
     : base(threadingService.JoinableTaskContext)
 {
     _startupProjectsListService = startupProjectsListService;
     _projectGuidService         = projectGuidService;
     _projectSubscriptionService = projectSubscriptionService;
     _launchProviders            = launchProviders;
 }
예제 #24
0
 public ProjectAssetFileWatcher(
     IVsService <SVsFileChangeEx, IVsAsyncFileChangeEx> fileChangeService,
     [Import(ContractNames.ProjectTreeProviders.FileSystemDirectoryTree)] IProjectTreeProvider fileSystemTreeProvider,
     IUnconfiguredProjectCommonServices projectServices,
     IUnconfiguredProjectTasksService projectTasksService,
     IActiveConfiguredProjectSubscriptionService activeConfiguredProjectSubscriptionService)
     : base(projectServices.ThreadingService.JoinableTaskContext)
 {
     _fileChangeService      = fileChangeService;
     _fileSystemTreeProvider = fileSystemTreeProvider;
     _projectServices        = projectServices;
     _projectTasksService    = projectTasksService;
     _activeConfiguredProjectSubscriptionService = activeConfiguredProjectSubscriptionService;
 }
예제 #25
0
        public async Task <string?> GetLocalAppDataFolderAsync(IVsService <IVsShell> vsShellService)
        {
            await _threadingService.SwitchToUIThread();

            IVsShell?shell = await vsShellService.GetValueAsync();

            Assumes.Present(shell);

            if (ErrorHandler.Succeeded(shell.GetProperty((int)__VSSPROPID4.VSSPROPID_LocalAppDataDir, out object value)))
            {
                return(value as string);
            }

            return(null);
        }
        public LanguageServiceErrorListProvider(
            UnconfiguredProject project,
            IActiveWorkspaceProjectContextHost projectContextHost,
            IVsService <SVsFeatureFlags, IVsFeatureFlags> featureFlagsService,
            JoinableTaskContext joinableTaskContext)
        {
            _project            = project;
            _projectContextHost = projectContextHost;

            _isLspPullDiagnosticsEnabled = new AsyncLazy <bool>(async() =>
            {
                IVsFeatureFlags?service = await featureFlagsService.GetValueAsync();
                return(service.IsFeatureEnabled(LspPullDiagnosticsFeatureFlagName, defaultValue: false));
            }, joinableTaskContext.Factory);
        }
예제 #27
0
 public TestRenamerProjectTreeActionHandler(
     UnconfiguredProject unconfiguredProject,
     IUnconfiguredProjectVsServices projectVsServices,
     [Import(typeof(VisualStudioWorkspace))] Workspace workspace,
     IEnvironmentOptions environmentOptions,
     IUserNotificationServices userNotificationServices,
     IRoslynServices roslynServices,
     IWaitIndicator waitService,
     IVsOnlineServices vsOnlineServices,
     IProjectThreadingService threadingService,
     IVsUIService <IVsExtensibility, IVsExtensibility3> extensibility,
     IVsService <SVsOperationProgress, IVsOperationProgressStatusService> operationProgressService) :
     base(unconfiguredProject, projectVsServices, workspace, environmentOptions, userNotificationServices, roslynServices, waitService,
          vsOnlineServices, threadingService, extensibility, operationProgressService)
 {
 }
예제 #28
0
        public StartupProjectRegistrar(
            IVsService <SVsStartupProjectsListService, IVsStartupProjectsListService> startupProjectsListService,
            IProjectThreadingService threadingService,
            IActiveConfiguredProjectSubscriptionService activeConfiguredProjectSubscriptionService,
            ActiveConfiguredProject <DebuggerLaunchProviders> launchProviders)
        {
            Requires.NotNull(startupProjectsListService, nameof(startupProjectsListService));
            Requires.NotNull(threadingService, nameof(threadingService));
            Requires.NotNull(activeConfiguredProjectSubscriptionService, nameof(activeConfiguredProjectSubscriptionService));
            Requires.NotNull(launchProviders, nameof(launchProviders));

            _startupProjectsListService = startupProjectsListService;
            _threadingService           = threadingService;
            _activeConfiguredProjectSubscriptionService = activeConfiguredProjectSubscriptionService;
            _launchProviders = launchProviders;
        }
예제 #29
0
        protected AbstractGenerateNuGetPackageCommand(
            UnconfiguredProject project,
            IProjectThreadingService threadingService,
            IVsService <SVsSolutionBuildManager, IVsSolutionBuildManager2> vsSolutionBuildManagerService,
            GeneratePackageOnBuildPropertyProvider generatePackageOnBuildPropertyProvider)
        {
            Requires.NotNull(project, nameof(project));
            Requires.NotNull(threadingService, nameof(threadingService));
            Requires.NotNull(vsSolutionBuildManagerService, nameof(vsSolutionBuildManagerService));
            Requires.NotNull(generatePackageOnBuildPropertyProvider, nameof(generatePackageOnBuildPropertyProvider));

            Project           = project;
            _threadingService = threadingService;
            _vsSolutionBuildManagerService          = vsSolutionBuildManagerService;
            _generatePackageOnBuildPropertyProvider = generatePackageOnBuildPropertyProvider;
        }
        internal async Task RenameAsync(string sourceCode, string oldFilePath, string newFilePath,
                                        IUserNotificationServices userNotificationServices,
                                        IRoslynServices roslynServices,
                                        IVsOnlineServices vsOnlineServices,
                                        string language,
                                        IVsService <SVsSettingsPersistenceManager, ISettingsManager> settingsManagerService)
        {
            var unconfiguredProject = UnconfiguredProjectFactory.Create(fullPath: $@"C:\project1.{ProjectFileExtension}");
            var projectServices     = IUnconfiguredProjectVsServicesFactory.Implement(
                threadingServiceCreator: () => IProjectThreadingServiceFactory.Create(),
                unconfiguredProjectCreator: () => unconfiguredProject);

            using var ws = new AdhocWorkspace();
            ws.AddSolution(InitializeWorkspace(ProjectId.CreateNewId(), oldFilePath, sourceCode, language));

            var environmentOptionsFactory       = IEnvironmentOptionsFactory.Implement((string category, string page, string property, bool defaultValue) => { return(true); });
            var waitIndicator                   = (new Mock <IWaitIndicator>()).Object;
            var projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();
            var projectThreadingService         = IProjectThreadingServiceFactory.Create();
            var refactorNotifyService           = (new Mock <IRefactorNotifyService>()).Object;
            var extensibility                   = new Mock <IVsUIService <IVsExtensibility, IVsExtensibility3> >().Object;
            var operationProgressMock           = new Mock <IVsService <SVsOperationProgress, IVsOperationProgressStatusService> >().Object;
            var context = new Mock <IProjectTreeActionHandlerContext>().Object;

            var mockNode = new Mock <IProjectTree>();

            mockNode.SetupGet(x => x.FilePath).Returns(oldFilePath);
            mockNode.SetupGet(x => x.IsFolder).Returns(false);
            var node = mockNode.Object;

            var renamer = new TestRenamerProjectTreeActionHandler(unconfiguredProject,
                                                                  projectServices,
                                                                  ws,
                                                                  environmentOptionsFactory,
                                                                  userNotificationServices,
                                                                  roslynServices,
                                                                  waitIndicator,
                                                                  vsOnlineServices,
                                                                  projectAsynchronousTasksService,
                                                                  projectThreadingService,
                                                                  extensibility,
                                                                  operationProgressMock,
                                                                  settingsManagerService);

            await renamer.RenameAsync(context, node, newFilePath)
            .TimeoutAfter(TimeSpan.FromSeconds(1));
        }