Bug 3003 - XamlObjectWriterSettings events are not called
Summary: XamlObjectWriterSettings events are not called
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-21 03:52 UTC by Curtis Wensley
Modified: 2012-03-09 16:19 UTC (History)
2 users (show)

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


Attachments
Sample to test xaml events (5.03 KB, application/zip)
2012-03-08 13:56 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-21 03:52:06 UTC
The XamlObjectWriterSettings has these events:

AfterBeginInitHandler
AfterEndInitHandler
AfterPropertiesHandler
BeforePropertiesHandler
XamlSetValueHandler

These do not seem to be called when the corresponding action happens in the XamlObjectWriter
Comment 1 Atsushi Eno 2012-03-08 09:18:23 UTC
They are left not implemented because there is no documentation on when those events could be invoked. Yet XamlSetValueHandler is actually used.
https://github.com/mono/mono/blob/master/mcs/class/System.Xaml/System.Xaml/XamlObjectWriter.cs#L390
Could you elaborate us, to explain 1) when those events could be invoked, and/or 2) provide a test case that illustrates the usage of those events?
Comment 2 Curtis Wensley 2012-03-08 13:56:06 UTC
Created attachment 1487 [details]
Sample to test xaml events

I agree there is very sparse information.  From looking through the documentation, this is what I can assume is going on:

AfterBeginInit/AfterEndInit follow the ISupportInitialze calls, which are called before and after complete initialization of an object. I don't think the xamlobjectwriter implements ISupportInitialize yet either, but could be done at the same time.

Before/AfterProperties are less explanatory in when exactly they should be called. It seems that they are similar to the Begin/EndInit, but AfterProperties are called before the object is added/set to the parent, whereas EndInit is called after.

I've created a sample app that gives the following output on MS.NET:

Parent Constructed
ISupportInitialize.BeginInit: Parent
XamlObjectWriterSettings.AfterBeginInit: Parent
XamlObjectWriterSettings.BeforeProperties: Parent
XamlObjectWriterSettings.XamlSetValue: Parent Title, Member: Title
Parent.Title_set: Parent
Child Constructed
ISupportInitialize.BeginInit: Child
XamlObjectWriterSettings.AfterBeginInit: Child
XamlObjectWriterSettings.BeforeProperties: Child
XamlObjectWriterSettings.XamlSetValue: child 1, Member: AssociatedProperty
Parent.SetAssociatedProperty: child 1
XamlObjectWriterSettings.XamlSetValue: Child Title 1, Member: Title
Child.Title_set: Child
XamlObjectWriterSettings.AfterProperties: Child
Item 'Child' inserted at index '0'
ISupportInitialize.EndInit: Child
XamlObjectWriterSettings.AfterEndInit: Child
Child Constructed
ISupportInitialize.BeginInit: Child
XamlObjectWriterSettings.AfterBeginInit: Child
XamlObjectWriterSettings.BeforeProperties: Child
XamlObjectWriterSettings.XamlSetValue: child 2, Member: AssociatedProperty
Parent.SetAssociatedProperty: child 2
XamlObjectWriterSettings.XamlSetValue: Child Title 2, Member: Title
Child.Title_set: Child
XamlObjectWriterSettings.AfterProperties: Child
Item 'Child' inserted at index '1'
ISupportInitialize.EndInit: Child
XamlObjectWriterSettings.AfterEndInit: Child
XamlObjectWriterSettings.AfterProperties: Parent
ISupportInitialize.EndInit: Parent
XamlObjectWriterSettings.AfterEndInit: Parent
Loaded Parent

The output in mono/master:

Parent Constructed
XamlObjectWriterSettings.XamlSetValue: Parent Title, Member: Title
Child Constructed
Parent.SetAssociatedProperty: child 1
XamlObjectWriterSettings.XamlSetValue: Child Title 1, Member: Title
Item 'Child' inserted at index '0'
Child Constructed
Parent.SetAssociatedProperty: child 2
XamlObjectWriterSettings.XamlSetValue: Child Title 2, Member: Title
Item 'Child' inserted at index '1'
Loaded Parent
Comment 3 Atsushi Eno 2012-03-08 23:50:09 UTC
Wow, thanks very much for the detailed usage description, analysis and test code :) It seems I have to begin with fixing another Add() issue. I will keep you updated on another bug entry for that.
Comment 4 Atsushi Eno 2012-03-09 05:02:04 UTC
Fixed in git master (bf48e7823d ... d7d2e98). Now we get identical output to this test case. Thanks again for the nice test.
Comment 5 Curtis Wensley 2012-03-09 16:19:03 UTC
Awesome!  Though one glitch.  I forgot to add a test for singular child properties (instead of using a collection as in the provided example).  It seems that the Child.EndInit() is called *before* the child is set to the parent property. 

Shall I submit another bug?  I can send an updated test app if needed.