Skip to content

Cleanup XmlReader - #51561

Merged
6 commits merged into
dotnet:mainfrom
kronic:main
Apr 22, 2021
Merged

Cleanup XmlReader#51561
6 commits merged into
dotnet:mainfrom
kronic:main

Conversation

@kronic

@kronic kronic commented Apr 20, 2021

Copy link
Copy Markdown
Contributor

Cleanup XmlReader{Async}

@ghost ghost added the area-System.Xml label Apr 20, 2021
@ghost

ghost commented Apr 20, 2021

Copy link
Copy Markdown

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

Issue Details

Cleanup XmlReader{Async}

Author: kronic
Assignees: -
Labels:

area-System.Xml

Milestone: -

}
}
}
public virtual string Name => Prefix.Length == 0 ? LocalName : NameTable.Add(string.Concat(Prefix, ":", LocalName));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
public virtual string Name => Prefix.Length == 0 ? LocalName : NameTable.Add(string.Concat(Prefix, ":", LocalName));
public virtual string Name => Prefix.Length == 0 ? LocalName : NameTable.Add($"{Prefix}:{LocalName}");


ReturnContent:
return (sb == null) ? value : sb.ToString();
ReturnContent:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think previous indentation was correct (not 100% sure)

break;
case XmlNodeType.EntityReference:
xtw.WriteEntityRef(this.Name);
xtw.WriteEntityRef(Value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is not cleanup

{
throw new XmlException(SR.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo);
}
return XmlUntypedConverter.Untyped.ChangeType(strContentValue, returnType, namespaceResolver ?? this as IXmlNamespaceResolver);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please move any implementation changes to a separate PR

}

return (returnType == typeof(string)) ? string.Empty : XmlUntypedStringConverter.Instance.FromString(string.Empty, returnType, namespaceResolver);
return returnType == typeof(string) ? string.Empty : XmlUntypedConverter.Untyped.ChangeType(string.Empty, returnType, namespaceResolver);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same

// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;
using System.ComponentModel;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is new namespace needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] -> [EditorBrowsable(EditorBrowsableState.Never)]

@krwq krwq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please move any implementation changes to a separate PR


ReturnContent:
return (sb == null) ? value : sb.ToString();
ReturnContent:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change goes against the coding style: https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/coding-style.md

When using labels (for goto), indent the label one less than the current indentation.

@stephentoub stephentoub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Style changes generally look fine. I agree with @krwq the functional changes need to be separated out.

@danmoseley

Copy link
Copy Markdown
Contributor

That's a lot of semicolons, does that get us closer to enabling SA1106 globally?

@stephentoub

Copy link
Copy Markdown
Member

That's a lot of semicolons, does that get us closer to enabling SA1106 globally?

Semicolons?

Regardless, we won't be enabling SA1106:
#50236 (comment)

@danmoseley

Copy link
Copy Markdown
Contributor

Semicolons?

I was referring to the many empty statements that @kronic removed.

@kronic

kronic commented Apr 21, 2021

Copy link
Copy Markdown
Contributor Author

@krwq done

}

return (returnType == typeof(string)) ? string.Empty : XmlUntypedStringConverter.Instance.FromString(string.Empty, returnType, namespaceResolver);
return returnType == typeof(string) ? string.Empty : XmlUntypedStringConverter.Instance.FromString(string.Empty, returnType, namespaceResolver!);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is ! needed now?

@kronic kronic Apr 21, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Resharper gives warning Possible 'null' assignment to entity.
Next pr I plan to replace to XmlUntypedConverter.Untyped.ChangeType(string.Empty, returnType, namespaceResolver) as done in XmlRederAsync.ReadElementContentAsAsync

@kronic kronic Apr 21, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@krwq If necessary, can I remove it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kronic, I assume if it wasn't needed before it shouldn't be now, especially namespaceResolver is non-nullable in that context. For next PR, let's talk about it in next PR, this is likely ok but prefer to think about it separately (also easier to track down if we regress something)

@krwq krwq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM minus ! comment

@kronic

kronic commented Apr 21, 2021

Copy link
Copy Markdown
Contributor Author

@krwq done

@krwq

krwq commented Apr 21, 2021

Copy link
Copy Markdown
Member

Thanks @kronic!

@ghost

ghost commented Apr 21, 2021

Copy link
Copy Markdown

Hello @krwq!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@kronic

kronic commented Apr 22, 2021

Copy link
Copy Markdown
Contributor Author

@krwq what are the problems of auto-merge

@krwq

krwq commented Apr 22, 2021

Copy link
Copy Markdown
Member

Seems CI leg is failing, it will not auto-merge until that pass. I'll see if the issue is related

EDIT: seems it's not. I'll restart failing legs, if this keeps on failing and it's known issue I'll merge manually

@ghost
ghost merged commit 1132baa into dotnet:main Apr 22, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
This pull request was closed.
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.

6 participants