Skip to content
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

Exception Thrown: AustraliaPublicHoliday #27

Closed
dotnetshadow opened this issue Apr 28, 2018 · 2 comments
Closed

Exception Thrown: AustraliaPublicHoliday #27

dotnetshadow opened this issue Apr 28, 2018 · 2 comments
Assignees

Comments

@dotnetshadow
Copy link

dotnetshadow commented Apr 28, 2018

Hi there,

Firstly a great library, but I have a come across an issue while using your library:

Using **Australian Public Holiday** with state **NSW** and Year **2016**

Code

// Get the holidays based on state
var calendar = new AustraliaPublicHoliday { State = AustraliaPublicHoliday.States.NSW };
var result = calendar.PublicHolidayNames(2016);

**Exception: Message: "An item with the same key has already been added. Key: [26/12/2016 12:00:00 AM, Boxing Day]" **

'calendar.PublicHolidayNames(2016)' threw an exception of type 'System.ArgumentException'
    Data: {System.Collections.ListDictionaryInternal}
    HResult: -2147024809
    HelpLink: null
    InnerException: null
    Message: "An item with the same key has already been added. Key: [26/12/2016 12:00:00 AM, Boxing Day]"
    ParamName: null
    Source: "System.Collections"
    StackTrace: "   at System.Collections.Generic.TreeSet`1.AddIfNotPresent(T item)\r\n   at System.Collections.Generic.SortedDictionary`2.Add(TKey key, TValue value)\r\n   at PublicHoliday.AustraliaPublicHoliday.PublicHolidayNames(Int32 year)"
    TargetSite: {Boolean AddIfNotPresent(T)}

Even though this error shouldn't really be happening, as a first step I think it's important to ensure that the same item can't be added twice.

@martinjw
Copy link
Owner

It was an error in the Boxing Day calculation. A check to avoid adding the date twice would have returned a wrong result (missing Boxing Day).

Thanks for the report! It'll be on nuget soon...

@martinjw martinjw self-assigned this Apr 28, 2018
@dotnetshadow
Copy link
Author

Cheers thanks for that, good point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants