From 3831f094c1cd131cf2f9a2c05d5f6bc76d98ef08 Mon Sep 17 00:00:00 2001 From: Marc Gravell Date: Tue, 14 Nov 2023 07:38:14 +0000 Subject: [PATCH] add public .ctor to identiy (for AOT) --- Dapper/PublicAPI.Shipped.txt | 1 + Dapper/SqlMapper.Identity.cs | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Dapper/PublicAPI.Shipped.txt b/Dapper/PublicAPI.Shipped.txt index 4c5417a6..15f614f0 100644 --- a/Dapper/PublicAPI.Shipped.txt +++ b/Dapper/PublicAPI.Shipped.txt @@ -117,6 +117,7 @@ Dapper.SqlMapper.ICustomQueryParameter.AddParameter(System.Data.IDbCommand! comm Dapper.SqlMapper.Identity Dapper.SqlMapper.Identity.Equals(Dapper.SqlMapper.Identity? other) -> bool Dapper.SqlMapper.Identity.ForDynamicParameters(System.Type! type) -> Dapper.SqlMapper.Identity! +Dapper.SqlMapper.Identity.Identity(string! sql, System.Data.CommandType commandType, System.Data.IDbConnection! connection, System.Type? type, System.Type? parametersType) -> void Dapper.SqlMapper.IDynamicParameters Dapper.SqlMapper.IDynamicParameters.AddParameters(System.Data.IDbCommand! command, Dapper.SqlMapper.Identity! identity) -> void Dapper.SqlMapper.IMemberMap diff --git a/Dapper/SqlMapper.Identity.cs b/Dapper/SqlMapper.Identity.cs index 4871d9c0..f32f17ee 100644 --- a/Dapper/SqlMapper.Identity.cs +++ b/Dapper/SqlMapper.Identity.cs @@ -12,10 +12,10 @@ internal sealed class Identity #pragma warning disable CS0618 // Type or member is obsolete internal Identity ForGrid(Type primaryType, int gridIndex) => - new Identity(sql, commandType, connectionString, primaryType, parametersType, gridIndex); + new Identity(sql, commandType.GetValueOrDefault(), connectionString, primaryType, parametersType, gridIndex); internal Identity ForGrid(Type primaryType, int gridIndex) => - new Identity(sql, commandType, connectionString, primaryType, parametersType, 0, gridIndex); + new Identity(sql, commandType.GetValueOrDefault(), connectionString, primaryType, parametersType, 0, gridIndex); internal Identity ForGrid(Type primaryType, Type[] otherTypes, int gridIndex) => (otherTypes is null || otherTypes.Length == 0) - ? new Identity(sql, commandType, connectionString, primaryType, parametersType, 0, gridIndex) + ? new Identity(sql, commandType.GetValueOrDefault(), connectionString, primaryType, parametersType, 0, gridIndex) : new IdentityWithTypes(sql, commandType, connectionString, primaryType, parametersType, otherTypes, gridIndex); /// @@ -111,13 +111,17 @@ internal Identity ForGrid(Type primaryType, Type[] otherTypes, int gridIndex) => /// The parameters type to create an for. /// public Identity ForDynamicParameters(Type type) => - new Identity(sql, commandType, connectionString, this.type, type, 0, -1); + new Identity(sql, commandType.GetValueOrDefault(), connectionString, this.type, type, 0, -1); #pragma warning restore CS0618 // Type or member is obsolete - internal Identity(string sql, CommandType? commandType, IDbConnection connection, Type? type, Type? parametersType) + /// + /// Create a new instance. + /// + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] // discourage usage + public Identity(string sql, CommandType commandType, IDbConnection connection, Type? type, Type? parametersType) : this(sql, commandType, connection.ConnectionString, type, parametersType, 0, 0) { /* base call */ } - private protected Identity(string sql, CommandType? commandType, string connectionString, Type? type, Type? parametersType, int otherTypesHash, int gridIndex) + private protected Identity(string sql, CommandType commandType, string connectionString, Type? type, Type? parametersType, int otherTypesHash, int gridIndex) { #pragma warning disable CS0618 // Type or member is obsolete this.sql = sql; @@ -165,7 +169,7 @@ private protected Identity(string sql, CommandType? commandType, string connecti /// [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("Please use " + nameof(CommandType) + ". This API may be removed at a later date.")] - public readonly CommandType? commandType; + public readonly CommandType? commandType; // in addition to field hell, this should now be non-nullable /// /// The SQL command type.