Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"no source available" when targeting net462 #523

Closed
clairernovotny opened this issue Feb 19, 2017 · 8 comments
Closed

"no source available" when targeting net462 #523

clairernovotny opened this issue Feb 19, 2017 · 8 comments
Assignees

Comments

@clairernovotny
Copy link

clairernovotny commented Feb 19, 2017

From this issue here: xunit/xunit#1112

When I create a new xUnit test project in VS2017 RC4 (or newer), test Explorer cannot show the source code for any of the tests. When targeting netcoreapp1.1 (which is there by default in the template, it works as expected.

csproj file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net462</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170125-04" />
    <PackageReference Include="xunit" Version="2.2.0-beta5-build3474" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta5-build1225" />
  </ItemGroup>

  <ItemGroup>
    <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
  </ItemGroup>

</Project>

UnitTest1.cs file:

using System;
using Xunit;

namespace XUnitTestProject1
{
    public class UnitTest1
    {
        [Fact]
        public void Test1()
        {
        }
    }
}

We dug into this and found out that Microsoft.VisualStudio.TestPlatform.ObjectModel is missing from the host process when run. That means that we cannot get an instance of DiaSession. The test host has to inject the correct version of the library from a location also containing msdia140typelib_clr0200. It does this for the legacy project system.

/cc @bradwilson

@bradwilson
Copy link

FYI: You can use the RTM bits of xUnit.net (released a few hours ago). The experience is exactly the same.

@smadala
Copy link
Contributor

smadala commented Feb 20, 2017

Related to: #373

Work around: Add following PropertyGroup to csproj.

<PropertyGroup>
    <DebugType Condition="'$(TargetFramework)' != '' AND !$(TargetFramework.StartsWith('netcoreapp'))">Full</DebugType>
</PropertyGroup>

@smadala
Copy link
Contributor

smadala commented Feb 24, 2017

Fixed in Microsoft.NET.Test.Sdk: 15.0.0-preview-20170222-09.

@smadala smadala closed this as completed Feb 24, 2017
@anderslm
Copy link

I'm still having this issue.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net462</TargetFramework>

    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>  
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
    <PackageReference Include="xunit" Version="2.2.0" />

    <PackageReference Include="Moq" Version="4.7.1" />
    <PackageReference Include="FluentAssertions" Version="4.19.2" />
  </ItemGroup>

  <ItemGroup>
    <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
  </ItemGroup>

</Project>

"No source available" for tests, no code-coverage and no context-awareness when trying to run test from the editor.

@smadala
Copy link
Contributor

smadala commented Mar 17, 2017

no context-awareness

known issue xunit/xunit#1140.

For No source available and no code-coverage, I am not able to repro it on VS 15.0.26228.4, can please provide additional data.

  • What is the VS 2017 build?
  • Can you please share your project?

@anderslm
Copy link

anderslm commented Mar 20, 2017

@smadala
thx for pointing me to the xunit issue.

VS build: 15.0.0+26228.9

I've just spend two hours trying to reproduce the error in a new solution. Finally did it. It's really weird. You have to have a test class, that inherits from a super-class with a generic type-parameter. The generic-type supplied to the super-class then have to be a MVC controller. When all that is true and you mark a test method async, then the error occurs....

You can find a test-solution here: https://github.com/anderslm/Testing

P.S.
Incidentally all our tests in our solution fulfills that requirement...

@smadala
Copy link
Contributor

smadala commented Mar 22, 2017

@anderslm Thanks for sample project, I'm able to repro it. But for similar test method MSTest
mstest-simple.txt is working fine. This could be xunit issue.
/cc @onovotny @bradwilson Can you please look into this?

@bradwilson
Copy link

Theory: Given the description, it sounds like there is probably a dependency lookup failure when getting source information, presumably because the MVC assembly is not loaded into that source info app domain.

terrajobst added a commit to dotnet/platform-compat that referenced this issue Apr 10, 2017
Apparently there is VS tests bug that prevents test explorer from
showing source information otherwise. See
microsoft/vstest#523.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants