diff options
Diffstat (limited to 'main/src/addins/NUnit/Services')
-rw-r--r-- | main/src/addins/NUnit/Services/BinaryResultsStore.cs | 2 | ||||
-rw-r--r-- | main/src/addins/NUnit/Services/NUnitProjectTestSuite.cs | 39 |
2 files changed, 30 insertions, 11 deletions
diff --git a/main/src/addins/NUnit/Services/BinaryResultsStore.cs b/main/src/addins/NUnit/Services/BinaryResultsStore.cs index c6d0eca036..dc0581e209 100644 --- a/main/src/addins/NUnit/Services/BinaryResultsStore.cs +++ b/main/src/addins/NUnit/Services/BinaryResultsStore.cs @@ -24,9 +24,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; -using ICSharpCode.NRefactory.Utils; using System.Xml.Serialization; using System.IO; +using ICSharpCode.NRefactory6.Utils; namespace MonoDevelop.NUnit { diff --git a/main/src/addins/NUnit/Services/NUnitProjectTestSuite.cs b/main/src/addins/NUnit/Services/NUnitProjectTestSuite.cs index 6a789d36ba..e7381ff1ae 100644 --- a/main/src/addins/NUnit/Services/NUnitProjectTestSuite.cs +++ b/main/src/addins/NUnit/Services/NUnitProjectTestSuite.cs @@ -34,8 +34,9 @@ using System.Collections.Generic; using MonoDevelop.Projects; using MonoDevelop.Ide; using MonoDevelop.Ide.TypeSystem; -using ICSharpCode.NRefactory.TypeSystem; using System; +using Microsoft.CodeAnalysis; +using System.Threading; using ProjectReference = MonoDevelop.Projects.ProjectReference; namespace MonoDevelop.NUnit @@ -82,27 +83,45 @@ namespace MonoDevelop.NUnit { if (string.IsNullOrEmpty (fixtureTypeName) || string.IsNullOrEmpty (fixtureTypeName)) return null; - var ctx = TypeSystemService.GetCompilation (project); - var cls = ctx.MainAssembly.GetTypeDefinition (fixtureTypeNamespace ?? "", fixtureTypeName, 0); + var csc = new CancellationTokenSource (); + var task = TypeSystemService.GetCompilationAsync (project, csc.Token); + task.Wait (2000); + if (!task.IsCompleted) { + csc.Cancel (); + return null; + } + var ctx = task.Result; + var cls = ctx.Assembly.GetTypeByMetadataName (string.IsNullOrEmpty (fixtureTypeNamespace) ? fixtureTypeName : fixtureTypeNamespace + "." + fixtureTypeName); if (cls == null) return null; if (cls.Name != methodName) { - foreach (var met in cls.GetMethods ()) { - if (met.Name == methodName) - return new SourceCodeLocation (met.Region.FileName, met.Region.BeginLine, met.Region.BeginColumn); + foreach (var met in cls.GetMembers ().OfType<IMethodSymbol> ()) { + if (met.Name == methodName) { + var loc = met.Locations.FirstOrDefault (l => l.IsInSource); + return ConvertToSourceCodeLocation (loc); + } } int idx = methodName != null ? methodName.IndexOf ('(') : -1; if (idx > 0) { methodName = methodName.Substring (0, idx); - foreach (var met in cls.GetMethods ()) { - if (met.Name == methodName) - return new SourceCodeLocation (met.Region.FileName, met.Region.BeginLine, met.Region.BeginColumn); + foreach (var met in cls.GetMembers ().OfType<IMethodSymbol> ()) { + if (met.Name == methodName){ + var loc = met.Locations.FirstOrDefault (l => l.IsInSource); + return ConvertToSourceCodeLocation (loc); + } } } } - return new SourceCodeLocation (cls.Region.FileName, cls.Region.BeginLine, cls.Region.BeginColumn); + var classLoc = cls.Locations.FirstOrDefault (l => l.IsInSource); + return ConvertToSourceCodeLocation (classLoc); + } + + SourceCodeLocation ConvertToSourceCodeLocation (Location loc) + { + var lineSpan = loc.GetLineSpan (); + return new SourceCodeLocation (loc.SourceTree.FilePath, lineSpan.StartLinePosition.Line, lineSpan.StartLinePosition.Character); } public override void Dispose () |