Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
give an enum flags
public enum PortalNotifications
None = 0,
TardyAlerts = 0x10,
IncidentAlerts = 0x20,
All = 0xffff,
UseCurrent = 0x10000
public class DeviceNotifications
public PortalNotifications NotificationsType = PortalNotifications.All;
.net 4 when serializing the value PortalNotifications.All will generate a single entry in the xml
Xamarin datacontractserializer will serialize all applicable flag values
<NotificationsType xmlns:d2p1="http://schemas.datacontract.org/2004/07/PSRMWebService.Model.Version1">None TardyAlerts IncidentAlerts All</NotificationsType>
I assume the .net 4 one looks for exact matches first.
below is the code we use to do the serialization. On the server the deserialization is done automatically via MVC webapi
protected void SerializeToString(object Data, Type DataType, out int DataLength, out string DataString)
DataLength = 0;
using (var MS = new MemoryStream())
// default text encoding is UTF-8 apparently
DataContractSerializer ser = new DataContractSerializer(DataType);
byte Buffer = MS.ToArray();
long Length = Buffer.LongLength;
// the length parameter is becuase the buffer is a set size...
DataString = Encoding.UTF8.GetString( Buffer, 0, (int) Length );
// this looks hokey, it is, the datacontractserlializer is supposed to default to utf-8 but
// some builds of monotuch it puts a double byte mark at the start. so we remove it otherwise
// it wont deseaerlize
if ( (int) DataString > 65000 )
DataString = DataString.Substring( 1 );
DataLength = DataString.Length;
hopefully this is readable enough. We are basically using the standard datacontractserializer and writing it to a memorystream.
the .net enum encoder always seems to look for an exact match in flags first, then it looks for partial matches.
Thank you for the detailed bug report.
The pull request for this issue can be found in the link below.