Skip to content

EditorBrowsable is useless for source generators to hide stuff #60080

@stephentoub

Description

@stephentoub

Version Used:
Version 17.2.0 Preview 2.0 [32303.453.main]

Steps to Reproduce:
Paste this and then start typing SomeNamespace.

using System.ComponentModel;

namespace SomeNamespace
{
    [EditorBrowsable(EditorBrowsableState.Never)]
    [Browsable(false)]
    internal class CoolTypeNotToBeUsed
    {
    }
}

Expected Behavior:
CoolTypeNotToBeUsed doesn't show up in IntelliSense.

Actual Behavior:
It shows up.
image

As it turns out, I shouldn't be surprised... the docs are pretty clear:
https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.editorbrowsableattribute?view=net-6.0
"Specifies that a property or method"... so, not a type
"In Visual C#, EditorBrowsableAttribute does not suppress members from a class in the same assembly."... so, yeah

But this makes EditorBrowsableAttribute useless for source generators that want to emit code that's not browsable by the rest of the library.

We should either change the meaning of EditorBrowsableState.Never in the IDE to actually mean "Never, not even in the same assembly", or we should add a new "NeverNotEvenInTheSameAssembly" state that does the right thing.

cc: @terrajobst, @jaredpar

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEuntriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions