1

Closed

cannot get list of items from deserialize method.

description

hello,
i am trying to deserialize a .csproj file , but it seems that the list of ItemGroups and PropertyGroups does not get populated in the strongly typed class when i deserialize from file. I get zero elements returned although the xml file has items.
I have checked documentation and have added all attributes correctly based on what i have understood.
I would appreciate if some can take a look at attached example and detect whether it is a bug or a missing setting.
Thanks
yiannis

file attachments

Closed Oct 14, 2012 at 2:06 PM by sina_iravanian
Solved in 2.10

comments

sina_iravanian wrote Sep 3, 2012 at 11:04 AM

Hello Yiannis,

I inspected the problem. Since the XML document (.csproj file) contains an XML Namespace (xmlns) attribute, the fully qualified name for each element is hence modified. YAXLib supports XML namespaces through [YAXNamespace] attribute or simply putting the namespace in curly braces inside alias names as in: [YAXSerializeAs("{path/to/namespace}Alias")]

But your sample revealed other bugs in these attributes too.

The quickest workaround for this problem before these bugs are fixed is to remove the xmlns attribute from the input files, before handing it to YAXLib.

giannik wrote Sep 3, 2012 at 8:15 PM

thanks.
followed the workaround and worked out great.

sina_iravanian wrote Oct 2, 2012 at 3:35 AM

Yiannis,

This problem is solved in YAXLib 2.10. This version fully supports namespaces. The only thing you need to do is to add a the following attribute to your topmost class:
[YAXNamespace("http://schemas.microsoft.com/developer/msbuild/2003")]

Also, you do not need to store the value of xmlns attribute in a separate property. For a demo based on your issue see the following sample class in the source code:
YAXLib / YAXLibTests / SampleClasses / CsprojParser.cs
or see it live from here:
https://github.com/sinairv/YAXLib/blob/master/YAXLibTests/SampleClasses/CsprojParser.cs

Please let me know if the issue is solved or exists.

giannik wrote Oct 16, 2012 at 1:01 PM

hello,
I confirm that the problem is now solved with new version 2.11. I have tested it out.
Thank you
Giannis