You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The serializer builder currently throws when a field on a record does not have a matching property on the .NET type being mapped. If a default value were used instead, would that obscure errors (like typos on member names)?
How would default values be represented on the Schema class?
The text was updated successfully, but these errors were encountered:
@dstelljes We are running into an issue with schemas created from .NET types where the default values that are declared on the class properties don't get translated to the schema, i.e.
public class Message
{
public int? Property { get; set; } = null;
}
generates the schema {"name":"Message","type":"record","fields":[{"name":"Property","type":["null","int"]}]} without the default field.
Is this related to this serialization issue? I also see that this is tagged as "help wanted" and may be able to help work on it if given some direction.
It’s somewhat related—this issue specifically relates to support for "default" values when building serializers.
Your use case is tricky because there isn’t any reliable way to get the default .NET value when building a schema: In your example, null is assigned to Property when Message is constructed; it’s not a constant value that can be obtained by reflecting on the class.
Open questions:
The serializer builder currently throws when a field on a record does not have a matching property on the .NET type being mapped. If a default value were used instead, would that obscure errors (like typos on member names)?
How would default values be represented on the
Schema
class?The text was updated successfully, but these errors were encountered: