Make class serializable in PCL

I am working on a cross-platform application (using Xamarin) that interacts with a server application. These two applications must exchange data using the TCP protocol, and for this I need to make some classes Serializable.

So what I want to do is install these classes in a portable class library so that it can be referenced using both my cross-platform application and the server.

The problem I am facing is that labeling the Serializable class is not possible in PCL. I tried downloading the Microsoft.NET Portable Library Assemblies Link Collections and adding a link to the DLL, but it says that they are already referenced by default.

[Serializable] //I need to use this flag
public struct Product
{
    [XmlAttribute(AttributeName = "Name")]
    public string Name { get; set; }

    [XmlAttribute(AttributeName = "Id")]
    public int Id { get; set; }

    [XmlAttribute(AttributeName = "Price")]
    public double Price { get; set; }

    [XmlAttribute(AttributeName = "Brand")]
    public string Brand { get; set; }
}

, Serializable PCL?

+4

Source: https://habr.com/ru/post/1675994/


All Articles