From 34add8ff085a0bfb9c3ab5b141b9d53dee3519c4 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Thu, 19 Nov 2020 11:25:53 +0200 Subject: [PATCH 1/2] Correct nullability annotation for IDataRecord Fixes #44886 --- src/libraries/System.Data.Common/ref/System.Data.Common.cs | 4 ++-- .../System.Data.Common/src/System/Data/IDataRecord.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Data.Common/ref/System.Data.Common.cs b/src/libraries/System.Data.Common/ref/System.Data.Common.cs index 8541ef63bbc0e..ece4f558c7ba8 100644 --- a/src/libraries/System.Data.Common/ref/System.Data.Common.cs +++ b/src/libraries/System.Data.Common/ref/System.Data.Common.cs @@ -1259,9 +1259,9 @@ public partial interface IDataRecord object this[string name] { get; } bool GetBoolean(int i); byte GetByte(int i); - long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length); + long GetBytes(int i, long fieldOffset, byte[]? buffer, int bufferoffset, int length); char GetChar(int i); - long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length); + long GetChars(int i, long fieldoffset, char[]? buffer, int bufferoffset, int length); System.Data.IDataReader GetData(int i); string GetDataTypeName(int i); System.DateTime GetDateTime(int i); diff --git a/src/libraries/System.Data.Common/src/System/Data/IDataRecord.cs b/src/libraries/System.Data.Common/src/System/Data/IDataRecord.cs index 2563e75aff3b6..8dad2b2c18b1b 100644 --- a/src/libraries/System.Data.Common/src/System/Data/IDataRecord.cs +++ b/src/libraries/System.Data.Common/src/System/Data/IDataRecord.cs @@ -16,9 +16,9 @@ public interface IDataRecord int GetOrdinal(string name); bool GetBoolean(int i); byte GetByte(int i); - long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length); + long GetBytes(int i, long fieldOffset, byte[]? buffer, int bufferoffset, int length); char GetChar(int i); - long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length); + long GetChars(int i, long fieldoffset, char[]? buffer, int bufferoffset, int length); Guid GetGuid(int i); short GetInt16(int i); int GetInt32(int i); From a0113133c4d6474c1df3c3d8241006384cc175f1 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Fri, 20 Nov 2020 15:43:24 +0200 Subject: [PATCH 2/2] Fix nullability in concrete DbDataRecord too --- src/libraries/System.Data.Common/ref/System.Data.Common.cs | 4 ++-- .../src/System/Data/Common/DataRecordInternal.cs | 4 ++-- .../System.Data.Common/src/System/Data/Common/DbDataRecord.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Data.Common/ref/System.Data.Common.cs b/src/libraries/System.Data.Common/ref/System.Data.Common.cs index ece4f558c7ba8..423e82d28d8dd 100644 --- a/src/libraries/System.Data.Common/ref/System.Data.Common.cs +++ b/src/libraries/System.Data.Common/ref/System.Data.Common.cs @@ -2202,9 +2202,9 @@ protected DbDataRecord() { } public abstract object this[string name] { get; } public abstract bool GetBoolean(int i); public abstract byte GetByte(int i); - public abstract long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length); + public abstract long GetBytes(int i, long dataIndex, byte[]? buffer, int bufferIndex, int length); public abstract char GetChar(int i); - public abstract long GetChars(int i, long dataIndex, char[] buffer, int bufferIndex, int length); + public abstract long GetChars(int i, long dataIndex, char[]? buffer, int bufferIndex, int length); public System.Data.IDataReader GetData(int i) { throw null; } public abstract string GetDataTypeName(int i); public abstract System.DateTime GetDateTime(int i); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs index 7c0989201be80..0bad614a43049 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs @@ -100,7 +100,7 @@ public override byte GetByte(int i) return ((byte)_values[i]); } - public override long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length) + public override long GetBytes(int i, long dataIndex, byte[]? buffer, int bufferIndex, int length) { int cbytes = 0; int ndataIndex; @@ -170,7 +170,7 @@ public override long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIn public override char GetChar(int i) => ((string)_values[i])[0]; - public override long GetChars(int i, long dataIndex, char[] buffer, int bufferIndex, int length) + public override long GetChars(int i, long dataIndex, char[]? buffer, int bufferIndex, int length) { // if the object doesn't contain a char[] then the user will get an exception string s = (string)_values[i]; diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataRecord.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataRecord.cs index 189e17610ac7e..605045fe5b632 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataRecord.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataRecord.cs @@ -19,11 +19,11 @@ protected DbDataRecord() : base() { } public abstract byte GetByte(int i); - public abstract long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length); + public abstract long GetBytes(int i, long dataIndex, byte[]? buffer, int bufferIndex, int length); public abstract char GetChar(int i); - public abstract long GetChars(int i, long dataIndex, char[] buffer, int bufferIndex, int length); + public abstract long GetChars(int i, long dataIndex, char[]? buffer, int bufferIndex, int length); public IDataReader GetData(int i) => GetDbDataReader(i);