Skip to content

Commit

Permalink
- Use [CallerArgumentExpression] for parameterName argument in Check …
Browse files Browse the repository at this point in the history
…methods

- Remove explicit setting of parameterName from uses of these methods

Fixes dotnet#33523
  • Loading branch information
Steven.Darby authored and Steven.Darby committed Apr 12, 2024
1 parent 97fc62a commit 9944a0f
Show file tree
Hide file tree
Showing 176 changed files with 1,022 additions and 1,015 deletions.
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
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
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
12 changes: 6 additions & 6 deletions src/EFCore.Cosmos/Query/Internal/CollectionShaperExpression.cs
Expand Up @@ -23,8 +23,8 @@ public class CollectionShaperExpression : Expression, IPrintableExpression
INavigationBase? navigation,
Type elementType)
{
Check.NotNull(projection, nameof(projection));
Check.NotNull(innerShaper, nameof(innerShaper));
Check.NotNull(projection);
Check.NotNull(innerShaper);

Projection = projection;
InnerShaper = innerShaper;
Expand Down Expand Up @@ -90,7 +90,7 @@ public override Type Type
/// </summary>
protected override Expression VisitChildren(ExpressionVisitor visitor)
{
Check.NotNull(visitor, nameof(visitor));
Check.NotNull(visitor);

var projection = visitor.Visit(Projection);
var innerShaper = visitor.Visit(InnerShaper);
Expand All @@ -108,8 +108,8 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
Expression projection,
Expression innerShaper)
{
Check.NotNull(projection, nameof(projection));
Check.NotNull(innerShaper, nameof(innerShaper));
Check.NotNull(projection);
Check.NotNull(innerShaper);

return projection != Projection || innerShaper != InnerShaper
? new CollectionShaperExpression(projection, innerShaper, Navigation, ElementType)
Expand All @@ -124,7 +124,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));
Check.NotNull(expressionPrinter);

expressionPrinter.AppendLine("CollectionShaper:");
using (expressionPrinter.Indent())
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Design/Design/DbContextActivator.cs
Expand Up @@ -41,7 +41,7 @@ public static class DbContextActivator
IOperationReportHandler? reportHandler,
string[]? args)
{
Check.NotNull(contextType, nameof(contextType));
Check.NotNull(contextType);

EF.IsDesignTime = true;

Expand Down

0 comments on commit 9944a0f

Please sign in to comment.