HighTechTalks DotNet Forums  

InheritedPropertyDescriptor vs. ReflectedPropertyDescriptor

Dotnet Framework (WinForms DesignTime) microsoft.public.dotnet.framework.windowsforms.designtime


Discuss InheritedPropertyDescriptor vs. ReflectedPropertyDescriptor in the Dotnet Framework (WinForms DesignTime) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #21  
Old   
Notre Poubelle
 
Posts: n/a

Default Re: InheritedPropertyDescriptor vs. ReflectedPropertyDescriptor - 03-29-2007 , 12:48 PM






Hi Linda,

I think we're taking little steps closer to resolving this very long
discussion. Thanks for your continued involvement!

I think what we're starting to agree is that the DefaultValueAttribute does
not work for InheritedPropertyDescirptors. We also agree that the
ShouldSerialize method does work, but that it requires the return value to be
False at object construction time.

We also seem to agree that ReflectedPropertyDescriptor does not behave the
same as InheritedPropertyDescriptor. It has been my experience that a
ReflectedPropertyDescriptor will allow
PropertyDescriptor.ShouldSerializeValue to return True if either the
DefaultValueAttribute is used appropriately, the ShouldSerialize/Reset
methods are present (instead of the DefaultValueAttribute), or neither of
these two sets (DefaultValueAttribute or ShouldSerialize/Reset methods) are
present for the property. Based on my experience, and the latest comments in
your last post, InheritedPropertyDescriptor requires that a ShouldSerialize
method is present, and that this method must return false at construction
time.

Because these two classes behave differently, the developer needs to be
aware of the differences in these two internal classes so that he can
properly write his code such that his properties are serialized.

Thanks,
Notre

Reply With Quote
  #22  
Old   
Linda Liu [MSFT]
 
Posts: n/a

Default Re: InheritedPropertyDescriptor vs. ReflectedPropertyDescriptor - 04-06-2007 , 08:48 AM






Hi Notre,

Thank you for your persistence on this issue.

After discussion, Microsoft is considering on modifying the MSDN
documentation to remark how the InheritedPropertyDescriptor behaves
different from ReflectPropertyDescriptor.

You have helped us make progress and it's our honour to have a customer
like you : )

Have a nice weekend!

Cheers,

Linda Liu
Microsoft Online Community Support


Reply With Quote
  #23  
Old   
Notre Poubelle
 
Posts: n/a

Default Re: InheritedPropertyDescriptor vs. ReflectedPropertyDescriptor - 04-06-2007 , 06:02 PM



Thank you, your expert consult, and Sergey for all of your help in this
issue. It really took everyone to get it resolved.

Sincerely,
Notre


Reply With Quote
  #24  
Old   
donetcoder
 
Posts: n/a

Default Re: InheritedPropertyDescriptor vs. ReflectedPropertyDescriptor - 12-10-2007 , 01:52 PM



I'm not sure I understand the work around or solution for this issue. I have
run into the same thing and this is the only info out there on this subject.
ShouldSerializeValue comes back false no matter what. I have tried the
ShouldSerializeMYMEMBERNAME but mine don't seem to be called.

Any help would be appreciated.


"Notre Poubelle" wrote:

Quote:
Hi Linda,

I don't know if I agree with this comment:

In addition, we should always write a ShouldSerialize<PropertyName> method
for each property we'd like to serialize.

I'll explain why I'm not so sure in a moment. As for this comment:

We should always use
TypeDescriptor.GetProperties(component) in our serializer and call the
ShouldSerializeValue method on each property to tell if it should be
serialized.


I completely agree with the above statement, and this is what I'm doing.
But this is where my concern with the previous statement (that we should
always write a ShouldSerialize<PropertyName> method for each property we wish
to serialize) comes in.

The documentation for PropertyDescriptor.ShouldSerializeValue
(http://msdn2.microsoft.com/en-us/lib...izevalue.aspx),
says that it first looks for a default value by looking for a
DefaultValueAttribute. If this is not found, then it looks for a
"ShouldSerializeMyProperty" method.

The documentation *does* say that you need to implement the
"ShouldSerializeMyProeprty" method, but I read this to mean that it not
actually required by the design pattern, but rather is a way of refining the
behaviour of PropertyDescriptor.ShouldSerializeValue beyond what is possible
with the DefaultValueAttribute.

I make this conclusion because of later statements in the documentation that
say: "If this method cannot find a DefaultValueAttribute or a
"ShouldSerializeMyProperty" method, it cannot create optimizations and it
returns true." This is NOT the case with the implementation of
InheritedPropertyDescriptor.ShouldSerializeValue; if I have not used a
DefaultValueAttribute (or even if do, it seems to make no difference) and if
do not include a "ShouldSerializeMyProperty", then
InheritedPropertyDescriptor.ShouldSerializeValue returns False rather than
True.

The fact that the component designer is substituting different property
descriptors should be invisible to you.

I agree that this would be ideal, and it is what the documentation suggests
should be the case. However, my experience does not agree with this
statement, nor the documentation.

Thanks,
Notre

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.