Skip to content

Commit

Permalink
Fix issue #125 - certain Clang Task string comparisons were not takin…
Browse files Browse the repository at this point in the history
…g into

account locale when doing ToLower.
  • Loading branch information
bdrlamb-ms committed Sep 3, 2015
1 parent 2a66959 commit e8f7b91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Binary file modified msvc/ClangCompileTask.dll
Binary file not shown.
8 changes: 7 additions & 1 deletion msvc/task/ClangCompileTask/ClangCompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Diagnostics;
using Microsoft.Win32;
using System.Threading;
using System.Globalization;

namespace ClangCompile
{
Expand Down Expand Up @@ -382,6 +383,9 @@ string DecorateFile(string path, string extension)

string GetSpecial(string name, object value, ITaskItem input)
{
// ToLower is affected by localization. Need to be careful here.
name = name.ToLower(new CultureInfo("en-US", false));

if (value == null)
{
if (name == "inputfilename")
Expand Down Expand Up @@ -898,6 +902,8 @@ private string filterAdditionalOptions(string opts)
#endregion

#region ToolTask Overrides
// ToLower() is affected by localization.
// Be VERY careful when adding static strings to the dictionary, since lookup is also done with ToLower.
static Dictionary<string, PropertyInfo> AllProps = typeof(Clang).GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance).ToDictionary(x => x.Name.ToLower());

protected override string GenerateFullPathToTool()
Expand Down Expand Up @@ -928,7 +934,7 @@ private string ReplaceOptions(string commandLine, ITaskItem input)
PropertyPageAttribute ppAttr = (PropertyPageAttribute)Attribute.GetCustomAttribute(pInfo, typeof(PropertyPageAttribute));
string propSwitch = ppAttr.Switch;
object value = pInfo.GetValue(this);
string propVal = GetSpecial(autoSubst.ToLower(), value, input);
string propVal = GetSpecial(autoSubst, value, input);

if (propVal != null && propVal != "")
{
Expand Down

0 comments on commit e8f7b91

Please sign in to comment.