Skip to content

Type conflict with BindingFlags #16609

@joshcomley

Description

@joshcomley

Type/namespace conflict with BindingFlags and System.Reflection.TypeExtensions renders code unable to compile.

Same issue discussed here:
dotnet/corefx#6636 (comment)

Steps to reproduce

program.cs:

using System;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var bf = System.Reflection.BindingFlags.CreateInstance;
        }
    }
}

project.json:

{
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },

    "dependencies": {
        "System.Reflection.TypeExtensions": "4.1.0-rc3-23904"
    },

  "frameworks": {
    "netstandardapp1.5": {
      "dependencies": {
        "NETStandard.Library": "1.0.0-rc3-23904"
      },
      "imports": [
        "dnxcore50",
        "portable-net451+win8"
      ]
    }
  }
}

Nuget.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="AspNetCI" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
    <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
    <add key="nuget.org-v2" value="https://www.nuget.org/api/v2/" />
    <add key="dotnet-core" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" />
    <add key="dotnet-cli" value="https://www.myget.org/F/dotnet-cli/api/v3/index.json" />
  </packageSources>
</configuration>

Full code to reproduce is also available here:
https://github.com/joshcomley/BugSamples/tree/master/DotNetCore/BindingFlagsBug

Expected behavior

It should compile

Actual behavior

error CS0433: The type 'BindingFlags' exists in both 'System.Reflection.TypeExtensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Reflection, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Environment data

dotnet --version output:

.NET Command Line Tools (1.0.0-beta-001494)

Product Information:
Version: 1.0.0-beta-001494
Commit Sha: c7a9d1d63a

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions