Browse Source

Ignore invalid entries in SolutionConfigurationPlatforms section.

pull/315/head
Daniel Grunwald 12 years ago
parent
commit
c3025fab39
  1. 3
      src/Main/Base/Project/Project/Configuration/ConfigurationAndPlatform.cs
  2. 20
      src/Main/Base/Test/Project/SolutionLoaderTests.cs
  3. 5
      src/Main/SharpDevelop/Project/SolutionLoader.cs

3
src/Main/Base/Project/Project/Configuration/ConfigurationAndPlatform.cs

@ -28,6 +28,8 @@ namespace ICSharpCode.SharpDevelop.Project @@ -28,6 +28,8 @@ namespace ICSharpCode.SharpDevelop.Project
/// <summary>
/// Gets configuration and platform from an MSBuild condition in the format "'$(Configuration)|$(Platform)' == 'configuration|platform'".
/// If the condition only tests the configuration, the platform property will be null (and vice versa).
/// If the condition is not recognized, both condition and platform of the result will be null.
/// </summary>
public static ConfigurationAndPlatform FromCondition(string condition)
{
@ -52,6 +54,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -52,6 +54,7 @@ namespace ICSharpCode.SharpDevelop.Project
/// <summary>
/// Gets configuration and platform from a key string in the format 'configuration|platform'.
/// If the key string has an invalid format, both condition and platform of the result will be null.
/// </summary>
public static ConfigurationAndPlatform FromKey(string key)
{

20
src/Main/Base/Test/Project/SolutionLoaderTests.cs

@ -30,5 +30,25 @@ namespace ICSharpCode.SharpDevelop.Project @@ -30,5 +30,25 @@ namespace ICSharpCode.SharpDevelop.Project
Assert.AreEqual("{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg", entries[1].Key);
Assert.AreEqual("Release|Any CPU", entries[1].Value);
}
[Test]
public void DescriptionInSolutionConfigurationPlatforms()
{
// http://community.sharpdevelop.net/forums/t/19948.aspx
string input = "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution" + Environment.NewLine +
"\t\tDebug|Any CPU = Debug|Any CPU" + Environment.NewLine +
"\t\tRelease|Any CPU = Release|Any CPU" + Environment.NewLine +
"\t\tDescription = Some fancy description of the application." + Environment.NewLine +
"\tEndGlobalSection" + Environment.NewLine;
var loader = new SolutionLoader(new StringReader(input));
SolutionSection section = loader.ReadSection(isGlobal: true);
var configs = loader.LoadSolutionConfigurations(section).ToArray();
Assert.AreEqual(new[] {
new ConfigurationAndPlatform("Debug", "Any CPU"),
new ConfigurationAndPlatform("Release", "Any CPU")
}, configs);
}
}
}

5
src/Main/SharpDevelop/Project/SolutionLoader.cs

@ -285,10 +285,11 @@ namespace ICSharpCode.SharpDevelop.Project @@ -285,10 +285,11 @@ namespace ICSharpCode.SharpDevelop.Project
#endregion
#region Load Configurations
IEnumerable<ConfigurationAndPlatform> LoadSolutionConfigurations(IEnumerable<KeyValuePair<string, string>> section)
internal IEnumerable<ConfigurationAndPlatform> LoadSolutionConfigurations(IEnumerable<KeyValuePair<string, string>> section)
{
// Entries in the section look like this: 'Debug|Any CPU = Debug|Any CPU'
return section.Select(e => ConfigurationAndPlatform.FromKey(e.Key));
return section.Select(e => ConfigurationAndPlatform.FromKey(e.Key))
.Where(e => ConfigurationAndPlatform.IsValidName(e.Configuration) && ConfigurationAndPlatform.IsValidName(e.Platform));
}
void LoadProjectConfigurations(SolutionSection section, Dictionary<Guid, ProjectLoadInformation> projectInfoDict)

Loading…
Cancel
Save