Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraith2 committed Nov 4, 2022
1 parent 611d556 commit d55bcd3
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
<Compile Include="Microsoft.Data.SqlClient.cs" />
<Compile Include="Microsoft.Data.SqlClient.Manual.cs" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard2.1')) or ($(TargetFramework.StartsWith('netcoreapp')) and !$(TargetFramework.StartsWith('netcoreapp2')))">
<Compile Include="..\..\ref\System.Data.Common.Batch.IAsyncDisposable.cs" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('netcoreapp2')) or $(TargetFramework.StartsWith('netcoreapp3')) or $(TargetFramework.StartsWith('netstandard2'))">
<Compile Include="..\..\ref\Microsoft.Data.SqlClient.Batch.cs" />
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">
<Compile Include="..\..\ref\System.Data.Common.Batch.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<ItemGroup>
<Compile Include="..\..\ref\Microsoft.Data.SqlClient.Batch.cs" />
<Compile Include="..\..\ref\Microsoft.Data.SqlClient.Batch.NetCoreApp.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard' AND $(TargetNetStandardVersion)=='netstandard2.1'">
<Compile Include="..\..\ref\System.Data.Common.Batch.IAsyncDisposable.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">
<Compile Include="Microsoft.Data.SqlClient.NetStandard.cs" />
</ItemGroup>
Expand Down
19 changes: 8 additions & 11 deletions src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.Batch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SqlBatchCommand>.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<SqlBatchCommand>.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

This comment has been minimized.

Copy link
@ErikEJ

ErikEJ Nov 4, 2022

Contributor

Maybe add #else for readability?

new
#endif
Microsoft.Data.SqlClient.SqlBatchCommand BatchCommand { get { throw null; } }

}
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
}
14 changes: 6 additions & 8 deletions src/Microsoft.Data.SqlClient/ref/System.Data.Common.Batch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,19 +10,19 @@ 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<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Threading.CancellationToken cancellationToken = default) { throw null!; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken = default) { throw null!; }
protected abstract System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteDbDataReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken);
public abstract int ExecuteNonQuery();
public abstract System.Threading.Tasks.Task<int> ExecuteNonQueryAsync(System.Threading.CancellationToken cancellationToken = default);
public abstract object? ExecuteScalar();
public abstract System.Threading.Tasks.Task<object?> ExecuteScalarAsync(System.Threading.CancellationToken cancellationToken = default);
public abstract object ExecuteScalar();
public abstract System.Threading.Tasks.Task<object> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -52,9 +51,9 @@ protected abstract Task<DbDataReader> ExecuteDbDataReaderAsync(

public abstract Task<int> ExecuteNonQueryAsync(CancellationToken cancellationToken = default);

public abstract object? ExecuteScalar();
public abstract object ExecuteScalar();

public abstract Task<object?> ExecuteScalarAsync(CancellationToken cancellationToken = default);
public abstract Task<object> ExecuteScalarAsync(CancellationToken cancellationToken = default);

public abstract void Prepare();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down Expand Up @@ -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))]
Expand Down Expand Up @@ -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))]
Expand Down

0 comments on commit d55bcd3

Please sign in to comment.