Esempio n. 1
0
        internal async Task RenameAsync(string sourceCode, string oldFilePath, string newFilePath, IUserNotificationServices userNotificationServices, IRoslynServices roslynServices, string language)
        {
            using var ws = new AdhocWorkspace();
            var      projectId = ProjectId.CreateNewId();
            Solution solution  = ws.AddSolution(InitializeWorkspace(projectId, newFilePath, sourceCode, language));
            Project  project   = (from d in solution.Projects where d.Id == projectId select d).FirstOrDefault();

            var environmentOptionsFactory = IEnvironmentOptionsFactory.Implement((string category, string page, string property, bool defaultValue) => { return(true); });

            var renamer = new Renamer(ws, IProjectThreadingServiceFactory.Create(), userNotificationServices, environmentOptionsFactory, roslynServices, project, oldFilePath, newFilePath);
            await renamer.RenameAsync(project)
            .TimeoutAfter(TimeSpan.FromSeconds(1));
        }
        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));
        }
Esempio n. 3
0
        internal async Task RenameAsync(string sourceCode, string oldFilePath, string newFilePath, IUserNotificationServices userNotificationServices, IRoslynServices roslynServices, IVsOnlineServices vsOnlineServices, string language)
        {
            using var ws = new AdhocWorkspace();
            ws.AddSolution(InitializeWorkspace(ProjectId.CreateNewId(), newFilePath, sourceCode, language));

            var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: $@"C:\project1.{ProjectFileExtension}");
            var projectServices     = IUnconfiguredProjectVsServicesFactory.Implement(
                threadingServiceCreator: () => IProjectThreadingServiceFactory.Create(),
                unconfiguredProjectCreator: () => unconfiguredProject);
            var unconfiguredProjectTasksService = IUnconfiguredProjectTasksServiceFactory.Create();
            var environmentOptionsFactory       = IEnvironmentOptionsFactory.Implement((string category, string page, string property, bool defaultValue) => { return(true); });
            var waitIndicator         = (new Mock <IWaitIndicator>()).Object;
            var refactorNotifyService = (new Mock <IRefactorNotifyService>()).Object;

            var dte = IVsUIServiceFactory.Create <Shell.Interop.SDTE, EnvDTE.DTE>(null !);

            var renamer = new Renamer(projectServices, unconfiguredProjectTasksService, ws, dte, environmentOptionsFactory, userNotificationServices, roslynServices, waitIndicator, refactorNotifyService, vsOnlineServices);
            await renamer.HandleRenameAsync(oldFilePath, newFilePath)
            .TimeoutAfter(TimeSpan.FromSeconds(1));
        }