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

Issue with InterwikiMap #93

Closed
rwv37 opened this issue Jan 27, 2022 · 1 comment
Closed

Issue with InterwikiMap #93

rwv37 opened this issue Jan 27, 2022 · 1 comment
Assignees
Milestone

Comments

@rwv37
Copy link

rwv37 commented Jan 27, 2022

I used WCL to pull the InterwikiMap from Wikipedia. I had the following code, to put a particular item from it in a collection of my own:

        if (this.ReferenceSite.InterwikiMap.Contains(namespaceOrWhatever))
        {
            this.AddWantedInterwiki(this.ReferenceSite.InterwikiMap[namespaceOrWhatever]);
        }

That throws the following exception:

Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'Toollabs' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at WikiClientLibrary.Sites.InterwikiMap.get_Item(String prefix)
   at Rwv37.MediaWiki.SiteSetup.Coordinator.AddWantedColonfulWikiPage(WikiPage wikiPage) in C:\Users\bob\Bob\trunk\Dev\DotNet\Rwv37\MediaWiki\Rwv37.MediaWiki.SiteSetup\Coordinator.cs:line 250
   at Rwv37.MediaWiki.SiteSetup.Coordinator.AddWantedWikiPage(WikiPage wikiPage) in C:\Users\bob\Bob\trunk\Dev\DotNet\Rwv37\MediaWiki\Rwv37.MediaWiki.SiteSetup\Coordinator.cs:line 215
   at Rwv37.MediaWiki.SiteSetup.WantedItemsListRetriever.RetrievePagesAsync() in C:\Users\bob\Bob\trunk\Dev\DotNet\Rwv37\MediaWiki\Rwv37.MediaWiki.SiteSetup\WantedItemsListRetriever.cs:line 49
   at Rwv37.MediaWiki.SiteSetup.WantedItemsListRetriever.RetrievePagesAsync() in C:\Users\bob\Bob\trunk\Dev\DotNet\Rwv37\MediaWiki\Rwv37.MediaWiki.SiteSetup\WantedItemsListRetriever.cs:line 49
   at Rwv37.MediaWiki.SiteSetup.WantedItemsListRetriever.RetrieveAsync() in C:\Users\bob\Bob\trunk\Dev\DotNet\Rwv37\MediaWiki\Rwv37.MediaWiki.SiteSetup\WantedItemsListRetriever.cs:line 34
   at Rwv37.MediaWiki.SiteSetup.Coordinator.GoAsync() in C:\Users\bob\Bob\trunk\Dev\DotNet\Rwv37\MediaWiki\Rwv37.MediaWiki.SiteSetup\Coordinator.cs:line 54
   at Rwv37.MediaWiki.SiteSetup.Program.<Main>(String[] args)

Note that the exact same key is used in the calls to Contains and [], so it seems strange that Contains would say the key is in there while at the same time [] would say it is not.

Also note the key is "Toollabs" with a capital T, but Wikipedia's interwiki entries are (I think) all lowercase. So, on a hunch, I tried adding a ToLower call on one (and only one) of them:

        if (this.ReferenceSite.InterwikiMap.Contains(namespaceOrWhatever))
        {
            this.AddWantedInterwiki(this.ReferenceSite.InterwikiMap[namespaceOrWhatever.ToLower()]);
        }

And it started working fine. So I think there might be a mismatch between the case-sensitivity-or-not of Contains and [] (which, if correct, would contradict the documentation).

@CXuesong CXuesong self-assigned this Jan 29, 2022
@CXuesong CXuesong added this to the v0.8.0 milestone Jan 29, 2022
@CXuesong
Copy link
Owner

CXuesong commented Jan 29, 2022

Bug fixed and released v0.8.0-int.5. Please try again with the latest package.

@CXuesong CXuesong closed this as completed Feb 8, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants