scriptclass

0.20.0

Class definition extensions for PowerShell's object-based type system

Minimum PowerShell version

5.1

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name scriptclass -RequiredVersion 0.20.0

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name scriptclass -Version 0.20.0

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) 2019 Adam Edwards.

Package Details

Author(s)

  • Adam Edwards

Tags

class object PSCustomObject netcore

Functions

=> ::> Add-MockInScriptClassScope Add-ScriptClassMock Enable-ScriptClassVerbosePreference Get-ScriptClass Import-Assembly Import-Script Initialize-ScriptClassTest Invoke-Method New-ScriptClass New-ScriptObject New-ScriptObjectMock Remove-ScriptClassMock Test-ScriptObject

PSEditions

Desktop Core

Dependencies

This module has no dependencies.

Release Notes

# ScriptClass 0.20.0 Release Notes

This version of *ScriptClass* contains a significant number of breaking changes, though consumers of previous versions
should be able to migrate to this version with relatively straightforward modifications -- the overall
philosphy of the library remains intact. These changes are the key milestone in moving this module to version 1.0.

The most significant changes are at the implementation layer, where refactoring and simplification should
make the code more reliable at runtime, enable better isolation of PowerShell modules built on it from
dependencies on implementation of *ScriptClass* or other modules depending on it, and even improve runtime performance.
In general, the codebase is more modular and now aligns to an explicit logical arrangement, making it easier
to maintain and modify.

## New features

* The `::>` operator now supports invocation on class instances, i.e. given an instance, it will call the
static member of that instance's class. It can still be used with class names as the target just as before.
* Script scope variables are inaccessible to code within a ScriptClass method -- this protects the method
code from unintended / confusing behavvior. This is also a breaking change
* Parameters may be passed to the script block used to define a class via `New-ScriptClass`. This is a workaround
for the breaking change above for cases where one explicitly wants outside state available to the method
* Module initialization occurs only within module scope -- no pre-initialization code is executed through the
`ScriptsToProcess` key of the manifest, resulting in better isolation and reliability
`Import-Script` now supports the `AnyExtension` option to allow any file, not just files ending with
the `ps1` extension, to be imported

## Breaking changes

* `Add-ScriptClass` is renamed to `New-ScriptClass`
* `Get-Class` is renamed to `Get-ScriptClass`
* The `with` alias is renamed to `withobject`
* Script scope variables are no longer accessible from *ScriptClass* methods -- use the `ArgumentList` parameter
of `New-ScriptClass` / `ScriptClass` to pass such variables to the *ScriptClass* definition
* The `PSCmdlet` automatic variable is no longer passed to *ScriptClass* methods
* Verbose output is not visible from *ScriptClass* methods unless a caller earlier in the stack has invoked the
new `Enable-ScriptClassVerbosePreference` command
* The `gls` alias directs to the new `Get-GraphItemWithMetadata` command instead of `Get-GraphChildItem`
* The `PSTypeName` property is no longer part of *ScriptClass* objects
* The `Get-ScriptClass` command returns a different data structure than the old `Get-Class` command

## Fixed defects

* The module's internal variables are now isolated within the module -- previously variables and
 functions at script scope were available to any callers outside the module, allowing them
 to modify *ScriptClass* internal state. And it was quite possible that *ScriptClass* internal state
 collided with variables or functions in other modules. This is no longer the case as *ScriptClass*
 now behaves like an ordinary Powershell module. This means its features can be accessed by
 other modules by including *ScriptClass* in the `NestedModules` element of those module manifests.

FileList

Version History

Version Downloads Last updated
0.20.3 2,989 1/21/2023
0.20.2 3,279 6/20/2020
0.20.1 4,393 9/22/2019
0.20.0 (current version) 226 9/20/2019
0.16.0 1,054 2/3/2019
0.15.0 80 1/13/2019
0.14.2 79 1/6/2019
0.14.1 44 1/5/2019
0.14.0 41 1/2/2019
0.13.7 353 8/16/2018
0.13.6 130 7/1/2018
0.12.10 159 2/14/2018
0.12.9 47 2/14/2018
0.12.8 41 2/12/2018
0.12.6 30 2/11/2018
0.12.5 38 2/11/2018
0.12.4 40 2/10/2018
0.12.2 45 2/8/2018
Show more