I have a problem serializing pcl class object because the class objects property is cannot be evaluated. The structure of my solution is having three projects -
I have one method in my service class like -
public async Task<HttpResponseMessage> SignIn(string username, string password)
{
var user = new Dto.UserLogin(username, password);
var serialize = Newtonsoft.Json.JsonConvert.SerializeObject(user);
var content = new StringContent(serialize);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = null;
using (var client = GetClient("{urlhere}", username, "POST"))
{
response = await client.PostAsync("api/{methodname}", content);
}
return response;
}
The code above does not throw error and can instantiate the "user" variable. However the problem was that when the serialization line happens, it serialize nothing. It seems like the "user" object is cannot access or show the two properties "Email" and "Password". But I can access them in debug using "user.Email". I've attached a screenshot of it.
Email and Password properties are public.
Thanks, Marvin
The comment from @Jack helps me to figure out the culprit. In Xamarin.Android property settings->Android options->linker, currently it is set to "SDK and User assemblies". I changed it to "SDK Assemblies Only" and this solved the problem.