Skip to content

Commit

Permalink
v1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Aug 10, 2021
1 parent b093ac6 commit a558a23
Show file tree
Hide file tree
Showing 15 changed files with 775 additions and 866 deletions.
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log for PSTypeExtensionTools

## v1.9.0

+ Fixed bug in `New-PSPropertySet` that failed to recognize a custom type. ([Issue #21](https://github.com/jdhitsolutions/PSTypeExtensionTools/issues/21))
+ Re-organized module layout.
+ Help updates.
+ Updated `README.md`.

## v1.8.0

+ Fixed bugs in `Get-PSTypeExtension` and `Export-PSTypeExtension` where I needed to let the user force recognizing a type name. ([Issue #20](https://github.com/jdhitsolutions/PSTypeExtensionTools/issues/20))
Expand Down
Binary file modified PSTypeExtensionTools.psd1
Binary file not shown.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Let's say you want to update a number object, but you have no idea what the type

Use `$this` to reference the object instead of `$_`. Now you can get the new property.

```powershell
```dos
PS C:\> $x = 123
PS C:\> $x.SquareRoot
11.0905365064094
Expand All @@ -39,7 +39,7 @@ Add-PSTypeExtension -TypeName system.int32 -MemberType ScriptMethod -MemberName

Here's how it might look:

```powershell
```dos
PS C:\> $x = 38
PS C:\> $x | select *
Expand Down Expand Up @@ -77,7 +77,7 @@ If you like this extension, you can export it and re-import it later.

To see current type extensions, you can use `Get-PSTypeExtension`. You can choose to see all extensions or selected ones by member name. CodeProperty extensions are hidden by default.

```powershell
```dos
PS C:\> Get-PSTypeExtension system.int32
TypeName: System.Int32
Expand All @@ -94,7 +94,7 @@ GetPercent ScriptMethod Param([int32]$Total,[int32]$Round=2) [math]::Round(($t
If you always want these extensions, you would have to put the commands into your PowerShell profile script. Or you can export the extensions to a JSON or XML file. You can either export all members or selected ones, which is helpful if you are extending a type that already has type extensions from PowerShell.

```powershell
PS C:\> Get-PSTypeExtension system.int32 |
Get-PSTypeExtension system.int32 |
Export-PSTypeExtension -TypeName system.int32 -Path c:\work\int32-types.json
```

Expand Down Expand Up @@ -150,7 +150,7 @@ New-PSPropertySet -Typename System.IO.FileInfo -Name FileAge -Properties Name,Si

I've included the file in the Samples folder.

```powershell
```dos
PS C:\> Update-TypeData $PSTypeSamples\fileinfo.types.ps1xml
PS C:\> dir c:\work -file | Select-Object fileage
Expand Down Expand Up @@ -320,4 +320,4 @@ There is an about help topic you can read:
help about_PSTypeExtensionTools
```

Last Updated 2021-03-10 21:49:24Z
Last Updated 2021-08-10 22:10:21Z
22 changes: 4 additions & 18 deletions docs/Export-PSTypeExtension.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ Export type extensions to a file.
### Object (Default)

```yaml
Export-PSTypeExtension -Path <String> [-InputObject <Object>] [-Force] [-Passthru] [-WhatIf] [-Confirm] [<CommonParameters>]
Export-PSTypeExtension -Path <String> [-InputObject <Object>] [-Passthru] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### Name

```yaml
Export-PSTypeExtension [-TypeName] <String> -MemberName <String[]> -Path <String> [-Force] [-Passthru] [-WhatIf] [-Confirm] [<CommonParameters>]
Export-PSTypeExtension [-TypeName] <String> -MemberName <String[]>
-Path <String> [-Passthru] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -190,23 +191,8 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Force
Force the command to accept the name as a type.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
20 changes: 2 additions & 18 deletions docs/Get-PSTypeExtension.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Get selected type extensions.
## SYNTAX

```yaml
Get-PSTypeExtension [-TypeName] <String> [-Members <String[]>] [-CodeProperty] [-Force] [<CommonParameters>]
Get-PSTypeExtension [-TypeName] <String> [-Members <String[]>] [-CodeProperty] [<CommonParameters>]
```

## DESCRIPTION

Use this command to list defined type extensions. You can either select individual ones or all of them. Do not specify any members to retrieve all of them. This command is very similar to Get-TypeData, except that it makes it easier to see the extension value. If you are specifying a custom type name, you may need to use -Force for the command to accept it as written.
Use this command to list defined type extensions. You can either select individual ones or all of them. Do not specify any members to retrieve all of them. This command is very similar to Get-TypeData, except that it makes it easier to see the extension value.

By default, CodeProperty members are not displayed because they can't be exported.

Expand Down Expand Up @@ -162,22 +162,6 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Force
Force the command to accept the name as a type.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
59 changes: 1 addition & 58 deletions en-us/PSTypeExtensionTools-help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,6 @@ True</dev:code>
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Force</maml:name>
<maml:description>
<maml:para>Force the command to accept the name as a type.</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>Export-PSTypeExtension</maml:name>
Expand Down Expand Up @@ -415,17 +404,6 @@ True</dev:code>
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Force</maml:name>
<maml:description>
<maml:para>Force the command to accept the name as a type.</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:syntax>
<command:parameters>
Expand Down Expand Up @@ -513,18 +491,6 @@ True</dev:code>
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Force</maml:name>
<maml:description>
<maml:para>Force the command to accept the name as a type.</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:parameters>
<command:inputTypes>
<command:inputType>
Expand Down Expand Up @@ -755,7 +721,7 @@ Win10Ent 10/16/2020 9:30:46 AM 25.00:49:58.1206825</dev:code>
</maml:description>
</command:details>
<maml:description>
<maml:para>Use this command to list defined type extensions. You can either select individual ones or all of them. Do not specify any members to retrieve all of them. This command is very similar to Get-TypeData, except that it makes it easier to see the extension value. If you are specifying a custom type name, you may need to use -Force for the command to accept it as written.</maml:para>
<maml:para>Use this command to list defined type extensions. You can either select individual ones or all of them. Do not specify any members to retrieve all of them. This command is very similar to Get-TypeData, except that it makes it easier to see the extension value.</maml:para>
<maml:para>By default, CodeProperty members are not displayed because they can't be exported.</maml:para>
</maml:description>
<command:syntax>
Expand Down Expand Up @@ -796,17 +762,6 @@ Win10Ent 10/16/2020 9:30:46 AM 25.00:49:58.1206825</dev:code>
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Force</maml:name>
<maml:description>
<maml:para>Force the command to accept the name as a type.</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:syntax>
<command:parameters>
Expand Down Expand Up @@ -846,18 +801,6 @@ Win10Ent 10/16/2020 9:30:46 AM 25.00:49:58.1206825</dev:code>
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Force</maml:name>
<maml:description>
<maml:para>Force the command to accept the name as a type.</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:parameters>
<command:inputTypes>
<command:inputType>
Expand Down
59 changes: 32 additions & 27 deletions en-us/about_PSTypeExtensionTools.help.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
TOPIC
about_PSTypeExtensionTools
about_pstypeextensiontools

SHORT DESCRIPTION
This PowerShell module contains commands that make it easier to work with
type extensions. Many of these commands are wrappers for built-in tools like
Get-TypeData or Update-TypeData. The commands in this module simplify
`Get-TypeData` or `Update-TypeData`. The commands in this module simplify
the process of finding, creating, exporting, and importing type extensions.

LONG DESCRIPTION
Expand All @@ -13,10 +13,10 @@ LONG DESCRIPTION
could run a PowerShell command like this:

PS C:\> 123 | Get-PSType |
Add-PSTypeExtension -MemberType ScriptProperty -MemberName SquareRoot
Add-PSTypeExtension -MemberType ScriptProperty -MemberName SquareRoot `
-Value { [math]::Sqrt($this)}

Use $this to reference the object instead of $_. Now you can get the new
Use `$this` to reference the object instead of $_. Now you can get the new
property.

PS C:\> $x = 123
Expand All @@ -34,25 +34,25 @@ LONG DESCRIPTION

PS C:\> $x = 38
PS C:\> $x | select *

SquareRoot Squared Cubed Value
---------- ------- ----- -----
6.16441400296898 1444 54872 38

PS C:\> $x.GetPercent(50)
76
PS C:\> $x.GetPercent(100)
38
PS C:\> $x.GetPercent(110,4)
34.5455

To see what has been defined, you can use Get-PSTypeExtension. You can
To see what has been defined, you can use `Get-PSTypeExtension`. You can
choose to see all extensions or selected ones by member name.

PS C:\> Get-PSTypeExtension system.int32

TypeName: System.Int32

Name Type Value
---- ---- -----
SquareRoot ScriptProperty [math]::Sqrt($this)
Expand Down Expand Up @@ -80,49 +80,54 @@ LONG DESCRIPTION

A number of sample files with type extensions can be found in this module's
Samples folder or GitHub repository at
https://github.com/jdhitsolutions/PSTypeExtensionTools/tree/master/samples.
https://github.com/jdhitsolutions/PSTypeExtensionTools/tree/master/samples.
When you have imported the module, you can access the samples folder using
the $PSTypeSamples variable.
the `$PSTypeSamples` variable.

Import-PSTypeExtension $PSTypeSamples\measure-extensions.json

CREATING PS1XML FILES
The Export-PSTypeExtension command will also export extensions to a
The `Export-PSTypeExtension` command will also export extensions to a
properly formatted .ps1xml file. This can be useful when building type
extension files for a module where you want to use the traditional ps1xml
form. You can also import these types of files with Update-TypeData with
form. You can also import these types of files with `Update-TypeData` with
the -AppendPath or -PrependPath parameters.

When exporting to .ps1xml file, Export-PSTypeExtension has a dynamic
parameter, Append. Tis allows you to combine multiple type extensions into
When exporting to .ps1xml file, `Export-PSTypeExtension` has a dynamic
parameter, `Append`. Tis allows you to combine multiple type extensions into
a single file. If you intend to use a property set, create that file first.
Then append your custom type extensions to that file.

NOTE
PowerShell type extensions only last for the duration of your PowerShell
session. If you make a mistake that is causing problems, restart PowerShell
or use the Remove-TypeData cmdlet.
or use the `Remove-TypeData` cmdlet.

TROUBLESHOOTING NOTE
Don't try to append or manually update an export file. If you have changes,
re-run the export command and generate the file anew.
Remember to use $this to reference the object and NOT $_.
Remember to use `$this` to reference the object and NOT `$_`.
Remember to enclose scriptblocks in {}.

SEE ALSO
+ Add-PSTypeExtension
+ Export-PSTypeExtension
+ Get-PSType
+ Get-PSTypeExtension
+ Import-PSTypeExtension
+ Update-TypeData
+ New-PSPropertySet

+
Add-PSTypeExtension
+
Export-PSTypeExtension
+
Get-PSType
+
Get-PSTypeExtension
+
Import-PSTypeExtension
+
Update-TypeData
+
New-PSPropertySet
This project was first described at
http://jdhitsolutions.com/blog/powershell/5777/a-powershell-module-for-your-type-extensions

KEYWORDS
- typedata
- typedata
- typeextension
- propertyset

Loading

0 comments on commit a558a23

Please sign in to comment.