en-US/Documentarian.AstInfo-help.xml
|
<?xml version="1.0" encoding="utf-8"?>
<helpItems schema="maml" xmlns="http://msh"> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Find-Ast</command:name> <command:verb>Find</command:verb> <command:noun>Ast</command:noun> <maml:description> <maml:para>Finds ASTs by type or predicate in a script block, file, or AST.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Find-Ast` function looks searches an AST. You can specify the AST to search as an AstInfo object, the path to a PowerShell script file, a script block, or a literal AST object. You can either provide your own predicate, which is a scriptblock that determines whether the inspected AST child object is one you're looking for, or the function can create one for you.</maml:para> <maml:para>If you're not providing your own predicate, the function can only search by AST type.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Find-Ast</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AstInfo</maml:name> <maml:description> <maml:para>The AstInfo object to search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">AstInfo</command:parameterValue> <dev:type> <maml:name>AstInfo</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Recurse</maml:name> <maml:description> <maml:para>Whether to recursively search the children of AST objects. By default, the function searches only the top level of the provided AST.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>The type of AST object you're looking for. You can specify this parameter instead of writing your own scriptblock for the Predicate parameter.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Type</command:parameterValue> <dev:type> <maml:name>Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Find-Ast</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AstInfo</maml:name> <maml:description> <maml:para>The AstInfo object to search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">AstInfo</command:parameterValue> <dev:type> <maml:name>AstInfo</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Predicate</maml:name> <maml:description> <maml:para>A scriptblock that returns `$true` if the inspected AST object meets your search criteria and `$false` if it doesn't.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue> <dev:type> <maml:name>ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Recurse</maml:name> <maml:description> <maml:para>Whether to recursively search the children of AST objects. By default, the function searches only the top level of the provided AST.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Find-Ast</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>The path to a PowerShell script file to parse and search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Recurse</maml:name> <maml:description> <maml:para>Whether to recursively search the children of AST objects. By default, the function searches only the top level of the provided AST.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>The type of AST object you're looking for. You can specify this parameter instead of writing your own scriptblock for the Predicate parameter.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Type</command:parameterValue> <dev:type> <maml:name>Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Find-Ast</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>The path to a PowerShell script file to parse and search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Predicate</maml:name> <maml:description> <maml:para>A scriptblock that returns `$true` if the inspected AST object meets your search criteria and `$false` if it doesn't.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue> <dev:type> <maml:name>ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Recurse</maml:name> <maml:description> <maml:para>Whether to recursively search the children of AST objects. By default, the function searches only the top level of the provided AST.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Find-Ast</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Predicate</maml:name> <maml:description> <maml:para>A scriptblock that returns `$true` if the inspected AST object meets your search criteria and `$false` if it doesn't.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue> <dev:type> <maml:name>ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Recurse</maml:name> <maml:description> <maml:para>Whether to recursively search the children of AST objects. By default, the function searches only the top level of the provided AST.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ScriptBlock</maml:name> <maml:description> <maml:para>The scriptblock to parse and search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue> <dev:type> <maml:name>ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Find-Ast</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Predicate</maml:name> <maml:description> <maml:para>A scriptblock that returns `$true` if the inspected AST object meets your search criteria and `$false` if it doesn't.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue> <dev:type> <maml:name>ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Recurse</maml:name> <maml:description> <maml:para>Whether to recursively search the children of AST objects. By default, the function searches only the top level of the provided AST.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TargetAst</maml:name> <maml:description> <maml:para>The literal AST object to search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Ast</command:parameterValue> <dev:type> <maml:name>Ast</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Find-Ast</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Recurse</maml:name> <maml:description> <maml:para>Whether to recursively search the children of AST objects. By default, the function searches only the top level of the provided AST.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ScriptBlock</maml:name> <maml:description> <maml:para>The scriptblock to parse and search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue> <dev:type> <maml:name>ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>The type of AST object you're looking for. You can specify this parameter instead of writing your own scriptblock for the Predicate parameter.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Type</command:parameterValue> <dev:type> <maml:name>Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Find-Ast</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Recurse</maml:name> <maml:description> <maml:para>Whether to recursively search the children of AST objects. By default, the function searches only the top level of the provided AST.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TargetAst</maml:name> <maml:description> <maml:para>The literal AST object to search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Ast</command:parameterValue> <dev:type> <maml:name>Ast</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>The type of AST object you're looking for. You can specify this parameter instead of writing your own scriptblock for the Predicate parameter.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Type</command:parameterValue> <dev:type> <maml:name>Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AstInfo</maml:name> <maml:description> <maml:para>The AstInfo object to search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">AstInfo</command:parameterValue> <dev:type> <maml:name>AstInfo</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>The path to a PowerShell script file to parse and search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Predicate</maml:name> <maml:description> <maml:para>A scriptblock that returns `$true` if the inspected AST object meets your search criteria and `$false` if it doesn't.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue> <dev:type> <maml:name>ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Recurse</maml:name> <maml:description> <maml:para>Whether to recursively search the children of AST objects. By default, the function searches only the top level of the provided AST.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ScriptBlock</maml:name> <maml:description> <maml:para>The scriptblock to parse and search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue> <dev:type> <maml:name>ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TargetAst</maml:name> <maml:description> <maml:para>The literal AST object to search.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Ast</command:parameterValue> <dev:type> <maml:name>Ast</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>The type of AST object you're looking for. You can specify this parameter instead of writing your own scriptblock for the Predicate parameter.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Type</command:parameterValue> <dev:type> <maml:name>Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.Language.Ast[]</maml:name> </dev:type> <maml:description> <maml:para>This function returns any Ast objects it finds in the provided AST that meet the criteria of the specified Type or Predicate parameters.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------------------- Example 1 --------------------------</maml:title> <dev:code>Find-Ast -Type AttributeAst -ScriptBlock { [ValidateNotNull()]$x = 5 } PositionalArguments : {} NamedArguments : {} TypeName : ValidateNotNull Extent : [ValidateNotNull()] Parent : [ValidateNotNull()]$x</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://microsoft.github.io/Documentarian/modules/astinfo/reference/cmdlets/find-ast</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-AstInfo</command:name> <command:verb>Get</command:verb> <command:noun>AstInfo</command:noun> <maml:description> <maml:para>Gets an AstInfo object from a script block, file, or text.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-AstInfo` function parses a PowerShell script file, a scriptblock, or an arbitrary string of text as PowerShell and returns an AstInfo object. The AstInfo object includes the parsed abstract syntax tree (AST), the parsed tokens, and any errors raised while parsing the input.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-AstInfo</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>The path to a PowerShell script file to parse.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-AstInfo</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ScriptBlock</maml:name> <maml:description> <maml:para>A scriptblock to parse.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue> <dev:type> <maml:name>ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-AstInfo</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Text</maml:name> <maml:description> <maml:para>An arbitrary string to parse as PowerShell.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>The path to a PowerShell script file to parse.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ScriptBlock</maml:name> <maml:description> <maml:para>A scriptblock to parse.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue> <dev:type> <maml:name>ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Text</maml:name> <maml:description> <maml:para>An arbitrary string to parse as PowerShell.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>AstInfo</maml:name> </dev:type> <maml:description> <maml:para>This function outputs an AstInfo object with the parsed information.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------------------- Example 1 --------------------------</maml:title> <dev:code>Get-AstInfo -ScriptBlock { [ValidateNotNull]$x = 5 } Ast Tokens Errors --- ------ ------ [ValidateNotNull]$x = 5 {[, ValidateNotNull, ], x…} {}</dev:code> <dev:remarks> <maml:para>{{ Add example description here }}</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://microsoft.github.io/Documentarian/modules/astinfo/reference/cmdlets/get-astinfo</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-AstType</command:name> <command:verb>Get</command:verb> <command:noun>AstType</command:noun> <maml:description> <maml:para>Gets AST types from the current AppDomain with optional filters.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-AstType` function returns a list of AST types, optionally filtered. You can filter the list of known AST types by type name or a regular expression pattern against the type name.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-AstType</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Specify a name to look for in the list of AST types; the "Ast" suffix is optional</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-AstType</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Pattern</maml:name> <maml:description> <maml:para>Specify a valid regular expression pattern to match in the list of AST types.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Specify a name to look for in the list of AST types; the "Ast" suffix is optional</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Pattern</maml:name> <maml:description> <maml:para>Specify a valid regular expression pattern to match in the list of AST types.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Type[]</maml:name> </dev:type> <maml:description> <maml:para>This function returns one or more objects representing the type information of the filtered AST types.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------------------- Example 1 --------------------------</maml:title> <dev:code>Get-AstType -Pattern Type* IsPublic IsSerial Name BaseType -------- -------- ---- -------- True False TypeConstraintAst System.Management.Automation.Language.AttributeBaseAst True False TypeDefinitionAst System.Management.Automation.Language.StatementAst True False TypeExpressionAst System.Management.Automation.Language.ExpressionAst</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://microsoft.github.io/Documentarian/modules/astinfo/reference/cmdlets/get-asttype</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>New-AstPredicate</command:name> <command:verb>New</command:verb> <command:noun>AstPredicate</command:noun> <maml:description> <maml:para>Returns a scriptblock predicate for finding ASTs of a particular type.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `New-AstPredicate` returns a valid scriptblock you can use to search a PowerShell abstract syntax tree (AST) for the specified type.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-AstPredicate</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="1" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>The AST type to create a predicate to search for in an AST. The type must be a valid AST type or the name of a valid AST type as a string. The `Ast` suffix is optional when the value is a string.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Type</command:parameterValue> <dev:type> <maml:name>Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="1" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>The AST type to create a predicate to search for in an AST. The type must be a valid AST type or the name of a valid AST type as a string. The `Ast` suffix is optional when the value is a string.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Type</command:parameterValue> <dev:type> <maml:name>Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> </dev:type> <maml:description> <maml:para>The function returns a scriptblock that you can use as the predicate to search an AST for the specified type.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------------------- Example 1 --------------------------</maml:title> <dev:code>$predicate = New-AstPredicate -Type VariableExpression Find-Ast -Predicate $predicate -ScriptBlock { [ValidateNotNull]$x = 5 } VariablePath : x Splatted : False StaticType : System.Object Extent : $x Parent : [ValidateNotNull]$x</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://microsoft.github.io/Documentarian/modules/astinfo/reference/cmdlets/new-astpredicate</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Resolve-TypeName</command:name> <command:verb>Resolve</command:verb> <command:noun>TypeName</command:noun> <maml:description> <maml:para>Resolves a TypeName object to the type's full name through reflection.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Resolve-TypeName` function resolves a System.Management.Automation.Language.TypeName or System.Management.Automation.Language.ArrayTypeName object to the type's full name as a string.</maml:para> <maml:para>This is useful for retrieving a type's full name through reflection. If the function can't successfully retrieve the full type name from reflection, it implies the type is unknown. In that case, the function returns the type name as a string, but without the assurance that it's the full type name.</maml:para> <maml:para>When you're inspecting an AST, parameters and properties have their type information as an attribute that has the TypeName property. You can use this function to fully resolve those type names from the AST.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Resolve-TypeName</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="1" aliases="none"> <maml:name>TypeName</maml:name> <maml:description> <maml:para>The TypeName or ArrayTypeName to resolve to a full type name.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Object</command:parameterValue> <dev:type> <maml:name>Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="1" aliases="none"> <maml:name>TypeName</maml:name> <maml:description> <maml:para>The TypeName or ArrayTypeName to resolve to a full type name.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Object</command:parameterValue> <dev:type> <maml:name>Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>This function returns the resolved full type name of the input object as a string.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------------------- Example 1 --------------------------</maml:title> <dev:code>$parameter = Find-Ast -Type Parameter -Recurse -ScriptBlock { param([string]$x) } $parameter $parameter.Attributes Resolve-TypeName -TypeName $parameter.Attributes[0].TypeName Attributes : {string} Name : $x DefaultValue : StaticType : System.String Extent : [string]$x Parent : param([string]$x) TypeName : string Extent : [string] Parent : [string]$x System.String</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://microsoft.github.io/Documentarian/modules/astinfo/reference/cmdlets/resolve-typename</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Test-IsAstType</command:name> <command:verb>Test</command:verb> <command:noun>IsAstType</command:noun> <maml:description> <maml:para>Determines if a type is an AST type.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Test-IsAstType` function verifies whether a given type is an AST type. If the type inherits from System.Management.Automation.Language.Ast , the function returns `$true`. If it isn't, the function returns `$false`.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Test-IsAstType</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>A System.Type object to check as an AST type.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Type</command:parameterValue> <dev:type> <maml:name>Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>A System.Type object to check as an AST type.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Type</command:parameterValue> <dev:type> <maml:name>Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Boolean</maml:name> </dev:type> <maml:description> <maml:para>This function returns `$true` if the input object is a valid AST type and `$false` otherwise.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------------------- Example 1 --------------------------</maml:title> <dev:code>Test-IsAstType -Type ([System.Management.Automation.Language.AttributeAst]) Test-IsAstType -Type ([string]) True False</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://microsoft.github.io/Documentarian/modules/astinfo/reference/cmdlets/test-isasttype</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> </helpItems> |