Bug 28014

Summary: Type is not serializable with a type-forwarded SerializableAttribute
Product: [Mono] Compilers Reporter: bgergo <bgergo.mac>
Component: C#Assignee: Marek Safar <masafa>
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: 3.12.0   
Target Milestone: ---   
Hardware: Other   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Run ConsoleApp from the solution both with Xamarin.Mac and Visual Studio 2012.

Description bgergo 2015-03-13 12:37:20 UTC
Created attachment 10325 [details]
Run ConsoleApp from the solution both with Xamarin.Mac and Visual Studio 2012.

I am evaluating Xamarin.Mac on OSX.

With the mono compiler there is no way to mark a class serializable in a PCL (Portable Class Library). Everything works fine with the windows csc, but not with the mono compiler.

I have made a small test console application:
 - during compile, the SerializableAttribute used on Lib1.MyClass is resolved using ShimLib.
 - but in the bin directory, ShimLib is overwritten with ShimLib.Forward (having the same strong name), which doesn't contain any implementation but forwards SerializableAttribute to mscorlib (using TypeForwardedTo).

The application displays the name and location of the SerializableAttribute used on Lib1.MyClass, which is correct both with csc and mono compiler.

But Lib1.MyClass is only serializable with csc!

I know that type-forwarding is a hack, but its needed many times when working with PCLs.

Please make the mono compiler handle this situation, or make it similar to the windows csharp compiler which doesn't check the origin of SerializableAttribute.

Thank you.
Comment 1 Marek Safar 2015-04-07 08:56:18 UTC
Fixed in master