tomasmcguinness / dotnet-passbook

A .Net Library for generating Apple Passbook (Wallet) files for iOS. Please get involved by creating pull requests and opening issues!
MIT License
318 stars 117 forks source link

Adding fields should throw an error if there is a duplicate #147

Closed KiwiVandi closed 2 years ago

KiwiVandi commented 2 years ago

This dotnet library will fail to actually create the pkpass if the dev has used the same key for example:

 request.AddPrimaryField(new StandardField("name", "London", "LDN"));

 request.AddSecondaryField(new StandardField("name", "Gate", "A55"));

 request.AddAuxiliaryField(new StandardField("name", "Seat", "G5"));

These 3 fields although being added for different section in the pkpass are using the same key 'name', the code still runs and produces the pkpass, only when viewing the system logs of the iOS device can we see the reason the PKPass cannot be loaded is due to the duplicate keys.

I think the dotnet library should throw an error on duplicate keys to save developers a headache. (Source: Developer that got a headache from this).

With the permission of Tomas I will make a PR suggestion checking for the validity of this data starting with checking for duplicate keys.

tomasmcguinness commented 2 years ago

Thanks. That's an excellent suggestions.