Correct nullability annotation for IDataRecord (#44938)
authorShay Rojansky <roji@roji.org>
Sat, 21 Nov 2020 07:11:41 +0000 (09:11 +0200)
committerGitHub <noreply@github.com>
Sat, 21 Nov 2020 07:11:41 +0000 (09:11 +0200)
Fixes #44886

src/libraries/System.Data.Common/ref/System.Data.Common.cs
src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs
src/libraries/System.Data.Common/src/System/Data/Common/DbDataRecord.cs
src/libraries/System.Data.Common/src/System/Data/IDataRecord.cs

index 8541ef6..423e82d 100644 (file)
@@ -1259,9 +1259,9 @@ namespace System.Data
         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);
@@ -2202,9 +2202,9 @@ namespace System.Data.Common
         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);
index 7c09892..0bad614 100644 (file)
@@ -100,7 +100,7 @@ namespace System.Data.Common
             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 @@ namespace System.Data.Common
 
         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];
index 189e176..605045f 100644 (file)
@@ -19,11 +19,11 @@ namespace System.Data.Common
 
         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);
 
index 2563e75..8dad2b2 100644 (file)
@@ -16,9 +16,9 @@ namespace System.Data
         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);