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

IDataRecord.GetBytes/GetChars should be annotated to allow a null buffer #44886

Closed
chrarnoldus opened this issue Nov 18, 2020 · 4 comments · Fixed by #44938
Closed

IDataRecord.GetBytes/GetChars should be annotated to allow a null buffer #44886

chrarnoldus opened this issue Nov 18, 2020 · 4 comments · Fixed by #44938
Assignees
Labels
area-System.Data breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. bug
Milestone

Comments

@chrarnoldus
Copy link

chrarnoldus commented Nov 18, 2020

The buffer parameter of GetBytes/GetChars should be annotated to allow null values. Currently in .NET 5.0.0 they are annotated to not allow null values (see #38810).

The documentation states:

If you pass a buffer that is null, GetChars returns the length of the field in characters.

Source: https://docs.microsoft.com/en-us/dotnet/api/system.data.idatarecord.getchars?view=net-5.0#remarks

In SqlClient the implementation does indeed conform to the documentation: https://github.com/dotnet/SqlClient/blob/f0572f3e9990b391d6102911fe12223e748e117b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs#L1663

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Nov 18, 2020
@Dotnet-GitSync-Bot
Copy link
Collaborator

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.

@stephentoub
Copy link
Member

cc: @roji

roji added a commit to roji/runtime that referenced this issue Nov 19, 2020
@roji roji added area-System.Data and removed untriaged New issue has not been triaged by the area owner labels Nov 19, 2020
@ghost
Copy link

ghost commented Nov 19, 2020

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

Issue Details

The buffer parameter of GetBytes/GetChars should be annotated to allow null values. Currently in .NET 5.0.0 they are annotated to not allow null values (see #38810).

The documentation states:

If you pass a buffer that is null, GetChars returns the length of the field in characters.

Source: https://docs.microsoft.com/en-us/dotnet/api/system.data.idatarecord.getchars?view=net-5.0#remarks

In SqlClient the implementation does indeed conform to the documentation: https://github.com/dotnet/SqlClient/blob/f0572f3e9990b391d6102911fe12223e748e117b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs#L1663

Author: chrarnoldus
Assignees: -
Labels:

area-System.Data

Milestone: -

@roji roji added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label Nov 19, 2020
@roji
Copy link
Member

roji commented Nov 19, 2020

Yeah, this is an incorrect annotation. I've submitted #44938 to fix this; technically this is a breaking change in case someone has implemented IDataRecord directly (as opposed to via DbDataReader, which is correctly annotated).

Listed this in dotnet/docs#21202 for documentation.

@roji roji self-assigned this Nov 19, 2020
@roji roji added this to the 6.0.0 milestone Nov 19, 2020
@roji roji added the bug label Nov 19, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Data breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants