emorydunn / StreamDeckPlugin

A library for creating Stream Deck plugins in Swift.
https://emorydunn.github.io/StreamDeckPlugin/
MIT License
50 stars 7 forks source link

capitalisation for keys in global settings (and possibly in other locations) #25

Closed justme-1968 closed 6 months ago

justme-1968 commented 6 months ago

i have just noticed that the stringified json that is send for setGlobalSettings has the names of the keys changed from mixed case (like 'apiKey') to first letter capitalised (like 'Apikey') this is not noticeable in the plugin itself as this is reverted in the didReceiveGlobalSettings event so everything including your tests look normal.

but it is a problem in using the property inspector as the keys seen there are not what was send. also settings saved from the property inspector will not match what is expected on the plugin side.

i have verified that the problem is indeed on the plugin side as even the message in the debugger will show the wrong case: Setting value for Apikey to Optional("1"). also the json string received on the pi java script side has the wrong case before even decoding the string.

i think the problem lies here in GlobalSettingKey.swift:

extension GlobalSettingKey {
    public static var name: String {
        String(describing: self)
    }
}
emorydunn commented 6 months ago

I'll investigate this, I don't think I've noticed any issues in my plugins, but perhaps the keys are just working out so I'm not running into it.

emorydunn commented 6 months ago

Looks like I was using the provided key to generate the type names, but wasn't actually using it for the actual key name in the macro. I've updated the macro to provide an override for the name property.