|
Why doesn't the unit test expect MaybeNull and AllowNull on empty collections? [XmlIgnoreAttribute()]
private String[] _text;
// generated code is missing analysis attributes
// [AllowNullAttribute()]
// [MaybeNullAttribute()]
[XmlElementAttribute("Text")]
public String[] Text
{
get
{
return _text;
}
set
{
_text = value;
}
}PS: The XmlSerializer is inconsitent when initializing |
Answered by
mganss
Dec 9, 2024
Replies: 4 comments 1 reply
|
XmlSchemaClassGenerator/XmlSchemaClassGenerator/TypeModel.cs Lines 603 to 612 in 269889d |
0 replies
|
I think this may stem from a time prior to |
0 replies
|
I'm thinking to change the cited code like this: private bool IsNullable => DefaultValue == null && !IsRequired;
private bool IsValueType => PropertyType is EnumModel || (PropertyType is SimpleModel model && model.ValueType.IsValueType);
private bool IsNullableValueType => IsNullable && !IsEnumerable && IsValueType;
private bool IsNullableReferenceType => IsNullable && (!IsEnumerable || !IsPrivateSetter) && (PropertyType is ClassModel || (PropertyType is SimpleModel model && !model.ValueType.IsValueType)); |
1 reply
Answer selected by
meixger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm thinking to change the cited code like this: