Skip to content

Commit 5f1fc14

Browse files
authored
Relax generic constraints for TableClient methods (Azure#25841)
1 parent 51f030b commit 5f1fc14

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

sdk/core/Azure.Core/src/Shared/Argument.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ internal static partial class Argument
3535
/// <param name="name">The name of the parameter.</param>
3636
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
3737
#if AZURE_NULLABLE
38-
public static void AssertNotNull<T>([AllowNull, NotNull] T value, string name) where T : class?
38+
public static void AssertNotNull<T>([AllowNull, NotNull] T value, string name)
3939
#else
40-
public static void AssertNotNull<T>(T value, string name) where T : class
40+
public static void AssertNotNull<T>(T value, string name)
4141
#endif
4242
{
4343
if (value is null)

sdk/tables/Azure.Data.Tables/api/Azure.Data.Tables.netstandard2.0.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public TableClient(System.Uri endpoint, string tableName, Azure.Data.Tables.Tabl
1919
public TableClient(System.Uri endpoint, string tableName, Azure.Data.Tables.TableSharedKeyCredential credential, Azure.Data.Tables.TableClientOptions options = null) { }
2020
public virtual string AccountName { get { throw null; } }
2121
public virtual string Name { get { throw null; } }
22-
public virtual System.Threading.Tasks.Task<Azure.Response> AddEntityAsync<T>(T entity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
23-
public virtual Azure.Response AddEntity<T>(T entity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
22+
public virtual System.Threading.Tasks.Task<Azure.Response> AddEntityAsync<T>(T entity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : Azure.Data.Tables.ITableEntity { throw null; }
23+
public virtual Azure.Response AddEntity<T>(T entity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : Azure.Data.Tables.ITableEntity { throw null; }
2424
public virtual Azure.Response<Azure.Data.Tables.Models.TableItem> Create(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
2525
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Data.Tables.Models.TableItem>> CreateAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
2626
public virtual Azure.Response<Azure.Data.Tables.Models.TableItem> CreateIfNotExists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
@@ -47,10 +47,10 @@ public TableClient(System.Uri endpoint, string tableName, Azure.Data.Tables.Tabl
4747
public virtual System.Threading.Tasks.Task<Azure.Response> SetAccessPolicyAsync(System.Collections.Generic.IEnumerable<Azure.Data.Tables.Models.TableSignedIdentifier> tableAcl, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
4848
public virtual Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.Response>> SubmitTransaction(System.Collections.Generic.IEnumerable<Azure.Data.Tables.TableTransactionAction> transactionActions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
4949
public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.Response>>> SubmitTransactionAsync(System.Collections.Generic.IEnumerable<Azure.Data.Tables.TableTransactionAction> transactionActions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
50-
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateEntityAsync<T>(T entity, Azure.ETag ifMatch, Azure.Data.Tables.TableUpdateMode mode = Azure.Data.Tables.TableUpdateMode.Merge, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
51-
public virtual Azure.Response UpdateEntity<T>(T entity, Azure.ETag ifMatch, Azure.Data.Tables.TableUpdateMode mode = Azure.Data.Tables.TableUpdateMode.Merge, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
52-
public virtual System.Threading.Tasks.Task<Azure.Response> UpsertEntityAsync<T>(T entity, Azure.Data.Tables.TableUpdateMode mode = Azure.Data.Tables.TableUpdateMode.Merge, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
53-
public virtual Azure.Response UpsertEntity<T>(T entity, Azure.Data.Tables.TableUpdateMode mode = Azure.Data.Tables.TableUpdateMode.Merge, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
50+
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateEntityAsync<T>(T entity, Azure.ETag ifMatch, Azure.Data.Tables.TableUpdateMode mode = Azure.Data.Tables.TableUpdateMode.Merge, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : Azure.Data.Tables.ITableEntity { throw null; }
51+
public virtual Azure.Response UpdateEntity<T>(T entity, Azure.ETag ifMatch, Azure.Data.Tables.TableUpdateMode mode = Azure.Data.Tables.TableUpdateMode.Merge, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : Azure.Data.Tables.ITableEntity { throw null; }
52+
public virtual System.Threading.Tasks.Task<Azure.Response> UpsertEntityAsync<T>(T entity, Azure.Data.Tables.TableUpdateMode mode = Azure.Data.Tables.TableUpdateMode.Merge, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : Azure.Data.Tables.ITableEntity { throw null; }
53+
public virtual Azure.Response UpsertEntity<T>(T entity, Azure.Data.Tables.TableUpdateMode mode = Azure.Data.Tables.TableUpdateMode.Merge, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : Azure.Data.Tables.ITableEntity { throw null; }
5454
}
5555
public partial class TableClientOptions : Azure.Core.ClientOptions
5656
{

sdk/tables/Azure.Data.Tables/src/Extensions/TableEntityExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal static class TableEntityExtensions
1212
/// The default case is intentionally unhandled as this means that no type annotation for the specified type is required.
1313
/// This is because the type is naturally serialized in a way that the table service can interpret without hints.
1414
/// </summary>
15-
internal static IDictionary<string, object> ToOdataAnnotatedDictionary<T>(this T entity) where T : class, ITableEntity
15+
internal static IDictionary<string, object> ToOdataAnnotatedDictionary<T>(this T entity)
1616
{
1717
if (entity is IDictionary<string, object> dictEntity)
1818
{

sdk/tables/Azure.Data.Tables/src/TableClient.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
550550
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
551551
/// <returns>A <see cref="Response"/> containing headers such as ETag.</returns>
552552
/// <exception cref="RequestFailedException">Exception thrown if entity already exists.</exception>
553-
public virtual async Task<Response> AddEntityAsync<T>(T entity, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
553+
public virtual async Task<Response> AddEntityAsync<T>(T entity, CancellationToken cancellationToken = default) where T : ITableEntity
554554
{
555555
Argument.AssertNotNull(entity, nameof(entity));
556556
Argument.AssertNotNull(entity?.PartitionKey, nameof(entity.PartitionKey));
@@ -584,7 +584,7 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
584584
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
585585
/// <returns>A <see cref="Response"/> containing headers such as ETag</returns>
586586
/// <exception cref="RequestFailedException">Exception thrown if entity already exists.</exception>
587-
public virtual Response AddEntity<T>(T entity, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
587+
public virtual Response AddEntity<T>(T entity, CancellationToken cancellationToken = default) where T : ITableEntity
588588
{
589589
Argument.AssertNotNull(entity, nameof(entity));
590590
Argument.AssertNotNull(entity?.PartitionKey, nameof(entity.PartitionKey));
@@ -708,7 +708,7 @@ await _tableOperations.QueryEntityWithPartitionAndRowKeyAsync(
708708
public virtual async Task<Response> UpsertEntityAsync<T>(
709709
T entity,
710710
TableUpdateMode mode = TableUpdateMode.Merge,
711-
CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
711+
CancellationToken cancellationToken = default) where T : ITableEntity
712712
{
713713
Argument.AssertNotNull(entity, nameof(entity));
714714
Argument.AssertNotNull(entity?.PartitionKey, nameof(entity.PartitionKey));
@@ -756,7 +756,7 @@ public virtual async Task<Response> UpsertEntityAsync<T>(
756756
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
757757
/// <returns>The <see cref="Response"/> indicating the result of the operation.</returns>
758758
public virtual Response UpsertEntity<T>(T entity, TableUpdateMode mode = TableUpdateMode.Merge, CancellationToken cancellationToken = default)
759-
where T : class, ITableEntity, new()
759+
where T : ITableEntity
760760
{
761761
Argument.AssertNotNull(entity, nameof(entity));
762762
Argument.AssertNotNull(entity?.PartitionKey, nameof(entity.PartitionKey));
@@ -816,7 +816,7 @@ public virtual async Task<Response> UpdateEntityAsync<T>(
816816
T entity,
817817
ETag ifMatch,
818818
TableUpdateMode mode = TableUpdateMode.Merge,
819-
CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
819+
CancellationToken cancellationToken = default) where T : ITableEntity
820820
{
821821
Argument.AssertNotNull(entity, nameof(entity));
822822
Argument.AssertNotNull(entity.PartitionKey, nameof(entity.PartitionKey));
@@ -882,7 +882,7 @@ public virtual async Task<Response> UpdateEntityAsync<T>(
882882
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
883883
/// <returns>The <see cref="Response"/> indicating the result of the operation.</returns>
884884
public virtual Response UpdateEntity<T>(T entity, ETag ifMatch, TableUpdateMode mode = TableUpdateMode.Merge, CancellationToken cancellationToken = default)
885-
where T : class, ITableEntity, new()
885+
where T : ITableEntity
886886
{
887887
Argument.AssertNotNull(entity, nameof(entity));
888888
Argument.AssertNotNull(entity.PartitionKey, nameof(entity.PartitionKey));

0 commit comments

Comments
 (0)