-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ArgumentException when trying to parse po file with double entries #26
Comments
Hello @FabianFrischmann, could you provide an example of input that produces the error when fed to the parser? |
Of course, // a part of my en.po (shortened for a smaller size) msgid "common.all" msgid "common.all" |
Thank you. I can confirm that this is unwanted behavior, it should be reported as a diagnostic warning or error. I'm just not sure which one would be the better approach. That is, when a duplicate key is encountered,
I'm leaning towards option 1 because the rest of the file can still contain valid entries, so this allows the consumer to decide whether or not to ignore entries with duplicate keys. What's your opinion? |
Personally I am for Option 1. A duplicate Entry is not directly an error, the rest of the file might still be valid. Maybe count it as an error, if the file contains the key multiple times with differend values? |
👍
While this behavior may be somewhat justified, duplicate keys are definitely an indication of incorrect input that the user should deal with. So, maybe a warning is enough in both cases, I wouldn't complicate the parser by tracking values of duplicate entries. |
you're right |
Hi,
I noticed the following behaviour when trying to parse a po file containing the same key multiple times.
If I understood it correctly errors like this should be returned in POParserResult#Diagnostics or?
The current result hoever is the following:
The Lib tries to parse a file containing a key 2 times and throws.
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(System.ExceptionResource)
at System.Collections.ObjectModel.KeyedCollection<TKey, TItem>.AddKey(TKey, TItem)
at System.Collections.ObjectModel.KeyedCollection<TKey, TItem>.InsertItem(int, TItem)
at Karambolo.PO.POCatalog.InsertItem(int, Karambolo.PO.IPOEntry)
at System.Collections.ObjectModel.Collection.Add(T)
at Karambolo.PO.POParser.Parse(System.IO.TextReader)
at Karambolo.PO.POParserExtensions.Parse(Karambolo.PO.POParser, string)
at GuptaUtils.Extensions.LocalizationExtensions.VocabularyProvider.ParseFile(...) //reading and parsing the file
Is this behaviour intentional or an internal error?
Using version Karambolo.PO.Compact 1.11.1
The text was updated successfully, but these errors were encountered: