private LocalDebuggerCommandArgumentsValueProvider CreateInstance(string targetExecutable = "", string outputKey = null, bool useOutputGroups = false) { var projectScope = IProjectCapabilitiesScopeFactory.Create(); var configuredProject = ConfiguredProjectFactory.Create(projectScope); var configGeneralProperties = new PropertyPageData() { Category = ConfigurationGeneral.SchemaName, PropertyName = ConfigurationGeneral.TargetPathProperty, Value = useOutputGroups ? string.Empty : targetExecutable }; var project = IUnconfiguredProjectFactory.Create(); var properties = ProjectPropertiesFactory.Create(project, configGeneralProperties); Lazy <IOutputGroupsService, IAppliesToMetadataView> outputGroupsWithData = null; if (useOutputGroups) { var metadata = new Mock <IAppliesToMetadataView>(); metadata.Setup(m => m.AppliesTo).Returns(""); var outputGroups = IOutputGroupsServiceFactory.Create(targetExecutable); outputGroupsWithData = new Lazy <IOutputGroupsService, IAppliesToMetadataView>(() => outputGroups, metadata.Object); } return(new LocalDebuggerCommandArgumentsValueProvider(new Lazy <ProjectProperties>(() => properties), outputGroupsWithData, configuredProject)); }
public void SharedProjectReferencesProviderContext_IsApplicable() { var capabilities = IProjectCapabilitiesScopeFactory.Create(capabilities: new string[] { ProjectCapability.ReferenceManagerSharedProjects }); var project = ConfiguredProjectFactory.Create(capabilities: capabilities); SharedProjectReferencesProviderContext context = new SharedProjectReferencesProviderContext(project); Assert.True(context.IsApplicable()); }
public void ProjectReferencesProviderContext_IsApplicable_False() { var capabilities = IProjectCapabilitiesScopeFactory.Create(); var project = ConfiguredProjectFactory.Create(capabilities: capabilities); ProjectReferencesProviderContext context = new ProjectReferencesProviderContext(project); Assert.False(context.IsApplicable()); }
public void AddFileContextProvider_IsApplicable_False() { var capabilities = IProjectCapabilitiesScopeFactory.Create(); var project = ConfiguredProjectFactory.Create(capabilities: capabilities); AddFileContextProvider context = new AddFileContextProvider(project); Assert.False(context.IsApplicable()); }
public void AddFileContextProvider_IsApplicable_True() { var capabilities = IProjectCapabilitiesScopeFactory.Create(capabilities: new string[] { ProjectCapability.ReferenceManagerBrowse }); var project = ConfiguredProjectFactory.Create(capabilities: capabilities); AddFileContextProvider context = new AddFileContextProvider(project); Assert.True(context.IsApplicable()); }
private static ConfiguredProject CreateConfiguredProject(string[] capabilities, Dictionary <string, string?> propertyNamesAndValues) { return(ConfiguredProjectFactory.Create( IProjectCapabilitiesScopeFactory.Create(capabilities), services: ConfiguredProjectServicesFactory.Create( projectPropertiesProvider: IProjectPropertiesProviderFactory.Create( commonProps: IProjectPropertiesFactory.CreateWithPropertiesAndValues( propertyNamesAndValues))))); }
private static IVsHierarchy CreateIVSHierarchy(string targetFrameworkMoniker = ".NETCoreApp,Version=v3.0") { var projectProperties = IProjectPropertiesFactory.CreateWithPropertyAndValue("TargetFrameworkMoniker", targetFrameworkMoniker); var propertiesProvider = IProjectPropertiesProviderFactory.Create(commonProps: projectProperties); var project = ConfiguredProjectFactory.Create(services: ConfiguredProjectServicesFactory.Create(projectPropertiesProvider: propertiesProvider)); var scope = IProjectCapabilitiesScopeFactory.Create(new[] { ProjectCapability.DotNet, ProjectCapability.PackageReferences }); var ivsHierarchy = IVsHierarchyFactory.ImplementAsUnconfiguredProject(UnconfiguredProjectFactory.Create(scope: scope, configuredProject: project)); return(ivsHierarchy); }
private static DotNetCoreProjectCompatibilityDetector CreateCompatibilityDetector(out IDialogServices dialogServices, string?versionDataString = null, Version?vsVersion = null, bool isSolutionOpen = false, bool hasNewProjects = false, bool usingPreviewSDK = false, bool isCapabilityMatch = true, string targetFrameworkMoniker = ".NETCoreApp,Version=v3.0") { dialogServices = IDialogServicesFactory.Create(); var additionalReference = dialogServices; var projectProperties = IProjectPropertiesFactory.CreateWithPropertyAndValue("TargetFrameworkMoniker", targetFrameworkMoniker); var propertiesProvider = IProjectPropertiesProviderFactory.Create(commonProps: projectProperties); var project = ConfiguredProjectFactory.Create(services: ConfiguredProjectServicesFactory.Create(projectPropertiesProvider: propertiesProvider)); var scope = hasNewProjects ? IProjectCapabilitiesScopeFactory.Create(new[] { ProjectCapability.DotNet, ProjectCapability.PackageReferences }) : null; var projectAccessor = new Lazy <IProjectServiceAccessor>(() => IProjectServiceAccessorFactory.Create(scope, project)); var lazyDialogServices = new Lazy <IDialogServices>(() => additionalReference); var threadHandling = new Lazy <IProjectThreadingService>(() => IProjectThreadingServiceFactory.Create(verifyOnUIThread: false)); var vsShellUtilitiesHelper = new Lazy <IVsShellUtilitiesHelper>(() => IVsShellUtilitiesHelperFactory.Create(string.Empty, vsVersion ?? new Version("16.1"))); var fileSystem = new Lazy <IFileSystem>(() => IFileSystemFactory.Create(existsFunc: x => true, readAllTextFunc: x => versionDataString ?? defaultVersionDataString)); var httpClient = new Lazy <IHttpClient>(() => IHttpClientFactory.Create(versionDataString ?? defaultVersionDataString)); var vsUIShellService = IVsServiceFactory.Create <SVsUIShell, IVsUIShell>(Mock.Of <IVsUIShell>()); var settingsManagerService = IVsServiceFactory.Create <SVsSettingsPersistenceManager, ISettingsManager>(Mock.Of <ISettingsManager>()); var vsSolutionService = IVsServiceFactory.Create <SVsSolution, IVsSolution>(IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(1, isFullyLoaded: isSolutionOpen)); var vsAppIdService = IVsServiceFactory.Create <SVsAppId, IVsAppId>(Mock.Of <IVsAppId>()); var vsShellService = IVsServiceFactory.Create <SVsShell, IVsShell>(Mock.Of <IVsShell>()); var compatibilityDetector = new TestDotNetCoreProjectCompatibilityDetector(projectAccessor, lazyDialogServices, threadHandling, vsShellUtilitiesHelper, fileSystem, httpClient, vsUIShellService, settingsManagerService, vsSolutionService, vsAppIdService, vsShellService, hasNewProjects, usingPreviewSDK, isCapabilityMatch); return(compatibilityDetector); }
private ConsoleDebugTargetsProvider GetDebugTargetsProvider(string outputType = "exe", Dictionary <string, string?>?properties = null, IVsDebugger10?debugger = null, IProjectCapabilitiesScope?scope = null) { _mockFS.WriteAllText(@"c:\test\Project\someapp.exe", ""); _mockFS.CreateDirectory(@"c:\test\Project"); _mockFS.CreateDirectory(@"c:\test\Project\bin\"); _mockFS.WriteAllText(@"c:\program files\dotnet\dotnet.exe", ""); var project = UnconfiguredProjectFactory.Create(filePath: _ProjectFile); var outputTypeEnum = new PageEnumValue(new EnumValue() { Name = outputType }); var data = new PropertyPageData(ConfigurationGeneral.SchemaName, ConfigurationGeneral.OutputTypeProperty, outputTypeEnum); var projectProperties = ProjectPropertiesFactory.Create(project, data); properties ??= new Dictionary <string, string?>() { { "RunCommand", @"dotnet" }, { "RunArguments", "exec " + "\"" + @"c:\test\project\bin\project.dll" + "\"" }, { "RunWorkingDirectory", @"bin\" }, { "TargetFrameworkIdentifier", @".NetCoreApp" }, { "OutDir", @"c:\test\project\bin\" } }; var delegatePropertiesMock = IProjectPropertiesFactory.MockWithPropertiesAndValues(properties); var delegateProvider = IProjectPropertiesProviderFactory.Create(null, delegatePropertiesMock.Object); var configuredProjectServices = Mock.Of <ConfiguredProjectServices>(o => o.ProjectPropertiesProvider == delegateProvider); var capabilitiesScope = scope ?? IProjectCapabilitiesScopeFactory.Create(capabilities: Enumerable.Empty <string>()); var configuredProject = Mock.Of <ConfiguredProject>(o => o.UnconfiguredProject == project && o.Services == configuredProjectServices && o.Capabilities == capabilitiesScope); var environment = IEnvironmentHelperFactory.ImplementGetEnvironmentVariable(_Path); return(CreateInstance(configuredProject: configuredProject, fileSystem: _mockFS, properties: projectProperties, environment: environment, debugger: debugger)); }
internal AbstractAddItemCommandHandler CreateInstance(IPhysicalProjectTree projectTree = null, IUnconfiguredProjectVsServices projectVsServices = null, IProjectTreeProvider provider = null, IVsAddProjectItemDlg addItemDialog = null, string capability = null) { var configuredProject = ConfiguredProjectFactory.Create(IProjectCapabilitiesScopeFactory.Create(new string[] { capability ?? TestAddItemCommand.Capability })); projectTree ??= IPhysicalProjectTreeFactory.Create(provider); projectVsServices ??= IUnconfiguredProjectVsServicesFactory.Implement( threadingServiceCreator: () => IProjectThreadingServiceFactory.Create() ); var addItemDialogService = IVsUIServiceFactory.Create <SVsAddProjectItemDlg, IVsAddProjectItemDlg>(addItemDialog); string result = "DirName"; var vsShellMock = new Mock <IVsShell>(); vsShellMock.Setup(x => x.LoadPackageString(ref It.Ref <Guid> .IsAny, (uint)TestAddItemCommand.ResourceIds.DirName, out result)).Returns(0); result = "TemplateName"; vsShellMock.Setup(x => x.LoadPackageString(ref It.Ref <Guid> .IsAny, (uint)TestAddItemCommand.ResourceIds.TemplateName, out result)).Returns(0); var vsShellService = IVsUIServiceFactory.Create <SVsShell, IVsShell>(vsShellMock.Object); return(new TestAddItemCommand(configuredProject, projectTree, projectVsServices, addItemDialogService, vsShellService)); }
public async Task QueryDebugTargetsAsync_ConsoleAppLaunch_IncludesIntegratedConsoleInLaunchOptions(DebugLaunchOptions launchOptions) { var debugger = IVsDebugger10Factory.ImplementIsIntegratedConsoleEnabled(enabled: true); var properties = new Dictionary <string, string?>() { { "TargetPath", @"C:\ConsoleApp.exe" }, { "TargetFrameworkIdentifier", @".NETFramework" } }; var scope = IProjectCapabilitiesScopeFactory.Create(capabilities: new string[] { ProjectCapabilities.IntegratedConsoleDebugging }); var provider = GetDebugTargetsProvider("exe", properties, debugger, scope); var activeProfile = new LaunchProfile() { Name = "Name", CommandName = "Project" }; var result = await provider.QueryDebugTargetsAsync(launchOptions, activeProfile); Assert.Single(result); Assert.True((result[0].LaunchOptions & DebugLaunchOptions.IntegratedConsole) == DebugLaunchOptions.IntegratedConsole); }
public async Task QueryDebugTargetsAsync_ConsoleAppLaunchWithNoDebuggerWithIntegratedConsoleEnabled_DoesNotWrapInCmd() { var debugger = IVsDebugger10Factory.ImplementIsIntegratedConsoleEnabled(enabled: true); var properties = new Dictionary <string, string?>() { { "TargetPath", @"C:\ConsoleApp.exe" }, { "TargetFrameworkIdentifier", @".NETFramework" } }; var scope = IProjectCapabilitiesScopeFactory.Create(capabilities: new string[] { ProjectCapabilities.IntegratedConsoleDebugging }); var provider = GetDebugTargetsProvider("exe", properties, debugger, scope); var activeProfile = new LaunchProfile() { Name = "Name", CommandName = "Project" }; var result = await provider.QueryDebugTargetsAsync(DebugLaunchOptions.NoDebug, activeProfile); Assert.Single(result); Assert.DoesNotContain("cmd.exe", result[0].Executable); }
public void FiltersItemTemplateFolders_WindowsForms(string templateDir, bool shouldBeFiltered) { var filter = new WindowsFormsAddItemFilter(UnconfiguredProjectFactory.Create(scope: IProjectCapabilitiesScopeFactory.Create(new string[] { "WindowsForms" }))); Guid guid = Guid.Empty; var result = filter.FilterTreeItemByTemplateDir(ref guid, templateDir, out int filterResult); Assert.Equal(0, result); Assert.Equal(shouldBeFiltered, filterResult == 1); }