From 177fe577124c85a5d9f455050588e3fddc1db377 Mon Sep 17 00:00:00 2001 From: lvv83 Date: Sun, 11 Jan 2015 22:27:46 +0300 Subject: [PATCH] Fix some tests for NUnit (stacktrace parser doesn't work properly if non-english language was set for SD) Some NRefactory refactorings applied --- .../UnitTesting/Model/TestProjectBase.cs | 2 +- .../NUnitTestResultFailureTestFixture.cs | 1 - .../OutputTextLineParser.cs | 24 +++++++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/AddIns/Analysis/UnitTesting/Model/TestProjectBase.cs b/src/AddIns/Analysis/UnitTesting/Model/TestProjectBase.cs index 741a9407a7..3d3f70453e 100644 --- a/src/AddIns/Analysis/UnitTesting/Model/TestProjectBase.cs +++ b/src/AddIns/Analysis/UnitTesting/Model/TestProjectBase.cs @@ -42,7 +42,7 @@ namespace ICSharpCode.UnitTesting IProject project; Dictionary topLevelTestClasses = new Dictionary(); - public TestProjectBase(IProject project) + protected TestProjectBase(IProject project) { if (project == null) throw new ArgumentNullException("project"); diff --git a/src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitTestResultFailureTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitTestResultFailureTestFixture.cs index 27ae8c569b..5c6e5b0e4b 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitTestResultFailureTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitTestResultFailureTestFixture.cs @@ -18,7 +18,6 @@ using System; using ICSharpCode.NRefactory.TypeSystem; -using ICSharpCode.SharpDevelop; using ICSharpCode.UnitTesting; using NUnit.Framework; diff --git a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs index f017dd54d4..446c5773de 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs @@ -95,7 +95,7 @@ namespace ICSharpCode.SharpDevelop.Gui FileLineReference result = null; if (lineText != null) { - Match match = Regex.Match(lineText, GetStackFrameRegex(), regexOptions); + Match match = CreateStackTraceMatch(lineText, regexOptions); while (match.Success) { try { int line = Convert.ToInt32(match.Groups[2].Value); @@ -115,15 +115,25 @@ namespace ICSharpCode.SharpDevelop.Gui .GetMethod("GetResourceString", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new[] { typeof(string) }, null); - static string GetStackFrameRegex() + static Match CreateStackTraceMatch(string lineText, RegexOptions regexOptions) { - string line = "in {0}:line {1}"; + string line = "in {0}:line {1}", pattern; + bool useResourceString = false; + Match match; - if (GetResourceString != null) { + do + { + pattern = line.Replace("{0}", @"(\w:[/\\].*?)").Replace("{1}", @"(\d+)"); + match = Regex.Match(lineText, pattern, regexOptions); + if (useResourceString || match.Success || GetResourceString == null) + break; + line = (string)GetResourceString.Invoke(null, new[] { "StackTrace_InFileLineNumber" }); - } - - return line.Replace("{0}", @"(\w:[/\\].*?)").Replace("{1}", @"(\d+)"); + useResourceString = true; + + } while (true); + + return match; } ///