HomeSeer / Plugin-SDK

Plugin development kit for the 4th major edition of the HomeSeer platform.
https://www.nuget.org/packages/HomeSeer-PluginSDK/
GNU Affero General Public License v3.0
20 stars 4 forks source link

PED named key does not honor case when retried from Feature object #50

Closed mcsSolutions closed 4 years ago

mcsSolutions commented 4 years ago

https://forums.homeseer.com/forum/developer-support/hs4-development-private/hs4-bugs/1347090-ped-named-key-does-not-honor-case-when-retried-from-feature-object

jldubz commented 4 years ago

@mcsSolutions

It looks like this has been the case since HS3 and probably prior to that as well. The source for PlugExtraData.vb shows that all keys are converted to lower

        Public Function AddNamed(ByVal Key As String, ByVal Obj As Object) As Boolean
            Try
                If Key Is Nothing Then Return False
                If String.IsNullOrEmpty(Key.Trim) Then Return False
                If Obj Is Nothing Then Return False
                CheckNamed()
                SyncLock Ncol.SyncRoot
                    Try
                        If Ncol.ContainsKey(Key.Trim.ToLower) Then Return False
                        SyncLock Ncol.SyncRoot
                            Ncol.Add(Key.Trim.ToLower, Obj)
                        End SyncLock
                        Return True
                    Catch ex As Exception
                        Return False
                    End Try
                End SyncLock
            Catch ex As Exception
                Return False
            End Try
        End Function

        Public Function AddUnNamed(ByVal Obj As Object) As Integer
            Try
                If Obj Is Nothing Then Return -1
                CheckUnNamed()
                SyncLock UNcol.SyncRoot
                    Return UNcol.Add(Obj)
                End SyncLock
            Catch ex As Exception
                Return -1
            End Try
        End Function

Until we can discard support for legacy code and data objects, there is not a simple way around this. We will have to update the documentation to specify that all keys are converted to lower until we can design a proper patch for this.

I'll update the inline docs for the next release.

Referenced by PSDK-18

jldubz commented 4 years ago

I'm closing this issue, but I have noted all of this for future updates.