Browse Source

Fixed bug in ScriptRunner (for scripts inside file or project templates).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4009 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
af544bac8e
  1. 8
      src/Main/Base/Project/Src/Internal/Templates/File/ScriptRunner.cs

8
src/Main/Base/Project/Src/Internal/Templates/File/ScriptRunner.cs

@ -23,13 +23,15 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -23,13 +23,15 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
FileDescriptionTemplate file;
readonly static Regex scriptRegex = new Regex("<%.*?%>");
readonly static Regex replaceRegex = new Regex("\"");
public string CompileScript(FileTemplate item, FileDescriptionTemplate file)
{
if (file.Content == null)
throw new ArgumentException("file must have textual content");
Match m = scriptRegex.Match(file.Content);
// A file must have at least two "<% %>" segments to be recognized as script.
// I consider this a bug, but we'll keep it for backwards compatibility;
// at least until the ScriptRunner gets replaced by something more sane.
m = m.NextMatch();
if (m.Success) {
this.item = item;
@ -126,13 +128,13 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -126,13 +128,13 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
for (Match m = scriptRegex.Match(file.Content); m.Success; m = m.NextMatch()) {
Group g = m.Groups[0];
outPut.Append("outPut.Append(@\"");
outPut.Append(file.Content.Substring(lastIndex, g.Index - lastIndex));
outPut.Append(file.Content.Substring(lastIndex, g.Index - lastIndex).Replace("\"", "\"\""));
outPut.Append("\");\n");
outPut.Append(g.Value.Substring(2, g.Length - 4));
lastIndex = g.Index + g.Length;
}
outPut.Append("outPut.Append(@\"");
string formattedContent = replaceRegex.Replace(file.Content.Substring(lastIndex, file.Content.Length - lastIndex), "\"\"");
string formattedContent = file.Content.Substring(lastIndex, file.Content.Length - lastIndex).Replace("\"", "\"\"");
outPut.Append(formattedContent);
outPut.Append("\");\n");
outPut.Append("return outPut.ToString();\n");

Loading…
Cancel
Save