kirkmunro / typepx Goto Github PK
View Code? Open in Web Editor NEWPowerShell Type Extensions and Accelerators
License: Apache License 2.0
PowerShell Type Extensions and Accelerators
License: Apache License 2.0
https://github.com/KirkMunro/TypePx/blob/master/typedata/array.ps1#L136
if ($results.Count -eq 1) {
,$results
} else {
$results
}
Shouldn't this be $results.Count -le 1
?
#### Repro
PS> function return0 { $o = new-object System.Collections.ArrayList; if($o.Count -eq 1) {return ,$o} else {return $o} }
PS> function return0alt { $o = new-object System.Collections.ArrayList; if($o.Count -le 1) {return ,$o} else {return $o} }
PS> function return1 { $o = new-object System.Collections.ArrayList; [Void]$o.Add('a'); if($o.Count -eq 1) {return ,$o} else {return $o} }
PS> function return2 { $o = new-object System.Collections.ArrayList; [Void]$o.Add('a'); [Void]$o.Add('b'); if($o.Count -eq 1) {return ,$o} else {return $o} }
#### Results
PS> $result = return0; $result.GetType(); $result.Count;
You cannot call a method on a null-valued expression.
At line:1 char:20
+ $result = return0; $result.GetType(); $result.Count;
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
0
PS> $result = return0alt; $result.GetType().ToString(); $result.Count;
System.Collections.ArrayList
0
PS> $result = return1; $result.GetType(); $result.Count;
System.Collections.ArrayList
1
PS> $result = return2; $result.GetType().ToString(); $result.Count;
System.Object[]
2
Hello Kirk,
Whenever I run "import-module typepx" while in a non-elevated session, I get the above error and module does not load.
PSVersion 5.1.15063.138
On my Windows 7 desktop running PowerShell 3 I encounter an exception when attempting to run the command> Get-TypeAccelerator -Name switch
The other variations of this function (Examples 1,3,4) run fine. When I first encountered this problem I had version 2.0.0.14 of TypePx, an update to 2.0.0.16 did not change the exception behavior.
Get-TypeAccelerator : Exception calling "LikeAny" with "1" argument(s): "Exception calling "where" with "1" argument(s): "Exception calling "LikeAny" with "1"
argument(s): "Property 'Count' cannot be found on this object. Make sure that it exists."""
At line:1 char:1
- CategoryInfo : NotSpecified: (:) [Get-TypeAccelerator], MethodInvocationException
- FullyQualifiedErrorId : ScriptMethodRuntimeException,Get-TypeAccelerator
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.