From da00fb69d615fa22a83dfee2077ad31b7bd15823 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Thu, 14 Jan 2021 23:06:09 +0100 Subject: [PATCH] Use target-typed new (#23871) --- .../InternalUsageDiagnosticAnalyzer.cs | 2 +- .../Diagnostics/CosmosEventId.cs | 4 +- .../Internal/CosmosDbOptionExtension.cs | 2 +- .../CosmosMemberTranslatorProvider.cs | 4 +- .../CosmosMethodCallTranslatorProvider.cs | 4 +- ...osmosProjectionBindingExpressionVisitor.cs | 4 +- ...yableMethodTranslatingExpressionVisitor.cs | 2 +- ...ionBindingRemovingExpressionVisitorBase.cs | 2 +- .../Query/Internal/InExpression.cs | 2 +- .../Query/Internal/QuerySqlGenerator.cs | 2 +- .../Internal/QuerySqlGeneratorFactory.cs | 2 +- .../Query/Internal/SelectExpression.cs | 4 +- .../Query/Internal/SqlExpressionFactory.cs | 2 +- .../Query/Internal/SqlFunctionExpression.cs | 6 +- .../Internal/CosmosConcurrencyToken.cs | 6 +- .../Internal/CSharpEntityTypeGenerator.cs | 2 +- .../Scaffolding/Internal/CSharpNamer.cs | 2 +- .../Scaffolding/Internal/CSharpUniqueNamer.cs | 2 +- .../Scaffolding/Internal/CSharpUtilities.cs | 4 +- .../RelationalScaffoldingModelFactory.cs | 6 +- .../Diagnostics/InMemoryEventId.cs | 4 +- .../Internal/InMemoryOptionsExtension.cs | 2 +- ...emoryProjectionBindingExpressionVisitor.cs | 4 +- .../Query/Internal/InMemoryQueryExpression.cs | 2 +- ...erExpressionProcessingExpressionVisitor.cs | 4 +- .../Storage/Internal/InMemoryStore.cs | 4 +- .../Storage/Internal/InMemoryTableFactory.cs | 2 +- .../Internal/InMemoryTransactionManager.cs | 2 +- .../Internal/ProxiesOptionsExtension.cs | 2 +- .../Proxies/Internal/ProxyFactory.cs | 2 +- .../Design/MethodCallCodeFragment.cs | 5 +- .../Diagnostics/DbCommandInterceptor.cs | 12 +- .../Diagnostics/DbConnectionInterceptor.cs | 4 +- .../Diagnostics/DbTransactionInterceptor.cs | 16 +-- .../Diagnostics/RelationalEventId.cs | 14 +-- .../RelationalModelBuilderExtensions.cs | 2 +- .../Builders/DbFunctionBuilderBase.cs | 2 +- .../Metadata/Internal/ColumnBase.cs | 2 +- .../Metadata/Internal/ColumnListComparer.cs | 2 +- .../Internal/ColumnMappingBaseComparer.cs | 2 +- .../Metadata/Internal/ForeignKeyConstraint.cs | 2 +- .../Internal/ForeignKeyConstraintComparer.cs | 2 +- .../Metadata/Internal/NamedListComparer.cs | 2 +- .../Metadata/Internal/RelationalModel.cs | 12 +- .../Metadata/Internal/Table.cs | 6 +- .../Metadata/Internal/TableBase.cs | 4 +- .../Metadata/Internal/TableIndex.cs | 2 +- .../Metadata/Internal/TableIndexComparer.cs | 2 +- .../Metadata/Internal/TableMappingBase.cs | 2 +- .../Internal/TableMappingBaseComparer.cs | 2 +- .../Metadata/Internal/UniqueConstraint.cs | 2 +- .../Internal/UniqueConstraintComparer.cs | 2 +- .../Internal/MigrationsIdGenerator.cs | 2 +- .../Internal/MigrationsModelDiffer.cs | 10 +- .../Migrations/MigrationBuilder.cs | 2 +- .../Migrations/MigrationCommandListBuilder.cs | 2 +- .../Operations/CreateTableOperation.cs | 8 +- .../Internal/QuerySqlGeneratorFactory.cs | 2 +- .../Query/Internal/RelationalCommandCache.cs | 2 +- ...tionalParameterBasedSqlProcessorFactory.cs | 2 +- ...ionalProjectionBindingExpressionVisitor.cs | 2 +- ...lExpressionSimplifyingExpressionVisitor.cs | 2 +- .../Query/QuerySqlGenerator.cs | 2 +- .../RelationalMemberTranslatorProvider.cs | 4 +- .../RelationalMethodCallTranslatorProvider.cs | 4 +- ...yableMethodTranslatingExpressionVisitor.cs | 2 +- ...sitor.ShaperProcessingExpressionVisitor.cs | 6 +- ...lationalSqlTranslatingExpressionVisitor.cs | 2 +- .../Query/SqlExpressionFactory.cs | 4 +- .../Query/SqlExpressions/CaseExpression.cs | 2 +- .../Query/SqlExpressions/ColumnExpression.cs | 2 +- .../Query/SqlExpressions/InExpression.cs | 2 +- .../Query/SqlExpressions/SelectExpression.cs | 24 ++-- .../SqlExpressions/SqlFunctionExpression.cs | 16 ++- .../Storage/ParameterNameGeneratorFactory.cs | 2 +- .../Storage/RelationalCommand.cs | 7 +- .../Storage/RelationalCommandBuilder.cs | 4 +- .../Storage/RelationalConnection.cs | 2 +- .../Storage/RelationalTransactionFactory.cs | 3 +- .../Storage/RelationalTypeMapping.cs | 12 +- .../Storage/RelationalTypeMappingInfo.cs | 2 +- .../Storage/RelationalTypeMappingSource.cs | 2 +- .../Internal/KeyValueIndexFactorySource.cs | 2 +- .../Update/Internal/SharedTableEntryMap.cs | 2 +- .../Update/ModificationCommand.cs | 2 +- .../Update/ReaderModificationCommandBatch.cs | 2 +- .../TemporaryDateTimeOffsetValueGenerator.cs | 2 +- .../TemporaryDateTimeValueGenerator.cs | 2 +- .../RelationalValueGeneratorSelector.cs | 2 +- .../SqlServerGeometryMemberTranslator.cs | 26 ++--- ...rverNetTopologySuiteCodeGeneratorPlugin.cs | 3 +- .../Internal/SqlServerGeometryTypeMapping.cs | 4 +- .../SqlServerAnnotationCodeGenerator.cs | 6 +- .../Diagnostics/SqlServerEventId.cs | 6 +- .../Internal/SqlServerConvertTranslator.cs | 4 +- .../SqlServerDataLengthFunctionTranslator.cs | 4 +- .../SqlServerDateDiffFunctionsTranslator.cs | 2 +- .../SqlServerDateTimeMemberTranslator.cs | 2 +- .../SqlServerDateTimeMethodTranslator.cs | 2 +- .../Query/Internal/SqlServerMathTranslator.cs | 2 +- .../SqlServerObjectToStringTranslator.cs | 2 +- ...qlServerSqlTranslatingExpressionVisitor.cs | 4 +- .../SqlServerTimeSpanMemberTranslator.cs | 2 +- .../Internal/SqlServerCodeGenerator.cs | 2 +- .../Internal/SqlServerDatabaseModelFactory.cs | 4 +- .../Internal/SqlServerTypeMappingSource.cs | 38 +++--- .../SqlServerModificationCommandBatch.cs | 2 +- .../Internal/SqlServerValueGeneratorCache.cs | 2 +- .../Diagnostics/SqliteEventId.cs | 8 +- .../Internal/SqliteCharMethodTranslator.cs | 2 +- .../Internal/SqliteDateTimeAddTranslator.cs | 2 +- .../SqliteDateTimeMemberTranslator.cs | 2 +- .../Query/Internal/SqliteMathTranslator.cs | 2 +- .../SqliteObjectToStringTranslator.cs | 4 +- .../SqliteQueryTranslationPostprocessor.cs | 2 +- .../Internal/SqliteCodeGenerator.cs | 2 +- .../Internal/SqliteTypeMappingSource.cs | 2 +- ...liteNetTopologySuiteCodeGeneratorPlugin.cs | 2 +- src/EFCore/ChangeTracking/ChangeTracker.cs | 2 +- .../ChangeTracking/ChangeTrackerExtensions.cs | 2 +- src/EFCore/ChangeTracking/CollectionEntry`.cs | 2 +- src/EFCore/ChangeTracking/EntityEntry.cs | 2 +- .../ChangeTracking/EntityEntryGraphNode.cs | 2 +- .../Internal/ChangeTrackerFactory.cs | 2 +- .../Internal/InternalEntityEntry.cs | 4 +- .../Internal/ValueGenerationManager.cs | 6 +- src/EFCore/ChangeTracking/MemberEntry.cs | 2 +- .../ChangeTracking/ObservableHashSet.cs | 7 +- src/EFCore/ChangeTracking/PropertyEntry`.cs | 2 +- src/EFCore/ChangeTracking/ReferenceEntry`.cs | 2 +- src/EFCore/DbContext.cs | 6 +- src/EFCore/DbFunctions.cs | 2 +- src/EFCore/Diagnostics/CoreEventId.cs | 12 +- .../Diagnostics/CoreLoggerExtensions.cs | 8 +- src/EFCore/Diagnostics/InterceptionResult.cs | 2 +- src/EFCore/Diagnostics/InterceptionResult`.cs | 2 +- .../Diagnostics/SaveChangesInterceptor.cs | 4 +- .../Diagnostics/WarningsConfiguration.cs | 5 +- src/EFCore/Infrastructure/Annotatable.cs | 2 +- .../Infrastructure/ConventionAnnotatable.cs | 2 +- .../Infrastructure/CoreOptionsExtension.cs | 2 +- .../EntityFrameworkEventSource.cs | 2 +- .../Infrastructure/IndentedStringBuilder.cs | 2 +- .../Internal/ConcurrencyDetector.cs | 2 +- .../Infrastructure/Internal/DbSetFinder.cs | 3 +- src/EFCore/Infrastructure/ModelSource.cs | 2 +- src/EFCore/Internal/DbContextLease.cs | 2 +- src/EFCore/Internal/DbContextPool.cs | 2 +- src/EFCore/Internal/DbSetSource.cs | 3 +- src/EFCore/Internal/EntityFinderSource.cs | 2 +- src/EFCore/Internal/InternalDbSet.cs | 4 +- src/EFCore/Internal/ServiceProviderCache.cs | 5 +- .../Internal/SingletonOptionsInitializer.cs | 2 +- .../Builders/CollectionNavigationBuilder.cs | 2 +- .../Builders/CollectionNavigationBuilder`.cs | 4 +- .../Metadata/Builders/EntityTypeBuilder.cs | 29 ++--- .../Metadata/Builders/EntityTypeBuilder`.cs | 24 ++-- .../Builders/OwnedNavigationBuilder.cs | 12 +- .../Builders/OwnedNavigationBuilder`.cs | 14 +-- .../Builders/ReferenceCollectionBuilder.cs | 10 +- .../Builders/ReferenceCollectionBuilder`.cs | 14 +-- .../Builders/ReferenceNavigationBuilder.cs | 4 +- .../Builders/ReferenceNavigationBuilder`.cs | 8 +- .../Builders/ReferenceReferenceBuilder.cs | 12 +- .../Builders/ReferenceReferenceBuilder`.cs | 17 ++- ...roviderConventionSetBuilderDependencies.cs | 2 +- .../Conventions/Internal/MetadataTracker.cs | 3 +- .../Conventions/NonNullableConventionBase.cs | 2 +- .../RelationshipDiscoveryConvention.cs | 2 +- .../Metadata/EntityTypeFullNameComparer.cs | 2 +- src/EFCore/Metadata/ForeignKeyComparer.cs | 2 +- src/EFCore/Metadata/IndexComparer.cs | 2 +- src/EFCore/Metadata/Internal/EntityType.cs | 18 +-- src/EFCore/Metadata/Internal/ForeignKey.cs | 2 +- src/EFCore/Metadata/Internal/Index.cs | 2 +- src/EFCore/Metadata/Internal/Key.cs | 2 +- src/EFCore/Metadata/Internal/Model.cs | 13 +-- src/EFCore/Metadata/Internal/Navigation.cs | 2 +- src/EFCore/Metadata/Internal/Property.cs | 2 +- .../Metadata/Internal/PropertyListComparer.cs | 2 +- .../Metadata/Internal/ServiceProperty.cs | 2 +- .../Metadata/Internal/SkipNavigation.cs | 2 +- .../Internal/SkipNavigationComparer.cs | 2 +- src/EFCore/Metadata/Internal/TypeBase.cs | 2 +- src/EFCore/Metadata/KeyComparer.cs | 2 +- src/EFCore/Metadata/MemberIdentity.cs | 2 +- src/EFCore/ModelBuilder.cs | 2 +- .../Query/CompiledQueryCacheKeyGenerator.cs | 2 +- .../Query/ExpressionEqualityComparer.cs | 2 +- src/EFCore/Query/ExpressionPrinter.cs | 4 +- .../Query/Internal/CompiledQueryCache.cs | 3 +- src/EFCore/Query/Internal/EntityQueryable`.cs | 2 +- ...nExpandingExpressionVisitor.Expressions.cs | 3 +- .../NavigationExpandingExpressionVisitor.cs | 10 +- .../NullCheckRemovingExpressionVisitor.cs | 2 +- .../ParameterExtractingExpressionVisitor.cs | 3 +- .../QueryCompilationContextFactory.cs | 2 +- ...yableMethodNormalizingExpressionVisitor.cs | 5 +- ...SubqueryMemberPushdownExpressionVisitor.cs | 2 +- src/EFCore/Query/ShapedQueryExpression.cs | 2 +- src/EFCore/Storage/CoreTypeMapping.cs | 2 +- src/EFCore/Storage/ExecutionStrategy.cs | 6 +- src/EFCore/Storage/TypeMappingInfo.cs | 2 +- src/EFCore/Storage/TypeMappingSource.cs | 3 +- src/EFCore/Storage/ValueBuffer.cs | 2 +- .../IPAddressToBytesConverter.cs | 3 +- .../HiLoValueGeneratorState.cs | 4 +- src/EFCore/ValueGeneration/ValueGenerator.cs | 2 +- .../ValueGeneration/ValueGeneratorCache.cs | 3 +- src/EFCore/ValueGeneration/ValueGenerator`.cs | 2 +- .../Extensions/SQLitePCLExtensions.cs | 2 +- .../SqliteCommand.cs | 4 +- .../SqliteConnection.cs | 6 +- .../SqliteFactory.cs | 2 +- .../SqliteParameterCollection.cs | 2 +- .../SqliteValueBinder.cs | 2 +- src/Shared/Multigraph.cs | 10 +- src/Shared/ReferenceEqualityComparer.cs | 2 +- src/Shared/SharedTypeExtensions.cs | 4 +- src/ef/AnsiConsole.cs | 2 +- ...spNetIdentityCustomTypesDefaultTestBase.cs | 14 +-- ...AspNetIdentityCustomTypesIntKeyTestBase.cs | 14 +-- .../AspNetIdentityDefaultTestBase.cs | 14 +-- .../AspNetIdentityIntKeyTestBase.cs | 14 +-- .../ConfigurationDbContextTestBase.cs | 42 +++---- .../PersistedGrantDbContextTestBase.cs | 4 +- .../BuiltInDataTypesCosmosTest.cs | 2 +- .../CosmosApiConsistencyTest.cs | 4 +- .../CustomConvertersCosmosTest.cs | 2 +- .../EmbeddedDocumentsTest.cs | 2 +- .../OptimisticConcurrencyCosmosTest.cs | 2 +- .../CosmosNorthwindTestStoreFactory.cs | 3 +- .../TestUtilities/CosmosTestHelpers.cs | 2 +- .../TestUtilities/CosmosTestStore.cs | 6 +- .../TestUtilities/CosmosTestStoreFactory.cs | 2 +- .../TestUtilities/TestSqlLoggerFactory.cs | 4 +- .../Metadata/CosmosMetadataExtensionsTest.cs | 2 +- .../Internal/IdValueGeneratorTest.cs | 6 +- .../CrossStoreFixture.cs | 2 +- .../Design/Internal/CSharpHelperTest.cs | 6 +- .../Internal/DbContextOperationsTest.cs | 10 +- .../DesignApiConsistencyTest.cs | 2 +- .../CSharpMigrationOperationGeneratorTest.cs | 18 +-- .../Design/SnapshotModelProcessorTest.cs | 4 +- .../Internal/CSharpDbContextGeneratorTest.cs | 4 +- .../ScaffoldingTypeMapperSqlServerTest.cs | 2 +- .../ScaffoldingTypeMapperSqliteTest.cs | 2 +- .../TestUtilities/BuildReference.cs | 2 +- .../TestUtilities/TestOperationReporter.cs | 2 +- .../BuiltInDataTypesInMemoryTest.cs | 2 +- .../ConvertToProviderTypesInMemoryTest.cs | 2 +- .../CustomConvertersInMemoryTest.cs | 2 +- .../DatabaseErrorLogStateTest.cs | 4 +- .../GlobalDatabaseTest.cs | 2 +- .../InMemoryApiConsistencyTest.cs | 2 +- .../Query/QueryBugsInMemoryTest.cs | 14 +-- .../TestUtilities/InMemoryTestHelpers.cs | 2 +- .../TestUtilities/InMemoryTestStore.cs | 4 +- .../TestUtilities/InMemoryTestStoreFactory.cs | 4 +- .../TestControllers.cs | 26 ++--- .../ChangeDetectionProxyTests.cs | 4 +- .../ProxiesApiConsistencyTest.cs | 2 +- test/EFCore.Proxies.Tests/ProxyTests.cs | 2 +- .../TestUtilities/TestContext.cs | 2 +- .../MigrationsInfrastructureTestBase.cs | 2 +- .../MigrationsSqlGeneratorTestBase.cs | 18 +-- .../Query/UdfDbFunctionTestBase.cs | 20 ++-- .../TestUtilities/TestSqlLoggerFactory.cs | 4 +- .../TransactionTestBase.cs | 4 +- .../Design/AnnotationCodeGeneratorTest.cs | 2 +- ...RelationalMetadataBuilderExtensionsTest.cs | 2 +- .../Internal/MigrationsModelDifferTest.cs | 2 +- .../MigrationCommandExecutorTest.cs | 26 ++--- .../Query/Internal/QuerySqlGeneratorTest.cs | 2 +- .../RelationalApiConsistencyTest.cs | 16 +-- .../RelationalEventIdTest.cs | 2 +- .../Storage/RawSqlCommandBuilderTest.cs | 2 +- .../Storage/RelationalCommandTest.cs | 2 +- .../FakeProvider/FakeDbConnection.cs | 4 +- .../FakeProvider/FakeDbParameterCollection.cs | 2 +- .../FakeProvider/FakeRelationalConnection.cs | 2 +- .../FakeRelationalDatabaseCreator.cs | 12 +- .../TestUtilities/RelationalTestHelpers.cs | 2 +- .../TestProviderCodeGenerator.cs | 2 +- .../ReaderModificationCommandBatchTest.cs | 14 +-- .../ApiConsistencyTestBase.cs | 28 ++--- .../ConferencePlannerTestBase.cs | 12 +- .../CustomConvertersTestBase.cs | 6 +- .../DataAnnotationTestBase.cs | 2 +- .../FieldMappingTestBase.cs | 10 +- .../GraphUpdates/GraphUpdatesTestBase.cs | 48 ++++---- .../GraphUpdatesTestBaseOneToMany.cs | 2 +- .../InterceptionTestBase.cs | 6 +- .../KeysWithConvertersTestBase.cs | 20 ++-- .../LazyLoadProxyTestBase.cs | 24 ++-- .../LoadTestBase.cs | 8 +- .../ManyToManyLoadTestBase.cs | 28 ++--- .../MusicStoreTestBase.cs | 2 +- .../NotificationEntitiesTestBase.cs | 2 +- .../OverzealousInitializationTestBase.cs | 2 +- .../PropertyValuesTestBase.cs | 16 +-- .../Query/GearsOfWarQueryFixtureBase.cs | 2 +- .../Query/InheritanceQueryFixtureBase.cs | 2 +- ...orthwindAggregateOperatorsQueryTestBase.cs | 14 +-- .../NorthwindChangeTrackingQueryTestBase.cs | 2 +- .../NorthwindNavigationsQueryTestBase.cs | 2 +- .../Query/NorthwindQueryFixtureBase.cs | 2 +- .../NorthwindStringIncludeQueryTestBase.cs | 3 +- .../Query/OwnedQueryTestBase.cs | 24 ++-- .../Query/QueryTestBase.cs | 2 +- .../SeedingTestBase.cs | 2 +- .../SpatialTestBase.cs | 4 +- .../StoreGeneratedFixupTestBase.cs | 8 +- .../ComplexNavigationsData.cs | 98 ++++++++-------- .../TestModels/ConcurrencyModel/F1Context.cs | 76 ++++++------ .../TestModels/ConcurrencyModel/Sponsor.cs | 2 +- .../TestModels/ConcurrencyModel/Team.cs | 2 +- .../ConferenceDTO/SessionResponse.cs | 2 +- .../ConferencePlanner/EntityExtensions.cs | 6 +- .../FunkyDataModel/FunkyDataData.cs | 38 +++--- .../GearsOfWarModel/GearsOfWarData.cs | 64 +++++----- .../InheritanceModel/InheritanceData.cs | 2 +- .../InheritanceRelationshipsData.cs | 110 +++++++++--------- .../ManyToManyModel/ProxyableSharedType.cs | 2 +- .../TestModels/MusicStore/ShoppingCart.cs | 2 +- .../QueryFilterFuncletizationContext.cs | 4 +- .../TransportationContext.cs | 2 +- .../TestUtilities/AnnotationComparer.cs | 2 +- .../TestUtilities/DataGenerator.cs | 6 +- .../TestUtilities/GeometryComparer.cs | 2 +- .../TestUtilities/ListLoggerFactory.cs | 4 +- .../TestUtilities/QueryAsserter.cs | 2 +- ...ppendIncludeToExistingExpressionMutator.cs | 2 +- .../AppendSelectConstantExpressionMutator.cs | 2 +- .../InjectCoalesceExpressionMutator.cs | 4 +- .../InjectIncludeExpressionMutator.cs | 4 +- .../InjectJoinWithSelfExpressionMutator.cs | 2 +- .../InjectOrderByPropertyExpressionMutator.cs | 2 +- .../InjectStringFunctionExpressionMutator.cs | 4 +- .../InjectThenByPropertyExpressionMutator.cs | 2 +- .../InjectWhereExpressionMutator.cs | 2 +- .../ProceduralQueryExpressionGenerator.cs | 2 +- .../StringConcatWithSelfExpressionMutator.cs | 4 +- .../TestUtilities/TestHelpers.cs | 18 +-- .../TestUtilities/TestServiceFactory.cs | 5 +- .../TestUtilities/TestStore.cs | 6 +- .../TestUtilities/TestStoreIndex.cs | 9 +- .../TestUtilities/WKTComparer.cs | 4 +- .../Xunit/PlatformSkipConditionAttribute.cs | 2 +- .../Xunit/XunitTestCaseExtensions.cs | 7 +- .../BuiltInDataTypesSqlServerTest.cs | 30 ++--- .../ConnectionInterceptionSqlServerTest.cs | 2 +- .../ConvertToProviderTypesSqlServerTest.cs | 2 +- .../CustomConvertersSqlServerTest.cs | 2 +- .../DbContextPoolingTest.cs | 2 +- .../EverythingIsBytesSqlServerTest.cs | 16 +-- .../EverythingIsStringsSqlServerTest.cs | 20 +--- .../MemoryOptimizedTablesTest.cs | 2 +- .../NavigationTest.cs | 2 +- .../Query/QueryBugsTest.cs | 10 +- .../SpatialQuerySqlServerGeographyFixture.cs | 2 +- .../SqlServerApiConsistencyTest.cs | 5 +- .../SqlServerValueGenerationScenariosTest.cs | 4 +- ...SqlServerAdventureWorksTestStoreFactory.cs | 2 +- .../SqlServerConfiguredConditionAttribute.cs | 3 +- .../SqlServerNorthwindTestStoreFactory.cs | 2 +- .../TestUtilities/SqlServerTestHelpers.cs | 2 +- .../TestUtilities/SqlServerTestStore.cs | 6 +- .../SqlServerTestStoreFactory.cs | 2 +- .../TestRelationalCommandBuilderFactory.cs | 10 +- .../TestUtilities/TestSqlServerConnection.cs | 6 +- .../TwoDatabasesSqlServerTest.cs | 2 +- .../UpdatesSqlServerTest.cs | 2 +- .../SqlServerAnnotationCodeGeneratorTest.cs | 2 +- .../SqlServerDatabaseCreatorTest.cs | 4 +- .../SqlServerNTSApiConsistencyTest.cs | 2 +- .../SqlServerSequenceValueGeneratorTest.cs | 4 +- .../BuiltInDataTypesSqliteTest.cs | 18 +-- .../ConnectionInterceptionSqliteTest.cs | 2 +- .../ConvertToProviderTypesSqliteTest.cs | 2 +- .../CustomConvertersSqliteTest.cs | 2 +- .../SqliteApiConsistencyTest.cs | 2 +- .../SqliteDatabaseCreatorTest.cs | 2 +- .../PrivateCacheSqliteTestStoreFactory.cs | 2 +- .../SpatialiteRequiredAttribute.cs | 4 +- .../SqliteNorthwindTestStoreFactory.cs | 2 +- .../TestUtilities/SqliteTestHelpers.cs | 2 +- .../TestUtilities/SqliteTestStore.cs | 6 +- .../TestUtilities/SqliteTestStoreFactory.cs | 2 +- .../TwoDatabasesSqliteTest.cs | 2 +- .../SqliteMigrationAnnotationProviderTest.cs | 2 +- .../SqliteNTSApiConsistencyTest.cs | 2 +- test/EFCore.Tests/ApiConsistencyTest.cs | 12 +- .../ChangeTracking/ChangeTrackerTest.cs | 19 ++- .../Internal/CurrentValueComparerTest.cs | 24 ++-- .../Internal/FixupCompositeTest.cs | 4 +- .../ChangeTracking/Internal/FixupTest.cs | 4 +- .../InternalEntryEntrySubscriberTest.cs | 8 +- .../Internal/NavigationFixerTest.cs | 2 +- .../ObservableBackedBindingListTest.cs | 2 +- .../ObservableCollectionListSourceTest.cs | 4 +- .../Internal/SortableBindingListTest.cs | 14 +-- .../ChangeTracking/ObservableHashSetTest.cs | 2 +- .../ChangeTracking/TrackGraphTestBase.cs | 60 +++++----- test/EFCore.Tests/DbContextFactoryTest.cs | 2 +- test/EFCore.Tests/DbContextServicesTest.cs | 2 +- test/EFCore.Tests/DbContextTest.cs | 16 +-- test/EFCore.Tests/ExceptionTest.cs | 2 +- .../EntityFrameworkServicesBuilderTest.cs | 2 +- .../InternalServiceCollectionMapTest.cs | 4 +- .../Infrastructure/ModelValidatorTest.cs | 2 +- .../Conventions/ConventionDispatcherTest.cs | 68 +++++------ ...reignKeyPropertyDiscoveryConventionTest.cs | 2 +- .../IndexAttributeConventionTest.cs | 2 +- .../Conventions/KeyDiscoveryConventionTest.cs | 4 +- .../ManyToManyJoinEntityTypeConventionTest.cs | 4 +- .../NavigationAttributeConventionTest.cs | 2 +- .../NonNullableNavigationConventionTest.cs | 4 +- .../RelationshipDiscoveryConventionTest.cs | 4 +- .../ClrCollectionAccessorFactoryTest.cs | 2 +- .../Internal/ClrPropertyGetterFactoryTest.cs | 2 +- .../Internal/ClrPropertySetterFactoryTest.cs | 2 +- .../Internal/EntityMaterializerSourceTest.cs | 4 +- .../Internal/InternalEntityTypeBuilderTest.cs | 2 +- .../Internal/InternalForeignKeyBuilderTest.cs | 2 +- .../Internal/InternalModelBuilderTest.cs | 2 +- .../Internal/PropertyAccessorsFactoryTest.cs | 2 +- .../ModelBuilding/ManyToOneTestBase.cs | 2 +- .../ModelBuilding/ModelBuilderGenericTest.cs | 8 +- .../ModelBuilderNonGenericStringTest.cs | 5 +- .../ModelBuilderNonGenericTest.cs | 8 +- .../ModelBuilding/NonRelationshipTestBase.cs | 2 +- .../ModelBuilding/OwnedTypesTestBase.cs | 2 +- test/EFCore.Tests/ModelBuilding/TestModel.cs | 10 +- test/EFCore.Tests/ModelSourceTest.cs | 10 +- .../Query/ExpressionPrinterTest.cs | 2 +- .../Storage/BoolToStringConverterTest.cs | 4 +- .../Storage/BoolToZeroOneConverterTest.cs | 3 +- .../Storage/BytesToStringConverterTest.cs | 3 +- .../Storage/CharToStringConverterTest.cs | 3 +- .../Storage/DateTimeConvertersTest.cs | 9 +- .../Storage/DateTimeOffsetConvertersTest.cs | 9 +- .../Storage/ExecutionStrategyTest.cs | 2 +- .../Storage/GuidToBytesConverterTest.cs | 3 +- .../Storage/GuidToStringConverterTest.cs | 3 +- .../Storage/IPAddressToBytesConverterTest.cs | 3 +- .../Storage/IPAddressToStringConverterTest.cs | 2 +- .../Storage/NumberToBytesConverterTest.cs | 51 +++----- .../Storage/NumberToStringConverterTest.cs | 36 ++---- .../PhysicalAddressToBytesConverterTest.cs | 3 +- .../PhysicalAddressToStringConverterTest.cs | 3 +- .../Storage/StringToBoolConverterTest.cs | 3 +- .../Storage/StringToBytesConverterTest.cs | 3 +- .../Storage/StringToCharConverterTest.cs | 3 +- .../Storage/StringToDateTimeConverterTest.cs | 3 +- .../StringToDateTimeOffsetConverterTest.cs | 3 +- .../Storage/StringToGuidConverterTest.cs | 3 +- .../Storage/StringToNumberConverterTest.cs | 36 ++---- .../Storage/StringToTimeSpanConverterTest.cs | 3 +- .../Storage/StringToUriConverterTest.cs | 3 +- .../Storage/TimeSpanConvertersTest.cs | 6 +- .../Storage/ValueConverterTest.cs | 4 +- .../TestUtilities/FakeStateManager.cs | 4 +- .../TestUtilities/MockAssembly.cs | 2 +- .../SqliteBlobTest.cs | 2 +- 465 files changed, 1366 insertions(+), 1522 deletions(-) diff --git a/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs b/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs index 3ece2c37c2f..f5b5479f441 100644 --- a/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs +++ b/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs @@ -27,7 +27,7 @@ public const string MessageFormat private static readonly int EFLen = "EntityFrameworkCore".Length; private static readonly DiagnosticDescriptor _descriptor - = new DiagnosticDescriptor( + = new( Id, title: DefaultTitle, messageFormat: MessageFormat, diff --git a/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs b/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs index 54eaf77798c..3c3285225bc 100644 --- a/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs +++ b/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs @@ -43,7 +43,7 @@ private enum Id /// /// public static readonly EventId ExecutingSqlQuery - = new EventId((int)Id.ExecutingSqlQuery, _commandPrefix + Id.ExecutingSqlQuery); + = new((int)Id.ExecutingSqlQuery, _commandPrefix + Id.ExecutingSqlQuery); /// /// @@ -54,6 +54,6 @@ public static readonly EventId ExecutingSqlQuery /// /// public static readonly EventId ExecutingReadItem - = new EventId((int)Id.ExecutingReadItem, _commandPrefix + Id.ExecutingReadItem); + = new((int)Id.ExecutingReadItem, _commandPrefix + Id.ExecutingReadItem); } } diff --git a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs index 05a95eebf07..b9c896fef08 100644 --- a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs +++ b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs @@ -496,7 +496,7 @@ public virtual CosmosOptionsExtension WithExecutionStrategyFactory( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual CosmosOptionsExtension Clone() - => new CosmosOptionsExtension(this); + => new(this); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs b/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs index 8cc45199323..21ddaa19197 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs @@ -21,8 +21,8 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal /// public class CosmosMemberTranslatorProvider : IMemberTranslatorProvider { - private readonly List _plugins = new List(); - private readonly List _translators = new List(); + private readonly List _plugins = new(); + private readonly List _translators = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs b/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs index d30e1128f69..7f987f81e4d 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs @@ -21,8 +21,8 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal /// public class CosmosMethodCallTranslatorProvider : IMethodCallTranslatorProvider { - private readonly List _plugins = new List(); - private readonly List _translators = new List(); + private readonly List _plugins = new(); + private readonly List _translators = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs index 215634b9061..383281a2f1f 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs @@ -38,13 +38,13 @@ private static readonly MethodInfo _getParameterValueMethodInfo private readonly IDictionary _projectionMapping = new Dictionary(); - private readonly Stack _projectionMembers = new Stack(); + private readonly Stack _projectionMembers = new(); private readonly IDictionary _collectionShaperMapping = new Dictionary(); private readonly Stack _includedNavigations - = new Stack(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs index 4f82ac800b9..52c940ede16 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs @@ -249,7 +249,7 @@ protected override ShapedQueryExpression CreateShapedQueryExpression(IEntityType } private ShapedQueryExpression CreateShapedQueryExpression(Expression queryExpression, IEntityType entityType) - => new ShapedQueryExpression( + => new( queryExpression, new EntityShaperExpression( entityType, diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs index ff784e3d7d4..06eb627c3eb 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs @@ -62,7 +62,7 @@ private readonly IDictionary _ordinalParameterBindings = new Dictionary(); private List _pendingIncludes - = new List(); + = new(); private static readonly MethodInfo _toObjectMethodInfo = typeof(CosmosProjectionBindingRemovingExpressionVisitorBase) diff --git a/src/EFCore.Cosmos/Query/Internal/InExpression.cs b/src/EFCore.Cosmos/Query/Internal/InExpression.cs index f5989440248..12d93ddd85c 100644 --- a/src/EFCore.Cosmos/Query/Internal/InExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/InExpression.cs @@ -83,7 +83,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InExpression Negate() - => new InExpression(Item, !IsNegated, Values, TypeMapping!); + => new(Item, !IsNegated, Values, TypeMapping!); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs b/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs index 6d3ef445c6b..0b78961d59e 100644 --- a/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs +++ b/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs @@ -24,7 +24,7 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal /// public class QuerySqlGenerator : SqlExpressionVisitor { - private readonly StringBuilder _sqlBuilder = new StringBuilder(); + private readonly StringBuilder _sqlBuilder = new(); private IReadOnlyDictionary _parameterValues; private List _sqlParameters; private bool _useValueProjection; diff --git a/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs b/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs index 0dd00893e0e..8f30a6fb0da 100644 --- a/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs @@ -20,6 +20,6 @@ public class QuerySqlGeneratorFactory : IQuerySqlGeneratorFactory /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual QuerySqlGenerator Create() - => new QuerySqlGenerator(); + => new(); } } diff --git a/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs b/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs index d0faf8783cd..a1893b654f0 100644 --- a/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs @@ -25,8 +25,8 @@ public class SelectExpression : Expression private const string RootAlias = "c"; private IDictionary _projectionMapping = new Dictionary(); - private readonly List _projection = new List(); - private readonly List _orderings = new List(); + private readonly List _projection = new(); + private readonly List _orderings = new(); private ValueConverter _partitionKeyValueConverter; private Expression _partitionKeyValue; diff --git a/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs b/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs index ebc047a9239..c1faef078ea 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs @@ -509,7 +509,7 @@ public virtual InExpression In(SqlExpression item, SqlExpression values, bool ne /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlConstantExpression Constant(object value, CoreTypeMapping typeMapping = null) - => new SqlConstantExpression(Expression.Constant(value), typeMapping); + => new(Expression.Constant(value), typeMapping); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs index 93bccd2ffff..97c681712a6 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs @@ -89,11 +89,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlFunctionExpression ApplyTypeMapping([CanBeNull] CoreTypeMapping? typeMapping) - => new SqlFunctionExpression( - Name, - Arguments, - Type, - typeMapping ?? TypeMapping); + => new(Name, Arguments, Type, typeMapping ?? TypeMapping); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyToken.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyToken.cs index e85762cd256..b9d05e5d050 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyToken.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyToken.cs @@ -25,7 +25,7 @@ private CosmosConcurrencyToken(string value, CosmosConcurrencyMode mode) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static CosmosConcurrencyToken None { get; } = new CosmosConcurrencyToken(null, CosmosConcurrencyMode.None); + public static CosmosConcurrencyToken None { get; } = new(null, CosmosConcurrencyMode.None); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -50,7 +50,7 @@ private CosmosConcurrencyToken(string value, CosmosConcurrencyMode mode) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static CosmosConcurrencyToken IfMatch([CanBeNull] string value) - => new CosmosConcurrencyToken(value, CosmosConcurrencyMode.IfMatch); + => new(value, CosmosConcurrencyMode.IfMatch); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -59,6 +59,6 @@ public static CosmosConcurrencyToken IfMatch([CanBeNull] string value) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static CosmosConcurrencyToken IfNotMatch([CanBeNull] string value) - => new CosmosConcurrencyToken(value, CosmosConcurrencyMode.IfNoneMatch); + => new(value, CosmosConcurrencyMode.IfNoneMatch); } } diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs index 17ce96528d6..7de5931edc5 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs @@ -510,7 +510,7 @@ private void GenerateComment(string comment) private sealed class AttributeWriter { private readonly string _attributeName; - private readonly List _parameters = new List(); + private readonly List _parameters = new(); public AttributeWriter([NotNull] string attributeName) { diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs index c484a36f7ca..da894b257b1 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs @@ -26,7 +26,7 @@ public class CSharpNamer /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - protected readonly Dictionary NameCache = new Dictionary(); + protected readonly Dictionary NameCache = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpUniqueNamer.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpUniqueNamer.cs index b05c7a2d1d0..525f7eb4d33 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpUniqueNamer.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpUniqueNamer.cs @@ -15,7 +15,7 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal /// public class CSharpUniqueNamer : CSharpNamer { - private readonly HashSet _usedNames = new HashSet(StringComparer.OrdinalIgnoreCase); + private readonly HashSet _usedNames = new(StringComparer.OrdinalIgnoreCase); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs index d662b5789b7..35f6561666a 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs @@ -18,7 +18,7 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal /// public class CSharpUtilities : ICSharpUtilities { - private static readonly HashSet _cSharpKeywords = new HashSet + private static readonly HashSet _cSharpKeywords = new() { "abstract", "as", @@ -100,7 +100,7 @@ public class CSharpUtilities : ICSharpUtilities }; private static readonly Regex _invalidCharsRegex - = new Regex( + = new( @"[^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Nl}\p{Mn}\p{Mc}\p{Cf}\p{Pc}\p{Lm}]", default, TimeSpan.FromMilliseconds(1000.0)); diff --git a/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs b/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs index 63276031ba1..aeb096c05e1 100644 --- a/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs +++ b/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs @@ -36,10 +36,10 @@ public class RelationalScaffoldingModelFactory : IScaffoldingModelFactory private readonly ICandidateNamingService _candidateNamingService; private Dictionary> _columnNamers; private ModelReverseEngineerOptions _options; - private readonly DatabaseTable _nullTable = new DatabaseTable(); + private readonly DatabaseTable _nullTable = new(); private CSharpUniqueNamer _tableNamer; private CSharpUniqueNamer _dbSetNamer; - private readonly HashSet _unmappedColumns = new HashSet(); + private readonly HashSet _unmappedColumns = new(); private readonly IPluralizer _pluralizer; private readonly ICSharpUtilities _cSharpUtilities; private readonly IScaffoldingTypeMapper _scaffoldingTypeMapper; @@ -929,7 +929,7 @@ protected virtual void AddNavigationProperties([NotNull] IMutableForeignKey fore // Stores the names of the EntityType itself and its Properties, but does not include any Navigation Properties private readonly Dictionary> _entityTypeAndPropertyIdentifiers = - new Dictionary>(); + new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs b/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs index 376e0d32704..efe7b10f9c7 100644 --- a/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs +++ b/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs @@ -33,7 +33,7 @@ private enum Id private static readonly string _transactionPrefix = DbLoggerCategory.Database.Transaction.Name + "."; private static EventId MakeTransactionId(Id id) - => new EventId((int)id, _transactionPrefix + id); + => new((int)id, _transactionPrefix + id); /// /// @@ -51,7 +51,7 @@ private static EventId MakeTransactionId(Id id) private static readonly string _updatePrefix = DbLoggerCategory.Update.Name + "."; private static EventId MakeUpdateId(Id id) - => new EventId((int)id, _updatePrefix + id); + => new((int)id, _updatePrefix + id); /// /// diff --git a/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs b/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs index bbab0b73fa8..e7c6b9dcd14 100644 --- a/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs +++ b/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs @@ -62,7 +62,7 @@ public virtual DbContextOptionsExtensionInfo Info /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual InMemoryOptionsExtension Clone() - => new InMemoryOptionsExtension(this); + => new(this); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs index 518146a309e..74611da58be 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs @@ -35,7 +35,7 @@ public class InMemoryProjectionBindingExpressionVisitor : ExpressionVisitor private readonly IDictionary _projectionMapping = new Dictionary(); - private readonly Stack _projectionMembers = new Stack(); + private readonly Stack _projectionMembers = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -502,7 +502,7 @@ private CollectionShaperExpression AddCollectionProjection( ShapedQueryExpression subquery, INavigationBase? navigation, Type elementType) - => new CollectionShaperExpression( + => new( new ProjectionBindingExpression( _queryExpression, _queryExpression.AddSubqueryProjection( diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs b/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs index 5135d2411a1..0ba21736128 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs @@ -35,7 +35,7 @@ private static readonly ConstructorInfo _valueBufferConstructor private static readonly PropertyInfo _valueBufferCountMemberInfo = typeof(ValueBuffer).GetRequiredProperty(nameof(ValueBuffer.Count)); - private readonly List _valueBufferSlots = new List(); + private readonly List _valueBufferSlots = new(); private readonly IDictionary> _entityProjectionCache = new Dictionary>(); diff --git a/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs index 822294fa19a..ecf886590f6 100644 --- a/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs @@ -23,8 +23,8 @@ public class ShaperExpressionProcessingExpressionVisitor : ExpressionVisitor private readonly ParameterExpression _valueBufferParameter; private readonly IDictionary _mapping = new Dictionary(); - private readonly List _variables = new List(); - private readonly List _expressions = new List(); + private readonly List _variables = new(); + private readonly List _expressions = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs index bb080437f13..d8e180b338a 100644 --- a/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs +++ b/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs @@ -24,7 +24,7 @@ public class InMemoryStore : IInMemoryStore private readonly IInMemoryTableFactory _tableFactory; private readonly bool _useNameMatching; - private readonly object _lock = new object(); + private readonly object _lock = new(); private Dictionary _tables; @@ -120,7 +120,7 @@ public virtual bool Clear() } private static Dictionary CreateTables() - => new Dictionary(); + => new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs index 2eb055a56c6..ceee6ddeb24 100644 --- a/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs +++ b/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs @@ -26,7 +26,7 @@ public class InMemoryTableFactory : IInMemoryTableFactory private readonly bool _nullabilityCheckEnabled; private readonly ConcurrentDictionary<(IEntityType EntityType, IInMemoryTable BaseTable), Func> _factories - = new ConcurrentDictionary<(IEntityType, IInMemoryTable), Func>(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs index c44a52932b1..0f2cc1fab69 100644 --- a/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs +++ b/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs @@ -29,7 +29,7 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Storage.Internal /// public class InMemoryTransactionManager : IDbContextTransactionManager, ITransactionEnlistmentManager { - private static readonly InMemoryTransaction _stubTransaction = new InMemoryTransaction(); + private static readonly InMemoryTransaction _stubTransaction = new(); private readonly IDiagnosticsLogger _logger; diff --git a/src/EFCore.Proxies/Proxies/Internal/ProxiesOptionsExtension.cs b/src/EFCore.Proxies/Proxies/Internal/ProxiesOptionsExtension.cs index a3a86a54599..35d3a6c9f06 100644 --- a/src/EFCore.Proxies/Proxies/Internal/ProxiesOptionsExtension.cs +++ b/src/EFCore.Proxies/Proxies/Internal/ProxiesOptionsExtension.cs @@ -65,7 +65,7 @@ public virtual DbContextOptionsExtensionInfo Info /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual ProxiesOptionsExtension Clone() - => new ProxiesOptionsExtension(this); + => new(this); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs b/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs index aae68a69ba8..a962a1a0492 100644 --- a/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs +++ b/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs @@ -25,7 +25,7 @@ public class ProxyFactory : IProxyFactory private static readonly Type _notifyPropertyChangedInterface = typeof(INotifyPropertyChanged); private static readonly Type _notifyPropertyChangingInterface = typeof(INotifyPropertyChanging); - private readonly ProxyGenerator _generator = new ProxyGenerator(); + private readonly ProxyGenerator _generator = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Design/MethodCallCodeFragment.cs b/src/EFCore.Relational/Design/MethodCallCodeFragment.cs index 3060783f61a..5573850a7f7 100644 --- a/src/EFCore.Relational/Design/MethodCallCodeFragment.cs +++ b/src/EFCore.Relational/Design/MethodCallCodeFragment.cs @@ -79,9 +79,6 @@ public virtual MethodCallCodeFragment Chain([NotNull] string method, [NotNull] p /// The next method. /// A new fragment representing the method chain. public virtual MethodCallCodeFragment Chain([NotNull] MethodCallCodeFragment call) - => new MethodCallCodeFragment( - Method, - _arguments.ToArray(), - ChainedCall?.Chain(call) ?? call); + => new(Method, _arguments.ToArray(), ChainedCall?.Chain(call) ?? call); } } diff --git a/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs b/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs index 5308b31b925..7003b93541a 100644 --- a/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs +++ b/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs @@ -158,7 +158,7 @@ public virtual ValueTask> ReaderExecutingAsync( CommandEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask>(result); + => new(result); /// /// Called just before EF intends to call . @@ -185,7 +185,7 @@ public virtual ValueTask> ScalarExecutingAsync( CommandEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask>(result); + => new(result); /// /// Called just before EF intends to call . @@ -212,7 +212,7 @@ public virtual ValueTask> NonQueryExecutingAsync( CommandEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask>(result); + => new(result); /// /// @@ -319,7 +319,7 @@ public virtual ValueTask ReaderExecutedAsync( CommandExecutedEventData eventData, DbDataReader result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// /// @@ -348,7 +348,7 @@ public virtual ValueTask ScalarExecutedAsync( CommandExecutedEventData eventData, object result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// /// @@ -377,7 +377,7 @@ public virtual ValueTask NonQueryExecutedAsync( CommandExecutedEventData eventData, int result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// /// Called when execution of a command has failed with an exception. diff --git a/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs b/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs index 719b95ac2be..dac80201213 100644 --- a/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs +++ b/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs @@ -65,7 +65,7 @@ public virtual ValueTask ConnectionOpeningAsync( ConnectionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// /// Called just after EF has called . @@ -136,7 +136,7 @@ public virtual ValueTask ConnectionClosingAsync( DbConnection connection, ConnectionEventData eventData, InterceptionResult result) - => new ValueTask(result); + => new(result); /// /// Called just after EF has called in an async context. diff --git a/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs b/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs index 03fa13b2fd3..654a23fd94a 100644 --- a/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs +++ b/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs @@ -93,7 +93,7 @@ public virtual ValueTask> TransactionStartingA TransactionStartingEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask>(result); + => new(result); /// /// @@ -125,7 +125,7 @@ public virtual ValueTask TransactionStartedAsync( TransactionEndEventData eventData, DbTransaction result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// /// @@ -173,7 +173,7 @@ public virtual ValueTask TransactionUsedAsync( TransactionEventData eventData, DbTransaction result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// /// Called just before EF intends to call . @@ -236,7 +236,7 @@ public virtual ValueTask TransactionCommittingAsync( TransactionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// /// Called immediately after EF calls . @@ -313,7 +313,7 @@ public virtual ValueTask TransactionRollingBackAsync( TransactionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// /// Called immediately after EF calls . @@ -349,7 +349,7 @@ public virtual ValueTask CreatingSavepointAsync( TransactionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// public virtual Task CreatedSavepointAsync( @@ -378,7 +378,7 @@ public virtual ValueTask RollingBackToSavepointAsync( TransactionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// public virtual Task RolledBackToSavepointAsync( @@ -407,7 +407,7 @@ public virtual ValueTask ReleasingSavepointAsync( TransactionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// public virtual Task ReleasedSavepointAsync( diff --git a/src/EFCore.Relational/Diagnostics/RelationalEventId.cs b/src/EFCore.Relational/Diagnostics/RelationalEventId.cs index 6c5d41210fb..e9bf0ceb6ff 100644 --- a/src/EFCore.Relational/Diagnostics/RelationalEventId.cs +++ b/src/EFCore.Relational/Diagnostics/RelationalEventId.cs @@ -98,7 +98,7 @@ private enum Id private static readonly string _connectionPrefix = DbLoggerCategory.Database.Connection.Name + "."; private static EventId MakeConnectionId(Id id) - => new EventId((int)id, _connectionPrefix + id); + => new((int)id, _connectionPrefix + id); /// /// @@ -168,7 +168,7 @@ private static EventId MakeConnectionId(Id id) private static readonly string _sqlPrefix = DbLoggerCategory.Database.Command.Name + "."; private static EventId MakeCommandId(Id id) - => new EventId((int)id, _sqlPrefix + id); + => new((int)id, _sqlPrefix + id); /// /// @@ -238,7 +238,7 @@ private static EventId MakeCommandId(Id id) private static readonly string _transactionPrefix = DbLoggerCategory.Database.Transaction.Name + "."; private static EventId MakeTransactionId(Id id) - => new EventId((int)id, _transactionPrefix + id); + => new((int)id, _transactionPrefix + id); /// /// @@ -490,7 +490,7 @@ private static EventId MakeTransactionId(Id id) private static readonly string _migrationsPrefix = DbLoggerCategory.Migrations.Name + "."; private static EventId MakeMigrationsId(Id id) - => new EventId((int)id, _migrationsPrefix + id); + => new((int)id, _migrationsPrefix + id); /// /// @@ -599,7 +599,7 @@ private static EventId MakeMigrationsId(Id id) private static readonly string _queryPrefix = DbLoggerCategory.Query.Name + "."; private static EventId MakeQueryId(Id id) - => new EventId((int)id, _queryPrefix + id); + => new((int)id, _queryPrefix + id); /// /// @@ -640,7 +640,7 @@ private static EventId MakeQueryId(Id id) private static readonly string _validationPrefix = DbLoggerCategory.Model.Validation.Name + "."; private static EventId MakeValidationId(Id id) - => new EventId((int)id, _validationPrefix + id); + => new((int)id, _validationPrefix + id); /// /// @@ -726,7 +726,7 @@ private static EventId MakeValidationId(Id id) private static readonly string _updatePrefix = DbLoggerCategory.Update.Name + "."; private static EventId MakeUpdateId(Id id) - => new EventId((int)id, _updatePrefix + id); + => new((int)id, _updatePrefix + id); /// /// diff --git a/src/EFCore.Relational/Extensions/RelationalModelBuilderExtensions.cs b/src/EFCore.Relational/Extensions/RelationalModelBuilderExtensions.cs index a781fe2b9ee..72f8fa66938 100644 --- a/src/EFCore.Relational/Extensions/RelationalModelBuilderExtensions.cs +++ b/src/EFCore.Relational/Extensions/RelationalModelBuilderExtensions.cs @@ -30,7 +30,7 @@ public static SequenceBuilder HasSequence( [NotNull] this ModelBuilder modelBuilder, [NotNull] string name, [CanBeNull] string schema = null) - => new SequenceBuilder( + => new( HasSequence( Check.NotNull(modelBuilder, nameof(modelBuilder)).Model, name, diff --git a/src/EFCore.Relational/Metadata/Builders/DbFunctionBuilderBase.cs b/src/EFCore.Relational/Metadata/Builders/DbFunctionBuilderBase.cs index 550088a0b64..e9527f38c42 100644 --- a/src/EFCore.Relational/Metadata/Builders/DbFunctionBuilderBase.cs +++ b/src/EFCore.Relational/Metadata/Builders/DbFunctionBuilderBase.cs @@ -94,7 +94,7 @@ public virtual DbFunctionBuilderBase IsBuiltIn(bool builtIn = true) /// The parameter name. /// The builder to use for further parameter configuration. public virtual DbFunctionParameterBuilder HasParameter([NotNull] string name) - => new DbFunctionParameterBuilder(Builder.HasParameter(name, ConfigurationSource.Explicit).Metadata); + => new(Builder.HasParameter(name, ConfigurationSource.Explicit).Metadata); #region Hidden System.Object members diff --git a/src/EFCore.Relational/Metadata/Internal/ColumnBase.cs b/src/EFCore.Relational/Metadata/Internal/ColumnBase.cs index b2d8a174fc8..2d259fa85f8 100644 --- a/src/EFCore.Relational/Metadata/Internal/ColumnBase.cs +++ b/src/EFCore.Relational/Metadata/Internal/ColumnBase.cs @@ -51,7 +51,7 @@ public ColumnBase([NotNull] string name, [NotNull] string type, [NotNull] TableB /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedSet PropertyMappings { get; } - = new SortedSet(ColumnMappingBaseComparer.Instance); + = new(ColumnMappingBaseComparer.Instance); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Metadata/Internal/ColumnListComparer.cs b/src/EFCore.Relational/Metadata/Internal/ColumnListComparer.cs index 6f40d4c3c90..cc69e088f7a 100644 --- a/src/EFCore.Relational/Metadata/Internal/ColumnListComparer.cs +++ b/src/EFCore.Relational/Metadata/Internal/ColumnListComparer.cs @@ -23,7 +23,7 @@ public sealed class ColumnListComparer : IComparer>, IEqu /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static readonly ColumnListComparer Instance = new ColumnListComparer(); + public static readonly ColumnListComparer Instance = new(); private ColumnListComparer() { diff --git a/src/EFCore.Relational/Metadata/Internal/ColumnMappingBaseComparer.cs b/src/EFCore.Relational/Metadata/Internal/ColumnMappingBaseComparer.cs index a88e0c7365b..5548a99064c 100644 --- a/src/EFCore.Relational/Metadata/Internal/ColumnMappingBaseComparer.cs +++ b/src/EFCore.Relational/Metadata/Internal/ColumnMappingBaseComparer.cs @@ -26,7 +26,7 @@ private ColumnMappingBaseComparer() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static readonly ColumnMappingBaseComparer Instance = new ColumnMappingBaseComparer(); + public static readonly ColumnMappingBaseComparer Instance = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs b/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs index c1e91a86391..c8a2979833d 100644 --- a/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs +++ b/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs @@ -49,7 +49,7 @@ public ForeignKeyConstraint( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual SortedSet MappedForeignKeys { get; } = new SortedSet(ForeignKeyComparer.Instance); + public virtual SortedSet MappedForeignKeys { get; } = new(ForeignKeyComparer.Instance); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraintComparer.cs b/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraintComparer.cs index ce4c6c3d82b..598e0cfedd2 100644 --- a/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraintComparer.cs +++ b/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraintComparer.cs @@ -27,7 +27,7 @@ private ForeignKeyConstraintComparer() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static readonly ForeignKeyConstraintComparer Instance = new ForeignKeyConstraintComparer(); + public static readonly ForeignKeyConstraintComparer Instance = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Metadata/Internal/NamedListComparer.cs b/src/EFCore.Relational/Metadata/Internal/NamedListComparer.cs index a6ceb958375..40f7c5edf88 100644 --- a/src/EFCore.Relational/Metadata/Internal/NamedListComparer.cs +++ b/src/EFCore.Relational/Metadata/Internal/NamedListComparer.cs @@ -24,7 +24,7 @@ public sealed class NamedListComparer : IComparer<(string, string?, IReadOnlyLis /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static readonly NamedListComparer Instance = new NamedListComparer(); + public static readonly NamedListComparer Instance = new(); private NamedListComparer() { diff --git a/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs b/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs index 3f512964b20..e7936e59292 100644 --- a/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs +++ b/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs @@ -43,7 +43,7 @@ public RelationalModel([NotNull] IModel model) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedDictionary DefaultTables { get; } - = new SortedDictionary(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -52,7 +52,7 @@ public RelationalModel([NotNull] IModel model) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedDictionary<(string, string?), Table> Tables { get; } - = new SortedDictionary<(string, string?), Table>(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -61,7 +61,7 @@ public RelationalModel([NotNull] IModel model) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedDictionary<(string, string?), View> Views { get; } - = new SortedDictionary<(string, string?), View>(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -70,7 +70,7 @@ public RelationalModel([NotNull] IModel model) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedDictionary Queries { get; } - = new SortedDictionary(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -79,7 +79,7 @@ public RelationalModel([NotNull] IModel model) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedDictionary<(string, string?, IReadOnlyList), StoreFunction> Functions { get; } - = new SortedDictionary<(string, string?, IReadOnlyList), StoreFunction>(NamedListComparer.Instance); + = new(NamedListComparer.Instance); /// public virtual ITable? FindTable(string name, string? schema) @@ -1139,7 +1139,7 @@ public static ReferentialAction ToReferentialAction(DeleteBehavior deleteBehavio /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault), () => this.ToDebugString(MetadataDebugStringOptions.LongDefault)); diff --git a/src/EFCore.Relational/Metadata/Internal/Table.cs b/src/EFCore.Relational/Metadata/Internal/Table.cs index fa984e07178..edc34402d57 100644 --- a/src/EFCore.Relational/Metadata/Internal/Table.cs +++ b/src/EFCore.Relational/Metadata/Internal/Table.cs @@ -41,7 +41,7 @@ public Table([NotNull] string name, [CanBeNull] string? schema, [NotNull] Relati /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedDictionary ForeignKeyConstraints { get; } - = new SortedDictionary(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -99,7 +99,7 @@ public virtual UniqueConstraint? PrimaryKey /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedDictionary UniqueConstraints { get; } - = new SortedDictionary(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -121,7 +121,7 @@ public virtual UniqueConstraint? PrimaryKey /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedDictionary Indexes { get; } - = new SortedDictionary(); + = new(); /// public virtual bool IsExcludedFromMigrations { get; set; } diff --git a/src/EFCore.Relational/Metadata/Internal/TableBase.cs b/src/EFCore.Relational/Metadata/Internal/TableBase.cs index cb62f905fdf..67aa1f3d86b 100644 --- a/src/EFCore.Relational/Metadata/Internal/TableBase.cs +++ b/src/EFCore.Relational/Metadata/Internal/TableBase.cs @@ -57,7 +57,7 @@ public TableBase([NotNull] string name, [CanBeNull] string? schema, [NotNull] Re /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedSet EntityTypeMappings { get; } - = new SortedSet(TableMappingBaseComparer.Instance); + = new(TableMappingBaseComparer.Instance); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -66,7 +66,7 @@ public TableBase([NotNull] string name, [CanBeNull] string? schema, [NotNull] Re /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedDictionary Columns { get; [param: NotNull] protected set; } - = new SortedDictionary(StringComparer.Ordinal); + = new(StringComparer.Ordinal); /// public virtual IColumnBase? FindColumn(string name) diff --git a/src/EFCore.Relational/Metadata/Internal/TableIndex.cs b/src/EFCore.Relational/Metadata/Internal/TableIndex.cs index b727f3fe436..e53fe194560 100644 --- a/src/EFCore.Relational/Metadata/Internal/TableIndex.cs +++ b/src/EFCore.Relational/Metadata/Internal/TableIndex.cs @@ -46,7 +46,7 @@ public TableIndex( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual SortedSet MappedIndexes { get; } = new SortedSet(IndexComparer.Instance); + public virtual SortedSet MappedIndexes { get; } = new(IndexComparer.Instance); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Metadata/Internal/TableIndexComparer.cs b/src/EFCore.Relational/Metadata/Internal/TableIndexComparer.cs index b9459d4ba60..719984d83a8 100644 --- a/src/EFCore.Relational/Metadata/Internal/TableIndexComparer.cs +++ b/src/EFCore.Relational/Metadata/Internal/TableIndexComparer.cs @@ -27,7 +27,7 @@ private TableIndexComparer() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static readonly TableIndexComparer Instance = new TableIndexComparer(); + public static readonly TableIndexComparer Instance = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Metadata/Internal/TableMappingBase.cs b/src/EFCore.Relational/Metadata/Internal/TableMappingBase.cs index 88d4b29d556..96f21ad2422 100644 --- a/src/EFCore.Relational/Metadata/Internal/TableMappingBase.cs +++ b/src/EFCore.Relational/Metadata/Internal/TableMappingBase.cs @@ -47,7 +47,7 @@ public TableMappingBase( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SortedSet ColumnMappings { get; } - = new SortedSet(ColumnMappingBaseComparer.Instance); + = new(ColumnMappingBaseComparer.Instance); /// public virtual bool IncludesDerivedTypes { get; } diff --git a/src/EFCore.Relational/Metadata/Internal/TableMappingBaseComparer.cs b/src/EFCore.Relational/Metadata/Internal/TableMappingBaseComparer.cs index 0327a0b3d3b..8b2852c60df 100644 --- a/src/EFCore.Relational/Metadata/Internal/TableMappingBaseComparer.cs +++ b/src/EFCore.Relational/Metadata/Internal/TableMappingBaseComparer.cs @@ -28,7 +28,7 @@ private TableMappingBaseComparer() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static readonly TableMappingBaseComparer Instance = new TableMappingBaseComparer(); + public static readonly TableMappingBaseComparer Instance = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs b/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs index 8cb6fa0e8ab..71fd4112139 100644 --- a/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs +++ b/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs @@ -42,7 +42,7 @@ public UniqueConstraint( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual SortedSet MappedKeys { get; } = new SortedSet(KeyComparer.Instance); + public virtual SortedSet MappedKeys { get; } = new(KeyComparer.Instance); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Metadata/Internal/UniqueConstraintComparer.cs b/src/EFCore.Relational/Metadata/Internal/UniqueConstraintComparer.cs index 27fef6bf89e..d149113b1c6 100644 --- a/src/EFCore.Relational/Metadata/Internal/UniqueConstraintComparer.cs +++ b/src/EFCore.Relational/Metadata/Internal/UniqueConstraintComparer.cs @@ -27,7 +27,7 @@ private UniqueConstraintComparer() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static readonly UniqueConstraintComparer Instance = new UniqueConstraintComparer(); + public static readonly UniqueConstraintComparer Instance = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Migrations/Internal/MigrationsIdGenerator.cs b/src/EFCore.Relational/Migrations/Internal/MigrationsIdGenerator.cs index 18bf7464f9d..a0db9e89755 100644 --- a/src/EFCore.Relational/Migrations/Internal/MigrationsIdGenerator.cs +++ b/src/EFCore.Relational/Migrations/Internal/MigrationsIdGenerator.cs @@ -26,7 +26,7 @@ public class MigrationsIdGenerator : IMigrationsIdGenerator private const string Format = "yyyyMMddHHmmss"; private DateTime _lastTimestamp = DateTime.MinValue; - private readonly object _lock = new object(); + private readonly object _lock = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs index d0f81edd566..ce498519967 100644 --- a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs +++ b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs @@ -69,7 +69,7 @@ public class MigrationsModelDiffer : IMigrationsModelDiffer private IUpdateAdapter _targetUpdateAdapter; private readonly Dictionary _sourceSharedIdentityEntryMaps = - new Dictionary(); + new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -868,7 +868,7 @@ private PropertyInfoEqualityComparer() { } - public static readonly PropertyInfoEqualityComparer Instance = new PropertyInfoEqualityComparer(); + public static readonly PropertyInfoEqualityComparer Instance = new(); public bool Equals(PropertyInfo x, PropertyInfo y) => x.IsSameAs(y); @@ -2493,8 +2493,8 @@ public static IProperty[] GetMappedProperties([NotNull] ITable table, [NotNull] private sealed class EntryMapping { - public HashSet SourceEntries { get; } = new HashSet(); - public HashSet TargetEntries { get; } = new HashSet(); + public HashSet SourceEntries { get; } = new(); + public HashSet TargetEntries { get; } = new(); public bool RecreateRow { get; set; } } @@ -2503,7 +2503,7 @@ private sealed class SharedIdentityMap private readonly IUpdateAdapter _updateAdapter; private readonly Dictionary _entryValueMap - = new Dictionary(); + = new(); public SharedIdentityMap(IUpdateAdapter updateAdapter) { diff --git a/src/EFCore.Relational/Migrations/MigrationBuilder.cs b/src/EFCore.Relational/Migrations/MigrationBuilder.cs index baa6aebeee3..82ae2d8c004 100644 --- a/src/EFCore.Relational/Migrations/MigrationBuilder.cs +++ b/src/EFCore.Relational/Migrations/MigrationBuilder.cs @@ -35,7 +35,7 @@ public MigrationBuilder([CanBeNull] string activeProvider) /// /// The list of s being built. /// - public virtual List Operations { get; } = new List(); + public virtual List Operations { get; } = new(); /// /// Builds an to add a new column to a table. diff --git a/src/EFCore.Relational/Migrations/MigrationCommandListBuilder.cs b/src/EFCore.Relational/Migrations/MigrationCommandListBuilder.cs index abb2a65d002..763bfcb70f1 100644 --- a/src/EFCore.Relational/Migrations/MigrationCommandListBuilder.cs +++ b/src/EFCore.Relational/Migrations/MigrationCommandListBuilder.cs @@ -15,7 +15,7 @@ namespace Microsoft.EntityFrameworkCore.Migrations /// public class MigrationCommandListBuilder { - private readonly List _commands = new List(); + private readonly List _commands = new(); private readonly MigrationsSqlGeneratorDependencies _dependencies; private IRelationalCommandBuilder _commandBuilder; diff --git a/src/EFCore.Relational/Migrations/Operations/CreateTableOperation.cs b/src/EFCore.Relational/Migrations/Operations/CreateTableOperation.cs index af8c9d8674b..f14d7405e71 100644 --- a/src/EFCore.Relational/Migrations/Operations/CreateTableOperation.cs +++ b/src/EFCore.Relational/Migrations/Operations/CreateTableOperation.cs @@ -21,21 +21,21 @@ public class CreateTableOperation : TableOperation /// /// An ordered list of for adding columns to the table. /// - public virtual List Columns { get; } = new List(); + public virtual List Columns { get; } = new(); /// /// A list of for creating foreign key constraints in the table. /// - public virtual List ForeignKeys { get; } = new List(); + public virtual List ForeignKeys { get; } = new(); /// /// A list of for creating unique constraints in the table. /// - public virtual List UniqueConstraints { get; } = new List(); + public virtual List UniqueConstraints { get; } = new(); /// /// A list of for creating check constraints in the table. /// - public virtual List CheckConstraints { get; } = new List(); + public virtual List CheckConstraints { get; } = new(); } } diff --git a/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs b/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs index 6411cd37e0d..c3a0d3f62ec 100644 --- a/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs +++ b/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs @@ -43,6 +43,6 @@ public QuerySqlGeneratorFactory([NotNull] QuerySqlGeneratorDependencies dependen /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual QuerySqlGenerator Create() - => new QuerySqlGenerator(_dependencies); + => new(_dependencies); } } diff --git a/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs b/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs index 9b4cba950d5..67dfcd80851 100644 --- a/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs +++ b/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs @@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal public class RelationalCommandCache : IPrintableExpression { private static readonly ConcurrentDictionary _locks - = new ConcurrentDictionary(); + = new(); private readonly IMemoryCache _memoryCache; private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory; diff --git a/src/EFCore.Relational/Query/Internal/RelationalParameterBasedSqlProcessorFactory.cs b/src/EFCore.Relational/Query/Internal/RelationalParameterBasedSqlProcessorFactory.cs index adeff040d9a..3ebce2d9d1e 100644 --- a/src/EFCore.Relational/Query/Internal/RelationalParameterBasedSqlProcessorFactory.cs +++ b/src/EFCore.Relational/Query/Internal/RelationalParameterBasedSqlProcessorFactory.cs @@ -47,6 +47,6 @@ public RelationalParameterBasedSqlProcessorFactory( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual RelationalParameterBasedSqlProcessor Create(bool useRelationalNulls) - => new RelationalParameterBasedSqlProcessor(_dependencies, useRelationalNulls); + => new(_dependencies, useRelationalNulls); } } diff --git a/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs b/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs index 576a410dacb..b451a261887 100644 --- a/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs @@ -42,7 +42,7 @@ private static readonly MethodInfo _getParameterValueMethodInfo private readonly IDictionary _projectionMapping = new Dictionary(); - private readonly Stack _projectionMembers = new Stack(); + private readonly Stack _projectionMembers = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs b/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs index c9658136d27..3b539fbd934 100644 --- a/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs @@ -313,7 +313,7 @@ private Expression SimplifySqlBinary(SqlBinaryExpression sqlBinaryExpression) } private List ConstructCollection(object left, object right) - => new List { left, right }; + => new() { left, right }; private List AddToCollection(IEnumerable collection, object newElement) { diff --git a/src/EFCore.Relational/Query/QuerySqlGenerator.cs b/src/EFCore.Relational/Query/QuerySqlGenerator.cs index 8366335dfbb..6fc7f95f401 100644 --- a/src/EFCore.Relational/Query/QuerySqlGenerator.cs +++ b/src/EFCore.Relational/Query/QuerySqlGenerator.cs @@ -31,7 +31,7 @@ public class QuerySqlGenerator : SqlExpressionVisitor private readonly ISqlGenerationHelper _sqlGenerationHelper; private IRelationalCommandBuilder _relationalCommandBuilder; - private static readonly Dictionary _operatorMap = new Dictionary + private static readonly Dictionary _operatorMap = new() { { ExpressionType.Equal, " = " }, { ExpressionType.NotEqual, " <> " }, diff --git a/src/EFCore.Relational/Query/RelationalMemberTranslatorProvider.cs b/src/EFCore.Relational/Query/RelationalMemberTranslatorProvider.cs index 89e92a68ab7..d7e4466c672 100644 --- a/src/EFCore.Relational/Query/RelationalMemberTranslatorProvider.cs +++ b/src/EFCore.Relational/Query/RelationalMemberTranslatorProvider.cs @@ -30,8 +30,8 @@ namespace Microsoft.EntityFrameworkCore.Query /// public class RelationalMemberTranslatorProvider : IMemberTranslatorProvider { - private readonly List _plugins = new List(); - private readonly List _translators = new List(); + private readonly List _plugins = new(); + private readonly List _translators = new(); /// /// Creates a new instance of the class. diff --git a/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs b/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs index 5c4547c9afd..8da0da16126 100644 --- a/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs +++ b/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs @@ -31,8 +31,8 @@ namespace Microsoft.EntityFrameworkCore.Query /// public class RelationalMethodCallTranslatorProvider : IMethodCallTranslatorProvider { - private readonly List _plugins = new List(); - private readonly List _translators = new List(); + private readonly List _plugins = new(); + private readonly List _translators = new(); private readonly ISqlExpressionFactory _sqlExpressionFactory; /// diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs index b7617837b82..b573062cbbd 100644 --- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs @@ -175,7 +175,7 @@ protected override ShapedQueryExpression CreateShapedQueryExpression(IEntityType } private static ShapedQueryExpression CreateShapedQueryExpression(IEntityType entityType, SelectExpression selectExpression) - => new ShapedQueryExpression( + => new( selectExpression, new RelationalEntityShaperExpression( entityType, diff --git a/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs index 09a58fc00fc..d984a9418e5 100644 --- a/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs @@ -107,12 +107,12 @@ private static readonly MethodInfo _collectionAccessorAddMethodInfo private readonly IDictionary _variableShaperMapping = new Dictionary(); // There are always entity variables to avoid materializing same entity twice - private readonly List _variables = new List(); + private readonly List _variables = new(); - private readonly List _expressions = new List(); + private readonly List _expressions = new(); // IncludeExpressions are added at the end in case they are using ValuesArray - private readonly List _includeExpressions = new List(); + private readonly List _includeExpressions = new(); // If there is collection shaper then we need to construct ValuesArray to store values temporarily in ResultContext private List? _collectionPopulatingExpressions; diff --git a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs index 8067109eb22..926821b9293 100644 --- a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs @@ -638,7 +638,7 @@ static Expression RemapLambda(GroupingElementExpression groupingElement, LambdaE } selector = _sqlExpressionFactory.Case( - new List { new CaseWhenClause(groupingElement.Predicate, selector) }, + new List { new(groupingElement.Predicate, selector) }, elseResult: null); } diff --git a/src/EFCore.Relational/Query/SqlExpressionFactory.cs b/src/EFCore.Relational/Query/SqlExpressionFactory.cs index 33bc73aca1b..ea71e6ef89c 100644 --- a/src/EFCore.Relational/Query/SqlExpressionFactory.cs +++ b/src/EFCore.Relational/Query/SqlExpressionFactory.cs @@ -788,11 +788,11 @@ public virtual SqlFragmentExpression Fragment(string sql) /// public virtual SqlConstantExpression Constant(object? value, RelationalTypeMapping? typeMapping = null) - => new SqlConstantExpression(Expression.Constant(value), typeMapping); + => new(Expression.Constant(value), typeMapping); /// public virtual SelectExpression Select(SqlExpression? projection) - => new SelectExpression(projection); + => new(projection); /// public virtual SelectExpression Select(IEntityType entityType) diff --git a/src/EFCore.Relational/Query/SqlExpressions/CaseExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/CaseExpression.cs index 898a47440c9..f47aabee4e9 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/CaseExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/CaseExpression.cs @@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions /// public class CaseExpression : SqlExpression { - private readonly List _whenClauses = new List(); + private readonly List _whenClauses = new(); /// /// Creates a new instance of the class which represents a simple CASE expression. diff --git a/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs index ba964a9aefe..114a05e1794 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs @@ -96,7 +96,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// /// A new expression which has property set to true. public ColumnExpression MakeNullable() - => new ColumnExpression(Name, Table, Type, TypeMapping!, true); + => new(Name, Table, Type, TypeMapping!, true); /// protected override void Print(ExpressionPrinter expressionPrinter) diff --git a/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs index 29b52513cae..b63564f0e2f 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs @@ -141,7 +141,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// /// An expression which is negated form of this expression. public virtual InExpression Negate() - => new InExpression(Item, Values, Subquery, !IsNegated, TypeMapping); + => new(Item, Values, Subquery, !IsNegated, TypeMapping); /// /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will diff --git a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs index a24d20ce6ad..5593c92425d 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs @@ -36,7 +36,7 @@ namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions public sealed class SelectExpression : TableExpressionBase { private static readonly Dictionary _mirroredOperationMap = - new Dictionary + new() { { ExpressionType.Equal, ExpressionType.Equal }, { ExpressionType.NotEqual, ExpressionType.NotEqual }, @@ -51,20 +51,20 @@ public sealed class SelectExpression : TableExpressionBase private readonly IDictionary> _entityProjectionCache = new Dictionary>(); - private readonly List _projection = new List(); - private readonly List _tables = new List(); - private readonly List _groupBy = new List(); - private readonly List _orderings = new List(); + private readonly List _projection = new(); + private readonly List _tables = new(); + private readonly List _groupBy = new(); + private readonly List _orderings = new(); private readonly List<(ColumnExpression Column, ValueComparer Comparer)> _identifier - = new List<(ColumnExpression Column, ValueComparer Comparer)>(); + = new(); private readonly List<(ColumnExpression Column, ValueComparer Comparer)> _childIdentifiers - = new List<(ColumnExpression Column, ValueComparer Comparer)>(); + = new(); - private readonly List _pendingCollections = new List(); + private readonly List _pendingCollections = new(); - private List _tptLeftJoinTables = new List(); + private List _tptLeftJoinTables = new(); private IDictionary _projectionMapping = new Dictionary(); /// @@ -317,7 +317,7 @@ private static ColumnExpression CreateColumnExpression( ITableBase table, TableExpressionBase tableExpression, bool nullable) - => new ColumnExpression(property, table.FindColumn(property)!, tableExpression, nullable); + => new(property, table.FindColumn(property)!, tableExpression, nullable); /// /// Checks whether this representes a which is not composed upon. @@ -723,7 +723,7 @@ public void ApplyDefaultIfEmpty([NotNull] ISqlExpressionFactory sqlExpressionFac var dummySelectExpression = new SelectExpression( alias: "empty", - new List { new ProjectionExpression(nullSqlExpression, "empty") }, + new List { new(nullSqlExpression, "empty") }, new List(), new List(), new List()); @@ -2113,7 +2113,7 @@ protected override Expression VisitExtension(Expression extensionExpression) } private CollectionShaperExpression Remap(CollectionShaperExpression collectionShaperExpression) - => new CollectionShaperExpression( + => new( new ProjectionBindingExpression( _queryExpression, ((ProjectionBindingExpression)collectionShaperExpression.Projection).Index!.Value + (int)_pendingCollectionOffset!, diff --git a/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs index 53968c488eb..716d21725ff 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs @@ -307,7 +307,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// A relational type mapping to apply. /// A new expression which has supplied type mapping. public virtual SqlFunctionExpression ApplyTypeMapping([CanBeNull] RelationalTypeMapping? typeMapping) - => new SqlFunctionExpression( + => new( Instance, Schema, Name, @@ -426,7 +426,7 @@ public static SqlFunctionExpression CreateNiladic( [NotNull] string name, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => new SqlFunctionExpression(name, nullable: true, type, typeMapping); + => new(name, nullable: true, type, typeMapping); /// /// Creates a new instance of the class. @@ -442,7 +442,7 @@ public static SqlFunctionExpression CreateNiladic( [NotNull] string name, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => new SqlFunctionExpression(schema, name, nullable: true, type, typeMapping); + => new(schema, name, nullable: true, type, typeMapping); /// /// Creates a new instance of the class. @@ -458,7 +458,7 @@ public static SqlFunctionExpression CreateNiladic( [NotNull] string name, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => new SqlFunctionExpression(instance, name, nullable: true, instancePropagatesNullability: false, type, typeMapping); + => new(instance, name, nullable: true, instancePropagatesNullability: false, type, typeMapping); /// /// Creates a new instance of the class. @@ -476,7 +476,7 @@ public static SqlFunctionExpression Create( [NotNull] IEnumerable arguments, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => new SqlFunctionExpression( + => new( instance, name, arguments, @@ -500,8 +500,7 @@ public static SqlFunctionExpression Create( [NotNull] IEnumerable arguments, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => new SqlFunctionExpression( - name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping); + => new(name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping); /// /// Creates a new instance of the class. @@ -519,8 +518,7 @@ public static SqlFunctionExpression Create( [NotNull] IEnumerable arguments, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => new SqlFunctionExpression( - schema, name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping); + => new(schema, name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping); #endregion } diff --git a/src/EFCore.Relational/Storage/ParameterNameGeneratorFactory.cs b/src/EFCore.Relational/Storage/ParameterNameGeneratorFactory.cs index 202ae17bef0..1ed912b1c99 100644 --- a/src/EFCore.Relational/Storage/ParameterNameGeneratorFactory.cs +++ b/src/EFCore.Relational/Storage/ParameterNameGeneratorFactory.cs @@ -39,6 +39,6 @@ public ParameterNameGeneratorFactory([NotNull] ParameterNameGeneratorDependencie /// /// The newly created generator. public virtual ParameterNameGenerator Create() - => new ParameterNameGenerator(); + => new(); } } diff --git a/src/EFCore.Relational/Storage/RelationalCommand.cs b/src/EFCore.Relational/Storage/RelationalCommand.cs index c69d4be0cab..83cc389c45a 100644 --- a/src/EFCore.Relational/Storage/RelationalCommand.cs +++ b/src/EFCore.Relational/Storage/RelationalCommand.cs @@ -682,11 +682,6 @@ protected virtual RelationalDataReader CreateRelationalDataReader( [NotNull] DbDataReader reader, Guid commandId, [CanBeNull] IDiagnosticsLogger? logger) - => new RelationalDataReader( - connection, - command, - reader, - commandId, - logger); + => new(connection, command, reader, commandId, logger); } } diff --git a/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs b/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs index ac0c681d630..65d995ad9af 100644 --- a/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs +++ b/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs @@ -21,8 +21,8 @@ namespace Microsoft.EntityFrameworkCore.Storage /// public class RelationalCommandBuilder : IRelationalCommandBuilder { - private readonly List _parameters = new List(); - private readonly IndentedStringBuilder _commandTextBuilder = new IndentedStringBuilder(); + private readonly List _parameters = new(); + private readonly IndentedStringBuilder _commandTextBuilder = new(); /// /// diff --git a/src/EFCore.Relational/Storage/RelationalConnection.cs b/src/EFCore.Relational/Storage/RelationalConnection.cs index f039c768f98..6a95ca66f74 100644 --- a/src/EFCore.Relational/Storage/RelationalConnection.cs +++ b/src/EFCore.Relational/Storage/RelationalConnection.cs @@ -948,7 +948,7 @@ Task IResettableService.ResetStateAsync(CancellationToken cancellationToken) /// The semaphore used to serialize access to this connection. /// [Obsolete("EF Core no longer uses this semaphore. It will be removed in an upcoming release.")] - public virtual SemaphoreSlim Semaphore { get; } = new SemaphoreSlim(1); + public virtual SemaphoreSlim Semaphore { get; } = new(1); private Transaction? _enlistedTransaction; diff --git a/src/EFCore.Relational/Storage/RelationalTransactionFactory.cs b/src/EFCore.Relational/Storage/RelationalTransactionFactory.cs index 4694d8c9b55..0dda975825d 100644 --- a/src/EFCore.Relational/Storage/RelationalTransactionFactory.cs +++ b/src/EFCore.Relational/Storage/RelationalTransactionFactory.cs @@ -60,7 +60,6 @@ public virtual RelationalTransaction Create( Guid transactionId, IDiagnosticsLogger logger, bool transactionOwned) - => new RelationalTransaction( - connection, transaction, transactionId, logger, transactionOwned, Dependencies.SqlGenerationHelper); + => new(connection, transaction, transactionId, logger, transactionOwned, Dependencies.SqlGenerationHelper); } } diff --git a/src/EFCore.Relational/Storage/RelationalTypeMapping.cs b/src/EFCore.Relational/Storage/RelationalTypeMapping.cs index d6d38c8589e..1bc61939d35 100644 --- a/src/EFCore.Relational/Storage/RelationalTypeMapping.cs +++ b/src/EFCore.Relational/Storage/RelationalTypeMapping.cs @@ -122,7 +122,7 @@ public RelationalTypeMappingParameters( /// The mapping info containing the facets to use. /// The new parameter object. public RelationalTypeMappingParameters WithTypeMappingInfo(in RelationalTypeMappingInfo mappingInfo) - => new RelationalTypeMappingParameters( + => new( CoreParameters, mappingInfo.StoreTypeName ?? StoreType, StoreTypePostfix, @@ -145,7 +145,7 @@ public RelationalTypeMappingParameters WithStoreTypeAndSize( [NotNull] string storeType, int? size, StoreTypePostfix? storeTypePostfix = null) - => new RelationalTypeMappingParameters( + => new( CoreParameters, storeType, storeTypePostfix ?? StoreTypePostfix, @@ -165,7 +165,7 @@ public RelationalTypeMappingParameters WithStoreTypeAndSize( public RelationalTypeMappingParameters WithPrecisionAndScale( int? precision, int? scale) - => new RelationalTypeMappingParameters( + => new( CoreParameters, StoreType, StoreTypePostfix, @@ -182,7 +182,7 @@ public RelationalTypeMappingParameters WithPrecisionAndScale( /// The precision of data the property is configured to store, or null if no size is configured. /// The new parameter object. public RelationalTypeMappingParameters WithPrecision(int? precision) - => new RelationalTypeMappingParameters( + => new( CoreParameters, StoreType, StoreTypePostfix, @@ -199,7 +199,7 @@ public RelationalTypeMappingParameters WithPrecision(int? precision) /// The scale of data the property is configured to store, or null if no size is configured. /// The new parameter object. public RelationalTypeMappingParameters WithScale(int? scale) - => new RelationalTypeMappingParameters( + => new( CoreParameters, StoreType, StoreTypePostfix, @@ -217,7 +217,7 @@ public RelationalTypeMappingParameters WithScale(int? scale) /// The converter. /// The new parameter object. public RelationalTypeMappingParameters WithComposedConverter([CanBeNull] ValueConverter converter) - => new RelationalTypeMappingParameters( + => new( CoreParameters.WithComposedConverter(converter), StoreType, StoreTypePostfix, diff --git a/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs b/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs index 249485d9a15..7d78b204a6e 100644 --- a/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs +++ b/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs @@ -244,7 +244,7 @@ public Type? ClrType /// The converter to apply. /// The new mapping info. public RelationalTypeMappingInfo WithConverter(in ValueConverterInfo converterInfo) - => new RelationalTypeMappingInfo(this, converterInfo); + => new(this, converterInfo); /// /// Compares this to another to check if they represent the same mapping. diff --git a/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs b/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs index 409107e5533..69c00494f6b 100644 --- a/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs +++ b/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs @@ -37,7 +37,7 @@ namespace Microsoft.EntityFrameworkCore.Storage public abstract class RelationalTypeMappingSource : TypeMappingSourceBase, IRelationalTypeMappingSource { private readonly ConcurrentDictionary<(RelationalTypeMappingInfo, Type?, ValueConverter?), RelationalTypeMapping?> _explicitMappings - = new ConcurrentDictionary<(RelationalTypeMappingInfo, Type?, ValueConverter?), RelationalTypeMapping?>(); + = new(); /// /// Initializes a new instance of the this class. diff --git a/src/EFCore.Relational/Update/Internal/KeyValueIndexFactorySource.cs b/src/EFCore.Relational/Update/Internal/KeyValueIndexFactorySource.cs index 53dccaed70d..b245cca7afd 100644 --- a/src/EFCore.Relational/Update/Internal/KeyValueIndexFactorySource.cs +++ b/src/EFCore.Relational/Update/Internal/KeyValueIndexFactorySource.cs @@ -25,7 +25,7 @@ namespace Microsoft.EntityFrameworkCore.Update.Internal public class KeyValueIndexFactorySource : IKeyValueIndexFactorySource { private readonly ConcurrentDictionary _factories - = new ConcurrentDictionary(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Update/Internal/SharedTableEntryMap.cs b/src/EFCore.Relational/Update/Internal/SharedTableEntryMap.cs index ea0d658dd1a..6623662197e 100644 --- a/src/EFCore.Relational/Update/Internal/SharedTableEntryMap.cs +++ b/src/EFCore.Relational/Update/Internal/SharedTableEntryMap.cs @@ -20,7 +20,7 @@ public class SharedTableEntryMap private readonly ITable _table; private readonly IUpdateAdapter _updateAdapter; private readonly IComparer _comparer; - private readonly Dictionary _entryValueMap = new Dictionary(); + private readonly Dictionary _entryValueMap = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/Update/ModificationCommand.cs b/src/EFCore.Relational/Update/ModificationCommand.cs index c90a4c19101..49b9cfac127 100644 --- a/src/EFCore.Relational/Update/ModificationCommand.cs +++ b/src/EFCore.Relational/Update/ModificationCommand.cs @@ -28,7 +28,7 @@ public class ModificationCommand private readonly Func _generateParameterName; private readonly bool _sensitiveLoggingEnabled; private readonly IComparer _comparer; - private readonly List _entries = new List(); + private readonly List _entries = new(); private IReadOnlyList _columnModifications; private bool _requiresResultPropagation; private bool _mainEntryAdded; diff --git a/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs b/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs index 1bb277d644f..82bbcd1154a 100644 --- a/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs +++ b/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs @@ -25,7 +25,7 @@ namespace Microsoft.EntityFrameworkCore.Update /// public abstract class ReaderModificationCommandBatch : ModificationCommandBatch { - private readonly List _modificationCommands = new List(); + private readonly List _modificationCommands = new(); /// /// Creates a new instance. diff --git a/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeOffsetValueGenerator.cs b/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeOffsetValueGenerator.cs index d9f93e40030..1f3c93b15de 100644 --- a/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeOffsetValueGenerator.cs +++ b/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeOffsetValueGenerator.cs @@ -24,7 +24,7 @@ public class TemporaryDateTimeOffsetValueGenerator : ValueGenerator public override DateTimeOffset Next(EntityEntry entry) - => new DateTimeOffset(Interlocked.Increment(ref _current), TimeSpan.Zero); + => new(Interlocked.Increment(ref _current), TimeSpan.Zero); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeValueGenerator.cs b/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeValueGenerator.cs index 47ea678e9a5..3085c14fec0 100644 --- a/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeValueGenerator.cs +++ b/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeValueGenerator.cs @@ -24,7 +24,7 @@ public class TemporaryDateTimeValueGenerator : ValueGenerator /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public override DateTime Next(EntityEntry entry) - => new DateTime(Interlocked.Increment(ref _current)); + => new(Interlocked.Increment(ref _current)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Relational/ValueGeneration/RelationalValueGeneratorSelector.cs b/src/EFCore.Relational/ValueGeneration/RelationalValueGeneratorSelector.cs index 9f2d598e8e7..43835c189ba 100644 --- a/src/EFCore.Relational/ValueGeneration/RelationalValueGeneratorSelector.cs +++ b/src/EFCore.Relational/ValueGeneration/RelationalValueGeneratorSelector.cs @@ -28,7 +28,7 @@ namespace Microsoft.EntityFrameworkCore.ValueGeneration public class RelationalValueGeneratorSelector : ValueGeneratorSelector { private readonly TemporaryNumberValueGeneratorFactory _numberFactory - = new TemporaryNumberValueGeneratorFactory(); + = new(); /// /// Initializes a new instance of the class. diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs index d0c2caeceb3..63cbe23b5fc 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs @@ -110,30 +110,24 @@ public SqlServerGeometryMemberTranslator( { var whenClauses = new List { - new CaseWhenClause( - _sqlExpressionFactory.Constant("Point"), _sqlExpressionFactory.Constant(OgcGeometryType.Point)), - new CaseWhenClause( - _sqlExpressionFactory.Constant("LineString"), _sqlExpressionFactory.Constant(OgcGeometryType.LineString)), - new CaseWhenClause( - _sqlExpressionFactory.Constant("Polygon"), _sqlExpressionFactory.Constant(OgcGeometryType.Polygon)), - new CaseWhenClause( - _sqlExpressionFactory.Constant("MultiPoint"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiPoint)), - new CaseWhenClause( + new(_sqlExpressionFactory.Constant("Point"), _sqlExpressionFactory.Constant(OgcGeometryType.Point)), + new(_sqlExpressionFactory.Constant("LineString"), _sqlExpressionFactory.Constant(OgcGeometryType.LineString)), + new(_sqlExpressionFactory.Constant("Polygon"), _sqlExpressionFactory.Constant(OgcGeometryType.Polygon)), + new(_sqlExpressionFactory.Constant("MultiPoint"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiPoint)), + new( _sqlExpressionFactory.Constant("MultiLineString"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiLineString)), - new CaseWhenClause( - _sqlExpressionFactory.Constant("MultiPolygon"), - _sqlExpressionFactory.Constant(OgcGeometryType.MultiPolygon)), - new CaseWhenClause( + new(_sqlExpressionFactory.Constant("MultiPolygon"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiPolygon)), + new( _sqlExpressionFactory.Constant("GeometryCollection"), _sqlExpressionFactory.Constant(OgcGeometryType.GeometryCollection)), - new CaseWhenClause( + new( _sqlExpressionFactory.Constant("CircularString"), _sqlExpressionFactory.Constant(OgcGeometryType.CircularString)), - new CaseWhenClause( + new( _sqlExpressionFactory.Constant("CompoundCurve"), _sqlExpressionFactory.Constant(OgcGeometryType.CompoundCurve)), - new CaseWhenClause( + new( _sqlExpressionFactory.Constant("CurvePolygon"), _sqlExpressionFactory.Constant(OgcGeometryType.CurvePolygon)) }; diff --git a/src/EFCore.SqlServer.NTS/Scaffolding/Internal/SqlServerNetTopologySuiteCodeGeneratorPlugin.cs b/src/EFCore.SqlServer.NTS/Scaffolding/Internal/SqlServerNetTopologySuiteCodeGeneratorPlugin.cs index cd97fc7f83d..96d09ee9124 100644 --- a/src/EFCore.SqlServer.NTS/Scaffolding/Internal/SqlServerNetTopologySuiteCodeGeneratorPlugin.cs +++ b/src/EFCore.SqlServer.NTS/Scaffolding/Internal/SqlServerNetTopologySuiteCodeGeneratorPlugin.cs @@ -21,7 +21,6 @@ public class SqlServerNetTopologySuiteCodeGeneratorPlugin : ProviderCodeGenerato /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public override MethodCallCodeFragment GenerateProviderOptions() - => new MethodCallCodeFragment( - nameof(SqlServerNetTopologySuiteDbContextOptionsBuilderExtensions.UseNetTopologySuite)); + => new(nameof(SqlServerNetTopologySuiteDbContextOptionsBuilderExtensions.UseNetTopologySuite)); } } diff --git a/src/EFCore.SqlServer.NTS/Storage/Internal/SqlServerGeometryTypeMapping.cs b/src/EFCore.SqlServer.NTS/Storage/Internal/SqlServerGeometryTypeMapping.cs index a4232ae4beb..f0e52b38f5b 100644 --- a/src/EFCore.SqlServer.NTS/Storage/Internal/SqlServerGeometryTypeMapping.cs +++ b/src/EFCore.SqlServer.NTS/Storage/Internal/SqlServerGeometryTypeMapping.cs @@ -171,10 +171,10 @@ protected override void ConfigureParameter(DbParameter parameter) } private static SqlServerBytesReader CreateReader(NtsGeometryServices services, bool isGeography) - => new SqlServerBytesReader(services) { IsGeography = isGeography }; + => new(services) { IsGeography = isGeography }; private static SqlServerBytesWriter CreateWriter(bool isGeography) - => new SqlServerBytesWriter { IsGeography = isGeography }; + => new() { IsGeography = isGeography }; private static bool IsGeography(string storeType) => string.Equals(storeType, "geography", StringComparison.OrdinalIgnoreCase); diff --git a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs index cfbcfb13138..ee75e9981d6 100644 --- a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs +++ b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs @@ -136,7 +136,7 @@ private IReadOnlyList GenerateValueGenerationStrategy( var increment = GetAndRemove(SqlServerAnnotationNames.IdentityIncrement) ?? 1; return new List { - new MethodCallCodeFragment( + new( onModel ? nameof(SqlServerModelBuilderExtensions.UseIdentityColumns) : nameof(SqlServerPropertyBuilderExtensions.UseIdentityColumn), @@ -153,7 +153,7 @@ private IReadOnlyList GenerateValueGenerationStrategy( var schema = GetAndRemove(SqlServerAnnotationNames.HiLoSequenceSchema); return new List { - new MethodCallCodeFragment( + new( nameof(SqlServerModelBuilderExtensions.UseHiLo), (name, schema) switch { @@ -166,7 +166,7 @@ private IReadOnlyList GenerateValueGenerationStrategy( case SqlServerValueGenerationStrategy.None: return new List { - new MethodCallCodeFragment( + new( nameof(ModelBuilder.HasAnnotation), SqlServerAnnotationNames.ValueGenerationStrategy, SqlServerValueGenerationStrategy.None) diff --git a/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs b/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs index 1b02de29ab5..191f009cb42 100644 --- a/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs +++ b/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs @@ -68,7 +68,7 @@ private enum Id private static readonly string _validationPrefix = DbLoggerCategory.Model.Validation.Name + "."; private static EventId MakeValidationId(Id id) - => new EventId((int)id, _validationPrefix + id); + => new((int)id, _validationPrefix + id); /// /// @@ -127,7 +127,7 @@ private static EventId MakeValidationId(Id id) private static readonly string _transactionPrefix = DbLoggerCategory.Database.Transaction.Name + "."; private static EventId MakeTransactionId(Id id) - => new EventId((int)id, _transactionPrefix + id); + => new((int)id, _transactionPrefix + id); /// /// @@ -143,7 +143,7 @@ private static EventId MakeTransactionId(Id id) private static readonly string _scaffoldingPrefix = DbLoggerCategory.Scaffolding.Name + "."; private static EventId MakeScaffoldingId(Id id) - => new EventId((int)id, _scaffoldingPrefix + id); + => new((int)id, _scaffoldingPrefix + id); /// /// A column was found. diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs index 3f0ef0402bc..690177166c3 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs @@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal /// public class SqlServerConvertTranslator : IMethodCallTranslator { - private static readonly Dictionary _typeMapping = new Dictionary + private static readonly Dictionary _typeMapping = new() { [nameof(Convert.ToBoolean)] = "bit", [nameof(Convert.ToByte)] = "tinyint", @@ -35,7 +35,7 @@ public class SqlServerConvertTranslator : IMethodCallTranslator [nameof(Convert.ToString)] = "nvarchar(max)" }; - private static readonly List _supportedTypes = new List + private static readonly List _supportedTypes = new() { typeof(bool), typeof(byte), diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs index a533fdeb921..14e5e622c04 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs @@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal /// public class SqlServerDataLengthFunctionTranslator : IMethodCallTranslator { - private static readonly List _longReturningTypes = new List + private static readonly List _longReturningTypes = new() { "nvarchar(max)", "varchar(max)", @@ -31,7 +31,7 @@ public class SqlServerDataLengthFunctionTranslator : IMethodCallTranslator }; private static readonly HashSet _methodInfoDataLengthMapping - = new HashSet + = new() { typeof(SqlServerDbFunctionsExtensions).GetRequiredRuntimeMethod( nameof(SqlServerDbFunctionsExtensions.DataLength), diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs index e5f442c4c57..e85c152236a 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs @@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal public class SqlServerDateDiffFunctionsTranslator : IMethodCallTranslator { private readonly Dictionary _methodInfoDateDiffMapping - = new Dictionary + = new() { { typeof(SqlServerDbFunctionsExtensions).GetRequiredRuntimeMethod( diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs index 79e82ade0d6..f7af119b09c 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs @@ -24,7 +24,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal public class SqlServerDateTimeMemberTranslator : IMemberTranslator { private static readonly Dictionary _datePartMapping - = new Dictionary + = new() { { nameof(DateTime.Year), "year" }, { nameof(DateTime.Month), "month" }, diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs index 0f862f5d450..131d61107b2 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs @@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal /// public class SqlServerDateTimeMethodTranslator : IMethodCallTranslator { - private readonly Dictionary _methodInfoDatePartMapping = new Dictionary + private readonly Dictionary _methodInfoDatePartMapping = new() { { typeof(DateTime).GetRequiredRuntimeMethod(nameof(DateTime.AddYears), new[] { typeof(int) }), "year" }, { typeof(DateTime).GetRequiredRuntimeMethod(nameof(DateTime.AddMonths), new[] { typeof(int) }), "month" }, diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs index a7a9fddec66..2a8f25d5099 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs @@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal /// public class SqlServerMathTranslator : IMethodCallTranslator { - private static readonly Dictionary _supportedMethodTranslations = new Dictionary + private static readonly Dictionary _supportedMethodTranslations = new() { { typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Abs), new[] { typeof(decimal) }), "ABS" }, { typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Abs), new[] { typeof(double) }), "ABS" }, diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs index 60035b4be6b..0c8efe74043 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs @@ -25,7 +25,7 @@ public class SqlServerObjectToStringTranslator : IMethodCallTranslator private const int DefaultLength = 100; private static readonly Dictionary _typeMapping - = new Dictionary + = new() { { typeof(sbyte), "varchar(4)" }, { typeof(byte), "varchar(3)" }, diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs index f84250b6b63..da223af03e1 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs @@ -21,7 +21,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal public class SqlServerSqlTranslatingExpressionVisitor : RelationalSqlTranslatingExpressionVisitor { private static readonly HashSet _dateTimeDataTypes - = new HashSet + = new() { "time", "date", @@ -31,7 +31,7 @@ private static readonly HashSet _dateTimeDataTypes }; private static readonly HashSet _arithmeticOperatorTypes - = new HashSet + = new() { ExpressionType.Add, ExpressionType.Subtract, diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs index 26077a407b6..3057d2f09b5 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs @@ -22,7 +22,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal /// public class SqlServerTimeSpanMemberTranslator : IMemberTranslator { - private static readonly Dictionary _datePartMappings = new Dictionary + private static readonly Dictionary _datePartMappings = new() { { nameof(TimeSpan.Hours), "hour" }, { nameof(TimeSpan.Minutes), "minute" }, diff --git a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerCodeGenerator.cs b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerCodeGenerator.cs index da6e9d7e4cb..1b3ce7615e7 100644 --- a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerCodeGenerator.cs +++ b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerCodeGenerator.cs @@ -35,7 +35,7 @@ public SqlServerCodeGenerator([NotNull] ProviderCodeGeneratorDependencies depend public override MethodCallCodeFragment GenerateUseProvider( string connectionString, MethodCallCodeFragment? providerOptions) - => new MethodCallCodeFragment( + => new( nameof(SqlServerDbContextOptionsExtensions.UseSqlServer), providerOptions == null ? new object[] { connectionString } diff --git a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs index 2d356657808..4bcd923c989 100644 --- a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs +++ b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs @@ -57,7 +57,7 @@ private const string _namePartRegex = @"(?:(?:\[(?(?:(?:\]\])|[^\]])+)\])|(?[^\.\[\]]+))"; private static readonly Regex _partExtractor - = new Regex( + = new( string.Format( CultureInfo.InvariantCulture, @"^{0}(?:\.{1})?$", @@ -69,7 +69,7 @@ private static readonly Regex _partExtractor // see https://msdn.microsoft.com/en-us/library/ff878091.aspx // decimal/numeric are excluded because default value varies based on the precision. private static readonly Dictionary _defaultSequenceMinMax = - new Dictionary(StringComparer.OrdinalIgnoreCase) + new(StringComparer.OrdinalIgnoreCase) { { "tinyint", new[] { 0L, 255L } }, { "smallint", new[] { -32768L, 32767L } }, diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs index 37c798a9ac5..6e129f0105c 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs @@ -57,64 +57,64 @@ private readonly SqlServerByteArrayTypeMapping _rowversion storeTypePostfix: StoreTypePostfix.None); private readonly IntTypeMapping _int - = new IntTypeMapping("int", DbType.Int32); + = new("int", DbType.Int32); private readonly BoolTypeMapping _bool = new SqlServerBoolTypeMapping("bit"); private readonly SqlServerStringTypeMapping _fixedLengthUnicodeString - = new SqlServerStringTypeMapping(unicode: true, fixedLength: true); + = new(unicode: true, fixedLength: true); private readonly SqlServerStringTypeMapping _textUnicodeString - = new SqlServerStringTypeMapping("ntext", unicode: true, sqlDbType: SqlDbType.NText, storeTypePostfix: StoreTypePostfix.None); + = new("ntext", unicode: true, sqlDbType: SqlDbType.NText, storeTypePostfix: StoreTypePostfix.None); private readonly SqlServerStringTypeMapping _variableLengthUnicodeString - = new SqlServerStringTypeMapping(unicode: true); + = new(unicode: true); private readonly SqlServerStringTypeMapping _variableLengthMaxUnicodeString - = new SqlServerStringTypeMapping("nvarchar(max)", unicode: true, storeTypePostfix: StoreTypePostfix.None); + = new("nvarchar(max)", unicode: true, storeTypePostfix: StoreTypePostfix.None); private readonly SqlServerStringTypeMapping _fixedLengthAnsiString - = new SqlServerStringTypeMapping(fixedLength: true); + = new(fixedLength: true); private readonly SqlServerStringTypeMapping _textAnsiString - = new SqlServerStringTypeMapping("text", sqlDbType: SqlDbType.Text, storeTypePostfix: StoreTypePostfix.None); + = new("text", sqlDbType: SqlDbType.Text, storeTypePostfix: StoreTypePostfix.None); private readonly SqlServerStringTypeMapping _variableLengthAnsiString - = new SqlServerStringTypeMapping(); + = new(); private readonly SqlServerStringTypeMapping _variableLengthMaxAnsiString - = new SqlServerStringTypeMapping("varchar(max)", storeTypePostfix: StoreTypePostfix.None); + = new("varchar(max)", storeTypePostfix: StoreTypePostfix.None); private readonly SqlServerByteArrayTypeMapping _variableLengthBinary - = new SqlServerByteArrayTypeMapping(); + = new(); private readonly SqlServerByteArrayTypeMapping _imageBinary - = new SqlServerByteArrayTypeMapping("image", sqlDbType: SqlDbType.Image); + = new("image", sqlDbType: SqlDbType.Image); private readonly SqlServerByteArrayTypeMapping _variableLengthMaxBinary - = new SqlServerByteArrayTypeMapping("varbinary(max)", storeTypePostfix: StoreTypePostfix.None); + = new("varbinary(max)", storeTypePostfix: StoreTypePostfix.None); private readonly SqlServerByteArrayTypeMapping _fixedLengthBinary - = new SqlServerByteArrayTypeMapping(fixedLength: true); + = new(fixedLength: true); private readonly SqlServerDateTimeTypeMapping _date - = new SqlServerDateTimeTypeMapping("date", DbType.Date); + = new("date", DbType.Date); private readonly SqlServerDateTimeTypeMapping _datetime - = new SqlServerDateTimeTypeMapping("datetime", DbType.DateTime); + = new("datetime", DbType.DateTime); private readonly SqlServerDateTimeTypeMapping _datetime2 - = new SqlServerDateTimeTypeMapping("datetime2", DbType.DateTime2); + = new("datetime2", DbType.DateTime2); private readonly DoubleTypeMapping _double = new SqlServerDoubleTypeMapping("float"); private readonly SqlServerDateTimeOffsetTypeMapping _datetimeoffset - = new SqlServerDateTimeOffsetTypeMapping("datetimeoffset"); + = new("datetimeoffset"); private readonly GuidTypeMapping _uniqueidentifier - = new GuidTypeMapping("uniqueidentifier", DbType.Guid); + = new("uniqueidentifier", DbType.Guid); private readonly DecimalTypeMapping _decimal = new SqlServerDecimalTypeMapping( @@ -131,7 +131,7 @@ private readonly TimeSpanTypeMapping _time = new SqlServerTimeSpanTypeMapping("time"); private readonly SqlServerStringTypeMapping _xml - = new SqlServerStringTypeMapping("xml", unicode: true, storeTypePostfix: StoreTypePostfix.None); + = new("xml", unicode: true, storeTypePostfix: StoreTypePostfix.None); private readonly Dictionary _clrTypeMappings; diff --git a/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs b/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs index d81f76e1b21..f6e2648e38c 100644 --- a/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs +++ b/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs @@ -25,7 +25,7 @@ public class SqlServerModificationCommandBatch : AffectedCountModificationComman private const int MaxRowCount = 1000; private int _parameterCount = 1; // Implicit parameter for the command text private readonly int _maxBatchSize; - private readonly List _bulkInsertCommands = new List(); + private readonly List _bulkInsertCommands = new(); private int _commandsLeftToLengthCheck = 50; /// diff --git a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorCache.cs b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorCache.cs index fec6a2fa60f..342b429b327 100644 --- a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorCache.cs +++ b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorCache.cs @@ -27,7 +27,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.ValueGeneration.Internal public class SqlServerValueGeneratorCache : ValueGeneratorCache, ISqlServerValueGeneratorCache { private readonly ConcurrentDictionary _sequenceGeneratorCache - = new ConcurrentDictionary(); + = new(); /// /// Initializes a new instance of the class. diff --git a/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs b/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs index a7fb794c4af..fe81b17198e 100644 --- a/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs +++ b/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs @@ -50,7 +50,7 @@ private enum Id private static readonly string _validationPrefix = DbLoggerCategory.Model.Validation.Name + "."; private static EventId MakeValidationId(Id id) - => new EventId((int)id, _validationPrefix + id); + => new((int)id, _validationPrefix + id); /// /// @@ -81,7 +81,7 @@ private static EventId MakeValidationId(Id id) private static readonly string _infraPrefix = DbLoggerCategory.Infrastructure.Name + "."; private static EventId MakeInfraId(Id id) - => new EventId((int)id, _infraPrefix + id); + => new((int)id, _infraPrefix + id); /// /// @@ -100,7 +100,7 @@ private static EventId MakeInfraId(Id id) private static readonly string _migrationsPrefix = DbLoggerCategory.Migrations.Name + "."; private static EventId MakeMigrationsId(Id id) - => new EventId((int)id, _migrationsPrefix + id); + => new((int)id, _migrationsPrefix + id); /// /// An operation may fail due to a pending rebuild of the table. @@ -111,7 +111,7 @@ private static EventId MakeMigrationsId(Id id) private static readonly string _scaffoldingPrefix = DbLoggerCategory.Scaffolding.Name + "."; private static EventId MakeScaffoldingId(Id id) - => new EventId((int)id, _scaffoldingPrefix + id); + => new((int)id, _scaffoldingPrefix + id); /// /// A column was found. diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs index 8adc6608897..3d190c6443f 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs @@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal /// public class SqliteCharMethodTranslator : IMethodCallTranslator { - private static readonly Dictionary _supportedMethods = new Dictionary + private static readonly Dictionary _supportedMethods = new() { { typeof(char).GetRequiredRuntimeMethod(nameof(char.ToLower), new[] { typeof(char) }), "lower" }, { typeof(char).GetRequiredRuntimeMethod(nameof(char.ToUpper), new[] { typeof(char) }), "upper" } diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs index 8c473d5c381..256e32b381a 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs @@ -28,7 +28,7 @@ private static readonly MethodInfo _addMilliseconds private static readonly MethodInfo _addTicks = typeof(DateTime).GetRequiredRuntimeMethod(nameof(DateTime.AddTicks), new[] { typeof(long) }); - private readonly Dictionary _methodInfoToUnitSuffix = new Dictionary + private readonly Dictionary _methodInfoToUnitSuffix = new() { { typeof(DateTime).GetRequiredRuntimeMethod(nameof(DateTime.AddYears), new[] { typeof(int) }), " years" }, { typeof(DateTime).GetRequiredRuntimeMethod(nameof(DateTime.AddMonths), new[] { typeof(int) }), " months" }, diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs index 1e058dac7ee..c81ef13f840 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs @@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal public class SqliteDateTimeMemberTranslator : IMemberTranslator { private static readonly Dictionary _datePartMapping - = new Dictionary + = new() { { nameof(DateTime.Year), "%Y" }, { nameof(DateTime.Month), "%m" }, diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs index 93fe90b8efc..3c17d812412 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs @@ -24,7 +24,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal /// public class SqliteMathTranslator : IMethodCallTranslator { - private static readonly Dictionary _supportedMethods = new Dictionary + private static readonly Dictionary _supportedMethods = new() { { typeof(Math).GetRequiredMethod(nameof(Math.Abs), new[] { typeof(double) }), "abs" }, { typeof(Math).GetRequiredMethod(nameof(Math.Abs), new[] { typeof(float) }), "abs" }, diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs index 39c202b43dd..d0f5ccab6df 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs @@ -22,8 +22,8 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal /// public class SqliteObjectToStringTranslator : IMethodCallTranslator { - private static readonly HashSet _typeMapping = new HashSet - { + private static readonly HashSet _typeMapping = new() + { typeof(bool), typeof(byte), typeof(byte[]), diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessor.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessor.cs index f604da8e350..51bc6994add 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessor.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessor.cs @@ -21,7 +21,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal /// public class SqliteQueryTranslationPostprocessor : RelationalQueryTranslationPostprocessor { - private readonly ApplyValidatingVisitor _applyValidator = new ApplyValidatingVisitor(); + private readonly ApplyValidatingVisitor _applyValidator = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteCodeGenerator.cs b/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteCodeGenerator.cs index 58ac03204c0..4cdd63a7740 100644 --- a/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteCodeGenerator.cs +++ b/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteCodeGenerator.cs @@ -33,7 +33,7 @@ public SqliteCodeGenerator([NotNull] ProviderCodeGeneratorDependencies dependenc public override MethodCallCodeFragment GenerateUseProvider( string connectionString, MethodCallCodeFragment providerOptions) - => new MethodCallCodeFragment( + => new( nameof(SqliteDbContextOptionsBuilderExtensions.UseSqlite), providerOptions == null ? new object[] { connectionString } diff --git a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteTypeMappingSource.cs b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteTypeMappingSource.cs index be0b577c5c9..c982ea778e9 100644 --- a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteTypeMappingSource.cs +++ b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteTypeMappingSource.cs @@ -28,7 +28,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal public class SqliteTypeMappingSource : RelationalTypeMappingSource { private static readonly HashSet _spatialiteTypes - = new HashSet(StringComparer.OrdinalIgnoreCase) + = new(StringComparer.OrdinalIgnoreCase) { "GEOMETRY", "GEOMETRYZ", diff --git a/src/EFCore.Sqlite.NTS/Scaffolding/Internal/SqliteNetTopologySuiteCodeGeneratorPlugin.cs b/src/EFCore.Sqlite.NTS/Scaffolding/Internal/SqliteNetTopologySuiteCodeGeneratorPlugin.cs index 838771b327d..5560fe3ab21 100644 --- a/src/EFCore.Sqlite.NTS/Scaffolding/Internal/SqliteNetTopologySuiteCodeGeneratorPlugin.cs +++ b/src/EFCore.Sqlite.NTS/Scaffolding/Internal/SqliteNetTopologySuiteCodeGeneratorPlugin.cs @@ -21,7 +21,7 @@ public class SqliteNetTopologySuiteCodeGeneratorPlugin : ProviderCodeGeneratorPl /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public override MethodCallCodeFragment GenerateProviderOptions() - => new MethodCallCodeFragment( + => new( nameof(SqliteNetTopologySuiteDbContextOptionsBuilderExtensions.UseNetTopologySuite)); } } diff --git a/src/EFCore/ChangeTracking/ChangeTracker.cs b/src/EFCore/ChangeTracking/ChangeTracker.cs index 37ca85169e8..3ef698aea31 100644 --- a/src/EFCore/ChangeTracking/ChangeTracker.cs +++ b/src/EFCore/ChangeTracking/ChangeTracker.cs @@ -441,7 +441,7 @@ public virtual void Clear() /// /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(ChangeTrackerDebugStringOptions.ShortDefault), () => this.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault)); diff --git a/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs b/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs index 87db70ecb50..2e8e9330d82 100644 --- a/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs +++ b/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs @@ -51,7 +51,7 @@ public static string ToDebugString( private sealed class EntityEntryComparer : IComparer { - public static readonly EntityEntryComparer Instance = new EntityEntryComparer(); + public static readonly EntityEntryComparer Instance = new(); public int Compare(InternalEntityEntry x, InternalEntityEntry y) { diff --git a/src/EFCore/ChangeTracking/CollectionEntry`.cs b/src/EFCore/ChangeTracking/CollectionEntry`.cs index 3e3842970c2..380eee2613f 100644 --- a/src/EFCore/ChangeTracking/CollectionEntry`.cs +++ b/src/EFCore/ChangeTracking/CollectionEntry`.cs @@ -55,7 +55,7 @@ public CollectionEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] IN /// /// An entry for the entity that owns this member. public new virtual EntityEntry EntityEntry - => new EntityEntry(InternalEntry); + => new(InternalEntry); /// /// Gets or sets the value currently assigned to this property. If the current value is set using this property, diff --git a/src/EFCore/ChangeTracking/EntityEntry.cs b/src/EFCore/ChangeTracking/EntityEntry.cs index 0275c9dc225..1f11fc18282 100644 --- a/src/EFCore/ChangeTracking/EntityEntry.cs +++ b/src/EFCore/ChangeTracking/EntityEntry.cs @@ -451,7 +451,7 @@ public override string ToString() /// /// public virtual DebugView DebugView - => new DebugView( + => new( () => InternalEntry.ToDebugString(ChangeTrackerDebugStringOptions.ShortDefault), () => InternalEntry.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault)); diff --git a/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs b/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs index c3a927eb782..d50056a71a6 100644 --- a/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs +++ b/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs @@ -75,7 +75,7 @@ public virtual EntityEntry SourceEntry /// /// public virtual EntityEntry Entry - => new EntityEntry(_entry); + => new(_entry); /// /// diff --git a/src/EFCore/ChangeTracking/Internal/ChangeTrackerFactory.cs b/src/EFCore/ChangeTracking/Internal/ChangeTrackerFactory.cs index 52edb14596f..b6bd89481bd 100644 --- a/src/EFCore/ChangeTracking/Internal/ChangeTrackerFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/ChangeTrackerFactory.cs @@ -57,6 +57,6 @@ public ChangeTrackerFactory( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual ChangeTracker Create() - => new ChangeTracker(_context, _stateManager, _changeDetector, _model, _graphIterator); + => new(_context, _stateManager, _changeDetector, _model, _graphIterator); } } diff --git a/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs b/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs index 22faa258d8c..e33f16faf63 100644 --- a/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs +++ b/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs @@ -1608,7 +1608,7 @@ public virtual bool IsKeyUnknown /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual EntityEntry ToEntityEntry() - => new EntityEntry(this); + => new(this); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1738,7 +1738,7 @@ public override string ToString() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(ChangeTrackerDebugStringOptions.ShortDefault), () => this.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault)); diff --git a/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs b/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs index f3caa8e41ad..95603dfb2e9 100644 --- a/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs +++ b/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs @@ -33,10 +33,8 @@ public class ValueGenerationManager : IValueGenerationManager private readonly IKeyPropagator _keyPropagator; private readonly IDiagnosticsLogger _logger; private readonly ILoggingOptions _loggingOptions; - private readonly Dictionary> _entityTypePropagatingPropertiesMap - = new Dictionary>(); - private readonly Dictionary> _entityTypeGeneratingPropertiesMap - = new Dictionary>(); + private readonly Dictionary> _entityTypePropagatingPropertiesMap = new(); + private readonly Dictionary> _entityTypeGeneratingPropertiesMap = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/ChangeTracking/MemberEntry.cs b/src/EFCore/ChangeTracking/MemberEntry.cs index 4db26bffda0..1dacf22f31b 100644 --- a/src/EFCore/ChangeTracking/MemberEntry.cs +++ b/src/EFCore/ChangeTracking/MemberEntry.cs @@ -88,7 +88,7 @@ public virtual object CurrentValue /// /// An entry for the entity that owns this member. public virtual EntityEntry EntityEntry - => new EntityEntry(InternalEntry); + => new(InternalEntry); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/ChangeTracking/ObservableHashSet.cs b/src/EFCore/ChangeTracking/ObservableHashSet.cs index cec1a54cde2..ca8ca0795fc 100644 --- a/src/EFCore/ChangeTracking/ObservableHashSet.cs +++ b/src/EFCore/ChangeTracking/ObservableHashSet.cs @@ -484,11 +484,8 @@ protected virtual void OnCollectionChanged([NotNull] NotifyCollectionChangedEven internal static class ObservableHashSetSingletons { - public static readonly PropertyChangedEventArgs _countPropertyChanged - = new PropertyChangedEventArgs("Count"); - - public static readonly PropertyChangingEventArgs _countPropertyChanging - = new PropertyChangingEventArgs("Count"); + public static readonly PropertyChangedEventArgs _countPropertyChanged = new("Count"); + public static readonly PropertyChangingEventArgs _countPropertyChanging = new("Count"); public static readonly object[] _noItems = Array.Empty(); } diff --git a/src/EFCore/ChangeTracking/PropertyEntry`.cs b/src/EFCore/ChangeTracking/PropertyEntry`.cs index c9d1823b613..4645a70aaa7 100644 --- a/src/EFCore/ChangeTracking/PropertyEntry`.cs +++ b/src/EFCore/ChangeTracking/PropertyEntry`.cs @@ -51,7 +51,7 @@ public PropertyEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] IPro /// /// An entry for the entity that owns this member. public new virtual EntityEntry EntityEntry - => new EntityEntry(InternalEntry); + => new(InternalEntry); /// /// Gets or sets the value currently assigned to this property. If the current value is set using this property, diff --git a/src/EFCore/ChangeTracking/ReferenceEntry`.cs b/src/EFCore/ChangeTracking/ReferenceEntry`.cs index a612aba30e8..1fed0cbb501 100644 --- a/src/EFCore/ChangeTracking/ReferenceEntry`.cs +++ b/src/EFCore/ChangeTracking/ReferenceEntry`.cs @@ -54,7 +54,7 @@ public ReferenceEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] INa /// /// An entry for the entity that owns this member. public new virtual EntityEntry EntityEntry - => new EntityEntry(InternalEntry); + => new(InternalEntry); /// /// The of the entity this navigation targets. diff --git a/src/EFCore/DbContext.cs b/src/EFCore/DbContext.cs index 835427e4120..4966be864b9 100644 --- a/src/EFCore/DbContext.cs +++ b/src/EFCore/DbContext.cs @@ -153,7 +153,7 @@ public virtual IModel Model /// /// public virtual DbContextId ContextId - => new DbContextId(_contextId, _leaseCount); + => new(_contextId, _leaseCount); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -891,7 +891,7 @@ public virtual EntityEntry Entry([NotNull] TEntity entity) private EntityEntry EntryWithoutDetectChanges(TEntity entity) where TEntity : class - => new EntityEntry(DbContextDependencies.StateManager.GetOrCreateEntry(entity)); + => new(DbContextDependencies.StateManager.GetOrCreateEntry(entity)); /// /// @@ -919,7 +919,7 @@ public virtual EntityEntry Entry([NotNull] object entity) } private EntityEntry EntryWithoutDetectChanges(object entity) - => new EntityEntry(DbContextDependencies.StateManager.GetOrCreateEntry(entity)); + => new(DbContextDependencies.StateManager.GetOrCreateEntry(entity)); private void SetEntityState(InternalEntityEntry entry, EntityState entityState) { diff --git a/src/EFCore/DbFunctions.cs b/src/EFCore/DbFunctions.cs index 7eff596ed09..84bb0c8509a 100644 --- a/src/EFCore/DbFunctions.cs +++ b/src/EFCore/DbFunctions.cs @@ -17,7 +17,7 @@ private DbFunctions() { } - internal static DbFunctions Instance { get; } = new DbFunctions(); + internal static DbFunctions Instance { get; } = new(); #region Hidden System.Object members diff --git a/src/EFCore/Diagnostics/CoreEventId.cs b/src/EFCore/Diagnostics/CoreEventId.cs index b5c7f3d3058..afc1b71d086 100644 --- a/src/EFCore/Diagnostics/CoreEventId.cs +++ b/src/EFCore/Diagnostics/CoreEventId.cs @@ -127,7 +127,7 @@ private enum Id private static readonly string _updatePrefix = DbLoggerCategory.Update.Name + "."; private static EventId MakeUpdateId(Id id) - => new EventId((int)id, _updatePrefix + id); + => new((int)id, _updatePrefix + id); /// /// @@ -152,7 +152,7 @@ private static EventId MakeUpdateId(Id id) private static readonly string _queryPrefix = DbLoggerCategory.Query.Name + "."; private static EventId MakeQueryId(Id id) - => new EventId((int)id, _queryPrefix + id); + => new((int)id, _queryPrefix + id); /// /// @@ -275,7 +275,7 @@ public static readonly EventId FirstWithoutOrderByAndFilterWarning private static readonly string _infraPrefix = DbLoggerCategory.Infrastructure.Name + "."; private static EventId MakeInfraId(Id id) - => new EventId((int)id, _infraPrefix + id); + => new((int)id, _infraPrefix + id); /// /// @@ -410,12 +410,12 @@ private static EventId MakeInfraId(Id id) private static readonly string _modelPrefix = DbLoggerCategory.Model.Name + "."; private static EventId MakeModelId(Id id) - => new EventId((int)id, _modelPrefix + id); + => new((int)id, _modelPrefix + id); private static readonly string _modelValidationPrefix = DbLoggerCategory.Model.Validation.Name + "."; private static EventId MakeModelValidationId(Id id) - => new EventId((int)id, _modelValidationPrefix + id); + => new((int)id, _modelValidationPrefix + id); /// /// @@ -767,7 +767,7 @@ public static readonly EventId PossibleIncorrectRequiredNavigationWithQueryFilte private static readonly string _changeTrackingPrefix = DbLoggerCategory.ChangeTracking.Name + "."; private static EventId MakeChangeTrackingId(Id id) - => new EventId((int)id, _changeTrackingPrefix + id); + => new((int)id, _changeTrackingPrefix + id); /// /// diff --git a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs index 76086442e8e..b34d4bd5053 100644 --- a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs +++ b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs @@ -115,7 +115,7 @@ private static DbContextErrorEventData CreateDbContextErrorEventData( DbContext context, Exception exception, EventDefinition definition) - => new DbContextErrorEventData(definition, SaveChangesFailed, context, exception); + => new(definition, SaveChangesFailed, context, exception); private static string SaveChangesFailed(EventDefinitionBase definition, EventData payload) { @@ -197,7 +197,7 @@ private static DbContextErrorEventData CreateDbContextErrorEventData( DbContext context, Exception exception, EventDefinition definition) - => new DbContextErrorEventData( + => new( definition, OptimisticConcurrencyException, context, @@ -3164,7 +3164,7 @@ public static ValueTask> SaveChangesStartingAsync( } private static DbContextEventData CreateSaveChangesStartingEventData(DbContext context, EventDefinition definition) - => new DbContextEventData( + => new( definition, SaveChangesStarting, context); @@ -3255,7 +3255,7 @@ private static SaveChangesCompletedEventData CreateSaveChangesCompletedEventData DbContext context, int entitiesSavedCount, EventDefinition definition) - => new SaveChangesCompletedEventData( + => new( definition, SaveChangesCompleted, context, diff --git a/src/EFCore/Diagnostics/InterceptionResult.cs b/src/EFCore/Diagnostics/InterceptionResult.cs index 754ede0b283..4203c535cef 100644 --- a/src/EFCore/Diagnostics/InterceptionResult.cs +++ b/src/EFCore/Diagnostics/InterceptionResult.cs @@ -23,7 +23,7 @@ public readonly struct InterceptionResult /// execution should be suppressed. /// public static InterceptionResult Suppress() - => new InterceptionResult(true); + => new(true); private InterceptionResult(bool suppress) => IsSuppressed = suppress; diff --git a/src/EFCore/Diagnostics/InterceptionResult`.cs b/src/EFCore/Diagnostics/InterceptionResult`.cs index cf6e6d0fe19..15b9d9bc3dd 100644 --- a/src/EFCore/Diagnostics/InterceptionResult`.cs +++ b/src/EFCore/Diagnostics/InterceptionResult`.cs @@ -31,7 +31,7 @@ public readonly struct InterceptionResult /// /// The result to use. public static InterceptionResult SuppressWithResult([CanBeNull] TResult result) - => new InterceptionResult(result); + => new(result); private InterceptionResult(TResult result) { diff --git a/src/EFCore/Diagnostics/SaveChangesInterceptor.cs b/src/EFCore/Diagnostics/SaveChangesInterceptor.cs index 08db3f0d38c..993c9212e9c 100644 --- a/src/EFCore/Diagnostics/SaveChangesInterceptor.cs +++ b/src/EFCore/Diagnostics/SaveChangesInterceptor.cs @@ -89,7 +89,7 @@ public virtual ValueTask> SavingChangesAsync( DbContextEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) - => new ValueTask>(result); + => new(result); /// /// @@ -117,7 +117,7 @@ public virtual ValueTask SavedChangesAsync( SaveChangesCompletedEventData eventData, int result, CancellationToken cancellationToken = default) - => new ValueTask(result); + => new(result); /// /// Called when an exception has been thrown in . diff --git a/src/EFCore/Diagnostics/WarningsConfiguration.cs b/src/EFCore/Diagnostics/WarningsConfiguration.cs index de03142e0bc..0d2106faffd 100644 --- a/src/EFCore/Diagnostics/WarningsConfiguration.cs +++ b/src/EFCore/Diagnostics/WarningsConfiguration.cs @@ -22,8 +22,7 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics /// public class WarningsConfiguration { - private Dictionary _explicitBehaviors - = new Dictionary(); + private Dictionary _explicitBehaviors = new(); private WarningBehavior _defaultBehavior = WarningBehavior.Log; @@ -51,7 +50,7 @@ protected WarningsConfiguration([NotNull] WarningsConfiguration copyFrom) /// /// A clone of this instance, which can be modified before being returned as immutable. protected virtual WarningsConfiguration Clone() - => new WarningsConfiguration(this); + => new(this); /// /// The option set from the method. diff --git a/src/EFCore/Infrastructure/Annotatable.cs b/src/EFCore/Infrastructure/Annotatable.cs index 8676405f79e..30f35997eb3 100644 --- a/src/EFCore/Infrastructure/Annotatable.cs +++ b/src/EFCore/Infrastructure/Annotatable.cs @@ -198,7 +198,7 @@ public virtual object? this[string name] /// The value to be stored in the annotation. /// The newly created annotation. protected virtual Annotation CreateAnnotation([NotNull] string name, [CanBeNull] object? value) - => new Annotation(name, value); + => new(name, value); /// [DebuggerStepThrough] diff --git a/src/EFCore/Infrastructure/ConventionAnnotatable.cs b/src/EFCore/Infrastructure/ConventionAnnotatable.cs index e740f286b16..84f89dcb8fe 100644 --- a/src/EFCore/Infrastructure/ConventionAnnotatable.cs +++ b/src/EFCore/Infrastructure/ConventionAnnotatable.cs @@ -121,7 +121,7 @@ private static ConventionAnnotation CreateAnnotation( string name, object? value, ConfigurationSource configurationSource) - => new ConventionAnnotation(name, value, configurationSource); + => new(name, value, configurationSource); /// IConventionAnnotatableBuilder IConventionAnnotatable.Builder diff --git a/src/EFCore/Infrastructure/CoreOptionsExtension.cs b/src/EFCore/Infrastructure/CoreOptionsExtension.cs index d6ec52cfff5..009cde137fd 100644 --- a/src/EFCore/Infrastructure/CoreOptionsExtension.cs +++ b/src/EFCore/Infrastructure/CoreOptionsExtension.cs @@ -94,7 +94,7 @@ public virtual DbContextOptionsExtensionInfo Info /// /// A clone of this instance, which can be modified before being returned as immutable. protected virtual CoreOptionsExtension Clone() - => new CoreOptionsExtension(this); + => new(this); /// /// Creates a new instance with all options the same as for this instance, but with the given option changed. diff --git a/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs b/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs index d05ffdb1ff2..d46de6e1595 100644 --- a/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs +++ b/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs @@ -36,7 +36,7 @@ public sealed class EntityFrameworkEventSource : EventSource /// /// The singleton instance of . /// - public static readonly EntityFrameworkEventSource Log = new EntityFrameworkEventSource(); + public static readonly EntityFrameworkEventSource Log = new(); private EntityFrameworkEventSource() : base("Microsoft.EntityFrameworkCore") diff --git a/src/EFCore/Infrastructure/IndentedStringBuilder.cs b/src/EFCore/Infrastructure/IndentedStringBuilder.cs index 133793a0718..da13006f769 100644 --- a/src/EFCore/Infrastructure/IndentedStringBuilder.cs +++ b/src/EFCore/Infrastructure/IndentedStringBuilder.cs @@ -25,7 +25,7 @@ public class IndentedStringBuilder private byte _indent; private bool _indentPending = true; - private readonly StringBuilder _stringBuilder = new StringBuilder(); + private readonly StringBuilder _stringBuilder = new(); /// /// The current length of the built string. diff --git a/src/EFCore/Infrastructure/Internal/ConcurrencyDetector.cs b/src/EFCore/Infrastructure/Internal/ConcurrencyDetector.cs index 4df03cb21f4..bfd3a149a97 100644 --- a/src/EFCore/Infrastructure/Internal/ConcurrencyDetector.cs +++ b/src/EFCore/Infrastructure/Internal/ConcurrencyDetector.cs @@ -27,7 +27,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure.Internal public class ConcurrencyDetector : IConcurrencyDetector { private int _inCriticalSection; - private static readonly AsyncLocal _threadHasLock = new AsyncLocal(); + private static readonly AsyncLocal _threadHasLock = new(); private int _refCount; /// diff --git a/src/EFCore/Infrastructure/Internal/DbSetFinder.cs b/src/EFCore/Infrastructure/Internal/DbSetFinder.cs index 52d1242ff50..58e9062ec98 100644 --- a/src/EFCore/Infrastructure/Internal/DbSetFinder.cs +++ b/src/EFCore/Infrastructure/Internal/DbSetFinder.cs @@ -26,8 +26,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure.Internal /// public class DbSetFinder : IDbSetFinder { - private readonly ConcurrentDictionary> _cache - = new ConcurrentDictionary>(); + private readonly ConcurrentDictionary> _cache = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Infrastructure/ModelSource.cs b/src/EFCore/Infrastructure/ModelSource.cs index ea74e3caea6..25aaf9199af 100644 --- a/src/EFCore/Infrastructure/ModelSource.cs +++ b/src/EFCore/Infrastructure/ModelSource.cs @@ -29,7 +29,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure /// public class ModelSource : IModelSource { - private readonly object _syncObject = new object(); + private readonly object _syncObject = new(); /// /// Creates a new instance. diff --git a/src/EFCore/Internal/DbContextLease.cs b/src/EFCore/Internal/DbContextLease.cs index 060d955bc65..c6682ea1df3 100644 --- a/src/EFCore/Internal/DbContextLease.cs +++ b/src/EFCore/Internal/DbContextLease.cs @@ -23,7 +23,7 @@ public struct DbContextLease /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static DbContextLease InactiveLease { get; } = new DbContextLease(); + public static DbContextLease InactiveLease { get; } = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Internal/DbContextPool.cs b/src/EFCore/Internal/DbContextPool.cs index 24983a6917d..ab1f1972bee 100644 --- a/src/EFCore/Internal/DbContextPool.cs +++ b/src/EFCore/Internal/DbContextPool.cs @@ -26,7 +26,7 @@ public class DbContextPool : IDbContextPool, IDisposable, IA { private const int DefaultPoolSize = 32; - private readonly ConcurrentQueue _pool = new ConcurrentQueue(); + private readonly ConcurrentQueue _pool = new(); private readonly Func _activator; diff --git a/src/EFCore/Internal/DbSetSource.cs b/src/EFCore/Internal/DbSetSource.cs index b575c6f4b4c..eee8437bf0f 100644 --- a/src/EFCore/Internal/DbSetSource.cs +++ b/src/EFCore/Internal/DbSetSource.cs @@ -27,8 +27,7 @@ public class DbSetSource : IDbSetSource private static readonly MethodInfo _genericCreateSet = typeof(DbSetSource).GetTypeInfo().GetDeclaredMethod(nameof(CreateSetFactory)); - private readonly ConcurrentDictionary<(Type Type, string Name), Func> _cache - = new ConcurrentDictionary<(Type Type, string Name), Func>(); + private readonly ConcurrentDictionary<(Type Type, string Name), Func> _cache = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Internal/EntityFinderSource.cs b/src/EFCore/Internal/EntityFinderSource.cs index ad3efe58b28..3aa38806bc1 100644 --- a/src/EFCore/Internal/EntityFinderSource.cs +++ b/src/EFCore/Internal/EntityFinderSource.cs @@ -30,7 +30,7 @@ private static readonly MethodInfo _genericCreate = typeof(EntityFinderSource).GetTypeInfo().GetDeclaredMethod(nameof(CreateConstructor)); private readonly ConcurrentDictionary> _cache - = new ConcurrentDictionary>(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Internal/InternalDbSet.cs b/src/EFCore/Internal/InternalDbSet.cs index 5b6f31cd356..bd3e03d25ba 100644 --- a/src/EFCore/Internal/InternalDbSet.cs +++ b/src/EFCore/Internal/InternalDbSet.cs @@ -134,7 +134,7 @@ private EntityQueryable EntityQueryable } private EntityQueryable CreateEntityQueryable() - => new EntityQueryable(_context.GetDependencies().QueryProvider, EntityType); + => new(_context.GetDependencies().QueryProvider, EntityType); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -524,7 +524,7 @@ Task IResettableService.ResetStateAsync(CancellationToken cancellationToken) } private EntityEntry EntryWithoutDetectChanges(TEntity entity) - => new EntityEntry(_context.GetDependencies().StateManager.GetOrCreateEntry(entity, EntityType)); + => new(_context.GetDependencies().StateManager.GetOrCreateEntry(entity, EntityType)); private void SetEntityStates(IEnumerable entities, EntityState entityState) { diff --git a/src/EFCore/Internal/ServiceProviderCache.cs b/src/EFCore/Internal/ServiceProviderCache.cs index 612d952ffe7..fe5e3557e80 100644 --- a/src/EFCore/Internal/ServiceProviderCache.cs +++ b/src/EFCore/Internal/ServiceProviderCache.cs @@ -23,8 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Internal public class ServiceProviderCache { private readonly ConcurrentDictionary DebugInfo)> - _configurations - = new ConcurrentDictionary)>(); + _configurations = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -32,7 +31,7 @@ public class ServiceProviderCache /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static ServiceProviderCache Instance { get; } = new ServiceProviderCache(); + public static ServiceProviderCache Instance { get; } = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Internal/SingletonOptionsInitializer.cs b/src/EFCore/Internal/SingletonOptionsInitializer.cs index 805054b1345..b8f578d87ff 100644 --- a/src/EFCore/Internal/SingletonOptionsInitializer.cs +++ b/src/EFCore/Internal/SingletonOptionsInitializer.cs @@ -24,7 +24,7 @@ namespace Microsoft.EntityFrameworkCore.Internal public class SingletonOptionsInitializer : ISingletonOptionsInitializer { private volatile bool _isInitialized; - private readonly object _lock = new object(); + private readonly object _lock = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs b/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs index 780a4f05962..382d656c5ce 100644 --- a/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs +++ b/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs @@ -121,7 +121,7 @@ IConventionForeignKeyBuilder IInfrastructure.Insta /// /// An object to further configure the relationship. public virtual ReferenceCollectionBuilder WithOne([CanBeNull] string navigationName = null) - => new ReferenceCollectionBuilder( + => new( DeclaringEntityType, RelatedEntityType, WithOneBuilder( diff --git a/src/EFCore/Metadata/Builders/CollectionNavigationBuilder`.cs b/src/EFCore/Metadata/Builders/CollectionNavigationBuilder`.cs index f3134e5ef46..53d8a370c3a 100644 --- a/src/EFCore/Metadata/Builders/CollectionNavigationBuilder`.cs +++ b/src/EFCore/Metadata/Builders/CollectionNavigationBuilder`.cs @@ -55,7 +55,7 @@ public CollectionNavigationBuilder( public new virtual ReferenceCollectionBuilder WithOne( [CanBeNull] string navigationName = null) { - return new ReferenceCollectionBuilder( + return new( DeclaringEntityType, RelatedEntityType, WithOneBuilder( @@ -80,7 +80,7 @@ public CollectionNavigationBuilder( /// An object to further configure the relationship. public virtual ReferenceCollectionBuilder WithOne( [CanBeNull] Expression> navigationExpression) - => new ReferenceCollectionBuilder( + => new( DeclaringEntityType, RelatedEntityType, WithOneBuilder(navigationExpression?.GetMemberAccess()).Metadata); diff --git a/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs b/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs index 3bafd6b7e57..774f84a1a2f 100644 --- a/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs +++ b/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs @@ -76,7 +76,7 @@ public virtual EntityTypeBuilder HasAnnotation([NotNull] string annotation, [Not /// The name of the base type or to indicate no base type. /// The same builder instance so that multiple configuration calls can be chained. public virtual EntityTypeBuilder HasBaseType([CanBeNull] string name) - => new EntityTypeBuilder(Builder.HasBaseType(name, ConfigurationSource.Explicit).Metadata); + => new(Builder.HasBaseType(name, ConfigurationSource.Explicit).Metadata); /// /// Sets the base type of this entity type in an inheritance hierarchy. @@ -84,7 +84,7 @@ public virtual EntityTypeBuilder HasBaseType([CanBeNull] string name) /// The base type or to indicate no base type. /// The same builder instance so that multiple configuration calls can be chained. public virtual EntityTypeBuilder HasBaseType([CanBeNull] Type entityType) - => new EntityTypeBuilder(Builder.HasBaseType(entityType, ConfigurationSource.Explicit).Metadata); + => new(Builder.HasBaseType(entityType, ConfigurationSource.Explicit).Metadata); /// /// Sets the properties that make up the primary key for this entity type. @@ -92,8 +92,7 @@ public virtual EntityTypeBuilder HasBaseType([CanBeNull] Type entityType) /// The names of the properties that make up the primary key. /// An object that can be used to configure the primary key. public virtual KeyBuilder HasKey([NotNull] params string[] propertyNames) - => new KeyBuilder( - Builder.PrimaryKey(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); + => new(Builder.PrimaryKey(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); /// /// Creates an alternate key in the model for this entity type if one does not already exist over the specified @@ -103,8 +102,7 @@ public virtual KeyBuilder HasKey([NotNull] params string[] propertyNames) /// The names of the properties that make up the key. /// An object that can be used to configure the key. public virtual KeyBuilder HasAlternateKey([NotNull] params string[] propertyNames) - => new KeyBuilder( - Builder.HasKey(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); + => new(Builder.HasKey(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); /// /// Configures the entity type to have no keys. It will only be usable for queries. @@ -130,7 +128,7 @@ public virtual EntityTypeBuilder HasNoKey() /// The name of the property to be configured. /// An object that can be used to configure the property. public virtual PropertyBuilder Property([NotNull] string propertyName) - => new PropertyBuilder( + => new( Builder.Property( Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata); @@ -152,7 +150,7 @@ public virtual PropertyBuilder Property([NotNull] string propertyName) /// The name of the property to be configured. /// An object that can be used to configure the property. public virtual PropertyBuilder Property([NotNull] string propertyName) - => new PropertyBuilder( + => new( Builder.Property( typeof(TProperty), Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata); @@ -174,7 +172,7 @@ public virtual PropertyBuilder Property([NotNull] string p /// The name of the property to be configured. /// An object that can be used to configure the property. public virtual PropertyBuilder Property([NotNull] Type propertyType, [NotNull] string propertyName) - => new PropertyBuilder( + => new( Builder.Property( Check.NotNull(propertyType, nameof(propertyType)), Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata); @@ -194,7 +192,7 @@ public virtual PropertyBuilder Property([NotNull] Type propertyType, [NotNull] s /// The name of the property to be configured. /// An object that can be used to configure the property. public virtual PropertyBuilder IndexerProperty([NotNull] string propertyName) - => new PropertyBuilder( + => new( Builder.IndexerProperty( typeof(TProperty), Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata); @@ -214,7 +212,7 @@ public virtual PropertyBuilder IndexerProperty([NotNull] s /// The name of the property to be configured. /// An object that can be used to configure the property. public virtual PropertyBuilder IndexerProperty([NotNull] Type propertyType, [NotNull] string propertyName) - => new PropertyBuilder( + => new( Builder.IndexerProperty( Check.NotNull(propertyType, nameof(propertyType)), Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata); @@ -228,9 +226,7 @@ public virtual PropertyBuilder IndexerProperty([NotNull] Type propertyType, [Not /// The name of the navigation property to be configured. /// An object that can be used to configure the navigation property. public virtual NavigationBuilder Navigation([NotNull] string navigationName) - => new NavigationBuilder( - Builder.Navigation( - Check.NotEmpty(navigationName, nameof(navigationName)))); + => new(Builder.Navigation(Check.NotEmpty(navigationName, nameof(navigationName)))); /// /// Excludes the given property from the entity type. This method is typically used to remove properties @@ -268,8 +264,7 @@ public virtual EntityTypeBuilder HasQueryFilter([CanBeNull] LambdaExpression fil /// The names of the properties that make up the index. /// An object that can be used to configure the index. public virtual IndexBuilder HasIndex([NotNull] params string[] propertyNames) - => new IndexBuilder( - Builder.HasIndex(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); + => new(Builder.HasIndex(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); /// /// Configures an index on the specified properties and with the given name. @@ -282,7 +277,7 @@ public virtual IndexBuilder HasIndex([NotNull] params string[] propertyNames) public virtual IndexBuilder HasIndex( [NotNull] string[] propertyNames, [NotNull] string name) - => new IndexBuilder( + => new( Builder.HasIndex( Check.NotEmpty(propertyNames, nameof(propertyNames)), Check.NotEmpty(name, nameof(name)), diff --git a/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs b/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs index c3724d5fe48..26d86824ab2 100644 --- a/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs +++ b/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs @@ -54,7 +54,7 @@ public EntityTypeBuilder([NotNull] IMutableEntityType entityType) /// The name of the base type or to indicate no base type. /// The same builder instance so that multiple configuration calls can be chained. public new virtual EntityTypeBuilder HasBaseType([CanBeNull] string name) - => new EntityTypeBuilder(Builder.HasBaseType(name, ConfigurationSource.Explicit).Metadata); + => new(Builder.HasBaseType(name, ConfigurationSource.Explicit).Metadata); /// /// Sets the base type of this entity type in an inheritance hierarchy. @@ -62,7 +62,7 @@ public EntityTypeBuilder([NotNull] IMutableEntityType entityType) /// The base type or to indicate no base type. /// The same builder instance so that multiple configuration calls can be chained. public new virtual EntityTypeBuilder HasBaseType([CanBeNull] Type entityType) - => new EntityTypeBuilder(Builder.HasBaseType(entityType, ConfigurationSource.Explicit).Metadata); + => new(Builder.HasBaseType(entityType, ConfigurationSource.Explicit).Metadata); /// /// Sets the base type of this entity type in an inheritance hierarchy. @@ -97,7 +97,7 @@ public virtual KeyBuilder HasKey([NotNull] Expression> key /// The names of the properties that make up the primary key. /// An object that can be used to configure the primary key. public new virtual KeyBuilder HasKey([NotNull] params string[] propertyNames) - => new KeyBuilder( + => new( Builder.PrimaryKey( Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); @@ -118,7 +118,7 @@ public virtual KeyBuilder HasKey([NotNull] Expression> key /// /// An object that can be used to configure the key. public virtual KeyBuilder HasAlternateKey([NotNull] Expression> keyExpression) - => new KeyBuilder( + => new( Builder.HasKey( Check.NotNull(keyExpression, nameof(keyExpression)).GetMemberAccessList(), ConfigurationSource.Explicit).Metadata); @@ -132,7 +132,7 @@ public virtual KeyBuilder HasAlternateKey([NotNull] Expression The names of the properties that make up the key. /// An object that can be used to configure the key. public new virtual KeyBuilder HasAlternateKey([NotNull] params string[] propertyNames) - => new KeyBuilder( + => new( Builder.HasKey( Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); @@ -153,7 +153,7 @@ public virtual KeyBuilder HasAlternateKey([NotNull] Expression /// An object that can be used to configure the property. public virtual PropertyBuilder Property([NotNull] Expression> propertyExpression) - => new PropertyBuilder( + => new( Builder.Property( Check.NotNull(propertyExpression, nameof(propertyExpression)).GetMemberAccess(), ConfigurationSource.Explicit) .Metadata); @@ -171,7 +171,7 @@ public virtual PropertyBuilder Property([NotNull] Expressi public virtual NavigationBuilder Navigation( [NotNull] Expression> navigationExpression) where TNavigation : class - => new NavigationBuilder( + => new( Builder.Navigation( Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess())); @@ -188,7 +188,7 @@ public virtual NavigationBuilder Navigation( public virtual NavigationBuilder Navigation( [NotNull] Expression>> navigationExpression) where TNavigation : class - => new NavigationBuilder( + => new( Builder.Navigation( Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess())); @@ -262,7 +262,7 @@ public virtual EntityTypeBuilder ToQuery([NotNull] Expression /// An object that can be used to configure the index. public virtual IndexBuilder HasIndex([NotNull] Expression> indexExpression) - => new IndexBuilder( + => new( Builder.HasIndex( Check.NotNull(indexExpression, nameof(indexExpression)).GetMemberAccessList(), ConfigurationSource.Explicit).Metadata); @@ -287,7 +287,7 @@ public virtual IndexBuilder HasIndex([NotNull] Expression HasIndex( [NotNull] Expression> indexExpression, [NotNull] string name) - => new IndexBuilder( + => new( Builder.HasIndex( Check.NotNull(indexExpression, nameof(indexExpression)).GetMemberAccessList(), name, @@ -301,7 +301,7 @@ public virtual IndexBuilder HasIndex( /// The names of the properties that make up the index. /// An object that can be used to configure the index. public new virtual IndexBuilder HasIndex([NotNull] params string[] propertyNames) - => new IndexBuilder( + => new( Builder.HasIndex( Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); @@ -317,7 +317,7 @@ public virtual IndexBuilder HasIndex( public new virtual IndexBuilder HasIndex( [NotNull] string[] propertyNames, [NotNull] string name) - => new IndexBuilder( + => new( Builder.HasIndex( Check.NotEmpty(propertyNames, nameof(propertyNames)), name, diff --git a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs index edb4a20e0c8..0b3c7d525b0 100644 --- a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs +++ b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs @@ -127,7 +127,7 @@ public virtual OwnedNavigationBuilder HasAnnotation([NotNull] string annotation, /// The names of the properties that make up the primary key. /// An object that can be used to configure the primary key. public virtual KeyBuilder HasKey([NotNull] params string[] propertyNames) - => new KeyBuilder( + => new( DependentEntityType.Builder.PrimaryKey( Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); @@ -191,7 +191,7 @@ public virtual PropertyBuilder Property([NotNull] string p /// The name of the property to be configured. /// An object that can be used to configure the property. public virtual PropertyBuilder Property([NotNull] Type propertyType, [NotNull] string propertyName) - => new PropertyBuilder( + => new( DependentEntityType.Builder.Property( Check.NotNull(propertyType, nameof(propertyType)), Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata); @@ -211,7 +211,7 @@ public virtual PropertyBuilder Property([NotNull] Type propertyType, [NotNull] s /// The name of the property to be configured. /// An object that can be used to configure the property. public virtual PropertyBuilder IndexerProperty([NotNull] string propertyName) - => new PropertyBuilder( + => new( DependentEntityType.Builder.IndexerProperty( typeof(TProperty), Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata); @@ -231,7 +231,7 @@ public virtual PropertyBuilder IndexerProperty([NotNull] s /// The name of the property to be configured. /// An object that can be used to configure the property. public virtual PropertyBuilder IndexerProperty([NotNull] Type propertyType, [NotNull] string propertyName) - => new PropertyBuilder( + => new( DependentEntityType.Builder.IndexerProperty( Check.NotNull(propertyType, nameof(propertyType)), Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata); @@ -246,7 +246,7 @@ public virtual PropertyBuilder IndexerProperty([NotNull] Type propertyType, [Not /// The name of the navigation property to be configured. /// An object that can be used to configure the navigation property. public virtual NavigationBuilder Navigation([NotNull] string navigationName) - => new NavigationBuilder( + => new( DependentEntityType.Builder.Navigation( Check.NotEmpty(navigationName, nameof(navigationName)))); @@ -271,7 +271,7 @@ public virtual OwnedNavigationBuilder Ignore([NotNull] string propertyName) /// The names of the properties that make up the index. /// An object that can be used to configure the index. public virtual IndexBuilder HasIndex([NotNull] params string[] propertyNames) - => new IndexBuilder( + => new( DependentEntityType.Builder.HasIndex( Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); diff --git a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs index 83c5e506655..22d65c4a527 100644 --- a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs +++ b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs @@ -58,7 +58,7 @@ public OwnedNavigationBuilder([NotNull] IMutableForeignKey ownership) /// /// An object that can be used to configure the primary key. public virtual KeyBuilder HasKey([NotNull] Expression> keyExpression) - => new KeyBuilder( + => new( DependentEntityType.Builder.PrimaryKey( Check.NotNull(keyExpression, nameof(keyExpression)).GetMemberAccessList(), ConfigurationSource.Explicit).Metadata); @@ -68,7 +68,7 @@ public virtual KeyBuilder HasKey([NotNull] Expression The names of the properties that make up the primary key. /// An object that can be used to configure the primary key. public new virtual KeyBuilder HasKey([NotNull] params string[] propertyNames) - => new KeyBuilder( + => new( DependentEntityType.Builder.PrimaryKey( Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); @@ -115,7 +115,7 @@ public virtual PropertyBuilder Property( public virtual NavigationBuilder Navigation( [NotNull] Expression> navigationExpression) where TNavigation : class - => new NavigationBuilder( + => new( DependentEntityType.Builder.Navigation( Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess())); @@ -135,7 +135,7 @@ public virtual NavigationBuilder Navigation Navigation( [NotNull] Expression>> navigationExpression) where TNavigation : class - => new NavigationBuilder( + => new( DependentEntityType.Builder.Navigation( Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess())); @@ -178,7 +178,7 @@ public virtual OwnedNavigationBuilder Ignore( /// /// An object that can be used to configure the index. public virtual IndexBuilder HasIndex([NotNull] Expression> indexExpression) - => new IndexBuilder( + => new( DependentEntityType.Builder.HasIndex( Check.NotNull(indexExpression, nameof(indexExpression)).GetMemberAccessList(), ConfigurationSource.Explicit) .Metadata); @@ -190,7 +190,7 @@ public virtual IndexBuilder HasIndex([NotNull] Expression The names of the properties that make up the index. /// An object that can be used to configure the index. public new virtual IndexBuilder HasIndex([NotNull] params string[] propertyNames) - => new IndexBuilder( + => new( DependentEntityType.Builder.HasIndex( Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata); @@ -241,7 +241,7 @@ public virtual IndexBuilder HasIndex([NotNull] Expression An object that can be used to configure the relationship. public virtual OwnershipBuilder WithOwner( [CanBeNull] Expression> referenceExpression) - => new OwnershipBuilder( + => new( PrincipalEntityType, DependentEntityType, Builder.HasNavigation( diff --git a/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder.cs b/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder.cs index d9d14bb96c1..baaaf6e06ce 100644 --- a/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder.cs +++ b/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder.cs @@ -95,7 +95,7 @@ public virtual ReferenceCollectionBuilder HasAnnotation([NotNull] string annotat /// /// The same builder instance so that multiple configuration calls can be chained. public virtual ReferenceCollectionBuilder HasForeignKey([NotNull] params string[] foreignKeyPropertyNames) - => new ReferenceCollectionBuilder( + => new( HasForeignKeyBuilder(Check.NotEmpty(foreignKeyPropertyNames, nameof(foreignKeyPropertyNames))), this, foreignKeySet: true); @@ -129,7 +129,7 @@ protected virtual InternalForeignKeyBuilder HasForeignKeyBuilder([NotNull] IRead /// The name(s) of the referenced key property(s). /// The same builder instance so that multiple configuration calls can be chained. public virtual ReferenceCollectionBuilder HasPrincipalKey([NotNull] params string[] keyPropertyNames) - => new ReferenceCollectionBuilder( + => new( HasPrincipalKeyBuilder(Check.NotEmpty(keyPropertyNames, nameof(keyPropertyNames))), this, principalKeySet: true); @@ -161,7 +161,7 @@ protected virtual InternalForeignKeyBuilder HasPrincipalKeyBuilder([NotNull] IRe /// A value indicating whether this is a required relationship. /// The same builder instance so that multiple configuration calls can be chained. public virtual ReferenceCollectionBuilder IsRequired(bool required = true) - => new ReferenceCollectionBuilder( + => new( Builder.IsRequired(required, ConfigurationSource.Explicit), this, requiredSet: true); @@ -173,8 +173,6 @@ public virtual ReferenceCollectionBuilder IsRequired(bool required = true) /// The action to perform. /// The same builder instance so that multiple configuration calls can be chained. public virtual ReferenceCollectionBuilder OnDelete(DeleteBehavior deleteBehavior) - => new ReferenceCollectionBuilder( - Builder.OnDelete(deleteBehavior, ConfigurationSource.Explicit), - this); + => new(Builder.OnDelete(deleteBehavior, ConfigurationSource.Explicit), this); } } diff --git a/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder`.cs b/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder`.cs index 262917dbf8c..ffa6c144a84 100644 --- a/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder`.cs +++ b/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder`.cs @@ -82,7 +82,7 @@ protected ReferenceCollectionBuilder( /// The same builder instance so that multiple configuration calls can be chained. public new virtual ReferenceCollectionBuilder HasForeignKey( [NotNull] params string[] foreignKeyPropertyNames) - => new ReferenceCollectionBuilder( + => new( HasForeignKeyBuilder(Check.NotEmpty(foreignKeyPropertyNames, nameof(foreignKeyPropertyNames))), this, foreignKeySet: true); @@ -114,7 +114,7 @@ protected ReferenceCollectionBuilder( /// The same builder instance so that multiple configuration calls can be chained. public virtual ReferenceCollectionBuilder HasForeignKey( [NotNull] Expression> foreignKeyExpression) - => new ReferenceCollectionBuilder( + => new( HasForeignKeyBuilder(Check.NotNull(foreignKeyExpression, nameof(foreignKeyExpression)).GetMemberAccessList()), this, foreignKeySet: true); @@ -129,7 +129,7 @@ public virtual ReferenceCollectionBuilder Ha /// The same builder instance so that multiple configuration calls can be chained. public new virtual ReferenceCollectionBuilder HasPrincipalKey( [NotNull] params string[] keyPropertyNames) - => new ReferenceCollectionBuilder( + => new( HasPrincipalKeyBuilder(Check.NotEmpty(keyPropertyNames, nameof(keyPropertyNames))), this, principalKeySet: true); @@ -153,7 +153,7 @@ public virtual ReferenceCollectionBuilder Ha /// The same builder instance so that multiple configuration calls can be chained. public virtual ReferenceCollectionBuilder HasPrincipalKey( [NotNull] Expression> keyExpression) - => new ReferenceCollectionBuilder( + => new( HasPrincipalKeyBuilder(Check.NotNull(keyExpression, nameof(keyExpression)).GetMemberAccessList()), this, principalKeySet: true); @@ -179,8 +179,7 @@ public virtual ReferenceCollectionBuilder Ha /// A value indicating whether this is a required relationship. /// The same builder instance so that multiple configuration calls can be chained. public new virtual ReferenceCollectionBuilder IsRequired(bool required = true) - => new ReferenceCollectionBuilder( - Builder.IsRequired(required, ConfigurationSource.Explicit), this, requiredSet: true); + => new(Builder.IsRequired(required, ConfigurationSource.Explicit), this, requiredSet: true); /// /// Configures the operation applied to dependent entities in the relationship when the @@ -189,7 +188,6 @@ public virtual ReferenceCollectionBuilder Ha /// The action to perform. /// The same builder instance so that multiple configuration calls can be chained. public new virtual ReferenceCollectionBuilder OnDelete(DeleteBehavior deleteBehavior) - => new ReferenceCollectionBuilder( - Builder.OnDelete(deleteBehavior, ConfigurationSource.Explicit), this); + => new(Builder.OnDelete(deleteBehavior, ConfigurationSource.Explicit), this); } } diff --git a/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder.cs b/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder.cs index 3780fb8fbd6..7a3956cb676 100644 --- a/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder.cs +++ b/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder.cs @@ -133,7 +133,7 @@ IConventionForeignKeyBuilder IInfrastructure.Insta /// An object to further configure the relationship. public virtual ReferenceCollectionBuilder WithMany([CanBeNull] string collection = null) { - return new ReferenceCollectionBuilder( + return new( RelatedEntityType, DeclaringEntityType, WithManyBuilder(Check.NullButNotEmpty(collection, nameof(collection))).Metadata); @@ -207,7 +207,7 @@ private InternalForeignKeyBuilder WithManyBuilder(MemberIdentity collection) /// /// An object that can be used to configure the relationship. public virtual ReferenceReferenceBuilder WithOne([CanBeNull] string reference = null) - => new ReferenceReferenceBuilder( + => new( DeclaringEntityType, RelatedEntityType, WithOneBuilder(Check.NullButNotEmpty(reference, nameof(reference))).Metadata); diff --git a/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder`.cs b/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder`.cs index 6a081e3d27c..90877d4f806 100644 --- a/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder`.cs +++ b/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder`.cs @@ -77,7 +77,7 @@ public ReferenceNavigationBuilder( public new virtual ReferenceCollectionBuilder WithMany( [CanBeNull] string navigationName = null) { - return new ReferenceCollectionBuilder( + return new( RelatedEntityType, DeclaringEntityType, WithManyBuilder( @@ -103,7 +103,7 @@ public ReferenceNavigationBuilder( public virtual ReferenceCollectionBuilder WithMany( [CanBeNull] Expression>> navigationExpression) { - return new ReferenceCollectionBuilder( + return new( RelatedEntityType, DeclaringEntityType, WithManyBuilder(navigationExpression?.GetMemberAccess()).Metadata); @@ -126,7 +126,7 @@ public virtual ReferenceCollectionBuilder WithMany( /// An object to further configure the relationship. public new virtual ReferenceReferenceBuilder WithOne( [CanBeNull] string navigationName = null) - => new ReferenceReferenceBuilder( + => new( DeclaringEntityType, RelatedEntityType, WithOneBuilder( @@ -150,7 +150,7 @@ public virtual ReferenceCollectionBuilder WithMany( /// An object to further configure the relationship. public virtual ReferenceReferenceBuilder WithOne( [CanBeNull] Expression> navigationExpression) - => new ReferenceReferenceBuilder( + => new( DeclaringEntityType, RelatedEntityType, WithOneBuilder(navigationExpression?.GetMemberAccess()).Metadata); diff --git a/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder.cs b/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder.cs index 0bd6eca3a73..7c9c5049b7c 100644 --- a/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder.cs +++ b/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder.cs @@ -100,7 +100,7 @@ public virtual ReferenceReferenceBuilder HasAnnotation([NotNull] string annotati public virtual ReferenceReferenceBuilder HasForeignKey( [NotNull] string dependentEntityTypeName, [NotNull] params string[] foreignKeyPropertyNames) - => new ReferenceReferenceBuilder( + => new( HasForeignKeyBuilder( ResolveEntityType(Check.NotNull(dependentEntityTypeName, nameof(dependentEntityTypeName))), dependentEntityTypeName, @@ -138,7 +138,7 @@ public virtual ReferenceReferenceBuilder HasForeignKey( public virtual ReferenceReferenceBuilder HasForeignKey( [NotNull] Type dependentEntityType, [NotNull] params string[] foreignKeyPropertyNames) - => new ReferenceReferenceBuilder( + => new( HasForeignKeyBuilder( ResolveEntityType(Check.NotNull(dependentEntityType, nameof(dependentEntityType))), dependentEntityType.ShortDisplayName(), @@ -219,7 +219,7 @@ private InternalForeignKeyBuilder HasForeignKeyBuilder( public virtual ReferenceReferenceBuilder HasPrincipalKey( [NotNull] string principalEntityTypeName, [NotNull] params string[] keyPropertyNames) - => new ReferenceReferenceBuilder( + => new( HasPrincipalKeyBuilder( ResolveEntityType(Check.NotEmpty(principalEntityTypeName, nameof(principalEntityTypeName))), principalEntityTypeName, @@ -248,7 +248,7 @@ public virtual ReferenceReferenceBuilder HasPrincipalKey( public virtual ReferenceReferenceBuilder HasPrincipalKey( [NotNull] Type principalEntityType, [NotNull] params string[] keyPropertyNames) - => new ReferenceReferenceBuilder( + => new( HasPrincipalKeyBuilder( ResolveEntityType(Check.NotNull(principalEntityType, nameof(principalEntityType))), principalEntityType.ShortDisplayName(), @@ -376,7 +376,7 @@ private EntityType GetOtherEntityType(EntityType entityType) /// A value indicating whether this is a required relationship. /// The same builder instance so that multiple configuration calls can be chained. public virtual ReferenceReferenceBuilder IsRequired(bool required = true) - => new ReferenceReferenceBuilder(Builder.IsRequired(required, ConfigurationSource.Explicit), this, requiredSet: true); + => new(Builder.IsRequired(required, ConfigurationSource.Explicit), this, requiredSet: true); /// /// Configures the operation applied to dependent entities in the relationship when the @@ -385,6 +385,6 @@ public virtual ReferenceReferenceBuilder IsRequired(bool required = true) /// The action to perform. /// The same builder instance so that multiple configuration calls can be chained. public virtual ReferenceReferenceBuilder OnDelete(DeleteBehavior deleteBehavior) - => new ReferenceReferenceBuilder(Builder.OnDelete(deleteBehavior, ConfigurationSource.Explicit), this); + => new(Builder.OnDelete(deleteBehavior, ConfigurationSource.Explicit), this); } } diff --git a/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder`.cs b/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder`.cs index 73aca88aad8..ef6f35f1997 100644 --- a/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder`.cs +++ b/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder`.cs @@ -94,7 +94,7 @@ protected ReferenceReferenceBuilder( public new virtual ReferenceReferenceBuilder HasForeignKey( [NotNull] string dependentEntityTypeName, [NotNull] params string[] foreignKeyPropertyNames) - => new ReferenceReferenceBuilder( + => new( HasForeignKeyBuilder( ResolveEntityType(Check.NotNull(dependentEntityTypeName, nameof(dependentEntityTypeName))), dependentEntityTypeName, @@ -132,7 +132,7 @@ protected ReferenceReferenceBuilder( public new virtual ReferenceReferenceBuilder HasForeignKey( [NotNull] Type dependentEntityType, [NotNull] params string[] foreignKeyPropertyNames) - => new ReferenceReferenceBuilder( + => new( HasForeignKeyBuilder( ResolveEntityType(Check.NotNull(dependentEntityType, nameof(dependentEntityType))), dependentEntityType.ShortDisplayName(), @@ -208,7 +208,7 @@ public virtual ReferenceReferenceBuilder HasForeignKey< public virtual ReferenceReferenceBuilder HasForeignKey( [NotNull] Expression> foreignKeyExpression) where TDependentEntity : class - => new ReferenceReferenceBuilder( + => new( HasForeignKeyBuilder( ResolveEntityType(typeof(TDependentEntity)), typeof(TDependentEntity).ShortDisplayName(), @@ -232,7 +232,7 @@ public virtual ReferenceReferenceBuilder HasForeignKey< public new virtual ReferenceReferenceBuilder HasPrincipalKey( [NotNull] string principalEntityTypeName, [NotNull] params string[] keyPropertyNames) - => new ReferenceReferenceBuilder( + => new( HasPrincipalKeyBuilder( ResolveEntityType(Check.NotEmpty(principalEntityTypeName, nameof(principalEntityTypeName))), principalEntityTypeName, @@ -256,7 +256,7 @@ public virtual ReferenceReferenceBuilder HasForeignKey< public new virtual ReferenceReferenceBuilder HasPrincipalKey( [NotNull] Type principalEntityType, [NotNull] params string[] keyPropertyNames) - => new ReferenceReferenceBuilder( + => new( HasPrincipalKeyBuilder( ResolveEntityType(Check.NotNull(principalEntityType, nameof(principalEntityType))), principalEntityType.ShortDisplayName(), @@ -311,7 +311,7 @@ public virtual ReferenceReferenceBuilder HasPrincipalKe public virtual ReferenceReferenceBuilder HasPrincipalKey( [NotNull] Expression> keyExpression) where TPrincipalEntity : class - => new ReferenceReferenceBuilder( + => new( HasPrincipalKeyBuilder( ResolveEntityType(typeof(TPrincipalEntity)), typeof(TPrincipalEntity).ShortDisplayName(), @@ -327,7 +327,7 @@ public virtual ReferenceReferenceBuilder HasPrincipalKe /// A value indicating whether this is a required relationship. /// The same builder instance so that multiple configuration calls can be chained. public new virtual ReferenceReferenceBuilder IsRequired(bool required = true) - => new ReferenceReferenceBuilder( + => new( Builder.IsRequired(required, ConfigurationSource.Explicit), this, requiredSet: true); @@ -339,7 +339,6 @@ public virtual ReferenceReferenceBuilder HasPrincipalKe /// The action to perform. /// The same builder instance so that multiple configuration calls can be chained. public new virtual ReferenceReferenceBuilder OnDelete(DeleteBehavior deleteBehavior) - => new ReferenceReferenceBuilder( - Builder.OnDelete(deleteBehavior, ConfigurationSource.Explicit), this); + => new(Builder.OnDelete(deleteBehavior, ConfigurationSource.Explicit), this); } } diff --git a/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs b/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs index d015fcde550..d8daf10c530 100644 --- a/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs +++ b/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs @@ -155,7 +155,7 @@ public Type ContextType /// A replacement for the current dependency of this type. /// A new parameter object with the given service replaced. public ProviderConventionSetBuilderDependencies With([NotNull] ICurrentDbContext currentContext) - => new ProviderConventionSetBuilderDependencies( + => new( TypeMappingSource, ConstructorBindingFactory, ParameterBindingFactories, MemberClassifier, Logger, ValidationLogger, SetFinder, currentContext, ModelValidator); } diff --git a/src/EFCore/Metadata/Conventions/Internal/MetadataTracker.cs b/src/EFCore/Metadata/Conventions/Internal/MetadataTracker.cs index 3135f8f9710..43db35eb781 100644 --- a/src/EFCore/Metadata/Conventions/Internal/MetadataTracker.cs +++ b/src/EFCore/Metadata/Conventions/Internal/MetadataTracker.cs @@ -16,8 +16,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal /// public class MetadataTracker : IReferenceRoot { - private readonly Dictionary> _trackedForeignKeys = - new Dictionary>(); + private readonly Dictionary> _trackedForeignKeys = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Conventions/NonNullableConventionBase.cs b/src/EFCore/Metadata/Conventions/NonNullableConventionBase.cs index eff4a3d30da..4e588dd0bca 100644 --- a/src/EFCore/Metadata/Conventions/NonNullableConventionBase.cs +++ b/src/EFCore/Metadata/Conventions/NonNullableConventionBase.cs @@ -157,7 +157,7 @@ private sealed class NonNullabilityConventionState public Type NullableContextAttrType; public FieldInfo NullableFlagsFieldInfo; public FieldInfo NullableContextFlagFieldInfo; - public Dictionary TypeCache { get; } = new Dictionary(); + public Dictionary TypeCache { get; } = new(); } } } diff --git a/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs b/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs index 224db55e53a..42d6812fbd7 100644 --- a/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs +++ b/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs @@ -1101,7 +1101,7 @@ private static void SetAmbiguousNavigations( private sealed class MemberInfoNameComparer : IComparer { - public static readonly MemberInfoNameComparer Instance = new MemberInfoNameComparer(); + public static readonly MemberInfoNameComparer Instance = new(); private MemberInfoNameComparer() { diff --git a/src/EFCore/Metadata/EntityTypeFullNameComparer.cs b/src/EFCore/Metadata/EntityTypeFullNameComparer.cs index 57f03e7ddb1..0919a88ca7d 100644 --- a/src/EFCore/Metadata/EntityTypeFullNameComparer.cs +++ b/src/EFCore/Metadata/EntityTypeFullNameComparer.cs @@ -27,7 +27,7 @@ private EntityTypeFullNameComparer() /// /// The singleton instance of the comparer to use. /// - public static readonly EntityTypeFullNameComparer Instance = new EntityTypeFullNameComparer(); + public static readonly EntityTypeFullNameComparer Instance = new(); /// /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other. diff --git a/src/EFCore/Metadata/ForeignKeyComparer.cs b/src/EFCore/Metadata/ForeignKeyComparer.cs index 447d4624e59..68c517c45c0 100644 --- a/src/EFCore/Metadata/ForeignKeyComparer.cs +++ b/src/EFCore/Metadata/ForeignKeyComparer.cs @@ -28,7 +28,7 @@ private ForeignKeyComparer() /// /// The singleton instance of the comparer to use. /// - public static readonly ForeignKeyComparer Instance = new ForeignKeyComparer(); + public static readonly ForeignKeyComparer Instance = new(); /// /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other. diff --git a/src/EFCore/Metadata/IndexComparer.cs b/src/EFCore/Metadata/IndexComparer.cs index e270875f8a8..fadad5c1963 100644 --- a/src/EFCore/Metadata/IndexComparer.cs +++ b/src/EFCore/Metadata/IndexComparer.cs @@ -28,7 +28,7 @@ private IndexComparer() /// /// The singleton instance of the comparer to use. /// - public static readonly IndexComparer Instance = new IndexComparer(); + public static readonly IndexComparer Instance = new(); /// /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other. diff --git a/src/EFCore/Metadata/Internal/EntityType.cs b/src/EFCore/Metadata/Internal/EntityType.cs index 8cc801167c1..47ebc74e0d0 100644 --- a/src/EFCore/Metadata/Internal/EntityType.cs +++ b/src/EFCore/Metadata/Internal/EntityType.cs @@ -33,27 +33,27 @@ public class EntityType : TypeBase, IMutableEntityType, IConventionEntityType private const string DynamicProxyGenAssemblyName = "DynamicProxyGenAssembly2"; private readonly SortedSet _foreignKeys - = new SortedSet(ForeignKeyComparer.Instance); + = new(ForeignKeyComparer.Instance); private readonly SortedDictionary _navigations - = new SortedDictionary(StringComparer.Ordinal); + = new(StringComparer.Ordinal); private readonly SortedDictionary _skipNavigations - = new SortedDictionary(StringComparer.Ordinal); + = new(StringComparer.Ordinal); private readonly SortedDictionary, Index> _unnamedIndexes - = new SortedDictionary, Index>(PropertyListComparer.Instance); + = new(PropertyListComparer.Instance); private readonly SortedDictionary _namedIndexes - = new SortedDictionary(StringComparer.Ordinal); + = new(StringComparer.Ordinal); private readonly SortedDictionary _properties; private readonly SortedDictionary, Key> _keys - = new SortedDictionary, Key>(PropertyListComparer.Instance); + = new(PropertyListComparer.Instance); private readonly SortedDictionary _serviceProperties - = new SortedDictionary(StringComparer.Ordinal); + = new(StringComparer.Ordinal); private List? _data; private Key? _primaryKey; @@ -361,7 +361,7 @@ public virtual void OnTypeRemoved() private void UpdateBaseTypeConfigurationSource(ConfigurationSource configurationSource) => _baseTypeConfigurationSource = configurationSource.Max(_baseTypeConfigurationSource); - private readonly SortedSet _directlyDerivedTypes = new SortedSet(EntityTypeFullNameComparer.Instance); + private readonly SortedSet _directlyDerivedTypes = new(EntityTypeFullNameComparer.Instance); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4250,7 +4250,7 @@ public virtual void Attach([NotNull] InternalEntityTypeBuilder entityTypeBuilder /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault), () => this.ToDebugString(MetadataDebugStringOptions.LongDefault)); } diff --git a/src/EFCore/Metadata/Internal/ForeignKey.cs b/src/EFCore/Metadata/Internal/ForeignKey.cs index 5e07e77d5b0..9ef2ccd365e 100644 --- a/src/EFCore/Metadata/Internal/ForeignKey.cs +++ b/src/EFCore/Metadata/Internal/ForeignKey.cs @@ -1184,7 +1184,7 @@ IEnumerable IForeignKey.GetReferencingSkipNavigations() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault), () => this.ToDebugString(MetadataDebugStringOptions.LongDefault)); diff --git a/src/EFCore/Metadata/Internal/Index.cs b/src/EFCore/Metadata/Internal/Index.cs index c599dce1bee..df32602e7a5 100644 --- a/src/EFCore/Metadata/Internal/Index.cs +++ b/src/EFCore/Metadata/Internal/Index.cs @@ -219,7 +219,7 @@ public override string ToString() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault), () => this.ToDebugString(MetadataDebugStringOptions.LongDefault)); diff --git a/src/EFCore/Metadata/Internal/Key.cs b/src/EFCore/Metadata/Internal/Key.cs index 3f39a4e5b67..68362f5aa5f 100644 --- a/src/EFCore/Metadata/Internal/Key.cs +++ b/src/EFCore/Metadata/Internal/Key.cs @@ -173,7 +173,7 @@ public override string ToString() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault), () => this.ToDebugString(MetadataDebugStringOptions.LongDefault)); diff --git a/src/EFCore/Metadata/Internal/Model.cs b/src/EFCore/Metadata/Internal/Model.cs index 54069803b2f..4a92d8dee1f 100644 --- a/src/EFCore/Metadata/Internal/Model.cs +++ b/src/EFCore/Metadata/Internal/Model.cs @@ -43,20 +43,19 @@ public class Model : ConventionAnnotatable, IMutableModel, IConventionModel public static readonly Type DefaultPropertyBagType = typeof(Dictionary); private readonly SortedDictionary _entityTypes - = new SortedDictionary(StringComparer.Ordinal); + = new(StringComparer.Ordinal); private readonly ConcurrentDictionary _indexerPropertyInfoMap - = new ConcurrentDictionary(); + = new(); private readonly ConcurrentDictionary _clrTypeNameMap - = new ConcurrentDictionary(); + = new(); private readonly Dictionary _ignoredTypeNames - = new Dictionary(StringComparer.Ordinal); + = new(StringComparer.Ordinal); private readonly Dictionary Types)> _sharedTypes = - new Dictionary)> - { { DefaultPropertyBagType, (ConfigurationSource.Convention, new SortedSet(EntityTypeFullNameComparer.Instance)) } }; + new() { { DefaultPropertyBagType, (ConfigurationSource.Convention, new SortedSet(EntityTypeFullNameComparer.Instance)) } }; private bool? _skipDetectChanges; private ChangeTrackingStrategy? _changeTrackingStrategy; @@ -929,7 +928,7 @@ public virtual object? RelationalModel /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault), () => this.ToDebugString(MetadataDebugStringOptions.LongDefault)); diff --git a/src/EFCore/Metadata/Internal/Navigation.cs b/src/EFCore/Metadata/Internal/Navigation.cs index 6a58a7559b9..e78150079ba 100644 --- a/src/EFCore/Metadata/Internal/Navigation.cs +++ b/src/EFCore/Metadata/Internal/Navigation.cs @@ -305,7 +305,7 @@ public override string ToString() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault), () => this.ToDebugString(MetadataDebugStringOptions.LongDefault)); diff --git a/src/EFCore/Metadata/Internal/Property.cs b/src/EFCore/Metadata/Internal/Property.cs index 0814ec1a94d..01f3d5ff063 100644 --- a/src/EFCore/Metadata/Internal/Property.cs +++ b/src/EFCore/Metadata/Internal/Property.cs @@ -662,7 +662,7 @@ public override string ToString() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault), () => this.ToDebugString(MetadataDebugStringOptions.LongDefault)); diff --git a/src/EFCore/Metadata/Internal/PropertyListComparer.cs b/src/EFCore/Metadata/Internal/PropertyListComparer.cs index 94bba3e0da5..c0e92cd33a9 100644 --- a/src/EFCore/Metadata/Internal/PropertyListComparer.cs +++ b/src/EFCore/Metadata/Internal/PropertyListComparer.cs @@ -23,7 +23,7 @@ public sealed class PropertyListComparer : IComparer>, /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static readonly PropertyListComparer Instance = new PropertyListComparer(); + public static readonly PropertyListComparer Instance = new(); private PropertyListComparer() { diff --git a/src/EFCore/Metadata/Internal/ServiceProperty.cs b/src/EFCore/Metadata/Internal/ServiceProperty.cs index acfded8a81f..e77ff698bd6 100644 --- a/src/EFCore/Metadata/Internal/ServiceProperty.cs +++ b/src/EFCore/Metadata/Internal/ServiceProperty.cs @@ -210,7 +210,7 @@ public override string ToString() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault), () => this.ToDebugString(MetadataDebugStringOptions.LongDefault)); } diff --git a/src/EFCore/Metadata/Internal/SkipNavigation.cs b/src/EFCore/Metadata/Internal/SkipNavigation.cs index 245d4e81d85..c6d0c19c0a3 100644 --- a/src/EFCore/Metadata/Internal/SkipNavigation.cs +++ b/src/EFCore/Metadata/Internal/SkipNavigation.cs @@ -344,7 +344,7 @@ public virtual ICollectionLoader ManyToManyLoader /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DebugView DebugView - => new DebugView( + => new( () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault), () => this.ToDebugString(MetadataDebugStringOptions.LongDefault)); diff --git a/src/EFCore/Metadata/Internal/SkipNavigationComparer.cs b/src/EFCore/Metadata/Internal/SkipNavigationComparer.cs index 61f5d21eb39..1befacce4ec 100644 --- a/src/EFCore/Metadata/Internal/SkipNavigationComparer.cs +++ b/src/EFCore/Metadata/Internal/SkipNavigationComparer.cs @@ -26,7 +26,7 @@ private SkipNavigationComparer() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static readonly SkipNavigationComparer Instance = new SkipNavigationComparer(); + public static readonly SkipNavigationComparer Instance = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Internal/TypeBase.cs b/src/EFCore/Metadata/Internal/TypeBase.cs index 70f50106ef9..032587a6797 100644 --- a/src/EFCore/Metadata/Internal/TypeBase.cs +++ b/src/EFCore/Metadata/Internal/TypeBase.cs @@ -28,7 +28,7 @@ public abstract class TypeBase : ConventionAnnotatable, IMutableTypeBase, IConve private ConfigurationSource _configurationSource; private readonly Dictionary _ignoredMembers - = new Dictionary(StringComparer.Ordinal); + = new(StringComparer.Ordinal); private bool _indexerPropertyInitialized; private PropertyInfo? _indexerPropertyInfo; diff --git a/src/EFCore/Metadata/KeyComparer.cs b/src/EFCore/Metadata/KeyComparer.cs index 42e39c7a440..64c19618055 100644 --- a/src/EFCore/Metadata/KeyComparer.cs +++ b/src/EFCore/Metadata/KeyComparer.cs @@ -28,7 +28,7 @@ private KeyComparer() /// /// The singleton instance of the comparer to use. /// - public static readonly KeyComparer Instance = new KeyComparer(); + public static readonly KeyComparer Instance = new(); /// /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other. diff --git a/src/EFCore/Metadata/MemberIdentity.cs b/src/EFCore/Metadata/MemberIdentity.cs index 7d8d8e8f3d9..57d012ad575 100644 --- a/src/EFCore/Metadata/MemberIdentity.cs +++ b/src/EFCore/Metadata/MemberIdentity.cs @@ -55,7 +55,7 @@ public bool IsNone() /// /// A instance that does not represent any member. /// - public static readonly MemberIdentity None = new MemberIdentity((object?)null); + public static readonly MemberIdentity None = new((object?)null); /// /// Creates a new from the given member name. diff --git a/src/EFCore/ModelBuilder.cs b/src/EFCore/ModelBuilder.cs index fa984aa97fb..5261de4a36a 100644 --- a/src/EFCore/ModelBuilder.cs +++ b/src/EFCore/ModelBuilder.cs @@ -132,7 +132,7 @@ IConventionModelBuilder IInfrastructure.Instance /// An object that can be used to configure the entity type. public virtual EntityTypeBuilder Entity() where TEntity : class - => new EntityTypeBuilder(Builder.Entity(typeof(TEntity), ConfigurationSource.Explicit).Metadata); + => new(Builder.Entity(typeof(TEntity), ConfigurationSource.Explicit).Metadata); /// /// diff --git a/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs b/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs index 3f97e5554f3..7fc0b7a2f67 100644 --- a/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs +++ b/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs @@ -62,7 +62,7 @@ public virtual object GenerateCacheKey(Expression query, bool async) /// A value indicating whether the query will be executed asynchronously. /// The cache key. protected CompiledQueryCacheKey GenerateCacheKeyCore([NotNull] Expression query, bool async) // Intentionally non-virtual - => new CompiledQueryCacheKey( + => new( Check.NotNull(query, nameof(query)), Dependencies.Model, Dependencies.CurrentContext.Context.ChangeTracker.QueryTrackingBehavior, diff --git a/src/EFCore/Query/ExpressionEqualityComparer.cs b/src/EFCore/Query/ExpressionEqualityComparer.cs index 2c98d146070..07b4d4814f5 100644 --- a/src/EFCore/Query/ExpressionEqualityComparer.cs +++ b/src/EFCore/Query/ExpressionEqualityComparer.cs @@ -30,7 +30,7 @@ private ExpressionEqualityComparer() /// /// Gets an instance of . /// - public static ExpressionEqualityComparer Instance { get; } = new ExpressionEqualityComparer(); + public static ExpressionEqualityComparer Instance { get; } = new(); /// /// Returns the hash code for given expression. diff --git a/src/EFCore/Query/ExpressionPrinter.cs b/src/EFCore/Query/ExpressionPrinter.cs index 1d63c1d5482..9c384be674f 100644 --- a/src/EFCore/Query/ExpressionPrinter.cs +++ b/src/EFCore/Query/ExpressionPrinter.cs @@ -29,7 +29,7 @@ namespace Microsoft.EntityFrameworkCore.Query /// public class ExpressionPrinter : ExpressionVisitor { - private static readonly List _simpleMethods = new List + private static readonly List _simpleMethods = new() { "get_Item", "TryReadValue", @@ -41,7 +41,7 @@ public class ExpressionPrinter : ExpressionVisitor private readonly List _namelessParameters; private readonly List _encounteredParameters; - private readonly Dictionary _binaryOperandMap = new Dictionary + private readonly Dictionary _binaryOperandMap = new() { { ExpressionType.Assign, " = " }, { ExpressionType.Equal, " == " }, diff --git a/src/EFCore/Query/Internal/CompiledQueryCache.cs b/src/EFCore/Query/Internal/CompiledQueryCache.cs index 5609a6c8862..27eb587a213 100644 --- a/src/EFCore/Query/Internal/CompiledQueryCache.cs +++ b/src/EFCore/Query/Internal/CompiledQueryCache.cs @@ -27,8 +27,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal /// public class CompiledQueryCache : ICompiledQueryCache { - private static readonly ConcurrentDictionary _locks - = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary _locks = new(); private readonly IMemoryCache _memoryCache; diff --git a/src/EFCore/Query/Internal/EntityQueryable`.cs b/src/EFCore/Query/Internal/EntityQueryable`.cs index 3b5acab127f..d0c18b2fed9 100644 --- a/src/EFCore/Query/Internal/EntityQueryable`.cs +++ b/src/EFCore/Query/Internal/EntityQueryable`.cs @@ -139,6 +139,6 @@ bool IListSource.ContainsListCollection /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual QueryDebugView DebugView - => new QueryDebugView(() => Expression.Print(), this.ToQueryString); + => new(() => Expression.Print(), this.ToQueryString); } } diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs index 288bb8971ab..2d3ac7009a3 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs @@ -211,8 +211,7 @@ public override int GetHashCode() /// private sealed class NavigationExpansionExpression : Expression, IPrintableExpression { - private readonly List<(MethodInfo OrderingMethod, Expression KeySelector)> _pendingOrderings - = new List<(MethodInfo OrderingMethod, Expression KeySelector)>(); + private readonly List<(MethodInfo OrderingMethod, Expression KeySelector)> _pendingOrderings = new(); private readonly string _parameterName; diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs index f97a3f607c7..698b01cd09e 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs @@ -30,7 +30,7 @@ public partial class NavigationExpandingExpressionVisitor : ExpressionVisitor private static readonly PropertyInfo _queryContextContextPropertyInfo = typeof(QueryContext).GetRequiredDeclaredProperty(nameof(QueryContext.Context)); - private static readonly Dictionary _predicateLessMethodInfo = new Dictionary + private static readonly Dictionary _predicateLessMethodInfo = new() { { QueryableMethods.FirstWithPredicate, QueryableMethods.FirstWithoutPredicate }, { QueryableMethods.FirstOrDefaultWithPredicate, QueryableMethods.FirstOrDefaultWithoutPredicate }, @@ -40,7 +40,7 @@ private static readonly PropertyInfo _queryContextContextPropertyInfo { QueryableMethods.LastOrDefaultWithPredicate, QueryableMethods.LastOrDefaultWithoutPredicate } }; - private static readonly List _supportedFilteredIncludeOperations = new List + private static readonly List _supportedFilteredIncludeOperations = new() { QueryableMethods.Where, QueryableMethods.OrderBy, @@ -60,14 +60,14 @@ private static readonly PropertyInfo _queryContextContextPropertyInfo private readonly ReducingExpressionVisitor _reducingExpressionVisitor; private readonly EntityReferenceOptionalMarkingExpressionVisitor _entityReferenceOptionalMarkingExpressionVisitor; private readonly RemoveRedundantNavigationComparisonExpressionVisitor _removeRedundantNavigationComparisonExpressionVisitor; - private readonly HashSet _parameterNames = new HashSet(); + private readonly HashSet _parameterNames = new(); private readonly ParameterExtractingExpressionVisitor _parameterExtractingExpressionVisitor; private readonly HashSet _nonCyclicAutoIncludeEntityTypes; private readonly Dictionary _parameterizedQueryFilterPredicateCache - = new Dictionary(); + = new(); - private readonly Parameters _parameters = new Parameters(); + private readonly Parameters _parameters = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Query/Internal/NullCheckRemovingExpressionVisitor.cs b/src/EFCore/Query/Internal/NullCheckRemovingExpressionVisitor.cs index 0d32a09a6c0..81e03d9f015 100644 --- a/src/EFCore/Query/Internal/NullCheckRemovingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/NullCheckRemovingExpressionVisitor.cs @@ -19,7 +19,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal public class NullCheckRemovingExpressionVisitor : ExpressionVisitor { private readonly NullSafeAccessVerifyingExpressionVisitor _nullSafeAccessVerifyingExpressionVisitor - = new NullSafeAccessVerifyingExpressionVisitor(); + = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Query/Internal/ParameterExtractingExpressionVisitor.cs b/src/EFCore/Query/Internal/ParameterExtractingExpressionVisitor.cs index 80650ae92a6..6ff016f902e 100644 --- a/src/EFCore/Query/Internal/ParameterExtractingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/ParameterExtractingExpressionVisitor.cs @@ -34,8 +34,7 @@ public class ParameterExtractingExpressionVisitor : ExpressionVisitor private readonly EvaluatableExpressionFindingExpressionVisitor _evaluatableExpressionFindingExpressionVisitor; private readonly ContextParameterReplacingExpressionVisitor _contextParameterReplacingExpressionVisitor; - private readonly Dictionary _evaluatedValues - = new Dictionary(ExpressionEqualityComparer.Instance); + private readonly Dictionary _evaluatedValues = new(ExpressionEqualityComparer.Instance); private IDictionary _evaluatableExpressions; private IQueryProvider? _currentQueryProvider; diff --git a/src/EFCore/Query/Internal/QueryCompilationContextFactory.cs b/src/EFCore/Query/Internal/QueryCompilationContextFactory.cs index 109b3a34f14..f8ae0007d80 100644 --- a/src/EFCore/Query/Internal/QueryCompilationContextFactory.cs +++ b/src/EFCore/Query/Internal/QueryCompilationContextFactory.cs @@ -47,6 +47,6 @@ public QueryCompilationContextFactory([NotNull] QueryCompilationContextDependenc /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual QueryCompilationContext Create(bool async) - => new QueryCompilationContext(_dependencies, async); + => new(_dependencies, async); } } diff --git a/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs b/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs index f5de05a329f..15571ccaee3 100644 --- a/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs @@ -27,8 +27,7 @@ public class QueryableMethodNormalizingExpressionVisitor : ExpressionVisitor { private readonly QueryCompilationContext _queryCompilationContext; - private readonly SelectManyVerifyingExpressionVisitor _selectManyVerifyingExpressionVisitor - = new SelectManyVerifyingExpressionVisitor(); + private readonly SelectManyVerifyingExpressionVisitor _selectManyVerifyingExpressionVisitor = new(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -636,7 +635,7 @@ private Expression TryFlattenGroupJoinSelectMany(MethodCallExpression methodCall private sealed class SelectManyVerifyingExpressionVisitor : ExpressionVisitor { - private readonly List _allowedParameters = new List(); + private readonly List _allowedParameters = new(); private readonly ISet _allowedMethods = new HashSet { nameof(Queryable.Where), nameof(Queryable.AsQueryable) }; private ParameterExpression? _rootParameter; diff --git a/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs b/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs index 70e15da3440..06760a798f8 100644 --- a/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs @@ -22,7 +22,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal /// public class SubqueryMemberPushdownExpressionVisitor : ExpressionVisitor { - private static readonly List _supportedMethods = new List + private static readonly List _supportedMethods = new() { QueryableMethods.FirstWithPredicate, QueryableMethods.FirstWithoutPredicate, diff --git a/src/EFCore/Query/ShapedQueryExpression.cs b/src/EFCore/Query/ShapedQueryExpression.cs index c981cba087f..a34c9c04708 100644 --- a/src/EFCore/Query/ShapedQueryExpression.cs +++ b/src/EFCore/Query/ShapedQueryExpression.cs @@ -114,7 +114,7 @@ public virtual ShapedQueryExpression UpdateShaperExpression([NotNull] Expression /// The property of the result. /// An expression with the updated result cardinality. public virtual ShapedQueryExpression UpdateResultCardinality(ResultCardinality resultCardinality) - => new ShapedQueryExpression(QueryExpression, ShaperExpression, resultCardinality); + => new(QueryExpression, ShaperExpression, resultCardinality); /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) diff --git a/src/EFCore/Storage/CoreTypeMapping.cs b/src/EFCore/Storage/CoreTypeMapping.cs index 2b4d0fc4035..c64766dd3d4 100644 --- a/src/EFCore/Storage/CoreTypeMapping.cs +++ b/src/EFCore/Storage/CoreTypeMapping.cs @@ -125,7 +125,7 @@ public ValueComparer? StructuralComparer /// The converter. /// The new parameter object. public CoreTypeMappingParameters WithComposedConverter([CanBeNull] ValueConverter? converter) - => new CoreTypeMappingParameters( + => new( ClrType, converter == null ? Converter : converter.ComposeWith(Converter), Comparer, diff --git a/src/EFCore/Storage/ExecutionStrategy.cs b/src/EFCore/Storage/ExecutionStrategy.cs index 0261510096e..7b7a746d1d6 100644 --- a/src/EFCore/Storage/ExecutionStrategy.cs +++ b/src/EFCore/Storage/ExecutionStrategy.cs @@ -91,12 +91,12 @@ protected ExecutionStrategy( /// /// The list of exceptions that caused the operation to be retried so far. /// - protected virtual List ExceptionsEncountered { get; } = new List(); + protected virtual List ExceptionsEncountered { get; } = new(); /// /// A pseudo-random number generator that can be used to vary the delay between retries. /// - protected virtual Random Random { get; } = new Random(); + protected virtual Random Random { get; } = new(); /// /// The maximum number of retry attempts. @@ -113,7 +113,7 @@ protected ExecutionStrategy( /// protected virtual ExecutionStrategyDependencies Dependencies { get; } - private static readonly AsyncLocal _suspended = new AsyncLocal(); + private static readonly AsyncLocal _suspended = new(); /// /// Indicates whether the strategy is suspended. The strategy is typically suspending while executing to avoid diff --git a/src/EFCore/Storage/TypeMappingInfo.cs b/src/EFCore/Storage/TypeMappingInfo.cs index 223279a4bec..662e4932180 100644 --- a/src/EFCore/Storage/TypeMappingInfo.cs +++ b/src/EFCore/Storage/TypeMappingInfo.cs @@ -211,7 +211,7 @@ public TypeMappingInfo( /// The converter to apply. /// The new mapping info. public TypeMappingInfo WithConverter(in ValueConverterInfo converterInfo) - => new TypeMappingInfo(this, converterInfo); + => new(this, converterInfo); /// /// Indicates whether or not the mapping is part of a key or index. diff --git a/src/EFCore/Storage/TypeMappingSource.cs b/src/EFCore/Storage/TypeMappingSource.cs index 492bea8dc09..701334bcf56 100644 --- a/src/EFCore/Storage/TypeMappingSource.cs +++ b/src/EFCore/Storage/TypeMappingSource.cs @@ -32,8 +32,7 @@ namespace Microsoft.EntityFrameworkCore.Storage /// public abstract class TypeMappingSource : TypeMappingSourceBase { - private readonly ConcurrentDictionary<(TypeMappingInfo, Type?, ValueConverter?), CoreTypeMapping?> _explicitMappings - = new ConcurrentDictionary<(TypeMappingInfo, Type?, ValueConverter?), CoreTypeMapping?>(); + private readonly ConcurrentDictionary<(TypeMappingInfo, Type?, ValueConverter?), CoreTypeMapping?> _explicitMappings = new(); /// /// Initializes a new instance of the this class. diff --git a/src/EFCore/Storage/ValueBuffer.cs b/src/EFCore/Storage/ValueBuffer.cs index faeed028809..9aab9046abc 100644 --- a/src/EFCore/Storage/ValueBuffer.cs +++ b/src/EFCore/Storage/ValueBuffer.cs @@ -26,7 +26,7 @@ namespace Microsoft.EntityFrameworkCore.Storage /// /// A buffer with no values in it. /// - public static readonly ValueBuffer Empty = new ValueBuffer(); + public static readonly ValueBuffer Empty = new(); private readonly object?[] _values; diff --git a/src/EFCore/Storage/ValueConversion/IPAddressToBytesConverter.cs b/src/EFCore/Storage/ValueConversion/IPAddressToBytesConverter.cs index d5d3540d8d2..db5f57339de 100644 --- a/src/EFCore/Storage/ValueConversion/IPAddressToBytesConverter.cs +++ b/src/EFCore/Storage/ValueConversion/IPAddressToBytesConverter.cs @@ -13,8 +13,7 @@ namespace Microsoft.EntityFrameworkCore.Storage.ValueConversion /// public class IPAddressToBytesConverter : ValueConverter { - private static readonly ConverterMappingHints _defaultHints - = new ConverterMappingHints(size: 16); + private static readonly ConverterMappingHints _defaultHints = new(size: 16); /// /// Creates a new instance of this converter. diff --git a/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs b/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs index 5a8e91d461e..29e5f0cbdfb 100644 --- a/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs +++ b/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs @@ -17,7 +17,7 @@ namespace Microsoft.EntityFrameworkCore.ValueGeneration /// public class HiLoValueGeneratorState : IDisposable { - private readonly SemaphoreSlim _semaphoreSlim = new SemaphoreSlim(1); + private readonly SemaphoreSlim _semaphoreSlim = new(1); private HiLoValue _currentValue; private readonly int _blockSize; @@ -161,7 +161,7 @@ public HiLoValue(long low, long high) public long High { get; } public HiLoValue NextValue() - => new HiLoValue(Low + 1, High); + => new(Low + 1, High); } /// diff --git a/src/EFCore/ValueGeneration/ValueGenerator.cs b/src/EFCore/ValueGeneration/ValueGenerator.cs index 95391e50a0a..24c5d2ca645 100644 --- a/src/EFCore/ValueGeneration/ValueGenerator.cs +++ b/src/EFCore/ValueGeneration/ValueGenerator.cs @@ -51,7 +51,7 @@ public virtual ValueTask NextAsync( protected virtual ValueTask NextValueAsync( [NotNull] EntityEntry entry, CancellationToken cancellationToken = default) - => new ValueTask(NextValue(entry)); + => new(NextValue(entry)); /// /// diff --git a/src/EFCore/ValueGeneration/ValueGeneratorCache.cs b/src/EFCore/ValueGeneration/ValueGeneratorCache.cs index 1f6e3855b29..e332b1ef9b6 100644 --- a/src/EFCore/ValueGeneration/ValueGeneratorCache.cs +++ b/src/EFCore/ValueGeneration/ValueGeneratorCache.cs @@ -35,8 +35,7 @@ public ValueGeneratorCache([NotNull] ValueGeneratorCacheDependencies dependencie Check.NotNull(dependencies, nameof(dependencies)); } - private readonly ConcurrentDictionary _cache - = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _cache = new(); private readonly struct CacheKey : IEquatable { diff --git a/src/EFCore/ValueGeneration/ValueGenerator`.cs b/src/EFCore/ValueGeneration/ValueGenerator`.cs index 01cd3eae642..c53852c7e2c 100644 --- a/src/EFCore/ValueGeneration/ValueGenerator`.cs +++ b/src/EFCore/ValueGeneration/ValueGenerator`.cs @@ -31,7 +31,7 @@ public abstract class ValueGenerator : ValueGenerator public new virtual ValueTask NextAsync( [NotNull] EntityEntry entry, CancellationToken cancellationToken = default) - => new ValueTask(Next(entry)); + => new(Next(entry)); /// /// Gets a value to be assigned to a property. diff --git a/src/Microsoft.Data.Sqlite.Core/Extensions/SQLitePCLExtensions.cs b/src/Microsoft.Data.Sqlite.Core/Extensions/SQLitePCLExtensions.cs index f28083de9e5..91f623034ae 100644 --- a/src/Microsoft.Data.Sqlite.Core/Extensions/SQLitePCLExtensions.cs +++ b/src/Microsoft.Data.Sqlite.Core/Extensions/SQLitePCLExtensions.cs @@ -9,7 +9,7 @@ namespace SQLitePCL { internal static class SQLitePCLExtensions { - private static readonly Dictionary _knownLibraries = new Dictionary + private static readonly Dictionary _knownLibraries = new() { { "e_sqlcipher", true }, { "e_sqlite3", false }, diff --git a/src/Microsoft.Data.Sqlite.Core/SqliteCommand.cs b/src/Microsoft.Data.Sqlite.Core/SqliteCommand.cs index 1e705d36653..ee077c92706 100644 --- a/src/Microsoft.Data.Sqlite.Core/SqliteCommand.cs +++ b/src/Microsoft.Data.Sqlite.Core/SqliteCommand.cs @@ -26,7 +26,7 @@ public class SqliteCommand : DbCommand { private SqliteParameterCollection? _parameters; - private readonly List _preparedStatements = new List(); + private readonly List _preparedStatements = new(); private SqliteConnection? _connection; private string _commandText = string.Empty; private bool _prepared; @@ -231,7 +231,7 @@ protected override void Dispose(bool disposing) /// /// The new parameter. public new virtual SqliteParameter CreateParameter() - => new SqliteParameter(); + => new(); /// /// Creates a new parameter. diff --git a/src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs b/src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs index cada2e70c2d..f5220151fc7 100644 --- a/src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs +++ b/src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs @@ -26,7 +26,7 @@ public partial class SqliteConnection : DbConnection private const string DataDirectoryMacro = "|DataDirectory|"; - private readonly List> _commands = new List>(); + private readonly List> _commands = new(); private Dictionary? _collations; @@ -406,7 +406,7 @@ protected override void Dispose(bool disposing) /// transaction. /// public new virtual SqliteCommand CreateCommand() - => new SqliteCommand + => new() { Connection = this, CommandTimeout = DefaultTimeout, @@ -936,7 +936,7 @@ public AggregateContext(T seed) private sealed class FunctionsKeyComparer : IEqualityComparer<(string name, int arity)> { - public static readonly FunctionsKeyComparer Instance = new FunctionsKeyComparer(); + public static readonly FunctionsKeyComparer Instance = new(); public bool Equals((string name, int arity) x, (string name, int arity) y) => StringComparer.OrdinalIgnoreCase.Equals(x.name, y.name) diff --git a/src/Microsoft.Data.Sqlite.Core/SqliteFactory.cs b/src/Microsoft.Data.Sqlite.Core/SqliteFactory.cs index d68ba304395..b6b998c313e 100644 --- a/src/Microsoft.Data.Sqlite.Core/SqliteFactory.cs +++ b/src/Microsoft.Data.Sqlite.Core/SqliteFactory.cs @@ -17,7 +17,7 @@ private SqliteFactory() /// /// The singleton instance. /// - public static readonly SqliteFactory Instance = new SqliteFactory(); + public static readonly SqliteFactory Instance = new(); /// /// Creates a new command. diff --git a/src/Microsoft.Data.Sqlite.Core/SqliteParameterCollection.cs b/src/Microsoft.Data.Sqlite.Core/SqliteParameterCollection.cs index 24c5e9ebfc8..6ba65086ffd 100644 --- a/src/Microsoft.Data.Sqlite.Core/SqliteParameterCollection.cs +++ b/src/Microsoft.Data.Sqlite.Core/SqliteParameterCollection.cs @@ -17,7 +17,7 @@ namespace Microsoft.Data.Sqlite /// Parameters public class SqliteParameterCollection : DbParameterCollection { - private readonly List _parameters = new List(); + private readonly List _parameters = new(); /// /// Initializes a new instance of the class. diff --git a/src/Microsoft.Data.Sqlite.Core/SqliteValueBinder.cs b/src/Microsoft.Data.Sqlite.Core/SqliteValueBinder.cs index 254d8ab030d..52201522ab7 100644 --- a/src/Microsoft.Data.Sqlite.Core/SqliteValueBinder.cs +++ b/src/Microsoft.Data.Sqlite.Core/SqliteValueBinder.cs @@ -206,7 +206,7 @@ public virtual void Bind() } private static readonly Dictionary _sqliteTypeMapping = - new Dictionary + new() { { typeof(bool), SqliteType.Integer }, { typeof(byte), SqliteType.Integer }, diff --git a/src/Shared/Multigraph.cs b/src/Shared/Multigraph.cs index 109e631424d..d77784cfb49 100644 --- a/src/Shared/Multigraph.cs +++ b/src/Shared/Multigraph.cs @@ -11,13 +11,9 @@ namespace Microsoft.EntityFrameworkCore.Utilities { internal class Multigraph : Graph { - private readonly HashSet _vertices = new HashSet(); - - private readonly Dictionary>> _successorMap = - new Dictionary>>(); - - private readonly Dictionary> _predecessorMap = - new Dictionary>(); + private readonly HashSet _vertices = new(); + private readonly Dictionary>> _successorMap = new(); + private readonly Dictionary> _predecessorMap = new(); public IEnumerable Edges => _successorMap.Values.SelectMany(s => s.Values).SelectMany(e => e).Distinct(); diff --git a/src/Shared/ReferenceEqualityComparer.cs b/src/Shared/ReferenceEqualityComparer.cs index 6719c1fedcf..b4fa289408e 100644 --- a/src/Shared/ReferenceEqualityComparer.cs +++ b/src/Shared/ReferenceEqualityComparer.cs @@ -14,7 +14,7 @@ private LegacyReferenceEqualityComparer() { } - public static LegacyReferenceEqualityComparer Instance { get; } = new LegacyReferenceEqualityComparer(); + public static LegacyReferenceEqualityComparer Instance { get; } = new(); public new bool Equals([CanBeNull] object x, [CanBeNull] object y) => ReferenceEquals(x, y); diff --git a/src/Shared/SharedTypeExtensions.cs b/src/Shared/SharedTypeExtensions.cs index a4b0253f9bc..56322056d08 100644 --- a/src/Shared/SharedTypeExtensions.cs +++ b/src/Shared/SharedTypeExtensions.cs @@ -18,7 +18,7 @@ namespace System [DebuggerStepThrough] internal static class SharedTypeExtensions { - private static readonly Dictionary _builtInTypeNames = new Dictionary + private static readonly Dictionary _builtInTypeNames = new() { { typeof(bool), "bool" }, { typeof(byte), "byte" }, @@ -408,7 +408,7 @@ public static IEnumerable GetMembersInHierarchy(this Type type) public static IEnumerable GetMembersInHierarchy(this Type type, string name) => type.GetMembersInHierarchy().Where(m => m.Name == name); - private static readonly Dictionary _commonTypeDictionary = new Dictionary + private static readonly Dictionary _commonTypeDictionary = new() { #pragma warning disable IDE0034 // Simplify 'default' expression - default causes default(object) { typeof(int), default(int) }, diff --git a/src/ef/AnsiConsole.cs b/src/ef/AnsiConsole.cs index ed3cb924c37..550fb4bf130 100644 --- a/src/ef/AnsiConsole.cs +++ b/src/ef/AnsiConsole.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Tools { internal static class AnsiConsole { - public static readonly AnsiTextWriter _out = new AnsiTextWriter(Console.Out); + public static readonly AnsiTextWriter _out = new(Console.Out); public static void WriteLine(string text) => _out.WriteLine(text); diff --git a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesDefaultTestBase.cs b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesDefaultTestBase.cs index d4a20baabbb..bff030b3e6e 100644 --- a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesDefaultTestBase.cs +++ b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesDefaultTestBase.cs @@ -143,7 +143,7 @@ await ExecuteWithStrategyInTransactionAsync( protected override List ExpectedMappings => new() { - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomRoleClaimString", TableName = "MyRoleClaims", @@ -165,7 +165,7 @@ protected override List ExpectedMappings "Navigation: CustomRoleClaimString.Role (CustomRoleString) ToPrincipal CustomRoleString Inverse: RoleClaims PropertyAccessMode.Field", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomRoleString", TableName = "MyRoles", @@ -184,7 +184,7 @@ protected override List ExpectedMappings "Navigation: CustomRoleString.UserRoles (ICollection) Collection ToDependent CustomUserRoleString Inverse: Role PropertyAccessMode.Field", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomUserClaimString", TableName = "MyUserClaims", @@ -206,7 +206,7 @@ protected override List ExpectedMappings "Navigation: CustomUserClaimString.User (CustomUserString) ToPrincipal CustomUserString Inverse: Claims PropertyAccessMode.Field", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomUserLoginString", TableName = "MyUserLogins", @@ -228,7 +228,7 @@ protected override List ExpectedMappings "Navigation: CustomUserLoginString.User (CustomUserString) ToPrincipal CustomUserString Inverse: Logins PropertyAccessMode.Field", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomUserRoleString", TableName = "MyUserRoles", @@ -250,7 +250,7 @@ protected override List ExpectedMappings "Navigation: CustomUserRoleString.User (CustomUserString) ToPrincipal CustomUserString Inverse: UserRoles PropertyAccessMode.Field", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomUserString", TableName = "MyUsers", @@ -286,7 +286,7 @@ protected override List ExpectedMappings "Navigation: CustomUserString.UserRoles (ICollection) Collection ToDependent CustomUserRoleString Inverse: User PropertyAccessMode.Field", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomUserTokenString", TableName = "MyUserTokens", diff --git a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesIntKeyTestBase.cs b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesIntKeyTestBase.cs index be6ede41f63..c5c99e76f3c 100644 --- a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesIntKeyTestBase.cs +++ b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesIntKeyTestBase.cs @@ -51,7 +51,7 @@ await ExecuteWithStrategyInTransactionAsync( protected override List ExpectedMappings => new() { - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomRoleClaimInt", TableName = "AspNetRoleClaims", @@ -66,7 +66,7 @@ protected override List ExpectedMappings Indexes = { "{'RoleId'} ", }, FKs = { "ForeignKey: CustomRoleClaimInt {'RoleId'} -> CustomRoleInt {'Id'} Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomRoleInt", TableName = "AspNetRoles", @@ -80,7 +80,7 @@ protected override List ExpectedMappings }, Indexes = { "{'NormalizedName'} Unique", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomUserClaimInt", TableName = "AspNetUserClaims", @@ -95,7 +95,7 @@ protected override List ExpectedMappings Indexes = { "{'UserId'} ", }, FKs = { "ForeignKey: CustomUserClaimInt {'UserId'} -> CustomUserInt {'Id'} ToDependent: Claims Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomUserInt", TableName = "AspNetUsers", @@ -131,7 +131,7 @@ protected override List ExpectedMappings "Navigation: CustomUserInt.UserRoles (ICollection) Collection ToDependent CustomUserRoleInt", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomUserLoginInt", TableName = "AspNetUserLogins", @@ -146,7 +146,7 @@ protected override List ExpectedMappings Indexes = { "{'UserId'} ", }, FKs = { "ForeignKey: CustomUserLoginInt {'UserId'} -> CustomUserInt {'Id'} ToDependent: Logins Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomUserRoleInt", TableName = "AspNetUserRoles", @@ -163,7 +163,7 @@ protected override List ExpectedMappings "ForeignKey: CustomUserRoleInt {'UserId'} -> CustomUserInt {'Id'} ToDependent: UserRoles Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.EntityFrameworkCore.CustomUserTokenInt", TableName = "AspNetUserTokens", diff --git a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityDefaultTestBase.cs b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityDefaultTestBase.cs index 6ba39d87e56..63c231221e8 100644 --- a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityDefaultTestBase.cs +++ b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityDefaultTestBase.cs @@ -22,7 +22,7 @@ protected AspNetIdentityDefaultTestBase(TFixture fixture) protected override List ExpectedMappings => new() { - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityRole", TableName = "AspNetRoles", @@ -36,7 +36,7 @@ protected override List ExpectedMappings }, Indexes = { "{'NormalizedName'} Unique", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityRoleClaim", TableName = "AspNetRoleClaims", @@ -51,7 +51,7 @@ protected override List ExpectedMappings Indexes = { "{'RoleId'} ", }, FKs = { "ForeignKey: IdentityRoleClaim {'RoleId'} -> IdentityRole {'Id'} Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityUser", TableName = "AspNetUsers", @@ -79,7 +79,7 @@ protected override List ExpectedMappings "{'NormalizedEmail'} ", "{'NormalizedUserName'} Unique", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityUserClaim", TableName = "AspNetUserClaims", @@ -94,7 +94,7 @@ protected override List ExpectedMappings Indexes = { "{'UserId'} ", }, FKs = { "ForeignKey: IdentityUserClaim {'UserId'} -> IdentityUser {'Id'} Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityUserLogin", TableName = "AspNetUserLogins", @@ -109,7 +109,7 @@ protected override List ExpectedMappings Indexes = { "{'UserId'} ", }, FKs = { "ForeignKey: IdentityUserLogin {'UserId'} -> IdentityUser {'Id'} Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityUserRole", TableName = "AspNetUserRoles", @@ -126,7 +126,7 @@ protected override List ExpectedMappings "ForeignKey: IdentityUserRole {'UserId'} -> IdentityUser {'Id'} Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityUserToken", TableName = "AspNetUserTokens", diff --git a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityIntKeyTestBase.cs b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityIntKeyTestBase.cs index c8661cfb56b..229bcdbe997 100644 --- a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityIntKeyTestBase.cs +++ b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityIntKeyTestBase.cs @@ -23,7 +23,7 @@ protected AspNetIdentityIntKeyTestBase(TFixture fixture) protected override List ExpectedMappings => new() { - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityRole", TableName = "AspNetRoles", @@ -37,7 +37,7 @@ protected override List ExpectedMappings }, Indexes = { "{'NormalizedName'} Unique", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityRoleClaim", TableName = "AspNetRoleClaims", @@ -52,7 +52,7 @@ protected override List ExpectedMappings Indexes = { "{'RoleId'} ", }, FKs = { "ForeignKey: IdentityRoleClaim {'RoleId'} -> IdentityRole {'Id'} Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityUser", TableName = "AspNetUsers", @@ -80,7 +80,7 @@ protected override List ExpectedMappings "{'NormalizedEmail'} ", "{'NormalizedUserName'} Unique", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityUserClaim", TableName = "AspNetUserClaims", @@ -95,7 +95,7 @@ protected override List ExpectedMappings Indexes = { "{'UserId'} ", }, FKs = { "ForeignKey: IdentityUserClaim {'UserId'} -> IdentityUser {'Id'} Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityUserLogin", TableName = "AspNetUserLogins", @@ -110,7 +110,7 @@ protected override List ExpectedMappings Indexes = { "{'UserId'} ", }, FKs = { "ForeignKey: IdentityUserLogin {'UserId'} -> IdentityUser {'Id'} Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityUserRole", TableName = "AspNetUserRoles", @@ -127,7 +127,7 @@ protected override List ExpectedMappings "ForeignKey: IdentityUserRole {'UserId'} -> IdentityUser {'Id'} Cascade", }, }, - new() + new EntityTypeMapping() { Name = "Microsoft.AspNetCore.Identity.IdentityUserToken", TableName = "AspNetUserTokens", diff --git a/test/EFCore.AspNet.Specification.Tests/ConfigurationDbContextTestBase.cs b/test/EFCore.AspNet.Specification.Tests/ConfigurationDbContextTestBase.cs index 92119e9d3c7..5f51b038a8e 100644 --- a/test/EFCore.AspNet.Specification.Tests/ConfigurationDbContextTestBase.cs +++ b/test/EFCore.AspNet.Specification.Tests/ConfigurationDbContextTestBase.cs @@ -258,7 +258,7 @@ public void Can_build_ConfigurationDbContext_model() protected virtual List ExpectedMappings => new() { - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ApiResource", TableName = "ApiResources", @@ -286,7 +286,7 @@ protected virtual List ExpectedMappings "Navigation: ApiResource.UserClaims (List) Collection ToDependent ApiResourceClaim Inverse: ApiResource", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ApiResourceClaim", TableName = "ApiResourceClaims", @@ -304,7 +304,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ApiResourceClaim.ApiResource (ApiResource) ToPrincipal ApiResource Inverse: UserClaims", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ApiResourceProperty", TableName = "ApiResourceProperties", @@ -326,7 +326,7 @@ protected virtual List ExpectedMappings "Navigation: ApiResourceProperty.ApiResource (ApiResource) ToPrincipal ApiResource Inverse: Properties", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ApiResourceScope", TableName = "ApiResourceScopes", @@ -344,7 +344,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ApiResourceScope.ApiResource (ApiResource) ToPrincipal ApiResource Inverse: Scopes", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ApiResourceSecret", TableName = "ApiResourceSecrets", @@ -366,7 +366,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ApiResourceSecret.ApiResource (ApiResource) ToPrincipal ApiResource Inverse: Secrets", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ApiScope", TableName = "ApiScopes", @@ -389,7 +389,7 @@ protected virtual List ExpectedMappings "Navigation: ApiScope.UserClaims (List) Collection ToDependent ApiScopeClaim Inverse: Scope", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ApiScopeClaim", TableName = "ApiScopeClaims", @@ -407,7 +407,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ApiScopeClaim.Scope (ApiScope) ToPrincipal ApiScope Inverse: UserClaims", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ApiScopeProperty", TableName = "ApiScopeProperties", @@ -426,7 +426,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ApiScopeProperty.Scope (ApiScope) ToPrincipal ApiScope Inverse: Properties", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.Client", TableName = "Clients", @@ -492,7 +492,7 @@ protected virtual List ExpectedMappings "Navigation: Client.RedirectUris (List) Collection ToDependent ClientRedirectUri Inverse: Client", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ClientClaim", TableName = "ClientClaims", @@ -508,7 +508,7 @@ protected virtual List ExpectedMappings FKs = { "ForeignKey: ClientClaim {'ClientId'} -> Client {'Id'} ToDependent: Claims ToPrincipal: Client Cascade", }, Navigations = { "Navigation: ClientClaim.Client (Client) ToPrincipal Client Inverse: Claims", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ClientCorsOrigin", TableName = "ClientCorsOrigins", @@ -526,7 +526,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ClientCorsOrigin.Client (Client) ToPrincipal Client Inverse: AllowedCorsOrigins", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ClientGrantType", TableName = "ClientGrantTypes", @@ -544,7 +544,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ClientGrantType.Client (Client) ToPrincipal Client Inverse: AllowedGrantTypes", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ClientIdPRestriction", TableName = "ClientIdPRestrictions", @@ -565,7 +565,7 @@ protected virtual List ExpectedMappings "Navigation: ClientIdPRestriction.Client (Client) ToPrincipal Client Inverse: IdentityProviderRestrictions", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ClientPostLogoutRedirectUri", TableName = "ClientPostLogoutRedirectUris", @@ -586,7 +586,7 @@ protected virtual List ExpectedMappings "Navigation: ClientPostLogoutRedirectUri.Client (Client) ToPrincipal Client Inverse: PostLogoutRedirectUris", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ClientProperty", TableName = "ClientProperties", @@ -605,7 +605,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ClientProperty.Client (Client) ToPrincipal Client Inverse: Properties", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ClientRedirectUri", TableName = "ClientRedirectUris", @@ -623,7 +623,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ClientRedirectUri.Client (Client) ToPrincipal Client Inverse: RedirectUris", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ClientScope", TableName = "ClientScopes", @@ -641,7 +641,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ClientScope.Client (Client) ToPrincipal Client Inverse: AllowedScopes", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.ClientSecret", TableName = "ClientSecrets", @@ -663,7 +663,7 @@ protected virtual List ExpectedMappings }, Navigations = { "Navigation: ClientSecret.Client (Client) ToPrincipal Client Inverse: ClientSecrets", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.IdentityResource", TableName = "IdentityResources", @@ -689,7 +689,7 @@ protected virtual List ExpectedMappings "Navigation: IdentityResource.UserClaims (List) Collection ToDependent IdentityResourceClaim Inverse: IdentityResource", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.IdentityResourceClaim", TableName = "IdentityResourceClaims", @@ -710,7 +710,7 @@ protected virtual List ExpectedMappings "Navigation: IdentityResourceClaim.IdentityResource (IdentityResource) ToPrincipal IdentityResource Inverse: UserClaims", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.IdentityResourceProperty", TableName = "IdentityResourceProperties", diff --git a/test/EFCore.AspNet.Specification.Tests/PersistedGrantDbContextTestBase.cs b/test/EFCore.AspNet.Specification.Tests/PersistedGrantDbContextTestBase.cs index 01cfd98751d..d8266cf6e34 100644 --- a/test/EFCore.AspNet.Specification.Tests/PersistedGrantDbContextTestBase.cs +++ b/test/EFCore.AspNet.Specification.Tests/PersistedGrantDbContextTestBase.cs @@ -282,7 +282,7 @@ public void Can_build_PersistedGrantDbContext_model() protected virtual List ExpectedMappings => new() { - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.DeviceFlowCodes", TableName = "DeviceCodes", @@ -304,7 +304,7 @@ protected virtual List ExpectedMappings "{'DeviceCode'} Unique", "{'Expiration'} ", }, }, - new() + new EntityTypeMapping() { Name = "IdentityServer4.EntityFramework.Entities.PersistedGrant", TableName = "PersistedGrants", diff --git a/test/EFCore.Cosmos.FunctionalTests/BuiltInDataTypesCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/BuiltInDataTypesCosmosTest.cs index 4c5c5b3f5e8..af36a865bb3 100644 --- a/test/EFCore.Cosmos.FunctionalTests/BuiltInDataTypesCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/BuiltInDataTypesCosmosTest.cs @@ -107,7 +107,7 @@ public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; public override DateTime DefaultDateTime - => new DateTime(); + => new(); protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Cosmos.FunctionalTests/CosmosApiConsistencyTest.cs b/test/EFCore.Cosmos.FunctionalTests/CosmosApiConsistencyTest.cs index b66fd4fed42..540b2bca304 100644 --- a/test/EFCore.Cosmos.FunctionalTests/CosmosApiConsistencyTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/CosmosApiConsistencyTest.cs @@ -27,7 +27,7 @@ protected override Assembly TargetAssembly public class CosmosApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new HashSet + public override HashSet FluentApiTypes { get; } = new() { typeof(CosmosModelBuilderExtensions), typeof(CosmosPropertyBuilderExtensions), @@ -39,7 +39,7 @@ public class CosmosApiConsistencyFixture : ApiConsistencyFixtureBase public override List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type ConventionBuilderExtensions)> MetadataExtensionTypes { get; } - = new List<(Type, Type, Type, Type, Type)> + = new() { (typeof(IModel), typeof(CosmosModelExtensions), typeof(CosmosModelExtensions), typeof(CosmosModelExtensions), typeof(CosmosModelBuilderExtensions)), diff --git a/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs index 23cc9345e91..c83291a2b8a 100644 --- a/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs @@ -181,7 +181,7 @@ public override bool SupportsDecimalComparisons => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; diff --git a/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs b/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs index fa37d48a3db..31bd7334698 100644 --- a/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs @@ -189,7 +189,7 @@ public virtual async Task Can_manipulate_embedded_collections() Street = "Another", City = "City", AddressTitle = new AddressTitle { Title = "P3 Alternative" }, - Notes = new List { new Note { Content = "Another note" } } + Notes = new List { new() { Content = "Another note" } } }; var existingFirstAddressEntry = context.Entry(people[2].Addresses.First()); diff --git a/test/EFCore.Cosmos.FunctionalTests/OptimisticConcurrencyCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/OptimisticConcurrencyCosmosTest.cs index 1c46ad3682e..ff653fdbff6 100644 --- a/test/EFCore.Cosmos.FunctionalTests/OptimisticConcurrencyCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/OptimisticConcurrencyCosmosTest.cs @@ -48,7 +48,7 @@ public override Task Deleting_then_updating_the_same_entity_results_in_DbUpdateC private class FakeDbContextTransaction : IDbContextTransaction { - public Guid TransactionId => new Guid(); + public Guid TransactionId => new(); public void Commit() { diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosNorthwindTestStoreFactory.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosNorthwindTestStoreFactory.cs index 93918ae4372..05095df1250 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosNorthwindTestStoreFactory.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosNorthwindTestStoreFactory.cs @@ -7,8 +7,7 @@ public class CosmosNorthwindTestStoreFactory : CosmosTestStoreFactory { private const string Name = "Northwind"; - public static new CosmosNorthwindTestStoreFactory Instance { get; } - = new CosmosNorthwindTestStoreFactory(); + public static new CosmosNorthwindTestStoreFactory Instance { get; } = new(); protected CosmosNorthwindTestStoreFactory() { diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestHelpers.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestHelpers.cs index b731e1018e8..8d34e6195f4 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestHelpers.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestHelpers.cs @@ -12,7 +12,7 @@ protected CosmosTestHelpers() { } - public static CosmosTestHelpers Instance { get; } = new CosmosTestHelpers(); + public static CosmosTestHelpers Instance { get; } = new(); public override IServiceCollection AddProviderServices(IServiceCollection services) => services.AddEntityFrameworkCosmos(); diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs index 432e1c5c744..dc1afb931de 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs @@ -27,16 +27,16 @@ public class CosmosTestStore : TestStore private static readonly Guid _runId = Guid.NewGuid(); public static CosmosTestStore Create(string name, Action extensionConfiguration = null) - => new CosmosTestStore(name, shared: false, extensionConfiguration: extensionConfiguration); + => new(name, shared: false, extensionConfiguration: extensionConfiguration); public static CosmosTestStore CreateInitialized(string name, Action extensionConfiguration = null) => (CosmosTestStore)Create(name, extensionConfiguration).Initialize(null, (Func)null); public static CosmosTestStore GetOrCreate(string name) - => new CosmosTestStore(name); + => new(name); public static CosmosTestStore GetOrCreate(string name, string dataFilePath) - => new CosmosTestStore(name, dataFilePath: dataFilePath); + => new(name, dataFilePath: dataFilePath); private CosmosTestStore( string name, diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStoreFactory.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStoreFactory.cs index 6838a95d371..98decc1c3ae 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStoreFactory.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStoreFactory.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class CosmosTestStoreFactory : ITestStoreFactory { - public static CosmosTestStoreFactory Instance { get; } = new CosmosTestStoreFactory(); + public static CosmosTestStoreFactory Instance { get; } = new(); protected CosmosTestStoreFactory() { diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs index 482e2527d07..6f12e1a6e5b 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs @@ -111,8 +111,8 @@ protected class TestSqlLogger : ListLogger public TestSqlLogger(bool shouldLogCommands) => _shouldLogCommands = shouldLogCommands; - public List SqlStatements { get; } = new List(); - public List Parameters { get; } = new List(); + public List SqlStatements { get; } = new(); + public List Parameters { get; } = new(); protected override void UnsafeClear() { diff --git a/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs index 8590e8ee326..1768b4c6ec9 100644 --- a/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs +++ b/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs @@ -86,7 +86,7 @@ public void Can_get_and_set_etag_name() } private static ModelBuilder CreateModelBuilder() - => new ModelBuilder(); + => new(); private class Customer { diff --git a/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs b/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs index 9c3daaf9345..3f70c4f964e 100644 --- a/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs +++ b/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs @@ -71,7 +71,7 @@ private class IntClassEntity private class IntClass { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new IntClass(v)); + = new(v => v.Value, v => new IntClass(v)); public IntClass(int value) => Value = value; @@ -98,7 +98,7 @@ private class IntStructEntity private struct IntStruct { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new IntStruct(v)); + = new(v => v.Value, v => new IntStruct(v)); public IntStruct(int value) => Value = value; @@ -114,7 +114,7 @@ private class BytesStructEntity private struct BytesStruct { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new BytesStruct(v)); + = new(v => v.Value, v => new BytesStruct(v)); public BytesStruct(byte[] value) => Value = value; diff --git a/test/EFCore.CrossStore.FunctionalTests/CrossStoreFixture.cs b/test/EFCore.CrossStore.FunctionalTests/CrossStoreFixture.cs index 27a537f017b..758be38e76a 100644 --- a/test/EFCore.CrossStore.FunctionalTests/CrossStoreFixture.cs +++ b/test/EFCore.CrossStore.FunctionalTests/CrossStoreFixture.cs @@ -16,7 +16,7 @@ public DbContextOptions CreateOptions(TestStore testStore) .Options; public CrossStoreContext CreateContext(TestStore testStore) - => new CrossStoreContext(CreateOptions(testStore)); + => new(CreateOptions(testStore)); public TestStore CreateTestStore(ITestStoreFactory testStoreFactory, string storeName, Action seed = null) => testStoreFactory.GetOrCreate(storeName) diff --git a/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs b/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs index b6ffebdf708..ccad4a499f7 100644 --- a/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs +++ b/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs @@ -606,7 +606,7 @@ private static SqlServerTypeMappingSource CreateTypeMappingSource( private static SqlServerTypeMappingSource CreateTypeMappingSource( params IRelationalTypeMappingSourcePlugin[] plugins) - => new SqlServerTypeMappingSource( + => new( TestServiceFactory.Instance.Create(), new RelationalTypeMappingSourceDependencies( plugins)); @@ -696,7 +696,7 @@ public SimpleTestTypeFactory(string factoryArg) public string FactoryArg { get; } public SimpleTestType Create() - => new SimpleTestType(); + => new(); public object Create(string arg1) => new SimpleTestType(arg1); @@ -705,7 +705,7 @@ public object Create(string arg1, int? arg2) => new SimpleTestType(arg1, arg2); public static SimpleTestType StaticCreate() - => new SimpleTestType(); + => new(); public static object StaticCreate(string arg1) => new SimpleTestType(arg1); diff --git a/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs b/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs index 4719ebe080a..6c278f8b12e 100644 --- a/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs +++ b/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs @@ -114,7 +114,7 @@ private static TestWebHost BuildWebHost(string[] args) private static class TestProgramWithoutAddDbContext { private static TestWebHost BuildWebHost(string[] args) - => new TestWebHost( + => new( new ServiceCollection() .AddSingleton( new TestContext( @@ -128,7 +128,7 @@ private static TestWebHost BuildWebHost(string[] args) private static class TestProgramWithContextFactory { private static TestWebHost BuildWebHost(string[] args) - => new TestWebHost( + => new( new ServiceCollection() .AddDbContextFactory(b => b.UseInMemoryDatabase("In-memory test database")) .BuildServiceProvider()); @@ -158,7 +158,7 @@ private static TestDbContextOperations CreateOperations(Type testProgramType) } private static TestWebHost CreateWebHost(Func configureProvider) - => new TestWebHost( + => new( new ServiceCollection() .AddDbContext( b => @@ -215,10 +215,10 @@ public DerivedContext(string factoryUsed) private class HierarchyContextFactory : IDesignTimeDbContextFactory, IDesignTimeDbContextFactory { BaseContext IDesignTimeDbContextFactory.CreateDbContext(string[] args) - => new BaseContext(nameof(BaseContext)); + => new(nameof(BaseContext)); DerivedContext IDesignTimeDbContextFactory.CreateDbContext(string[] args) - => new DerivedContext(nameof(DerivedContext)); + => new(nameof(DerivedContext)); } } } diff --git a/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs b/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs index 6b0a22c1cc4..1873f2201cc 100644 --- a/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs +++ b/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs @@ -26,7 +26,7 @@ protected override Assembly TargetAssembly public class DesignApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new HashSet { typeof(DesignTimeServiceCollectionExtensions) }; + public override HashSet FluentApiTypes { get; } = new() { typeof(DesignTimeServiceCollectionExtensions) }; } } } diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs index 2d905e71a4c..1e1a9b10f9d 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs @@ -2602,44 +2602,44 @@ public void SqlOperation_required_args() o => Assert.Equal("-- I <3 DDL", o.Sql)); } - private static readonly LineString _lineString1 = new LineString( + private static readonly LineString _lineString1 = new( new[] { new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(7.1, 7.2) }) { SRID = 4326 }; - private static readonly LineString _lineString2 = new LineString( + private static readonly LineString _lineString2 = new( new[] { new Coordinate(7.1, 7.2), new Coordinate(20.2, 20.2), new Coordinate(20.20, 1.1), new Coordinate(70.1, 70.2) }) { SRID = 4326 }; - private static readonly MultiPoint _multiPoint = new MultiPoint( + private static readonly MultiPoint _multiPoint = new( new[] { new Point(1.1, 2.2), new Point(2.2, 2.2), new Point(2.2, 1.1) }) { SRID = 4326 }; - private static readonly Polygon _polygon1 = new Polygon( + private static readonly Polygon _polygon1 = new( new LinearRing( new[] { new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(1.1, 2.2) })) { SRID = 4326 }; - private static readonly Polygon _polygon2 = new Polygon( + private static readonly Polygon _polygon2 = new( new LinearRing( new[] { new Coordinate(10.1, 20.2), new Coordinate(20.2, 20.2), new Coordinate(20.2, 10.1), new Coordinate(10.1, 20.2) })) { SRID = 4326 }; - private static readonly Point _point1 = new Point(1.1, 2.2, 3.3) { SRID = 4326 }; + private static readonly Point _point1 = new(1.1, 2.2, 3.3) { SRID = 4326 }; - private static readonly MultiLineString _multiLineString = new MultiLineString( + private static readonly MultiLineString _multiLineString = new( new[] { _lineString1, _lineString2 }) { SRID = 4326 }; - private static readonly MultiPolygon _multiPolygon = new MultiPolygon( + private static readonly MultiPolygon _multiPolygon = new( new[] { _polygon2, _polygon1 }) { SRID = 4326 }; - private static readonly GeometryCollection _geometryCollection = new GeometryCollection( + private static readonly GeometryCollection _geometryCollection = new( new Geometry[] { _lineString1, _lineString2, _multiPoint, _polygon1, _polygon2, _point1, _multiLineString, _multiPolygon }) { SRID = 4326 diff --git a/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs index bd54c865e4c..2f93686531d 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs @@ -273,10 +273,10 @@ private NullConventionSetBuilder() public ConventionSet CreateConventionSet() { - return new ConventionSet(); + return new(); } - public static NullConventionSetBuilder Instance { get; } = new NullConventionSetBuilder(); + public static NullConventionSetBuilder Instance { get; } = new(); } private class Blog diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs index 639a077d850..e1f3ee585da 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs @@ -859,10 +859,10 @@ public void Is_fixed_length_annotation_should_be_scaffolded_without_optional_par private class TestCodeGeneratorPlugin : ProviderCodeGeneratorPlugin { public override MethodCallCodeFragment GenerateProviderOptions() - => new MethodCallCodeFragment("SetProviderOption"); + => new("SetProviderOption"); public override MethodCallCodeFragment GenerateContextOptions() - => new MethodCallCodeFragment("SetContextOption"); + => new("SetContextOption"); } } } diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs index e3ca87a292e..4e26c9804f4 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs @@ -404,7 +404,7 @@ private static void AssertMapping( } private static ScaffoldingTypeMapper CreateMapper() - => new ScaffoldingTypeMapper( + => new( new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), TestServiceFactory.Instance.Create())); diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqliteTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqliteTest.cs index 18a6f479db1..ee199fc1590 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqliteTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqliteTest.cs @@ -459,7 +459,7 @@ private static void AssertMapping(TypeScaffoldingInfo mapping, bool inferred, } private static ScaffoldingTypeMapper CreateMapper() - => new ScaffoldingTypeMapper( + => new( new SqliteTypeMappingSource( TestServiceFactory.Instance.Create(), TestServiceFactory.Instance.Create())); diff --git a/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs b/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs index 41248bc6732..441cb58245e 100644 --- a/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs +++ b/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs @@ -42,6 +42,6 @@ where IOPath.GetFileNameWithoutExtension(r) == name } public static BuildReference ByPath(string path) - => new BuildReference(new[] { MetadataReference.CreateFromFile(path) }, path: path); + => new(new[] { MetadataReference.CreateFromFile(path) }, path: path); } } diff --git a/test/EFCore.Design.Tests/TestUtilities/TestOperationReporter.cs b/test/EFCore.Design.Tests/TestUtilities/TestOperationReporter.cs index 7e3030d6ca2..349a820d56d 100644 --- a/test/EFCore.Design.Tests/TestUtilities/TestOperationReporter.cs +++ b/test/EFCore.Design.Tests/TestUtilities/TestOperationReporter.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class TestOperationReporter : IOperationReporter { - private readonly List _messages = new List(); + private readonly List _messages = new(); public IReadOnlyList Messages => _messages; diff --git a/test/EFCore.InMemory.FunctionalTests/BuiltInDataTypesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/BuiltInDataTypesInMemoryTest.cs index c738866df75..c4666ee13cc 100644 --- a/test/EFCore.InMemory.FunctionalTests/BuiltInDataTypesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/BuiltInDataTypesInMemoryTest.cs @@ -42,7 +42,7 @@ public override bool SupportsDecimalComparisons => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); } } } diff --git a/test/EFCore.InMemory.FunctionalTests/ConvertToProviderTypesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/ConvertToProviderTypesInMemoryTest.cs index edaf820f597..39fc9019903 100644 --- a/test/EFCore.InMemory.FunctionalTests/ConvertToProviderTypesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ConvertToProviderTypesInMemoryTest.cs @@ -42,7 +42,7 @@ public override bool SupportsDecimalComparisons => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); } } } diff --git a/test/EFCore.InMemory.FunctionalTests/CustomConvertersInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/CustomConvertersInMemoryTest.cs index 8716f9d11b1..fbf65ac89f7 100644 --- a/test/EFCore.InMemory.FunctionalTests/CustomConvertersInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/CustomConvertersInMemoryTest.cs @@ -70,7 +70,7 @@ public override bool SupportsDecimalComparisons => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); } } } diff --git a/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs b/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs index f8f69c2dd3c..44743ab88cf 100644 --- a/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs @@ -167,7 +167,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) private class TestLoggerFactory : ILoggerFactory { - public readonly TestLogger Logger = new TestLogger(); + public readonly TestLogger Logger = new(); public void AddProvider(ILoggerProvider provider) { @@ -210,7 +210,7 @@ public bool IsEnabled(LogLevel logLevel) private class NullScope : IDisposable { - public static readonly NullScope Instance = new NullScope(); + public static readonly NullScope Instance = new(); public void Dispose() { diff --git a/test/EFCore.InMemory.FunctionalTests/GlobalDatabaseTest.cs b/test/EFCore.InMemory.FunctionalTests/GlobalDatabaseTest.cs index 22b65c58461..709945e8f80 100644 --- a/test/EFCore.InMemory.FunctionalTests/GlobalDatabaseTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/GlobalDatabaseTest.cs @@ -15,7 +15,7 @@ namespace Microsoft.EntityFrameworkCore { public class GlobalDatabaseTest { - private static readonly InMemoryDatabaseRoot _databaseRoot = new InMemoryDatabaseRoot(); + private static readonly InMemoryDatabaseRoot _databaseRoot = new(); [ConditionalFact] public void Different_stores_are_used_when_options_force_different_internal_service_provider() diff --git a/test/EFCore.InMemory.FunctionalTests/InMemoryApiConsistencyTest.cs b/test/EFCore.InMemory.FunctionalTests/InMemoryApiConsistencyTest.cs index a74d4e6475d..1619b88161d 100644 --- a/test/EFCore.InMemory.FunctionalTests/InMemoryApiConsistencyTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/InMemoryApiConsistencyTest.cs @@ -26,7 +26,7 @@ protected override Assembly TargetAssembly public class InMemoryApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new HashSet + public override HashSet FluentApiTypes { get; } = new() { typeof(InMemoryServiceCollectionExtensions), typeof(InMemoryDbContextOptionsExtensions), diff --git a/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs index 611c6ab21e8..7c3ba7d3b86 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs @@ -574,8 +574,8 @@ private void Seed5456(MyContext5456 context) Id = i + 1, Posts = new List { - new Post5456 { Comments = new List { new Comment5456(), new Comment5456() } }, - new Post5456() + new() { Comments = new List { new(), new() } }, + new() }, Author = new Author5456() }); @@ -933,7 +933,7 @@ private static void Seed21803(MyContext21803 context) private class AppEntity21803 { - private readonly List _otherEntities = new List(); + private readonly List _otherEntities = new(); public int Id { get; private set; } @@ -1254,13 +1254,13 @@ private static void Seed19253(MyContext19253 context) { var tmp_a = new A19253[] { - new A19253 {a = "a0", a1 = "a1", forkey = "a"}, - new A19253 {a = "a2", a1 = "a1", forkey = "d"}, + new() {a = "a0", a1 = "a1", forkey = "a"}, + new() {a = "a2", a1 = "a1", forkey = "d"}, }; var tmp_b = new B19253[] { - new B19253 {b = "b0", b1 = "b1", forkey = "a"}, - new B19253 {b = "b2", b1 = "b1", forkey = "c"}, + new() {b = "b0", b1 = "b1", forkey = "a"}, + new() {b = "b2", b1 = "b1", forkey = "c"}, }; context.A.AddRange(tmp_a); context.B.AddRange(tmp_b); diff --git a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestHelpers.cs b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestHelpers.cs index f8e680959e4..d7e6d1c9eb7 100644 --- a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestHelpers.cs +++ b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestHelpers.cs @@ -13,7 +13,7 @@ protected InMemoryTestHelpers() { } - public static InMemoryTestHelpers Instance { get; } = new InMemoryTestHelpers(); + public static InMemoryTestHelpers Instance { get; } = new(); public override IServiceCollection AddProviderServices(IServiceCollection services) => services.AddEntityFrameworkInMemoryDatabase(); diff --git a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs index 6f40b666c86..65b9cb9867a 100644 --- a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs +++ b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs @@ -16,13 +16,13 @@ public InMemoryTestStore(string name = null, bool shared = true) } public static InMemoryTestStore GetOrCreate(string name) - => new InMemoryTestStore(name); + => new(name); public static InMemoryTestStore GetOrCreateInitialized(string name) => new InMemoryTestStore(name).InitializeInMemory(null, (Func)null, null); public static InMemoryTestStore Create(string name) - => new InMemoryTestStore(name, shared: false); + => new(name, shared: false); public static InMemoryTestStore CreateInitialized(string name) => new InMemoryTestStore(name, shared: false).InitializeInMemory(null, (Func)null, null); diff --git a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStoreFactory.cs b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStoreFactory.cs index 6018ff52095..3ce2bca494d 100644 --- a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStoreFactory.cs +++ b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStoreFactory.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class InMemoryTestStoreFactory : ITestStoreFactory { - public static InMemoryTestStoreFactory Instance { get; } = new InMemoryTestStoreFactory(); + public static InMemoryTestStoreFactory Instance { get; } = new(); protected InMemoryTestStoreFactory() { @@ -25,6 +25,6 @@ public IServiceCollection AddProviderServices(IServiceCollection serviceCollecti .AddSingleton(); public ListLoggerFactory CreateListLoggerFactory(Func shouldLogCategory) - => new ListLoggerFactory(shouldLogCategory); + => new(shouldLogCategory); } } diff --git a/test/EFCore.OData.FunctionalTests/TestControllers.cs b/test/EFCore.OData.FunctionalTests/TestControllers.cs index f556e74dca6..66e25318bb4 100644 --- a/test/EFCore.OData.FunctionalTests/TestControllers.cs +++ b/test/EFCore.OData.FunctionalTests/TestControllers.cs @@ -20,54 +20,54 @@ public class TestODataController : ODataController { [NonAction] public new TestNotFoundResult NotFound() - => new TestNotFoundResult(base.NotFound()); + => new(base.NotFound()); [NonAction] public new TestNotFoundObjectResult NotFound(object value) - => new TestNotFoundObjectResult(base.NotFound(value)); + => new(base.NotFound(value)); [NonAction] public new TestBadRequestResult BadRequest() - => new TestBadRequestResult(base.BadRequest()); + => new(base.BadRequest()); [NonAction] public new TestBadRequestObjectResult BadRequest(ModelStateDictionary modelState) - => new TestBadRequestObjectResult(base.BadRequest(modelState)); + => new(base.BadRequest(modelState)); [NonAction] public TestBadRequestObjectResult BadRequest(string message) - => new TestBadRequestObjectResult(base.BadRequest(message)); + => new(base.BadRequest(message)); public new TestBadRequestObjectResult BadRequest(object obj) - => new TestBadRequestObjectResult(base.BadRequest(obj)); + => new(base.BadRequest(obj)); [NonAction] public new TestOkResult Ok() - => new TestOkResult(base.Ok()); + => new(base.Ok()); [NonAction] public new TestOkObjectResult Ok(object value) - => new TestOkObjectResult(value); + => new(value); [NonAction] public TestStatusCodeResult StatusCode(HttpStatusCode statusCode) - => new TestStatusCodeResult(base.StatusCode((int)statusCode)); + => new(base.StatusCode((int)statusCode)); [NonAction] public TestStatusCodeObjectResult StatusCode(HttpStatusCode statusCode, object value) - => new TestStatusCodeObjectResult(base.StatusCode((int)statusCode, value)); + => new(base.StatusCode((int)statusCode, value)); [NonAction] public new TestCreatedODataResult Created(T entity) - => new TestCreatedODataResult(entity); + => new(entity); [NonAction] public new TestCreatedResult Created(string uri, object entity) - => new TestCreatedResult(base.Created(uri, entity)); + => new(base.Created(uri, entity)); [NonAction] public new TestUpdatedODataResult Updated(T entity) - => new TestUpdatedODataResult(entity); + => new(entity); protected string GetServiceRootUri() { diff --git a/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs b/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs index 008459a682c..54bb6880aa5 100644 --- a/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs +++ b/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs @@ -398,7 +398,7 @@ public class ChangeSelfRefEntity public class ChangeNonVirtualIndexer { - private readonly Dictionary _keyValuePairs = new Dictionary(); + private readonly Dictionary _keyValuePairs = new(); public virtual int Id { get; set; } @@ -411,7 +411,7 @@ public object this[string key] public class ChangeNonVirtualIndexerNotUsed { - private readonly Dictionary _keyValuePairs = new Dictionary(); + private readonly Dictionary _keyValuePairs = new(); public virtual int Id { get; set; } diff --git a/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs b/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs index f5c40462f60..b835cad15ad 100644 --- a/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs +++ b/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs @@ -24,7 +24,7 @@ protected override Assembly TargetAssembly public class ProxiesApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new HashSet { typeof(ProxiesServiceCollectionExtensions) }; + public override HashSet FluentApiTypes { get; } = new() { typeof(ProxiesServiceCollectionExtensions) }; } } } diff --git a/test/EFCore.Proxies.Tests/ProxyTests.cs b/test/EFCore.Proxies.Tests/ProxyTests.cs index a33b7aa7a0c..c9ccff16dd7 100644 --- a/test/EFCore.Proxies.Tests/ProxyTests.cs +++ b/test/EFCore.Proxies.Tests/ProxyTests.cs @@ -348,7 +348,7 @@ public class IsOwnedButNotWeak private class NeweyContext : DbContext { private readonly IServiceProvider _internalServiceProvider; - private static readonly InMemoryDatabaseRoot _dbRoot = new InMemoryDatabaseRoot(); + private static readonly InMemoryDatabaseRoot _dbRoot = new(); private readonly bool _useLazyLoadingProxies; private readonly bool _useChangeDetectionProxies; private readonly string _dbName; diff --git a/test/EFCore.Proxies.Tests/TestUtilities/TestContext.cs b/test/EFCore.Proxies.Tests/TestUtilities/TestContext.cs index 5ce7d9ebc48..6d4b066fe46 100644 --- a/test/EFCore.Proxies.Tests/TestUtilities/TestContext.cs +++ b/test/EFCore.Proxies.Tests/TestUtilities/TestContext.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities internal abstract class TestContext : DbContext where TEntity : class { - private static readonly InMemoryDatabaseRoot _dbRoot = new InMemoryDatabaseRoot(); + private static readonly InMemoryDatabaseRoot _dbRoot = new(); private readonly IServiceProvider _internalServiceProvider; private readonly string _dbName; diff --git a/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsInfrastructureTestBase.cs b/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsInfrastructureTestBase.cs index f29308d04bd..3b1647783f3 100644 --- a/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsInfrastructureTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsInfrastructureTestBase.cs @@ -337,7 +337,7 @@ public abstract class protected override string StoreName { get; } = "MigrationsTest"; public EmptyMigrationsContext CreateEmptyContext() - => new EmptyMigrationsContext( + => new( TestStore.AddProviderOptions( new DbContextOptionsBuilder()) .UseInternalServiceProvider( diff --git a/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs b/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs index 1880931c468..fbb66564ec3 100644 --- a/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs @@ -184,44 +184,44 @@ public virtual void SqlOperation() => Generate( new SqlOperation { Sql = "-- I <3 DDL" }); - private static readonly LineString _lineString1 = new LineString( + private static readonly LineString _lineString1 = new( new[] { new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(7.1, 7.2) }) { SRID = 4326 }; - private static readonly LineString _lineString2 = new LineString( + private static readonly LineString _lineString2 = new( new[] { new Coordinate(7.1, 7.2), new Coordinate(20.2, 20.2), new Coordinate(20.20, 1.1), new Coordinate(70.1, 70.2) }) { SRID = 4326 }; - private static readonly MultiPoint _multiPoint = new MultiPoint( + private static readonly MultiPoint _multiPoint = new( new[] { new Point(1.1, 2.2), new Point(2.2, 2.2), new Point(2.2, 1.1) }) { SRID = 4326 }; - private static readonly Polygon _polygon1 = new Polygon( + private static readonly Polygon _polygon1 = new( new LinearRing( new[] { new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(1.1, 2.2) })) { SRID = 4326 }; - private static readonly Polygon _polygon2 = new Polygon( + private static readonly Polygon _polygon2 = new( new LinearRing( new[] { new Coordinate(10.1, 20.2), new Coordinate(20.2, 20.2), new Coordinate(20.2, 10.1), new Coordinate(10.1, 20.2) })) { SRID = 4326 }; - private static readonly Point _point1 = new Point(1.1, 2.2, 3.3) { SRID = 4326 }; + private static readonly Point _point1 = new(1.1, 2.2, 3.3) { SRID = 4326 }; - private static readonly MultiLineString _multiLineString = new MultiLineString( + private static readonly MultiLineString _multiLineString = new( new[] { _lineString1, _lineString2 }) { SRID = 4326 }; - private static readonly MultiPolygon _multiPolygon = new MultiPolygon( + private static readonly MultiPolygon _multiPolygon = new( new[] { _polygon2, _polygon1 }) { SRID = 4326 }; - private static readonly GeometryCollection _geometryCollection = new GeometryCollection( + private static readonly GeometryCollection _geometryCollection = new( new Geometry[] { _lineString1, _lineString2, _multiPoint, _polygon1, _polygon2, _point1, _multiLineString, _multiPolygon }) { SRID = 4326 diff --git a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs index 16cdbb3122c..4e0a7174da3 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs @@ -369,7 +369,7 @@ protected override void Seed(DbContext context) OrderDate = new DateTime(2000, 1, 20), Items = new List { - new LineItem { Quantity = 5, Product = product1 }, new LineItem { Quantity = 15, Product = product3 } + new() { Quantity = 5, Product = product1 }, new() { Quantity = 15, Product = product3 } } }; @@ -379,9 +379,9 @@ protected override void Seed(DbContext context) OrderDate = new DateTime(2000, 2, 21), Items = new List { - new LineItem { Quantity = 1, Product = product1 }, - new LineItem { Quantity = 6, Product = product2 }, - new LineItem { Quantity = 200, Product = product3 } + new() { Quantity = 1, Product = product1 }, + new() { Quantity = 6, Product = product2 }, + new() { Quantity = 200, Product = product3 } } }; @@ -389,7 +389,7 @@ protected override void Seed(DbContext context) { Name = "Order13", OrderDate = new DateTime(2001, 3, 20), - Items = new List { new LineItem { Quantity = 50, Product = product4 }, } + Items = new List { new() { Quantity = 50, Product = product4 }, } }; var order21 = new Order @@ -398,9 +398,9 @@ protected override void Seed(DbContext context) OrderDate = new DateTime(2000, 4, 21), Items = new List { - new LineItem { Quantity = 1, Product = product1 }, - new LineItem { Quantity = 34, Product = product4 }, - new LineItem { Quantity = 100, Product = product5 } + new() { Quantity = 1, Product = product1 }, + new() { Quantity = 34, Product = product4 }, + new() { Quantity = 100, Product = product5 } } }; @@ -410,7 +410,7 @@ protected override void Seed(DbContext context) OrderDate = new DateTime(2000, 5, 20), Items = new List { - new LineItem { Quantity = 34, Product = product3 }, new LineItem { Quantity = 100, Product = product4 } + new() { Quantity = 34, Product = product3 }, new() { Quantity = 100, Product = product4 } } }; @@ -418,7 +418,7 @@ protected override void Seed(DbContext context) { Name = "Order31", OrderDate = new DateTime(2001, 6, 21), - Items = new List { new LineItem { Quantity = 5, Product = product5 } } + Items = new List { new() { Quantity = 5, Product = product5 } } }; var address11 = new Address diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs index dbd2fdcf8f9..83097dabea1 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs @@ -118,8 +118,8 @@ protected class TestSqlLogger : ListLogger public TestSqlLogger(bool shouldLogCommands) => _shouldLogCommands = shouldLogCommands; - public List SqlStatements { get; } = new List(); - public List Parameters { get; } = new List(); + public List SqlStatements { get; } = new(); + public List Parameters { get; } = new(); protected override void UnsafeClear() { diff --git a/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs b/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs index a0ea2380399..b0e32e2a9cb 100644 --- a/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs @@ -1491,12 +1491,12 @@ protected override void Seed(PoolableDbContext context) protected static readonly IReadOnlyList Customers = new List { - new TransactionCustomer { Id = 1, Name = "Bob" }, new TransactionCustomer { Id = 2, Name = "Dave" } + new() { Id = 1, Name = "Bob" }, new() { Id = 2, Name = "Dave" } }; protected static readonly IReadOnlyList Orders = new List { - new TransactionOrder { Id = 100, Name = "Order1" }, new TransactionOrder { Id = 200, Name = "Order2" } + new() { Id = 100, Name = "Order1" }, new() { Id = 200, Name = "Order2" } }; protected abstract class TransactionEntity diff --git a/test/EFCore.Relational.Tests/Design/AnnotationCodeGeneratorTest.cs b/test/EFCore.Relational.Tests/Design/AnnotationCodeGeneratorTest.cs index e4d4c3f74fc..3dd18625a57 100644 --- a/test/EFCore.Relational.Tests/Design/AnnotationCodeGeneratorTest.cs +++ b/test/EFCore.Relational.Tests/Design/AnnotationCodeGeneratorTest.cs @@ -28,7 +28,7 @@ private ModelBuilder CreateModelBuilder() => RelationalTestHelpers.Instance.CreateConventionBuilder(); private AnnotationCodeGenerator CreateGenerator() - => new AnnotationCodeGenerator( + => new( new AnnotationCodeGeneratorDependencies( new TestRelationalTypeMappingSource( TestServiceFactory.Instance.Create(), diff --git a/test/EFCore.Relational.Tests/Metadata/RelationalMetadataBuilderExtensionsTest.cs b/test/EFCore.Relational.Tests/Metadata/RelationalMetadataBuilderExtensionsTest.cs index b622e10aba9..72abc764e76 100644 --- a/test/EFCore.Relational.Tests/Metadata/RelationalMetadataBuilderExtensionsTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/RelationalMetadataBuilderExtensionsTest.cs @@ -14,7 +14,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata public class RelationalMetadataBuilderExtensionsTest { private InternalModelBuilder CreateBuilder() - => new InternalModelBuilder(new Model()); + => new(new Model()); [ConditionalFact] public void Can_access_model() diff --git a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs index 67f69751e40..7695b03e330 100644 --- a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs +++ b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs @@ -10125,7 +10125,7 @@ public abstract class ProviderTenantEntity13300 : TenantEntity13300 public abstract class TenantEntity13300 { public Guid TenantId { get; set; } - public ReferencePoint13300 Created { get; set; } = new ReferencePoint13300(); + public ReferencePoint13300 Created { get; set; } = new(); } public class ReferencePoint13300 diff --git a/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs b/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs index 9bd6c5b296f..7cd66c1bbed 100644 --- a/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs +++ b/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs @@ -25,8 +25,8 @@ public async Task Executes_migration_commands_in_same_transaction(bool async) var commandList = new List { - new MigrationCommand(CreateRelationalCommand(), null, logger), - new MigrationCommand(CreateRelationalCommand(), null, logger) + new(CreateRelationalCommand(), null, logger), + new(CreateRelationalCommand(), null, logger) }; var migrationCommandExecutor = new MigrationCommandExecutor(); @@ -67,8 +67,8 @@ public async Task Executes_migration_commands_with_transaction_suppressed_outsid var commandList = new List { - new MigrationCommand(CreateRelationalCommand(), null, logger, transactionSuppressed: true), - new MigrationCommand(CreateRelationalCommand(), null, logger, transactionSuppressed: true) + new(CreateRelationalCommand(), null, logger, transactionSuppressed: true), + new(CreateRelationalCommand(), null, logger, transactionSuppressed: true) }; var migrationCommandExecutor = new MigrationCommandExecutor(); @@ -103,8 +103,8 @@ public async Task Ends_transaction_when_transaction_is_suppressed(bool async) var commandList = new List { - new MigrationCommand(CreateRelationalCommand(), null, logger), - new MigrationCommand(CreateRelationalCommand(), null, logger, transactionSuppressed: true) + new(CreateRelationalCommand(), null, logger), + new(CreateRelationalCommand(), null, logger, transactionSuppressed: true) }; var migrationCommandExecutor = new MigrationCommandExecutor(); @@ -144,8 +144,8 @@ public async Task Begins_new_transaction_when_transaction_nolonger_suppressed(bo var commandList = new List { - new MigrationCommand(CreateRelationalCommand(), null, logger, transactionSuppressed: true), - new MigrationCommand(CreateRelationalCommand(), null, logger) + new(CreateRelationalCommand(), null, logger, transactionSuppressed: true), + new(CreateRelationalCommand(), null, logger) }; var migrationCommandExecutor = new MigrationCommandExecutor(); @@ -185,9 +185,9 @@ public async Task Executes_commands_in_order_regardless_of_transaction_suppressi var commandList = new List { - new MigrationCommand(CreateRelationalCommand(commandText: "First"), null, logger), - new MigrationCommand(CreateRelationalCommand(commandText: "Second"), null, logger, transactionSuppressed: true), - new MigrationCommand(CreateRelationalCommand(commandText: "Third"), null, logger) + new(CreateRelationalCommand(commandText: "First"), null, logger), + new(CreateRelationalCommand(commandText: "Second"), null, logger, transactionSuppressed: true), + new(CreateRelationalCommand(commandText: "Third"), null, logger) }; var migrationCommandExecutor = new MigrationCommandExecutor(); @@ -258,7 +258,7 @@ public async Task Disposes_transaction_on_exception(bool async) var logger = new FakeDiagnosticsLogger(); - var commandList = new List { new MigrationCommand(CreateRelationalCommand(), null, logger) }; + var commandList = new List { new(CreateRelationalCommand(), null, logger) }; var migrationCommandExecutor = new MigrationCommandExecutor(); @@ -287,7 +287,7 @@ await Assert.ThrowsAsync( private const string ConnectionString = "Fake Connection String"; private static FakeRelationalConnection CreateConnection(IDbContextOptions options = null) - => new FakeRelationalConnection(options ?? CreateOptions()); + => new(options ?? CreateOptions()); private static IDbContextOptions CreateOptions(RelationalOptionsExtension optionsExtension = null) { diff --git a/test/EFCore.Relational.Tests/Query/Internal/QuerySqlGeneratorTest.cs b/test/EFCore.Relational.Tests/Query/Internal/QuerySqlGeneratorTest.cs index 04b46486aae..db7a3e09412 100644 --- a/test/EFCore.Relational.Tests/Query/Internal/QuerySqlGeneratorTest.cs +++ b/test/EFCore.Relational.Tests/Query/Internal/QuerySqlGeneratorTest.cs @@ -40,7 +40,7 @@ public void CheckComposableSql_does_not_throw(string sql) => CreateDummyQuerySqlGenerator().CheckComposableSql(sql); private DummyQuerySqlGenerator CreateDummyQuerySqlGenerator() - => new DummyQuerySqlGenerator( + => new( new QuerySqlGeneratorDependencies( new RelationalCommandBuilderFactory( new RelationalCommandBuilderDependencies( diff --git a/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs b/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs index f82f53745fe..04b39120e91 100644 --- a/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs +++ b/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs @@ -48,7 +48,7 @@ public void Readonly_relational_metadata_methods_have_expected_name() public class RelationalApiConsistencyFixture : ApiConsistencyFixtureBase { private static Dictionary _metadataTypes - => new Dictionary + => new() { { typeof(IDbFunction), @@ -63,7 +63,7 @@ public class RelationalApiConsistencyFixture : ApiConsistencyFixtureBase { typeof(ICheckConstraint), (typeof(IMutableCheckConstraint), typeof(IConventionCheckConstraint), null) } }; - public virtual HashSet RelationalMetadataTypes { get; } = new HashSet + public virtual HashSet RelationalMetadataTypes { get; } = new() { typeof(IRelationalModel), typeof(ITableBase), @@ -83,7 +83,7 @@ public class RelationalApiConsistencyFixture : ApiConsistencyFixtureBase typeof(IUniqueConstraint) }; - public override HashSet FluentApiTypes { get; } = new HashSet + public override HashSet FluentApiTypes { get; } = new() { typeof(RelationalForeignKeyBuilderExtensions), typeof(RelationalPropertyBuilderExtensions), @@ -106,7 +106,7 @@ public class RelationalApiConsistencyFixture : ApiConsistencyFixtureBase public override List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type ConventionBuilderExtensions)> MetadataExtensionTypes { get; } - = new List<(Type, Type, Type, Type, Type)> + = new() { (typeof(IModel), typeof(RelationalModelExtensions), typeof(RelationalModelExtensions), typeof(RelationalModelExtensions), typeof(RelationalModelBuilderExtensions)), @@ -123,7 +123,7 @@ public override }; public override HashSet NonVirtualMethods { get; } - = new HashSet + = new() { typeof(RelationalCompiledQueryCacheKeyGenerator) .GetRuntimeMethods() @@ -132,7 +132,7 @@ public override && m.DeclaringType == typeof(RelationalCompiledQueryCacheKeyGenerator)) }; - public override HashSet UnmatchedMetadataMethods { get; } = new HashSet + public override HashSet UnmatchedMetadataMethods { get; } = new() { typeof(IDbFunction).GetMethod("get_ReturnEntityType"), typeof(IMutableSequence).GetMethod("set_ClrType"), @@ -141,7 +141,7 @@ public override nameof(RelationalEntityTypeBuilderExtensions.ExcludeTableFromMigrations)) }; - public override HashSet AsyncMethodExceptions { get; } = new HashSet + public override HashSet AsyncMethodExceptions { get; } = new() { typeof(RelationalDatabaseFacadeExtensions).GetMethod(nameof(RelationalDatabaseFacadeExtensions.CloseConnectionAsync)), typeof(IRelationalConnection).GetMethod(nameof(IRelationalConnection.CloseAsync)), @@ -155,7 +155,7 @@ public override typeof(RelationalLoggerExtensions).GetMethod(nameof(RelationalLoggerExtensions.ConnectionClosedAsync)) }; - public List> RelationalMetadataMethods { get; } = new List>(); + public List> RelationalMetadataMethods { get; } = new(); protected override void Initialize() { diff --git a/test/EFCore.Relational.Tests/RelationalEventIdTest.cs b/test/EFCore.Relational.Tests/RelationalEventIdTest.cs index 97f6a7fba73..8f3e567be41 100644 --- a/test/EFCore.Relational.Tests/RelationalEventIdTest.cs +++ b/test/EFCore.Relational.Tests/RelationalEventIdTest.cs @@ -142,7 +142,7 @@ private class FakeMigrator : IMigrator public void Migrate(string targetMigration = null) => throw new NotImplementedException(); - public Task MigrateAsync(string targetMigration = null, CancellationToken cancellationToken = new CancellationToken()) + public Task MigrateAsync(string targetMigration = null, CancellationToken cancellationToken = new()) => throw new NotImplementedException(); public string GenerateScript( diff --git a/test/EFCore.Relational.Tests/Storage/RawSqlCommandBuilderTest.cs b/test/EFCore.Relational.Tests/Storage/RawSqlCommandBuilderTest.cs index 7571310f14e..29e0032fa8b 100644 --- a/test/EFCore.Relational.Tests/Storage/RawSqlCommandBuilderTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RawSqlCommandBuilderTest.cs @@ -23,7 +23,7 @@ public virtual void Builds_RelationalCommand_without_optional_parameters() private static RawSqlCommandBuilder CreateBuilder() { - return new RawSqlCommandBuilder( + return new( new RelationalCommandBuilderFactory( new RelationalCommandBuilderDependencies( new TestRelationalTypeMappingSource( diff --git a/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs index 6c367801107..09d5c64bd66 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs @@ -1237,7 +1237,7 @@ await Assert.ThrowsAsync( private const string ConnectionString = "Fake Connection String"; private static FakeRelationalConnection CreateConnection(IDbContextOptions options = null) - => new FakeRelationalConnection(options ?? CreateOptions()); + => new(options ?? CreateOptions()); private static IDbContextOptions CreateOptions( RelationalOptionsExtension optionsExtension = null) diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbConnection.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbConnection.cs index 6010c39ba01..2da8813650b 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbConnection.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbConnection.cs @@ -15,8 +15,8 @@ public class FakeDbConnection : DbConnection private readonly FakeCommandExecutor _commandExecutor; private ConnectionState _state; - private readonly List _dbCommands = new List(); - private readonly List _dbTransactions = new List(); + private readonly List _dbCommands = new(); + private readonly List _dbTransactions = new(); public FakeDbConnection( string connectionString, diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbParameterCollection.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbParameterCollection.cs index 99f44d082da..c0f21722131 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbParameterCollection.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbParameterCollection.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider { public class FakeDbParameterCollection : DbParameterCollection { - private readonly List _parameters = new List(); + private readonly List _parameters = new(); public override int Count => _parameters.Count; diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs index 71bcd002573..d5a177b0a60 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs @@ -17,7 +17,7 @@ public class FakeRelationalConnection : RelationalConnection { private DbConnection _connection; - private readonly List _dbConnections = new List(); + private readonly List _dbConnections = new(); public FakeRelationalConnection(IDbContextOptions options = null) : base( diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalDatabaseCreator.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalDatabaseCreator.cs index 4449676bcc1..59bbf56ed77 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalDatabaseCreator.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalDatabaseCreator.cs @@ -13,13 +13,13 @@ public class FakeRelationalDatabaseCreator : IRelationalDatabaseCreator public bool EnsureDeleted() => throw new NotImplementedException(); - public Task EnsureDeletedAsync(CancellationToken cancellationToken = new CancellationToken()) + public Task EnsureDeletedAsync(CancellationToken cancellationToken = new()) => throw new NotImplementedException(); public bool EnsureCreated() => throw new NotImplementedException(); - public Task EnsureCreatedAsync(CancellationToken cancellationToken = new CancellationToken()) + public Task EnsureCreatedAsync(CancellationToken cancellationToken = new()) => throw new NotImplementedException(); public bool CanConnect() @@ -31,7 +31,7 @@ public Task CanConnectAsync(CancellationToken cancellationToken = default) public bool Exists() => throw new NotImplementedException(); - public Task ExistsAsync(CancellationToken cancellationToken = new CancellationToken()) + public Task ExistsAsync(CancellationToken cancellationToken = new()) => throw new NotImplementedException(); public bool HasTables() @@ -43,19 +43,19 @@ public Task HasTablesAsync(CancellationToken cancellationToken = default) public void Create() => throw new NotImplementedException(); - public Task CreateAsync(CancellationToken cancellationToken = new CancellationToken()) + public Task CreateAsync(CancellationToken cancellationToken = new()) => throw new NotImplementedException(); public void Delete() => throw new NotImplementedException(); - public Task DeleteAsync(CancellationToken cancellationToken = new CancellationToken()) + public Task DeleteAsync(CancellationToken cancellationToken = new()) => throw new NotImplementedException(); public void CreateTables() => throw new NotImplementedException(); - public Task CreateTablesAsync(CancellationToken cancellationToken = new CancellationToken()) + public Task CreateTablesAsync(CancellationToken cancellationToken = new()) => throw new NotImplementedException(); public string GenerateCreateScript() diff --git a/test/EFCore.Relational.Tests/TestUtilities/RelationalTestHelpers.cs b/test/EFCore.Relational.Tests/TestUtilities/RelationalTestHelpers.cs index 839d0ac40af..e0922fc1aaa 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/RelationalTestHelpers.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/RelationalTestHelpers.cs @@ -13,7 +13,7 @@ protected RelationalTestHelpers() { } - public static RelationalTestHelpers Instance { get; } = new RelationalTestHelpers(); + public static RelationalTestHelpers Instance { get; } = new(); public override IServiceCollection AddProviderServices(IServiceCollection services) => FakeRelationalOptionsExtension.AddEntityFrameworkRelationalDatabase(services); diff --git a/test/EFCore.Relational.Tests/TestUtilities/TestProviderCodeGenerator.cs b/test/EFCore.Relational.Tests/TestUtilities/TestProviderCodeGenerator.cs index b531b7a1643..906c1a23533 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/TestProviderCodeGenerator.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/TestProviderCodeGenerator.cs @@ -16,7 +16,7 @@ public TestProviderCodeGenerator(ProviderCodeGeneratorDependencies dependencies) public override MethodCallCodeFragment GenerateUseProvider( string connectionString, MethodCallCodeFragment providerOptions) - => new MethodCallCodeFragment( + => new( "UseTestProvider", providerOptions == null ? new object[] { connectionString } diff --git a/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs b/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs index ccb68a87911..00cba419065 100644 --- a/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs +++ b/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs @@ -319,7 +319,7 @@ public void CreateStoreCommand_creates_parameters_for_each_ModificationCommand() true, new List { - new ColumnModification( + new( entry, property, property.GetTableColumnMappings().Single().Column, @@ -336,7 +336,7 @@ public void CreateStoreCommand_creates_parameters_for_each_ModificationCommand() true, new List { - new ColumnModification( + new( entry, property, property.GetTableColumnMappings().Single().Column, @@ -373,7 +373,7 @@ public void PopulateParameters_creates_parameter_for_write_ModificationCommand() true, new List { - new ColumnModification( + new( entry, property, property.GetTableColumnMappings().Single().Column, @@ -409,7 +409,7 @@ public void PopulateParameters_creates_parameter_for_condition_ModificationComma true, new List { - new ColumnModification( + new( entry, property, property.GetTableColumnMappings().Single().Column, @@ -445,7 +445,7 @@ public void PopulateParameters_creates_parameters_for_write_and_condition_Modifi true, new List { - new ColumnModification( + new( entry, property, property.GetTableColumnMappings().Single().Column, @@ -483,7 +483,7 @@ public void PopulateParameters_does_not_create_parameter_for_read_ModificationCo true, new List { - new ColumnModification( + new( entry, property, property.GetTableColumnMappings().Single().Column, @@ -628,7 +628,7 @@ private static FakeRelationalConnection CreateConnection(DbDataReader dbDataRead } private static FakeRelationalConnection CreateConnection(IDbContextOptions options = null) - => new FakeRelationalConnection(options ?? CreateOptions()); + => new(options ?? CreateOptions()); public static IDbContextOptions CreateOptions(RelationalOptionsExtension optionsExtension = null) { diff --git a/test/EFCore.Specification.Tests/ApiConsistencyTestBase.cs b/test/EFCore.Specification.Tests/ApiConsistencyTestBase.cs index c76e0bb06db..3448d95e745 100644 --- a/test/EFCore.Specification.Tests/ApiConsistencyTestBase.cs +++ b/test/EFCore.Specification.Tests/ApiConsistencyTestBase.cs @@ -803,7 +803,7 @@ from parameter in method.GetParameters() parametersWithRedundantAttribute.Select(t => $"{t.Type.FullName}.{t.Method.Name}[{t.Parameter.Name}]"))); } - private static readonly HashSet _nonCancellableAsyncMethods = new HashSet(); + private static readonly HashSet _nonCancellableAsyncMethods = new(); protected virtual HashSet NonCancellableAsyncMethods => _nonCancellableAsyncMethods; @@ -906,9 +906,9 @@ protected ApiConsistencyFixtureBase() Initialize(); } - public virtual HashSet FluentApiTypes { get; } = new HashSet(); + public virtual HashSet FluentApiTypes { get; } = new(); - public virtual Dictionary GenericFluentApiTypes { get; } = new Dictionary + public virtual Dictionary GenericFluentApiTypes { get; } = new() { { typeof(CollectionCollectionBuilder), typeof(CollectionCollectionBuilder<,>) }, { typeof(CollectionNavigationBuilder), typeof(CollectionNavigationBuilder<,>) }, @@ -928,14 +928,14 @@ protected ApiConsistencyFixtureBase() { typeof(DbContextOptionsBuilder), typeof(DbContextOptionsBuilder<>) } }; - public virtual HashSet NonVirtualMethods { get; } = new HashSet(); - public virtual HashSet NotAnnotatedMethods { get; } = new HashSet(); - public virtual HashSet AsyncMethodExceptions { get; } = new HashSet(); - public virtual HashSet UnmatchedMetadataMethods { get; } = new HashSet(); - public virtual HashSet MetadataMethodExceptions { get; } = new HashSet(); + public virtual HashSet NonVirtualMethods { get; } = new(); + public virtual HashSet NotAnnotatedMethods { get; } = new(); + public virtual HashSet AsyncMethodExceptions { get; } = new(); + public virtual HashSet UnmatchedMetadataMethods { get; } = new(); + public virtual HashSet MetadataMethodExceptions { get; } = new(); public virtual HashSet ComputedDependencyProperties { get; } - = new HashSet + = new() { typeof(ProviderConventionSetBuilderDependencies).GetProperty( nameof(ProviderConventionSetBuilderDependencies.ContextType)), @@ -949,7 +949,7 @@ protected ApiConsistencyFixtureBase() }; public Dictionary MetadataTypes { get; } - = new Dictionary + = new() { { typeof(IModel), (typeof(IMutableModel), typeof(IConventionModel), typeof(IConventionModelBuilder)) }, { @@ -985,18 +985,18 @@ protected ApiConsistencyFixtureBase() { typeof(IPropertyBase), (typeof(IMutablePropertyBase), typeof(IConventionPropertyBase), null) } }; - public Dictionary MutableMetadataTypes { get; } = new Dictionary(); - public Dictionary ConventionMetadataTypes { get; } = new Dictionary(); + public Dictionary MutableMetadataTypes { get; } = new(); + public Dictionary ConventionMetadataTypes { get; } = new(); public virtual List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type ConventionBuilderExtensions)> MetadataExtensionTypes { get; } - = new List<(Type, Type, Type, Type, Type)>(); + = new(); public List<(IReadOnlyList ReadOnly, IReadOnlyList Mutable, IReadOnlyList Convention, IReadOnlyList ConventionBuilder)> MetadataMethods { get; } - = new List<(IReadOnlyList, IReadOnlyList, IReadOnlyList, IReadOnlyList)>(); + = new(); protected virtual void Initialize() { diff --git a/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs b/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs index ea5038c14f0..cd3e69e8e83 100644 --- a/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs +++ b/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs @@ -790,14 +790,14 @@ protected override void Seed(ApplicationDbContext context) { var attendees1 = new List { - new TestModels.ConferencePlanner.Attendee + new() { EmailAddress = "sonicrainboom@sample.com", FirstName = "Rainbow", LastName = "Dash", UserName = "RainbowDash" }, - new TestModels.ConferencePlanner.Attendee + new() { EmailAddress = "solovely@sample.com", FirstName = "Flutter", @@ -808,14 +808,14 @@ protected override void Seed(ApplicationDbContext context) var attendees2 = new List { - new TestModels.ConferencePlanner.Attendee + new() { EmailAddress = "applesforever@sample.com", FirstName = "Apple", LastName = "Jack", UserName = "Applejack" }, - new TestModels.ConferencePlanner.Attendee + new() { EmailAddress = "precious@sample.com", FirstName = "Rarity", @@ -826,14 +826,14 @@ protected override void Seed(ApplicationDbContext context) var attendees3 = new List { - new TestModels.ConferencePlanner.Attendee + new() { EmailAddress = "princess@sample.com", FirstName = "Twilight", LastName = "Sparkle", UserName = "Princess" }, - new TestModels.ConferencePlanner.Attendee + new() { EmailAddress = "pinkie@sample.com", FirstName = "Pinkie", diff --git a/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs b/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs index f4babd35efd..59ebb2f6821 100644 --- a/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs +++ b/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs @@ -121,7 +121,7 @@ public virtual void Can_query_and_update_with_nullable_converter_on_primary_key( var principal = context.Add( new NullablePrincipal { - Id = 1, Dependents = new List { new NonNullableDependent { Id = 1 } } + Id = 1, Dependents = new List { new() { Id = 1 } } }) .Entity; @@ -214,7 +214,7 @@ private Email(string value) => _value = value; public static Email Create(string value) - => new Email(value); + => new(value); public static implicit operator string(Email email) => email._value; @@ -366,7 +366,7 @@ private OrderId(string stringValue) public static OrderId Parse(string stringValue) { - return new OrderId(stringValue); + return new(stringValue); } public static explicit operator string(OrderId orderId) diff --git a/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs b/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs index ff93e1580e0..f4739088536 100644 --- a/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs +++ b/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs @@ -2264,7 +2264,7 @@ protected class User13694 { public Guid Id { get; set; } private readonly string _email = string.Empty; - private readonly List _profiles = new List(); + private readonly List _profiles = new(); } protected class Profile13694 diff --git a/test/EFCore.Specification.Tests/FieldMappingTestBase.cs b/test/EFCore.Specification.Tests/FieldMappingTestBase.cs index 0590db820b7..e3aa91f29c8 100644 --- a/test/EFCore.Specification.Tests/FieldMappingTestBase.cs +++ b/test/EFCore.Specification.Tests/FieldMappingTestBase.cs @@ -26,7 +26,7 @@ protected FieldMappingTestBase(TFixture fixture) protected TFixture Fixture { get; } - protected static AsyncLocal _isSeeding = new AsyncLocal(); + protected static AsyncLocal _isSeeding = new(); protected interface IUser2 { @@ -76,7 +76,7 @@ public virtual void Field_mapping_with_conversion_does_not_throw() Assert.Equal(session.Id, entry.Property(e => e.Id).OriginalValue); var newUser = new User2(); - var newUsers = new List { new User2() }; + var newUsers = new List { new() }; entry.Reference(e => e.User).CurrentValue = newUser; entry.Collection(e => e.Users).CurrentValue = newUsers; @@ -1833,13 +1833,13 @@ protected static IList CreatePostsAndBlog() return new List { - new TPost + new() { AccessId = 20, AccessTitle = "Post20", AccessBlog = blog }, - new TPost + new() { AccessId = 21, AccessTitle = "Post21", @@ -2209,7 +2209,7 @@ protected override void Seed(PoolableDbContext context) } context.Add( - new LoginSession { User = new User2(), Users = new List { new User2() } }); + new LoginSession { User = new User2(), Users = new List { new() } }); context.Add(new OneToOneFieldNavPrincipal { Id = 1, Name = "OneToOneFieldNavPrincipal1" }); diff --git a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs index 6696a32b8ea..64ca935216f 100644 --- a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs @@ -405,38 +405,38 @@ protected virtual object CreateFullGraph() RequiredChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new Required1 + new() { Children = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new Required2(), new Required2() + new(), new() } }, - new Required1 + new() { Children = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new Required2(), new Required2() + new(), new() } } }, OptionalChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new Optional1 + new() { Children = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new Optional2(), new Optional2() + new(), new() }, CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) }, - new Optional1 + new() { Children = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new Optional2(), new Optional2() + new(), new() }, CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) @@ -459,60 +459,60 @@ protected virtual object CreateFullGraph() RequiredChildrenAk = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new RequiredAk1 + new() { AlternateId = Guid.NewGuid(), Children = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new RequiredAk2 { AlternateId = Guid.NewGuid() }, new RequiredAk2 { AlternateId = Guid.NewGuid() } + new() { AlternateId = Guid.NewGuid() }, new() { AlternateId = Guid.NewGuid() } }, CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new RequiredComposite2(), new RequiredComposite2() + new(), new() } }, - new RequiredAk1 + new() { AlternateId = Guid.NewGuid(), Children = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new RequiredAk2 { AlternateId = Guid.NewGuid() }, new RequiredAk2 { AlternateId = Guid.NewGuid() } + new() { AlternateId = Guid.NewGuid() }, new() { AlternateId = Guid.NewGuid() } }, CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new RequiredComposite2(), new RequiredComposite2() + new(), new() } } }, OptionalChildrenAk = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new OptionalAk1 + new() { AlternateId = Guid.NewGuid(), Children = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new OptionalAk2 { AlternateId = Guid.NewGuid() }, new OptionalAk2 { AlternateId = Guid.NewGuid() } + new() { AlternateId = Guid.NewGuid() }, new() { AlternateId = Guid.NewGuid() } }, CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new OptionalComposite2(), new OptionalComposite2() + new(), new() } }, - new OptionalAk1 + new() { AlternateId = Guid.NewGuid(), Children = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new OptionalAk2 { AlternateId = Guid.NewGuid() }, new OptionalAk2 { AlternateId = Guid.NewGuid() } + new() { AlternateId = Guid.NewGuid() }, new() { AlternateId = Guid.NewGuid() } }, CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new OptionalComposite2(), new OptionalComposite2() + new(), new() } } }, @@ -562,22 +562,22 @@ protected virtual object CreateFullGraph() }, RequiredCompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new RequiredComposite1 + new() { Id = 1, CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new OptionalOverlapping2 { Id = 1 }, new OptionalOverlapping2 { Id = 2 } + new() { Id = 1 }, new() { Id = 2 } } }, - new RequiredComposite1 + new() { Id = 2, CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new OptionalOverlapping2 { Id = 3 }, new OptionalOverlapping2 { Id = 4 } + new() { Id = 3 }, new() { Id = 4 } } } } diff --git a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseOneToMany.cs b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseOneToMany.cs index 8072c556a75..141bf611451 100644 --- a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseOneToMany.cs +++ b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseOneToMany.cs @@ -891,7 +891,7 @@ public virtual void Reparent_one_to_many_overlapping( Parent = context.Set().Single(IsTheRoot), CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) { - new OptionalOverlapping2 { Id = 5 }, new OptionalOverlapping2 { Id = 6 } + new() { Id = 5 }, new() { Id = 6 } } }; diff --git a/test/EFCore.Specification.Tests/InterceptionTestBase.cs b/test/EFCore.Specification.Tests/InterceptionTestBase.cs index 3777bc876b9..5cabfeff6a3 100644 --- a/test/EFCore.Specification.Tests/InterceptionTestBase.cs +++ b/test/EFCore.Specification.Tests/InterceptionTestBase.cs @@ -72,14 +72,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) } public UniverseContext CreateContext(IInterceptor appInterceptor, params IInterceptor[] injectedInterceptors) - => new UniverseContext( + => new( Fixture.CreateOptions( new[] { appInterceptor }, injectedInterceptors)); public UniverseContext CreateContext( IEnumerable appInterceptors, IEnumerable injectedInterceptors = null) - => new UniverseContext(Fixture.CreateOptions(appInterceptors, injectedInterceptors ?? Enumerable.Empty())); + => new(Fixture.CreateOptions(appInterceptors, injectedInterceptors ?? Enumerable.Empty())); public interface ITestDiagnosticListener : IDisposable { @@ -103,7 +103,7 @@ public class TestDiagnosticListener : ITestDiagnosticListener, { private readonly DbContextId _contextId; private readonly IDisposable _subscription; - private readonly List _events = new List(); + private readonly List _events = new(); public TestDiagnosticListener(DbContextId contextId) { diff --git a/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs b/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs index 79d88f4ed85..460d6e5b245 100644 --- a/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs +++ b/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs @@ -2023,7 +2023,7 @@ protected void ValidateRequiredBytes( protected struct IntStructKey { public static ValueConverter Converter - = new ValueConverter(v => v.Id, v => new IntStructKey { Id = v }); + = new(v => v.Id, v => new IntStructKey { Id = v }); public int Id { get; set; } } @@ -2031,7 +2031,7 @@ public static ValueConverter Converter protected struct BytesStructKey { public static ValueConverter Converter - = new ValueConverter(v => v.Id, v => new BytesStructKey { Id = v }); + = new(v => v.Id, v => new BytesStructKey { Id = v }); public byte[] Id { get; set; } @@ -2059,7 +2059,7 @@ public override int GetHashCode() protected struct ComparableIntStructKey : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Id, v => new ComparableIntStructKey { Id = v }); + = new(v => v.Id, v => new ComparableIntStructKey { Id = v }); public int Id { get; set; } @@ -2070,7 +2070,7 @@ public int CompareTo(object other) protected struct ComparableBytesStructKey : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Id, v => new ComparableBytesStructKey { Id = v }); + = new(v => v.Id, v => new ComparableBytesStructKey { Id = v }); public byte[] Id { get; set; } @@ -2107,7 +2107,7 @@ public int CompareTo(object other) protected struct GenericComparableIntStructKey : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Id, v => new GenericComparableIntStructKey { Id = v }); + = new(v => v.Id, v => new GenericComparableIntStructKey { Id = v }); public int Id { get; set; } @@ -2118,7 +2118,7 @@ public int CompareTo(GenericComparableIntStructKey other) protected struct GenericComparableBytesStructKey : IComparable { public static ValueConverter Converter - = new ValueConverter( + = new( v => v.Id, v => new GenericComparableBytesStructKey { Id = v }); public byte[] Id { get; set; } @@ -2156,7 +2156,7 @@ public int CompareTo(GenericComparableBytesStructKey other) protected struct StructuralComparableBytesStructKey : IStructuralComparable { public static ValueConverter Converter - = new ValueConverter( + = new( v => v.Id, v => new StructuralComparableBytesStructKey { Id = v }); public byte[] Id { get; set; } @@ -2201,7 +2201,7 @@ public int CompareTo(object other, IComparer comparer) protected class IntClassKey { public static ValueConverter Converter - = new ValueConverter(v => v.Id, v => new IntClassKey { Id = v }); + = new(v => v.Id, v => new IntClassKey { Id = v }); protected bool Equals(IntClassKey other) => other != null && Id == other.Id; @@ -2220,7 +2220,7 @@ public override int GetHashCode() protected class ComparableIntClassKey : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Id, v => new ComparableIntClassKey { Id = v }); + = new(v => v.Id, v => new ComparableIntClassKey { Id = v }); public int Id { get; set; } @@ -2242,7 +2242,7 @@ public int CompareTo(object other) protected class GenericComparableIntClassKey : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Id, v => new GenericComparableIntClassKey { Id = v }); + = new(v => v.Id, v => new GenericComparableIntClassKey { Id = v }); public int Id { get; set; } diff --git a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs index 61b356c6177..cd4c349d99b 100644 --- a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs +++ b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs @@ -2389,7 +2389,7 @@ private FirstName(string value) public static FirstName Create(string firstName) { - return new FirstName(firstName); + return new(firstName); } } @@ -2408,7 +2408,7 @@ private LastName(string value) public static LastName Create(string lastName) { - return new LastName(lastName); + return new(lastName); } } @@ -2940,15 +2940,15 @@ protected override void Seed(DbContext context) { Id = 707, AlternateId = "Root", - Children = new List { new Child { Id = 11 }, new Child { Id = 12 } }, + Children = new List { new() { Id = 11 }, new() { Id = 12 } }, SinglePkToPk = new SinglePkToPk { Id = 707 }, Single = new Single { Id = 21 }, - ChildrenAk = new List { new ChildAk { Id = 31 }, new ChildAk { Id = 32 } }, + ChildrenAk = new List { new() { Id = 31 }, new() { Id = 32 } }, SingleAk = new SingleAk { Id = 42 }, - ChildrenShadowFk = new List { new ChildShadowFk { Id = 51 }, new ChildShadowFk { Id = 52 } }, + ChildrenShadowFk = new List { new() { Id = 51 }, new() { Id = 52 } }, SingleShadowFk = new SingleShadowFk { Id = 62 }, ChildrenCompositeKey = - new List { new ChildCompositeKey { Id = 51 }, new ChildCompositeKey { Id = 52 } }, + new List { new() { Id = 51 }, new() { Id = 52 } }, SingleCompositeKey = new SingleCompositeKey { Id = 62 }, WithRecursiveProperty = new WithRecursiveProperty { Id = 8086 } }); @@ -3023,7 +3023,7 @@ protected override void Seed(DbContext context) new NonVirtualOneToManyOwner { Id = 300, - Addresses = new List { new OwnedAddress { Street = "4 Privet Drive", PostalCode = "SURREY" } } + Addresses = new List { new() { Street = "4 Privet Drive", PostalCode = "SURREY" } } }); context.Add( @@ -3032,9 +3032,9 @@ protected override void Seed(DbContext context) Id = 400, Addresses = new List { - new OwnedAddress { Street = "The Ministry", PostalCode = "MAG1C" }, - new OwnedAddress { Street = "Diagon Alley", PostalCode = "WC2H 0AW" }, - new OwnedAddress { Street = "Shell Cottage", PostalCode = "THE SEA" } + new() { Street = "The Ministry", PostalCode = "MAG1C" }, + new() { Street = "Diagon Alley", PostalCode = "WC2H 0AW" }, + new() { Street = "Shell Cottage", PostalCode = "THE SEA" } } }); @@ -3042,7 +3042,7 @@ protected override void Seed(DbContext context) new ExplicitLazyLoadNonVirtualOneToManyOwner { Id = 500, - Addresses = new List { new OwnedAddress { Street = "Spinner's End", PostalCode = "BE WA1R" } } + Addresses = new List { new() { Street = "Spinner's End", PostalCode = "BE WA1R" } } }); context.Add( @@ -3051,7 +3051,7 @@ protected override void Seed(DbContext context) Id = 600, Addresses = new List { - new OwnedAddress { Street = "12 Grimmauld Place", PostalCode = "L0N D0N" } + new() { Street = "12 Grimmauld Place", PostalCode = "L0N D0N" } } }); diff --git a/test/EFCore.Specification.Tests/LoadTestBase.cs b/test/EFCore.Specification.Tests/LoadTestBase.cs index d72b95e9b91..c99ce5e7279 100644 --- a/test/EFCore.Specification.Tests/LoadTestBase.cs +++ b/test/EFCore.Specification.Tests/LoadTestBase.cs @@ -129,10 +129,10 @@ public virtual void Attached_collections_are_not_marked_as_loaded(EntityState st { Id = 707, AlternateId = "Root", - Children = new List { new Child { Id = 11 }, new Child { Id = 12 } }, - ChildrenAk = new List { new ChildAk { Id = 31 }, new ChildAk { Id = 32 } }, - ChildrenShadowFk = new List { new ChildShadowFk { Id = 51 }, new ChildShadowFk { Id = 52 } }, - ChildrenCompositeKey = new List { new ChildCompositeKey { Id = 51 }, new ChildCompositeKey { Id = 52 } } + Children = new List { new() { Id = 11 }, new() { Id = 12 } }, + ChildrenAk = new List { new() { Id = 31 }, new() { Id = 32 } }, + ChildrenShadowFk = new List { new() { Id = 51 }, new() { Id = 52 } }, + ChildrenCompositeKey = new List { new() { Id = 51 }, new() { Id = 52 } } }; context.Attach(parent); diff --git a/test/EFCore.Specification.Tests/ManyToManyLoadTestBase.cs b/test/EFCore.Specification.Tests/ManyToManyLoadTestBase.cs index cd8beb1dd27..d27e62fed15 100644 --- a/test/EFCore.Specification.Tests/ManyToManyLoadTestBase.cs +++ b/test/EFCore.Specification.Tests/ManyToManyLoadTestBase.cs @@ -154,24 +154,24 @@ public virtual void Attached_collections_are_not_marked_as_loaded(EntityState st b => { b.Id = 7776; - b.TwoSkip = new ObservableCollection { new EntityTwo { Id = 7777 } }; - b.TwoSkipShared = new ObservableCollection { new EntityTwo { Id = 7778 } }; - b.SelfSkipPayloadLeft = new ObservableCollection { new EntityOne { Id = 7779 } }; - b.SelfSkipPayloadRight = new ObservableCollection { new EntityOne { Id = 7780 } }; - b.BranchSkip = new ObservableCollection { new EntityBranch { Id = 7781 } }; - b.ThreeSkipPayloadFull = new ObservableCollection { new EntityThree { Id = 7782 } }; - b.ThreeSkipPayloadFullShared = new ObservableCollection { new EntityThree { Id = 7783 } }; + b.TwoSkip = new ObservableCollection { new() { Id = 7777 } }; + b.TwoSkipShared = new ObservableCollection { new() { Id = 7778 } }; + b.SelfSkipPayloadLeft = new ObservableCollection { new() { Id = 7779 } }; + b.SelfSkipPayloadRight = new ObservableCollection { new() { Id = 7780 } }; + b.BranchSkip = new ObservableCollection { new() { Id = 7781 } }; + b.ThreeSkipPayloadFull = new ObservableCollection { new() { Id = 7782 } }; + b.ThreeSkipPayloadFullShared = new ObservableCollection { new() { Id = 7783 } }; }) : new EntityOne { Id = 7776, - TwoSkip = new List { new EntityTwo { Id = 7777 } }, - TwoSkipShared = new List { new EntityTwo { Id = 7778 } }, - SelfSkipPayloadLeft = new List { new EntityOne { Id = 7779 } }, - SelfSkipPayloadRight = new List { new EntityOne { Id = 7780 } }, - BranchSkip = new List { new EntityBranch { Id = 7781 } }, - ThreeSkipPayloadFull = new List { new EntityThree { Id = 7782 } }, - ThreeSkipPayloadFullShared = new List { new EntityThree { Id = 7783 } } + TwoSkip = new List { new() { Id = 7777 } }, + TwoSkipShared = new List { new() { Id = 7778 } }, + SelfSkipPayloadLeft = new List { new() { Id = 7779 } }, + SelfSkipPayloadRight = new List { new() { Id = 7780 } }, + BranchSkip = new List { new() { Id = 7781 } }, + ThreeSkipPayloadFull = new List { new() { Id = 7782 } }, + ThreeSkipPayloadFullShared = new List { new() { Id = 7783 } } }; context.Attach(left); diff --git a/test/EFCore.Specification.Tests/MusicStoreTestBase.cs b/test/EFCore.Specification.Tests/MusicStoreTestBase.cs index 6482dc0a8c8..4dc885070f4 100644 --- a/test/EFCore.Specification.Tests/MusicStoreTestBase.cs +++ b/test/EFCore.Specification.Tests/MusicStoreTestBase.cs @@ -236,7 +236,7 @@ await context.Database.CreateExecutionStrategy().ExecuteAsync( } protected Order CreateOrder(string userName = "RainbowDash") - => new Order + => new() { Username = userName, FirstName = "Macavity", diff --git a/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs b/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs index e150fa93eb5..a237246670f 100644 --- a/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs +++ b/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs @@ -123,7 +123,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con protected override void Seed(PoolableDbContext context) { context.Add( - new Blog { Id = 1, Posts = new List { new Post { Id = 1 }, new Post { Id = 2 } } }); + new Blog { Id = 1, Posts = new List { new() { Id = 1 }, new() { Id = 2 } } }); context.SaveChanges(); } diff --git a/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs b/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs index dd1cf360c38..98947ec07e5 100644 --- a/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs +++ b/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs @@ -110,7 +110,7 @@ protected override void Seed(AlbumViewerContext context) { Id = i, Artist = artists[i % 3], - Tracks = new List { new Track { Id = i * 2 }, new Track { Id = i * 2 + 1 } } + Tracks = new List { new() { Id = i * 2 }, new() { Id = i * 2 + 1 } } }); } diff --git a/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs b/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs index a1654e065a9..242a7c2f4e3 100644 --- a/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs +++ b/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs @@ -2154,7 +2154,7 @@ private Building() } public static Building Create(Guid buildingId, string name, decimal value) - => new Building + => new() { BuildingId = buildingId, Name = name, @@ -2364,10 +2364,10 @@ protected override void Seed(PoolableDbContext context) var offices = new List { - new Office { BuildingId = buildings[0].BuildingId, Number = "1/1221" }, - new Office { BuildingId = buildings[0].BuildingId, Number = "1/1223" }, - new Office { BuildingId = buildings[0].BuildingId, Number = "2/1458" }, - new Office { BuildingId = buildings[0].BuildingId, Number = "2/1789" } + new() { BuildingId = buildings[0].BuildingId, Number = "1/1221" }, + new() { BuildingId = buildings[0].BuildingId, Number = "1/1223" }, + new() { BuildingId = buildings[0].BuildingId, Number = "2/1458" }, + new() { BuildingId = buildings[0].BuildingId, Number = "2/1789" } }; foreach (var office in offices) @@ -2421,19 +2421,19 @@ protected override void Seed(PoolableDbContext context) var whiteboards = new List { - new Whiteboard + new() { AssetTag = "WB1973", iD = new byte[] { 1, 9, 7, 3 }, Office = offices[0] }, - new Whiteboard + new() { AssetTag = "WB1977", iD = new byte[] { 1, 9, 7, 7 }, Office = offices[0] }, - new Whiteboard + new() { AssetTag = "WB1970", iD = new byte[] { 1, 9, 7, 0 }, diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs index f3a78c7cfcd..f1b71043acd 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs @@ -31,7 +31,7 @@ public virtual ISetSource GetExpectedData() } public virtual Dictionary<(Type, string), Func> GetShadowPropertyMappings() - => new Dictionary<(Type, string), Func> + => new() { { (typeof(Gear), "AssignedCityName"), diff --git a/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs index 5f0824ca67f..6d6d9df22c5 100644 --- a/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class InheritanceQueryFixtureBase : SharedStoreFixtureBase, IFilteredQueryFixtureBase { - private readonly Dictionary _expectedDataCache = new Dictionary(); + private readonly Dictionary _expectedDataCache = new(); protected override string StoreName { get; } = "InheritanceTest"; diff --git a/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs index 67a333be691..55e0a3b5c1a 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs @@ -1213,7 +1213,7 @@ public virtual async Task Contains_with_local_non_primitive_list_inline_closure_ await AssertQuery( async, ss => ss.Set().Where( - c => new List { new Customer { CustomerID = "ABCDE" }, new Customer { CustomerID = id } } + c => new List { new() { CustomerID = "ABCDE" }, new() { CustomerID = id } } .Select(i => i.CustomerID).Contains(c.CustomerID)), entryCount: 1); id = "ANATR"; @@ -1221,7 +1221,7 @@ await AssertQuery( await AssertQuery( async, ss => ss.Set().Where( - c => new List { new Customer { CustomerID = "ABCDE" }, new Customer { CustomerID = id } } + c => new List { new() { CustomerID = "ABCDE" }, new() { CustomerID = id } } .Select(i => i.CustomerID).Contains(c.CustomerID)), entryCount: 1); } @@ -1229,7 +1229,7 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual Task Contains_with_local_non_primitive_list_closure_mix(bool async) { - var ids = new List { new Customer { CustomerID = "ABCDE" }, new Customer { CustomerID = "ALFKI" } }; + var ids = new List { new() { CustomerID = "ABCDE" }, new() { CustomerID = "ALFKI" } }; return AssertQuery( async, @@ -1478,7 +1478,7 @@ public virtual Task List_Contains_with_constant_list(bool async) return AssertQuery( async, ss => ss.Set().Where( - c => new List { new Customer { CustomerID = "ALFKI" }, new Customer { CustomerID = "ANATR" } }.Contains(c)), + c => new List { new() { CustomerID = "ALFKI" }, new() { CustomerID = "ANATR" } }.Contains(c)), entryCount: 2); } @@ -1486,7 +1486,7 @@ public virtual Task List_Contains_with_constant_list(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task List_Contains_with_parameter_list(bool async) { - var customers = new List { new Customer { CustomerID = "ALFKI" }, new Customer { CustomerID = "ANATR" } }; + var customers = new List { new() { CustomerID = "ALFKI" }, new() { CustomerID = "ANATR" } }; return AssertQuery( async, @@ -1498,7 +1498,7 @@ public virtual Task List_Contains_with_parameter_list(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Contains_with_parameter_list_value_type_id(bool async) { - var orders = new List { new Order { OrderID = 10248 }, new Order { OrderID = 10249 } }; + var orders = new List { new() { OrderID = 10248 }, new() { OrderID = 10249 } }; return AssertQuery( async, @@ -1513,7 +1513,7 @@ public virtual Task Contains_with_constant_list_value_type_id(bool async) return AssertQuery( async, ss => ss.Set().Where( - o => new List { new Order { OrderID = 10248 }, new Order { OrderID = 10249 } }.Contains(o)), + o => new List { new() { OrderID = 10248 }, new() { OrderID = 10249 } }.Contains(o)), entryCount: 2); } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs index 8599c0a924f..7f37ddab484 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs @@ -401,7 +401,7 @@ protected NorthwindContext CreateContext() => Fixture.CreateContext(); protected virtual NorthwindContext CreateNoTrackingContext() - => new NorthwindContext( + => new( new DbContextOptionsBuilder(Fixture.CreateOptions()) .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking).Options); } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs index d3f85f039c2..2b38616d09f 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs @@ -71,7 +71,7 @@ join od in ss.Set().OrderBy(od => ClientOrderBy(od, od.Product)) on entryCount: 89)); } - private static readonly Random _randomGenerator = new Random(); + private static readonly Random _randomGenerator = new(); private static T ClientProjection(T t, object _) => t; diff --git a/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs index ca48db12265..836e08fdd3b 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs @@ -18,7 +18,7 @@ public abstract class NorthwindQueryFixtureBase : SharedStoreF public Func GetContextCreator() => () => CreateContext(); - private readonly Dictionary<(bool, string, string), ISetSource> _expectedDataCache = new Dictionary<(bool, string, string), ISetSource>(); + private readonly Dictionary<(bool, string, string), ISetSource> _expectedDataCache = new(); public virtual ISetSource GetExpectedData() => new NorthwindData(); diff --git a/test/EFCore.Specification.Tests/Query/NorthwindStringIncludeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindStringIncludeQueryTestBase.cs index b4cf574f5bd..351114a1a54 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindStringIncludeQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindStringIncludeQueryTestBase.cs @@ -24,8 +24,7 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NorthwindStringIncludeQueryTestBase : NorthwindIncludeQueryTestBase where TFixture : NorthwindQueryFixtureBase, new() { - private static readonly IncludeRewritingExpressionVisitor _includeRewritingExpressionVisitor = - new IncludeRewritingExpressionVisitor(); + private static readonly IncludeRewritingExpressionVisitor _includeRewritingExpressionVisitor = new(); protected NorthwindStringIncludeQueryTestBase(TFixture fixture) : base(fixture) diff --git a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs index abe1e8b55eb..ea0e09ebfbf 100644 --- a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs @@ -1586,24 +1586,24 @@ public virtual IQueryable Set() } private static IReadOnlyList CreatePlanets() - => new List { new Planet { Id = 1, StarId = 1 } }; + => new List { new() { Id = 1, StarId = 1 } }; private static IReadOnlyList CreateStars() => new List { - new Star + new() { Id = 1, Name = "Sol", Composition = new List { - new Element + new() { Id = "H", Name = "Hydrogen", StarId = 1 }, - new Element + new() { Id = "He", Name = "Helium", @@ -1616,7 +1616,7 @@ private static IReadOnlyList CreateStars() private static IReadOnlyList CreateMoons() => new List { - new Moon + new() { Id = 1, PlanetId = 1, @@ -1679,8 +1679,8 @@ private static IReadOnlyList CreateOwnedPeople() order1["OrderDate"] = Convert.ToDateTime("2018-07-11 10:01:41"); order1.Details = new List { - new OrderDetail { Detail = "Discounted Order" }, - new OrderDetail { Detail = "Full Price Order" } + new() { Detail = "Discounted Order" }, + new() { Detail = "Full Price Order" } }; var order2 = new Order { Id = -11, Client = ownedPerson1 }; @@ -1692,7 +1692,7 @@ private static IReadOnlyList CreateOwnedPeople() order3["OrderDate"] = Convert.ToDateTime("2015-05-25 20:35:48"); order3.Details = new List { - new OrderDetail { Detail = "Internal Order" } + new() { Detail = "Internal Order" } }; ownedPerson2.Orders = new List { order3 }; @@ -1700,7 +1700,7 @@ private static IReadOnlyList CreateOwnedPeople() order4["OrderDate"] = Convert.ToDateTime("2014-11-10 04:32:42"); order4.Details = new List { - new OrderDetail { Detail = "Bulk Order" } + new() { Detail = "Bulk Order" } }; ownedPerson3.Orders = new List { order4 }; @@ -1719,18 +1719,18 @@ private static IReadOnlyList CreateOwnedPeople() } private static IReadOnlyList CreateFinks() - => new List { new Fink { Id = 1 } }; + => new List { new() { Id = 1 } }; private static IReadOnlyList CreateBartons() => new List { - new Barton + new() { Id = 1, Simple = "Simple", Throned = new Throned { Property = "Property", Value = 42 } }, - new Barton + new() { Id = 2, Simple = "Not", } diff --git a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs index 4e5ae987510..5f6969e1d6d 100644 --- a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs @@ -26,7 +26,7 @@ protected QueryTestBase(TFixture fixture) protected QueryAsserter QueryAsserter { get; } protected virtual QueryAsserter CreateQueryAsserter(TFixture fixture) - => new QueryAsserter( + => new( fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, diff --git a/test/EFCore.Specification.Tests/SeedingTestBase.cs b/test/EFCore.Specification.Tests/SeedingTestBase.cs index ef9c7d05070..b8328e3abd0 100644 --- a/test/EFCore.Specification.Tests/SeedingTestBase.cs +++ b/test/EFCore.Specification.Tests/SeedingTestBase.cs @@ -56,7 +56,7 @@ public virtual async Task Seeding_keyless_entity_throws_exception(bool async) protected abstract SeedingContext CreateContextWithEmptyDatabase(string testId); protected virtual KeylessSeedingContext CreateKeylessContextWithEmptyDatabase() - => new KeylessSeedingContext(TestStore.AddProviderOptions(new DbContextOptionsBuilder()).Options); + => new(TestStore.AddProviderOptions(new DbContextOptionsBuilder()).Options); protected abstract class SeedingContext : DbContext { diff --git a/test/EFCore.Specification.Tests/SpatialTestBase.cs b/test/EFCore.Specification.Tests/SpatialTestBase.cs index 13babe0116b..4fce890194e 100644 --- a/test/EFCore.Specification.Tests/SpatialTestBase.cs +++ b/test/EFCore.Specification.Tests/SpatialTestBase.cs @@ -48,10 +48,10 @@ public virtual void Values_arent_compared_by_reference() public virtual void Mutation_of_tracked_values_does_not_mutate_values_in_store() { Point CreatePoint(double y = 2.2) - => new Point(1.1, y, 3.3); + => new(1.1, y, 3.3); Polygon CreatePolygon(double y = 2.2) - => new Polygon( + => new( new LinearRing( new[] { new Coordinate(1.1, 2.2), new Coordinate(2.2, y), new Coordinate(2.2, 1.1), new Coordinate(1.1, 2.2) })); diff --git a/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs b/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs index 5043c873666..a63e2b5a77e 100644 --- a/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs +++ b/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs @@ -18,8 +18,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class StoreGeneratedFixupTestBase : IClassFixture where TFixture : StoreGeneratedFixupTestBase.StoreGeneratedFixupFixtureBase, new() { - protected static readonly Guid Guid77 = new Guid("{DE390D36-DAAC-4C8B-91F7-E9F5DAA7EF01}"); - protected static readonly Guid Guid78 = new Guid("{4C80406F-49AF-4D85-AFFB-75C146A98A70}"); + protected static readonly Guid Guid77 = new("{DE390D36-DAAC-4C8B-91F7-E9F5DAA7EF01}"); + protected static readonly Guid Guid78 = new("{4C80406F-49AF-4D85-AFFB-75C146A98A70}"); protected StoreGeneratedFixupTestBase(TFixture fixture) => Fixture = fixture; @@ -4397,8 +4397,8 @@ private static void AddData(FirstLevel first) { first.SecondLevels = new List { - new SecondLevel { ThirdLevels = new List { new ThirdLevel(), new ThirdLevel() } }, - new SecondLevel { ThirdLevels = new List { new ThirdLevel(), new ThirdLevel() } } + new() { ThirdLevels = new List { new(), new() } }, + new() { ThirdLevels = new List { new(), new() } } }; } diff --git a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs index 7459b493614..20b95124ff8 100644 --- a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs +++ b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs @@ -66,61 +66,61 @@ public static IReadOnlyList CreateLevelOnes(bool tableSplitting) { var result = new List { - new Level1 + new() { Id = 1, Name = "L1 01", Date = new DateTime(2001, 1, 1) }, - new Level1 + new() { Id = 2, Name = "L1 02", Date = new DateTime(2002, 2, 2) }, - new Level1 + new() { Id = 3, Name = "L1 03", Date = new DateTime(2003, 3, 3) }, - new Level1 + new() { Id = 4, Name = "L1 04", Date = new DateTime(2004, 4, 4) }, - new Level1 + new() { Id = 5, Name = "L1 05", Date = new DateTime(2005, 5, 5) }, - new Level1 + new() { Id = 6, Name = "L1 06", Date = new DateTime(2006, 6, 6) }, - new Level1 + new() { Id = 7, Name = "L1 07", Date = new DateTime(2007, 7, 7) }, - new Level1 + new() { Id = 8, Name = "L1 08", Date = new DateTime(2008, 8, 8) }, - new Level1 + new() { Id = 9, Name = "L1 09", Date = new DateTime(2009, 9, 9) }, - new Level1 + new() { Id = 10, Name = "L1 10", @@ -133,19 +133,19 @@ public static IReadOnlyList CreateLevelOnes(bool tableSplitting) result.AddRange( new List { - new Level1 + new() { Id = 11, Name = "L1 11", Date = new DateTime(2009, 11, 11) }, - new Level1 + new() { Id = 12, Name = "L1 12", Date = new DateTime(2008, 12, 12) }, - new Level1 + new() { Id = 13, Name = "L1 13", @@ -169,61 +169,61 @@ public static IReadOnlyList CreateLevelTwos(bool tableSplitting) { var result = new List { - new Level2 + new() { Id = 1, Name = "L2 01", Date = new DateTime(2010, 10, 10) }, - new Level2 + new() { Id = 2, Name = "L2 02", Date = new DateTime(2002, 2, 2) }, - new Level2 + new() { Id = 3, Name = "L2 03", Date = new DateTime(2008, 8, 8) }, - new Level2 + new() { Id = 4, Name = "L2 04", Date = new DateTime(2004, 4, 4) }, - new Level2 + new() { Id = 5, Name = "L2 05", Date = new DateTime(2006, 6, 6) }, - new Level2 + new() { Id = 6, Name = "L2 06", Date = new DateTime(2005, 5, 5) }, - new Level2 + new() { Id = 7, Name = "L2 07", Date = new DateTime(2007, 7, 7) }, - new Level2 + new() { Id = 8, Name = "L2 08", Date = new DateTime(2003, 3, 3) }, - new Level2 + new() { Id = 9, Name = "L2 09", Date = new DateTime(2009, 9, 9) }, - new Level2 + new() { Id = 10, Name = "L2 10", @@ -236,7 +236,7 @@ public static IReadOnlyList CreateLevelTwos(bool tableSplitting) result.AddRange( new List { - new Level2 + new() { Id = 11, Name = "L2 11", @@ -260,16 +260,16 @@ public static IReadOnlyList CreateLevelThrees(bool tableSplitting) { var result = new List { - new Level3 { Id = 1, Name = "L3 01" }, - new Level3 { Id = 2, Name = "L3 02" }, - new Level3 { Id = 3, Name = "L3 03" }, - new Level3 { Id = 4, Name = "L3 04" }, - new Level3 { Id = 5, Name = "L3 05" }, - new Level3 { Id = 6, Name = "L3 06" }, - new Level3 { Id = 7, Name = "L3 07" }, - new Level3 { Id = 8, Name = "L3 08" }, - new Level3 { Id = 9, Name = "L3 09" }, - new Level3 { Id = 10, Name = "L3 10" } + new() { Id = 1, Name = "L3 01" }, + new() { Id = 2, Name = "L3 02" }, + new() { Id = 3, Name = "L3 03" }, + new() { Id = 4, Name = "L3 04" }, + new() { Id = 5, Name = "L3 05" }, + new() { Id = 6, Name = "L3 06" }, + new() { Id = 7, Name = "L3 07" }, + new() { Id = 8, Name = "L3 08" }, + new() { Id = 9, Name = "L3 09" }, + new() { Id = 10, Name = "L3 10" } }; foreach (var l3 in result) @@ -287,16 +287,16 @@ public static IReadOnlyList CreateLevelFours(bool tableSplitting) { var result = new List { - new Level4 { Id = 1, Name = "L4 01" }, - new Level4 { Id = 2, Name = "L4 02" }, - new Level4 { Id = 3, Name = "L4 03" }, - new Level4 { Id = 4, Name = "L4 04" }, - new Level4 { Id = 5, Name = "L4 05" }, - new Level4 { Id = 6, Name = "L4 06" }, - new Level4 { Id = 7, Name = "L4 07" }, - new Level4 { Id = 8, Name = "L4 08" }, - new Level4 { Id = 9, Name = "L4 09" }, - new Level4 { Id = 10, Name = "L4 10" } + new() { Id = 1, Name = "L4 01" }, + new() { Id = 2, Name = "L4 02" }, + new() { Id = 3, Name = "L4 03" }, + new() { Id = 4, Name = "L4 04" }, + new() { Id = 5, Name = "L4 05" }, + new() { Id = 6, Name = "L4 06" }, + new() { Id = 7, Name = "L4 07" }, + new() { Id = 8, Name = "L4 08" }, + new() { Id = 9, Name = "L4 09" }, + new() { Id = 10, Name = "L4 10" } }; foreach (var l4 in result) @@ -322,7 +322,7 @@ public static IReadOnlyList CreateInheritanceBaseOnes() public static IReadOnlyList CreateInheritanceBaseTwos() { - var result = new List { new InheritanceBase2 { Id = 1, Name = "IB2 01" } }; + var result = new List { new() { Id = 1, Name = "IB2 01" } }; return result; } @@ -331,9 +331,9 @@ public static IReadOnlyList CreateInheritanceLeafOnes() { var result = new List { - new InheritanceLeaf1 { Id = 1, Name = "IL1 01" }, - new InheritanceLeaf1 { Id = 2, Name = "IL1 02" }, - new InheritanceLeaf1 { Id = 3, Name = "IL1 03" } + new() { Id = 1, Name = "IL1 01" }, + new() { Id = 2, Name = "IL1 02" }, + new() { Id = 3, Name = "IL1 03" } }; return result; @@ -341,7 +341,7 @@ public static IReadOnlyList CreateInheritanceLeafOnes() public static IReadOnlyList CreateInheritanceLeafTwos() { - var result = new List { new InheritanceLeaf2 { Id = 1, Name = "IL2 01" } }; + var result = new List { new() { Id = 1, Name = "IL2 01" } }; return result; } diff --git a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/F1Context.cs b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/F1Context.cs index 924222d0b8f..66c71f6e4e1 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/F1Context.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/F1Context.cs @@ -31,10 +31,10 @@ private static void AddEntities(F1Context context) { foreach (var engineSupplier in new List { - new EngineSupplier { Name = "Mercedes" }, - new EngineSupplier { Name = "Renault" }, - new EngineSupplier { Name = "Ferrari" }, - new EngineSupplier { Name = "Cosworth" } + new() { Name = "Mercedes" }, + new() { Name = "Renault" }, + new() { Name = "Ferrari" }, + new() { Name = "Cosworth" } }) { context.Add(engineSupplier); @@ -83,7 +83,7 @@ private static void AddEntities(F1Context context) foreach (var team in new List { - new Team + new() { Id = Team.McLaren, Name = "Vodafone McLaren Mercedes", @@ -99,7 +99,7 @@ private static void AddEntities(F1Context context) Poles = 146, FastestLaps = 140 }, - new Team + new() { Id = Team.Mercedes, Name = "Mercedes GP Petronas F1 Team", @@ -115,7 +115,7 @@ private static void AddEntities(F1Context context) Poles = 8, FastestLaps = 9 }, - new Team + new() { Id = Team.RedBull, Name = "Red Bull Racing", @@ -131,7 +131,7 @@ private static void AddEntities(F1Context context) Poles = 16, FastestLaps = 11 }, - new Team + new() { Id = Team.Ferrari, Name = "Scuderia Ferrari Marlboro", @@ -147,7 +147,7 @@ private static void AddEntities(F1Context context) Poles = 203, FastestLaps = 221 }, - new Team + new() { Id = Team.Williams, Name = "AT&T Williams", @@ -163,7 +163,7 @@ private static void AddEntities(F1Context context) Poles = 125, FastestLaps = 130 }, - new Team + new() { Id = Team.Renault, Name = "Renault F1 Team", @@ -179,7 +179,7 @@ private static void AddEntities(F1Context context) Poles = 51, FastestLaps = 31 }, - new Team + new() { Id = Team.ForceIndia, Name = "Force India F1 Team", @@ -195,7 +195,7 @@ private static void AddEntities(F1Context context) Poles = 1, FastestLaps = 1 }, - new Team + new() { Id = Team.ToroRosso, Name = "Scuderia Toro Rosso", @@ -211,7 +211,7 @@ private static void AddEntities(F1Context context) Poles = 1, FastestLaps = 0 }, - new Team + new() { Id = Team.Lotus, Name = "Lotus Racing", @@ -227,7 +227,7 @@ private static void AddEntities(F1Context context) Poles = 102, FastestLaps = 65 }, - new Team + new() { Id = Team.Hispania, Name = "Hispania Racing F1 Team (HRT)", @@ -243,7 +243,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Team + new() { Id = Team.Sauber, Name = "BMW Sauber F1 Team", @@ -259,7 +259,7 @@ private static void AddEntities(F1Context context) Poles = 1, FastestLaps = 2 }, - new Team + new() { Id = Team.Vickers, Name = "Vickers Racing", @@ -282,7 +282,7 @@ private static void AddEntities(F1Context context) foreach (var driver in new List { - new Driver + new() { Id = 1, Name = "Jenson Button", @@ -295,7 +295,7 @@ private static void AddEntities(F1Context context) Poles = 7, FastestLaps = 3 }, - new Driver + new() { Id = 2, Name = "Lewis Hamilton", @@ -321,7 +321,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Driver + new() { Id = 4, Name = "Michael Schumacher", @@ -334,7 +334,7 @@ private static void AddEntities(F1Context context) Poles = 68, FastestLaps = 76 }, - new Driver + new() { Id = 5, Name = "Nico Rosberg", @@ -360,7 +360,7 @@ private static void AddEntities(F1Context context) Poles = 1, FastestLaps = 2 }, - new Driver + new() { Id = 7, Name = "Sebastian Vettel", @@ -373,7 +373,7 @@ private static void AddEntities(F1Context context) Poles = 12, FastestLaps = 6 }, - new Driver + new() { Id = 8, Name = "Mark Webber", @@ -425,7 +425,7 @@ private static void AddEntities(F1Context context) Poles = 12, FastestLaps = 18 }, - new Driver + new() { Id = 12, Name = "Felipe Massa", @@ -438,7 +438,7 @@ private static void AddEntities(F1Context context) Poles = 15, FastestLaps = 12 }, - new Driver + new() { Id = 13, Name = "Fernando Alonso", @@ -490,7 +490,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Driver + new() { Id = 17, Name = "Rubens Barrichello", @@ -503,7 +503,7 @@ private static void AddEntities(F1Context context) Poles = 14, FastestLaps = 17 }, - new Driver + new() { Id = 18, Name = "Nico Hülkenberg", @@ -529,7 +529,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Driver + new() { Id = 20, Name = "Robert Kubica", @@ -542,7 +542,7 @@ private static void AddEntities(F1Context context) Poles = 1, FastestLaps = 1 }, - new Driver + new() { Id = 21, Name = "Vitaly Petrov", @@ -594,7 +594,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Driver + new() { Id = 25, Name = "Adrian Sutil", @@ -607,7 +607,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 1 }, - new Driver + new() { Id = 26, Name = "Vitantonio Liuzzi", @@ -633,7 +633,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Driver + new() { Id = 28, Name = "Sébastien Buemi", @@ -646,7 +646,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Driver + new() { Id = 29, Name = "Jaime Alguersuari", @@ -685,7 +685,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Driver + new() { Id = 32, Name = "Jarno Trulli", @@ -698,7 +698,7 @@ private static void AddEntities(F1Context context) Poles = 4, FastestLaps = 1 }, - new Driver + new() { Id = 33, Name = "Heikki Kovalainen", @@ -724,7 +724,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Driver + new() { Id = 35, Name = "Karun Chandhok", @@ -737,7 +737,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Driver + new() { Id = 36, Name = "Bruno Senna", @@ -776,7 +776,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 0 }, - new Driver + new() { Id = 39, Name = "Timo Glock", @@ -789,7 +789,7 @@ private static void AddEntities(F1Context context) Poles = 0, FastestLaps = 1 }, - new Driver + new() { Id = 40, Name = "Lucas di Grassi", diff --git a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Sponsor.cs b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Sponsor.cs index d5f06f9d17c..5d3092f4a60 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Sponsor.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Sponsor.cs @@ -10,7 +10,7 @@ public class Sponsor { public static readonly string ClientTokenPropertyName = "ClientToken"; - private readonly ObservableCollection _teams = new ObservableCollection(); + private readonly ObservableCollection _teams = new(); public int Id { get; set; } public string Name { get; set; } diff --git a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs index 9e07beb9631..995a3679eb1 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs @@ -12,7 +12,7 @@ public class Team { private readonly ILazyLoader _loader; private readonly ObservableCollection _drivers = new ObservableCollectionListSource(); - private readonly ObservableCollection _sponsors = new ObservableCollection(); + private readonly ObservableCollection _sponsors = new(); private Engine _engine; private Chassis _chassis; private Gearbox _gearbox; diff --git a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SessionResponse.cs b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SessionResponse.cs index 29f0ee8c95c..6835f0446ec 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SessionResponse.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SessionResponse.cs @@ -9,6 +9,6 @@ public class SessionResponse : Session { public Track Track { get; set; } - public List Speakers { get; set; } = new List(); + public List Speakers { get; set; } = new(); } } diff --git a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs index d3e9f7871a5..038b2226cb6 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner public static class EntityExtensions { public static SessionResponse MapSessionResponse(this Session session) - => new SessionResponse + => new() { Id = session.Id, Title = session.Title, @@ -24,7 +24,7 @@ public static SessionResponse MapSessionResponse(this Session session) }; public static SpeakerResponse MapSpeakerResponse(this Speaker speaker) - => new SpeakerResponse + => new() { Id = speaker.Id, Name = speaker.Name, @@ -38,7 +38,7 @@ public static SpeakerResponse MapSpeakerResponse(this Speaker speaker) }; public static AttendeeResponse MapAttendeeResponse(this Attendee attendee) - => new AttendeeResponse + => new() { Id = attendee.Id, FirstName = attendee.FirstName, diff --git a/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataData.cs b/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataData.cs index 0bf22ce066d..50d0e7d3208 100644 --- a/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataData.cs +++ b/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataData.cs @@ -31,127 +31,127 @@ public virtual IQueryable Set() public static IReadOnlyList CreateFunkyCustomers() => new List { - new FunkyCustomer + new() { Id = 1, FirstName = "%Bar", LastName = "%B", NullableBool = true }, - new FunkyCustomer + new() { Id = 2, FirstName = "Ba%r", LastName = "a%", NullableBool = true }, - new FunkyCustomer + new() { Id = 3, FirstName = "Bar%", LastName = "%B%", NullableBool = true }, - new FunkyCustomer + new() { Id = 4, FirstName = "%Ba%r%", LastName = null, NullableBool = false }, - new FunkyCustomer + new() { Id = 5, FirstName = "B%a%%r%", LastName = "r%", NullableBool = false }, - new FunkyCustomer + new() { Id = 6, FirstName = null, LastName = "%B%a%r" }, - new FunkyCustomer + new() { Id = 7, FirstName = "%B%a%r", LastName = "" }, - new FunkyCustomer + new() { Id = 8, FirstName = "", LastName = "%%r%" }, - new FunkyCustomer + new() { Id = 9, FirstName = "_Bar", LastName = "_B", NullableBool = false }, - new FunkyCustomer + new() { Id = 10, FirstName = "Ba_r", LastName = "a_", NullableBool = false }, - new FunkyCustomer + new() { Id = 11, FirstName = "Bar_", LastName = "_B_", NullableBool = false }, - new FunkyCustomer + new() { Id = 12, FirstName = "_Ba_r_", LastName = null, NullableBool = true }, - new FunkyCustomer + new() { Id = 13, FirstName = "B_a__r_", LastName = "r_", NullableBool = true }, - new FunkyCustomer + new() { Id = 14, FirstName = null, LastName = "_B_a_r" }, - new FunkyCustomer + new() { Id = 15, FirstName = "_B_a_r", LastName = "" }, - new FunkyCustomer + new() { Id = 16, FirstName = "", LastName = "__r_" }, - new FunkyCustomer + new() { Id = 17, FirstName = "[]Bar", LastName = "[]", NullableBool = true }, - new FunkyCustomer + new() { Id = 18, FirstName = "B[a]r", LastName = "B[", NullableBool = true }, - new FunkyCustomer + new() { Id = 19, FirstName = "B[[a^r", diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs index dc64d892a2b..ccf9da82e3c 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs @@ -107,14 +107,14 @@ public virtual IQueryable Set() public static IReadOnlyList CreateSquads() => new List { - new Squad + new() { Id = 1, Name = "Delta", Banner = new byte[] { 0x00, 0x01 }, Banner5 = new byte[] { 0x04, 0x05, 0x06, 0x07, 0x08 } }, - new Squad + new() { Id = 2, Name = "Kilo", @@ -126,7 +126,7 @@ public static IReadOnlyList CreateSquads() public static IReadOnlyList CreateMissions() => new List { - new Mission + new() { Id = 1, CodeName = "Lightmass Offensive", @@ -134,7 +134,7 @@ public static IReadOnlyList CreateMissions() Timeline = new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0)), Duration = new TimeSpan(1, 2, 3) }, - new Mission + new() { Id = 2, CodeName = "Hollow Storm", @@ -142,7 +142,7 @@ public static IReadOnlyList CreateMissions() Timeline = new DateTimeOffset(2, 3, 1, 8, 0, 0, new TimeSpan(-5, 0, 0)), Duration = new TimeSpan(0, 1, 2, 3, 456) }, - new Mission + new() { Id = 3, CodeName = "Halvo Bay defense", @@ -155,9 +155,9 @@ public static IReadOnlyList CreateMissions() public static IReadOnlyList CreateSquadMissions() => new List { - new SquadMission(), - new SquadMission(), - new SquadMission() + new(), + new(), + new() }; public static IReadOnlyList CreateCities() @@ -193,70 +193,70 @@ public static IReadOnlyList CreateCities() public static IReadOnlyList CreateWeapons() => new List { - new Weapon + new() { Id = 1, Name = "Marcus' Lancer", AmmunitionType = AmmunitionType.Cartridge, IsAutomatic = true }, - new Weapon + new() { Id = 2, Name = "Marcus' Gnasher", AmmunitionType = AmmunitionType.Shell, IsAutomatic = false }, - new Weapon + new() { Id = 3, Name = "Dom's Hammerburst", AmmunitionType = AmmunitionType.Cartridge, IsAutomatic = false }, - new Weapon + new() { Id = 4, Name = "Dom's Gnasher", AmmunitionType = AmmunitionType.Shell, IsAutomatic = false }, - new Weapon + new() { Id = 5, Name = "Cole's Gnasher", AmmunitionType = AmmunitionType.Shell, IsAutomatic = false }, - new Weapon + new() { Id = 6, Name = "Cole's Mulcher", AmmunitionType = AmmunitionType.Cartridge, IsAutomatic = true }, - new Weapon + new() { Id = 7, Name = "Baird's Lancer", AmmunitionType = AmmunitionType.Cartridge, IsAutomatic = true }, - new Weapon + new() { Id = 8, Name = "Baird's Gnasher", AmmunitionType = AmmunitionType.Shell, IsAutomatic = false }, - new Weapon + new() { Id = 9, Name = "Paduk's Markza", AmmunitionType = AmmunitionType.Cartridge, IsAutomatic = false }, - new Weapon + new() { Id = 10, Name = "Mauler's Flail", @@ -267,18 +267,18 @@ public static IReadOnlyList CreateWeapons() public static IReadOnlyList CreateTags() => new List { - new CogTag { Id = Guid.Parse("DF36F493-463F-4123-83F9-6B135DEEB7BA"), Note = "Dom's Tag", IssueDate = new DateTime(3, 2, 2) }, - new CogTag { Id = Guid.Parse("A8AD98F9-E023-4E2A-9A70-C2728455BD34"), Note = "Cole's Tag", IssueDate = new DateTime(2, 10, 11) }, - new CogTag { Id = Guid.Parse("A7BE028A-0CF2-448F-AB55-CE8BC5D8CF69"), Note = "Paduk's Tag", IssueDate = new DateTime(15, 3, 7) }, - new CogTag { Id = Guid.Parse("70534E05-782C-4052-8720-C2C54481CE5F"), Note = "Baird's Tag", IssueDate = new DateTime(7, 5, 3) }, - new CogTag { Id = Guid.Parse("34C8D86E-A4AC-4BE5-827F-584DDA348A07"), Note = "Marcus' Tag", IssueDate = new DateTime(1, 9, 25) }, - new CogTag { Id = Guid.Parse("B39A6FBA-9026-4D69-828E-FD7068673E57"), Note = "K.I.A.", IssueDate = new DateTime(21, 7, 7) } + new() { Id = Guid.Parse("DF36F493-463F-4123-83F9-6B135DEEB7BA"), Note = "Dom's Tag", IssueDate = new DateTime(3, 2, 2) }, + new() { Id = Guid.Parse("A8AD98F9-E023-4E2A-9A70-C2728455BD34"), Note = "Cole's Tag", IssueDate = new DateTime(2, 10, 11) }, + new() { Id = Guid.Parse("A7BE028A-0CF2-448F-AB55-CE8BC5D8CF69"), Note = "Paduk's Tag", IssueDate = new DateTime(15, 3, 7) }, + new() { Id = Guid.Parse("70534E05-782C-4052-8720-C2C54481CE5F"), Note = "Baird's Tag", IssueDate = new DateTime(7, 5, 3) }, + new() { Id = Guid.Parse("34C8D86E-A4AC-4BE5-827F-584DDA348A07"), Note = "Marcus' Tag", IssueDate = new DateTime(1, 9, 25) }, + new() { Id = Guid.Parse("B39A6FBA-9026-4D69-828E-FD7068673E57"), Note = "K.I.A.", IssueDate = new DateTime(21, 7, 7) } }; public static IReadOnlyList CreateGears() => new List { - new Gear + new() { Nickname = "Dom", FullName = "Dominic Santiago", @@ -289,7 +289,7 @@ public static IReadOnlyList CreateGears() LeaderNickname = "Marcus", LeaderSquadId = 1 }, - new Gear + new() { Nickname = "Cole Train", FullName = "Augustus Cole", @@ -300,7 +300,7 @@ public static IReadOnlyList CreateGears() LeaderNickname = "Marcus", LeaderSquadId = 1 }, - new Gear + new() { Nickname = "Paduk", FullName = "Garron Paduk", @@ -336,21 +336,21 @@ public static IReadOnlyList CreateGears() public static IReadOnlyList CreateLocustLeaders() => new List { - new LocustLeader + new() { Name = "General Karn", ThreatLevel = 3, ThreatLevelByte = 3, ThreatLevelNullableByte = 3 }, - new LocustLeader + new() { Name = "General RAAM", ThreatLevel = 4, ThreatLevelByte = 4, ThreatLevelNullableByte = 4 }, - new LocustLeader + new() { Name = "High Priest Skorge", ThreatLevel = 1, @@ -364,7 +364,7 @@ public static IReadOnlyList CreateLocustLeaders() ThreatLevelByte = 5, ThreatLevelNullableByte = 5 }, - new LocustLeader + new() { Name = "The Speaker", ThreatLevel = 3, @@ -402,7 +402,7 @@ public static IReadOnlyList CreateFactions() public static IReadOnlyList CreateHighCommands() => new List { - new LocustHighCommand + new() { Id = 1, Name = "Locust Main Command", diff --git a/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs b/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs index 78d5355eaae..d32a23bc1b5 100644 --- a/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs +++ b/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs @@ -171,7 +171,7 @@ public static IReadOnlyList CreateAnimals() public static IReadOnlyList CreateCountries() => new List { - new Country { Id = 1, Name = "New Zealand" }, new Country { Id = 2, Name = "USA" }, + new() { Id = 1, Name = "New Zealand" }, new() { Id = 2, Name = "USA" }, }; public static IReadOnlyList CreateDrinks() diff --git a/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs b/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs index d2d12586686..e7c37a706fa 100644 --- a/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs +++ b/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs @@ -133,26 +133,26 @@ public virtual IQueryable Set() public static IReadOnlyList CreateBaseEntities() => new List { - new BaseInheritanceRelationshipEntity + new() { Id = 1, Name = "Base1", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB1" }, OwnedCollectionOnBase = - new List { new OwnedEntity { Id = 1, Name = "OCOB11" }, new OwnedEntity { Id = 2, Name = "OCOB12" } }, + new List { new() { Id = 1, Name = "OCOB11" }, new() { Id = 2, Name = "OCOB12" } }, BaseCollectionOnBase = new List(), CollectionOnBase = new List(), }, - new BaseInheritanceRelationshipEntity + new() { Id = 2, Name = "Base2", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB2" }, - OwnedCollectionOnBase = new List { new OwnedEntity { Id = 3, Name = "OCOB21" } }, + OwnedCollectionOnBase = new List { new() { Id = 3, Name = "OCOB21" } }, BaseCollectionOnBase = new List(), CollectionOnBase = new List(), }, - new BaseInheritanceRelationshipEntity + new() { Id = 3, Name = "Base3", @@ -166,10 +166,10 @@ public static IReadOnlyList CreateBaseEntitie Name = "Derived1(4)", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB4" }, OwnedCollectionOnBase = - new List { new OwnedEntity { Id = 4, Name = "OCOB41" }, new OwnedEntity { Id = 5, Name = "OCOB42" } }, + new List { new() { Id = 4, Name = "OCOB41" }, new() { Id = 5, Name = "OCOB42" } }, OwnedReferenceOnDerived = new OwnedEntity { Name = "OROD4" }, OwnedCollectionOnDerived = - new List { new OwnedEntity { Id = 1, Name = "OCOD41" }, new OwnedEntity { Id = 2, Name = "OCOD42" } }, + new List { new() { Id = 1, Name = "OCOD41" }, new() { Id = 2, Name = "OCOD42" } }, BaseCollectionOnBase = new List(), BaseCollectionOnDerived = new List(), CollectionOnBase = new List(), @@ -181,9 +181,9 @@ public static IReadOnlyList CreateBaseEntitie Id = 5, Name = "Derived2(5)", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB5" }, - OwnedCollectionOnBase = new List { new OwnedEntity { Id = 6, Name = "OCOB51" } }, + OwnedCollectionOnBase = new List { new() { Id = 6, Name = "OCOB51" } }, OwnedReferenceOnDerived = new OwnedEntity { Name = "OROD5" }, - OwnedCollectionOnDerived = new List { new OwnedEntity { Id = 3, Name = "OCOD51" } }, + OwnedCollectionOnDerived = new List { new() { Id = 3, Name = "OCOD51" } }, BaseCollectionOnBase = new List(), BaseCollectionOnDerived = new List(), CollectionOnBase = new List(), @@ -207,19 +207,19 @@ public static IReadOnlyList CreateBaseEntitie public static IReadOnlyList CreateBaseReferencesOnBase() => new List { - new BaseReferenceOnBase + new() { Id = 1, Name = "BROB1", NestedCollection = new List() }, - new BaseReferenceOnBase + new() { Id = 2, Name = "BROB2", NestedCollection = new List() }, - new BaseReferenceOnBase + new() { Id = 3, Name = "BROB3 (dangling)", @@ -260,9 +260,9 @@ public static IReadOnlyList CreateBaseReferencesOnBase() public static IReadOnlyList CreateBaseReferencesOnDerived() => new List { - new BaseReferenceOnDerived { Id = 1, Name = "BROD1" }, - new BaseReferenceOnDerived { Id = 2, Name = "BROD2 (dangling)" }, - new BaseReferenceOnDerived { Id = 3, Name = "BROD3 (dangling)" }, + new() { Id = 1, Name = "BROD1" }, + new() { Id = 2, Name = "BROD2 (dangling)" }, + new() { Id = 3, Name = "BROD3 (dangling)" }, new DerivedReferenceOnDerived { Id = 4, Name = "DROD1" }, new DerivedReferenceOnDerived { Id = 5, Name = "DROD2" }, new DerivedReferenceOnDerived { Id = 6, Name = "DROD3 (dangling)" }, @@ -271,27 +271,27 @@ public static IReadOnlyList CreateBaseReferencesOnDerive public static IReadOnlyList CreateReferencesOnBase() => new List { - new ReferenceOnBase { Id = 1, Name = "ROB1" }, - new ReferenceOnBase { Id = 2, Name = "ROB2" }, - new ReferenceOnBase { Id = 3, Name = "ROB3" }, - new ReferenceOnBase { Id = 4, Name = "ROB4" }, + new() { Id = 1, Name = "ROB1" }, + new() { Id = 2, Name = "ROB2" }, + new() { Id = 3, Name = "ROB3" }, + new() { Id = 4, Name = "ROB4" }, }; public static IReadOnlyList CreateReferencesOnDerived() => new List { - new ReferenceOnDerived { Id = 1, Name = "ROD1" }, - new ReferenceOnDerived { Id = 2, Name = "ROD2" }, - new ReferenceOnDerived { Id = 3, Name = "ROD3 (dangling)" }, + new() { Id = 1, Name = "ROD1" }, + new() { Id = 2, Name = "ROD2" }, + new() { Id = 3, Name = "ROD3 (dangling)" }, }; public static IReadOnlyList CreateNestedReferences() => new List { - new NestedReferenceBase { Id = 1, Name = "NRB1" }, - new NestedReferenceBase { Id = 2, Name = "NRB2" }, - new NestedReferenceBase { Id = 3, Name = "NRB3" }, - new NestedReferenceBase { Id = 4, Name = "NRB4 (dangling)" }, + new() { Id = 1, Name = "NRB1" }, + new() { Id = 2, Name = "NRB2" }, + new() { Id = 3, Name = "NRB3" }, + new() { Id = 4, Name = "NRB4 (dangling)" }, new NestedReferenceDerived { Id = 5, Name = "NRD1" }, new NestedReferenceDerived { Id = 6, Name = "NRD2" }, new NestedReferenceDerived { Id = 7, Name = "NRD3" }, @@ -302,31 +302,31 @@ public static IReadOnlyList CreateNestedReferences() public static IReadOnlyList CreateBaseCollectionsOnBase() => new List { - new BaseCollectionOnBase + new() { Id = 1, Name = "BCOB11", NestedCollection = new List() }, - new BaseCollectionOnBase + new() { Id = 2, Name = "BCOB12", NestedCollection = new List() }, - new BaseCollectionOnBase + new() { Id = 3, Name = "BCOB21", NestedCollection = new List() }, - new BaseCollectionOnBase + new() { Id = 4, Name = "BCOB31 (dangling)", NestedCollection = new List() }, - new BaseCollectionOnBase + new() { Id = 5, Name = "BCOB32 (dangling)", @@ -393,9 +393,9 @@ public static IReadOnlyList CreateBaseCollectionsOnBase() public static IReadOnlyList CreateBaseCollectionsOnDerived() => new List { - new BaseCollectionOnDerived { Id = 1, Name = "BCOD11" }, - new BaseCollectionOnDerived { Id = 2, Name = "BCOD21 (dangling)" }, - new BaseCollectionOnDerived { Id = 3, Name = "BCOD22 (dangling)" }, + new() { Id = 1, Name = "BCOD11" }, + new() { Id = 2, Name = "BCOD21 (dangling)" }, + new() { Id = 3, Name = "BCOD22 (dangling)" }, new DerivedCollectionOnDerived { Id = 4, Name = "DCOD11" }, new DerivedCollectionOnDerived { Id = 5, Name = "DCOD12" }, new DerivedCollectionOnDerived { Id = 6, Name = "DCOD21" }, @@ -405,34 +405,34 @@ public static IReadOnlyList CreateBaseCollectionsOnDeri public static IReadOnlyList CreateCollectionsOnBase() => new List { - new CollectionOnBase { Id = 1, Name = "COB11" }, - new CollectionOnBase { Id = 2, Name = "COB12" }, - new CollectionOnBase { Id = 3, Name = "COB21" }, - new CollectionOnBase { Id = 4, Name = "COB31" }, - new CollectionOnBase { Id = 5, Name = "COB32" }, - new CollectionOnBase { Id = 6, Name = "COB33" }, - new CollectionOnBase { Id = 7, Name = "COB41" }, - new CollectionOnBase { Id = 8, Name = "COB51 (dangling)" }, - new CollectionOnBase { Id = 9, Name = "COB52 (dangling)" }, + new() { Id = 1, Name = "COB11" }, + new() { Id = 2, Name = "COB12" }, + new() { Id = 3, Name = "COB21" }, + new() { Id = 4, Name = "COB31" }, + new() { Id = 5, Name = "COB32" }, + new() { Id = 6, Name = "COB33" }, + new() { Id = 7, Name = "COB41" }, + new() { Id = 8, Name = "COB51 (dangling)" }, + new() { Id = 9, Name = "COB52 (dangling)" }, }; public static IReadOnlyList CreateCollectionsOnDerived() => new List { - new CollectionOnDerived { Id = 1, Name = "COD11" }, - new CollectionOnDerived { Id = 2, Name = "COD21" }, - new CollectionOnDerived { Id = 3, Name = "COD22" }, - new CollectionOnDerived { Id = 4, Name = "COD31 (dangling)" }, + new() { Id = 1, Name = "COD11" }, + new() { Id = 2, Name = "COD21" }, + new() { Id = 3, Name = "COD22" }, + new() { Id = 4, Name = "COD31 (dangling)" }, }; public static IReadOnlyList CreateNestedCollections() => new List { - new NestedCollectionBase { Id = 1, Name = "NCB11" }, - new NestedCollectionBase { Id = 2, Name = "NCB21" }, - new NestedCollectionBase { Id = 3, Name = "NCB22" }, - new NestedCollectionBase { Id = 4, Name = "NCB31" }, - new NestedCollectionBase { Id = 5, Name = "NCB41 (dangling)" }, + new() { Id = 1, Name = "NCB11" }, + new() { Id = 2, Name = "NCB21" }, + new() { Id = 3, Name = "NCB22" }, + new() { Id = 4, Name = "NCB31" }, + new() { Id = 5, Name = "NCB41 (dangling)" }, new NestedCollectionDerived { Id = 6, Name = "NCD11" }, new NestedCollectionDerived { Id = 7, Name = "NCD21" }, new NestedCollectionDerived { Id = 8, Name = "NCD21" }, @@ -446,19 +446,19 @@ public static IReadOnlyList CreateNestedCollections() public static IReadOnlyList CreatePrincipalEntities() => new List { - new PrincipalEntity { Id = 1, Name = "PE1" }, new PrincipalEntity { Id = 2, Name = "PE2" }, + new() { Id = 1, Name = "PE1" }, new() { Id = 2, Name = "PE2" }, }; public static IReadOnlyList CreateReferencedEntities() => new List { - new ReferencedEntity + new() { Id = 1, Name = "RE1", Principals = new List() }, - new ReferencedEntity + new() { Id = 2, Name = "RE2", diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ProxyableSharedType.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ProxyableSharedType.cs index a523151f246..f64656327b5 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ProxyableSharedType.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ProxyableSharedType.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.TestModels.ManyToManyModel { public class ProxyableSharedType { - private readonly Dictionary _keyValueStore = new Dictionary(); + private readonly Dictionary _keyValueStore = new(); public virtual object this[string key] { diff --git a/test/EFCore.Specification.Tests/TestModels/MusicStore/ShoppingCart.cs b/test/EFCore.Specification.Tests/TestModels/MusicStore/ShoppingCart.cs index f2a3e3b4e79..1c12a80c008 100644 --- a/test/EFCore.Specification.Tests/TestModels/MusicStore/ShoppingCart.cs +++ b/test/EFCore.Specification.Tests/TestModels/MusicStore/ShoppingCart.cs @@ -20,7 +20,7 @@ private ShoppingCart(MusicStoreContext dbContext, string id) } public static ShoppingCart GetCart(MusicStoreContext db, string cartId) - => new ShoppingCart(db, cartId); + => new(db, cartId); public async Task AddToCart(Album album) { diff --git a/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs b/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs index 198ac208de1..72413836e1d 100644 --- a/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs @@ -26,7 +26,7 @@ public int GetId() => 2; public Indirection GetFlag() - => new Indirection(); + => new(); public List TenantIds { get; set; } public Indirection IndirectionFlag { get; set; } @@ -218,7 +218,7 @@ public static void SeedData(QueryFilterFuncletizationContext context) new ExtensionContextFilter { IsEnabled = false }, new ParameterFilter { Tenant = 1 }, new ParameterFilter { Tenant = 2 }, - new PrincipalSetFilter { Dependents = new List { new DependentSetFilter(), new DependentSetFilter() } }, + new PrincipalSetFilter { Dependents = new List { new(), new() } }, new PrincipalSetFilter(), new MultiContextFilter { BossId = 1, IsEnabled = true }, new MultiContextFilter { BossId = 1, IsEnabled = false }, diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs index 00a51408b37..305f3e93e28 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs @@ -104,7 +104,7 @@ public void AssertSeeded() protected IEnumerable CreateVehicles() => new List { - new Vehicle + new() { Name = "Trek Pro Fit Madone 6 Series", SeatingCapacity = 1, diff --git a/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs index 0f27a7cccab..2f04a5dfb92 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { internal class AnnotationComparer : IEqualityComparer, IComparer { - public static readonly AnnotationComparer Instance = new AnnotationComparer(); + public static readonly AnnotationComparer Instance = new(); private AnnotationComparer() { diff --git a/test/EFCore.Specification.Tests/TestUtilities/DataGenerator.cs b/test/EFCore.Specification.Tests/TestUtilities/DataGenerator.cs index 49485a58abd..01e1132e4b3 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/DataGenerator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/DataGenerator.cs @@ -9,10 +9,8 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public static class DataGenerator { - private static readonly ConcurrentDictionary Values = new ConcurrentDictionary(); - - private static readonly ConcurrentDictionary _boolCombinations - = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary Values = new(); + private static readonly ConcurrentDictionary _boolCombinations = new(); public static object[][] GetBoolCombinations(int length) => _boolCombinations.GetOrAdd(length, l => GetCombinations(Values[typeof(bool)], l)); diff --git a/test/EFCore.Specification.Tests/TestUtilities/GeometryComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/GeometryComparer.cs index d026f0f8837..6b681f5108d 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/GeometryComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/GeometryComparer.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class GeometryComparer : IEqualityComparer { - public static GeometryComparer Instance { get; } = new GeometryComparer(); + public static GeometryComparer Instance { get; } = new(); private GeometryComparer() { diff --git a/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs b/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs index 090bda6b7c4..686e629d85f 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs @@ -77,14 +77,14 @@ public static string NormalizeLineEndings(string expectedString) protected class ListLogger : ILogger { - private readonly object _sync = new object(); + private readonly object _sync = new(); private CancellationTokenSource _cancellationTokenSource; protected bool IsRecordingSuspended { get; private set; } public ITestOutputHelper TestOutputHelper { get; set; } public List<(LogLevel, EventId, string, object, Exception)> LoggedEvents { get; } - = new List<(LogLevel, EventId, string, object, Exception)>(); + = new(); public CancellationToken CancelOnNextLogEntry() { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs index 069fb48d271..d60cebf414c 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs @@ -34,7 +34,7 @@ public class QueryAsserter private readonly bool _ignoreEntryCount; private const bool ProceduralQueryGeneration = false; - private readonly List _includePath = new List(); + private readonly List _includePath = new(); private readonly ISetSource _expectedData; public QueryAsserter( diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendIncludeToExistingExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendIncludeToExistingExpressionMutator.cs index 5a5dbc641c0..312a9384137 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendIncludeToExistingExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendIncludeToExistingExpressionMutator.cs @@ -87,7 +87,7 @@ public override Expression Apply(Expression expression, Random random) private class ExpressionFinder : ExpressionVisitor { - public readonly List FoundExpressions = new List(); + public readonly List FoundExpressions = new(); protected override Expression VisitMethodCall(MethodCallExpression node) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectConstantExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectConstantExpressionMutator.cs index 90afe7aa551..628dbce1933 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectConstantExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectConstantExpressionMutator.cs @@ -15,7 +15,7 @@ public AppendSelectConstantExpressionMutator(DbContext context) { } - private readonly List<(Type type, Expression expression)> _expressions = new List<(Type type, Expression expression)> + private readonly List<(Type type, Expression expression)> _expressions = new() { (type: typeof(int), expression: Expression.Constant(42, typeof(int))), (type: typeof(int?), expression: Expression.Constant(7, typeof(int?))), diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectCoalesceExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectCoalesceExpressionMutator.cs index 8adf2738276..4bfeadbe10e 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectCoalesceExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectCoalesceExpressionMutator.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities.QueryTestGeneration { public class InjectCoalesceExpressionMutator : ExpressionMutator { - private readonly ExpressionFinder _expressionFinder = new ExpressionFinder(); + private readonly ExpressionFinder _expressionFinder = new(); public InjectCoalesceExpressionMutator(DbContext context) : base(context) @@ -43,7 +43,7 @@ private class ExpressionFinder : ExpressionVisitor { private bool _insideLambda; - public List FoundExpressions { get; } = new List(); + public List FoundExpressions { get; } = new(); public override Expression Visit(Expression node) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectIncludeExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectIncludeExpressionMutator.cs index dde4c924f09..5939b253ffa 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectIncludeExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectIncludeExpressionMutator.cs @@ -66,14 +66,14 @@ private class ExpressionFinder : ExpressionVisitor { private readonly InjectIncludeExpressionMutator _mutator; - private readonly List _topLevelEntityTypes = new List(); + private readonly List _topLevelEntityTypes = new(); public ExpressionFinder(InjectIncludeExpressionMutator mutator) { _mutator = mutator; } - public readonly List FoundExpressions = new List(); + public readonly List FoundExpressions = new(); private int _depth; diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectJoinWithSelfExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectJoinWithSelfExpressionMutator.cs index cb5e345bf14..4bb63018bf4 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectJoinWithSelfExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectJoinWithSelfExpressionMutator.cs @@ -62,7 +62,7 @@ public ExpressionFinder(InjectJoinWithSelfExpressionMutator mutator) _mutator = mutator; } - public List FoundExpressions { get; } = new List(); + public List FoundExpressions { get; } = new(); protected override Expression VisitMethodCall(MethodCallExpression node) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectOrderByPropertyExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectOrderByPropertyExpressionMutator.cs index 85d6f240b5a..978acd66c40 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectOrderByPropertyExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectOrderByPropertyExpressionMutator.cs @@ -83,7 +83,7 @@ public ExpressionFinder(InjectOrderByPropertyExpressionMutator mutator) _mutator = mutator; } - public Dictionary> FoundExpressions { get; } = new Dictionary>(); + public Dictionary> FoundExpressions { get; } = new(); public override Expression Visit(Expression expression) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectStringFunctionExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectStringFunctionExpressionMutator.cs index 821ab5cc306..eb263d41376 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectStringFunctionExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectStringFunctionExpressionMutator.cs @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities.QueryTestGeneration { public class InjectStringFunctionExpressionMutator : ExpressionMutator { - private readonly ExpressionFinder _expressionFinder = new ExpressionFinder(); + private readonly ExpressionFinder _expressionFinder = new(); public InjectStringFunctionExpressionMutator(DbContext context) : base(context) @@ -44,7 +44,7 @@ private class ExpressionFinder : ExpressionVisitor private bool _insideLambda; private bool _insideEFProperty; - public List FoundExpressions { get; } = new List(); + public List FoundExpressions { get; } = new(); public override Expression Visit(Expression node) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectThenByPropertyExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectThenByPropertyExpressionMutator.cs index cbbebde287c..277a7478335 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectThenByPropertyExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectThenByPropertyExpressionMutator.cs @@ -83,7 +83,7 @@ public ExpressionFinder(InjectThenByPropertyExpressionMutator mutator) _mutator = mutator; } - public Dictionary> FoundExpressions { get; } = new Dictionary>(); + public Dictionary> FoundExpressions { get; } = new(); public override Expression Visit(Expression expression) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectWhereExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectWhereExpressionMutator.cs index 94c541db8d3..dffb548fb9c 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectWhereExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectWhereExpressionMutator.cs @@ -119,7 +119,7 @@ public ExpressionFinder(InjectWhereExpressionMutator mutator) _mutator = mutator; } - public List FoundExpressions { get; } = new List(); + public List FoundExpressions { get; } = new(); public override Expression Visit(Expression expression) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs index c52cba407d6..c1958aaf6c0 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs @@ -57,7 +57,7 @@ public Expression Generate(Expression expression, Random random) public class ProcedurallyGeneratedQueryExecutor { - private static readonly Dictionary> _knownFailingTests = new Dictionary>(); + private static readonly Dictionary> _knownFailingTests = new(); static ProcedurallyGeneratedQueryExecutor() { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/StringConcatWithSelfExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/StringConcatWithSelfExpressionMutator.cs index f46cf97fd87..de3e757c8e0 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/StringConcatWithSelfExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/StringConcatWithSelfExpressionMutator.cs @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities.QueryTestGeneration { public class StringConcatWithSelfExpressionMutator : ExpressionMutator { - private readonly ExpressionFinder _expressionFinder = new ExpressionFinder(); + private readonly ExpressionFinder _expressionFinder = new(); public StringConcatWithSelfExpressionMutator(DbContext context) : base(context) @@ -44,7 +44,7 @@ private class ExpressionFinder : ExpressionVisitor { private bool _insideLambda; - public List FoundExpressions { get; } = new List(); + public List FoundExpressions { get; } = new(); public override Expression Visit(Expression node) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs b/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs index fd4bc44d080..cf4129f0a69 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs @@ -74,32 +74,32 @@ public DbContextOptionsBuilder AddProviderOptions(DbContextOptionsBuilder option public abstract void UseProviderOptions(DbContextOptionsBuilder optionsBuilder); public DbContext CreateContext(IServiceProvider serviceProvider, IModel model) - => new DbContext(CreateOptions(model, serviceProvider)); + => new(CreateOptions(model, serviceProvider)); public DbContext CreateContext(IServiceProvider serviceProvider, DbContextOptions options) - => new DbContext(new DbContextOptionsBuilder(options).UseInternalServiceProvider(serviceProvider).Options); + => new(new DbContextOptionsBuilder(options).UseInternalServiceProvider(serviceProvider).Options); public DbContext CreateContext(IServiceProvider serviceProvider) - => new DbContext(CreateOptions(serviceProvider)); + => new(CreateOptions(serviceProvider)); public DbContext CreateContext(IModel model) - => new DbContext(CreateOptions(model, CreateServiceProvider())); + => new(CreateOptions(model, CreateServiceProvider())); public DbContext CreateContext(DbContextOptions options) - => new DbContext(new DbContextOptionsBuilder(options).UseInternalServiceProvider(CreateServiceProvider()).Options); + => new(new DbContextOptionsBuilder(options).UseInternalServiceProvider(CreateServiceProvider()).Options); public DbContext CreateContext() - => new DbContext(CreateOptions(CreateServiceProvider())); + => new(CreateOptions(CreateServiceProvider())); public DbContext CreateContext(IServiceCollection customServices, IModel model) - => new DbContext(CreateOptions(model, CreateServiceProvider(customServices))); + => new(CreateOptions(model, CreateServiceProvider(customServices))); public DbContext CreateContext(IServiceCollection customServices, DbContextOptions options) - => new DbContext( + => new( new DbContextOptionsBuilder(options).UseInternalServiceProvider(CreateServiceProvider(customServices)).Options); public DbContext CreateContext(IServiceCollection customServices) - => new DbContext(CreateOptions(CreateServiceProvider(customServices))); + => new(CreateOptions(CreateServiceProvider(customServices))); public IServiceProvider CreateContextServices(IServiceProvider serviceProvider, IModel model) => ((IInfrastructure)CreateContext(serviceProvider, model)).Instance; diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestServiceFactory.cs b/test/EFCore.Specification.Tests/TestUtilities/TestServiceFactory.cs index 5fc6a73070e..029d7bdf467 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestServiceFactory.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestServiceFactory.cs @@ -16,14 +16,13 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class TestServiceFactory { - public static readonly TestServiceFactory Instance = new TestServiceFactory(); + public static readonly TestServiceFactory Instance = new(); private TestServiceFactory() { } - private readonly ConcurrentDictionary _factories - = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _factories = new(); private readonly IReadOnlyList<(Type Type, object Implementation)> _wellKnownExceptions = new List<(Type, object)> diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs b/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs index d664e9819e3..16f9bd5cfbe 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public abstract class TestStore : IDisposable { - private static readonly TestStoreIndex _globalTestStoreIndex = new TestStoreIndex(); + private static readonly TestStoreIndex _globalTestStoreIndex = new(); public IServiceProvider ServiceProvider { get; protected set; } protected TestStore(string name, bool shared) @@ -87,7 +87,7 @@ public virtual Task CleanAsync(DbContext context) } protected virtual DbContext CreateDefaultContext() - => new DbContext(AddProviderOptions(new DbContextOptionsBuilder().EnableServiceProviderCaching(false)).Options); + => new(AddProviderOptions(new DbContextOptionsBuilder().EnableServiceProviderCaching(false)).Options); protected virtual TestStoreIndex GetTestStoreIndex(IServiceProvider serviceProvider) => _globalTestStoreIndex; @@ -102,7 +102,7 @@ public virtual Task DisposeAsync() return Task.CompletedTask; } - private static readonly SemaphoreSlim _transactionSyncRoot = new SemaphoreSlim(1); + private static readonly SemaphoreSlim _transactionSyncRoot = new(1); public static IDisposable CreateTransactionScope(bool useTransaction = true) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestStoreIndex.cs b/test/EFCore.Specification.Tests/TestUtilities/TestStoreIndex.cs index afa9ceffcaa..f6c9200ff62 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestStoreIndex.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestStoreIndex.cs @@ -10,12 +10,9 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class TestStoreIndex { - private readonly HashSet _createdDatabases = new HashSet(); - - private readonly ConcurrentDictionary _creationLocks - = new ConcurrentDictionary(); - - private readonly object _hashSetLock = new object(); + private readonly HashSet _createdDatabases = new(); + private readonly ConcurrentDictionary _creationLocks = new(); + private readonly object _hashSetLock = new(); public virtual void CreateShared(string name, Action initializeDatabase) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/WKTComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/WKTComparer.cs index 6055b9cbc73..f016272f2e2 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/WKTComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/WKTComparer.cs @@ -9,9 +9,9 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class WKTComparer : IEqualityComparer { - private static readonly WKTReader _reader = new WKTReader(); + private static readonly WKTReader _reader = new(); - public static WKTComparer Instance { get; } = new WKTComparer(); + public static WKTComparer Instance { get; } = new(); private WKTComparer() { diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/PlatformSkipConditionAttribute.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/PlatformSkipConditionAttribute.cs index d733c776727..3c2b5c310d1 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/PlatformSkipConditionAttribute.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/PlatformSkipConditionAttribute.cs @@ -18,7 +18,7 @@ public PlatformSkipConditionAttribute(TestPlatform excludedPlatforms) } public ValueTask IsMetAsync() - => new ValueTask(CanRunOnThisPlatform(_excludedPlatforms)); + => new(CanRunOnThisPlatform(_excludedPlatforms)); public string SkipReason { get; set; } = "Test cannot run on this platform."; diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/XunitTestCaseExtensions.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/XunitTestCaseExtensions.cs index 80ea34accaf..963f0fff98a 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/XunitTestCaseExtensions.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/XunitTestCaseExtensions.cs @@ -13,11 +13,8 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities.Xunit { public static class XunitTestCaseExtensions { - private static readonly ConcurrentDictionary> _typeAttributes - = new ConcurrentDictionary>(); - - private static readonly ConcurrentDictionary> _assemblyAttributes - = new ConcurrentDictionary>(); + private static readonly ConcurrentDictionary> _typeAttributes = new(); + private static readonly ConcurrentDictionary> _assemblyAttributes = new(); public static async ValueTask TrySkipAsync(XunitTestCase testCase, IMessageBus messageBus) { diff --git a/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs index fdd9fe7b1ce..5a269df45f1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs @@ -789,7 +789,7 @@ private static void AssertMappedDataTypes(MappedDataTypes entity, int id) } private static MappedDataTypes CreateMappedDataTypes(int id) - => new MappedDataTypes + => new() { Int = id, LongAsBigInt = 78L, @@ -963,7 +963,7 @@ private static void AssertMappedSquareDataTypes(MappedSquareDataTypes entity, in } private static MappedSquareDataTypes CreateMappedSquareDataTypes(int id) - => new MappedSquareDataTypes + => new() { Int = id, LongAsBigInt = 78L, @@ -1141,7 +1141,7 @@ private static void AssertMappedNullableDataTypes(MappedNullableDataTypes entity } private static MappedNullableDataTypes CreateMappedNullableDataTypes(int id) - => new MappedNullableDataTypes + => new() { Int = id, LongAsBigint = 78L, @@ -1392,7 +1392,7 @@ private static void AssertMappedSizedDataTypes(MappedSizedDataTypes entity, int } private static MappedSizedDataTypes CreateMappedSizedDataTypes(int id) - => new MappedSizedDataTypes + => new() { Id = id, StringAsChar3 = "Wor", @@ -1547,7 +1547,7 @@ private static void AssertMappedSizedSeparatelyDataTypes(MappedSizedSeparatelyDa } private static MappedSizedSeparatelyDataTypes CreateMappedSizedSeparatelyDataTypes(int id) - => new MappedSizedSeparatelyDataTypes + => new() { Id = id, StringAsChar3 = "Wor", @@ -1618,7 +1618,7 @@ private static void AssertMappedScaledDataTypes(MappedScaledDataTypes entity, in } private static MappedScaledDataTypes CreateMappedScaledDataTypes(int id) - => new MappedScaledDataTypes + => new() { Id = id, FloatAsFloat3 = 83.3f, @@ -1679,7 +1679,7 @@ private static void AssertMappedScaledSeparatelyDataTypes(MappedScaledSeparately } private static MappedScaledSeparatelyDataTypes CreateMappedScaledSeparatelyDataTypes(int id) - => new MappedScaledSeparatelyDataTypes + => new() { Id = id, FloatAsFloat3 = 83.3f, @@ -1727,7 +1727,7 @@ private static void AssertMappedPrecisionAndScaledDataTypes(MappedPrecisionAndSc } private static MappedPrecisionAndScaledDataTypes CreateMappedPrecisionAndScaledDataTypes(int id) - => new MappedPrecisionAndScaledDataTypes + => new() { Id = id, DecimalAsDecimal52 = 101.1m, @@ -1770,7 +1770,7 @@ private static void AssertMappedPrecisionAndScaledSeparatelyDataTypes(MappedPrec } private static MappedPrecisionAndScaledSeparatelyDataTypes CreateMappedPrecisionAndScaledSeparatelyDataTypes(int id) - => new MappedPrecisionAndScaledSeparatelyDataTypes + => new() { Id = id, DecimalAsDecimal52 = 101.1m, @@ -1910,7 +1910,7 @@ private static void AssertMappedDataTypesWithIdentity(MappedDataTypesWithIdentit } private static MappedDataTypesWithIdentity CreateMappedDataTypesWithIdentity(int id) - => new MappedDataTypesWithIdentity + => new() { Int = id, LongAsBigint = 78L, @@ -2098,7 +2098,7 @@ private static void AssertMappedNullableDataTypesWithIdentity(MappedNullableData } private static MappedNullableDataTypesWithIdentity CreateMappedNullableDataTypesWithIdentity(int id) - => new MappedNullableDataTypesWithIdentity + => new() { Int = id, LongAsBigint = 78L, @@ -2352,7 +2352,7 @@ private static void AssertMappedSizedDataTypesWithIdentity(MappedSizedDataTypesW } private static MappedSizedDataTypesWithIdentity CreateMappedSizedDataTypesWithIdentity(int id) - => new MappedSizedDataTypesWithIdentity + => new() { Int = id, StringAsChar3 = "Wor", @@ -2488,7 +2488,7 @@ private static void AssertMappedScaledDataTypesWithIdentity(MappedScaledDataType } private static MappedScaledDataTypesWithIdentity CreateMappedScaledDataTypesWithIdentity(int id) - => new MappedScaledDataTypesWithIdentity + => new() { Int = id, FloatAsFloat3 = 83.3f, @@ -2540,7 +2540,7 @@ private static void AssertMappedPrecisionAndScaledDataTypesWithIdentity( } private static MappedPrecisionAndScaledDataTypesWithIdentity CreateMappedPrecisionAndScaledDataTypesWithIdentity(int id) - => new MappedPrecisionAndScaledDataTypesWithIdentity + => new() { Int = id, DecimalAsDecimal52 = 101.1m, @@ -3623,7 +3623,7 @@ public override bool SupportsBinaryKeys => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); } [Flags] diff --git a/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs index b6ebd893910..b651fe11f12 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs @@ -34,7 +34,7 @@ protected override IServiceCollection InjectInterceptors( } protected override BadUniverseContext CreateBadUniverse(DbContextOptionsBuilder optionsBuilder) - => new BadUniverseContext(optionsBuilder.UseSqlServer(new FakeDbConnection()).Options); + => new(optionsBuilder.UseSqlServer(new FakeDbConnection()).Options); public class FakeDbConnection : DbConnection { diff --git a/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs index 742c952a0d2..1392dae2618 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs @@ -197,7 +197,7 @@ public override bool SupportsDecimalComparisons => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base diff --git a/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs index 9a417c96987..24ed8552773 100644 --- a/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs @@ -319,7 +319,7 @@ public override bool SupportsDecimalComparisons => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base diff --git a/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs b/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs index 4e2e5fbca39..dbc27d8fd2f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs @@ -1147,7 +1147,7 @@ async Task ProcessRequest() private int _stopwatchStarted; - private readonly Stopwatch _stopwatch = new Stopwatch(); + private readonly Stopwatch _stopwatch = new(); private long _requests; diff --git a/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs index c0dfaba318c..54e1df005f2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs @@ -221,7 +221,7 @@ public override bool SupportsDecimalComparisons => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base @@ -241,7 +241,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con public class SqlServerBytesTestStoreFactory : SqlServerTestStoreFactory { - public static new SqlServerBytesTestStoreFactory Instance { get; } = new SqlServerBytesTestStoreFactory(); + public static new SqlServerBytesTestStoreFactory Instance { get; } = new(); public override IServiceCollection AddProviderServices(IServiceCollection serviceCollection) => base.AddProviderServices( @@ -250,15 +250,9 @@ public override IServiceCollection AddProviderServices(IServiceCollection servic public class SqlServerBytesTypeMappingSource : RelationalTypeMappingSource { - private readonly SqlServerByteArrayTypeMapping _rowversion - = new SqlServerByteArrayTypeMapping("rowversion", size: 8); - - private readonly SqlServerByteArrayTypeMapping _variableLengthBinary - = new SqlServerByteArrayTypeMapping(); - - private readonly SqlServerByteArrayTypeMapping _fixedLengthBinary - = new SqlServerByteArrayTypeMapping(fixedLength: true); - + private readonly SqlServerByteArrayTypeMapping _rowversion = new("rowversion", size: 8); + private readonly SqlServerByteArrayTypeMapping _variableLengthBinary = new(); + private readonly SqlServerByteArrayTypeMapping _fixedLengthBinary = new(fixedLength: true); private readonly Dictionary _storeTypeMappings; public SqlServerBytesTypeMappingSource( diff --git a/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs index 92ca317806c..d18ae751214 100644 --- a/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs @@ -217,7 +217,7 @@ public override bool SupportsDecimalComparisons => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base @@ -239,7 +239,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con public class SqlServerStringsTestStoreFactory : SqlServerTestStoreFactory { - public static new SqlServerStringsTestStoreFactory Instance { get; } = new SqlServerStringsTestStoreFactory(); + public static new SqlServerStringsTestStoreFactory Instance { get; } = new(); public override IServiceCollection AddProviderServices(IServiceCollection serviceCollection) => base.AddProviderServices( @@ -248,18 +248,10 @@ public override IServiceCollection AddProviderServices(IServiceCollection servic public class SqlServerStringsTypeMappingSource : RelationalTypeMappingSource { - private readonly SqlServerStringTypeMapping _fixedLengthUnicodeString - = new SqlServerStringTypeMapping(unicode: true, fixedLength: true); - - private readonly SqlServerStringTypeMapping _variableLengthUnicodeString - = new SqlServerStringTypeMapping(unicode: true); - - private readonly SqlServerStringTypeMapping _fixedLengthAnsiString - = new SqlServerStringTypeMapping(fixedLength: true); - - private readonly SqlServerStringTypeMapping _variableLengthAnsiString - = new SqlServerStringTypeMapping(); - + private readonly SqlServerStringTypeMapping _fixedLengthUnicodeString = new(unicode: true, fixedLength: true); + private readonly SqlServerStringTypeMapping _variableLengthUnicodeString = new(unicode: true); + private readonly SqlServerStringTypeMapping _fixedLengthAnsiString = new(fixedLength: true); + private readonly SqlServerStringTypeMapping _variableLengthAnsiString = new(); private readonly Dictionary _storeTypeMappings; public SqlServerStringsTypeMappingSource( diff --git a/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs b/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs index f15b9708893..ad2e8c2f3ab 100644 --- a/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs @@ -54,7 +54,7 @@ protected TestStore CreateTestStore() } private MemoryOptimizedContext CreateContext() - => new MemoryOptimizedContext(Fixture.CreateOptions(TestStore)); + => new(Fixture.CreateOptions(TestStore)); public class MemoryOptimizedTablesFixture : ServiceProviderFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/NavigationTest.cs b/test/EFCore.SqlServer.FunctionalTests/NavigationTest.cs index 6607424aa67..d25fb05e2f0 100644 --- a/test/EFCore.SqlServer.FunctionalTests/NavigationTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/NavigationTest.cs @@ -114,6 +114,6 @@ public NavigationTestFixture() } public virtual GoTContext CreateContext() - => new GoTContext(_options); + => new(_options); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs index 30b56d00860..1012587d3bb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs @@ -1529,8 +1529,8 @@ public void Seed() { Posts = new List { - new Post5456 { Comments = new List { new Comment5456(), new Comment5456() } }, - new Post5456() + new() { Comments = new List { new(), new() } }, + new() }, Author = new Author5456() }); @@ -5133,7 +5133,7 @@ public static implicit operator string(Bar6864 bar) => bar.Value; public Bar6864 Clone() - => new Bar6864(_value); + => new(_value); } } @@ -7491,7 +7491,7 @@ public void Seed() public class AppEntity21803 { - private readonly List _otherEntities = new List(); + private readonly List _otherEntities = new(); public int Id { get; private set; } @@ -8623,7 +8623,7 @@ FROM [Entities] AS [e] protected class MyContext10295 : DbContext { - private readonly List _ids = new List { 1, 7 }; + private readonly List _ids = new() { 1, 7 }; public DbSet Entities { get; set; } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyFixture.cs index 3e4a486e62c..799801bb57e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyFixture.cs @@ -22,7 +22,7 @@ public NtsGeometryServices GeometryServices () => CreateGeometryServices()); protected static NtsGeometryServices CreateGeometryServices() - => new NtsGeometryServices( + => new( NtsGeometryServices.Instance.DefaultCoordinateSequenceFactory, NtsGeometryServices.Instance.DefaultPrecisionModel, 4326); diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerApiConsistencyTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerApiConsistencyTest.cs index ff4e8c3ce5d..cac3768eae8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerApiConsistencyTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerApiConsistencyTest.cs @@ -28,7 +28,7 @@ protected override Assembly TargetAssembly public class SqlServerApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new HashSet + public override HashSet FluentApiTypes { get; } = new() { typeof(SqlServerDbContextOptionsBuilder), typeof(SqlServerDbContextOptionsExtensions), @@ -43,8 +43,7 @@ public class SqlServerApiConsistencyFixture : ApiConsistencyFixtureBase public override List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type - ConventionBuilderExtensions)> MetadataExtensionTypes { get; } - = new List<(Type, Type, Type, Type, Type)> + ConventionBuilderExtensions)> MetadataExtensionTypes { get; } = new() { (typeof(IModel), typeof(SqlServerModelExtensions), typeof(SqlServerModelExtensions), typeof(SqlServerModelExtensions), typeof(SqlServerModelBuilderExtensions)), diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs index 73f4edbdae1..8cbba25bc1e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs @@ -376,8 +376,8 @@ public void Insert_with_non_key_default_value() var blogs = new List { - new Blog { Name = "One Unicorn" }, - new Blog + new() { Name = "One Unicorn" }, + new() { Name = "Two Unicorns", CreatedOn = new DateTime(1969, 8, 3, 0, 10, 0), diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerAdventureWorksTestStoreFactory.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerAdventureWorksTestStoreFactory.cs index 7d7084d1b22..bbbe79be0ed 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerAdventureWorksTestStoreFactory.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerAdventureWorksTestStoreFactory.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class SqlServerAdventureWorksTestStoreFactory : SqlServerTestStoreFactory { - public static new SqlServerAdventureWorksTestStoreFactory Instance { get; } = new SqlServerAdventureWorksTestStoreFactory(); + public static new SqlServerAdventureWorksTestStoreFactory Instance { get; } = new(); protected SqlServerAdventureWorksTestStoreFactory() { diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs index 035cd4aa2ab..ad2fa8b45d7 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs @@ -12,8 +12,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities public sealed class SqlServerConfiguredConditionAttribute : Attribute, ITestCondition { public ValueTask IsMetAsync() - => new ValueTask( - TestEnvironment.IsConfigured && (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || !TestEnvironment.IsLocalDb)); + => new(TestEnvironment.IsConfigured && (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || !TestEnvironment.IsLocalDb)); public string SkipReason => TestEnvironment.IsLocalDb diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerNorthwindTestStoreFactory.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerNorthwindTestStoreFactory.cs index 5047eff6474..0bbaf0b28ab 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerNorthwindTestStoreFactory.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerNorthwindTestStoreFactory.cs @@ -7,7 +7,7 @@ public class SqlServerNorthwindTestStoreFactory : SqlServerTestStoreFactory { public const string Name = "Northwind"; public static readonly string NorthwindConnectionString = SqlServerTestStore.CreateConnectionString(Name); - public static new SqlServerNorthwindTestStoreFactory Instance { get; } = new SqlServerNorthwindTestStoreFactory(); + public static new SqlServerNorthwindTestStoreFactory Instance { get; } = new(); protected SqlServerNorthwindTestStoreFactory() { diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestHelpers.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestHelpers.cs index a132c9b3f55..77564acba69 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestHelpers.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestHelpers.cs @@ -14,7 +14,7 @@ protected SqlServerTestHelpers() { } - public static SqlServerTestHelpers Instance { get; } = new SqlServerTestHelpers(); + public static SqlServerTestHelpers Instance { get; } = new(); public override IServiceCollection AddProviderServices(IServiceCollection services) => services.AddEntityFrameworkSqlServer(); diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs index 77727f336b9..a9e1e619ca3 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs @@ -29,16 +29,16 @@ public static SqlServerTestStore GetNorthwindStore() .GetOrCreate(SqlServerNorthwindTestStoreFactory.Name).Initialize(null, (Func)null); public static SqlServerTestStore GetOrCreate(string name) - => new SqlServerTestStore(name); + => new(name); public static SqlServerTestStore GetOrCreateInitialized(string name) => new SqlServerTestStore(name).InitializeSqlServer(null, (Func)null, null); public static SqlServerTestStore GetOrCreate(string name, string scriptPath, bool? multipleActiveResultSets = null) - => new SqlServerTestStore(name, scriptPath: scriptPath, multipleActiveResultSets: multipleActiveResultSets); + => new(name, scriptPath: scriptPath, multipleActiveResultSets: multipleActiveResultSets); public static SqlServerTestStore Create(string name, bool useFileName = false) - => new SqlServerTestStore(name, useFileName, shared: false); + => new(name, useFileName, shared: false); public static SqlServerTestStore CreateInitialized(string name, bool useFileName = false, bool? multipleActiveResultSets = null) => new SqlServerTestStore(name, useFileName, shared: false, multipleActiveResultSets: multipleActiveResultSets) diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStoreFactory.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStoreFactory.cs index cdb2a66f55e..16f02cf6e0e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStoreFactory.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStoreFactory.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class SqlServerTestStoreFactory : RelationalTestStoreFactory { - public static SqlServerTestStoreFactory Instance { get; } = new SqlServerTestStoreFactory(); + public static SqlServerTestStoreFactory Instance { get; } = new(); protected SqlServerTestStoreFactory() { diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs index ece420e46ef..b4eb7129334 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs @@ -27,7 +27,7 @@ public virtual IRelationalCommandBuilder Create() private class TestRelationalCommandBuilder : IRelationalCommandBuilder { - private readonly List _parameters = new List(); + private readonly List _parameters = new(); public TestRelationalCommandBuilder( RelationalCommandBuilderDependencies dependencies) @@ -35,7 +35,7 @@ public TestRelationalCommandBuilder( Dependencies = dependencies; } - public IndentedStringBuilder Instance { get; } = new IndentedStringBuilder(); + public IndentedStringBuilder Instance { get; } = new(); public RelationalCommandBuilderDependencies Dependencies { get; } @@ -125,7 +125,7 @@ public int ExecuteNonQuery(RelationalCommandParameterObject parameterObject) public Task ExecuteNonQueryAsync( RelationalCommandParameterObject parameterObject, - CancellationToken cancellationToken = new CancellationToken()) + CancellationToken cancellationToken = new()) { var connection = parameterObject.Connection; var errorNumber = PreExecution(connection); @@ -157,7 +157,7 @@ public object ExecuteScalar(RelationalCommandParameterObject parameterObject) public async Task ExecuteScalarAsync( RelationalCommandParameterObject parameterObject, - CancellationToken cancellationToken = new CancellationToken()) + CancellationToken cancellationToken = new()) { var connection = parameterObject.Connection; var errorNumber = PreExecution(connection); @@ -190,7 +190,7 @@ public RelationalDataReader ExecuteReader(RelationalCommandParameterObject param public async Task ExecuteReaderAsync( RelationalCommandParameterObject parameterObject, - CancellationToken cancellationToken = new CancellationToken()) + CancellationToken cancellationToken = new()) { var connection = parameterObject.Connection; var errorNumber = PreExecution(connection); diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestSqlServerConnection.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestSqlServerConnection.cs index b9cb89ac4d6..fbfb6cc99a1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestSqlServerConnection.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestSqlServerConnection.cs @@ -18,10 +18,10 @@ public TestSqlServerConnection(RelationalConnectionDependencies dependencies) } public int ErrorNumber { get; set; } = -2; - public Queue OpenFailures { get; } = new Queue(); + public Queue OpenFailures { get; } = new(); public int OpenCount { get; set; } - public Queue CommitFailures { get; } = new Queue(); - public Queue ExecutionFailures { get; } = new Queue(); + public Queue CommitFailures { get; } = new(); + public Queue ExecutionFailures { get; } = new(); public int ExecutionCount { get; set; } public override bool Open(bool errorsExpected = false) diff --git a/test/EFCore.SqlServer.FunctionalTests/TwoDatabasesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/TwoDatabasesSqlServerTest.cs index d66be4da382..a35c251dad9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TwoDatabasesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TwoDatabasesSqlServerTest.cs @@ -24,7 +24,7 @@ protected override DbContextOptionsBuilder CreateTestOptions( : optionsBuilder.UseSqlServer(); protected override TwoDatabasesWithDataContext CreateBackingContext(string databaseName) - => new TwoDatabasesWithDataContext(Fixture.CreateOptions(SqlServerTestStore.Create(databaseName))); + => new(Fixture.CreateOptions(SqlServerTestStore.Create(databaseName))); protected override string DummyConnectionString { get; } = "Database=DoesNotExist"; } diff --git a/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerTest.cs index 2d616562738..72861754718 100644 --- a/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerTest.cs @@ -26,7 +26,7 @@ public virtual void Save_with_shared_foreign_key() context => { context.AddRange( - new ProductWithBytes { ProductCategories = new List { new ProductCategory { CategoryId = 77 } } }, + new ProductWithBytes { ProductCategories = new List { new() { CategoryId = 77 } } }, new Category { Id = 77, PrincipalId = 777 }); context.SaveChanges(); diff --git a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs index bac030f2e87..a9190f2318d 100644 --- a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs @@ -231,7 +231,7 @@ public void GenerateFluentApi_IProperty_works_with_HiLo() } private SqlServerAnnotationCodeGenerator CreateGenerator() - => new SqlServerAnnotationCodeGenerator( + => new( new AnnotationCodeGeneratorDependencies( new SqlServerTypeMappingSource( new TypeMappingSourceDependencies( diff --git a/test/EFCore.SqlServer.Tests/SqlServerDatabaseCreatorTest.cs b/test/EFCore.SqlServer.Tests/SqlServerDatabaseCreatorTest.cs index 46dd32da2ab..58e5f54059e 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerDatabaseCreatorTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerDatabaseCreatorTest.cs @@ -206,8 +206,8 @@ public IRelationalCommandBuilder Create() private class FakeRelationalCommandBuilder : IRelationalCommandBuilder { - private readonly List _parameters = new List(); - public IndentedStringBuilder Instance { get; } = new IndentedStringBuilder(); + private readonly List _parameters = new(); + public IndentedStringBuilder Instance { get; } = new(); public IReadOnlyList Parameters => _parameters; diff --git a/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs b/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs index 4581f51dc2e..62392722406 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs @@ -24,7 +24,7 @@ protected override Assembly TargetAssembly public class SqlServerNTSApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new HashSet + public override HashSet FluentApiTypes { get; } = new() { typeof(SqlServerNetTopologySuiteDbContextOptionsBuilderExtensions), typeof(SqlServerNetTopologySuiteServiceCollectionExtensions) diff --git a/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs b/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs index c05db4b378e..8bd63dc49dd 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs @@ -226,9 +226,7 @@ public IRelationalCommand Build(string sql) public RawSqlCommand Build( string sql, IEnumerable parameters) - => new RawSqlCommand( - new FakeRelationalCommand(this), - new Dictionary()); + => new(new FakeRelationalCommand(this), new Dictionary()); private class FakeRelationalCommand : IRelationalCommand { diff --git a/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs index c35c09a6fc0..546f9588c45 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs @@ -71,7 +71,7 @@ private static void AssertMappedDataTypes(MappedDataTypes entity, int id) } private static MappedDataTypes CreateMappedDataTypes(int id) - => new MappedDataTypes + => new() { Id = id, Int = 77, @@ -109,7 +109,7 @@ private static void AssertMappedNullableDataTypes(MappedNullableDataTypes entity } private static MappedNullableDataTypes CreateMappedNullableDataTypes(int id) - => new MappedNullableDataTypes + => new() { Id = id, Int = 77, @@ -174,7 +174,7 @@ private static void AssertMappedSizedDataTypes(MappedSizedDataTypes entity, int } private static MappedSizedDataTypes CreateMappedSizedDataTypes(int id) - => new MappedSizedDataTypes + => new() { Id = id, Nvarchar = "Into", @@ -233,7 +233,7 @@ private static void AssertMappedScaledDataTypes(MappedScaledDataTypes entity, in } private static MappedScaledDataTypes CreateMappedScaledDataTypes(int id) - => new MappedScaledDataTypes + => new() { Id = id, Float = 83.3f, @@ -290,7 +290,7 @@ private static void AssertMappedDataTypesWithIdentity(MappedDataTypesWithIdentit } private static MappedDataTypesWithIdentity CreateMappedDataTypesWithIdentity(int id) - => new MappedDataTypesWithIdentity + => new() { AltId = id, Int = 77, @@ -329,7 +329,7 @@ private static void AssertMappedNullableDataTypesWithIdentity(MappedNullableData } private static MappedNullableDataTypesWithIdentity CreateMappedNullableDataTypesWithIdentity(int id) - => new MappedNullableDataTypesWithIdentity + => new() { AltId = id, Int = 77, @@ -395,7 +395,7 @@ private static void AssertMappedSizedDataTypesWithIdentity(MappedSizedDataTypesW } private static MappedSizedDataTypesWithIdentity CreateMappedSizedDataTypesWithIdentity(int id) - => new MappedSizedDataTypesWithIdentity + => new() { AltId = id, Nvarchar = "Into", @@ -454,7 +454,7 @@ private static void AssertMappedScaledDataTypesWithIdentity(MappedScaledDataType } private static MappedScaledDataTypesWithIdentity CreateMappedScaledDataTypesWithIdentity(int id) - => new MappedScaledDataTypesWithIdentity + => new() { AltId = id, Float = 83.3f, @@ -1772,7 +1772,7 @@ public override bool SupportsBinaryKeys => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); } protected class MappedDataTypes diff --git a/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs index 28194080075..fb2cef132ce 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs @@ -17,7 +17,7 @@ protected ConnectionInterceptionSqliteTestBase(InterceptionSqliteFixtureBase fix } protected override BadUniverseContext CreateBadUniverse(DbContextOptionsBuilder optionsBuilder) - => new BadUniverseContext(optionsBuilder.UseSqlite("Data Source=file:data.db?mode=invalidmode").Options); + => new(optionsBuilder.UseSqlite("Data Source=file:data.db?mode=invalidmode").Options); public abstract class InterceptionSqliteFixtureBase : InterceptionFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs index 70bcc5df654..2c207303295 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs @@ -44,7 +44,7 @@ public override bool SupportsBinaryKeys => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs index 296bde454d3..9dbc838d1c1 100644 --- a/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs @@ -145,7 +145,7 @@ public override bool SupportsBinaryKeys => true; public override DateTime DefaultDateTime - => new DateTime(); + => new(); } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/SqliteApiConsistencyTest.cs b/test/EFCore.Sqlite.FunctionalTests/SqliteApiConsistencyTest.cs index 91364f8c24e..2b2fcf187bc 100644 --- a/test/EFCore.Sqlite.FunctionalTests/SqliteApiConsistencyTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/SqliteApiConsistencyTest.cs @@ -26,7 +26,7 @@ protected override Assembly TargetAssembly public class SqliteApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new HashSet + public override HashSet FluentApiTypes { get; } = new() { typeof(SqliteServiceCollectionExtensions), typeof(SqliteDbContextOptionsBuilderExtensions), diff --git a/test/EFCore.Sqlite.FunctionalTests/SqliteDatabaseCreatorTest.cs b/test/EFCore.Sqlite.FunctionalTests/SqliteDatabaseCreatorTest.cs index 76d15f5ce32..c2f56d6de6a 100644 --- a/test/EFCore.Sqlite.FunctionalTests/SqliteDatabaseCreatorTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/SqliteDatabaseCreatorTest.cs @@ -114,7 +114,7 @@ public void Exists_returns_true_when_memory(string connectionString) } private DbContext CreateContext(string connectionString) - => new DbContext( + => new( new DbContextOptionsBuilder() .UseSqlite(connectionString) .UseInternalServiceProvider( diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/PrivateCacheSqliteTestStoreFactory.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/PrivateCacheSqliteTestStoreFactory.cs index e9fa68f80fa..bf2bd7249d8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/PrivateCacheSqliteTestStoreFactory.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/PrivateCacheSqliteTestStoreFactory.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class PrivateCacheSqliteTestStoreFactory : SqliteTestStoreFactory { - public static new PrivateCacheSqliteTestStoreFactory Instance { get; } = new PrivateCacheSqliteTestStoreFactory(); + public static new PrivateCacheSqliteTestStoreFactory Instance { get; } = new(); protected PrivateCacheSqliteTestStoreFactory() { diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SpatialiteRequiredAttribute.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SpatialiteRequiredAttribute.cs index df5a55739c9..ff99dc7a8a8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SpatialiteRequiredAttribute.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SpatialiteRequiredAttribute.cs @@ -13,7 +13,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities public sealed class SpatialiteRequiredAttribute : Attribute, ITestCondition { private static readonly Lazy _loaded - = new Lazy( + = new( () => { using var connection = new SqliteConnection("Data Source=:memory:"); @@ -21,7 +21,7 @@ private static readonly Lazy _loaded }); public ValueTask IsMetAsync() - => new ValueTask(_loaded.Value); + => new(_loaded.Value); public string SkipReason => "mod_spatialite not found. Install it to run this test."; diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteNorthwindTestStoreFactory.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteNorthwindTestStoreFactory.cs index d5f1a34df81..42bb5c70fd2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteNorthwindTestStoreFactory.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteNorthwindTestStoreFactory.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class SqliteNorthwindTestStoreFactory : SqliteTestStoreFactory { - public static new SqliteNorthwindTestStoreFactory Instance { get; } = new SqliteNorthwindTestStoreFactory(); + public static new SqliteNorthwindTestStoreFactory Instance { get; } = new(); protected SqliteNorthwindTestStoreFactory() { diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestHelpers.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestHelpers.cs index a15d104031e..0a1bdc259bb 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestHelpers.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestHelpers.cs @@ -14,7 +14,7 @@ protected SqliteTestHelpers() { } - public static SqliteTestHelpers Instance { get; } = new SqliteTestHelpers(); + public static SqliteTestHelpers Instance { get; } = new(); public override IServiceCollection AddProviderServices(IServiceCollection services) => services.AddEntityFrameworkSqlite(); diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs index 59bb8f644b4..d1c46c65269 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs @@ -14,7 +14,7 @@ public class SqliteTestStore : RelationalTestStore public const int CommandTimeout = 30; public static SqliteTestStore GetOrCreate(string name, bool sharedCache = true) - => new SqliteTestStore(name, sharedCache: sharedCache); + => new(name, sharedCache: sharedCache); public static SqliteTestStore GetOrCreateInitialized(string name) => new SqliteTestStore(name).InitializeSqlite( @@ -23,10 +23,10 @@ public static SqliteTestStore GetOrCreateInitialized(string name) null); public static SqliteTestStore GetExisting(string name) - => new SqliteTestStore(name, seed: false); + => new(name, seed: false); public static SqliteTestStore Create(string name, bool sharedCache = true) - => new SqliteTestStore(name, sharedCache: sharedCache, shared: false); + => new(name, sharedCache: sharedCache, shared: false); private readonly bool _seed; diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStoreFactory.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStoreFactory.cs index 0d27e45fa6e..fa9d1ae9fbb 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStoreFactory.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStoreFactory.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class SqliteTestStoreFactory : RelationalTestStoreFactory { - public static SqliteTestStoreFactory Instance { get; } = new SqliteTestStoreFactory(); + public static SqliteTestStoreFactory Instance { get; } = new(); protected SqliteTestStoreFactory() { diff --git a/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs index a0cb08d3e67..0312cd16e50 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs @@ -24,7 +24,7 @@ protected override DbContextOptionsBuilder CreateTestOptions( : optionsBuilder.UseSqlite(); protected override TwoDatabasesWithDataContext CreateBackingContext(string databaseName) - => new TwoDatabasesWithDataContext(Fixture.CreateOptions(SqliteTestStore.Create(databaseName))); + => new(Fixture.CreateOptions(SqliteTestStore.Create(databaseName))); protected override string DummyConnectionString { get; } = "DataSource=DummyDatabase"; diff --git a/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationAnnotationProviderTest.cs b/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationAnnotationProviderTest.cs index 66193b4fe57..4f32caef513 100644 --- a/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationAnnotationProviderTest.cs +++ b/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationAnnotationProviderTest.cs @@ -15,7 +15,7 @@ public class SqliteMigrationAnnotationProviderTest private readonly ModelBuilder _modelBuilder; private readonly SqliteAnnotationProvider _provider; - private readonly Annotation _autoincrement = new Annotation(SqliteAnnotationNames.Autoincrement, true); + private readonly Annotation _autoincrement = new(SqliteAnnotationNames.Autoincrement, true); public SqliteMigrationAnnotationProviderTest() { diff --git a/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs b/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs index 55d8bb0e908..719c15c2191 100644 --- a/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs +++ b/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs @@ -24,7 +24,7 @@ protected override Assembly TargetAssembly public class SqliteNTSApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new HashSet + public override HashSet FluentApiTypes { get; } = new() { typeof(SqliteNetTopologySuiteDbContextOptionsBuilderExtensions), typeof(SqliteNetTopologySuiteServiceCollectionExtensions) diff --git a/test/EFCore.Tests/ApiConsistencyTest.cs b/test/EFCore.Tests/ApiConsistencyTest.cs index 1833bc9358d..ce36d4facdf 100644 --- a/test/EFCore.Tests/ApiConsistencyTest.cs +++ b/test/EFCore.Tests/ApiConsistencyTest.cs @@ -37,7 +37,7 @@ protected override void Initialize() base.Initialize(); } - public override HashSet FluentApiTypes { get; } = new HashSet + public override HashSet FluentApiTypes { get; } = new() { typeof(ModelBuilder), typeof(CollectionCollectionBuilder), @@ -80,7 +80,7 @@ protected override void Initialize() public override List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type ConventionBuilderExtensions)> MetadataExtensionTypes { get; } - = new List<(Type, Type, Type, Type, Type)> + = new() { (typeof(IModel), typeof(ModelExtensions), typeof(MutableModelExtensions), typeof(ConventionModelExtensions), null), (typeof(IAnnotatable), typeof(AnnotatableExtensions), typeof(MutableAnnotatableExtensions), @@ -100,7 +100,7 @@ public override typeof(ConventionPropertyBaseExtensions), null) }; - public override HashSet NonVirtualMethods { get; } = new HashSet + public override HashSet NonVirtualMethods { get; } = new() { typeof(CompiledQueryCacheKeyGenerator).GetMethod("GenerateCacheKeyCore", AnyInstance), typeof(InternalEntityEntry).GetMethod("get_Item"), @@ -108,14 +108,14 @@ public override typeof(InternalEntityEntry).GetMethod(nameof(InternalEntityEntry.HasDefaultValue)) }; - public override HashSet NotAnnotatedMethods { get; } = new HashSet + public override HashSet NotAnnotatedMethods { get; } = new() { typeof(DbContext).GetMethod(nameof(DbContext.OnConfiguring), AnyInstance), typeof(DbContext).GetMethod(nameof(DbContext.OnModelCreating), AnyInstance), typeof(IEntityTypeConfiguration<>).GetMethod(nameof(IEntityTypeConfiguration.Configure)) }; - public override HashSet UnmatchedMetadataMethods { get; } = new HashSet + public override HashSet UnmatchedMetadataMethods { get; } = new() { typeof(OwnedNavigationBuilder<,>).GetMethod( nameof(OwnedNavigationBuilder.OwnsOne), 0, new[] { typeof(string), typeof(string) }), @@ -177,7 +177,7 @@ public override nameof(IConventionSkipNavigationBuilder.UsePropertyAccessMode), new[] { typeof(PropertyAccessMode), typeof(bool) }), }; - public override HashSet MetadataMethodExceptions { get; } = new HashSet + public override HashSet MetadataMethodExceptions { get; } = new() { typeof(IConventionAnnotatable).GetMethod(nameof(IConventionAnnotatable.SetAnnotation)), typeof(ConventionAnnotatableExtensions).GetMethod(nameof(ConventionAnnotatableExtensions.SetOrRemoveAnnotation)), diff --git a/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs b/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs index bd048144e56..7c1b5ed83e4 100644 --- a/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs @@ -1327,8 +1327,7 @@ private class CatMat public int MatId { get; set; } } - private static readonly ListLoggerFactory _loggerFactory - = new ListLoggerFactory(); + private static readonly ListLoggerFactory _loggerFactory = new(); private static readonly IServiceProvider _serviceProvider = InMemoryFixture.BuildServiceProvider(_loggerFactory); @@ -1616,9 +1615,9 @@ public void Dependent_FKs_are_not_nulled_when_principal_is_detached(bool delayCa Id = 1, Products = new List { - new OptionalProduct { Id = 1 }, - new OptionalProduct { Id = 2 }, - new OptionalProduct { Id = 3 } + new() { Id = 1 }, + new() { Id = 2 }, + new() { Id = 3 } } }; @@ -1653,9 +1652,9 @@ public void Dependent_FKs_are_not_nulled_when_principal_is_detached(bool delayCa { newCategory.Products = new List { - new OptionalProduct { Id = 1 }, - new OptionalProduct { Id = 2 }, - new OptionalProduct { Id = 3 } + new() { Id = 1 }, + new() { Id = 2 }, + new() { Id = 3 } }; } @@ -1776,7 +1775,7 @@ private class Kontainer { public int Id { get; set; } public string Name { get; set; } - public List Rooms { get; set; } = new List(); + public List Rooms { get; set; } = new(); } private class KontainerRoom @@ -1793,7 +1792,7 @@ private class Troduct { public int Id { get; set; } public string Description { get; set; } - public List Rooms { get; set; } = new List(); + public List Rooms { get; set; } = new(); } private class KontainerContext : DbContext diff --git a/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs index 74102aac845..f102850def7 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs @@ -445,13 +445,13 @@ private class Godzilla private struct NotComparable { public static ValueConverter Converter - = new ValueConverter(v => new NotComparable(), v => new NotComparable()); + = new(v => new NotComparable(), v => new NotComparable()); } private struct IntStruct { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new IntStruct { Value = v }); + = new(v => v.Value, v => new IntStruct { Value = v }); public int Value { get; set; } } @@ -459,7 +459,7 @@ public static ValueConverter Converter private struct BytesStruct { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new BytesStruct { Value = v }); + = new(v => v.Value, v => new BytesStruct { Value = v }); public byte[] Value { get; set; } @@ -487,7 +487,7 @@ public override int GetHashCode() private struct ComparableIntStruct : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new ComparableIntStruct { Value = v }); + = new(v => v.Value, v => new ComparableIntStruct { Value = v }); public int Value { get; set; } @@ -498,7 +498,7 @@ public int CompareTo(object other) private struct ComparableBytesStruct : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new ComparableBytesStruct { Value = v }); + = new(v => v.Value, v => new ComparableBytesStruct { Value = v }); public byte[] Value { get; set; } @@ -537,7 +537,7 @@ public int CompareTo(object other) private struct GenericComparableIntStruct : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new GenericComparableIntStruct { Value = v }); + = new(v => v.Value, v => new GenericComparableIntStruct { Value = v }); public int Value { get; set; } @@ -548,8 +548,7 @@ public int CompareTo(GenericComparableIntStruct other) private struct GenericComparableBytesStruct : IComparable { public static ValueConverter Converter - = new ValueConverter( - v => v.Value, v => new GenericComparableBytesStruct { Value = v }); + = new(v => v.Value, v => new GenericComparableBytesStruct { Value = v }); public byte[] Value { get; set; } @@ -588,8 +587,7 @@ public int CompareTo(GenericComparableBytesStruct other) private struct StructuralComparableBytesStruct : IStructuralComparable { public static ValueConverter Converter - = new ValueConverter( - v => v.Value, v => new StructuralComparableBytesStruct { Value = v }); + = new(v => v.Value, v => new StructuralComparableBytesStruct { Value = v }); public byte[] Value { get; set; } @@ -633,7 +631,7 @@ public int CompareTo(object other, IComparer comparer) private class IntClass { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new IntClass { Value = v }); + = new(v => v.Value, v => new IntClass { Value = v }); private bool Equals(IntClass other) => other != null && Value == other.Value; @@ -652,7 +650,7 @@ public override int GetHashCode() private class ComparableIntClass : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new ComparableIntClass { Value = v }); + = new(v => v.Value, v => new ComparableIntClass { Value = v }); public int Value { get; set; } @@ -674,7 +672,7 @@ public int CompareTo(object other) private class GenericComparableIntClass : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Value, v => new GenericComparableIntClass { Value = v }); + = new(v => v.Value, v => new GenericComparableIntClass { Value = v }); public int Value { get; set; } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs index d78ea1e4e1b..307b302e62c 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs @@ -14,8 +14,8 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal { public class FixupCompositeTest { - private static readonly Guid Guid77 = new Guid("{DE390D36-DAAC-4C8B-91F7-E9F5DAA7EF01}"); - private static readonly Guid Guid78 = new Guid("{4C80406F-49AF-4D85-AFFB-75C146A98A70}"); + private static readonly Guid Guid77 = new("{DE390D36-DAAC-4C8B-91F7-E9F5DAA7EF01}"); + private static readonly Guid Guid78 = new("{4C80406F-49AF-4D85-AFFB-75C146A98A70}"); [ConditionalTheory] [InlineData(EntityState.Added)] diff --git a/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs index 9af32ebc64e..8aea0be5e9a 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs @@ -2604,7 +2604,7 @@ public class ContainerX { public int Id { get; set; } public string Name { get; set; } - public List Rooms { get; set; } = new List(); + public List Rooms { get; set; } = new(); } public class ContainerRoomX @@ -2621,7 +2621,7 @@ public class ProductX { public int Id { get; set; } public string Description { get; set; } - public List Rooms { get; set; } = new List(); + public List Rooms { get; set; } = new(); } protected class EscapeRoom : DbContext diff --git a/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs index 824cab87ac1..d7a3619ef30 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs @@ -481,10 +481,8 @@ public void Entries_are_unsubscribed_when_context_is_disposed_or_cleared(bool us private class TestPropertyListener : IChangeDetector { - public List> Changing { get; } = - new List>(); - - public List> Changed { get; } = new List>(); + public List> Changing { get; } = new(); + public List> Changed { get; } = new(); public void PropertyChanged(InternalEntityEntry entry, IPropertyBase property, bool setModified) => Changed.Add(Tuple.Create(entry, property)); @@ -512,7 +510,7 @@ public void Resume() private class TestNavigationListener : INavigationFixer { public List, IEnumerable>> CollectionChanged { get; } - = new List, IEnumerable>>(); + = new(); public void NavigationReferenceChanged( InternalEntityEntry entry, diff --git a/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs index cd0d85fb254..3d54ab6aec5 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs @@ -50,7 +50,7 @@ protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBu private class Blog { public int Id { get; set; } - public HashSet Posts { get; } = new HashSet(); + public HashSet Posts { get; } = new(); } private class Post diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs index d9643f0aa83..dccacbf5924 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs @@ -546,7 +546,7 @@ public ListElement(int i) } public static implicit operator ListElement(int i) - => new ListElement(i); + => new(i); public int Int { get; } public int? NullableInt { get; } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ObservableCollectionListSourceTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ObservableCollectionListSourceTest.cs index b587d8b8606..4b4b3cf079e 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ObservableCollectionListSourceTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ObservableCollectionListSourceTest.cs @@ -27,7 +27,7 @@ public void ObservableCollectionListSource_exposes_ObservableCollection_IEnumera [ConditionalFact] public void ObservableCollectionListSource_exposes_ObservableCollection_List_constructor() { - var entities = new List { new FakeEntity(), new FakeEntity() }; + var entities = new List { new(), new() }; var ols = new ObservableCollectionListSource(entities); Assert.Equal(2, ols.Count); } @@ -41,7 +41,7 @@ public void ObservableCollectionListSource_ContainsListCollection_returns_false( [ConditionalFact] public void ObservableCollectionListSource_GetList_returns_BindingList_attached_to_the_ObservableCollection() { - var ols = new ObservableCollectionListSource { new FakeEntity(), new FakeEntity() }; + var ols = new ObservableCollectionListSource { new(), new() }; var bindingList = ((IListSource)ols).GetList(); Assert.Equal(2, bindingList.Count); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs index 7c6a77be24a..e72337b5a31 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs @@ -169,15 +169,15 @@ public void SortableBindingList_can_sort_when_list_is_of_derived_type() { var list = new List { - new DerivedListElement(3), - new DerivedListElement(1), - new DerivedListElement(4) + new(3), + new(1), + new(4) }; var sortedList = new List { - new DerivedListElement(1), - new DerivedListElement(3), - new DerivedListElement(4) + new(1), + new(3), + new(4) }; var bindingList = new SortableBindingList(list); @@ -203,7 +203,7 @@ public ListElement(int i) } public static implicit operator ListElement(int i) - => new ListElement(i); + => new(i); public int Int { get; } public int? NullableInt { get; } diff --git a/test/EFCore.Tests/ChangeTracking/ObservableHashSetTest.cs b/test/EFCore.Tests/ChangeTracking/ObservableHashSetTest.cs index 0a09f83da85..82b6b614e2b 100644 --- a/test/EFCore.Tests/ChangeTracking/ObservableHashSetTest.cs +++ b/test/EFCore.Tests/ChangeTracking/ObservableHashSetTest.cs @@ -14,7 +14,7 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking { public class ObservableHashSetTest { - private static readonly Random _random = new Random(); + private static readonly Random _random = new(); [ConditionalFact] public void Can_construct() diff --git a/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs b/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs index 344cd1f84f8..bfcd1e32941 100644 --- a/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs +++ b/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs @@ -91,9 +91,9 @@ public void Can_attach_nullable_PK_parent_with_child_collection(bool useAttach, { Products = new List { - new NullbileProduct(), - new NullbileProduct(), - new NullbileProduct() + new(), + new(), + new() } }; @@ -340,9 +340,9 @@ public void Can_attach_parent_with_child_collection() Id = 1, Products = new List { - new Product { Id = 1 }, - new Product { Id = 2 }, - new Product { Id = 3 } + new() { Id = 1 }, + new() { Id = 2 }, + new() { Id = 3 } } }; @@ -508,9 +508,9 @@ public void Entities_that_are_already_tracked_will_not_get_attached() Id = 1, Products = new List { - new Product { Id = 1 }, + new() { Id = 1 }, existingProduct, - new Product { Id = 3 } + new() { Id = 3 } } }; @@ -553,19 +553,19 @@ public void Further_graph_traversal_stops_if_an_entity_is_not_attached() Id = 1, Products = new List { - new Product + new() { Id = 1, CategoryId = 1, Details = new ProductDetails { Id = 1 } }, - new Product + new() { Id = 2, CategoryId = 1, Details = new ProductDetails { Id = 2 } }, - new Product + new() { Id = 3, CategoryId = 1, @@ -722,9 +722,9 @@ public void Dependents_are_detached_not_deleted_when_principal_is_detached(bool Id = 1, Products = new List { - new Product { Id = 1 }, - new Product { Id = 2 }, - new Product { Id = 3 } + new() { Id = 1 }, + new() { Id = 2 }, + new() { Id = 3 } } }; @@ -772,9 +772,9 @@ public void Dependents_are_detached_not_deleted_when_principal_is_detached(bool { newCategory.Products = new List { - new Product { Id = 1 }, - new Product { Id = 2 }, - new Product { Id = 3 } + new() { Id = 1 }, + new() { Id = 2 }, + new() { Id = 3 } }; } @@ -869,19 +869,19 @@ public void TrackGraph_overload_can_visit_a_graph_without_attaching() Id = 1, Products = new List { - new Product + new() { Id = 1, CategoryId = 1, Details = new ProductDetails { Id = 1 } }, - new Product + new() { Id = 2, CategoryId = 1, Details = new ProductDetails { Id = 2 } }, - new Product + new() { Id = 3, CategoryId = 1, @@ -988,9 +988,9 @@ private static void KeyValueAttachTest(string databaseName, Action { - new Product { Id = 77, CategoryId = expectModified ? 0 : 77 }, - new Product { Id = 0, CategoryId = expectModified ? 0 : 77 }, - new Product { Id = 78, CategoryId = expectModified ? 0 : 77 } + new() { Id = 77, CategoryId = expectModified ? 0 : 77 }, + new() { Id = 0, CategoryId = expectModified ? 0 : 77 }, + new() { Id = 78, CategoryId = expectModified ? 0 : 77 } } }; @@ -1031,9 +1031,9 @@ public void Can_attach_graph_using_custom_delegate() Id = 77, Products = new List { - new Product { Id = 77, CategoryId = 77 }, - new Product { Id = 0, CategoryId = 77 }, - new Product { Id = 78, CategoryId = 77 } + new() { Id = 77, CategoryId = 77 }, + new() { Id = 0, CategoryId = 77 }, + new() { Id = 78, CategoryId = 77 } } }; @@ -1107,19 +1107,19 @@ public void TrackGraph_overload_can_visit_an_already_attached_graph() Id = 1, Products = new List { - new Product + new() { Id = 1, CategoryId = 1, Details = new ProductDetails { Id = 1 } }, - new Product + new() { Id = 2, CategoryId = 1, Details = new ProductDetails { Id = 2 } }, - new Product + new() { Id = 3, CategoryId = 1, @@ -1196,7 +1196,7 @@ private class Dark } private static Product CreateSimpleGraph(int id) - => new Product { Id = id, Category = new Category { Id = id } }; + => new() { Id = id, Category = new Category { Id = id } }; private class ChangeDetectorProxy : ChangeDetector { diff --git a/test/EFCore.Tests/DbContextFactoryTest.cs b/test/EFCore.Tests/DbContextFactoryTest.cs index eb91b39641e..1e83b8e2ba3 100644 --- a/test/EFCore.Tests/DbContextFactoryTest.cs +++ b/test/EFCore.Tests/DbContextFactoryTest.cs @@ -555,7 +555,7 @@ public WoolacombeContextFactory(DbContextOptions options) => _options = options; public WoolacombeContext CreateDbContext() - => new WoolacombeContext(_options); + => new(_options); } private static string GetStoreName(DbContext context1) diff --git a/test/EFCore.Tests/DbContextServicesTest.cs b/test/EFCore.Tests/DbContextServicesTest.cs index fb0a28f0989..0b081509fae 100644 --- a/test/EFCore.Tests/DbContextServicesTest.cs +++ b/test/EFCore.Tests/DbContextServicesTest.cs @@ -74,7 +74,7 @@ private void DebugLogTest(bool useLoggerFactory, bool configureForDebug, bool sh } } - protected static List<(LogLevel Level, EventId Id, string Message)> Log { get; } = new List<(LogLevel, EventId, string)>(); + protected static List<(LogLevel Level, EventId Id, string Message)> Log { get; } = new(); private class InfoLogContext : DbContext { diff --git a/test/EFCore.Tests/DbContextTest.cs b/test/EFCore.Tests/DbContextTest.cs index 0fc7803accc..cd979ee39d2 100644 --- a/test/EFCore.Tests/DbContextTest.cs +++ b/test/EFCore.Tests/DbContextTest.cs @@ -203,9 +203,9 @@ public async Task Can_change_navigation_while_attaching_entities(bool async) { var questions = new List { - new Question + new() { - Author = context.Users.First(), Answers = new List { new Answer { Author = context.Users.Last() } } + Author = context.Users.First(), Answers = new List { new() { Author = context.Users.Last() } } } }; @@ -612,7 +612,7 @@ public async Task Add_Attach_Remove_Update_do_not_call_DetectChanges() context.AddRange( new Product { Id = id++, Name = "Little Hedgehogs" }); context.AddRange( - new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); + new List { new() { Id = id++, Name = "Little Hedgehogs" } }); context.AddRange( new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); await context.AddAsync( @@ -624,7 +624,7 @@ await context.AddRangeAsync( await context.AddRangeAsync( new Product { Id = id++, Name = "Little Hedgehogs" }); await context.AddRangeAsync( - new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); + new List { new() { Id = id++, Name = "Little Hedgehogs" } }); await context.AddRangeAsync( new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); context.Attach( @@ -636,7 +636,7 @@ await context.AddRangeAsync( context.AttachRange( new Product { Id = id++, Name = "Little Hedgehogs" }); context.AttachRange( - new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); + new List { new() { Id = id++, Name = "Little Hedgehogs" } }); context.AttachRange( new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); context.Update( @@ -648,7 +648,7 @@ await context.AddRangeAsync( context.UpdateRange( new Product { Id = id++, Name = "Little Hedgehogs" }); context.UpdateRange( - new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); + new List { new() { Id = id++, Name = "Little Hedgehogs" } }); context.UpdateRange( new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); context.Remove( @@ -660,7 +660,7 @@ await context.AddRangeAsync( context.RemoveRange( new Product { Id = id++, Name = "Little Hedgehogs" }); context.RemoveRange( - new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); + new List { new() { Id = id++, Name = "Little Hedgehogs" } }); context.RemoveRange( new List { new Product { Id = id, Name = "Little Hedgehogs" } }); @@ -847,7 +847,7 @@ public object GetService(Type serviceType) public class FakeServiceScopeFactory : IServiceScopeFactory { - public static FakeServiceScope Scope { get; } = new FakeServiceScope(); + public static FakeServiceScope Scope { get; } = new(); public IServiceScope CreateScope() => Scope; diff --git a/test/EFCore.Tests/ExceptionTest.cs b/test/EFCore.Tests/ExceptionTest.cs index c789bbd159f..60f968aa54f 100644 --- a/test/EFCore.Tests/ExceptionTest.cs +++ b/test/EFCore.Tests/ExceptionTest.cs @@ -190,7 +190,7 @@ public void SetStoreGeneratedValue(IProperty property, object value) => throw new NotImplementedException(); public EntityEntry ToEntityEntry() - => new EntityEntry(new FakeInternalEntityEntry()); + => new(new FakeInternalEntityEntry()); public object GetRelationshipSnapshotValue(IPropertyBase propertyBase) => throw new NotImplementedException(); diff --git a/test/EFCore.Tests/Infrastructure/EntityFrameworkServicesBuilderTest.cs b/test/EFCore.Tests/Infrastructure/EntityFrameworkServicesBuilderTest.cs index 2a561630eac..9d1e0b2e9ec 100644 --- a/test/EFCore.Tests/Infrastructure/EntityFrameworkServicesBuilderTest.cs +++ b/test/EFCore.Tests/Infrastructure/EntityFrameworkServicesBuilderTest.cs @@ -363,7 +363,7 @@ public Task ResetStateAsync(CancellationToken cancellationToken = default) } private static DbContext CreateContext(IServiceProvider serviceProvider) - => new DbContext( + => new( new DbContextOptionsBuilder() .UseInternalServiceProvider(serviceProvider) .UseInMemoryDatabase(Guid.NewGuid().ToString()) diff --git a/test/EFCore.Tests/Infrastructure/InternalServiceCollectionMapTest.cs b/test/EFCore.Tests/Infrastructure/InternalServiceCollectionMapTest.cs index 168aaa31fee..495f92d5925 100644 --- a/test/EFCore.Tests/Infrastructure/InternalServiceCollectionMapTest.cs +++ b/test/EFCore.Tests/Infrastructure/InternalServiceCollectionMapTest.cs @@ -299,10 +299,10 @@ public void Throws_if_attempt_is_made_to_register_dependency_as_instance() } private static ServiceCollectionMap CreateServiceMap() - => new ServiceCollectionMap(new ServiceCollection().AddEntityFrameworkInMemoryDatabase()); + => new(new ServiceCollection().AddEntityFrameworkInMemoryDatabase()); private static DbContext CreateContext(IServiceProvider serviceProvider) - => new DbContext( + => new( new DbContextOptionsBuilder() .UseInternalServiceProvider(serviceProvider) .UseInMemoryDatabase(Guid.NewGuid().ToString()) diff --git a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs index acaf6e71aae..8ff3a6f7773 100644 --- a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs +++ b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs @@ -1142,7 +1142,7 @@ public virtual void Detects_reference_navigations_in_seeds2(bool sensitiveDataLo e.HasMany(o => o.Products) .WithMany(p => p.Orders); e.HasData( - new Order { Id = 1, Products = new List { new Product() } }); + new Order { Id = 1, Products = new List { new() } }); }); VerifyError( diff --git a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs index b6a27736ba2..637e253ba8e 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs @@ -223,7 +223,7 @@ public void OnModelAnnotationChanged_calls_conventions_in_order(bool useBuilder, private class ModelAnnotationChangedConvention : IModelAnnotationChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public ModelAnnotationChangedConvention(bool terminate) { @@ -489,7 +489,7 @@ public void OnEntityTypeMemberIgnored_calls_conventions_in_order(bool useBuilder private class EntityTypeMemberIgnoredConvention : IEntityTypeMemberIgnoredConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public EntityTypeMemberIgnoredConvention(bool terminate) { @@ -585,7 +585,7 @@ public void OnBaseTypeChanged_calls_conventions_in_order(bool useBuilder, bool u private class EntityTypeBaseTypeChangedConvention : IEntityTypeBaseTypeChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public EntityTypeBaseTypeChangedConvention(bool terminate) { @@ -690,7 +690,7 @@ public void OnPrimaryKeyChanged_calls_conventions_in_order(bool useBuilder, bool private class EntityTypePrimaryKeyChangedConvention : IEntityTypePrimaryKeyChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public EntityTypePrimaryKeyChangedConvention(bool terminate) { @@ -788,7 +788,7 @@ public void OnEntityTypeAnnotationChanged_calls_conventions_in_order(bool useBui private class EntityTypeAnnotationChangedConvention : IEntityTypeAnnotationChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public EntityTypeAnnotationChangedConvention(bool terminate) { @@ -866,7 +866,7 @@ public void OnForeignKeyAdded_calls_conventions_in_order(bool useBuilder, bool u private class ForeignKeyAddedConvention : IForeignKeyAddedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public ForeignKeyAddedConvention(bool terminate) { @@ -942,7 +942,7 @@ public void OnForeignKeyRemoved_calls_conventions_in_order(bool useScope) private class ForeignKeyRemovedConvention : IForeignKeyRemovedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public ForeignKeyRemovedConvention(bool terminate) { @@ -1070,7 +1070,7 @@ public void OnForeignKeyPrincipalEndChanged_calls_conventions_in_order(bool useS private class ForeignKeyPrincipalEndChangedConvention : IForeignKeyPrincipalEndChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public ForeignKeyPrincipalEndChangedConvention(bool terminate) { @@ -1138,7 +1138,7 @@ public void OnForeignKeyPropertiesChangedConvention_calls_conventions_in_order(b private class ForeignKeyPropertiesChangedConvention : IForeignKeyPropertiesChangedConvention { private readonly bool _terminate; - public readonly List<(string, string)> Calls = new List<(string, string)>(); + public readonly List<(string, string)> Calls = new(); public ForeignKeyPropertiesChangedConvention(bool terminate) { @@ -1255,7 +1255,7 @@ public void OnForeignKeyUniquenessChanged_calls_conventions_in_order(bool useBui private class ForeignKeyUniquenessChangedConvention : IForeignKeyUniquenessChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public ForeignKeyUniquenessChangedConvention(bool terminate) { @@ -1356,7 +1356,7 @@ public void OnForeignKeyRequirednessChanged_calls_conventions_in_order(bool useB private class ForeignKeyRequirednessChangedConvention : IForeignKeyRequirednessChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public ForeignKeyRequirednessChangedConvention(bool terminate) { @@ -1459,7 +1459,7 @@ public void OnForeignKeyDependentRequirednessChanged_calls_conventions_in_order( private class ForeignKeyDependentRequirednessChangedConvention : IForeignKeyDependentRequirednessChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public ForeignKeyDependentRequirednessChangedConvention(bool terminate) { @@ -1561,7 +1561,7 @@ public void OnForeignKeyOwnershipChanged_calls_conventions_in_order(bool useBuil private class ForeignKeyOwnershipChangedConvention : IForeignKeyOwnershipChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public ForeignKeyOwnershipChangedConvention(bool terminate) { @@ -1661,7 +1661,7 @@ public void OnForeignKeyAnnotationChanged_calls_conventions_in_order(bool useBui private class ForeignKeyAnnotationChangedConvention : IForeignKeyAnnotationChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public ForeignKeyAnnotationChangedConvention(bool terminate) { @@ -1753,7 +1753,7 @@ public void OnNavigationAdded_calls_conventions_in_order(bool useBuilder, bool u private class NavigationAddedConvention : INavigationAddedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public NavigationAddedConvention(bool terminate) { @@ -1866,7 +1866,7 @@ public void OnNavigationAnnotationChanged_calls_conventions_in_order(bool useBui private class NavigationAnnotationChangedConvention : INavigationAnnotationChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public NavigationAnnotationChangedConvention(bool terminate) { @@ -1961,7 +1961,7 @@ public void OnNavigationRemoved_calls_conventions_in_order(bool useBuilder, bool private class NavigationRemovedConvention : INavigationRemovedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public NavigationRemovedConvention(bool terminate) { @@ -2036,7 +2036,7 @@ public void OnSkipNavigationAdded_calls_conventions_in_order(bool useBuilder, bo private class SkipNavigationAddedConvention : ISkipNavigationAddedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public SkipNavigationAddedConvention(bool terminate) { @@ -2139,7 +2139,7 @@ public void OnSkipNavigationAnnotationChanged_calls_conventions_in_order(bool us private class SkipNavigationAnnotationChangedConvention : ISkipNavigationAnnotationChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public SkipNavigationAnnotationChangedConvention(bool terminate) { @@ -2231,7 +2231,7 @@ public void OnSkipNavigationForeignKeyChanged_calls_conventions_in_order(bool us private class SkipNavigationForeignKeyChangedConvention : ISkipNavigationForeignKeyChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public SkipNavigationForeignKeyChangedConvention(bool terminate) { @@ -2329,7 +2329,7 @@ public void OnSkipNavigationInverseChanged_calls_conventions_in_order(bool useBu private class SkipNavigationInverseChangedConvention : ISkipNavigationInverseChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public SkipNavigationInverseChangedConvention(bool terminate) { @@ -2402,7 +2402,7 @@ public void OnSkipNavigationRemoved_calls_conventions_in_order(bool useScope) private class SkipNavigationRemovedConvention : ISkipNavigationRemovedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public SkipNavigationRemovedConvention(bool terminate) { @@ -2478,7 +2478,7 @@ public void OnKeyAdded_calls_conventions_in_order(bool useBuilder, bool useScope private class KeyAddedConvention : IKeyAddedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public KeyAddedConvention(bool terminate) { @@ -2541,7 +2541,7 @@ public void OnKeyRemoved_calls_conventions_in_order(bool useScope) private class KeyRemovedConvention : IKeyRemovedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public KeyRemovedConvention(bool terminate) { @@ -2641,7 +2641,7 @@ public void OnKeyAnnotationChanged_calls_conventions_in_order(bool useBuilder, b private class KeyAnnotationChangedConvention : IKeyAnnotationChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public KeyAnnotationChangedConvention(bool terminate) { @@ -2718,7 +2718,7 @@ public void OnIndexAdded_calls_conventions_in_order(bool useBuilder, bool useSco private class IndexAddedConvention : IIndexAddedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public IndexAddedConvention(bool terminate) { @@ -2786,7 +2786,7 @@ public void OnIndexRemoved_calls_conventions_in_order(bool useScope) private class IndexRemovedConvention : IIndexRemovedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public IndexRemovedConvention(bool terminate) { @@ -2884,7 +2884,7 @@ public void OnIndexUniquenessChanged_calls_conventions_in_order(bool useBuilder, private class IndexUniquenessChangedConvention : IIndexUniquenessChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public IndexUniquenessChangedConvention(bool terminate) { @@ -2982,7 +2982,7 @@ public void OnIndexAnnotationChanged_calls_conventions_in_order(bool useBuilder, private class IndexAnnotationChangedConvention : IIndexAnnotationChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public IndexAnnotationChangedConvention(bool terminate) { @@ -3086,7 +3086,7 @@ public void OnPropertyAdded_calls_conventions_in_order(bool useBuilder, bool use private class PropertyAddedConvention : IPropertyAddedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public PropertyAddedConvention(bool terminate) { @@ -3224,7 +3224,7 @@ public void OnPropertyNullabilityChanged_calls_conventions_in_order(bool useBuil private class PropertyNullabilityChangedConvention : IPropertyNullabilityChangedConvention { - public readonly List Calls = new List(); + public readonly List Calls = new(); private readonly bool _terminate; public PropertyNullabilityChangedConvention(bool terminate) @@ -3323,7 +3323,7 @@ public void OnPropertyFieldChanged_calls_conventions_in_order(bool useBuilder, b private class PropertyFieldChangedConvention : IPropertyFieldChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public PropertyFieldChangedConvention(bool terminate) { @@ -3423,7 +3423,7 @@ public void OnPropertyAnnotationChanged_calls_conventions_in_order(bool useBuild private class PropertyAnnotationChangedConvention : IPropertyAnnotationChangedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public PropertyAnnotationChangedConvention(bool terminate) { @@ -3496,7 +3496,7 @@ public void OnPropertyRemoved_calls_conventions_in_order(bool useScope) private class PropertyRemovedConvention : IPropertyRemovedConvention { private readonly bool _terminate; - public readonly List Calls = new List(); + public readonly List Calls = new(); public PropertyRemovedConvention(bool terminate) { diff --git a/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs index 73a8ec9b7d1..c64373d2647 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs @@ -1160,7 +1160,7 @@ private ProviderConventionSetBuilderDependencies CreateDependencies() } public ListLoggerFactory ListLoggerFactory { get; } - = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Name); + = new(l => l == DbLoggerCategory.Model.Name); private Property PrimaryKey => PrincipalType.FindPrimaryKey().Properties.Single(); diff --git a/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs index 6ae3de0c428..40ff36cf1b6 100644 --- a/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs @@ -320,7 +320,7 @@ private void RunConvention(InternalModelBuilder modelBuilder) } private IndexAttributeConvention CreateIndexAttributeConvention() - => new IndexAttributeConvention(CreateDependencies()); + => new(CreateDependencies()); private ProviderConventionSetBuilderDependencies CreateDependencies() => InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService(); diff --git a/test/EFCore.Tests/Metadata/Conventions/KeyDiscoveryConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/KeyDiscoveryConventionTest.cs index 8c2c874c6f1..cc2e97c74db 100644 --- a/test/EFCore.Tests/Metadata/Conventions/KeyDiscoveryConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/KeyDiscoveryConventionTest.cs @@ -136,7 +136,7 @@ public void DiscoverKeyProperties_does_not_discover_key_when_multiple_ids() } public ListLoggerFactory ListLoggerFactory { get; } - = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Name); + = new(l => l == DbLoggerCategory.Model.Name); private void RunConvention(InternalEntityTypeBuilder entityTypeBuilder) { @@ -155,7 +155,7 @@ private void RunConvention(InternalPropertyBuilder propertyBuilder) } private KeyDiscoveryConvention CreateKeyDiscoveryConvention() - => new KeyDiscoveryConvention(CreateDependencies()); + => new(CreateDependencies()); private ProviderConventionSetBuilderDependencies CreateDependencies() => InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService() diff --git a/test/EFCore.Tests/Metadata/Conventions/ManyToManyJoinEntityTypeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/ManyToManyJoinEntityTypeConventionTest.cs index f500a7b6c7d..c7f74667865 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ManyToManyJoinEntityTypeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ManyToManyJoinEntityTypeConventionTest.cs @@ -252,7 +252,7 @@ public void Join_entity_type_is_created() } public ListLoggerFactory ListLoggerFactory { get; } - = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Name); + = new(l => l == DbLoggerCategory.Model.Name); private DiagnosticsLogger CreateLogger() { @@ -276,7 +276,7 @@ private InternalSkipNavigationBuilder RunConvention(InternalSkipNavigationBuilde } private ManyToManyJoinEntityTypeConvention CreateManyToManyConvention() - => new ManyToManyJoinEntityTypeConvention(CreateDependencies()); + => new(CreateDependencies()); private ProviderConventionSetBuilderDependencies CreateDependencies() => InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService() diff --git a/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs index b896f6a89da..982f9eaef71 100644 --- a/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs @@ -990,7 +990,7 @@ public void Navigation_attribute_convention_runs_for_private_property() } public ListLoggerFactory ListLoggerFactory { get; } - = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Name); + = new(l => l == DbLoggerCategory.Model.Name); private InternalEntityTypeBuilder CreateInternalEntityTypeBuilder() { diff --git a/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs index 86a5e78191a..45e853bd917 100644 --- a/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs @@ -142,10 +142,10 @@ private Navigation RunConvention(InternalForeignKeyBuilder relationshipBuilder, } private NonNullableNavigationConvention CreateNotNullNavigationConvention() - => new NonNullableNavigationConvention(CreateDependencies()); + => new(CreateDependencies()); public ListLoggerFactory ListLoggerFactory { get; } - = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Name); + = new(l => l == DbLoggerCategory.Model.Name); private InternalEntityTypeBuilder CreateInternalEntityTypeBuilder() { diff --git a/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs index e15f6131227..48ad9cf2ca4 100644 --- a/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs @@ -1018,7 +1018,7 @@ public void Does_not_discover_nonNavigation_properties() } public ListLoggerFactory ListLoggerFactory { get; } - = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Name); + = new(l => l == DbLoggerCategory.Model.Name); private static IMemberClassifier CreateMemberClassifier() => new MemberClassifier( @@ -1162,7 +1162,7 @@ private InternalEntityTypeBuilder RunConvention(InternalEntityTypeBuilder entity } private RelationshipDiscoveryConvention CreateRelationshipDiscoveryConvention() - => new RelationshipDiscoveryConvention(CreateDependencies()); + => new(CreateDependencies()); private void Cleanup(InternalModelBuilder modelBuilder) { diff --git a/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs index 488c81b65ed..9f67a0770ad 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs @@ -645,7 +645,7 @@ private MyPrivateCollection() public static MyPrivateCollection Create() { - return new MyPrivateCollection(); + return new(); } } diff --git a/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs index 72b0c28f748..35163725efd 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs @@ -124,7 +124,7 @@ public Fuel(double volume) private class IndexedClass { - private readonly Dictionary _internalValues = new Dictionary + private readonly Dictionary _internalValues = new() { { "PropertyA", "ValueA" }, { "PropertyB", 123 } }; diff --git a/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs index c8327883749..49466a485ec 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs @@ -306,7 +306,7 @@ private class BaseEntity private class IndexedClass { - private readonly Dictionary _internalValues = new Dictionary + private readonly Dictionary _internalValues = new() { { "PropertyA", "ValueA" }, { "PropertyB", 123 } }; diff --git a/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs b/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs index 80afc3ce0d7..a1b64bcb679 100644 --- a/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs @@ -182,7 +182,7 @@ public void Can_create_materializer_for_entity_with_instance_factory_method() private class TestProxyFactory { - public static readonly TestProxyFactory Instance = new TestProxyFactory(); + public static readonly TestProxyFactory Instance = new(); public object Create(IEntityType entityType) => Activator.CreateInstance(entityType.ClrType); @@ -336,7 +336,7 @@ public SomeEntity(int id, Guid? goo) } public static SomeEntity Factory(int id, Guid? goo) - => new SomeEntity(id, goo) { FactoryUsed = true }; + => new(id, goo) { FactoryUsed = true }; public static SomeEntity GeneralFactory(object[] constructorArguments) { diff --git a/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs index 13fdba88774..4e8aec2ba84 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs @@ -3259,7 +3259,7 @@ public void DiscriminatorValue_throws_if_base_cannot_be_set() } private InternalModelBuilder CreateModelBuilder() - => new InternalModelBuilder(new Model()); + => new(new Model()); private InternalModelBuilder CreateConventionalModelBuilder() => (InternalModelBuilder)InMemoryTestHelpers.Instance.CreateConventionBuilder().GetInfrastructure(); diff --git a/test/EFCore.Tests/Metadata/Internal/InternalForeignKeyBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalForeignKeyBuilderTest.cs index 5dfe80372ea..4d42d89efd0 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalForeignKeyBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalForeignKeyBuilderTest.cs @@ -1009,7 +1009,7 @@ public void Navigation_to_dependent_does_not_change_uniqueness_for_relationship_ } private InternalModelBuilder CreateInternalModelBuilder() - => new InternalModelBuilder(new Model()); + => new(new Model()); private class Order { diff --git a/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs index 9fc8f99a88b..2b41b0bf3e7 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs @@ -521,7 +521,7 @@ private static ProviderConventionSetBuilderDependencies CreateDependencies() => InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService(); protected virtual InternalModelBuilder CreateModelBuilder(Model model = null) - => new InternalModelBuilder(model ?? new Model()); + => new(model ?? new Model()); private class Base { diff --git a/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs index 1070e5c5419..2129127a597 100644 --- a/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs @@ -68,7 +68,7 @@ public void Can_use_PropertyAccessorsFactory_on_non_indexed_property() private class IndexedClass { - private readonly Dictionary _internalValues = new Dictionary { { "PropertyA", "ValueA" } }; + private readonly Dictionary _internalValues = new() { { "PropertyA", "ValueA" } }; internal int Id { get; set; } diff --git a/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs b/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs index 92466686788..ba4dc295a61 100644 --- a/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs @@ -1197,7 +1197,7 @@ protected class User13300 { public Guid Id { get; set; } private readonly string _email = string.Empty; - private readonly List _profiles = new List(); + private readonly List _profiles = new(); } protected class Profile13300 diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericTest.cs index 20929110674..3291da3853a 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericTest.cs @@ -654,7 +654,7 @@ public override IMutableForeignKey Metadata protected virtual GenericTestReferenceCollectionBuilder Wrap( ReferenceCollectionBuilder referenceCollectionBuilder) - => new GenericTestReferenceCollectionBuilder(referenceCollectionBuilder); + => new(referenceCollectionBuilder); public override TestReferenceCollectionBuilder HasForeignKey( Expression> foreignKeyExpression) @@ -697,7 +697,7 @@ public override IMutableForeignKey Metadata protected virtual GenericTestReferenceReferenceBuilder Wrap( ReferenceReferenceBuilder referenceReferenceBuilder) - => new GenericTestReferenceReferenceBuilder(referenceReferenceBuilder); + => new(referenceReferenceBuilder); public override TestReferenceReferenceBuilder HasAnnotation(string annotation, object value) => Wrap(ReferenceReferenceBuilder.HasAnnotation(annotation, value)); @@ -816,7 +816,7 @@ protected virtual GenericTestOwnershipBuilder W OwnershipBuilder ownershipBuilder) where TNewEntity : class where TNewDependentEntity : class - => new GenericTestOwnershipBuilder(ownershipBuilder); + => new(ownershipBuilder); public override TestOwnershipBuilder HasAnnotation(string annotation, object value) => Wrap(OwnershipBuilder.HasAnnotation(annotation, value)); @@ -864,7 +864,7 @@ protected virtual GenericTestOwnedNavigationBuilder ownershipBuilder) where TNewEntity : class where TNewDependentEntity : class - => new GenericTestOwnedNavigationBuilder(ownershipBuilder); + => new(ownershipBuilder); public override TestOwnedNavigationBuilder HasAnnotation( string annotation, diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs index 3555f204a27..4c01a0b1494 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs @@ -235,14 +235,13 @@ public NonGenericStringTestReferenceReferenceBuilder(ReferenceReferenceBuilder r public NonGenericStringTestReferenceReferenceBuilder HasForeignKey( string dependentEntityTypeName, params string[] foreignKeyPropertyNames) - => new NonGenericStringTestReferenceReferenceBuilder( + => new( ReferenceReferenceBuilder.HasForeignKey(dependentEntityTypeName, foreignKeyPropertyNames)); public NonGenericStringTestReferenceReferenceBuilder HasPrincipalKey( string principalEntityTypeName, params string[] keyPropertyNames) - => new NonGenericStringTestReferenceReferenceBuilder - (ReferenceReferenceBuilder.HasPrincipalKey(principalEntityTypeName, keyPropertyNames)); + => new(ReferenceReferenceBuilder.HasPrincipalKey(principalEntityTypeName, keyPropertyNames)); private ReferenceReferenceBuilder ReferenceReferenceBuilder { get; } diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs index 1a9a36f9f43..fd4e1171dd3 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs @@ -201,7 +201,7 @@ public override IMutableEntityType Metadata => EntityTypeBuilder.Metadata; protected virtual NonGenericTestEntityTypeBuilder Wrap(EntityTypeBuilder entityTypeBuilder) - => new NonGenericTestEntityTypeBuilder(entityTypeBuilder); + => new(entityTypeBuilder); public override TestEntityTypeBuilder HasAnnotation(string annotation, object value) => Wrap(EntityTypeBuilder.HasAnnotation(annotation, value)); @@ -781,7 +781,7 @@ public override IMutableForeignKey Metadata protected virtual NonGenericTestReferenceReferenceBuilder Wrap( ReferenceReferenceBuilder referenceReferenceBuilder) - => new NonGenericTestReferenceReferenceBuilder(referenceReferenceBuilder); + => new(referenceReferenceBuilder); public override TestReferenceReferenceBuilder HasAnnotation(string annotation, object value) => Wrap(ReferenceReferenceBuilder.HasAnnotation(annotation, value)); @@ -908,7 +908,7 @@ protected virtual NonGenericTestOwnershipBuilder OwnershipBuilder ownershipBuilder) where TNewEntity : class where TNewRelatedEntity : class - => new NonGenericTestOwnershipBuilder(ownershipBuilder); + => new(ownershipBuilder); public override TestOwnershipBuilder HasAnnotation(string annotation, object value) => Wrap(OwnershipBuilder.HasAnnotation(annotation, value)); @@ -959,7 +959,7 @@ protected virtual NonGenericTestOwnedNavigationBuilder new NonGenericTestOwnedNavigationBuilder(ownedNavigationBuilder); + => new(ownedNavigationBuilder); public override TestOwnedNavigationBuilder HasAnnotation( string annotation, diff --git a/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs b/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs index 55cab1bcbb3..74212113ec8 100644 --- a/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs @@ -1501,7 +1501,7 @@ public virtual void Can_add_seed_data_objects() { c.HasData( new Beta { Id = -1 }); - var customers = new List { new Beta { Id = -2 } }; + var customers = new List { new() { Id = -2 } }; c.HasData(customers); }); diff --git a/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs b/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs index e0f70cbdb64..bd87e5aa688 100644 --- a/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs @@ -570,7 +570,7 @@ public virtual void Can_configure_owned_type_from_an_owned_type_collection(HasDa ownedNavigationBuilder.HasData(new List { new OrderDetails { OrderId = -1 } }); break; case HasDataOverload.Enumerable | HasDataOverload.Generic: - ownedNavigationBuilder.HasData(new List { new OrderDetails { OrderId = -1 } }); + ownedNavigationBuilder.HasData(new List { new() { OrderId = -1 } }); break; default: Assert.True(false, $"Unexpected HasData overload specification {hasDataOverload}"); diff --git a/test/EFCore.Tests/ModelBuilding/TestModel.cs b/test/EFCore.Tests/ModelBuilding/TestModel.cs index 83d77e56e9d..e2b7978afd5 100644 --- a/test/EFCore.Tests/ModelBuilding/TestModel.cs +++ b/test/EFCore.Tests/ModelBuilding/TestModel.cs @@ -876,7 +876,7 @@ public object this[string name] protected class IndexedClassByDictionary { - private readonly Dictionary _indexerData = new Dictionary(); + private readonly Dictionary _indexerData = new(); public int Id { get; set; } @@ -1097,15 +1097,15 @@ protected class CollectionNavigationToSharedType protected class AmbiguousManyToManyImplicitLeft { public int Id { get; set; } - public List Navigation1 { get; } = new List(); - public List Navigation2 { get; } = new List(); + public List Navigation1 { get; } = new(); + public List Navigation2 { get; } = new(); } protected class AmbiguousManyToManyImplicitRight { public int Id { get; set; } - public List Navigation1 { get; } = new List(); - public List Navigation2 { get; } = new List(); + public List Navigation1 { get; } = new(); + public List Navigation2 { get; } = new(); } protected class AmbiguousInversePropertyLeft diff --git a/test/EFCore.Tests/ModelSourceTest.cs b/test/EFCore.Tests/ModelSourceTest.cs index 4c4b91afde9..877d4b249d6 100644 --- a/test/EFCore.Tests/ModelSourceTest.cs +++ b/test/EFCore.Tests/ModelSourceTest.cs @@ -26,11 +26,11 @@ namespace Microsoft.EntityFrameworkCore { public class ModelSourceTest { - private readonly IConventionSetBuilder _nullConventionSetBuilder = - new NullConventionSetBuilder(); + private readonly IConventionSetBuilder _nullConventionSetBuilder + = new NullConventionSetBuilder(); - private readonly ModelDependencies _testModelDependencies = - new ModelDependencies(new TestLogger()); + private readonly ModelDependencies _testModelDependencies + = new(new TestLogger()); [ConditionalFact] public void OnModelCreating_is_only_called_once() @@ -187,7 +187,7 @@ public ConcreteModelSource(IDbSetFinder setFinder) private class NullConventionSetBuilder : IConventionSetBuilder { public ConventionSet CreateConventionSet() - => new ConventionSet(); + => new(); } } } diff --git a/test/EFCore.Tests/Query/ExpressionPrinterTest.cs b/test/EFCore.Tests/Query/ExpressionPrinterTest.cs index e75bdbec72b..0388522907d 100644 --- a/test/EFCore.Tests/Query/ExpressionPrinterTest.cs +++ b/test/EFCore.Tests/Query/ExpressionPrinterTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ExpressionPrinterTest { - private readonly ExpressionPrinter _expressionPrinter = new ExpressionPrinter(); + private readonly ExpressionPrinter _expressionPrinter = new(); [ConditionalFact] public void UnaryExpression_printed_correctly() diff --git a/test/EFCore.Tests/Storage/BoolToStringConverterTest.cs b/test/EFCore.Tests/Storage/BoolToStringConverterTest.cs index 31da2e2bec0..9aa3c239afd 100644 --- a/test/EFCore.Tests/Storage/BoolToStringConverterTest.cs +++ b/test/EFCore.Tests/Storage/BoolToStringConverterTest.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Storage public class BoolToStringConverterTest { private static readonly BoolToStringConverter _boolToTrueFalse - = new BoolToStringConverter("False", "True"); + = new("False", "True"); [ConditionalFact] public void Can_convert_bools_to_true_false_strings() @@ -37,7 +37,7 @@ public void Can_convert_true_false_strings_to_bool() } private static readonly BoolToStringConverter _boolToYn - = new BoolToStringConverter("N", "Y"); + = new("N", "Y"); [ConditionalFact] public void Can_convert_bools_to_Y_N_strings() diff --git a/test/EFCore.Tests/Storage/BoolToZeroOneConverterTest.cs b/test/EFCore.Tests/Storage/BoolToZeroOneConverterTest.cs index 8b152de152c..7cc7a53e243 100644 --- a/test/EFCore.Tests/Storage/BoolToZeroOneConverterTest.cs +++ b/test/EFCore.Tests/Storage/BoolToZeroOneConverterTest.cs @@ -8,8 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class BoolToZeroOneConverterTest { - private static readonly BoolToZeroOneConverter _boolToZeroOne - = new BoolToZeroOneConverter(); + private static readonly BoolToZeroOneConverter _boolToZeroOne = new(); [ConditionalFact] public void Can_convert_bools_to_zero_one() diff --git a/test/EFCore.Tests/Storage/BytesToStringConverterTest.cs b/test/EFCore.Tests/Storage/BytesToStringConverterTest.cs index d0a311e7a9d..a40f44f030d 100644 --- a/test/EFCore.Tests/Storage/BytesToStringConverterTest.cs +++ b/test/EFCore.Tests/Storage/BytesToStringConverterTest.cs @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class BytesToStringConverterTest { - private static readonly BytesToStringConverter _bytesToStringConverter - = new BytesToStringConverter(); + private static readonly BytesToStringConverter _bytesToStringConverter = new(); [ConditionalFact] public void Can_convert_strings_to_bytes() diff --git a/test/EFCore.Tests/Storage/CharToStringConverterTest.cs b/test/EFCore.Tests/Storage/CharToStringConverterTest.cs index 68aa0b9ddde..d6c7c223c61 100644 --- a/test/EFCore.Tests/Storage/CharToStringConverterTest.cs +++ b/test/EFCore.Tests/Storage/CharToStringConverterTest.cs @@ -8,8 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class CharToStringConverterTest { - private static readonly CharToStringConverter _charToString - = new CharToStringConverter(); + private static readonly CharToStringConverter _charToString = new(); [ConditionalFact] public void Can_convert_chars_to_strings() diff --git a/test/EFCore.Tests/Storage/DateTimeConvertersTest.cs b/test/EFCore.Tests/Storage/DateTimeConvertersTest.cs index 051fdbe30d9..cce8ff4afd5 100644 --- a/test/EFCore.Tests/Storage/DateTimeConvertersTest.cs +++ b/test/EFCore.Tests/Storage/DateTimeConvertersTest.cs @@ -10,8 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class DateTimeConvertersTest { - private static readonly DateTimeToTicksConverter _dateTimeToTicks - = new DateTimeToTicksConverter(); + private static readonly DateTimeToTicksConverter _dateTimeToTicks = new(); [ConditionalFact] public void Can_convert_DateTime_to_ticks() @@ -34,8 +33,7 @@ public void Can_convert_ticks_to_DateTime() Assert.Equal(new DateTime(), converter(0)); } - private static readonly DateTimeToBinaryConverter _dateTimeToBinary - = new DateTimeToBinaryConverter(); + private static readonly DateTimeToBinaryConverter _dateTimeToBinary = new(); [ConditionalFact] public void Can_convert_DateTime_to_binary() @@ -109,8 +107,7 @@ public void Can_convert_unsigned_binary_to_DateTime() Assert.Equal(new DateTime(), converter(0)); } - private static readonly DateTimeToStringConverter _dateTimeToString - = new DateTimeToStringConverter(); + private static readonly DateTimeToStringConverter _dateTimeToString = new(); [ConditionalFact] public void Can_convert_DateTime_to_string() diff --git a/test/EFCore.Tests/Storage/DateTimeOffsetConvertersTest.cs b/test/EFCore.Tests/Storage/DateTimeOffsetConvertersTest.cs index 741799681e8..2594629147f 100644 --- a/test/EFCore.Tests/Storage/DateTimeOffsetConvertersTest.cs +++ b/test/EFCore.Tests/Storage/DateTimeOffsetConvertersTest.cs @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class DateTimeOffsetConvertersTest { - private static readonly DateTimeOffsetToStringConverter _dateTimeOffsetToString - = new DateTimeOffsetToStringConverter(); + private static readonly DateTimeOffsetToStringConverter _dateTimeOffsetToString = new(); [ConditionalFact] public void Can_convert_DateTimeOffset_to_string() @@ -39,8 +38,7 @@ public void Can_convert_string_to_DateTimeOffset() new DateTimeOffset(), converter("0001-01-01 00:00:00+00:00")); } - private static readonly DateTimeOffsetToBytesConverter _dateTimeOffsetToBytes - = new DateTimeOffsetToBytesConverter(); + private static readonly DateTimeOffsetToBytesConverter _dateTimeOffsetToBytes = new(); [ConditionalFact] public void Can_convert_DateTimeOffset_to_bytes() @@ -70,8 +68,7 @@ public void Can_convert_bytes_to_DateTimeOffset() converter(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 })); } - private static readonly DateTimeOffsetToBinaryConverter _dateTimeOffsetToBinary - = new DateTimeOffsetToBinaryConverter(); + private static readonly DateTimeOffsetToBinaryConverter _dateTimeOffsetToBinary = new(); [ConditionalFact] public void Can_convert_DateTimeOffset_to_binary() diff --git a/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs b/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs index d2a2b7760a2..66cff72708d 100644 --- a/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs +++ b/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs @@ -26,7 +26,7 @@ public void Dispose() => Context.Dispose(); private TestExecutionStrategy CreateFailOnRetryStrategy() - => new TestExecutionStrategy( + => new( Context, shouldRetryOn: e => { diff --git a/test/EFCore.Tests/Storage/GuidToBytesConverterTest.cs b/test/EFCore.Tests/Storage/GuidToBytesConverterTest.cs index addd30845cd..8320d7da20c 100644 --- a/test/EFCore.Tests/Storage/GuidToBytesConverterTest.cs +++ b/test/EFCore.Tests/Storage/GuidToBytesConverterTest.cs @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class GuidToBytesConverterTest { - private static readonly GuidToBytesConverter _guidToBytes - = new GuidToBytesConverter(); + private static readonly GuidToBytesConverter _guidToBytes = new(); [ConditionalFact] public void Can_convert_GUIDs_to_bytes() diff --git a/test/EFCore.Tests/Storage/GuidToStringConverterTest.cs b/test/EFCore.Tests/Storage/GuidToStringConverterTest.cs index c51536f1031..eda586a3278 100644 --- a/test/EFCore.Tests/Storage/GuidToStringConverterTest.cs +++ b/test/EFCore.Tests/Storage/GuidToStringConverterTest.cs @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class GuidToStringConverterTest { - private static readonly GuidToStringConverter _guidToString - = new GuidToStringConverter(); + private static readonly GuidToStringConverter _guidToString = new(); [ConditionalFact] public void Can_convert_GUIDs_to_String() diff --git a/test/EFCore.Tests/Storage/IPAddressToBytesConverterTest.cs b/test/EFCore.Tests/Storage/IPAddressToBytesConverterTest.cs index 0c658721905..f0568fdf001 100644 --- a/test/EFCore.Tests/Storage/IPAddressToBytesConverterTest.cs +++ b/test/EFCore.Tests/Storage/IPAddressToBytesConverterTest.cs @@ -10,8 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class IPAddressToBytesConverterTest { - private static readonly IPAddressToBytesConverter _ipAddressToBytes - = new IPAddressToBytesConverter(); + private static readonly IPAddressToBytesConverter _ipAddressToBytes = new(); [ConditionalTheory] [InlineData("255.255.255.255")] diff --git a/test/EFCore.Tests/Storage/IPAddressToStringConverterTest.cs b/test/EFCore.Tests/Storage/IPAddressToStringConverterTest.cs index d420525333b..4fbcd418558 100644 --- a/test/EFCore.Tests/Storage/IPAddressToStringConverterTest.cs +++ b/test/EFCore.Tests/Storage/IPAddressToStringConverterTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Storage public class IPAddressToStringConverterTest { private static readonly IPAddressToStringConverter _ipAddressToString - = new IPAddressToStringConverter(); + = new(); [ConditionalTheory] [InlineData("255.255.255.255")] diff --git a/test/EFCore.Tests/Storage/NumberToBytesConverterTest.cs b/test/EFCore.Tests/Storage/NumberToBytesConverterTest.cs index 14f421ed87b..7821897773e 100644 --- a/test/EFCore.Tests/Storage/NumberToBytesConverterTest.cs +++ b/test/EFCore.Tests/Storage/NumberToBytesConverterTest.cs @@ -10,8 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class NumberToBytesConverterTest { - private static readonly NumberToBytesConverter _byteToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _byteToBytesConverter = new(); [ConditionalFact] public void Can_convert_byte_to_bytes() @@ -36,8 +35,7 @@ public void Ordering_preserved_for_byte_to_bytes() ValueConverterTest.OrderingTest(_byteToBytesConverter, (byte)0, (byte)7, (byte)77, (byte)255); } - private static readonly NumberToBytesConverter _nullableByteToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _nullableByteToBytesConverter = new(); [ConditionalFact] public void Can_convert_nullable_byte_to_bytes() @@ -63,8 +61,7 @@ public void Ordering_preserved_for_nullable_byte_to_bytes() ValueConverterTest.OrderingTest(_nullableByteToBytesConverter, (byte?)0, (byte?)7, (byte?)77, (byte?)255); } - private static readonly NumberToBytesConverter _shortToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _shortToBytesConverter = new(); [ConditionalFact] public void Can_convert_short_to_bytes() @@ -85,8 +82,7 @@ public void Can_convert_bytes_to_short() Assert.Equal(0, converter(null)); } - private static readonly NumberToBytesConverter _intToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _intToBytesConverter = new(); [ConditionalFact] public void Can_convert_int_to_bytes() @@ -107,8 +103,7 @@ public void Can_convert_bytes_to_int() Assert.Equal(0, converter(null)); } - private static readonly NumberToBytesConverter _nullableIntToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _nullableIntToBytesConverter = new(); [ConditionalFact] public void Can_convert_nullable_int_to_bytes() @@ -130,8 +125,7 @@ public void Can_convert_bytes_to_nullable_int() Assert.Null(converter(null)); } - private static readonly NumberToBytesConverter _longToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _longToBytesConverter = new(); [ConditionalFact] public void Can_convert_long_to_bytes() @@ -152,8 +146,7 @@ public void Can_convert_bytes_to_long() Assert.Equal(0, converter(null)); } - private static readonly NumberToBytesConverter _sbyteToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _sbyteToBytesConverter = new(); [ConditionalFact] public void Can_convert_sbyte_to_bytes() @@ -174,8 +167,7 @@ public void Can_convert_bytes_to_sbyte() Assert.Equal(0, converter(null)); } - private static readonly NumberToBytesConverter _nullableSbyteToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _nullableSbyteToBytesConverter = new(); [ConditionalFact] public void Can_convert_nullable_sbyte_to_bytes() @@ -197,8 +189,7 @@ public void Can_convert_bytes_to_nullable_sbyte() Assert.Null(converter(null)); } - private static readonly NumberToBytesConverter _ushortToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _ushortToBytesConverter = new(); [ConditionalFact] public void Can_convert_ushort_to_bytes() @@ -223,8 +214,7 @@ public void Ordering_preserved_for_ushort_to_bytes() ValueConverterTest.OrderingTest(_ushortToBytesConverter, (ushort)0, (ushort)7, (ushort)777, (ushort)7777); } - private static readonly NumberToBytesConverter _uintToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _uintToBytesConverter = new(); [ConditionalFact] public void Can_convert_uint_to_bytes() @@ -243,8 +233,7 @@ public void Can_convert_bytes_to_uint() Assert.Equal((uint)0, converter(null)); } - private static readonly NumberToBytesConverter _nullableUintToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _nullableUintToBytesConverter = new(); [ConditionalFact] public void Can_convert_nullable_uint_to_bytes() @@ -270,8 +259,7 @@ public void Ordering_preserved_for_uint_to_bytes() ValueConverterTest.OrderingTest(_uintToBytesConverter, (uint)0, (uint)7, (uint)777777, (uint)77777777); } - private static readonly NumberToBytesConverter _ulongToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _ulongToBytesConverter = new(); [ConditionalFact] public void Can_convert_ulong_to_bytes() @@ -296,8 +284,7 @@ public void Ordering_preserved_for_ulong_to_bytes() ValueConverterTest.OrderingTest(_ulongToBytesConverter, (ulong)0, (ulong)777, (ulong)77777777, (ulong)7777777777777777); } - private static readonly NumberToBytesConverter _charToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _charToBytesConverter = new(); [ConditionalFact] public void Can_convert_char_to_bytes() @@ -322,8 +309,7 @@ public void Ordering_preserved_for_char_to_bytes() ValueConverterTest.OrderingTest(_charToBytesConverter, '\u0000', 'A', 'Z', '\u7777'); } - private static readonly NumberToBytesConverter _decimalToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _decimalToBytesConverter = new(); [ConditionalFact] public void Can_convert_decimal_to_bytes() @@ -387,8 +373,7 @@ public void Can_convert_bytes_to_decimal() converter(new byte[] { 0x80, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 })); } - private static readonly NumberToBytesConverter _nullableDecimalToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _nullableDecimalToBytesConverter = new(); [ConditionalFact] public void Can_convert_nullable_decimal_to_bytes() @@ -454,8 +439,7 @@ public void Can_convert_bytes_to_nullable_decimal() Assert.Null(converter(null)); } - private static readonly NumberToBytesConverter _floatToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _floatToBytesConverter = new(); [ConditionalFact] public void Can_convert_float_to_bytes() @@ -476,8 +460,7 @@ public void Can_convert_bytes_to_float() Assert.Equal(0, converter(null)); } - private static readonly NumberToBytesConverter _doubleToBytesConverter - = new NumberToBytesConverter(); + private static readonly NumberToBytesConverter _doubleToBytesConverter = new(); [ConditionalFact] public void Can_convert_double_to_bytes() diff --git a/test/EFCore.Tests/Storage/NumberToStringConverterTest.cs b/test/EFCore.Tests/Storage/NumberToStringConverterTest.cs index 39514fb2ac0..f0fc8127a4f 100644 --- a/test/EFCore.Tests/Storage/NumberToStringConverterTest.cs +++ b/test/EFCore.Tests/Storage/NumberToStringConverterTest.cs @@ -12,8 +12,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class NumberToStringConverterTest { - private static readonly NumberToStringConverter _ulongToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _ulongToNaturalString = new(); [ConditionalFact] public void Can_convert_ulongs_to_natural_strings() @@ -61,8 +60,7 @@ public void Can_convert_natural_strings_to_ulongs_object() Assert.Null(converter(null)); } - private static readonly NumberToStringConverter _longToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _longToNaturalString = new(); [ConditionalFact] public void Can_convert_longs_to_natural_strings() @@ -116,8 +114,7 @@ public void Can_convert_natural_strings_to_longs_object() Assert.Null(converter(null)); } - private static readonly NumberToStringConverter _uintToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _uintToNaturalString = new(); [ConditionalFact] public void Can_convert_uints_to_natural_strings() @@ -165,8 +162,7 @@ public void Can_convert_natural_strings_to_uints_object() Assert.Null(converter(null)); } - private static readonly NumberToStringConverter _intToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _intToNaturalString = new(); [ConditionalFact] public void Can_convert_ints_to_natural_strings() @@ -220,8 +216,7 @@ public void Can_convert_natural_strings_to_ints_object() Assert.Null(converter(null)); } - private static readonly NumberToStringConverter _ushortToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _ushortToNaturalString = new(); [ConditionalFact] public void Can_convert_ushorts_to_natural_strings() @@ -269,8 +264,7 @@ public void Can_convert_natural_strings_to_ushorts_object() Assert.Null(converter(null)); } - private static readonly NumberToStringConverter _shortToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _shortToNaturalString = new(); [ConditionalFact] public void Can_convert_shorts_to_natural_strings() @@ -324,8 +318,7 @@ public void Can_convert_natural_strings_to_shorts_object() Assert.Null(converter(null)); } - private static readonly NumberToStringConverter _byteToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _byteToNaturalString = new(); [ConditionalFact] public void Can_convert_bytes_to_natural_strings() @@ -373,8 +366,7 @@ public void Can_convert_natural_strings_to_bytes_object() Assert.Null(converter(null)); } - private static readonly NumberToStringConverter _sbyteToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _sbyteToNaturalString = new(); [ConditionalFact] public void Can_convert_sbytes_to_natural_strings() @@ -428,8 +420,7 @@ public void Can_convert_natural_strings_to_sbytes_object() Assert.Null(converter(null)); } - private static readonly NumberToStringConverter _decimalToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _decimalToNaturalString = new(); [ConditionalFact] public void Can_convert_decimals_to_natural_strings() @@ -458,8 +449,7 @@ public void Can_convert_natural_strings_to_decimals() Assert.Equal(0, converter(null)); } - private static readonly NumberToStringConverter _doubleToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _doubleToNaturalString = new(); [ConditionalFact] public void Can_convert_doubles_to_natural_strings() @@ -488,8 +478,7 @@ public void Can_convert_natural_strings_to_doubles() Assert.Equal(0, converter(null)); } - private static readonly NumberToStringConverter _floatToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _floatToNaturalString = new(); [ConditionalFact] public void Can_convert_floats_to_natural_strings() @@ -518,8 +507,7 @@ public void Can_convert_natural_strings_to_floats() Assert.Equal(0, converter(null)); } - private static readonly NumberToStringConverter _nullableSbyteToNaturalString - = new NumberToStringConverter(); + private static readonly NumberToStringConverter _nullableSbyteToNaturalString = new(); [ConditionalFact] public void Can_convert_nullable_sbytes_to_natural_strings() diff --git a/test/EFCore.Tests/Storage/PhysicalAddressToBytesConverterTest.cs b/test/EFCore.Tests/Storage/PhysicalAddressToBytesConverterTest.cs index 047d3ea6a0a..4e0cbc7faf6 100644 --- a/test/EFCore.Tests/Storage/PhysicalAddressToBytesConverterTest.cs +++ b/test/EFCore.Tests/Storage/PhysicalAddressToBytesConverterTest.cs @@ -10,8 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class PhysicalAddressToBytesConverterTest { - private static readonly PhysicalAddressToBytesConverter _physicalAddressToBytes - = new PhysicalAddressToBytesConverter(); + private static readonly PhysicalAddressToBytesConverter _physicalAddressToBytes = new(); [ConditionalTheory] [MemberData(nameof(Data))] diff --git a/test/EFCore.Tests/Storage/PhysicalAddressToStringConverterTest.cs b/test/EFCore.Tests/Storage/PhysicalAddressToStringConverterTest.cs index 82abf38f98b..1ca78541c10 100644 --- a/test/EFCore.Tests/Storage/PhysicalAddressToStringConverterTest.cs +++ b/test/EFCore.Tests/Storage/PhysicalAddressToStringConverterTest.cs @@ -13,8 +13,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class PhysicalAddressToStringConverterTest { - private static readonly PhysicalAddressToStringConverter _physicalAddressToString - = new PhysicalAddressToStringConverter(); + private static readonly PhysicalAddressToStringConverter _physicalAddressToString = new(); [ConditionalTheory] [MemberData(nameof(Data))] diff --git a/test/EFCore.Tests/Storage/StringToBoolConverterTest.cs b/test/EFCore.Tests/Storage/StringToBoolConverterTest.cs index facef05f7c9..dbad42d9582 100644 --- a/test/EFCore.Tests/Storage/StringToBoolConverterTest.cs +++ b/test/EFCore.Tests/Storage/StringToBoolConverterTest.cs @@ -8,8 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class StringToBoolConverterTest { - private static readonly StringToBoolConverter _stringToBool - = new StringToBoolConverter(); + private static readonly StringToBoolConverter _stringToBool = new(); [ConditionalFact] public void Can_convert_strings_to_bools() diff --git a/test/EFCore.Tests/Storage/StringToBytesConverterTest.cs b/test/EFCore.Tests/Storage/StringToBytesConverterTest.cs index e0eacacf31a..2eec9d299eb 100644 --- a/test/EFCore.Tests/Storage/StringToBytesConverterTest.cs +++ b/test/EFCore.Tests/Storage/StringToBytesConverterTest.cs @@ -10,8 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class StringToBytesConverterTest { - private static readonly StringToBytesConverter _stringToUtf8Converter - = new StringToBytesConverter(Encoding.UTF8); + private static readonly StringToBytesConverter _stringToUtf8Converter = new(Encoding.UTF8); [ConditionalFact] public void Can_convert_strings_to_UTF8() diff --git a/test/EFCore.Tests/Storage/StringToCharConverterTest.cs b/test/EFCore.Tests/Storage/StringToCharConverterTest.cs index 98ff99c00ea..36fcf2cfc59 100644 --- a/test/EFCore.Tests/Storage/StringToCharConverterTest.cs +++ b/test/EFCore.Tests/Storage/StringToCharConverterTest.cs @@ -8,8 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class StringToCharConverterTest { - private static readonly StringToCharConverter _stringToChar - = new StringToCharConverter(); + private static readonly StringToCharConverter _stringToChar = new(); [ConditionalFact] public void Can_convert_strings_to_chars() diff --git a/test/EFCore.Tests/Storage/StringToDateTimeConverterTest.cs b/test/EFCore.Tests/Storage/StringToDateTimeConverterTest.cs index 2eba55a73ef..0907e4466e4 100644 --- a/test/EFCore.Tests/Storage/StringToDateTimeConverterTest.cs +++ b/test/EFCore.Tests/Storage/StringToDateTimeConverterTest.cs @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class StringToDateTimeConverterTest { - private static readonly StringToDateTimeConverter _stringToDateTime - = new StringToDateTimeConverter(); + private static readonly StringToDateTimeConverter _stringToDateTime = new(); [ConditionalFact] public void Can_convert_string_to_DateTime() diff --git a/test/EFCore.Tests/Storage/StringToDateTimeOffsetConverterTest.cs b/test/EFCore.Tests/Storage/StringToDateTimeOffsetConverterTest.cs index 9712877b33c..1c32209dda2 100644 --- a/test/EFCore.Tests/Storage/StringToDateTimeOffsetConverterTest.cs +++ b/test/EFCore.Tests/Storage/StringToDateTimeOffsetConverterTest.cs @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class StringToDateTimeOffsetConverterTest { - private static readonly StringToDateTimeOffsetConverter _stringToDateTimeOffset - = new StringToDateTimeOffsetConverter(); + private static readonly StringToDateTimeOffsetConverter _stringToDateTimeOffset = new(); [ConditionalFact] public void Can_convert_string_to_DateTimeOffset() diff --git a/test/EFCore.Tests/Storage/StringToGuidConverterTest.cs b/test/EFCore.Tests/Storage/StringToGuidConverterTest.cs index afdd6844f46..c9f31e1410e 100644 --- a/test/EFCore.Tests/Storage/StringToGuidConverterTest.cs +++ b/test/EFCore.Tests/Storage/StringToGuidConverterTest.cs @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class StringToGuidConverterTest { - private static readonly StringToGuidConverter _stringToGuid - = new StringToGuidConverter(); + private static readonly StringToGuidConverter _stringToGuid = new(); [ConditionalFact] public void Can_convert_String_to_GUIDs() diff --git a/test/EFCore.Tests/Storage/StringToNumberConverterTest.cs b/test/EFCore.Tests/Storage/StringToNumberConverterTest.cs index 61261bb11aa..cb48337b460 100644 --- a/test/EFCore.Tests/Storage/StringToNumberConverterTest.cs +++ b/test/EFCore.Tests/Storage/StringToNumberConverterTest.cs @@ -12,8 +12,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class StringToNumberConverterTest { - private static readonly StringToNumberConverter _naturalStringToUlong - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToUlong = new(); [ConditionalFact] public void Can_convert_natural_strings_to_ulongs() @@ -61,8 +60,7 @@ public void Can_convert_ulongs_to_natural_strings_object() Assert.Null(converter(null)); } - private static readonly StringToNumberConverter _naturalStringToLong - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToLong = new(); [ConditionalFact] public void Can_convert_natural_strings_to_longs() @@ -116,8 +114,7 @@ public void Can_convert_longs_to_natural_strings_object() Assert.Null(converter(null)); } - private static readonly StringToNumberConverter _naturalStringToUint - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToUint = new(); [ConditionalFact] public void Can_convert_natural_strings_to_uints() @@ -165,8 +162,7 @@ public void Can_convert_uints_to_natural_strings_object() Assert.Null(converter(null)); } - private static readonly StringToNumberConverter _naturalStringToInt - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToInt = new(); [ConditionalFact] public void Can_convert_natural_strings_to_ints() @@ -220,8 +216,7 @@ public void Can_convert_ints_to_natural_strings_object() Assert.Null(converter(null)); } - private static readonly StringToNumberConverter _naturalStringToUshort - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToUshort = new(); [ConditionalFact] public void Can_convert_natural_strings_to_ushorts() @@ -269,8 +264,7 @@ public void Can_convert_ushorts_to_natural_strings_object() Assert.Null(converter(null)); } - private static readonly StringToNumberConverter _naturalStringToShort - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToShort = new(); [ConditionalFact] public void Can_convert_natural_strings_to_shorts() @@ -324,8 +318,7 @@ public void Can_convert_shorts_to_natural_strings_object() Assert.Null(converter(null)); } - private static readonly StringToNumberConverter _naturalStringToByte - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToByte = new(); [ConditionalFact] public void Can_convert_natural_strings_to_bytes() @@ -373,8 +366,7 @@ public void Can_convert_bytes_to_natural_strings_object() Assert.Null(converter(null)); } - private static readonly StringToNumberConverter _naturalStringToSbyte - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToSbyte = new(); [ConditionalFact] public void Can_convert_natural_strings_to_sbytes() @@ -428,8 +420,7 @@ public void Can_convert_sbytes_to_natural_strings_object() Assert.Null(converter(null)); } - private static readonly StringToNumberConverter _naturalStringToDecimal - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToDecimal = new(); [ConditionalFact] public void Can_convert_natural_strings_to_decimals() @@ -458,8 +449,7 @@ public void Can_convert_decimals_to_natural_strings() Assert.Equal("-0.00000000000000000001", converter((decimal)-0.00000000000000000001)); } - private static readonly StringToNumberConverter _naturalStringToDouble - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToDouble = new(); [ConditionalFact] public void Can_convert_natural_strings_to_doubles() @@ -488,8 +478,7 @@ public void Can_convert_doubles_to_natural_strings() Assert.Equal("-1E-20", converter(-0.00000000000000000001)); } - private static readonly StringToNumberConverter _naturalStringToFloat - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToFloat = new(); [ConditionalFact] public void Can_convert_natural_strings_to_floats() @@ -518,8 +507,7 @@ public void Can_convert_floats_to_natural_strings() Assert.Equal("-1E-20", converter((float)-0.00000000000000000001)); } - private static readonly StringToNumberConverter _naturalStringToNullableSbyte - = new StringToNumberConverter(); + private static readonly StringToNumberConverter _naturalStringToNullableSbyte = new(); [ConditionalFact] public void Can_convert_natural_strings_to_nullable_sbytes() diff --git a/test/EFCore.Tests/Storage/StringToTimeSpanConverterTest.cs b/test/EFCore.Tests/Storage/StringToTimeSpanConverterTest.cs index b865a0c239c..117c170e353 100644 --- a/test/EFCore.Tests/Storage/StringToTimeSpanConverterTest.cs +++ b/test/EFCore.Tests/Storage/StringToTimeSpanConverterTest.cs @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class StringToTimeSpanConverterTest { - private static readonly StringToTimeSpanConverter _stringToTimeSpan - = new StringToTimeSpanConverter(); + private static readonly StringToTimeSpanConverter _stringToTimeSpan = new(); [ConditionalFact] public void Can_convert_string_to_TimeSpan() diff --git a/test/EFCore.Tests/Storage/StringToUriConverterTest.cs b/test/EFCore.Tests/Storage/StringToUriConverterTest.cs index 8ca944f03de..7f794686abb 100644 --- a/test/EFCore.Tests/Storage/StringToUriConverterTest.cs +++ b/test/EFCore.Tests/Storage/StringToUriConverterTest.cs @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class StringToUriConverterTest { - private static readonly StringToUriConverter _stringToUri - = new StringToUriConverter(); + private static readonly StringToUriConverter _stringToUri = new(); [ConditionalFact] public void Can_convert_strings_to_uris() diff --git a/test/EFCore.Tests/Storage/TimeSpanConvertersTest.cs b/test/EFCore.Tests/Storage/TimeSpanConvertersTest.cs index 5e026f07274..ac36a9faa6f 100644 --- a/test/EFCore.Tests/Storage/TimeSpanConvertersTest.cs +++ b/test/EFCore.Tests/Storage/TimeSpanConvertersTest.cs @@ -10,8 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Storage { public class TimeSpanConvertersTest { - private static readonly TimeSpanToStringConverter _timeSpanToString - = new TimeSpanToStringConverter(); + private static readonly TimeSpanToStringConverter _timeSpanToString = new(); [ConditionalFact] public void Can_convert_TimeSpan_to_string() @@ -37,8 +36,7 @@ public void Can_convert_string_to_TimeSpan() Assert.Equal(new TimeSpan(), converter("00:00:00")); } - private static readonly TimeSpanToTicksConverter _timeSpanToTicks - = new TimeSpanToTicksConverter(); + private static readonly TimeSpanToTicksConverter _timeSpanToTicks = new(); [ConditionalFact] public void Can_convert_TimeSpan_to_ticks() diff --git a/test/EFCore.Tests/Storage/ValueConverterTest.cs b/test/EFCore.Tests/Storage/ValueConverterTest.cs index 0f39b015ae1..74d9bf5aed8 100644 --- a/test/EFCore.Tests/Storage/ValueConverterTest.cs +++ b/test/EFCore.Tests/Storage/ValueConverterTest.cs @@ -264,9 +264,7 @@ public void Can_cast_between_numeric_types() } private static readonly ValueConverter _intToString - = new ValueConverter( - v => v.ToString(), - v => ConvertToInt(v)); + = new(v => v.ToString(), v => ConvertToInt(v)); private static int ConvertToInt(string v) => int.TryParse(v, out var result) ? result : 0; diff --git a/test/EFCore.Tests/TestUtilities/FakeStateManager.cs b/test/EFCore.Tests/TestUtilities/FakeStateManager.cs index 600502acf91..6bab0df931e 100644 --- a/test/EFCore.Tests/TestUtilities/FakeStateManager.cs +++ b/test/EFCore.Tests/TestUtilities/FakeStateManager.cs @@ -41,7 +41,7 @@ public int SaveChanges(bool acceptAllChangesOnSuccess) return 1; } - public Task SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = new CancellationToken()) + public Task SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = new()) { SaveChangesAsyncCalled = true; return Task.FromResult(1); @@ -177,7 +177,7 @@ public InternalEntityEntry FindPrincipalUsingRelationshipSnapshot(InternalEntity => throw new NotImplementedException(); public DbContext Context - => new DbContext( + => new( new DbContextOptionsBuilder() .UseInternalServiceProvider(InMemoryFixture.DefaultServiceProvider) .UseInMemoryDatabase("D") diff --git a/test/EFCore.Tests/TestUtilities/MockAssembly.cs b/test/EFCore.Tests/TestUtilities/MockAssembly.cs index 2c08133061e..f3eab0482d8 100644 --- a/test/EFCore.Tests/TestUtilities/MockAssembly.cs +++ b/test/EFCore.Tests/TestUtilities/MockAssembly.cs @@ -32,7 +32,7 @@ public MockAssembly(IEnumerable definedTypes, MethodInfo entryPoint) public override IEnumerable DefinedTypes { get; } public override AssemblyName GetName() - => new AssemblyName(nameof(MockAssembly)); + => new(nameof(MockAssembly)); private class MockMethodInfo : MethodInfo { diff --git a/test/Microsoft.Data.Sqlite.Tests/SqliteBlobTest.cs b/test/Microsoft.Data.Sqlite.Tests/SqliteBlobTest.cs index 907c3a9e489..8f8cf80a241 100644 --- a/test/Microsoft.Data.Sqlite.Tests/SqliteBlobTest.cs +++ b/test/Microsoft.Data.Sqlite.Tests/SqliteBlobTest.cs @@ -15,7 +15,7 @@ public class SqliteBlobTest : IDisposable private const string Column = "value"; private const long Rowid = 1; - private readonly SqliteConnection _connection = new SqliteConnection("Data Source=:memory:"); + private readonly SqliteConnection _connection = new("Data Source=:memory:"); public SqliteBlobTest() {