diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj index 7e63af772b..6daba77ab9 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj @@ -16,16 +16,16 @@ - - - - - + - + + + + + diff --git a/src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.Batch.cs b/src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.Batch.cs index cadb63cb81..774fcdad99 100644 --- a/src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.Batch.cs +++ b/src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.Batch.cs @@ -60,23 +60,20 @@ public class SqlBatchCommandCollection : System.Data.Common.DbBatchCommandCollec public bool Remove(Microsoft.Data.SqlClient.SqlBatchCommand item) => throw null; public override bool Remove(System.Data.Common.DbBatchCommand item) => throw null; public override void RemoveAt(int index) => throw null; - Microsoft.Data.SqlClient.SqlBatchCommand System.Collections.Generic.IList.this[int index] - { - get => throw null; - set => throw null; - } - public new Microsoft.Data.SqlClient.SqlBatchCommand this[int index] - { - get => throw null; - set => throw null; - } + Microsoft.Data.SqlClient.SqlBatchCommand System.Collections.Generic.IList.this[int index] { get => throw null; set { } } + public new Microsoft.Data.SqlClient.SqlBatchCommand this[int index] { get => throw null; set { } } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => throw null; protected override System.Data.Common.DbBatchCommand GetBatchCommand(int index) => throw null; protected override void SetBatchCommand(int index, System.Data.Common.DbBatchCommand batchCommand) => throw null; } public sealed partial class SqlException { - public Microsoft.Data.SqlClient.SqlBatchCommand BatchCommand { get { throw null; } } + public +#if NET6_0_OR_GREATER + new +#endif + Microsoft.Data.SqlClient.SqlBatchCommand BatchCommand { get { throw null; } } + } #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } diff --git a/src/Microsoft.Data.SqlClient/ref/System.Data.Common.Batch.cs b/src/Microsoft.Data.SqlClient/ref/System.Data.Common.Batch.cs index 5ae7207037..678b0527a2 100644 --- a/src/Microsoft.Data.SqlClient/ref/System.Data.Common.Batch.cs +++ b/src/Microsoft.Data.SqlClient/ref/System.Data.Common.Batch.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable - namespace System.Data.Common { #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member @@ -12,10 +10,10 @@ public abstract partial class DbBatch : System.IDisposable public System.Data.Common.DbBatchCommandCollection BatchCommands { get { throw null!; } } protected abstract System.Data.Common.DbBatchCommandCollection DbBatchCommands { get; } public abstract int Timeout { get; set; } - public System.Data.Common.DbConnection? Connection { get; set; } - protected abstract System.Data.Common.DbConnection? DbConnection { get; set; } - public System.Data.Common.DbTransaction? Transaction { get; set; } - protected abstract System.Data.Common.DbTransaction? DbTransaction { get; set; } + public System.Data.Common.DbConnection Connection { get; set; } + protected abstract System.Data.Common.DbConnection DbConnection { get; set; } + public System.Data.Common.DbTransaction Transaction { get; set; } + protected abstract System.Data.Common.DbTransaction DbTransaction { get; set; } public System.Data.Common.DbDataReader ExecuteReader(System.Data.CommandBehavior behavior = System.Data.CommandBehavior.Default) { throw null!; } protected abstract System.Data.Common.DbDataReader ExecuteDbDataReader(System.Data.CommandBehavior behavior); public System.Threading.Tasks.Task ExecuteReaderAsync(System.Threading.CancellationToken cancellationToken = default) { throw null!; } @@ -23,8 +21,8 @@ public abstract partial class DbBatch : System.IDisposable protected abstract System.Threading.Tasks.Task ExecuteDbDataReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken); public abstract int ExecuteNonQuery(); public abstract System.Threading.Tasks.Task ExecuteNonQueryAsync(System.Threading.CancellationToken cancellationToken = default); - public abstract object? ExecuteScalar(); - public abstract System.Threading.Tasks.Task ExecuteScalarAsync(System.Threading.CancellationToken cancellationToken = default); + public abstract object ExecuteScalar(); + public abstract System.Threading.Tasks.Task ExecuteScalarAsync(System.Threading.CancellationToken cancellationToken = default); public abstract void Prepare(); public abstract System.Threading.Tasks.Task PrepareAsync(System.Threading.CancellationToken cancellationToken = default); public abstract void Cancel(); diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbBatch.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbBatch.cs index f552a162bd..478d5f64b9 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbBatch.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbBatch.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable using System.Threading; using System.Threading.Tasks; @@ -17,21 +16,21 @@ public abstract class DbBatch : IDisposable, IAsyncDisposable public abstract int Timeout { get; set; } - public DbConnection? Connection + public DbConnection Connection { get => DbConnection; set => DbConnection = value; } - protected abstract DbConnection? DbConnection { get; set; } + protected abstract DbConnection DbConnection { get; set; } - public DbTransaction? Transaction + public DbTransaction Transaction { get => DbTransaction; set => DbTransaction = value; } - protected abstract DbTransaction? DbTransaction { get; set; } + protected abstract DbTransaction DbTransaction { get; set; } public DbDataReader ExecuteReader(CommandBehavior behavior = CommandBehavior.Default) => ExecuteDbDataReader(behavior); @@ -52,9 +51,9 @@ protected abstract Task ExecuteDbDataReaderAsync( public abstract Task ExecuteNonQueryAsync(CancellationToken cancellationToken = default); - public abstract object? ExecuteScalar(); + public abstract object ExecuteScalar(); - public abstract Task ExecuteScalarAsync(CancellationToken cancellationToken = default); + public abstract Task ExecuteScalarAsync(CancellationToken cancellationToken = default); public abstract void Prepare(); diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlException.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlException.cs index 81bcefa65c..a55e9531b4 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlException.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlException.cs @@ -111,12 +111,12 @@ public override void GetObjectData(SerializationInfo si, StreamingContext contex #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #if NET6_0_OR_GREATER - protected override DbBatchCommand DbBatchCommand => SqlBatchCommand; -#else - public DbBatchCommand BatchCommand => SqlBatchCommand; -#endif + protected override DbBatchCommand DbBatchCommand => BatchCommand; - public SqlBatchCommand SqlBatchCommand + public new SqlBatchCommand BatchCommand +#else + public SqlBatchCommand BatchCommand +#endif { get => _batchCommand; internal set => _batchCommand = value; @@ -200,7 +200,7 @@ internal static SqlException CreateException(SqlErrorCollection errorCollection, } SqlException exception = new(message.ToString(), errorCollection, innerException, conId); - exception.SqlBatchCommand = batchCommand; + exception.BatchCommand = batchCommand; exception.Data.Add("HelpLink.ProdName", "Microsoft SQL Server"); if (!string.IsNullOrEmpty(serverVersion)) { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs index 55e5e076c2..794e1827ed 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs @@ -227,7 +227,7 @@ public static void DirectApi() } Assert.NotNull(exception); - Assert.NotNull(exception.SqlBatchCommand); + Assert.NotNull(exception.BatchCommand); } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] @@ -264,7 +264,7 @@ public static void ExceptionInBatchContainsBatch() } Assert.NotNull(exception); - Assert.NotNull(exception.SqlBatchCommand); + Assert.NotNull(exception.BatchCommand); } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] @@ -293,7 +293,7 @@ public static void ExceptionWithoutBatchContainsNoBatch() } Assert.NotNull(exception); - Assert.Null(exception.SqlBatchCommand); + Assert.Null(exception.BatchCommand); } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]