diff --git a/src/EFCore.Design/Design/DbContextActivator.cs b/src/EFCore.Design/Design/DbContextActivator.cs index 36e4d96176d..b0ea5d2b86c 100644 --- a/src/EFCore.Design/Design/DbContextActivator.cs +++ b/src/EFCore.Design/Design/DbContextActivator.cs @@ -4,7 +4,6 @@ using System; using System.Reflection; using Microsoft.EntityFrameworkCore.Design.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Design { @@ -44,8 +43,6 @@ public static DbContext CreateInstance( IOperationReportHandler? reportHandler, string[]? args) { - Check.NotNull(contextType, nameof(contextType)); - return new DbContextOperations( new OperationReporter(reportHandler), contextType.Assembly, diff --git a/src/EFCore.Design/Design/Internal/CSharpHelper.cs b/src/EFCore.Design/Design/Internal/CSharpHelper.cs index b40eb142352..5e653eac7c4 100644 --- a/src/EFCore.Design/Design/Internal/CSharpHelper.cs +++ b/src/EFCore.Design/Design/Internal/CSharpHelper.cs @@ -12,7 +12,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Design.Internal { @@ -161,9 +160,6 @@ public CSharpHelper(ITypeMappingSource typeMappingSource) /// public virtual string Lambda(IReadOnlyList properties, string? lambdaIdentifier) { - Check.NotNull(properties, nameof(properties)); - Check.NullButNotEmpty(lambdaIdentifier, nameof(lambdaIdentifier)); - lambdaIdentifier ??= "x"; var builder = new StringBuilder(); builder.Append(lambdaIdentifier); @@ -194,8 +190,6 @@ public virtual string Lambda(IReadOnlyList properties, string? lambdaIde /// public virtual string Reference(Type type, bool? fullName = null) { - Check.NotNull(type, nameof(type)); - fullName ??= type.IsNested ? ShouldUseFullName(type.DeclaringType!) : ShouldUseFullName(type); return type.DisplayName(fullName.Value, compilable: true); @@ -227,8 +221,6 @@ public virtual bool ShouldUseFullName(string shortTypeName) /// public virtual string Identifier(string name, ICollection? scope = null, bool? capitalize = null) { - Check.NotEmpty(name, nameof(name)); - var builder = new StringBuilder(); var partStart = 0; @@ -305,8 +297,6 @@ private static StringBuilder ChangeFirstLetterCase(StringBuilder builder, bool c /// public virtual string Namespace(params string[] name) { - Check.NotNull(name, nameof(name)); - var @namespace = new StringBuilder(); foreach (var piece in name.Where(p => !string.IsNullOrEmpty(p)) .SelectMany(p => p.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries))) diff --git a/src/EFCore.Design/Design/Internal/DatabaseOperations.cs b/src/EFCore.Design/Design/Internal/DatabaseOperations.cs index 4169d5e3b9f..10bb0d1a104 100644 --- a/src/EFCore.Design/Design/Internal/DatabaseOperations.cs +++ b/src/EFCore.Design/Design/Internal/DatabaseOperations.cs @@ -6,7 +6,6 @@ using System.IO; using System.Reflection; using Microsoft.EntityFrameworkCore.Scaffolding; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Design.Internal @@ -43,10 +42,6 @@ public DatabaseOperations( bool nullable, string[]? args) { - Check.NotNull(reporter, nameof(reporter)); - Check.NotNull(startupAssembly, nameof(startupAssembly)); - Check.NotNull(projectDir, nameof(projectDir)); - _reporter = reporter; _projectDir = projectDir; _rootNamespace = rootNamespace; @@ -79,11 +74,6 @@ public virtual SavedModelFiles ScaffoldContext( bool suppressOnConfiguring, bool noPluralize) { - Check.NotEmpty(provider, nameof(provider)); - Check.NotEmpty(connectionString, nameof(connectionString)); - Check.NotNull(schemas, nameof(schemas)); - Check.NotNull(tables, nameof(tables)); - outputDir = outputDir != null ? Path.GetFullPath(Path.Combine(_projectDir, outputDir)) : _projectDir; diff --git a/src/EFCore.Design/Design/Internal/DbContextOperations.cs b/src/EFCore.Design/Design/Internal/DbContextOperations.cs index e1e049032a6..d33f940211b 100644 --- a/src/EFCore.Design/Design/Internal/DbContextOperations.cs +++ b/src/EFCore.Design/Design/Internal/DbContextOperations.cs @@ -83,11 +83,6 @@ protected DbContextOperations( string[]? args, AppServiceProviderFactory appServicesFactory) { - Check.NotNull(reporter, nameof(reporter)); - Check.NotNull(assembly, nameof(assembly)); - Check.NotNull(startupAssembly, nameof(startupAssembly)); - Check.NotNull(projectDir, nameof(projectDir)); - _reporter = reporter; _assembly = assembly; _startupAssembly = startupAssembly; diff --git a/src/EFCore.Design/Design/Internal/DesignTimeServicesBuilder.cs b/src/EFCore.Design/Design/Internal/DesignTimeServicesBuilder.cs index c061ea996a9..b89e4916d46 100644 --- a/src/EFCore.Design/Design/Internal/DesignTimeServicesBuilder.cs +++ b/src/EFCore.Design/Design/Internal/DesignTimeServicesBuilder.cs @@ -50,7 +50,7 @@ public DesignTimeServicesBuilder( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IServiceProvider Build(DbContext context) - => CreateServiceCollection(Check.NotNull(context, nameof(context))).BuildServiceProvider(); + => CreateServiceCollection(context).BuildServiceProvider(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -78,7 +78,7 @@ public virtual IServiceCollection CreateServiceCollection(DbContext context) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IServiceProvider Build(string provider) - => CreateServiceCollection(Check.NotEmpty(provider, nameof(provider))).BuildServiceProvider(); + => CreateServiceCollection(provider).BuildServiceProvider(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Design/Design/Internal/MigrationsOperations.cs b/src/EFCore.Design/Design/Internal/MigrationsOperations.cs index 6085bd70e60..5cee3b09402 100644 --- a/src/EFCore.Design/Design/Internal/MigrationsOperations.cs +++ b/src/EFCore.Design/Design/Internal/MigrationsOperations.cs @@ -11,7 +11,6 @@ using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations.Design; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Design.Internal @@ -50,11 +49,6 @@ public MigrationsOperations( bool nullable, string[]? args) { - Check.NotNull(reporter, nameof(reporter)); - Check.NotNull(assembly, nameof(assembly)); - Check.NotNull(startupAssembly, nameof(startupAssembly)); - Check.NotNull(projectDir, nameof(projectDir)); - _reporter = reporter; _assembly = assembly; _projectDir = projectDir; @@ -87,8 +81,6 @@ public virtual MigrationFiles AddMigration( string? contextType, string? @namespace) { - Check.NotEmpty(name, nameof(name)); - if (outputDir != null) { outputDir = Path.GetFullPath(Path.Combine(_projectDir, outputDir)); diff --git a/src/EFCore.Design/Design/Internal/OperationLoggerProvider.cs b/src/EFCore.Design/Design/Internal/OperationLoggerProvider.cs index 39add0d703a..9bf21918a6c 100644 --- a/src/EFCore.Design/Design/Internal/OperationLoggerProvider.cs +++ b/src/EFCore.Design/Design/Internal/OperationLoggerProvider.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Design.Internal @@ -24,8 +23,6 @@ public class OperationLoggerProvider : ILoggerProvider /// public OperationLoggerProvider(IOperationReporter reporter) { - Check.NotNull(reporter, nameof(reporter)); - _reporter = reporter; } diff --git a/src/EFCore.Design/Design/OperationExecutor.cs b/src/EFCore.Design/Design/OperationExecutor.cs index 3fe55b5e97e..6460d64d1ea 100644 --- a/src/EFCore.Design/Design/OperationExecutor.cs +++ b/src/EFCore.Design/Design/OperationExecutor.cs @@ -703,8 +703,6 @@ public abstract class OperationBase : MarshalByRefObject /// The . protected OperationBase(IOperationResultHandler resultHandler) { - Check.NotNull(resultHandler, nameof(resultHandler)); - _resultHandler = resultHandler; } @@ -714,8 +712,6 @@ protected OperationBase(IOperationResultHandler resultHandler) /// The action to execute. protected virtual void Execute(Action action) { - Check.NotNull(action, nameof(action)); - try { action(); @@ -732,11 +728,7 @@ protected virtual void Execute(Action action) /// The result type. /// The action to execute. protected virtual void Execute(Func action) - { - Check.NotNull(action, nameof(action)); - - Execute(() => _resultHandler.OnResult(action())); - } + => Execute(() => _resultHandler.OnResult(action())); /// /// Executes an action passing results or exceptions to the . @@ -744,11 +736,7 @@ protected virtual void Execute(Func action) /// The type of results. /// The action to execute. protected virtual void Execute(Func> action) - { - Check.NotNull(action, nameof(action)); - - Execute(() => _resultHandler.OnResult(action().ToArray())); - } + => Execute(() => _resultHandler.OnResult(action().ToArray())); } } } diff --git a/src/EFCore.Design/Metadata/Internal/ScaffoldingEntityTypeAnnotations.cs b/src/EFCore.Design/Metadata/Internal/ScaffoldingEntityTypeAnnotations.cs index 903c8d6c41b..9cccba91947 100644 --- a/src/EFCore.Design/Metadata/Internal/ScaffoldingEntityTypeAnnotations.cs +++ b/src/EFCore.Design/Metadata/Internal/ScaffoldingEntityTypeAnnotations.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; - namespace Microsoft.EntityFrameworkCore.Metadata.Internal { /// @@ -32,6 +30,6 @@ public static string GetDbSetName(this IReadOnlyEntityType entityType) public static void SetDbSetName(this IMutableEntityType entityType, string? value) => entityType.SetAnnotation( ScaffoldingAnnotationNames.DbSetName, - Check.NullButNotEmpty(value, nameof(value))); + value); } } diff --git a/src/EFCore.Design/Metadata/Internal/ScaffoldingModelExtensions.cs b/src/EFCore.Design/Metadata/Internal/ScaffoldingModelExtensions.cs index f669c772ea7..782f69d7c4d 100644 --- a/src/EFCore.Design/Metadata/Internal/ScaffoldingModelExtensions.cs +++ b/src/EFCore.Design/Metadata/Internal/ScaffoldingModelExtensions.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Internal { @@ -50,7 +49,7 @@ public static IDictionary GetOrCreateEntityTypeErrors(this IRead public static void SetEntityTypeErrors(this IMutableModel model, IDictionary value) => model.SetAnnotation( ScaffoldingAnnotationNames.EntityTypeErrors, - Check.NotNull(value, nameof(value))); + value); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -70,6 +69,6 @@ public static void SetEntityTypeErrors(this IMutableModel model, IDictionary model.SetAnnotation( ScaffoldingAnnotationNames.DatabaseName, - Check.NullButNotEmpty(value, nameof(value))); + value); } } diff --git a/src/EFCore.Design/Migrations/Design/CSharpMigrationOperationGenerator.cs b/src/EFCore.Design/Migrations/Design/CSharpMigrationOperationGenerator.cs index f32046bfeac..0c8a425bbcb 100644 --- a/src/EFCore.Design/Migrations/Design/CSharpMigrationOperationGenerator.cs +++ b/src/EFCore.Design/Migrations/Design/CSharpMigrationOperationGenerator.cs @@ -27,8 +27,6 @@ public class CSharpMigrationOperationGenerator : ICSharpMigrationOperationGenera /// The dependencies. public CSharpMigrationOperationGenerator(CSharpMigrationOperationGeneratorDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -51,10 +49,6 @@ public virtual void Generate( IReadOnlyList operations, IndentedStringBuilder builder) { - Check.NotEmpty(builderName, nameof(builderName)); - Check.NotNull(operations, nameof(operations)); - Check.NotNull(builder, nameof(builder)); - var first = true; foreach (var operation in operations) { @@ -81,12 +75,7 @@ public virtual void Generate( /// The operation. /// The builder code is added to. protected virtual void Generate(MigrationOperation operation, IndentedStringBuilder builder) - { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - - throw new InvalidOperationException(DesignStrings.UnknownOperation(operation.GetType())); - } + => throw new InvalidOperationException(DesignStrings.UnknownOperation(operation.GetType())); /// /// Generates code for an . @@ -95,9 +84,6 @@ protected virtual void Generate(MigrationOperation operation, IndentedStringBuil /// The builder code is added to. protected virtual void Generate(AddColumnOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder .Append(".AddColumn<") .Append(Code.Reference(operation.ClrType)) @@ -236,9 +222,6 @@ protected virtual void Generate(AddColumnOperation operation, IndentedStringBuil /// The builder code is added to. protected virtual void Generate(AddForeignKeyOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".AddForeignKey("); using (builder.Indent()) @@ -334,9 +317,6 @@ protected virtual void Generate(AddForeignKeyOperation operation, IndentedString /// The builder code is added to. protected virtual void Generate(AddPrimaryKeyOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".AddPrimaryKey("); using (builder.Indent()) @@ -385,9 +365,6 @@ protected virtual void Generate(AddPrimaryKeyOperation operation, IndentedString /// The builder code is added to. protected virtual void Generate(AddUniqueConstraintOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".AddUniqueConstraint("); using (builder.Indent()) @@ -436,9 +413,6 @@ protected virtual void Generate(AddUniqueConstraintOperation operation, Indented /// The builder code is added to. protected virtual void Generate(AddCheckConstraintOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".AddCheckConstraint("); using (builder.Indent()) @@ -475,9 +449,6 @@ protected virtual void Generate(AddCheckConstraintOperation operation, IndentedS /// The builder code is added to. protected virtual void Generate(AlterColumnOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder .Append(".AlterColumn<") .Append(Code.Reference(operation.ClrType)) @@ -724,9 +695,6 @@ protected virtual void Generate(AlterColumnOperation operation, IndentedStringBu /// The builder code is added to. protected virtual void Generate(AlterDatabaseOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.Append(".AlterDatabase("); using (builder.Indent()) @@ -772,9 +740,6 @@ protected virtual void Generate(AlterDatabaseOperation operation, IndentedString /// The builder code is added to. protected virtual void Generate(AlterSequenceOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".AlterSequence("); using (builder.Indent()) @@ -867,9 +832,6 @@ protected virtual void Generate(AlterSequenceOperation operation, IndentedString /// The builder code is added to. protected virtual void Generate(AlterTableOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".AlterTable("); using (builder.Indent()) @@ -916,9 +878,6 @@ protected virtual void Generate(AlterTableOperation operation, IndentedStringBui /// The builder code is added to. protected virtual void Generate(CreateIndexOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".CreateIndex("); using (builder.Indent()) @@ -982,9 +941,6 @@ protected virtual void Generate(CreateIndexOperation operation, IndentedStringBu /// The builder code is added to. protected virtual void Generate(EnsureSchemaOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".EnsureSchema("); using (builder.Indent()) @@ -1005,9 +961,6 @@ protected virtual void Generate(EnsureSchemaOperation operation, IndentedStringB /// The builder code is added to. protected virtual void Generate(CreateSequenceOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.Append(".CreateSequence"); if (operation.ClrType != typeof(long)) @@ -1086,9 +1039,6 @@ protected virtual void Generate(CreateSequenceOperation operation, IndentedStrin /// The builder code is added to. protected virtual void Generate(CreateTableOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".CreateTable("); using (builder.Indent()) @@ -1393,9 +1343,6 @@ protected virtual void Generate(CreateTableOperation operation, IndentedStringBu /// The builder code is added to. protected virtual void Generate(DropColumnOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".DropColumn("); using (builder.Indent()) @@ -1429,9 +1376,6 @@ protected virtual void Generate(DropColumnOperation operation, IndentedStringBui /// The builder code is added to. protected virtual void Generate(DropForeignKeyOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".DropForeignKey("); using (builder.Indent()) @@ -1465,9 +1409,6 @@ protected virtual void Generate(DropForeignKeyOperation operation, IndentedStrin /// The builder code is added to. protected virtual void Generate(DropIndexOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".DropIndex("); using (builder.Indent()) @@ -1505,9 +1446,6 @@ protected virtual void Generate(DropIndexOperation operation, IndentedStringBuil /// The builder code is added to. protected virtual void Generate(DropPrimaryKeyOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".DropPrimaryKey("); using (builder.Indent()) @@ -1541,9 +1479,6 @@ protected virtual void Generate(DropPrimaryKeyOperation operation, IndentedStrin /// The builder code is added to. protected virtual void Generate(DropSchemaOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".DropSchema("); using (builder.Indent()) @@ -1564,9 +1499,6 @@ protected virtual void Generate(DropSchemaOperation operation, IndentedStringBui /// The builder code is added to. protected virtual void Generate(DropSequenceOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".DropSequence("); using (builder.Indent()) @@ -1596,9 +1528,6 @@ protected virtual void Generate(DropSequenceOperation operation, IndentedStringB /// The builder code is added to. protected virtual void Generate(DropTableOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".DropTable("); using (builder.Indent()) @@ -1628,9 +1557,6 @@ protected virtual void Generate(DropTableOperation operation, IndentedStringBuil /// The builder code is added to. protected virtual void Generate(DropUniqueConstraintOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".DropUniqueConstraint("); using (builder.Indent()) @@ -1664,9 +1590,6 @@ protected virtual void Generate(DropUniqueConstraintOperation operation, Indente /// The builder code is added to. protected virtual void Generate(DropCheckConstraintOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".DropCheckConstraint("); using (builder.Indent()) @@ -1700,9 +1623,6 @@ protected virtual void Generate(DropCheckConstraintOperation operation, Indented /// The builder code is added to. protected virtual void Generate(RenameColumnOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".RenameColumn("); using (builder.Indent()) @@ -1739,9 +1659,6 @@ protected virtual void Generate(RenameColumnOperation operation, IndentedStringB /// The builder code is added to. protected virtual void Generate(RenameIndexOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".RenameIndex("); using (builder.Indent()) @@ -1783,9 +1700,6 @@ protected virtual void Generate(RenameIndexOperation operation, IndentedStringBu /// The builder code is added to. protected virtual void Generate(RenameSequenceOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".RenameSequence("); using (builder.Indent()) @@ -1831,9 +1745,6 @@ protected virtual void Generate(RenameSequenceOperation operation, IndentedStrin /// The builder code is added to. protected virtual void Generate(RenameTableOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".RenameTable("); using (builder.Indent()) @@ -1879,9 +1790,6 @@ protected virtual void Generate(RenameTableOperation operation, IndentedStringBu /// The builder code is added to. protected virtual void Generate(RestartSequenceOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".RestartSequence("); using (builder.Indent()) @@ -1915,9 +1823,6 @@ protected virtual void Generate(RestartSequenceOperation operation, IndentedStri /// The builder code is added to. protected virtual void Generate(SqlOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder .Append(".Sql(") .Append(Code.Literal(operation.Sql)) @@ -1938,9 +1843,6 @@ protected virtual void Generate( InsertDataOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".InsertData("); using (builder.Indent()) @@ -2016,9 +1918,6 @@ protected virtual void Generate( DeleteDataOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".DeleteData("); using (builder.Indent()) @@ -2112,9 +2011,6 @@ protected virtual void Generate( UpdateDataOperation operation, IndentedStringBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.AppendLine(".UpdateData("); using (builder.Indent()) @@ -2237,9 +2133,6 @@ protected virtual void Annotations( IEnumerable annotations, IndentedStringBuilder builder) { - Check.NotNull(annotations, nameof(annotations)); - Check.NotNull(builder, nameof(builder)); - foreach (var annotation in annotations) { // TODO: Give providers an opportunity to render these as provider-specific extension methods @@ -2262,9 +2155,6 @@ protected virtual void OldAnnotations( IEnumerable annotations, IndentedStringBuilder builder) { - Check.NotNull(annotations, nameof(annotations)); - Check.NotNull(builder, nameof(builder)); - foreach (var annotation in annotations) { // TODO: Give providers an opportunity to render these as provider-specific extension methods diff --git a/src/EFCore.Design/Migrations/Design/CSharpMigrationOperationGeneratorDependencies.cs b/src/EFCore.Design/Migrations/Design/CSharpMigrationOperationGeneratorDependencies.cs index 36e4ebc3b81..bab01801327 100644 --- a/src/EFCore.Design/Migrations/Design/CSharpMigrationOperationGeneratorDependencies.cs +++ b/src/EFCore.Design/Migrations/Design/CSharpMigrationOperationGeneratorDependencies.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Migrations.Design { @@ -43,8 +42,6 @@ public sealed record CSharpMigrationOperationGeneratorDependencies [EntityFrameworkInternal] public CSharpMigrationOperationGeneratorDependencies(ICSharpHelper csharpHelper) { - Check.NotNull(csharpHelper, nameof(csharpHelper)); - CSharpHelper = csharpHelper; } diff --git a/src/EFCore.Design/Migrations/Design/CSharpMigrationsGenerator.cs b/src/EFCore.Design/Migrations/Design/CSharpMigrationsGenerator.cs index 3aa38cf9f7c..26d2226bedc 100644 --- a/src/EFCore.Design/Migrations/Design/CSharpMigrationsGenerator.cs +++ b/src/EFCore.Design/Migrations/Design/CSharpMigrationsGenerator.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations.Operations; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Migrations.Design { @@ -32,8 +31,6 @@ public CSharpMigrationsGenerator( CSharpMigrationsGeneratorDependencies csharpDependencies) : base(dependencies) { - Check.NotNull(csharpDependencies, nameof(csharpDependencies)); - CSharpDependencies = csharpDependencies; } @@ -73,10 +70,6 @@ public override string GenerateMigration( IReadOnlyList upOperations, IReadOnlyList downOperations) { - Check.NotEmpty(migrationName, nameof(migrationName)); - Check.NotNull(upOperations, nameof(upOperations)); - Check.NotNull(downOperations, nameof(downOperations)); - var builder = new IndentedStringBuilder(); var namespaces = new List { "Microsoft.EntityFrameworkCore.Migrations" }; namespaces.AddRange(GetNamespaces(upOperations.Concat(downOperations))); @@ -163,11 +156,6 @@ public override string GenerateMetadata( string migrationId, IModel targetModel) { - Check.NotNull(contextType, nameof(contextType)); - Check.NotEmpty(migrationName, nameof(migrationName)); - Check.NotEmpty(migrationId, nameof(migrationId)); - Check.NotNull(targetModel, nameof(targetModel)); - var builder = new IndentedStringBuilder(); AppendAutoGeneratedTag(builder); var namespaces = new List @@ -260,11 +248,6 @@ public override string GenerateSnapshot( string modelSnapshotName, IModel model) { - Check.NotEmpty(modelSnapshotNamespace, nameof(modelSnapshotNamespace)); - Check.NotNull(contextType, nameof(contextType)); - Check.NotEmpty(modelSnapshotName, nameof(modelSnapshotName)); - Check.NotNull(model, nameof(model)); - var builder = new IndentedStringBuilder(); AppendAutoGeneratedTag(builder); var namespaces = new List diff --git a/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs b/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs index d2add920161..d9ea1fb9502 100644 --- a/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs +++ b/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs @@ -35,8 +35,6 @@ private static readonly MethodInfo _hasAnnotationMethodInfo /// The dependencies. public CSharpSnapshotGenerator(CSharpSnapshotGeneratorDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -56,10 +54,6 @@ private ICSharpHelper Code /// The builder code is added to. public virtual void Generate(string modelBuilderName, IModel model, IndentedStringBuilder stringBuilder) { - Check.NotEmpty(modelBuilderName, nameof(modelBuilderName)); - Check.NotNull(model, nameof(model)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var annotations = Dependencies.AnnotationCodeGenerator .FilterIgnoredAnnotations(model.GetAnnotations()) .ToDictionary(a => a.Name, a => a); @@ -90,10 +84,6 @@ protected virtual void GenerateEntityTypes( IEnumerable entityTypes, IndentedStringBuilder stringBuilder) { - Check.NotEmpty(modelBuilderName, nameof(modelBuilderName)); - Check.NotNull(entityTypes, nameof(entityTypes)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - foreach (var entityType in entityTypes.Where( e => e.FindOwnership() == null)) { @@ -133,10 +123,6 @@ protected virtual void GenerateEntityType( IEntityType entityType, IndentedStringBuilder stringBuilder) { - Check.NotEmpty(modelBuilderName, nameof(modelBuilderName)); - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var ownership = entityType.FindOwnership(); var ownerNavigation = ownership?.PrincipalToDependent!.Name; @@ -239,10 +225,6 @@ protected virtual void GenerateOwnedTypes( IEnumerable ownerships, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(ownerships, nameof(ownerships)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - foreach (var ownership in ownerships) { stringBuilder.AppendLine(); @@ -261,13 +243,7 @@ protected virtual void GenerateOwnedType( string entityTypeBuilderName, IForeignKey ownership, IndentedStringBuilder stringBuilder) - { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(ownership, nameof(ownership)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - - GenerateEntityType(entityTypeBuilderName, ownership.DeclaringEntityType, stringBuilder); - } + => GenerateEntityType(entityTypeBuilderName, ownership.DeclaringEntityType, stringBuilder); /// /// Generates code for the relationships of an . @@ -280,10 +256,6 @@ protected virtual void GenerateEntityTypeRelationships( IEntityType entityType, IndentedStringBuilder stringBuilder) { - Check.NotEmpty(modelBuilderName, nameof(modelBuilderName)); - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - stringBuilder .Append(modelBuilderName) .Append(".Entity(") @@ -314,10 +286,6 @@ protected virtual void GenerateRelationships( IEntityType entityType, IndentedStringBuilder stringBuilder) { - Check.NotEmpty(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - GenerateForeignKeys(entityTypeBuilderName, entityType.GetDeclaredForeignKeys(), stringBuilder); GenerateOwnedTypes( @@ -339,9 +307,6 @@ protected virtual void GenerateBaseType( IEntityType? baseType, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - if (baseType != null) { stringBuilder @@ -451,10 +416,6 @@ protected virtual void GenerateProperties( IEnumerable properties, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(properties, nameof(properties)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - foreach (var property in properties) { GenerateProperty(entityTypeBuilderName, property, stringBuilder); @@ -472,10 +433,6 @@ protected virtual void GenerateProperty( IProperty property, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(property, nameof(property)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var clrType = FindValueConverter(property)?.ProviderClrType.MakeNullable(property.IsNullable) ?? property.ClrType; @@ -530,10 +487,6 @@ protected virtual void GeneratePropertyAnnotations( IProperty property, IndentedStringBuilder stringBuilder) { - Check.NotNull(propertyBuilderName, nameof(propertyBuilderName)); - Check.NotNull(property, nameof(property)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var annotations = Dependencies.AnnotationCodeGenerator .FilterIgnoredAnnotations(property.GetAnnotations()) .ToDictionary(a => a.Name, a => a); @@ -578,10 +531,6 @@ protected virtual void GenerateKeys( IKey? primaryKey, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(keys, nameof(keys)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - if (primaryKey != null) { GenerateKey(entityTypeBuilderName, primaryKey, stringBuilder, primary: true); @@ -612,10 +561,6 @@ protected virtual void GenerateKey( IndentedStringBuilder stringBuilder, bool primary = false) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(key, nameof(key)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var keyBuilderName = new StringBuilder() .Append(entityTypeBuilderName) .Append(primary ? ".HasKey(" : ".HasAlternateKey(") @@ -641,10 +586,6 @@ protected virtual void GenerateKey( /// The builder code is added to. protected virtual void GenerateKeyAnnotations(string keyBuilderName, IKey key, IndentedStringBuilder stringBuilder) { - Check.NotNull(keyBuilderName, nameof(keyBuilderName)); - Check.NotNull(key, nameof(key)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var annotations = Dependencies.AnnotationCodeGenerator .FilterIgnoredAnnotations(key.GetAnnotations()) .ToDictionary(a => a.Name, a => a); @@ -663,10 +604,6 @@ protected virtual void GenerateIndexes( IEnumerable indexes, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(indexes, nameof(indexes)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - foreach (var index in indexes) { GenerateIndex(entityTypeBuilderName, index, stringBuilder); @@ -684,10 +621,6 @@ protected virtual void GenerateIndex( IIndex index, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(index, nameof(index)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - // Note - method names below are meant to be hard-coded // because old snapshot files will fail if they are changed @@ -726,10 +659,6 @@ protected virtual void GenerateIndexAnnotations( IIndex index, IndentedStringBuilder stringBuilder) { - Check.NotNull(indexBuilderName, nameof(indexBuilderName)); - Check.NotNull(index, nameof(index)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var annotations = Dependencies.AnnotationCodeGenerator .FilterIgnoredAnnotations(index.GetAnnotations()) .ToDictionary(a => a.Name, a => a); @@ -748,10 +677,6 @@ protected virtual void GenerateEntityTypeAnnotations( IEntityType entityType, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var annotationList = entityType.GetAnnotations().ToList(); var discriminatorPropertyAnnotation = annotationList.FirstOrDefault(a => a.Name == CoreAnnotationNames.DiscriminatorProperty); @@ -980,10 +905,6 @@ protected virtual void GenerateCheckConstraints( IEntityType entityType, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var constraintsForEntity = entityType.GetCheckConstraints(); foreach (var checkConstraint in constraintsForEntity) @@ -1005,10 +926,6 @@ protected virtual void GenerateCheckConstraint( ICheckConstraint checkConstraint, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(checkConstraint, nameof(checkConstraint)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - stringBuilder .Append(entityTypeBuilderName) .Append(".HasCheckConstraint(") @@ -1038,10 +955,6 @@ protected virtual void GenerateForeignKeys( IEnumerable foreignKeys, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(foreignKeys, nameof(foreignKeys)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - foreach (var foreignKey in foreignKeys) { stringBuilder.AppendLine(); @@ -1061,10 +974,6 @@ protected virtual void GenerateForeignKey( IForeignKey foreignKey, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(foreignKey, nameof(foreignKey)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var foreignKeyBuilderNameStringBuilder = new StringBuilder(); if (!foreignKey.IsOwnership) @@ -1199,10 +1108,6 @@ protected virtual void GenerateForeignKeyAnnotations( IForeignKey foreignKey, IndentedStringBuilder stringBuilder) { - Check.NotNull(foreignKeyBuilderName, nameof(foreignKeyBuilderName)); - Check.NotNull(foreignKey, nameof(foreignKey)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var annotations = Dependencies.AnnotationCodeGenerator .FilterIgnoredAnnotations(foreignKey.GetAnnotations()) .ToDictionary(a => a.Name, a => a); @@ -1221,10 +1126,6 @@ protected virtual void GenerateEntityTypeNavigations( IEntityType entityType, IndentedStringBuilder stringBuilder) { - Check.NotEmpty(modelBuilderName, nameof(modelBuilderName)); - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - stringBuilder .Append(modelBuilderName) .Append(".Entity(") @@ -1257,10 +1158,6 @@ protected virtual void GenerateNavigations( IEnumerable navigations, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(navigations, nameof(navigations)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - foreach (var navigation in navigations) { stringBuilder.AppendLine(); @@ -1280,10 +1177,6 @@ protected virtual void GenerateNavigation( INavigation navigation, IndentedStringBuilder stringBuilder) { - Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName)); - Check.NotNull(navigation, nameof(navigation)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var navigationBuilderName = $"{entityTypeBuilderName}.Navigation({Code.Literal(navigation.Name)})"; stringBuilder.Append(navigationBuilderName); @@ -1314,10 +1207,6 @@ protected virtual void GenerateNavigationAnnotations( INavigation navigation, IndentedStringBuilder stringBuilder) { - Check.NotNull(navigationBuilderName, nameof(navigationBuilderName)); - Check.NotNull(navigation, nameof(navigation)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var annotations = Dependencies.AnnotationCodeGenerator .FilterIgnoredAnnotations(navigation.GetAnnotations()) .ToDictionary(a => a.Name, a => a); @@ -1338,10 +1227,6 @@ protected virtual void GenerateData( IEnumerable> data, IndentedStringBuilder stringBuilder) { - Check.NotNull(properties, nameof(properties)); - Check.NotNull(data, nameof(data)); - Check.NotNull(stringBuilder, nameof(stringBuilder)); - var dataList = data.ToList(); if (dataList.Count == 0) { diff --git a/src/EFCore.Design/Migrations/Design/CSharpSnapshotGeneratorDependencies.cs b/src/EFCore.Design/Migrations/Design/CSharpSnapshotGeneratorDependencies.cs index 9b303078e2c..cfc15f3d8cf 100644 --- a/src/EFCore.Design/Migrations/Design/CSharpSnapshotGeneratorDependencies.cs +++ b/src/EFCore.Design/Migrations/Design/CSharpSnapshotGeneratorDependencies.cs @@ -4,7 +4,6 @@ using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Migrations.Design { @@ -47,8 +46,6 @@ public CSharpSnapshotGeneratorDependencies( IRelationalTypeMappingSource relationalTypeMappingSource, IAnnotationCodeGenerator annotationCodeGenerator) { - Check.NotNull(csharpHelper, nameof(csharpHelper)); - CSharpHelper = csharpHelper; RelationalTypeMappingSource = relationalTypeMappingSource; AnnotationCodeGenerator = annotationCodeGenerator; diff --git a/src/EFCore.Design/Migrations/Design/MigrationsCodeGenerator.cs b/src/EFCore.Design/Migrations/Design/MigrationsCodeGenerator.cs index c74bbc674b2..5cfa6a76d23 100644 --- a/src/EFCore.Design/Migrations/Design/MigrationsCodeGenerator.cs +++ b/src/EFCore.Design/Migrations/Design/MigrationsCodeGenerator.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations.Operations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Migrations.Design { @@ -27,8 +26,6 @@ public abstract class MigrationsCodeGenerator : IMigrationsCodeGenerator /// The dependencies. protected MigrationsCodeGenerator(MigrationsCodeGeneratorDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore.Design/Migrations/Design/MigrationsScaffolder.cs b/src/EFCore.Design/Migrations/Design/MigrationsScaffolder.cs index 6685df740d5..8398cc2c6a5 100644 --- a/src/EFCore.Design/Migrations/Design/MigrationsScaffolder.cs +++ b/src/EFCore.Design/Migrations/Design/MigrationsScaffolder.cs @@ -35,8 +35,6 @@ public class MigrationsScaffolder : IMigrationsScaffolder /// The dependencies. public MigrationsScaffolder(MigrationsScaffolderDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - _contextType = dependencies.CurrentContext.Context.GetType(); _activeProvider = dependencies.DatabaseProvider.Name; Dependencies = dependencies; @@ -80,8 +78,6 @@ public virtual ScaffoldedMigration ScaffoldMigration( string? subNamespace = null, string? language = null) { - Check.NotEmpty(migrationName, nameof(migrationName)); - if (Dependencies.MigrationsAssembly.FindMigrationId(migrationName) != null) { throw new OperationException(DesignStrings.DuplicateMigrationName(migrationName)); @@ -250,8 +246,6 @@ public virtual MigrationFiles RemoveMigration( bool force, string? language) { - Check.NotEmpty(projectDir, nameof(projectDir)); - var files = new MigrationFiles(); var modelSnapshot = Dependencies.MigrationsAssembly.ModelSnapshot; @@ -391,9 +385,6 @@ public virtual MigrationFiles RemoveMigration( /// The saved migrations files. public virtual MigrationFiles Save(string projectDir, ScaffoldedMigration migration, string? outputDir) { - Check.NotEmpty(projectDir, nameof(projectDir)); - Check.NotNull(migration, nameof(migration)); - var lastMigrationFileName = migration.PreviousMigrationId + migration.FileExtension; var migrationDirectory = outputDir ?? GetDirectory(projectDir, lastMigrationFileName, migration.MigrationSubNamespace); var migrationFile = Path.Combine(migrationDirectory, migration.MigrationId + migration.FileExtension); @@ -453,9 +444,6 @@ protected virtual string GetDirectory( string? siblingFileName, string subnamespace) { - Check.NotEmpty(projectDir, nameof(projectDir)); - Check.NotNull(subnamespace, nameof(subnamespace)); - var defaultDirectory = Path.Combine(projectDir, Path.Combine(subnamespace.Split('.'))); if (siblingFileName != null) diff --git a/src/EFCore.Design/Migrations/Design/MigrationsScaffolderDependencies.cs b/src/EFCore.Design/Migrations/Design/MigrationsScaffolderDependencies.cs index 3f86f6b1fe8..c740f7bf2c5 100644 --- a/src/EFCore.Design/Migrations/Design/MigrationsScaffolderDependencies.cs +++ b/src/EFCore.Design/Migrations/Design/MigrationsScaffolderDependencies.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations.Internal; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Migrations.Design { @@ -57,18 +56,6 @@ public MigrationsScaffolderDependencies( ISnapshotModelProcessor snapshotModelProcessor, IMigrator migrator) { - Check.NotNull(currentContext, nameof(currentContext)); - Check.NotNull(model, nameof(model)); - Check.NotNull(migrationsAssembly, nameof(migrationsAssembly)); - Check.NotNull(migrationsModelDiffer, nameof(migrationsModelDiffer)); - Check.NotNull(migrationsIdGenerator, nameof(migrationsIdGenerator)); - Check.NotNull(migrationsCodeGeneratorSelector, nameof(migrationsCodeGeneratorSelector)); - Check.NotNull(historyRepository, nameof(historyRepository)); - Check.NotNull(operationReporter, nameof(operationReporter)); - Check.NotNull(databaseProvider, nameof(databaseProvider)); - Check.NotNull(snapshotModelProcessor, nameof(snapshotModelProcessor)); - Check.NotNull(migrator, nameof(migrator)); - CurrentContext = currentContext; Model = model; MigrationsAssembly = migrationsAssembly; diff --git a/src/EFCore.Design/Migrations/Design/ScaffoldedMigration.cs b/src/EFCore.Design/Migrations/Design/ScaffoldedMigration.cs index 3a1a4b63108..b6ff8050a94 100644 --- a/src/EFCore.Design/Migrations/Design/ScaffoldedMigration.cs +++ b/src/EFCore.Design/Migrations/Design/ScaffoldedMigration.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; - namespace Microsoft.EntityFrameworkCore.Migrations.Design { /// @@ -33,15 +31,6 @@ public ScaffoldedMigration( string snapshotName, string snapshotSubNamespace) { - Check.NotEmpty(fileExtension, nameof(fileExtension)); - Check.NotEmpty(migrationCode, nameof(migrationCode)); - Check.NotEmpty(migrationId, nameof(migrationId)); - Check.NotEmpty(metadataCode, nameof(metadataCode)); - Check.NotNull(migrationSubNamespace, nameof(migrationSubNamespace)); - Check.NotEmpty(snapshotCode, nameof(snapshotCode)); - Check.NotEmpty(snapshotName, nameof(snapshotName)); - Check.NotNull(snapshotSubNamespace, nameof(snapshotSubNamespace)); - FileExtension = fileExtension; PreviousMigrationId = previousMigrationId; MigrationCode = migrationCode; diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.cs index f23f89baa2f..282f0ba199e 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.cs @@ -12,7 +12,6 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -46,10 +45,6 @@ public CSharpDbContextGenerator( IAnnotationCodeGenerator annotationCodeGenerator, ICSharpHelper cSharpHelper) { - Check.NotNull(providerConfigurationCodeGenerator, nameof(providerConfigurationCodeGenerator)); - Check.NotNull(annotationCodeGenerator, nameof(annotationCodeGenerator)); - Check.NotNull(cSharpHelper, nameof(cSharpHelper)); - _providerConfigurationCodeGenerator = providerConfigurationCodeGenerator; _annotationCodeGenerator = annotationCodeGenerator; _code = cSharpHelper; @@ -72,8 +67,6 @@ public virtual string WriteCode( bool suppressConnectionStringWarning, bool suppressOnConfiguring) { - Check.NotNull(model, nameof(model)); - _useDataAnnotations = useDataAnnotations; _useNullableReferenceTypes = useNullableReferenceTypes; @@ -149,10 +142,6 @@ protected virtual void GenerateClass( bool suppressConnectionStringWarning, bool suppressOnConfiguring) { - Check.NotNull(model, nameof(model)); - Check.NotNull(contextName, nameof(contextName)); - Check.NotNull(connectionString, nameof(connectionString)); - _builder.AppendLine($"public partial class {contextName} : DbContext"); _builder.AppendLine("{"); @@ -246,8 +235,6 @@ protected virtual void GenerateOnConfiguring( string connectionString, bool suppressConnectionStringWarning) { - Check.NotNull(connectionString, nameof(connectionString)); - _builder.AppendLine("protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)"); _builder.AppendLine("{"); @@ -289,8 +276,6 @@ protected virtual void GenerateOnConfiguring( /// protected virtual void GenerateOnModelCreating(IModel model) { - Check.NotNull(model, nameof(model)); - _builder.AppendLine("protected override void OnModelCreating(ModelBuilder modelBuilder)"); _builder.Append("{"); diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs index a24dc987f85..167ad4acbba 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs @@ -12,7 +12,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -41,8 +40,6 @@ public CSharpEntityTypeGenerator( IAnnotationCodeGenerator annotationCodeGenerator, ICSharpHelper cSharpHelper) { - Check.NotNull(cSharpHelper, nameof(cSharpHelper)); - _annotationCodeGenerator = annotationCodeGenerator; _code = cSharpHelper; } @@ -55,8 +52,6 @@ public CSharpEntityTypeGenerator( /// public virtual string WriteCode(IEntityType entityType, string? @namespace, bool useDataAnnotations, bool useNullableReferenceTypes) { - Check.NotNull(entityType, nameof(entityType)); - _useDataAnnotations = useDataAnnotations; _useNullableReferenceTypes = useNullableReferenceTypes; @@ -109,8 +104,6 @@ public virtual string WriteCode(IEntityType entityType, string? @namespace, bool /// protected virtual void GenerateClass(IEntityType entityType) { - Check.NotNull(entityType, nameof(entityType)); - GenerateComment(entityType.GetComment()); if (_useDataAnnotations) @@ -141,8 +134,6 @@ protected virtual void GenerateClass(IEntityType entityType) /// protected virtual void GenerateEntityTypeDataAnnotations(IEntityType entityType) { - Check.NotNull(entityType, nameof(entityType)); - GenerateKeylessAttribute(entityType); GenerateTableAttribute(entityType); GenerateIndexAttributes(entityType); @@ -240,8 +231,6 @@ private void GenerateIndexAttributes(IEntityType entityType) /// protected virtual void GenerateConstructor(IEntityType entityType) { - Check.NotNull(entityType, nameof(entityType)); - var collectionNavigations = entityType.GetDeclaredNavigations() .Cast() .Concat(entityType.GetDeclaredSkipNavigations()) @@ -274,8 +263,6 @@ protected virtual void GenerateConstructor(IEntityType entityType) /// protected virtual void GenerateProperties(IEntityType entityType) { - Check.NotNull(entityType, nameof(entityType)); - foreach (var property in entityType.GetProperties().OrderBy(p => p.GetColumnOrder() ?? -1)) { GenerateComment(property.GetComment()); @@ -302,8 +289,6 @@ protected virtual void GenerateProperties(IEntityType entityType) /// protected virtual void GeneratePropertyDataAnnotations(IProperty property) { - Check.NotNull(property, nameof(property)); - GenerateKeyAttribute(property); GenerateRequiredAttribute(property); GenerateColumnAttribute(property); @@ -437,8 +422,6 @@ private void GeneratePrecisionAttribute(IProperty property) /// protected virtual void GenerateNavigationProperties(IEntityType entityType) { - Check.NotNull(entityType, nameof(entityType)); - var sortedNavigations = entityType.GetNavigations() .OrderBy(n => n.IsOnDependent ? 0 : 1) .ThenBy(n => n.IsCollection ? 1 : 0) @@ -515,8 +498,6 @@ private void GenerateInversePropertyAttribute(ISkipNavigation navigation) /// protected virtual void GenerateSkipNavigationProperties(IEntityType entityType) { - Check.NotNull(entityType, nameof(entityType)); - var skipNavigations = entityType.GetSkipNavigations().ToList(); if (skipNavigations.Count > 0) @@ -616,15 +597,11 @@ private sealed class AttributeWriter public AttributeWriter(string attributeName) { - Check.NotEmpty(attributeName, nameof(attributeName)); - _attributeName = attributeName; } public void AddParameter(string parameter) { - Check.NotEmpty(parameter, nameof(parameter)); - _parameters.Add(parameter); } diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpModelGenerator.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpModelGenerator.cs index d133a85ceb1..5ce83113340 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpModelGenerator.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpModelGenerator.cs @@ -5,7 +5,6 @@ using System.IO; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -45,9 +44,6 @@ public CSharpModelGenerator( ICSharpEntityTypeGenerator cSharpEntityTypeGenerator) : base(dependencies) { - Check.NotNull(cSharpDbContextGenerator, nameof(cSharpDbContextGenerator)); - Check.NotNull(cSharpEntityTypeGenerator, nameof(cSharpEntityTypeGenerator)); - CSharpDbContextGenerator = cSharpDbContextGenerator; CSharpEntityTypeGenerator = cSharpEntityTypeGenerator; } @@ -73,9 +69,6 @@ public override ScaffoldedModel GenerateModel( IModel model, ModelCodeGenerationOptions options) { - Check.NotNull(model, nameof(model)); - Check.NotNull(options, nameof(options)); - if (options.ContextName == null) { throw new ArgumentException( diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs index 13c7cee8493..709d0542abd 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -39,9 +38,6 @@ public CSharpNamer( ICSharpUtilities cSharpUtilities, Func? singularizePluralizer) { - Check.NotNull(nameGetter, nameof(nameGetter)); - Check.NotNull(cSharpUtilities, nameof(cSharpUtilities)); - _nameGetter = nameGetter; _cSharpUtilities = cSharpUtilities; _singularizePluralizer = singularizePluralizer; @@ -55,8 +51,6 @@ public CSharpNamer( /// public virtual string GetName(T item) { - Check.NotNull(item, nameof(item)); - if (NameCache.TryGetValue(item, out var cachedName)) { return cachedName; diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs index 814f6dd5692..bdecd247598 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs @@ -13,7 +13,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -43,9 +42,6 @@ public CSharpRuntimeModelCodeGenerator( ICSharpRuntimeAnnotationCodeGenerator annotationCodeGenerator, ICSharpHelper cSharpHelper) { - Check.NotNull(annotationCodeGenerator, nameof(annotationCodeGenerator)); - Check.NotNull(cSharpHelper, nameof(cSharpHelper)); - _annotationCodeGenerator = annotationCodeGenerator; _code = cSharpHelper; } @@ -69,9 +65,6 @@ public virtual IReadOnlyCollection GenerateModel( IModel model, CompiledModelCodeGenerationOptions options) { - Check.NotNull(model, nameof(model)); - Check.NotNull(options, nameof(options)); - var scaffoldedFiles = new List(); var modelCode = CreateModel(model, options.ModelNamespace, options.ContextType, options.UseNullableReferenceTypes); var modelFileName = options.ContextType.ShortDisplayName() + ModelSuffix + FileExtension; diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs index 909713e4b63..530bec2c879 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Globalization; using System.Text.RegularExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -137,9 +136,6 @@ public virtual string GenerateCSharpIdentifier( Func? singularizePluralizer, Func?, string> uniquifier) { - Check.NotNull(identifier, nameof(identifier)); - Check.NotNull(uniquifier, nameof(uniquifier)); - var proposedIdentifier = identifier.Length > 1 && identifier[0] == '@' ? "@" + _invalidCharsRegex.Replace(identifier.Substring(1), "_") @@ -179,8 +175,6 @@ public virtual string Uniquifier( string proposedIdentifier, ICollection? existingIdentifiers) { - Check.NotEmpty(proposedIdentifier, nameof(proposedIdentifier)); - if (existingIdentifiers == null) { return proposedIdentifier; diff --git a/src/EFCore.Design/Scaffolding/Internal/CandidateNamingService.cs b/src/EFCore.Design/Scaffolding/Internal/CandidateNamingService.cs index 83629bb6cbf..5908b3a731f 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CandidateNamingService.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CandidateNamingService.cs @@ -7,7 +7,6 @@ using System.Text; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Scaffolding.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -45,8 +44,6 @@ public virtual string GenerateCandidateIdentifier(DatabaseColumn originalColumn) /// public virtual string GetDependentEndCandidateNavigationPropertyName(IReadOnlyForeignKey foreignKey) { - Check.NotNull(foreignKey, nameof(foreignKey)); - var candidateName = FindCandidateNavigationName(foreignKey.Properties); return !string.IsNullOrEmpty(candidateName) ? candidateName : foreignKey.PrincipalEntityType.ShortName(); @@ -62,9 +59,6 @@ public virtual string GetPrincipalEndCandidateNavigationPropertyName( IReadOnlyForeignKey foreignKey, string dependentEndNavigationPropertyName) { - Check.NotNull(foreignKey, nameof(foreignKey)); - Check.NotEmpty(dependentEndNavigationPropertyName, nameof(dependentEndNavigationPropertyName)); - var allForeignKeysBetweenDependentAndPrincipal = foreignKey.PrincipalEntityType? .GetReferencingForeignKeys() @@ -78,8 +72,6 @@ public virtual string GetPrincipalEndCandidateNavigationPropertyName( private static string GenerateCandidateIdentifier(string originalIdentifier) { - Check.NotNull(originalIdentifier, nameof(originalIdentifier)); - var candidateStringBuilder = new StringBuilder(); var previousLetterCharInWordIsLowerCase = false; var isFirstCharacterInWord = true; diff --git a/src/EFCore.Design/Scaffolding/Internal/CompiledModelScaffolder.cs b/src/EFCore.Design/Scaffolding/Internal/CompiledModelScaffolder.cs index dc329a51f05..3581a86a293 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CompiledModelScaffolder.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CompiledModelScaffolder.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore.Design.Internal; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -34,9 +33,6 @@ public CompiledModelScaffolder( ICompiledModelCodeGeneratorSelector modelCodeGeneratorSelector, IOperationReporter reporter) { - Check.NotNull(modelCodeGeneratorSelector, nameof(modelCodeGeneratorSelector)); - Check.NotNull(reporter, nameof(reporter)); - ModelCodeGeneratorSelector = modelCodeGeneratorSelector; _reporter = reporter; } @@ -60,10 +56,6 @@ public virtual IReadOnlyList ScaffoldModel( string outputDir, CompiledModelCodeGenerationOptions options) { - Check.NotNull(model, nameof(model)); - Check.NotEmpty(outputDir, nameof(outputDir)); - Check.NotNull(options, nameof(options)); - var codeGenerator = ModelCodeGeneratorSelector.Select(options); var scaffoldedModel = codeGenerator.GenerateModel(model, options); diff --git a/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs b/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs index 46418cb52a4..06465be373a 100644 --- a/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs +++ b/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs @@ -17,7 +17,6 @@ using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Scaffolding.Metadata; using Microsoft.EntityFrameworkCore.Scaffolding.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -61,14 +60,6 @@ public RelationalScaffoldingModelFactory( LoggingDefinitions loggingDefinitions, IModelRuntimeInitializer modelRuntimeInitializer) { - Check.NotNull(reporter, nameof(reporter)); - Check.NotNull(candidateNamingService, nameof(candidateNamingService)); - Check.NotNull(pluralizer, nameof(pluralizer)); - Check.NotNull(cSharpUtilities, nameof(cSharpUtilities)); - Check.NotNull(scaffoldingTypeMapper, nameof(scaffoldingTypeMapper)); - Check.NotNull(loggingDefinitions, nameof(loggingDefinitions)); - Check.NotNull(modelRuntimeInitializer, nameof(modelRuntimeInitializer)); - _reporter = reporter; _candidateNamingService = candidateNamingService; _pluralizer = pluralizer; @@ -86,9 +77,6 @@ public RelationalScaffoldingModelFactory( /// public virtual IModel Create(DatabaseModel databaseModel, ModelReverseEngineerOptions options) { - Check.NotNull(databaseModel, nameof(databaseModel)); - Check.NotNull(options, nameof(options)); - var modelBuilder = new ModelBuilder(); _tableNamer = new CSharpUniqueNamer( @@ -122,7 +110,7 @@ public virtual IModel Create(DatabaseModel databaseModel, ModelReverseEngineerOp /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual string GetEntityTypeName(DatabaseTable table) - => _tableNamer.GetName(Check.NotNull(table, nameof(table))); + => _tableNamer.GetName(table); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -131,7 +119,7 @@ protected virtual string GetEntityTypeName(DatabaseTable table) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual string GetDbSetName(DatabaseTable table) - => _dbSetNamer.GetName(Check.NotNull(table, nameof(table))); + => _dbSetNamer.GetName(table); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -141,8 +129,6 @@ protected virtual string GetDbSetName(DatabaseTable table) /// protected virtual string GetPropertyName(DatabaseColumn column) { - Check.NotNull(column, nameof(column)); - var table = column.Table ?? _nullTable; var usedNames = new List(); if (column.Table != null) @@ -185,9 +171,6 @@ protected virtual string GetPropertyName(DatabaseColumn column) /// protected virtual ModelBuilder VisitDatabaseModel(ModelBuilder modelBuilder, DatabaseModel databaseModel) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - Check.NotNull(databaseModel, nameof(databaseModel)); - if (!string.IsNullOrEmpty(databaseModel.DefaultSchema)) { modelBuilder.HasDefaultSchema(databaseModel.DefaultSchema); @@ -222,9 +205,6 @@ protected virtual ModelBuilder VisitSequences( ModelBuilder modelBuilder, ICollection sequences) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - Check.NotNull(sequences, nameof(sequences)); - foreach (var sequence in sequences) { VisitSequence(modelBuilder, sequence); @@ -241,9 +221,6 @@ protected virtual ModelBuilder VisitSequences( /// protected virtual SequenceBuilder? VisitSequence(ModelBuilder modelBuilder, DatabaseSequence sequence) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - Check.NotNull(sequence, nameof(sequence)); - if (string.IsNullOrEmpty(sequence.Name)) { _reporter.WriteWarning(DesignStrings.SequencesRequireName); @@ -307,9 +284,6 @@ protected virtual ModelBuilder VisitSequences( /// protected virtual ModelBuilder VisitTables(ModelBuilder modelBuilder, ICollection tables) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - Check.NotNull(tables, nameof(tables)); - foreach (var table in tables) { VisitTable(modelBuilder, table); @@ -326,9 +300,6 @@ protected virtual ModelBuilder VisitTables(ModelBuilder modelBuilder, ICollectio /// protected virtual EntityTypeBuilder? VisitTable(ModelBuilder modelBuilder, DatabaseTable table) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - Check.NotNull(table, nameof(table)); - var entityTypeName = GetEntityTypeName(table); var builder = modelBuilder.Entity(entityTypeName); @@ -388,9 +359,6 @@ protected virtual ModelBuilder VisitTables(ModelBuilder modelBuilder, ICollectio /// protected virtual EntityTypeBuilder VisitColumns(EntityTypeBuilder builder, ICollection columns) { - Check.NotNull(builder, nameof(builder)); - Check.NotNull(columns, nameof(columns)); - foreach (var column in columns) { VisitColumn(builder, column); @@ -407,9 +375,6 @@ protected virtual EntityTypeBuilder VisitColumns(EntityTypeBuilder builder, ICol /// protected virtual PropertyBuilder? VisitColumn(EntityTypeBuilder builder, DatabaseColumn column) { - Check.NotNull(builder, nameof(builder)); - Check.NotNull(column, nameof(column)); - var typeScaffoldingInfo = GetTypeScaffoldingInfo(column); if (typeScaffoldingInfo == null) @@ -536,9 +501,6 @@ protected virtual EntityTypeBuilder VisitColumns(EntityTypeBuilder builder, ICol /// protected virtual KeyBuilder? VisitPrimaryKey(EntityTypeBuilder builder, DatabaseTable table) { - Check.NotNull(builder, nameof(builder)); - Check.NotNull(table, nameof(table)); - var primaryKey = table.PrimaryKey!; var unmappedColumns = primaryKey.Columns @@ -592,9 +554,6 @@ protected virtual EntityTypeBuilder VisitUniqueConstraints( EntityTypeBuilder builder, ICollection uniqueConstraints) { - Check.NotNull(builder, nameof(builder)); - Check.NotNull(uniqueConstraints, nameof(uniqueConstraints)); - foreach (var uniqueConstraint in uniqueConstraints) { VisitUniqueConstraint(builder, uniqueConstraint); @@ -613,9 +572,6 @@ protected virtual EntityTypeBuilder VisitUniqueConstraints( EntityTypeBuilder builder, DatabaseUniqueConstraint uniqueConstraint) { - Check.NotNull(builder, nameof(builder)); - Check.NotNull(uniqueConstraint, nameof(uniqueConstraint)); - var unmappedColumns = uniqueConstraint.Columns .Where(c => _unmappedColumns.Contains(c)) .Select(c => c.Name) @@ -647,9 +603,6 @@ protected virtual EntityTypeBuilder VisitUniqueConstraints( /// protected virtual EntityTypeBuilder VisitIndexes(EntityTypeBuilder builder, ICollection indexes) { - Check.NotNull(builder, nameof(builder)); - Check.NotNull(indexes, nameof(indexes)); - foreach (var index in indexes) { VisitIndex(builder, index); @@ -666,9 +619,6 @@ protected virtual EntityTypeBuilder VisitIndexes(EntityTypeBuilder builder, ICol /// protected virtual IndexBuilder? VisitIndex(EntityTypeBuilder builder, DatabaseIndex index) { - Check.NotNull(builder, nameof(builder)); - Check.NotNull(index, nameof(index)); - var unmappedColumns = index.Columns .Where(c => _unmappedColumns.Contains(c)) .Select(c => c.Name) @@ -709,9 +659,6 @@ protected virtual ModelBuilder VisitForeignKeys( ModelBuilder modelBuilder, IList foreignKeys) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - Check.NotNull(foreignKeys, nameof(foreignKeys)); - foreach (var fk in foreignKeys) { VisitForeignKey(modelBuilder, fk); @@ -786,9 +733,6 @@ protected virtual ModelBuilder VisitForeignKeys( /// protected virtual IMutableForeignKey? VisitForeignKey(ModelBuilder modelBuilder, DatabaseForeignKey foreignKey) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - Check.NotNull(foreignKey, nameof(foreignKey)); - if (foreignKey.PrincipalTable == null) { _reporter.WriteWarning( @@ -935,8 +879,6 @@ protected virtual ModelBuilder VisitForeignKeys( /// protected virtual void AddNavigationProperties(IMutableForeignKey foreignKey) { - Check.NotNull(foreignKey, nameof(foreignKey)); - var dependentEndExistingIdentifiers = ExistingIdentifiers(foreignKey.DeclaringEntityType); var dependentEndNavigationPropertyCandidateName = _candidateNamingService.GetDependentEndCandidateNavigationPropertyName(foreignKey); @@ -993,8 +935,6 @@ protected virtual void AddNavigationProperties(IMutableForeignKey foreignKey) /// protected virtual List ExistingIdentifiers(IReadOnlyEntityType entityType) { - Check.NotNull(entityType, nameof(entityType)); - if (!_entityTypeAndPropertyIdentifiers.TryGetValue(entityType, out var existingIdentifiers)) { existingIdentifiers = new List { entityType.Name }; @@ -1029,9 +969,6 @@ private static void AssignOnDeleteAction( DatabaseForeignKey databaseForeignKey, IMutableForeignKey foreignKey) { - Check.NotNull(databaseForeignKey, nameof(databaseForeignKey)); - Check.NotNull(foreignKey, nameof(foreignKey)); - switch (databaseForeignKey.OnDelete) { case ReferentialAction.Cascade: diff --git a/src/EFCore.Design/Scaffolding/Internal/ReverseEngineerScaffolder.cs b/src/EFCore.Design/Scaffolding/Internal/ReverseEngineerScaffolder.cs index c2db93cf8eb..ba78f606a4d 100644 --- a/src/EFCore.Design/Scaffolding/Internal/ReverseEngineerScaffolder.cs +++ b/src/EFCore.Design/Scaffolding/Internal/ReverseEngineerScaffolder.cs @@ -12,8 +12,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Storage.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -49,14 +47,6 @@ public ReverseEngineerScaffolder( IDesignTimeConnectionStringResolver connectionStringResolver, IOperationReporter reporter) { - Check.NotNull(databaseModelFactory, nameof(databaseModelFactory)); - Check.NotNull(scaffoldingModelFactory, nameof(scaffoldingModelFactory)); - Check.NotNull(modelCodeGeneratorSelector, nameof(modelCodeGeneratorSelector)); - Check.NotNull(cSharpUtilities, nameof(cSharpUtilities)); - Check.NotNull(cSharpHelper, nameof(cSharpHelper)); - Check.NotNull(connectionStringResolver, nameof(connectionStringResolver)); - Check.NotNull(reporter, nameof(reporter)); - _databaseModelFactory = databaseModelFactory; _factory = scaffoldingModelFactory; ModelCodeGeneratorSelector = modelCodeGeneratorSelector; @@ -86,11 +76,6 @@ public virtual ScaffoldedModel ScaffoldModel( ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions) { - Check.NotEmpty(connectionString, nameof(connectionString)); - Check.NotNull(databaseOptions, nameof(databaseOptions)); - Check.NotNull(modelOptions, nameof(modelOptions)); - Check.NotNull(codeOptions, nameof(codeOptions)); - if (!string.IsNullOrWhiteSpace(codeOptions.ContextName) && (!_cSharpUtilities.IsValidIdentifier(codeOptions.ContextName) || _cSharpUtilities.IsCSharpKeyword(codeOptions.ContextName))) diff --git a/src/EFCore.Design/Scaffolding/Internal/ScaffoldingTypeMapper.cs b/src/EFCore.Design/Scaffolding/Internal/ScaffoldingTypeMapper.cs index 558335c0c59..fd5d6b2d5bc 100644 --- a/src/EFCore.Design/Scaffolding/Internal/ScaffoldingTypeMapper.cs +++ b/src/EFCore.Design/Scaffolding/Internal/ScaffoldingTypeMapper.cs @@ -3,7 +3,6 @@ using System; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -25,8 +24,6 @@ public class ScaffoldingTypeMapper : IScaffoldingTypeMapper /// public ScaffoldingTypeMapper(IRelationalTypeMappingSource typeMappingSource) { - Check.NotNull(typeMappingSource, nameof(typeMappingSource)); - _typeMappingSource = typeMappingSource; } @@ -41,9 +38,6 @@ public ScaffoldingTypeMapper(IRelationalTypeMappingSource typeMappingSource) bool keyOrIndex, bool rowVersion) { - // This is because certain providers can have no type specified as a default type e.g. SQLite - Check.NotNull(storeType, nameof(storeType)); - var mapping = _typeMappingSource.FindMapping(storeType); if (mapping == null) { diff --git a/src/EFCore.Design/Scaffolding/Internal/TypeScaffoldingInfo.cs b/src/EFCore.Design/Scaffolding/Internal/TypeScaffoldingInfo.cs index 6396be1c436..ae25e34b81a 100644 --- a/src/EFCore.Design/Scaffolding/Internal/TypeScaffoldingInfo.cs +++ b/src/EFCore.Design/Scaffolding/Internal/TypeScaffoldingInfo.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { @@ -29,8 +28,6 @@ public TypeScaffoldingInfo( int? scaffoldPrecision, int? scaffoldScale) { - Check.NotNull(clrType, nameof(clrType)); - IsInferred = inferred; ScaffoldUnicode = scaffoldUnicode; ScaffoldMaxLength = scaffoldMaxLength; diff --git a/src/EFCore.Design/Scaffolding/ModelCodeGenerator.cs b/src/EFCore.Design/Scaffolding/ModelCodeGenerator.cs index 672dff482fa..fc286be493c 100644 --- a/src/EFCore.Design/Scaffolding/ModelCodeGenerator.cs +++ b/src/EFCore.Design/Scaffolding/ModelCodeGenerator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding { @@ -19,7 +18,9 @@ public abstract class ModelCodeGenerator : IModelCodeGenerator /// /// The dependencies. protected ModelCodeGenerator(ModelCodeGeneratorDependencies dependencies) - => Dependencies = Check.NotNull(dependencies, nameof(dependencies)); + { + Dependencies = dependencies; + } /// /// Gets the programming language supported by this service. diff --git a/src/EFCore.Design/Scaffolding/SavedModelFiles.cs b/src/EFCore.Design/Scaffolding/SavedModelFiles.cs index 27888df3c18..e2d79ef9869 100644 --- a/src/EFCore.Design/Scaffolding/SavedModelFiles.cs +++ b/src/EFCore.Design/Scaffolding/SavedModelFiles.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Scaffolding { @@ -18,9 +17,6 @@ public class SavedModelFiles /// The paths of additional files used by the model. public SavedModelFiles(string contextFile, IEnumerable additionalFiles) { - Check.NotNull(contextFile, nameof(contextFile)); - Check.NotNull(additionalFiles, nameof(additionalFiles)); - ContextFile = contextFile; AdditionalFiles = new List(additionalFiles); }