aspnet / Tooling

Issue tracker and info on Visual Studio tooling for ASP.NET
Other
256 stars 124 forks source link

Referencing a PCL breaks Intellisense in VS2015 Update2 but still compiles #849

Closed TheRealPiotrP closed 7 years ago

TheRealPiotrP commented 7 years ago

Moved from https://github.com/dotnet/cli/issues/3126 on behalf of @storment.


Steps to reproduce

Create a PCL (PortableClassLibrary1) targeting .NETPortable,Version=v4.5,Profile=Profile111

{
  "supports": {},
  "dependencies": {},
  "frameworks": {
    ".NETPortable,Version=v4.5,Profile=Profile111": {}
  }
}

Create a test class in the PCL

using System;

namespace Test.This.PCL
{
    public class TestItem() 
    {
        public string TestProp { get; set; }
    }
}

Create a project (Project1) targeting netstandard1.5 or netcoreapp1.0 Edit frameworks in project.json to import the PCL.

"frameworks": {
    "netstandard1.5": {
      "imports": [ "dnxcore50", "portable-net45+win8" ],
      "dependencies": {
        "PortableClassLibrary1": {
          "target": "project"
        }
      }
    }
  }

Create a test class in Project1

using Test.This.PCL;
using System;

namespace Project1
{
    public class Test()
    {
        private TestItem _testItem;
        public Test(TestItem testItem)
        {
            _testItem = testItem;
        }
    }
}

Expected behavior

No errors reported by Visual Studio.

Actual behavior

Project1 compiles with no issues at all but Visual Studio is full of errors.

using Test.This.PCL;

will complain that the namespace does not exist and any reference to TestItem will complain that the type or namespace could not be found. Changing the PCL to target .net standard means intellisense starts working again as expected.

Environment data

dotnet --info output: .NET Command Line Tools (1.0.0-preview1-002702)

Product Information: Version: 1.0.0-preview1-002702 Commit Sha: 6cde21225e

Runtime Environment: OS Name: Windows OS Version: 10.0.10586 OS Platform: Windows RID: win10-x64

mlorbetske commented 7 years ago

Moved to https://github.com/dotnet/roslyn-project-system/issues/1022 to track