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

Fix NRT annotations on XmlProcessingInstruction #71862

Closed
SteveDunn opened this issue Jul 8, 2022 · 3 comments · Fixed by #73687
Closed

Fix NRT annotations on XmlProcessingInstruction #71862

SteveDunn opened this issue Jul 8, 2022 · 3 comments · Fixed by #73687
Assignees
Milestone

Comments

@SteveDunn
Copy link
Contributor

SteveDunn commented Jul 8, 2022

Description

XmlProcessingInstruction is not annotated correctly. The implementation of Name explicitly accomodates a null target, and its Target is annotated as nullable. The Value property, which just returns _data, is annotated as [AllowNull] but just !s away a null value that's stored, so it can actually return null. Please see this PR comment for more context.

Reproduction Steps

No particular reproduction steps

Expected behavior

No specific behavioural changes should occur, this is just a compile time issue.

Actual behavior

No specific behavioural changes should occur, this is just a compile time issue.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 8, 2022
@ghost
Copy link

ghost commented Jul 8, 2022

Tagging subscribers to this area: @dotnet/area-system-xml
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

XmlProcessingInstruction is not annotated correctly? The implementation of Name explicitly accomodates a null target, and its Target is annotated as nullable. The Value property, which just returns _data, is annotated as [AllowNull] but just !s away a null value that's stored, so it can actually return null. Please see this PR comment for more context.

Reproduction Steps

No particular reproduction steps

Expected behavior

No specific behavioural changes should occur, this is just a compile time issue.

Actual behavior

No specific behavioural changes should occur, this is just a compile time issue.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: SteveDunn
Assignees: -
Labels:

area-System.Xml, untriaged

Milestone: -

@jeffhandley jeffhandley added this to the 7.0.0 milestone Jul 11, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jul 11, 2022
@krwq krwq self-assigned this Aug 10, 2022
@krwq
Copy link
Member

krwq commented Aug 10, 2022

I had to refer spec to figure out correct annotations since current implementation doesn't make it in any way easy.

Per https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-pi

  • target cannot be null - current implementation will throw when it encounters null target: I'm changing the behavior to throw and making it explicitly non-nullable
  • data - per spec this is optional although for current implementation there is no distinction between empty and null and current implementation return empty string when data is not provided: I'm changing the behavior that all getters for Data/Value (and whatever else it's called) are non-nullable and all setters are nullable - null will always translate to empty string since per spec it's equivalent and will make it most consistent with current implementation

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 10, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 12, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants