OpenRA/OpenRA — pull request #2409 by ihptru (2012-09-12 19:27:49+00:00)
Title: fix #2407; Character \# cannot be escaped in settings file

Another fix would be:

if (line.Contains('#'))
{
var commentIndex = line.IndexOf('#');
var previousIndex = commentIndex - 1;
if (commentIndex == 0 || line[previousIndex] != '\\')
line = line.Substring(0, commentIndex).TrimEnd(' ', '\t');
}

but this would ignore #bar in next line:
name\#foo#bar