Bug 28014 - Type is not serializable with a type-forwarded SerializableAttribute
Summary: Type is not serializable with a type-forwarded SerializableAttribute
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 3.12.0
Hardware: Other Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2015-03-13 12:37 UTC by bgergo
Modified: 2015-04-07 08:56 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Run ConsoleApp from the solution both with Xamarin.Mac and Visual Studio 2012. (60.95 KB, application/x-zip-compressed)
2015-03-13 12:37 UTC, bgergo

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

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