Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMatt Ward <matt.ward@microsoft.com>2020-01-21 16:09:27 +0300
committerMatt Ward <ward.matt@gmail.com>2020-01-21 22:32:25 +0300
commitd15e5c67513b793ec1a27fdd0a5ed7e7817303e2 (patch)
tree5f1462395ddef07593105a99c5bbd29c93149c62 /main
parentd02f67c11fa055b67b5e55c0b344706a49ec1e40 (diff)
[Core] Ensure multi-run config updated after project reload
With a multi-run configuration defined for the solution, if a project is reloaded, the multi-run config would not have the latest project run configuration. This would result in changes to the project run configuration in project options, such as adding or removing startup arguments, not being used when the multi-run configuration was used to run the solution. On reloading the new project run configuration is resolved and updated in the multi-run configuration. Previously only the SolutionItem was updated. Fixes VSTS #653269 - Multi startup project run configuration - arguments not passed after reload
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects/MultiItemSolutionRunConfiguration.cs17
-rw-r--r--main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/SolutionTests.cs34
-rw-r--r--main/tests/test-projects/test-multi-run-config-reload/ProjectA/Program.cs12
-rw-r--r--main/tests/test-projects/test-multi-run-config-reload/ProjectA/ProjectA.csproj43
-rw-r--r--main/tests/test-projects/test-multi-run-config-reload/ProjectA/Properties/AssemblyInfo.cs26
-rw-r--r--main/tests/test-projects/test-multi-run-config-reload/ProjectB/Program.cs13
-rw-r--r--main/tests/test-projects/test-multi-run-config-reload/ProjectB/ProjectB.csproj43
-rw-r--r--main/tests/test-projects/test-multi-run-config-reload/ProjectB/Properties/Properties27
-rw-r--r--main/tests/test-projects/test-multi-run-config-reload/test-multi-run-config-reload.sln23
9 files changed, 234 insertions, 4 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/MultiItemSolutionRunConfiguration.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/MultiItemSolutionRunConfiguration.cs
index 451944c78c..ea4a56fc8d 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/MultiItemSolutionRunConfiguration.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/MultiItemSolutionRunConfiguration.cs
@@ -75,8 +75,12 @@ namespace MonoDevelop.Projects
internal void ReplaceItem (SolutionItem oldItem, SolutionItem newItem)
{
foreach (var si in Items)
- if (si.SolutionItem == oldItem)
+ if (si.SolutionItem == oldItem) {
si.SolutionItem = newItem;
+
+ // SolutionItem's RunConfiguration will have been reloaded. Ensure the new run config is used.
+ si.ResolveRunConfiguration ();
+ }
}
internal void RemoveItem (SolutionItem item)
@@ -159,13 +163,18 @@ namespace MonoDevelop.Projects
SolutionItem = sol.GetSolutionItem (ItemId) as SolutionItem;
if (SolutionItem == null)
SolutionItem = sol.FindProjectByName (ItemName) as SolutionItem;
- if (SolutionItem != null && ConfigurationId != null)
- RunConfiguration = SolutionItem.GetRunConfigurations ().FirstOrDefault (c => c.Id == ConfigurationId);
+ ResolveRunConfiguration ();
ItemId = null;
ConfigurationId = null;
}
}
-
+
+ internal void ResolveRunConfiguration ()
+ {
+ if (SolutionItem != null && ConfigurationId != null)
+ RunConfiguration = SolutionItem.GetRunConfigurations ().FirstOrDefault (c => c.Id == ConfigurationId);
+ }
+
public SolutionItem SolutionItem { get; internal set; }
public SolutionItemRunConfiguration RunConfiguration { get; internal set; }
}
diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/SolutionTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/SolutionTests.cs
index fb969dc51c..fbac6af29c 100644
--- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/SolutionTests.cs
+++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/SolutionTests.cs
@@ -1055,6 +1055,40 @@ namespace MonoDevelop.Projects
WorkspaceObject.UnregisterCustomExtension (en);
}
}
+
+ [Test]
+ public async Task MultiRunConfig_ReloadProject_ProjectRunConfigUpdatedInMultiRunConfig ()
+ {
+ string solFile = Util.GetSampleProject ("test-multi-run-config-reload", "test-multi-run-config-reload.sln");
+
+ using (var sol = (Solution)await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile)) {
+ var projectA = (DotNetProject)sol.FindProjectByName ("ProjectA");
+ var projectB = (DotNetProject)sol.FindProjectByName ("ProjectB");
+ Assert.IsNotNull (projectA);
+ Assert.IsNotNull (projectB);
+
+ var multiRunConfig = new MultiItemSolutionRunConfiguration ("MultiTestId", "multi");
+ var startupItem1 = new StartupItem (projectA, projectA.RunConfigurations.Single ());
+ multiRunConfig.Items.Add (startupItem1);
+
+ var startupItem2 = new StartupItem (projectB, projectB.RunConfigurations.Single ());
+ multiRunConfig.Items.Add (startupItem2);
+
+ sol.MultiStartupRunConfigurations.Add (multiRunConfig);
+
+ await sol.RootFolder.ReloadItem (Util.GetMonitor (), projectA);
+
+ // Ensure latest project instance is used by getting them from the solution again.
+ projectA = (DotNetProject)sol.FindProjectByName ("ProjectA");
+ projectB = (DotNetProject)sol.FindProjectByName ("ProjectB");
+
+ var runConfigA = multiRunConfig.Items.Single (item => item.SolutionItem == projectA);
+ Assert.AreEqual (projectA.RunConfigurations.Single (), runConfigA.RunConfiguration, "Multi-run config does not match project's run config (ProjectA)");
+
+ var runConfigB = multiRunConfig.Items.Single (item => item.SolutionItem == projectB);
+ Assert.AreEqual (projectB.RunConfigurations.Single (), runConfigB.RunConfiguration, "Multi-run config does not match project's run config (ProjectB)");
+ }
+ }
}
class SomeItem: SolutionItem
diff --git a/main/tests/test-projects/test-multi-run-config-reload/ProjectA/Program.cs b/main/tests/test-projects/test-multi-run-config-reload/ProjectA/Program.cs
new file mode 100644
index 0000000000..5ecf514c73
--- /dev/null
+++ b/main/tests/test-projects/test-multi-run-config-reload/ProjectA/Program.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace ProjectA
+{
+ class MainClass
+ {
+ public static void Main (string[] args)
+ {
+ Console.WriteLine ("Project A: args.Length={0}", args.Length);
+ }
+ }
+}
diff --git a/main/tests/test-projects/test-multi-run-config-reload/ProjectA/ProjectA.csproj b/main/tests/test-projects/test-multi-run-config-reload/ProjectA/ProjectA.csproj
new file mode 100644
index 0000000000..e4a22dee09
--- /dev/null
+++ b/main/tests/test-projects/test-multi-run-config-reload/ProjectA/ProjectA.csproj
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">anycpu</Platform>
+ <ProjectGuid>{1217D2CD-2C77-4AEF-AC43-418FC5DD7CE9}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>ProjectA</RootNamespace>
+ <AssemblyName>ProjectA</AssemblyName>
+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|anycpu' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ExternalConsole>true</ExternalConsole>
+ <IntermediateOutputPath>obj\anycpu\Debug</IntermediateOutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|anycpu' ">
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ExternalConsole>true</ExternalConsole>
+ <IntermediateOutputPath>obj\anycpu\Release</IntermediateOutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
+ <StartAction>Project</StartAction>
+ <StartArguments>A1</StartArguments>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/test-multi-run-config-reload/ProjectA/Properties/AssemblyInfo.cs b/main/tests/test-projects/test-multi-run-config-reload/ProjectA/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..241be46e6f
--- /dev/null
+++ b/main/tests/test-projects/test-multi-run-config-reload/ProjectA/Properties/AssemblyInfo.cs
@@ -0,0 +1,26 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle ("ProjectA")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("Microsoft")]
+[assembly: AssemblyProduct ("")]
+[assembly: AssemblyCopyright ("Microsoft Corporation")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion ("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
diff --git a/main/tests/test-projects/test-multi-run-config-reload/ProjectB/Program.cs b/main/tests/test-projects/test-multi-run-config-reload/ProjectB/Program.cs
new file mode 100644
index 0000000000..efd3edfec0
--- /dev/null
+++ b/main/tests/test-projects/test-multi-run-config-reload/ProjectB/Program.cs
@@ -0,0 +1,13 @@
+
+using System;
+
+namespace ProjectB
+{
+ class MainClass
+ {
+ public static void Main (string[] args)
+ {
+ Console.WriteLine ("Project A: args.Length={0}", args.Length);
+ }
+ }
+}
diff --git a/main/tests/test-projects/test-multi-run-config-reload/ProjectB/ProjectB.csproj b/main/tests/test-projects/test-multi-run-config-reload/ProjectB/ProjectB.csproj
new file mode 100644
index 0000000000..6eb3523f3f
--- /dev/null
+++ b/main/tests/test-projects/test-multi-run-config-reload/ProjectB/ProjectB.csproj
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">anycpu</Platform>
+ <ProjectGuid>{2D669FEF-FBF4-4183-87E6-A3A4D6C8C97F}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>ProjectB</RootNamespace>
+ <AssemblyName>ProjectB</AssemblyName>
+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|anycpu' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ExternalConsole>true</ExternalConsole>
+ <IntermediateOutputPath>obj\anycpu\Debug</IntermediateOutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|anycpu' ">
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ExternalConsole>true</ExternalConsole>
+ <IntermediateOutputPath>obj\anycpu\Release</IntermediateOutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
+ <StartAction>Project</StartAction>
+ <StartArguments>B1 B2</StartArguments>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/test-multi-run-config-reload/ProjectB/Properties/Properties b/main/tests/test-projects/test-multi-run-config-reload/ProjectB/Properties/Properties
new file mode 100644
index 0000000000..35b79e04df
--- /dev/null
+++ b/main/tests/test-projects/test-multi-run-config-reload/ProjectB/Properties/Properties
@@ -0,0 +1,27 @@
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle ("ProjectB")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("Microsoft")]
+[assembly: AssemblyProduct ("")]
+[assembly: AssemblyCopyright ("Microsoft Corporation")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion ("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
diff --git a/main/tests/test-projects/test-multi-run-config-reload/test-multi-run-config-reload.sln b/main/tests/test-projects/test-multi-run-config-reload/test-multi-run-config-reload.sln
new file mode 100644
index 0000000000..4a7cf57fa7
--- /dev/null
+++ b/main/tests/test-projects/test-multi-run-config-reload/test-multi-run-config-reload.sln
@@ -0,0 +1,23 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectA", "ProjectA\ProjectA.csproj", "{1217D2CD-2C77-4AEF-AC43-418FC5DD7CE9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectB", "ProjectB\ProjectB.csproj", "{2D669FEF-FBF4-4183-87E6-A3A4D6C8C97F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|anycpu = Debug|anycpu
+ Release|anycpu = Release|anycpu
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1217D2CD-2C77-4AEF-AC43-418FC5DD7CE9}.Debug|anycpu.ActiveCfg = Debug|anycpu
+ {1217D2CD-2C77-4AEF-AC43-418FC5DD7CE9}.Debug|anycpu.Build.0 = Debug|anycpu
+ {1217D2CD-2C77-4AEF-AC43-418FC5DD7CE9}.Release|anycpu.ActiveCfg = Release|anycpu
+ {1217D2CD-2C77-4AEF-AC43-418FC5DD7CE9}.Release|anycpu.Build.0 = Release|anycpu
+ {2D669FEF-FBF4-4183-87E6-A3A4D6C8C97F}.Debug|anycpu.ActiveCfg = Debug|anycpu
+ {2D669FEF-FBF4-4183-87E6-A3A4D6C8C97F}.Debug|anycpu.Build.0 = Debug|anycpu
+ {2D669FEF-FBF4-4183-87E6-A3A4D6C8C97F}.Release|anycpu.ActiveCfg = Release|anycpu
+ {2D669FEF-FBF4-4183-87E6-A3A4D6C8C97F}.Release|anycpu.Build.0 = Release|anycpu
+ EndGlobalSection
+EndGlobal