Build/Test Issues

Code coverage missing when using dynamic keyword

Started by gravypower on 7,052 views

Hello,

I am having an issue when using the dynamic keyword.

When I have test like this:

[Test]
public void DynamicKeyword()
{
dynamic o = new ExpandoObject();
o.Foo = "Bar";
Assert.That(o.Foo, Is.EqualTo("Bar"));
}

I lose code coverage in the file. I have looked around the forum and the only suggestion was to close and reopen the tab but that did not solve my issue.

I am able to get the code coverage by not using the dynamic keyword in line and casting it it at the end like this:

[Test]
public void DynamicCast()
{
var o = new ExpandoObject();
Assert.That(((dynamic)o).Foo, Is.EqualTo("Bar"));
}

Any thoughts as I would like to use the dynamic keyword like the first example and still keep my green/red dots on the left.

Aaron
Forgot, Using VS 2013 with NCrunch 2.7.0.5
Hi, thanks for sharing this issue.

I've just thrown together a quick test on this side (.NET 4.5, VS2013), and the code coverage was still showing correctly. I suspect there may be more going on here.

Are you able to reproduce this issue in a simple throw-away solution? If so, would you mind submitting it via the contact form? https://www.ncrunch.net/Support/Contact.


Thanks!

Remco
I will put something together this evening (morning your time)

Aaron
Worked out the issue. It was the Roslyn CTP.

I am working with it in the project I originally found the issue, and when I created a simple project with the above test I had the same problem. This got me thinking that it could be Roslyn as I assume you did not have it installed.

Removed it and the code coverage returned :)

Did you still want me to open a support ticket? Would love to see it work with Roslyn but as its a CPT I am not too concerned.

Aaron


Interesting ... I wonder then if Roslyn is neglecting to emit debug information for methods using dynamic. Are you able to step into the code at all? If not, this could be something that should be raised with Microsoft.

NCrunch will support Roslyn - although any new features that rely on it won't really be useful until Roslyn is out of it's CTP state. Integrating with products while they're in CTP tends to be quite expensive, as they very often change before hitting RTM and the documentation is often fairly minimal. I'll note this down for some experimentation later when Roslyn starts to become a bigger thing for NCrunch. Thanks for making me aware of it.
Hey,

FYI: I am able to step trough the code.

Aaron

Post a reply

Log in to reply.