Bug 54412 - Merged ResourceDictionary Returning Incorrect Count
Summary: Merged ResourceDictionary Returning Incorrect Count
Status: RESOLVED FEATURE
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-04-03 17:44 UTC by Jimmy [MSFT]
Modified: 2017-04-04 07:49 UTC (History)
2 users (show)

Tags: merged resourcedictionary
Is this bug a regression?: ---
Last known good build: 2.3.3.193


Attachments
Repro project (295.51 KB, application/x-zip-compressed)
2017-04-03 17:46 UTC, Jimmy [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FEATURE

Description Jimmy [MSFT] 2017-04-03 17:44:58 UTC
### Overview
A ResourceDictionary that is merged with another one is reporting only its resources for its Count. 

For example, if Application.Resources has a single resource and is merged with another ResourceDictionary with also one resource, App.Current.Resources.Count is returning 1.

This appears to be a regression that started in Forms 2.3.4-pre1.

### Steps to Reproduce
1. Run the attached project


### Expected Results
The Button style is defined in App.xaml while the Label style is defined in TestDictionary.xaml. The second Label shows the result of App.Current.Resources.Count and should return 2.


### Actual Results
Even though both styles are working as expected, App.Current.Resources.Count returns 1.


### Regression Test
2.3.5.76        BAD
2.3.4-pre6      BAD
2.3.4-pre1      BAD
2.3.3.193       GOOD
Comment 1 Jimmy [MSFT] 2017-04-03 17:46:13 UTC
Created attachment 21156 [details]
Repro project
Comment 2 Jimmy [MSFT] 2017-04-03 18:24:30 UTC
I talked with the team and this is an intentional change. Previously Count would return the sum of resources including other merged dictionaries, but the enumerator only returned the content of the referenced dictionary. 

Starting with Forms 2.3.4, the behavior is now consistent and both Count and the enumerator return only the items from the referenced ResourceDictionary.