If New-PoshBotCardResponse is called with a System.Collections.Specialized.OrderedDictionary type instead of a System.Collections.Hashtable type, the order of the members of the OrderedDictionary is not maintained after the call.
Expected Behavior
$info = Get-ComputerInfo
if ($info) {
$fields = [ordered]@{
Name = $info.LogonServer
OS = $info.OSName
Uptime = $info.Uptime
IPAddress = $info.IPAddress
}
New-PoshBotCardResponse -Type Normal -Fields $fields
fields order going into call
Name Value
Name \DESKTOP-Q23N9QP
OS Microsoft Windows 10 Pro
Uptime
IPAddress
fields order after the call (Notice the order of the Fields is not what was passed.)
Type : Normal
Text :
Private : False
DM :
Fields : {Uptime, OS, IPAddress, Name}
Color : #008000
What we like to see instead. (Notice the order of the Fields is what we passed in.)
Type : Normal
Text :
Private : False
DM :
Fields : {Name, OS, Uptime, IPAddress}
Color : #008000
Current Behavior
Not sure this behavior can be categorized as a bug or not.
Current behavior is that as a result of the call the order of the fields in the Fields parameter is not maintained after the call as shown above.
Possible Solution
Because the Fields parameter is treated as a [hashtable] inside the New-PoshBotCardResponse function, order of the fields in the hashtable cannot be maintained. However, I was able to work around it locally by doing the following:
I replaced the [hashtable]$Fields line in the original source file with the following:
1.Create an instance of an OrderedDictionary type with an ordered list of fields
2.Make a call to New-PoshBotCardResponse using the Fields parameter and the instance of the OrderedDictionary from above.
3.After the call make note of the order of the fields in the original OrderedDictionary sent in
4.The order will not be maintained after the call.
Context
We are trying to create cards using the Fields parameter that will maintain the order of the fields in the OrderedDictionary we send in to the call.
Your Environment
Module version used: 0.11.7
Operating System and PowerShell version: Windows 10
PSVersion 5.1.18362.145
If New-PoshBotCardResponse is called with a System.Collections.Specialized.OrderedDictionary type instead of a System.Collections.Hashtable type, the order of the members of the OrderedDictionary is not maintained after the call.
Expected Behavior
$info = Get-ComputerInfo
if ($info) { $fields = [ordered]@{ Name = $info.LogonServer OS = $info.OSName Uptime = $info.Uptime IPAddress = $info.IPAddress } New-PoshBotCardResponse -Type Normal -Fields $fields
fields order going into call Name Value
Name \DESKTOP-Q23N9QP OS Microsoft Windows 10 Pro Uptime IPAddress
fields order after the call (Notice the order of the Fields is not what was passed.) Type : Normal Text : Private : False DM : Fields : {Uptime, OS, IPAddress, Name} Color : #008000
What we like to see instead. (Notice the order of the Fields is what we passed in.) Type : Normal Text : Private : False DM : Fields : {Name, OS, Uptime, IPAddress} Color : #008000
Current Behavior
Not sure this behavior can be categorized as a bug or not. Current behavior is that as a result of the call the order of the fields in the Fields parameter is not maintained after the call as shown above.
Possible Solution
Because the Fields parameter is treated as a [hashtable] inside the New-PoshBotCardResponse function, order of the fields in the hashtable cannot be maintained. However, I was able to work around it locally by doing the following:
I replaced the [hashtable]$Fields line in the original source file with the following:
Steps to Reproduce (for bugs)
1.Create an instance of an OrderedDictionary type with an ordered list of fields 2.Make a call to New-PoshBotCardResponse using the Fields parameter and the instance of the OrderedDictionary from above. 3.After the call make note of the order of the fields in the original OrderedDictionary sent in 4.The order will not be maintained after the call.
Context
We are trying to create cards using the Fields parameter that will maintain the order of the fields in the OrderedDictionary we send in to the call.
Your Environment