Bug 2980 - Xaml collection properties cannot explicitly implement IList
Summary: Xaml collection properties cannot explicitly implement IList
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-01-19 21:01 UTC by Curtis Wensley
Modified: 2012-03-09 00:47 UTC (History)
2 users (show)

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


Attachments
Test to reproduce the problem (18.71 KB, application/zip)
2012-01-19 21:01 UTC, Curtis Wensley
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 GitHub or Developer Community 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 FIXED

Description Curtis Wensley 2012-01-19 21:01:22 UTC
Created attachment 1240 [details]
Test to reproduce the problem

When using a collection property, System.Xaml should allow for explicitly implemented IList (and IDictionary, IDictionary<K,V>?) properties.  

Currently a collection property must have an implicitly implemented Add() method.

More info on what a collection property should allow for:

http://msdn.microsoft.com/en-us/library/ms753379.aspx#Collection_Properties

Attached is a sample app.

Expected Results:
Should call IList.Add() on the collection property, if it implements IList.

Actual Results:
Unhandled Exception: System.InvalidOperationException: The collection type 'TestXaml.Items.CustomCollection' does not have 'Add' method
  at System.Xaml.Schema.XamlTypeInvoker.AddToCollection (System.Object instance, System.Object item) [0x00146] in /Users/curtis/Projects/External/mono/mono/mcs/class/System.Xaml/System.Xaml.Schema/XamlTypeInvoker.cs:93 
  at System.Xaml.XamlObjectWriterInternal.AddToCollectionIfAppropriate (System.Xaml.XamlType xt, System.Xaml.XamlMember xm, System.Object parent, System.Object obj, System.Object keyObj) [0x00071] in /Users/curtis/Projects/External/mono/mono/mcs/class/System.Xaml/System.Xaml/XamlObjectWriter.cs:466 
  at System.Xaml.XamlObjectWriterInternal.StoreAppropriatelyTypedValue (System.Object obj, System.Object keyObj) [0x00166] in /Users/curtis/Projects/External/mono/mono/mcs/class/System.Xaml/System.Xaml/XamlObjectWriter.cs:449 
  at System.Xaml.XamlObjectWriterInternal.OnWriteEndObject () [0x000b3] in /Users/curtis/Projects/External/mono/mono/mcs/class/System.Xaml/System.Xaml/XamlObjectWriter.cs:291 
  at System.Xaml.XamlWriterInternalBase.WriteEndObject () [0x00019] in /Users/curtis/Projects/External/mono/mono/mcs/class/System.Xaml/System.Xaml/XamlWriterInternalBase.cs:205 
  at System.Xaml.XamlObjectWriter.WriteEndObject () [0x00000] in /Users/curtis/Projects/External/mono/mono/mcs/class/System.Xaml/System.Xaml/XamlObjectWriter.cs:194 
  at System.Xaml.XamlWriter.WriteNode (System.Xaml.XamlReader reader) [0x0005d] in /Users/curtis/Projects/External/mono/mono/mcs/class/System.Xaml/System.Xaml/XamlWriter.cs:69 
  at System.Xaml.XamlServices.Transform (System.Xaml.XamlReader xamlReader, System.Xaml.XamlWriter xamlWriter, Boolean closeWriter) [0x00039] in /Users/curtis/Projects/External/mono/mono/mcs/class/System.Xaml/System.Xaml/XamlServices.cs:123 
  at System.Xaml.XamlServices.Transform (System.Xaml.XamlReader xamlReader, System.Xaml.XamlWriter xamlWriter) [0x00000] in /Users/curtis/Projects/External/mono/mono/mcs/class/System.Xaml/System.Xaml/XamlServices.cs:109 
  at TestXaml.MainClass.Main (System.String[] args) [0x00032] in /Users/curtis/Projects/TestXaml/TestXaml/Main.cs:20
Comment 1 Curtis Wensley 2012-01-19 21:20:43 UTC
This aught to do it for the most part:

https://github.com/cwensley/mono/commit/627ba88183aaeb73468952d5d99057fdeb44ef7d

This doesn't implement the generic IDictionary<>, Array (with array markup extension) or IAddChild (which I think is WPF specific anyway).
Comment 2 Atsushi Eno 2012-03-09 00:47:24 UTC
This specific issue is fixed in git master 1899ac3. Thanks for the report.