dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.1k stars 4.04k forks source link

Intellisense reports CS0234 but compiler succeeds on netstandard2.0 project #17086

Open jonathanbyrne opened 7 years ago

jonathanbyrne commented 7 years ago

I'm not sure if this is an issue with Roslyn, MSBuild, Visual Studio, or something else but I have to start somewhere.

Version Used: CSC: 2.0.0.61404 Visual Studio: 15.0.26206.0 D15REL MSBuild: 15.1.545.13942

Steps to Reproduce:

  1. Create .NET Standard 2.0 Library project
    <Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <NetStandardImplicitPackageVersion>2.0.0-beta-25009-01</NetStandardImplicitPackageVersion>
    </PropertyGroup>
    </Project>
  2. Add class that inherits System.Refelection.TypeDelegator (I suspect that the same problem would occur with any type that is new in .NET Standard 2.0.)
    public class MyType : System.Reflection.TypeDelegator
    {
    }
  3. Build project

Expected Behavior: The project should build successfully and no errors should be reported in the output or in the error list window.

Actual Behavior: The project builds successfully but the error list window displays CS0234 with the message:

The type or namespace name 'TypeDelegator' does not exist in the namespace 'System.Reflection' (are you missing an assembly reference?)

Pilchie commented 7 years ago

@srivatsn / @davkean any ideas here? Does this belong on roslyn-project-system?

srivatsn commented 7 years ago

That's an old build of VS with an SDK that didnt support Netstandard 2.0. With the latest 15.3 Preview, this works fine.