public DebugTokenReplacer(IUnconfiguredProjectCommonServices unconnfiguredServices, IEnvironmentHelper environmentHelper, IActiveDebugFrameworkServices activeDebugFrameworkService) { UnconfiguredServices = unconnfiguredServices; EnvironmentHelper = environmentHelper; ActiveDebugFrameworkService = activeDebugFrameworkService; }
public ProjectLaunchTargetsProvider( IUnconfiguredProjectVsServices unconfiguredProjectVsServices, ConfiguredProject project, IDebugTokenReplacer tokenReplacer, IFileSystem fileSystem, IEnvironmentHelper environment, IActiveDebugFrameworkServices activeDebugFramework, ProjectProperties properties, IProjectThreadingService threadingService, IVsUIService <SVsShellDebugger, IVsDebugger10> debugger, IRemoteDebuggerAuthenticationService remoteDebuggerAuthenticationService, Lazy <IProjectHotReloadSessionManager> hotReloadSessionManager, Lazy <IHotReloadOptionService> debuggerSettings) { _project = project; _unconfiguredProjectVsServices = unconfiguredProjectVsServices; _tokenReplacer = tokenReplacer; _fileSystem = fileSystem; _environment = environment; _activeDebugFramework = activeDebugFramework; _threadingService = threadingService; _debugger = debugger; _remoteDebuggerAuthenticationService = remoteDebuggerAuthenticationService; _hotReloadSessionManager = hotReloadSessionManager; _debuggerSettings = debuggerSettings; _outputTypeChecker = new OutputTypeChecker(properties); }
public async Task ReplaceTokensInStringTests(string input, string expected, bool expandEnvVars) { IUnconfiguredProjectCommonServices services = IUnconfiguredProjectCommonServicesFactory.Create(); IActiveDebugFrameworkServices activeDebugFramework = Mock.Of <IActiveDebugFrameworkServices>(); var replacer = new DebugTokenReplacerUnderTest(IUnconfiguredProjectCommonServicesFactory.Create(), _envHelper.Object, activeDebugFramework); // Test msbuild vars string result = await replacer.ReplaceTokensInStringAsync(input, expandEnvVars); Assert.Equal(expected, result); }
internal StartupProjectSingleTargetGlobalBuildPropertyProvider( IProjectService projectService, ConfiguredProject configuredProject, IActiveDebugFrameworkServices activeDebugFrameworkServices, IImplicitlyTriggeredBuildState implicitlyTriggeredBuildState, IProjectSystemOptions projectSystemOptions) : base(projectService.Services) { _configuredProject = configuredProject; _activeDebugFrameworkServices = activeDebugFrameworkServices; _implicitlyTriggeredBuildState = implicitlyTriggeredBuildState; _projectSystemOptions = projectSystemOptions; }
public ConsoleDebugTargetsProvider(ConfiguredProject configuredProject, IDebugTokenReplacer tokenReplacer, IFileSystem fileSystem, IEnvironmentHelper environment, IActiveDebugFrameworkServices activeDebugFramework, ProjectProperties properties) { TokenReplacer = tokenReplacer; TheFileSystem = fileSystem; TheEnvironment = environment; ActiveDebugFramework = activeDebugFramework; Properties = properties; UnconfiguredProject = configuredProject.UnconfiguredProject; }
public ConsoleDebugTargetsProvider(UnconfiguredProject project, IDebugTokenReplacer tokenReplacer, IFileSystem fileSystem, IEnvironmentHelper environment, IActiveDebugFrameworkServices activeDebugFramework, ProjectProperties properties) { _tokenReplacer = tokenReplacer; _fileSystem = fileSystem; _environment = environment; _activeDebugFramework = activeDebugFramework; _properties = properties; _project = project; }
public ConsoleDebugTargetsProvider(UnconfiguredProject project, IDebugTokenReplacer tokenReplacer, IFileSystem fileSystem, IEnvironmentHelper environment, IActiveDebugFrameworkServices activeDebugFramework, ProjectProperties properties, IProjectThreadingService threadingService, IVsUIService <SVsShellDebugger, IVsDebugger10> debugger) { _tokenReplacer = tokenReplacer; _fileSystem = fileSystem; _environment = environment; _activeDebugFramework = activeDebugFramework; _properties = properties; _threadingService = threadingService; _debugger = debugger; _project = project; }
private ConsoleDebugTargetsProvider CreateInstance(UnconfiguredProject project = null, ConfiguredProject configuredProject = null, IDebugTokenReplacer tokenReplacer = null, IFileSystem fileSystem = null, IEnvironmentHelper environment = null, IActiveDebugFrameworkServices activeDebugFramework = null, ProjectProperties properties = null, IProjectThreadingService threadingService = null, IVsDebugger10 debugger = null) { environment ??= Mock.Of <IEnvironmentHelper>(); tokenReplacer ??= IDebugTokenReplacerFactory.Create(); activeDebugFramework ??= IActiveDebugFrameworkServicesFactory.ImplementGetConfiguredProjectForActiveFrameworkAsync(configuredProject); threadingService ??= IProjectThreadingServiceFactory.Create(); debugger ??= IVsDebugger10Factory.ImplementIsIntegratedConsoleEnabled(enabled: false); return(new ConsoleDebugTargetsProvider(project, tokenReplacer, fileSystem, environment, activeDebugFramework, properties, threadingService, IVsUIServiceFactory.Create <SVsShellDebugger, IVsDebugger10>(debugger))); }
/// <summary> /// Called by the base when one of our menu ids is queried for. If the index is /// is greater than the count we want to return false /// </summary> public override bool QueryStatusCommand(int cmdIndex, EventArgs e) { IActiveDebugFrameworkServices activeDebugFramework = StartupProjectHelper.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles); if (activeDebugFramework != null) { // See if this project supports at least two runtimes List <string> frameworks = null; string activeFramework = null; ExecuteSynchronously(async() => { frameworks = await activeDebugFramework.GetProjectFrameworksAsync().ConfigureAwait(false); if (frameworks != null && frameworks.Count > 1 && cmdIndex < frameworks.Count) { // Only call this if we will need it down below. activeFramework = await activeDebugFramework.GetActiveDebuggingFrameworkPropertyAsync().ConfigureAwait(false); } }); if (frameworks == null || frameworks.Count < 2) { // Hide and disable the command Visible = false; Enabled = false; Checked = false; return(true); } else if (cmdIndex >= 0 && cmdIndex < frameworks.Count) { Text = frameworks[cmdIndex]; Visible = true; Enabled = true; // Get's a check if it matches the active one, or there is no active one in which case the first one is the active one Checked = (string.IsNullOrEmpty(activeFramework) && cmdIndex == 0) || string.Equals(frameworks[cmdIndex], activeFramework, StringComparison.Ordinal); MatchedCommandId = 0; return(true); } } return(false); }
/// <summary> /// CAlled by the base when one if our menu ids is clicked. Need to return true if the command was handled /// </summary> public override bool ExecCommand(int cmdIndex, EventArgs e) { bool handled = false; IActiveDebugFrameworkServices activeDebugFramework = StartupProjectHelper.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles); if (activeDebugFramework != null) { ExecuteSynchronously(async() => { List <string> frameworks = await activeDebugFramework.GetProjectFrameworksAsync().ConfigureAwait(false); if (frameworks != null && cmdIndex >= 0 && cmdIndex < frameworks.Count) { await activeDebugFramework.SetActiveDebuggingFrameworkPropertyAsync(frameworks[cmdIndex]).ConfigureAwait(false); handled = true; } }); } return(handled); }
public ProjectLaunchTargetsProvider( IUnconfiguredProjectVsServices unconfiguredProjectVsServices, ConfiguredProject project, IDebugTokenReplacer tokenReplacer, IFileSystem fileSystem, IEnvironmentHelper environment, IActiveDebugFrameworkServices activeDebugFramework, ProjectProperties properties, IProjectThreadingService threadingService, IVsUIService <SVsShellDebugger, IVsDebugger10> debugger, IRemoteDebuggerAuthenticationService remoteDebuggerAuthenticationService) { _project = project; _unconfiguredProjectVsServices = unconfiguredProjectVsServices; _tokenReplacer = tokenReplacer; _fileSystem = fileSystem; _environment = environment; _activeDebugFramework = activeDebugFramework; _properties = properties; _threadingService = threadingService; _debugger = debugger; _remoteDebuggerAuthenticationService = remoteDebuggerAuthenticationService; }
public async Task ReplaceTokensInProfileTests() { IUnconfiguredProjectCommonServices services = IUnconfiguredProjectCommonServicesFactory.Create(); IActiveDebugFrameworkServices activeDebugFramework = Mock.Of <IActiveDebugFrameworkServices>(); var replacer = new DebugTokenReplacerUnderTest(IUnconfiguredProjectCommonServicesFactory.Create(), _envHelper.Object, activeDebugFramework); // Tests all the possible replacements. env3 tests that enviroment vars are resolved before msbuild tokens var launchProfile = new LaunchProfile() { Name = "$(msbuildProperty1)", CommandLineArgs = "%env1%", CommandName = "$(msbuildProperty2)", ExecutablePath = "$(test this string", // Not a valid token WorkingDirectory = "c:\\test\\%env3%", LaunchBrowser = false, LaunchUrl = "http://localhost:8080/$(unknownproperty)", EnvironmentVariables = ImmutableDictionary <string, string> .Empty.Add("var1", "%env1%").Add("var2", "$(msbuildProperty3)"), OtherSettings = ImmutableDictionary <string, object> .Empty.Add("setting1", "%env1%").Add("setting2", true), }; var resolvedProfile = await replacer.ReplaceTokensInProfileAsync(launchProfile); // Name and Command name should never be touched Assert.Equal("$(msbuildProperty1)", resolvedProfile.Name); Assert.Equal("$(msbuildProperty2)", resolvedProfile.CommandName); Assert.Equal("envVariable1", resolvedProfile.CommandLineArgs); Assert.Equal("$(test this string", resolvedProfile.ExecutablePath); Assert.False(resolvedProfile.LaunchBrowser); Assert.Equal("http://localhost:8080/", resolvedProfile.LaunchUrl); Assert.Equal("c:\\test\\Property6", resolvedProfile.WorkingDirectory); Assert.Equal("envVariable1", resolvedProfile.EnvironmentVariables["var1"]); Assert.Equal("Property3", resolvedProfile.EnvironmentVariables["var2"]); Assert.Equal("envVariable1", resolvedProfile.OtherSettings["setting1"]); Assert.True((bool)resolvedProfile.OtherSettings["setting2"]); }
public void QueryStatus() { IActiveDebugFrameworkServices activeDebugFramework = StartupProjectHelper.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles); if (activeDebugFramework != null) { string activeFramework = null; List <string> frameworks = null; ExecuteSynchronously(async() => { frameworks = await activeDebugFramework.GetProjectFrameworksAsync(); if (frameworks != null && frameworks.Count > 1) { // Only get this if we will need it down below activeFramework = await activeDebugFramework.GetActiveDebuggingFrameworkPropertyAsync(); } }); if (frameworks != null && frameworks.Count > 1) { // If no active framework or the current active property doesn't match any of the frameworks, then // st it to the first one. if (!string.IsNullOrEmpty(activeFramework) && frameworks.Contains(activeFramework)) { Text = string.Format(VSResources.DebugFrameworkMenuText, activeFramework); } else { Text = string.Format(VSResources.DebugFrameworkMenuText, frameworks[0]); } Visible = true; Enabled = true; } } }
public DebugTokenReplacerUnderTest(IUnconfiguredProjectCommonServices commonServices, IEnvironmentHelper envHelper, IActiveDebugFrameworkServices debugFramework) : base(commonServices, envHelper, debugFramework) { }
public DebugTokenReplacer(IEnvironmentHelper environmentHelper, IActiveDebugFrameworkServices activeDebugFrameworkService, IProjectAccessor projectAccessor) { EnvironmentHelper = environmentHelper; ActiveDebugFrameworkService = activeDebugFrameworkService; ProjectAccessor = projectAccessor; }
ConsoleDebugTargetsProvider GetDebugTargetsProvider(string outputType = "exe", Dictionary <string, string> properties = 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", ""); LaunchProfile activeProfile = new LaunchProfile() { Name = "MyApplication", CommandLineArgs = "--someArgs", ExecutablePath = @"c:\test\Project\someapp.exe" }; _mockEnvironment.Setup(s => s.GetEnvironmentVariable("Path")).Returns(() => _Path); var project = UnconfiguredProjectFactory.Create(null, null, _ProjectFile); var outputTypeEnum = new PageEnumValue(new EnumValue() { Name = outputType }); var data = new PropertyPageData() { Category = ConfigurationGeneral.SchemaName, PropertyName = ConfigurationGeneral.OutputTypeProperty, Value = outputTypeEnum }; var projectProperties = ProjectPropertiesFactory.Create(project, data); if (properties == null) { properties = new Dictionary <string, string>() { { "RunCommand", @"dotnet" }, { "RunArguments", "exec " + "\"" + @"c:\test\project\bin\project.dll" + "\"" }, { "RunWorkingDirectory", @"bin\" }, { "TargetFrameworkIdentifier", @".NetCoreApp" } }; } var delegatePropertiesMock = IProjectPropertiesFactory .MockWithPropertiesAndValues(properties); var delegateProvider = IProjectPropertiesProviderFactory.Create(null, delegatePropertiesMock.Object); IConfiguredProjectServices configuredProjectServices = Mock.Of <IConfiguredProjectServices>(o => o.ProjectPropertiesProvider == delegateProvider); ConfiguredProject configuredProject = Mock.Of <ConfiguredProject>(o => o.UnconfiguredProject == project && o.Services == configuredProjectServices); _mockTokenReplace.Setup(s => s.ReplaceTokensInProfileAsync(It.IsAny <ILaunchProfile>())).Returns <ILaunchProfile>(p => Task.FromResult(p)); IActiveDebugFrameworkServices activeDebugFramework = Mock.Of <IActiveDebugFrameworkServices>(o => o.GetConfiguredProjectForActiveFrameworkAsync() == Task.FromResult(configuredProject)); var debugProvider = new ConsoleDebugTargetsProvider( configuredProject, _mockTokenReplace.Object, _mockFS, _mockEnvironment.Object, activeDebugFramework, projectProperties); return(debugProvider); }