.NET Forum / Windows Forms / Design Time / March 2005
REPOST: TypeConverter Problems
|
|
Thread rating:  |
Alex Clark - 09 Mar 2005 11:30 GMT (Repost as my original didn't have my MSDN registered email addy)
Hi all,
I'm coding a custom component which is designed to be dropped onto a form and have it's properties manipulated at runtime. I have a custom implementation of the TypeConverter class called UniversalTypeConverter which inherits from ExpandableObjectConverter, and for the most part this is serializing my properties to code without problem, except for a minor quirk.
In simple terms, my Class hierarchy is as follows:
MyComponent |_ Collection (Strongly Typed Implementation of Class A) |_ Item (Class A) |_ Read/Write Property (Class B) |_ Collection (Strongly Typed Implementation of Class C)
My problem is that with the class hierarchy layed out as above, VS does NOT serialize the items in the collection of Class C (collection is a property of Class B) to my code. I can add them using the property editor in VS no problem, but when I go back to the collection, it's empty (this happens even if I don't rebuild/save the project in between). Class A, Class B, and Class C are all attributed with my UniversalTypeConverter, which is geared up to handle each of them.
I know this sounds like I'm doing something wrong with my TypeConverter, but I've tested it separately on each of these classes and it works fine. For example, when I add a test property to my component as below....
MyComponent |_ Test Property (Class A) {tested as ReadOnly and Read/Write} |_ Read/Write Property (Class B) |_ Collection (Strongly Typed Implementation of Class C)
...and I add items to the Class C collection on the above test property, VS works perfectly. Equally, I had to set it up as follows as a workaround, which works perfectly...
MyComponent |_ Collection (Strongly Typed Implementation of Class A) |_ Item (Class A) |_ Collection (Strongly Typed Implementation of Class C) --> Points to Class A's private variable of type Class B
So essentially, in Class A, instead of...
Public Property MyClassB As ClassB ...get/set... End Property (doesn't work)
I have the following...
Public Readonly Property MyClassCs Get Returns m_MyClassB.MyClassCCollection End Get End Property
Which works fine with VS, it's able to serialize the items in the collection no problem.
Let me clear up the obvious: DesignerSerializationVisibility(Content) has been attributed to properties where applicable. I've tried my TypeConverter with constructors that both are and are not full descriptors of the object instance, I've tried removing properties and restructuring them in my Class C, but none of it has had any effect.
I've even attached another instance of VS to the first in order to debug it and step through the code generation. It correctly identifies items in the collection when it comes to serialize it out to code. It just doesn't seem to want to do it. No exceptions are thrown (I had it trapping all .NET exceptions, even those that were handled).
The really weird thing is, if I add something to this collection and then change just one other minor property on ClassB, THEN the contents of the collection are serialized to code correctly. It's as though VS.NET doesn't deem there to have been enough of a change to warrant updating the code if the only thing I've done is modified the collection on ClassB!
So my question is, is there some limit as to the "depth" that VS's code generator can go when serializing component properties to code? I've just proven to myself that the only way my component can work is to make the collection property one step "shallower", ie move it up a level in my class hierarchy. Then VS generates the code flawlessly.
Can someone from MS please confirm/deny this?
Many thanks,
Alex Clark
Kevin Yu [MSFT] - 10 Mar 2005 02:23 GMT Hi Alex,
We have reviewed this issue and are currently researching on it. We will update you ASAP. Thanks for your patience!
Kevin Yu
 Signature ======= "This posting is provided "AS IS" with no warranties, and confers no rights."
"Jeffrey Tan[MSFT]" - 11 Mar 2005 02:27 GMT Hi Alex,
Sorry for the delay reponse.
I think you meet a problem with implementing a customized TypeConverter for deep nested collection property, you want to know if this is the limiation of Winform designer code serializer.
Currently, I have done some internal document search and known issues search, but I did not find any colleciton depth related issue with implementing TypeConverter and code serialization. So I still can not confirm this as a known issue for you.
To help us track out this issue better, can you please create a little sample project which demenstrate this problem? Once I have a sample project to reproduce this issue, we can work it out faster and more efficient.
I will wait for your further feedback. Thanks
Best regards, Jeffrey Tan Microsoft Online Partner Support
 Signature Get Secure! - www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.
Alex Clark - 11 Mar 2005 12:29 GMT Jeffrey Can I email it to you directly please? What address should I use?
Thanks, Alex Clark
> Hi Alex, > [quoted text clipped - 22 lines] > Get Secure! - www.microsoft.com/security > This posting is provided "as is" with no warranties and confers no rights. "Jeffrey Tan[MSFT]" - 14 Mar 2005 02:08 GMT Hi Alex,
Thanks for your feedback!!
Normally, we suggest you attach your sample project in the newsgroup, then all the community members can refer to it and give more information. If you have any concern can not attach the project in the newsgroup, please feel free to tell me, thanks.
To directly email me, you may remove "online." from my email address in my reply title. I will wait for your project, thanks again.
Best regards, Jeffrey Tan Microsoft Online Partner Support
 Signature Get Secure! - www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.
Alex Clark - 14 Mar 2005 13:43 GMT Thanks Jeffrey,
I've sent it to your MS email. I'll be happy to post details here of how the problem was resolved so that the whole newsgroup can benefit.
Thanks, Alex Clark
> Hi Alex, > [quoted text clipped - 14 lines] > Get Secure! - www.microsoft.com/security > This posting is provided "as is" with no warranties and confers no rights. "Jeffrey Tan[MSFT]" - 15 Mar 2005 07:30 GMT Hi Alex,
Thanks for your sample project. I have referred it and reproduced out your issue. I will do some research in this issue and reply to you ASAP. Thanks for your understanding.
Best regards, Jeffrey Tan Microsoft Online Partner Support
 Signature Get Secure! - www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.
Alex Clark - 18 Mar 2005 01:59 GMT Hi Jeffrey,
Any progress on this?
Kind Regards, Alex Clark
> Hi Alex, > [quoted text clipped - 7 lines] > Get Secure! - www.microsoft.com/security > This posting is provided "as is" with no warranties and confers no rights. "Jeffrey Tan[MSFT]" - 18 Mar 2005 09:15 GMT Hi Alex,
Sorry for letting you wait for so long.
Actually, we have forward this issue to the product team side, we have got some response from him, which confirmed this as a limitation. Currently, we are still working on this issue to find a workaround for it. I will update you ASAP. Thanks for your understanding!!
Best regards, Jeffrey Tan Microsoft Online Partner Support
 Signature Get Secure! - www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.
Alex Clark - 22 Mar 2005 12:56 GMT Hi Jeffrey,
Any workaround found for this? Also, can I assume it's going to be fixed in VS2005? I can live with it for now if I know the next release will have it fixed, but I hope the Whidbey product team are planning to rectify it.
Kind Regards, Alex Clark
> Hi Alex, > [quoted text clipped - 10 lines] > Get Secure! - www.microsoft.com/security > This posting is provided "as is" with no warranties and confers no rights.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|