Bug 60316 - Merged Dirctionaries bug with hierarchically merging
Summary: Merged Dirctionaries bug with hierarchically merging
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: unspecified
Hardware: PC Windows
: Normal enhancement
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-23 09:53 UTC by makeman
Modified: 2017-10-23 21:51 UTC (History)
4 users (show)

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

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 ANSWERED

Description makeman 2017-10-23 09:53:35 UTC
Current implementation of Merged Dictionaries contain the bug when we try to merge some dictionaries hierarchically. Just try to run following test method on 'master' brunch and WPF or UWP.

    public static void MergedDictionariesDeepSublevels()
    {
	    var rd0 = new ResourceDictionary();
	    var rd1 = new ResourceDictionary { { "Key1", "Level1" } };
	    var rd2 = new ResourceDictionary { { "Key2", "Level2" } };

	    rd0.MergedDictionaries.Add(rd1);
	    rd1.MergedDictionaries.Add(rd2);

	    Assert.That(rd0["Key1"], "Level1");
	    Assert.That(rd0["Key2"], "Level2"); // <= fail on master, work on WPF or UWP

	    //Assert.That(rd0.ContainsKey("Key1"), Is.EqualTo(true));
	    //Assert.That(rd0.ContainsKey("Key2"), Is.EqualTo(true));
    }

For fix details see:
https://github.com/xamarin/Xamarin.Forms/pull/1218
https://github.com/xamarin/Xamarin.Forms/pull/1215
Comment 1 Dániel Buga 2017-10-23 10:14:18 UTC
While Xamarin Forms is neither WPF, nor UWP, when technologies are this similar in both style and intent, I think the principle of least surprise should apply and the behaviour of XF's MergedDictionaries should reflect what's already implemented in the .NET platforms. While not necessarily related, I believe this is analogous to the work done on XAML Standard and .NET Standard where the aim is to align these platforms.

Stephane Delcroix commented here: https://github.com/xamarin/Xamarin.Forms/pull/1215#discussion_r146193863 that is it not a bug but it was done on purpose, he did not give any explanation or reference to why. Because of this and the above reasoning, I, too, believe that this is an issue that should be fixed.
Comment 2 Adam 2017-10-23 11:32:39 UTC
This isn't actually a bug, it would be a new feature request. MergedWith and MergedDictionaries don't have a traversal into deeper layers, they never have.

While this is certainly possible, and i'm all for looking into adding it, because it would be a good feature add, it should be discussed first, then a PR submitted, once someone on the XF team approves of it.
Comment 3 Paul DiPietro [MSFT] 2017-10-23 18:08:56 UTC
I suggest moving this discussion to the Evolution forum per the above comment.

https://forums.xamarin.com/categories/xamarin-forms-evolution