FIX: AsDateBox could not be serialized to frontend XML if it had no f…

I do not agree with this solution. There is an enum with a fixed number of items. How can it happen the value is not set? This way if we enhance the enum and forget to implement it in this part of code, nothing will happen and it will fall back to “Long” format. This will be quite confusing and might cause hard times for someone to debug this.

CC @jsusen @washi

I was confused by this code in FormXmlBuilder which expects that the fromat might not be set:

case "Format":
								if(property.Value != null)
								{
									XmlDocument formatDoc = new XmlDocument();
									formatDoc.LoadXml(property.Value);
									format = formatDoc.SelectSingleNode("DateTimePickerFormat").InnerText;
								}
								break;

And also the section editor will just display format “long” if it is missing in the xml.
So I guess we will have to throw an exception here as well telling the user that te model is damaged.

Why is it not enough to throw an exception when building the XML for the date box? In any case we know what is wrong so we can fix it. But this can only happen in theory or when manually constructing model files. In practice every date box gets this value when added in screen designer.

Or if it is a fallback for a null value, it should fall back in your example code (next time please put a permalink to GitHub so it is easy to see the rest of the code).

So if empty => long. Otherwise - try to decode and fail if unknown value.

A DateBox without a format is in the Demo project. Not sure how it got there but it looks like it was ok in the past not to persist the explicit format value.