Skip to content
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

Merged
merged 2 commits into from
Aug 28, 2020

Conversation

jozkee
Copy link
Member

@jozkee jozkee commented Aug 28, 2020

Switches Markup property from XmlNode[]? to XmlNode?[]? in XmlSchemaAppInfo and XmlSchemaDocumentation.

@jozkee jozkee added this to the 5.0.0 milestone Aug 28, 2020
@jozkee jozkee self-assigned this Aug 28, 2020
@ghost
Copy link

ghost commented Aug 28, 2020

Tagging subscribers to this area: @buyaa-n, @krwq
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@jeffhandley jeffhandley left a 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]!;
Copy link
Member

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?

Copy link
Member Author

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)
Copy link
Member

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?

Copy link
Member Author

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.

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)
Copy link
Member

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?

Copy link
Member Author

@jozkee jozkee Aug 28, 2020

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).

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jozkee jozkee merged commit 7408f1b into dotnet:master Aug 28, 2020
@jozkee jozkee deleted the nullability_markup branch August 28, 2020 06:58
carlossanlop pushed a commit to carlossanlop/runtime that referenced this pull request Aug 28, 2020
…elements (dotnet#41488)

* Switch Markup property to XmlNode?[]? to reflect it can contain null elements

* Update ref
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants