Skip to content

Commit

Permalink
Generate async files
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed May 30, 2024
1 parent dcc7c1c commit 2f4730f
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/NHibernate.Test/Async/NHSpecificTest/GH1547/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ public partial class DriverForSubstitutedCommand : IDriver
#endregion
#region Pure forwarding

Task<DbDataReader> IDriver.ExecuteReaderAsync(DbCommand cmd, CancellationToken cancellationToken)
{
return _driverImplementation.ExecuteReaderAsync(cmd, cancellationToken);
}

#endregion

private partial class SubstituteDbCommand : DbCommand
Expand Down
9 changes: 9 additions & 0 deletions src/NHibernate.Test/Async/NHSpecificTest/GH3530/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected override void CreateSchema()
CreateTable("DateTime");
CreateTable("Double");
CreateTable("Decimal");
CreateTable("Float");

base.CreateSchema();
}
Expand Down Expand Up @@ -194,6 +195,14 @@ public async Task TestIntegerAsync(CultureInfo from, CultureInfo to)
await (PerformTestAsync<int, IntegerEntity>(from, to, integerValue, (expected, actual) => Assert.AreEqual(expected, actual)));
}

[Test, TestCaseSource(nameof(GetTestCases))]
public async Task TestFloatAsync(CultureInfo from, CultureInfo to)
{
float floatValue = 12.3f;

await (PerformTestAsync<float, FloatEntity>(from, to, floatValue, (expected, actual) => Assert.AreEqual(expected, actual)));
}

private CultureInfo CurrentCulture
{
get => CultureInfo.CurrentCulture;
Expand Down
16 changes: 16 additions & 0 deletions src/NHibernate.Test/Async/TypesTest/AbstractDateTimeTypeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,20 @@ protected DateTimeKind GetTypeKind()
return (DateTimeKind) _kindProperty.GetValue(Type);
}
}

public partial class ClientDriverWithParamsStats : IDriver
{

Task<DbDataReader> IDriver.ExecuteReaderAsync(DbCommand cmd, CancellationToken cancellationToken)
{
return _driverImplementation.ExecuteReaderAsync(cmd, cancellationToken);
}

#region Firebird mess

#endregion
#region Pure forwarding

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ protected DateTimeKind GetTypeKind()
}
}

public class ClientDriverWithParamsStats : IDriver
public partial class ClientDriverWithParamsStats : IDriver
{
private readonly Dictionary<SqlType, int> _usedSqlTypes = new Dictionary<SqlType, int>();
private readonly Dictionary<DbType, int> _usedDbTypes = new Dictionary<DbType, int>();
Expand Down
7 changes: 5 additions & 2 deletions src/NHibernate/Async/AdoNet/AbstractBatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,16 @@ private async Task<DbDataReader> DoExecuteReaderAsync(DbCommand cmd, Cancellatio
cancellationToken.ThrowIfCancellationRequested();
try
{
var reader = await (cmd.ExecuteReaderAsync(cancellationToken)).ConfigureAwait(false);
var driver = _factory.ConnectionProvider.Driver;
var reader = await (driver.ExecuteReaderAsync(cmd, cancellationToken)).ConfigureAwait(false);

if (reader == null)
{
// MySql may return null instead of an exception, by example when the query is canceled by another thread.
throw new InvalidOperationException("The query execution has yielded a null reader. (Has it been canceled?)");
}
return _factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders

return driver.SupportsMultipleOpenReaders
? reader
: await (NHybridDataReader.CreateAsync(reader, cancellationToken)).ConfigureAwait(false);
}
Expand Down
41 changes: 41 additions & 0 deletions src/NHibernate/Async/Driver/DirectCastDbDataReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


using System;
using System.Collections;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;

namespace NHibernate.Driver
{
using System.Threading.Tasks;
using System.Threading;
public partial class DirectCastDbDataReader : DbDataReader
{

public override Task<bool> NextResultAsync(CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested)
{
return Task.FromCanceled<bool>(cancellationToken);
}
return _reader.NextResultAsync(cancellationToken);
}

public override Task<bool> ReadAsync(CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested)
{
return Task.FromCanceled<bool>(cancellationToken);
}
return _reader.ReadAsync(cancellationToken);
}
}
}
51 changes: 51 additions & 0 deletions src/NHibernate/Async/Driver/DriverBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using NHibernate.Engine;
using NHibernate.SqlCommand;
using NHibernate.SqlTypes;
using NHibernate.Util;
using Environment = NHibernate.Cfg.Environment;

namespace NHibernate.Driver
{
using System.Threading.Tasks;
using System.Threading;
public abstract partial class DriverBase : IDriver, ISqlParameterFormatter
{

#if NETFX
#else

#endif

/// <summary>
/// Provides a mechanism to override the default DbDataReader used
/// by a data provider. Some providers don't provide a DataReader
/// that implement all of the methods.
/// </summary>
/// <param name="cmd">The command to execute.</param>
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
/// <returns>A <see cref="DbDataReader">DbDataReader</see> object.</returns>
public virtual Task<DbDataReader> ExecuteReaderAsync(DbCommand cmd, CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested)
{
return Task.FromCanceled<DbDataReader>(cancellationToken);
}
return cmd.ExecuteReaderAsync(cancellationToken);
}
}
}
36 changes: 36 additions & 0 deletions src/NHibernate/Async/Driver/IDriver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using NHibernate.Engine;
using NHibernate.SqlCommand;
using NHibernate.SqlTypes;

namespace NHibernate.Driver
{
using System.Threading.Tasks;
using System.Threading;
public partial interface IDriver
{

/// <summary>
/// Provides a mechanism to override the default DbDataReader used
/// by a data provider. Some providers don't provide a DataReader
/// that implement all of the methods.
/// </summary>
/// <param name="cmd">The command to execute.</param>
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
/// <returns>A <see cref="DbDataReader">DbDataReader</see> object.</returns>
Task<DbDataReader> ExecuteReaderAsync(DbCommand cmd, CancellationToken cancellationToken);
}
}
6 changes: 6 additions & 0 deletions src/NHibernate/Async/Driver/OracleDataClientDriverBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@ protected override async Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBeha
return reader;
}
}

public override async Task<DbDataReader> ExecuteReaderAsync(DbCommand cmd, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
return new DirectCastDbDataReader(await (cmd.ExecuteReaderAsync(cancellationToken)).ConfigureAwait(false));
}
}
}
34 changes: 34 additions & 0 deletions src/NHibernate/Async/Driver/Sql2008ClientDriver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


using System;
using System.Data;
using System.Data.Common;
using NHibernate.Util;

namespace NHibernate.Driver
{
using System.Threading.Tasks;
using System.Threading;
public partial class Sql2008ClientDriver : SqlClientDriver
{

#if NETFX
#else

#endif

public override async Task<DbDataReader> ExecuteReaderAsync(DbCommand cmd, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
return new DirectCastDbDataReader(await (cmd.ExecuteReaderAsync(cancellationToken)).ConfigureAwait(false));
}
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Driver/DirectCastDbDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace NHibernate.Driver
{
public class DirectCastDbDataReader : DbDataReader
public partial class DirectCastDbDataReader : DbDataReader
{
private readonly DbDataReader _reader;

Expand Down
2 changes: 1 addition & 1 deletion src/NHibernate/Driver/DriverBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace NHibernate.Driver
/// <summary>
/// Base class for the implementation of IDriver
/// </summary>
public abstract class DriverBase : IDriver, ISqlParameterFormatter
public abstract partial class DriverBase : IDriver, ISqlParameterFormatter
{
private static readonly INHibernateLogger log = NHibernateLogger.For(typeof(DriverBase));

Expand Down
2 changes: 1 addition & 1 deletion src/NHibernate/Driver/IDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace NHibernate.Driver
/// value="FullyQualifiedClassName, AssemblyName"
/// </code>
/// </remarks>
public interface IDriver
public partial interface IDriver
{
/// <summary>
/// Configure the driver using <paramref name="settings"/>.
Expand Down
2 changes: 1 addition & 1 deletion src/NHibernate/Driver/Sql2008ClientDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace NHibernate.Driver
{
public class Sql2008ClientDriver : SqlClientDriver
public partial class Sql2008ClientDriver : SqlClientDriver
{
const byte MaxTime = 5;

Expand Down

0 comments on commit 2f4730f

Please sign in to comment.