Search

Enable hiding object members from Format-List, select *, tab completion, etc. by Andrey Anastasov

Active

1
0
Sign in
to vote
Type: Suggestion
ID: 777689
Opened: 1/28/2013 10:42:25 AM
Access Restriction: Public
0
Workaround(s)
The functionality described in this request is targeted at snapin developers, not at end users. PowerShell 3.0 gives users access to class members which are explicit interface implementation, e.g:

interface IPrivatelyNamed {
string PrivateName { get; }
}

class MyType : IPrivatelyNamed {
// ...

string IPrivatelyNamed.PrivateName {
     get { return _privateName; }
}
}

Traditional .Net languages treat IPrivatelyNamed.PrivateName as a private member of MyType. PowerShell 3.0 does the opposite, exposing such members to the end user without requiring upcast to the declaring interface. While this behavior has valid uses, there are valid uses to the opposite. Explicitly implemented interfaces have practical uses as private implementation, at least as far as the end user is concerned. As a result, what is a reasonably well hidden internal implementation in traditional .Net languages and in PowerShell 2.0, is highly user visible in PowerShell 3.0.

This is a request to provide ability to selectively hide such class members from the end user. For example, the snapin developer could mark the members that need hiding with specific .Net attribute or through elements in PS1XML.

This request is provoked by a practical issue in VMware PowerCLI which uses explicitly implemented interfaces as developer-level interface. This developer-level interface comes with compatibility guarantees that make it difficult to modify. On the other hand, PowerShell 3.0 displays the developer-level interface to end users, polluting user-visible namespaces.
Details (expand)
How often does this happen?
Always Happens
Have you seen this problem before in this product?
No, this is new to the most recent version
Reproduction Steps
The described behavior is a known design choice so I assume that the team will understand the issue from the abstract description above, better than from reproduction steps.
Expected Results
 
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.