Often when playing with .Net objects in Monad, I need to use MSDN class library reference to learn how to use a particular type and its members. Now, I have my bookmarks and favorite search engine but I always thought it would be cool if get-member cmdlet could provide me a help link/reference to go to. Thanks to the way MSDN organizes the class library content this seems possible. MSDN uses the .Net namespace to organize the content. So http://msdn2.microsoft.com/library/System.Diagnostics.Process.aspx refers to the page providing information on the Process Type while http://msdn2.microsoft.com/library/System.Diagnostics.Process.Start.aspx refers to the page providing information on the Start method.
Using monad's Extended Type System (ETS) features and the way MSDN orgranizes the information I can achieve what I want. The get-member cmdlet outputs an object of Type System.Management.Automation.Commands.MemberDefinition. I will extend this type by adding a ScriptProperty called HelpLink via types.mshxml. The following is the xml snippet that I add to my types.mshxml. The ScriptBlock basically constructs a url string based on the type name and name of the member being accessed. You will have to restart msh to get the changes in.
<Type> <Name>System.Management.Automation.Commands.MemberDefinition</Name> <Members> <ScriptProperty> <Name>HelpLink</Name> <GetScriptBlock> "http://msdn2.microsoft.com/library/" + $this.typename +"." +$this.name+".aspx"</GetScriptBlock> </ScriptProperty> </Members> </Type>
This is what the get-member output looks like before adding the extension.
MSH> $a = ps msh
MSH > $a | get-member -membertype method -name Start | format-list
TypeName : System.Diagnostics.ProcessName : StartMemberType : MethodDefinition : System.Boolean Start()
This is what the get-member output looks like after the extension.
MSH C:\> $a | get-member -membertype method -name Start | format-list
HelpLink : http://msdn2.microsoft.com/library/System.Diagnostics.Process.Start.aspxTypeName : System.Diagnostics.ProcessName : StartMemberType : MethodDefinition : System.Boolean Start()
I can now navigate to the exact help link directly from monad whenever needed :-). This seems to work ok for types in the base class library, but will not work for COM objects or the adapted objects or any custom types you might have.