juliano.net
juliano.net

Reputation: 8177

Run sgen on a 5MB assembly with many classes with the same name

I'm trying to generate the XmlSerializers assembly for a project that outputs a 5MB dll. This project has many classes with different .Net namespaces but with the same name, so sgen is returning the error message "The top XML element 'XXXX' from namespace '' references distinct types XXXX and XXXX.

So I'm adding the TypeName property to the XmlTypeAttribute of every repeating class. The problem is, every time I run the SGEN command, it takes at least 15 minutes to show any feedback.

Do you have any suggestions?

Thanks.

Upvotes: 0

Views: 256

Answers (1)

Alexander
Alexander

Reputation: 4173

sgen is a single-threaded tool, it runs in two phases - in first, it generates source code for serialization assembly, and in second phase it compiles generated assembly.

Probably you can get some performance boost if you will separate and compile your classes into several assemblies (equal to number of CPU cores), run sgen in parallel for each assembly, and then merge resulting dlls into one xml serializer using ILMerge.

Upvotes: 1

Related Questions