Skip to content

Commit

Permalink
Add ArrayList support
Browse files Browse the repository at this point in the history
  • Loading branch information
ili101 committed Nov 9, 2020
1 parent 91d03f2 commit 84e3894
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.2 - 2020/10/XX (Stable)
### New
* Add ArrayList input support.

## 2.0.1 - 2019/08/24 (Stable)
### Documentation
* Updated Description and Tags.
Expand Down
4 changes: 2 additions & 2 deletions Join-Object.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ function Join-Object {
if ($Left -is [Data.DataTable]) {
$LeftNew = [DataTableExtensions]::AsEnumerable($Left)
}
elseif ($Left -is [PSCustomObject]) {
elseif ($Left -is [PSCustomObject] -or $Left -is [Collections.ArrayList]) {
$LeftNew = @($Left)
}
else {
Expand All @@ -786,7 +786,7 @@ function Join-Object {
if ($Right -is [Data.DataTable]) {
$RightNew = [DataTableExtensions]::AsEnumerable($Right)
}
elseif ($Right -is [PSCustomObject]) {
elseif ($Right -is [PSCustomObject] -or $Right -is [Collections.ArrayList]) {
$RightNew = @($Right)
}
else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
<TN RefId="0">
<T>System.Object[]</T>
<T>System.Array</T>
<T>System.Object</T>
</TN>
<LST>
<Obj RefId="1">
<TN RefId="1">
<T>System.Management.Automation.PSCustomObject</T>
<T>System.Object</T>
</TN>
<MS>
<I32 N="ID">1</I32>
<S N="Subscription">S1</S>
<S N="R_Name">A</S>
<I32 N="R_IntT">5</I32>
</MS>
</Obj>
<Obj RefId="2">
<TNRef RefId="1" />
<MS>
<I32 N="ID">2</I32>
<S N="Subscription">S2</S>
<Nil N="R_Name" />
<Nil N="R_IntT" />
</MS>
</Obj>
<Obj RefId="3">
<TNRef RefId="1" />
<MS>
<I32 N="ID">3</I32>
<S N="Subscription">S3</S>
<S N="R_Name">C</S>
<Nil N="R_IntT" />
</MS>
</Obj>
</LST>
</Obj>
</Objs>
11 changes: 11 additions & 0 deletions Tests/Join-Object.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,17 @@ Describe -Name 'Join-Object' -Fixture {
RightMultiMode = 'DuplicateLines'
}
}
Format-Test @{
Params = @{
Left = '[Collections.ArrayList]PSCustomObject'
Right = 'DataTable'
LeftJoinProperty = 'ID'
RightJoinProperty = 'IDD'
LeftProperties = @{ ID = 'ID' ; Sub = 'Subscription' }
ExcludeRightProperties = 'Junk'
Prefix = 'R_'
}
}
)
if ($FilterTests) {
$TestCases = $TestCases | Where-Object TestName -In $FilterTests
Expand Down
3 changes: 3 additions & 0 deletions Tests/TestHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ function Get-Params {
elseif ($ParamSplit[0] -eq '[DataTable]') {
$Output = (Get-Variable -Name $ParamSplit[1]).Value | ConvertTo-DataTable
}
elseif ($ParamSplit[0] -eq '[Collections.ArrayList]') {
$Output = [Collections.ArrayList](Get-Variable -Name $ParamSplit[1]).Value
}
else {
$Output = (Get-Variable -Name $ParamSplit[0]).Value
}
Expand Down

0 comments on commit 84e3894

Please sign in to comment.