-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Switch Markup property to XmlNode?[]? to reflect it can contain null elements #41488
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
Conversation
jeffhandley
left a 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.
LGTM but please get another review. 😃
| 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.
| } | ||
|
|
||
| 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); |
| } | ||
|
|
||
| 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).
eerhardt
left a 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.
![]()
Switches
Markupproperty fromXmlNode[]?toXmlNode?[]?inXmlSchemaAppInfoandXmlSchemaDocumentation.