Open jborean93 opened 2 months ago
Dave Wyatt wrote a using-object in 2014. I still use it heavily: https://davewyatt.wordpress.com/2014/04/11/using-object-powershell-version-of-cs-using-statement/ - but yes, it suffers from some of the challenges you mention and isn't as flexible. I would just ask that you don't break it. :-)
This proposal would be more useful if there was a way for the using
in the begin
block to be Dispose()
d in the end
block. i.e.
begin {
using $a = whatever
...
}
process {
...
}
end {
...
# $a gets Dispose()d here
}
@DerpMcDerp that’s what the clean block added in PowerShell 7.3 is great for!