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

Nullable annotation mismatch in System.Text.Json.JsonException #41956

Closed
huoyaoyuan opened this issue Sep 8, 2020 · 3 comments
Closed

Nullable annotation mismatch in System.Text.Json.JsonException #41956

huoyaoyuan opened this issue Sep 8, 2020 · 3 comments

Comments

@huoyaoyuan
Copy link
Member

ref

public JsonException(string? message, string path, long? lineNumber, long? bytePositionInLine) { }
public JsonException(string? message, string path, long? lineNumber, long? bytePositionInLine, System.Exception? innerException) { }

impl

public JsonException(string? message, string path, long? lineNumber, long? bytePositionInLine, Exception? innerException) : base(message, innerException)
{
_message = message;
LineNumber = lineNumber;
BytePositionInLine = bytePositionInLine;
Path = path;
}
/// <summary>
/// Creates a new exception object to relay error information to the user.
/// </summary>
/// <param name="message">The context specific error message.</param>
/// <param name="path">The path where the invalid JSON was encountered.</param>
/// <param name="lineNumber">The line number at which the invalid JSON was encountered (starting at 0) when deserializing.</param>
/// <param name="bytePositionInLine">The byte count within the current line where the invalid JSON was encountered (starting at 0).</param>
/// <remarks>
/// Note that the <paramref name="bytePositionInLine"/> counts the number of bytes (i.e. UTF-8 code units) and not characters or scalars.
/// </remarks>
public JsonException(string? message, string? path, long? lineNumber, long? bytePositionInLine) : base(message)

proposed

Annotate all path to nullable, since the Path property is decided to be nullable.

backport priority

Low. The update will be relaxing, and it should be uncommon for user to call constructor of library specified exception.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Text.Json untriaged New issue has not been triaged by the area owner labels Sep 8, 2020
@jozkee
Copy link
Member

jozkee commented Sep 8, 2020

This will be fixed in #41731; I will mark this issue as 5.0 since that PR is being ported to 5.0 in #41845, although, If aforementioned PR is rejected, I don't think this issue on its own would meet the bar.

@jozkee jozkee added this to the 5.0.0 milestone Sep 8, 2020
@jozkee jozkee removed the untriaged New issue has not been triaged by the area owner label Sep 8, 2020
@huoyaoyuan
Copy link
Member Author

The PR title is misleading so I missed it. Thanks.

@layomia
Copy link
Contributor

layomia commented Sep 10, 2020

Closing as the fix was merged in #41845. cc @jozkee

@layomia layomia closed this as completed Sep 10, 2020
@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

No branches or pull requests

4 participants