Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use [CallerArgumentExpression] for parameterName argument in Check methods #33524

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EFCore.Abstractions/BackingFieldAttribute.cs
Expand Up @@ -20,7 +20,7 @@ public sealed class BackingFieldAttribute : Attribute
/// <param name="name">The name of the backing field.</param>
public BackingFieldAttribute(string name)
{
Check.NotEmpty(name, nameof(name));
Check.NotEmpty(name);

Name = name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Abstractions/CommentAttribute.cs
Expand Up @@ -20,7 +20,7 @@ public sealed class CommentAttribute : Attribute
/// <param name="comment">The comment.</param>
public CommentAttribute(string comment)
{
Check.NotEmpty(comment, nameof(comment));
Check.NotEmpty(comment);

Comment = comment;
}
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.Abstractions/DbFunctionAttribute.cs
Expand Up @@ -38,7 +38,7 @@ public DbFunctionAttribute()
/// <param name="schema">The schema of the function in the database.</param>
public DbFunctionAttribute(string name, string? schema = null)
{
Check.NotEmpty(name, nameof(name));
Check.NotEmpty(name);

_name = name;
_schema = schema;
Expand All @@ -53,7 +53,7 @@ public DbFunctionAttribute(string name, string? schema = null)
get => _name;
set
{
Check.NotEmpty(value, nameof(value));
Check.NotEmpty(value);

_name = value;
}
Expand Down
Expand Up @@ -21,7 +21,7 @@ public class EntityTypeConfigurationAttribute : Attribute
/// <param name="entityConfigurationType">The IEntityTypeConfiguration&lt;&gt; type to use.</param>
public EntityTypeConfigurationAttribute(Type entityConfigurationType)
{
Check.NotNull(entityConfigurationType, nameof(entityConfigurationType));
Check.NotNull(entityConfigurationType);

EntityTypeConfigurationType = entityConfigurationType;
}
Expand Down
10 changes: 5 additions & 5 deletions src/EFCore.Abstractions/IndexAttribute.cs
Expand Up @@ -27,8 +27,8 @@ public sealed class IndexAttribute : Attribute
/// <param name="additionalPropertyNames">The additional properties which constitute the index, if any, in order.</param>
public IndexAttribute(string propertyName, params string[] additionalPropertyNames)
{
Check.NotEmpty(propertyName, nameof(propertyName));
Check.HasNoEmptyElements(additionalPropertyNames, nameof(additionalPropertyNames));
Check.NotEmpty(propertyName);
Check.HasNoEmptyElements(additionalPropertyNames);

PropertyNames = new List<string> { propertyName };
((List<string>)PropertyNames).AddRange(additionalPropertyNames);
Expand All @@ -41,8 +41,8 @@ public IndexAttribute(string propertyName, params string[] additionalPropertyNam
[Obsolete("Use the other constructor")]
public IndexAttribute(params string[] propertyNames)
{
Check.NotEmpty(propertyNames, nameof(propertyNames));
Check.HasNoEmptyElements(propertyNames, nameof(propertyNames));
Check.NotEmpty(propertyNames);
Check.HasNoEmptyElements(propertyNames);

PropertyNames = propertyNames.ToList();
}
Expand All @@ -59,7 +59,7 @@ public IndexAttribute(params string[] propertyNames)
public string? Name
{
get => _name;
set => _name = Check.NotNull(value, nameof(value));
set => _name = Check.NotNull(value);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.Abstractions/PrimaryKeyAttribute.cs
Expand Up @@ -31,8 +31,8 @@ public sealed class PrimaryKeyAttribute : Attribute
/// <param name="additionalPropertyNames">The additional properties which constitute the primary key, if any, in order.</param>
public PrimaryKeyAttribute(string propertyName, params string[] additionalPropertyNames)
{
Check.NotEmpty(propertyName, nameof(propertyName));
Check.HasNoEmptyElements(additionalPropertyNames, nameof(additionalPropertyNames));
Check.NotEmpty(propertyName);
Check.HasNoEmptyElements(additionalPropertyNames);

PropertyNames = new List<string> { propertyName };
((List<string>)PropertyNames).AddRange(additionalPropertyNames);
Expand Down
26 changes: 13 additions & 13 deletions src/EFCore.Cosmos/Extensions/CosmosDbContextOptionsExtensions.cs
Expand Up @@ -49,8 +49,8 @@ public static class CosmosDbContextOptionsExtensions
this DbContextOptionsBuilder optionsBuilder,
Action<CosmosDbContextOptionsBuilder> cosmosOptionsAction)
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(cosmosOptionsAction, nameof(cosmosOptionsAction));
Check.NotNull(optionsBuilder);
Check.NotNull(cosmosOptionsAction);

ConfigureWarnings(optionsBuilder);

Expand Down Expand Up @@ -107,10 +107,10 @@ public static class CosmosDbContextOptionsExtensions
string databaseName,
Action<CosmosDbContextOptionsBuilder>? cosmosOptionsAction = null)
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(accountEndpoint, nameof(accountEndpoint));
Check.NotEmpty(accountKey, nameof(accountKey));
Check.NotEmpty(databaseName, nameof(databaseName));
Check.NotNull(optionsBuilder);
Check.NotNull(accountEndpoint);
Check.NotEmpty(accountKey);
Check.NotEmpty(databaseName);

var extension = optionsBuilder.Options.FindExtension<CosmosOptionsExtension>()
?? new CosmosOptionsExtension();
Expand Down Expand Up @@ -177,10 +177,10 @@ public static class CosmosDbContextOptionsExtensions
string databaseName,
Action<CosmosDbContextOptionsBuilder>? cosmosOptionsAction = null)
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(accountEndpoint, nameof(accountEndpoint));
Check.NotNull(tokenCredential, nameof(tokenCredential));
Check.NotEmpty(databaseName, nameof(databaseName));
Check.NotNull(optionsBuilder);
Check.NotNull(accountEndpoint);
Check.NotNull(tokenCredential);
Check.NotEmpty(databaseName);

var extension = optionsBuilder.Options.FindExtension<CosmosOptionsExtension>()
?? new CosmosOptionsExtension();
Expand Down Expand Up @@ -242,9 +242,9 @@ public static class CosmosDbContextOptionsExtensions
string databaseName,
Action<CosmosDbContextOptionsBuilder>? cosmosOptionsAction = null)
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(connectionString, nameof(connectionString));
Check.NotNull(databaseName, nameof(databaseName));
Check.NotNull(optionsBuilder);
Check.NotNull(connectionString);
Check.NotNull(databaseName);

var extension = optionsBuilder.Options.FindExtension<CosmosOptionsExtension>()
?? new CosmosOptionsExtension();
Expand Down
Expand Up @@ -29,7 +29,7 @@ public static class CosmosEntityTypeBuilderExtensions
this EntityTypeBuilder entityTypeBuilder,
string? name)
{
Check.NullButNotEmpty(name, nameof(name));
Check.NullButNotEmpty(name);

entityTypeBuilder.Metadata.SetContainer(name);

Expand Down Expand Up @@ -99,7 +99,7 @@ public static class CosmosEntityTypeBuilderExtensions
string? name,
bool fromDataAnnotation = false)
{
Check.NullButNotEmpty(name, nameof(name));
Check.NullButNotEmpty(name);

return entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.ContainerName, name, fromDataAnnotation);
}
Expand Down Expand Up @@ -190,7 +190,7 @@ public static class CosmosEntityTypeBuilderExtensions
string? name,
bool fromDataAnnotation = false)
{
Check.NullButNotEmpty(name, nameof(name));
Check.NullButNotEmpty(name);

return entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.PropertyName, name, fromDataAnnotation);
}
Expand Down Expand Up @@ -245,7 +245,7 @@ public static class CosmosEntityTypeBuilderExtensions
Expression<Func<TEntity, TProperty>> propertyExpression)
where TEntity : class
{
Check.NotNull(propertyExpression, nameof(propertyExpression));
Check.NotNull(propertyExpression);

return HasPartitionKey(entityTypeBuilder, propertyExpression.GetMemberAccess().GetSimpleMemberName());
}
Expand Down Expand Up @@ -296,7 +296,7 @@ public static class CosmosEntityTypeBuilderExtensions
string? name,
bool fromDataAnnotation = false)
{
Check.NullButNotEmpty(name, nameof(name));
Check.NullButNotEmpty(name);

return entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.PartitionKeyName, name, fromDataAnnotation);
}
Expand Down Expand Up @@ -413,7 +413,7 @@ public static EntityTypeBuilder<TEntity> UseETagConcurrency<TEntity>(this Entity
int? seconds,
bool fromDataAnnotation = false)
{
Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder));
Check.NotNull(entityTypeBuilder);

return entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.AnalyticalStoreTimeToLive, seconds, fromDataAnnotation);
}
Expand Down
16 changes: 8 additions & 8 deletions src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs
Expand Up @@ -40,7 +40,7 @@ public static class CosmosEntityTypeExtensions
public static void SetContainer(this IMutableEntityType entityType, string? name)
=> entityType.SetOrRemoveAnnotation(
CosmosAnnotationNames.ContainerName,
Check.NullButNotEmpty(name, nameof(name)));
Check.NullButNotEmpty(name));

/// <summary>
/// Sets the name of the container to which the entity type is mapped.
Expand All @@ -54,7 +54,7 @@ public static void SetContainer(this IMutableEntityType entityType, string? name
bool fromDataAnnotation = false)
=> (string?)entityType.SetOrRemoveAnnotation(
CosmosAnnotationNames.ContainerName,
Check.NullButNotEmpty(name, nameof(name)),
Check.NullButNotEmpty(name),
fromDataAnnotation)?.Value;

/// <summary>
Expand Down Expand Up @@ -88,7 +88,7 @@ public static void SetContainer(this IMutableEntityType entityType, string? name
public static void SetContainingPropertyName(this IMutableEntityType entityType, string? name)
=> entityType.SetOrRemoveAnnotation(
CosmosAnnotationNames.PropertyName,
Check.NullButNotEmpty(name, nameof(name)));
Check.NullButNotEmpty(name));

/// <summary>
/// Sets the name of the parent property to which the entity type is mapped.
Expand All @@ -102,7 +102,7 @@ public static void SetContainingPropertyName(this IMutableEntityType entityType,
bool fromDataAnnotation = false)
=> (string?)entityType.SetOrRemoveAnnotation(
CosmosAnnotationNames.PropertyName,
Check.NullButNotEmpty(name, nameof(name)),
Check.NullButNotEmpty(name),
fromDataAnnotation)?.Value;

/// <summary>
Expand Down Expand Up @@ -130,7 +130,7 @@ public static void SetContainingPropertyName(this IMutableEntityType entityType,
public static void SetPartitionKeyPropertyName(this IMutableEntityType entityType, string? name)
=> entityType.SetOrRemoveAnnotation(
CosmosAnnotationNames.PartitionKeyName,
Check.NullButNotEmpty(name, nameof(name)));
Check.NullButNotEmpty(name));

/// <summary>
/// Sets the name of the property that is used to store the partition key.
Expand All @@ -144,7 +144,7 @@ public static void SetPartitionKeyPropertyName(this IMutableEntityType entityTyp
bool fromDataAnnotation = false)
=> (string?)entityType.SetOrRemoveAnnotation(
CosmosAnnotationNames.PartitionKeyName,
Check.NullButNotEmpty(name, nameof(name)),
Check.NullButNotEmpty(name),
fromDataAnnotation)?.Value;

/// <summary>
Expand Down Expand Up @@ -224,7 +224,7 @@ public static void SetPartitionKeyPropertyName(this IMutableEntityType entityTyp
public static void SetETagPropertyName(this IMutableEntityType entityType, string? name)
=> entityType.SetOrRemoveAnnotation(
CosmosAnnotationNames.ETagName,
Check.NullButNotEmpty(name, nameof(name)));
Check.NullButNotEmpty(name));

/// <summary>
/// Sets the name of the property that is used to store the ETag.
Expand All @@ -238,7 +238,7 @@ public static void SetETagPropertyName(this IMutableEntityType entityType, strin
bool fromDataAnnotation = false)
=> (string?)entityType.SetOrRemoveAnnotation(
CosmosAnnotationNames.ETagName,
Check.NullButNotEmpty(name, nameof(name)),
Check.NullButNotEmpty(name),
fromDataAnnotation)?.Value;

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.Cosmos/Extensions/CosmosModelBuilderExtensions.cs
Expand Up @@ -30,7 +30,7 @@ public static class CosmosModelBuilderExtensions
this ModelBuilder modelBuilder,
string? name)
{
Check.NullButNotEmpty(name, nameof(name));
Check.NullButNotEmpty(name);

modelBuilder.Model.SetDefaultContainer(name);

Expand Down Expand Up @@ -83,7 +83,7 @@ public static class CosmosModelBuilderExtensions
string? name,
bool fromDataAnnotation = false)
{
Check.NullButNotEmpty(name, nameof(name));
Check.NullButNotEmpty(name);

return modelBuilder.CanSetAnnotation(CosmosAnnotationNames.ContainerName, name, fromDataAnnotation);
}
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.Cosmos/Extensions/CosmosModelExtensions.cs
Expand Up @@ -31,7 +31,7 @@ public static class CosmosModelExtensions
public static void SetDefaultContainer(this IMutableModel model, string? name)
=> model.SetOrRemoveAnnotation(
CosmosAnnotationNames.ContainerName,
Check.NullButNotEmpty(name, nameof(name)));
Check.NullButNotEmpty(name));

/// <summary>
/// Sets the default container name.
Expand All @@ -46,7 +46,7 @@ public static void SetDefaultContainer(this IMutableModel model, string? name)
bool fromDataAnnotation = false)
=> (string?)model.SetOrRemoveAnnotation(
CosmosAnnotationNames.ContainerName,
Check.NullButNotEmpty(name, nameof(name)),
Check.NullButNotEmpty(name),
fromDataAnnotation)?.Value;

/// <summary>
Expand Down
Expand Up @@ -31,7 +31,7 @@ public static class CosmosPrimitiveCollectionBuilderExtensions
this PrimitiveCollectionBuilder primitiveCollectionBuilder,
string name)
{
Check.NotNull(name, nameof(name));
Check.NotNull(name);

primitiveCollectionBuilder.Metadata.SetJsonPropertyName(name);

Expand Down
Expand Up @@ -34,7 +34,7 @@ public static class CosmosPropertyBuilderExtensions
this PropertyBuilder propertyBuilder,
string name)
{
Check.NotNull(name, nameof(name));
Check.NotNull(name);

propertyBuilder.Metadata.SetJsonPropertyName(name);

Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs
Expand Up @@ -37,7 +37,7 @@ public static class CosmosQueryableExtensions
[NotParameterized] string partitionKey)
where TEntity : class
{
Check.NotNull(partitionKey, nameof(partitionKey));
Check.NotNull(partitionKey);

return
source.Provider is EntityQueryProvider
Expand Down Expand Up @@ -82,8 +82,8 @@ public static class CosmosQueryableExtensions
params object[] parameters)
where TEntity : class
{
Check.NotEmpty(sql, nameof(sql));
Check.NotNull(parameters, nameof(parameters));
Check.NotEmpty(sql);
Check.NotNull(parameters);

var queryableSource = (IQueryable)source;
var entityQueryRootExpression = (EntityQueryRootExpression)queryableSource.Expression;
Expand Down