iRon7 / Join-Object

Combines two objects lists based on a related property between them.
MIT License
107 stars 13 forks source link

Code change to work with Set-StrictMode 2.0+ #3

Closed mcclimont closed 5 years ago

mcclimont commented 5 years ago

StrictMode 2.0 introduced "Cannot call non-existent properties on objects", altered code to accomodate this strict mode. Reference: https://blogs.technet.microsoft.com/heyscriptingguy/2014/12/03/enforce-better-script-practices-by-using-set-strictmode/

iRon7 commented 5 years ago

Thanks a lot for the suggestion, I will incorporate this in my next version (almost ready) and put this in my standard tests.

iRon7 commented 5 years ago

I have updated the Join-Object cmdlet and added Set-StrictMode -Version 2.0 to my tests. I didn't add Set-StrictMode -Version 2.0 to the Join-Object cmdlet as users might easily add a Merge-Expression that could cause a Set-StrictMode -Version 2.0 error, e.g. -MergeExpression @{$Left.$_, $Right.$_} could fail because the $Left and/or $Right object properties might not exist in the outer joins. For this, I have added two additional objects for the MergeExpression: $LeftOrVoid and $RightOrVoid which suppliy the concerned $Left or $Right object if existing, otherwise it will refer to an object which all properties values set to $Null.