Skip to content
This repository has been archived by the owner on Nov 9, 2018. It is now read-only.

Commit

Permalink
Follow up to fixing async symbol support
Browse files Browse the repository at this point in the history
Changing signature of ISourceInformationProvider to work with MethodInfo
instead.

Also cleaning up some little issues in unit tests and adding a few
[NotNull]s that were needed.
  • Loading branch information
rynowak committed Aug 11, 2015
1 parent 1941681 commit 8dd3a13
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
5 changes: 4 additions & 1 deletion src/Microsoft.Dnx.TestAdapter/ISourceInformationProvider.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Reflection;
using Microsoft.Framework.Internal;

namespace Microsoft.Dnx.TestAdapter
{
public interface ISourceInformationProvider
{
SourceInformation GetSourceInformation(string className, string methodName);
SourceInformation GetSourceInformation([NotNull] MethodInfo method);
}
}
4 changes: 3 additions & 1 deletion src/Microsoft.Dnx.TestAdapter/ITestDiscoverySink.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.Framework.Internal;

namespace Microsoft.Dnx.TestAdapter
{
public interface ITestDiscoverySink
{
void SendTest(Test test);
void SendTest([NotNull] Test test);
}
}
6 changes: 4 additions & 2 deletions src/Microsoft.Dnx.TestAdapter/ITestExecutionSink.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.Framework.Internal;

namespace Microsoft.Dnx.TestAdapter
{
public interface ITestExecutionSink
{
void RecordStart(Test test);
void RecordStart([NotNull] Test test);

void RecordResult(TestResult testResult);
void RecordResult([NotNull] TestResult testResult);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public SourceInformationProvider(
_logger = logger;
}

public SourceInformation GetSourceInformation(string className, string methodName)
public SourceInformation GetSourceInformation(MethodInfo method)
{
if (!EnsureInitialized())
{
Expand All @@ -57,12 +57,10 @@ public SourceInformation GetSourceInformation(string className, string methodNam
// Note that this doesn't deal gracefully with overloaded methods. Symbol APIs don't provide
// a way to match overloads. We'd really need MetadataTokens to do this correctly (missing in
// CoreCLR).
var method = ResolveBestMethodInfo(className, methodName);
if (method != null)
{
className = method.DeclaringType.FullName;
methodName = method.Name;
}
method = ResolveBestMethodInfo(method);

var className = method.DeclaringType.FullName;
var methodName = method.Name;

// The DIA code doesn't include a + for nested classes, just a dot.
var symbolId = FindMethodSymbolId(className.Replace('+', '.'), methodName);
Expand All @@ -83,22 +81,10 @@ public SourceInformation GetSourceInformation(string className, string methodNam
}
}

private MethodInfo ResolveBestMethodInfo(string className, string methodName)
private MethodInfo ResolveBestMethodInfo(MethodInfo method)
{
Debug.Assert(_isInitialized == true);

var @class = _assembly.GetType(className);
if (@class == null)
{
return null;
}

var method = @class.GetMethods().Where(m => m.Name == methodName).FirstOrDefault();
if (method == null)
{
return null;
}

// If a method has a StateMachineAttribute, then all of the user code will show up
// in the symbols associated with the compiler-generated code. So, we need to look
// for the 'MoveNext' on the generated type and resolve symbols for that.
Expand Down
3 changes: 1 addition & 2 deletions test/Microsoft.Dnx.TestHost.Tests/TestHostTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@ public async Task ListTest()
var fullMessageDiagnostics = string.Format("Full output: \n{0}", string.Join("\n", host.Output));
var testOutput = host.Output.Where(message => message.MessageType != "Log");

Assert.True(10 == testOutput.Count(), "Output count is not 8. \n" + fullMessageDiagnostics);
Assert.True(10 == testOutput.Count(), "Number of messages is not right. \n" + fullMessageDiagnostics);
Assert.Single(host.Output, m => TestFound(m, "SampleTest.True_is_true"));
Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest1(x: 1)"));
Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest1(x: 2)"));
Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest1(x: 3)"));
Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest2(x: 1, s: \"Hi\")"));
Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest2(x: 2, s: \"Hi\")"));
Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest2(x: 3, s: \"Hi\")"));
Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest2(x: 3, s: \"Hi\")"));
Assert.Single(host.Output, m => TestFound(m, "SampleTest.SampleAsyncTest"));
Assert.Single(host.Output, m => TestFound(m, "DerivedTest.ThisGetsInherited"));
Assert.Equal("TestDiscovery.Response", host.Output[host.Output.Count - 1].MessageType);
Expand Down

0 comments on commit 8dd3a13

Please sign in to comment.