XmlSchemaClassGenerator
XmlSchemaClassGenerator copied to clipboard
Interaction of --collectionSettersMode with --nullableReferenceAttributes
Using NR arg (--nullableReferenceAttributes) we can get collection decorated with attributes like that
[XmlArray("ErrorList")]
[XmlArrayItem("Error", Namespace = "http://ns-here")]
public Collection<ErrorDataType> ErrorList
{
[return: MaybeNull] get => this._errorList;
[param: AllowNull] init => this._errorList = value;
}
though collection setters with backing field (--collectionSettersMode=Init) let init the collection
public ErrorListType()
{
this._errorList = new Collection<ErrorDataType>();
}
Now there's a conflict, since removing the backing field entirely removes all of collection initializers - both nullable and not nullable, but letting it stay leads to erroneously initialized empty collections that supposed to be null.
Expected to have empty collection when empty tag presents (<ErrorList/>) but null collection when no tag presents.
Am I missing some obvious arg combination?