Skip to content

Hide internal parameter properties in blazor from the IntelliSense #12271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Stamo-Gochev opened this issue Jul 17, 2019 · 6 comments
Closed
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one ✔️ Resolution: Won't Fix Resolved because we decided not to change the behavior reported in this issue. Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue.

Comments

@Stamo-Gochev
Copy link

Describe the bug

Is there a way to hide an internal property, which has the [Parameter]attribute, e.g.:

    public class ParentComponentBase : ComponentBase
    {
        [Parameter]
        internal string Value { get; set; }
    }`

Using EditorBrowsable does not seem to work either:

    public class ParentComponentBase : ComponentBase
    {
        [Parameter]
        [EditorBrowsable(EditorBrowsableState.Never)]
        internal string Value { get; set; }
    }

Expected behavior

The internal property is not visible.

Screenshots

image

@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Jul 17, 2019
@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @Stamo-Gochev.
What do you need this for?

@mkArtakMSFT mkArtakMSFT added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Jul 17, 2019
@Stamo-Gochev
Copy link
Author

@mkArtakMSFT I need this in order to hide an internal setting of a component. The scenario is that a component can be used as a standalone unit, but it can be also integrated in another component, e.g. in a hierarchy. Let's say an editor component can be used in a form, but it can also be used as an editor in a grid component, which requires some internal customizations that are not (currently) relevant to be used in the standalone case.

I think that the EditorBrowsable attribute should handle such scenarios as it serves a more general purpose (and my concrete scenario might not be the best use case). Still, it seems like [Parameter] props cannot be hidden for some reason.

@Joe4evr
Copy link

Joe4evr commented Jul 18, 2019

For what it's worth, I've never seen EditorBrowsable respected within the same project or while there's a direct reference to the source. On top of that, [Parameter] properties can be private and they're still visible when writing Blazor, BUT they're going to change that: #8825. That might be the solution you want in the first place.

@mkArtakMSFT
Copy link
Member

Thanks @Stamo-Gochev.
This is not something we plan to do.

@mkArtakMSFT mkArtakMSFT added enhancement This issue represents an ask for new feature or an enhancement to an existing one ✔️ Resolution: Won't Fix Resolved because we decided not to change the behavior reported in this issue. labels Jul 19, 2019
@SteveSandersonMS
Copy link
Member

@Stamo-Gochev The reason is that there are other ways this can be achieved, and we're not sure that [EditorBrowsable] is a desirable way to do it. For example:

  • You could choose not to declare any [Parameter] property for your internal parameter, and instead receive its value privately by overriding SetParameters on the receiving component (read it directly from the incoming ParameterCollection)
  • Or, instead of using a parameter for this parent/child communication, have the parent pass an instance of itself to the child so the child can read stuff back from the parent
  • Or, capture the child using a ref and then make calls to its public methods to perform the private communication between parent and child

I hope one of those is suitable for your use cases!

@Stamo-Gochev
Copy link
Author

Thanks @SteveSandersonMS, this makes sense.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one ✔️ Resolution: Won't Fix Resolved because we decided not to change the behavior reported in this issue. Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue.
Projects
None yet
Development

No branches or pull requests

4 participants