|
Bugzilla – Full Text Bug Listing |
| Summary: | Using WCF DataContractSerializer to serialize object derived from DynamicObject is not throwing proper exception | ||
|---|---|---|---|
| Product: | [Mono] Mono: Class Libraries | Reporter: | David Curylo <curylod> |
| Component: | WCF | Assignee: | Atsushi Enomoto <atsushieno> |
| Status: | NEW --- | QA Contact: | Mono Bugs <mono-bugs> |
| Severity: | Enhancement | ||
| Priority: | P5 - None | ||
| Version: | 2.8.x | ||
| Target Milestone: | --- | ||
| Hardware: | 64bit | ||
| OS: | Mac OS X 10.6 | ||
| Whiteboard: | |||
| Found By: | --- | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
| Attachments: | Sample code for reproducing this bug. | ||
This serializability verification is now in WCF part in git master (4a5f7c7). However, since DynamicObject class in Mono (unlike .NET) is indeed marked as [Serializable], this incompatibility still happens and it cannot be fixed in WCF side. I cannot blindly remove this attribute for the fear of any possible behavioral breakage. CCing Marek. I think this is more .net limitation than feature. We are not doing anything wrong here just allow more sensible behaviour than .net 4. I know it can break serialization when doing mono -> .net. Our code is solely based on DLR which should be inline with .net. I think there is quite high possibility that the missing Serializable will be fixed in the next .net version. I don't agree. Both runtimes should offer the same behavior. The problem with it being limited one one framework and not limited on the other is that this creates an incompatibility. If a developer builds and develops their code under Mono, and then deploys to .NET, their code will fail when deployed on a different, pseudo-compatible framework. In that case, the only way to be sure code will work on either framework would be to build on .NET and test for compatibility with Mono. Also, there is no reason to believe that a future version of the DLR will offer a DynamicObject that supports serialization, but if it ever did, that would be the time to enable similar behavior on Mono. Picking and choosing when which functionality to implement based on design opinions rather than compatibility defeats the purpose of Mono as a "cross platform implementation of .NET." (In reply to comment #2) > I think this is more .net limitation than feature. We are not doing anything > wrong here just allow more sensible behaviour than .net 4. I know it can break > serialization when doing mono -> .net. > > Our code is solely based on DLR which should be inline with .net. I think there > is quite high possibility that the missing Serializable will be fixed in the > next .net version. Considering that it is .NET that throws exception i.e. it does not break working code, and it is too tiny compatibility difference, it's not even worthy of MINOR importance. |
Created attachment 406689 [details] Sample code for reproducing this bug. User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4 If I define a type that derives from System.Dynamic.DynamicObject, decorate that with the WCF [DataContract] attribute, and attempt to serialize an instance of this type using the WCF DataContractSerializer, I should get the following exception, but on Mono, the object is serialized without exception. This behavior is inconsistent the the Microsoft .NET 4 runtime. Unhandled Exception: System.Runtime.Serialization.InvalidDataContractException: Type 'WCFDynamicObject.Dyn' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute. Consider marking the base type 'System.Dynamic.DynamicObject' with DataContractAttribute or SerializableAttribute, or removing them from the derived type. Reproducible: Always Steps to Reproduce: 1. Create a valid WCF data contract, derived from System.Dynamic.DynamicObject, as illustrated in the attached code sample. 2. Use the WCF DataContractSerializer to attempt to serialize this object. Actual Results: No exception occurs. Expected Results: Expecting this exception, as thrown under Microsoft .NET 4 runtime: Unhandled Exception: System.Runtime.Serialization.InvalidDataContractException: Type 'WCFDynamicObject.Dyn' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute. Consider marking the base type 'System.Dynamic.DynamicObject' with DataContractAttribute or SerializableAttribute, or removing them from the derived type.