-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch Markup property to XmlNode?[]? to reflect it can contain null elements #41488
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but please get another review. 😃
if (a != null) | ||
{ | ||
for (int ia = 0; ia < a.Length; ia++) | ||
{ | ||
XmlNode ai = (XmlNode)a[ia]; | ||
XmlNode ai = (XmlNode)a[ia]!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we know this can't be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not 100% sure but if ai
happens to be null
that would cause a NRE in line 552. So product code already assumes that ai
can't be null
.
@@ -778,7 +778,7 @@ internal override bool IsContentParsed() | |||
return _currentEntry.ParseContent; | |||
} | |||
|
|||
internal override void ProcessMarkup(XmlNode[] markup) | |||
internal override void ProcessMarkup(XmlNode?[] markup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't markup be null here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
markup
is always initialized in the only call site.
runtime/src/libraries/System.Private.Xml/src/System/Xml/Schema/Parser.cs
Lines 246 to 252 in 454d66d
XmlNode?[] markup = new XmlNode[list.Count]; | |
for (int i = 0; i < list.Count; i++) | |
{ | |
markup[i] = list[i]; | |
} | |
_builder!.ProcessMarkup(markup); |
@@ -561,7 +561,7 @@ internal override bool IsContentParsed() | |||
return true; | |||
} | |||
|
|||
internal override void ProcessMarkup(XmlNode[] markup) | |||
internal override void ProcessMarkup(XmlNode?[] markup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't markup be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same answer as previous comment #41488 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…elements (dotnet#41488) * Switch Markup property to XmlNode?[]? to reflect it can contain null elements * Update ref
Switches
Markup
property fromXmlNode[]?
toXmlNode?[]?
inXmlSchemaAppInfo
andXmlSchemaDocumentation
.