Skip to content

Interaction of --collectionSettersMode with --nullableReferenceAttributes #570

@strigefleur

Description

@strigefleur

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions