EditorBrowsable(EditorBrowsableState.Never) in VS 2015 does not work as well as it does in VS 2013
#4,434 创建于 2015年8月7日
描述
Problem
Consider the following projects and classes:
ProjectA
is not included in the solution
namespace ProjectA
{
using System;
using System.ComponentModel;
public class BaseClass
{
[EditorBrowsable(EditorBrowsableState.Never)]
public new Type GetType() { return base.GetType(); }
[EditorBrowsable(EditorBrowsableState.Never)]
public new static bool Equals(object objA, object objB) { return Object.Equals(objA, objB); }
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj) { return base.Equals(obj); }
[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() { return base.GetHashCode(); }
[EditorBrowsable(EditorBrowsableState.Never)]
protected new object MemberwiseClone() { return base.MemberwiseClone(); }
[EditorBrowsable(EditorBrowsableState.Never)]
public new static bool ReferenceEquals(object objA, object objB) { return Object.ReferenceEquals(objA, objB); }
[EditorBrowsable(EditorBrowsableState.Never)]
public override string ToString() { return base.ToString(); }
public static void DoSomeBasicThing() {}
}
}
namespace ProjectA
{
public class ClassA : BaseClass
{
public static void InitializeClassA() { }
public void DoSomethingA() {}
}
}
ProjectB
is included in the solution; has a binary reference to ProjectA
namespace ProjectB
{
using System.ComponentModel;
using ProjectA;
[EditorBrowsable(EditorBrowsableState.Never)]
public class ClassB : BaseClass, IInterfaceA<ClassB>
{
public void DoSomethingB()
{
var objectA = new ClassA();
}
}
}
ProjectC
is included in the solution; has a binary reference to ProjectA; has a project reference to ProjectB
namespace ProjectC
{
using ProjectB;
public class ClassC
{
public void TestEm()
{
var objectB = new ClassB();
}
}
}
In Visual Studio 2013 the EditorBrowsable attribute is honored correctly for members of types defined in assemblies that are included using a binary reference. However, in Visual Studio 2015, some of the methods defined on the System.Object [static Equals, static ReferenceEquals, and GetType] appear in the Intellisense menu despite being marked with the EditorBrowsable attribute with the EditorBrowsableState.Never argument in a sub class via new hiding methods.
Here are some screenshots:
| Visual Studio 2013 - viewing ProjectA.ClassA's Intellisense menu from ProjectB.ClassB: | Visual Studio 2015 - viewing ProjectA.ClassA's Intellisense menu from ProjectB.ClassB: |
|---|---|
![]() |
![]() |
| Visual Studio 2013 - viewing objectA's Intellisense menu from ProjectB.ClassB: | Visual Studio 2015 - viewing objectA's Intellisense menu from ProjectB.ClassB: |
|---|---|
![]() |
![]() |
| Visual Studio 2013 - viewing ProjectB.ClassB's Intellisense menu from ProjectC.ClassC: | Visual Studio 2015 - viewing ProjectB.ClassB's Intellisense menu from ProjectC.ClassC: |
|---|---|
![]() |
![]() |
| Visual Studio 2013 - viewing objectB's Intellisense menu from ProjectC.ClassC: | Visual Studio 2015 - viewing objectB's Intellisense menu from ProjectC.ClassC: |
|---|---|
![]() |
![]() |
Note that this is the additional problem I mentioned in #4358 in the footnote of this comment.







