From cf51269602aec052632e00d405ae57292fbeed66 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 28 Nov 2025 11:52:10 +0500 Subject: [PATCH 01/55] Check whether active transaction still exists before rollback If transaction has become broken during commit its rollback leads to new exception which will overwrite the original one. Check for active transaction should work because on exception within driver.CommitTransaction() active transaction is set to NULL. --- .../Orm/Upgrade/UpgradingDomainBuilder.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs index 9895fce1b..b13829e2d 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs @@ -172,7 +172,13 @@ private void CompleteUpgradeTransaction() driver.CommitTransaction(null, connection); } catch { - driver.RollbackTransaction(null, connection); + // If transaction has become broken during commit its rollback leads to new exception + // which will overwrite the original one. + // Check for active transaction should work because on exception within + // driver.Commit it is set to NULL. + if (connection.ActiveTransaction != null) { + driver.RollbackTransaction(null, connection); + } throw; } } @@ -190,7 +196,13 @@ private async ValueTask CompleteUpgradeTransactionAsync(CancellationToken token) await driver.CommitTransactionAsync(null, connection, token); } catch { - await driver.RollbackTransactionAsync(null, connection, token); + // If transaction has become broken during commit its rollback leads to new exception + // which will overwrite the original one. + // Check for active transaction should work because on exception within + // driver.Commit it is set to NULL. + if (connection.ActiveTransaction != null) { + await driver.RollbackTransactionAsync(null, connection, token); + } throw; } } From 0dbe36063bc553c90c3fc042f8255838e701b79a Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 28 Nov 2025 17:29:11 +0500 Subject: [PATCH 02/55] Update Npgsql package --- Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj | 2 +- Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj b/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj index 782450481..d03e9e6f3 100644 --- a/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj +++ b/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj @@ -25,7 +25,7 @@ - + diff --git a/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj b/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj index f1b35fdf4..fee9fc7e4 100644 --- a/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj +++ b/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj @@ -20,7 +20,7 @@ - + From 8883711ee9d6e8d2308185501ffe445a38e06ad1 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 28 Nov 2025 17:47:39 +0500 Subject: [PATCH 03/55] Temp upgrade to Npgsql 10.0.0.0 for net8 --- .../Xtensive.Orm.PostgreSql.csproj | 8 +++++++- Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj | 11 ++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj b/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj index d03e9e6f3..37fb31399 100644 --- a/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj +++ b/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj @@ -24,9 +24,15 @@ false - + + + + + + + diff --git a/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj b/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj index fee9fc7e4..4152d7ddc 100644 --- a/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj +++ b/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj @@ -18,9 +18,18 @@ + + + + + + + + + - + From c2be023436eb9c777e21ddde53848686850cb51d Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Mon, 1 Dec 2025 13:25:16 +0500 Subject: [PATCH 04/55] Revert "Temp upgrade to Npgsql 10.0.0.0 for net8" This reverts commit 8883711ee9d6e8d2308185501ffe445a38e06ad1. --- .../Xtensive.Orm.PostgreSql.csproj | 8 +------- Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj | 11 +---------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj b/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj index 37fb31399..d03e9e6f3 100644 --- a/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj +++ b/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj @@ -24,15 +24,9 @@ false - - - - + - - - diff --git a/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj b/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj index 4152d7ddc..fee9fc7e4 100644 --- a/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj +++ b/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj @@ -18,18 +18,9 @@ - - - - - - - - - - + From ef795747879f4e5b2a4e4214a76115803bfc61b5 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Mon, 1 Dec 2025 13:25:27 +0500 Subject: [PATCH 05/55] Revert "Update Npgsql package" This reverts commit 0dbe36063bc553c90c3fc042f8255838e701b79a. --- Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj | 2 +- Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj b/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj index d03e9e6f3..782450481 100644 --- a/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj +++ b/Orm/Xtensive.Orm.PostgreSql/Xtensive.Orm.PostgreSql.csproj @@ -25,7 +25,7 @@ - + diff --git a/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj b/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj index fee9fc7e4..f1b35fdf4 100644 --- a/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj +++ b/Orm/Xtensive.Orm.Tests/Xtensive.Orm.Tests.csproj @@ -20,7 +20,7 @@ - + From 458e0aec9fd89a4f4afec8b2466924f182fd66d1 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Mon, 1 Dec 2025 15:23:11 +0500 Subject: [PATCH 06/55] Improve changelog --- ChangeLog/7.2.1-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog/7.2.1-dev.txt b/ChangeLog/7.2.1-dev.txt index e69de29bb..1fe22ec11 100644 --- a/ChangeLog/7.2.1-dev.txt +++ b/ChangeLog/7.2.1-dev.txt @@ -0,0 +1 @@ +[main] Addressed issue of overwriting exception on attempt to rollback the transaction of Domain upgrade if commit operation failed \ No newline at end of file From 78cff7d801e4d985803acd34ad95b5862156d646 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 27 Feb 2026 12:00:48 +0500 Subject: [PATCH 07/55] Fix async enumerator not disposed properly --- Orm/Xtensive.Orm/Orm/QueryResult.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/QueryResult.cs b/Orm/Xtensive.Orm/Orm/QueryResult.cs index 7a83cc87e..fdb3c25f5 100644 --- a/Orm/Xtensive.Orm/Orm/QueryResult.cs +++ b/Orm/Xtensive.Orm/Orm/QueryResult.cs @@ -54,9 +54,10 @@ public IEnumerator GetEnumerator() public async IAsyncEnumerable AsAsyncEnumerable() { EnsureResultsAlive(); - var enumerator = reader.AsAsyncEnumerator(); - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { - yield return enumerator.Current; + await using (var enumerator = reader.AsAsyncEnumerator()) { + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { + yield return enumerator.Current; + } } } From a9d0924f270b0f222daf0ff5444ee0d4ad7a24a1 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 27 Feb 2026 12:25:01 +0500 Subject: [PATCH 08/55] Improve changelog --- ChangeLog/7.2.1-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog/7.2.1-dev.txt b/ChangeLog/7.2.1-dev.txt index e69de29bb..bcc72c82f 100644 --- a/ChangeLog/7.2.1-dev.txt +++ b/ChangeLog/7.2.1-dev.txt @@ -0,0 +1 @@ +[main] Addressed issue of not disposing IAsyncEnumerator which caused query being open \ No newline at end of file From aa65f8e8522b78892a5dc47965db34082322451c Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Tue, 24 Feb 2026 11:39:13 +0500 Subject: [PATCH 09/55] Covariant returns --- .../Arithmetic/Internal/NullableArithmetic.cs | 5 +-- .../Internal/PrimitiveArithmetics.tt | 7 ++--- .../Collections/ExtensionCollection.cs | 11 ++++--- Orm/Xtensive.Orm/Collections/TypeRegistry.cs | 8 ++--- .../Comparison/CastingComparer.cs | 2 +- .../Comparison/Internals/ArrayComparer.cs | 3 +- .../Comparison/Internals/AssemblyComparer.cs | 3 +- .../Internals/BaseComparerWrapper.cs | 3 +- .../Comparison/Internals/BooleanComparer.cs | 2 +- .../Comparison/Internals/ByteComparer.cs | 3 +- .../Comparison/Internals/CharComparer.cs | 3 +- .../Comparison/Internals/DecimalComparer.cs | 3 +- .../Comparison/Internals/DoubleComparer.cs | 3 +- .../Comparison/Internals/EnumComparer.cs | 3 +- .../Internals/EnumerableInterfaceComparer.cs | 4 +-- .../Comparison/Internals/GuidComparer.cs | 3 +- .../Comparison/Internals/Int16Comparer.cs | 3 +- .../Comparison/Internals/Int32Comparer.cs | 2 +- .../Comparison/Internals/Int64Comparer.cs | 3 +- .../Internals/KeyValuePairComparer.cs | 3 +- .../Comparison/Internals/NullableComparer.cs | 3 +- .../Comparison/Internals/ObjectComparer.cs | 3 +- .../Internals/PairComparer{T1,T2}.cs | 5 +-- .../Comparison/Internals/PairComparer{T}.cs | 3 +- .../Comparison/Internals/SByteComparer.cs | 3 +- .../Comparison/Internals/SingleComparer.cs | 3 +- .../Comparison/Internals/StringComparer.cs | 5 +-- .../Comparison/Internals/TupleComparer.cs | 3 +- .../Internals/TupleDescriptorComparer.cs | 3 +- .../Comparison/Internals/TypeComparer.cs | 3 +- .../Comparison/Internals/UInt16Comparer.cs | 3 +- .../Comparison/Internals/UInt32Comparer.cs | 3 +- .../Comparison/Internals/UInt64Comparer.cs | 3 +- .../DatabaseConfigurationCollection.cs | 10 ++++-- .../Orm/Configuration/DomainConfiguration.cs | 20 ++++++------ .../Orm/Configuration/DomainTypeRegistry.cs | 2 +- .../ExtensionConfigurationCollection.cs | 2 +- .../Orm/Configuration/IgnoreRuleCollection.cs | 8 ++++- .../KeyGeneratorConfiguration.cs | 2 +- .../KeyGeneratorConfigurationCollection.cs | 10 ++++-- .../Configuration/LinqExtensionRegistry.cs | 13 +++++--- .../Configuration/MappingRuleCollection.cs | 10 ++++-- .../Configuration/NameMappingCollection.cs | 11 ++++--- .../Orm/Configuration/NamingConvention.cs | 20 +++++++----- .../Orm/Configuration/NodeConfiguration.cs | 10 +++--- .../Orm/Configuration/SessionConfiguration.cs | 2 +- .../SessionConfigurationCollection.cs | 8 ++++- .../Orm/Configuration/VersioningConvention.cs | 15 ++++++--- .../Prefetch/Nodes/ExpressionMapBuilder.cs | 8 ++--- .../Expressions/Visitors/ColumnGatherer.cs | 31 ++++++++++--------- .../Visitors/ExtendedExpressionReplacer.cs | 26 ++++++++-------- .../Visitors/IncludeFilterMappingGatherer.cs | 2 +- .../Linq/Expressions/Visitors/OwnerRemover.cs | 24 +++++++------- .../Materialization/ExpressionMaterializer.cs | 2 +- .../Orm/Linq/ParameterExtractor.cs | 2 +- .../Linq/Rewriters/SubqueryFilterRemover.cs | 4 +-- .../Orm/Linq/Translator.Queryable.cs | 2 +- .../Orm/Model/Internals/TypePairComparer.cs | 2 +- .../Expressions/ExpressionProcessor.cs | 2 +- .../Orm/Providers/SqlCompiler.Include.cs | 2 +- Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.cs | 2 +- .../RealTemporaryTableBackEnd.cs | 4 +-- Orm/Xtensive.Orm/Orm/Rse/AggregateColumn.cs | 4 +-- Orm/Xtensive.Orm/Orm/Rse/CalculatedColumn.cs | 4 +-- Orm/Xtensive.Orm/Orm/Rse/MappedColumn.cs | 4 +-- Orm/Xtensive.Orm/Orm/Rse/SystemColumn.cs | 4 +-- .../ApplyProviderCorrectorRewriter.cs | 6 ++-- .../Internals/OrderingRewriter.cs | 12 +++---- Orm/Xtensive.Orm/Orm/Session.cs | 2 +- .../Upgrade/Internals/DomainModelConverter.cs | 10 +++--- .../Upgrade/Internals/SqlModelConverter.cs | 16 +++++----- .../Sql/Ddl/Actions/SqlAlterIdentityInfo.cs | 2 +- Orm/Xtensive.Orm/Sql/Ddl/SqlAlterSequence.cs | 2 +- .../Sql/Model/SequenceDescriptor.cs | 14 ++++++--- Orm/Xtensive.Orm/Tuples/DifferentialTuple.cs | 6 ++-- Orm/Xtensive.Orm/Tuples/Packed/PackedTuple.cs | 4 +-- 76 files changed, 245 insertions(+), 221 deletions(-) diff --git a/Orm/Xtensive.Orm/Arithmetic/Internal/NullableArithmetic.cs b/Orm/Xtensive.Orm/Arithmetic/Internal/NullableArithmetic.cs index 7e7e93c83..030abd006 100644 --- a/Orm/Xtensive.Orm/Arithmetic/Internal/NullableArithmetic.cs +++ b/Orm/Xtensive.Orm/Arithmetic/Internal/NullableArithmetic.cs @@ -82,10 +82,7 @@ public override bool IsSigned } /// - protected override IArithmetic CreateNew(ArithmeticRules rules) - { - return new NullableArithmetic(Provider, rules); - } + protected override NullableArithmetic CreateNew(ArithmeticRules rules) => new(Provider, rules); // Constructors diff --git a/Orm/Xtensive.Orm/Arithmetic/Internal/PrimitiveArithmetics.tt b/Orm/Xtensive.Orm/Arithmetic/Internal/PrimitiveArithmetics.tt index 4477aa360..90e9a1a84 100644 --- a/Orm/Xtensive.Orm/Arithmetic/Internal/PrimitiveArithmetics.tt +++ b/Orm/Xtensive.Orm/Arithmetic/Internal/PrimitiveArithmetics.tt @@ -1,4 +1,4 @@ -<#@ template language="C#" #> +<#@ template language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> // Copyright (C) 2008 Xtensive LLC. @@ -146,10 +146,7 @@ foreach (var type in types) { } /// - protected override IArithmetic<<#= primitiveName #>> CreateNew(ArithmeticRules rules) - { - return new <#= className #>(Provider, rules); - } + protected override <#= className #> CreateNew(ArithmeticRules rules) => new(Provider, rules); // Constructors diff --git a/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs b/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs index fe851865d..57a62944a 100644 --- a/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs +++ b/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs @@ -106,10 +106,13 @@ public override void Lock(bool recursive) #region ICloneable methods /// - public object Clone() - { - return new ExtensionCollection(this); - } + object ICloneable.Clone() => Clone(); + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public ExtensionCollection Clone() => new(this); #endregion diff --git a/Orm/Xtensive.Orm/Collections/TypeRegistry.cs b/Orm/Xtensive.Orm/Collections/TypeRegistry.cs index 80c02cb43..91603f6be 100644 --- a/Orm/Xtensive.Orm/Collections/TypeRegistry.cs +++ b/Orm/Xtensive.Orm/Collections/TypeRegistry.cs @@ -151,14 +151,14 @@ public override void Lock(bool recursive) #region ICloneable members + /// + object ICloneable.Clone() => Clone(); + /// /// Clones this instance. /// /// - public virtual object Clone() - { - return new TypeRegistry(this); - } + public virtual TypeRegistry Clone() => new TypeRegistry(this); #endregion diff --git a/Orm/Xtensive.Orm/Comparison/CastingComparer.cs b/Orm/Xtensive.Orm/Comparison/CastingComparer.cs index 77033a2e5..b97c95dec 100644 --- a/Orm/Xtensive.Orm/Comparison/CastingComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/CastingComparer.cs @@ -40,7 +40,7 @@ public AsymmetricCompareHandler(Func baseCompare) private readonly AdvancedComparer sourceComparer; /// - protected override IAdvancedComparer CreateNew(ComparisonRules rules) + protected override CastingComparer CreateNew(ComparisonRules rules) => new CastingComparer(sourceComparer.ApplyRules(rules)); /// diff --git a/Orm/Xtensive.Orm/Comparison/Internals/ArrayComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/ArrayComparer.cs index e775b0673..e8a04998d 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/ArrayComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/ArrayComparer.cs @@ -13,8 +13,7 @@ namespace Xtensive.Comparison internal sealed class ArrayComparer : WrappingComparer, ISystemComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new ArrayComparer(Provider, ComparisonRules.Combine(rules)); + protected override ArrayComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(T[] x, T[] y) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/AssemblyComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/AssemblyComparer.cs index af3e73747..52f34e71d 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/AssemblyComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/AssemblyComparer.cs @@ -14,8 +14,7 @@ namespace Xtensive.Comparison internal sealed class AssemblyComparer: WrappingComparer, ISystemComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new AssemblyComparer(Provider, ComparisonRules.Combine(rules)); + protected override AssemblyComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(Assembly x, Assembly y) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/BaseComparerWrapper.cs b/Orm/Xtensive.Orm/Comparison/Internals/BaseComparerWrapper.cs index ef4e624db..3c9e8be56 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/BaseComparerWrapper.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/BaseComparerWrapper.cs @@ -14,8 +14,7 @@ namespace Xtensive.Comparison internal class BaseComparerWrapper: WrappingComparer where T: TBase { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new BaseComparerWrapper(Provider, ComparisonRules.Combine(rules)); + protected override BaseComparerWrapper CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(T x, T y) => BaseComparer.Compare(x, y); diff --git a/Orm/Xtensive.Orm/Comparison/Internals/BooleanComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/BooleanComparer.cs index 0b5fd6ad6..153784f94 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/BooleanComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/BooleanComparer.cs @@ -14,7 +14,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class BooleanComparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) => new BooleanComparer(Provider, ComparisonRules.Combine(rules)); + protected override BooleanComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override bool GetNearestValue(bool value, Direction direction) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/ByteComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/ByteComparer.cs index ebef97031..f6a6b834e 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/ByteComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/ByteComparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class ByteComparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new ByteComparer(Provider, ComparisonRules.Combine(rules)); + protected override ByteComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/CharComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/CharComparer.cs index 6a2eca9ed..136524c2f 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/CharComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/CharComparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class CharComparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new CharComparer(Provider, ComparisonRules.Combine(rules)); + protected override CharComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/DecimalComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/DecimalComparer.cs index 2190b2c79..579df40e2 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/DecimalComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/DecimalComparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class DecimalComparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new DecimalComparer(Provider, ComparisonRules.Combine(rules)); + protected override DecimalComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/DoubleComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/DoubleComparer.cs index 7d8fe1167..1a686c910 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/DoubleComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/DoubleComparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class DoubleComparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new DoubleComparer(Provider, ComparisonRules.Combine(rules)); + protected override DoubleComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/EnumComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/EnumComparer.cs index fd904619e..d0c7dd0a5 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/EnumComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/EnumComparer.cs @@ -26,8 +26,7 @@ internal sealed class EnumComparer : WrappingComparer valueToIndex; private readonly int maxIndex; - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new EnumComparer(Provider, ComparisonRules.Combine(rules)); + protected override EnumComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(TEnum x, TEnum y) => BaseComparer.Compare(EnumToSystem(x), EnumToSystem(y)); diff --git a/Orm/Xtensive.Orm/Comparison/Internals/EnumerableInterfaceComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/EnumerableInterfaceComparer.cs index af5896047..eca2e7de7 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/EnumerableInterfaceComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/EnumerableInterfaceComparer.cs @@ -15,8 +15,8 @@ internal sealed class EnumerableInterfaceComparer : WrappingComp ISystemComparer where TEnumerable: class, IEnumerable { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new EnumerableInterfaceComparer(Provider, ComparisonRules.Combine(rules)); + protected override EnumerableInterfaceComparer CreateNew(ComparisonRules rules) + => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(TEnumerable x, TEnumerable y) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/GuidComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/GuidComparer.cs index 42271594d..63be565e9 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/GuidComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/GuidComparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class GuidComparer: ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new GuidComparer(Provider, ComparisonRules.Combine(rules)); + protected override GuidComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/Int16Comparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/Int16Comparer.cs index fe10bc585..6ddd8d06b 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/Int16Comparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/Int16Comparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class Int16Comparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new Int16Comparer(Provider, ComparisonRules.Combine(rules)); + protected override Int16Comparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/Int32Comparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/Int32Comparer.cs index bbe22f1d0..9e77defa4 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/Int32Comparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/Int32Comparer.cs @@ -12,7 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class Int32Comparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) => new Int32Comparer(Provider, ComparisonRules.Combine(rules)); + protected override Int32Comparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/Int64Comparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/Int64Comparer.cs index 50dfb9d1c..df62ffc00 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/Int64Comparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/Int64Comparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class Int64Comparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new Int64Comparer(Provider, ComparisonRules.Combine(rules)); + protected override Int64Comparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/KeyValuePairComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/KeyValuePairComparer.cs index c61ff9bf5..b691600c5 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/KeyValuePairComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/KeyValuePairComparer.cs @@ -15,8 +15,7 @@ namespace Xtensive.Comparison internal sealed class KeyValuePairComparer: WrappingComparer, T1, T2>, ISystemComparer> { - protected override IAdvancedComparer> CreateNew(ComparisonRules rules) - => new KeyValuePairComparer(Provider, ComparisonRules.Combine(rules)); + protected override KeyValuePairComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(KeyValuePair x, KeyValuePair y) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/NullableComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/NullableComparer.cs index 935248b46..4727b41a0 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/NullableComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/NullableComparer.cs @@ -23,8 +23,7 @@ internal sealed class NullableComparer: WrappingComparer private Func currentBaseGetHashCode; - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new NullableComparer(Provider, ComparisonRules.Combine(rules)); + protected override NullableComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(T? x, T? y) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/ObjectComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/ObjectComparer.cs index f53972f32..9c6d5da60 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/ObjectComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/ObjectComparer.cs @@ -20,8 +20,7 @@ internal sealed class ObjectComparer: AdvancedComparerBase [NonSerialized] private int nullHashCode; - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new ObjectComparer(Provider, ComparisonRules.Combine(rules)); + protected override ObjectComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(T x, T y) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/PairComparer{T1,T2}.cs b/Orm/Xtensive.Orm/Comparison/Internals/PairComparer{T1,T2}.cs index db277ef56..37decfcb8 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/PairComparer{T1,T2}.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/PairComparer{T1,T2}.cs @@ -13,10 +13,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class PairComparer: WrappingComparer, T1, T2> { - protected override IAdvancedComparer> CreateNew(ComparisonRules rules) - { - return new PairComparer(Provider, ComparisonRules.Combine(rules)); - } + protected override PairComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(Pair x, Pair y) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/PairComparer{T}.cs b/Orm/Xtensive.Orm/Comparison/Internals/PairComparer{T}.cs index 86d7f2ffe..8bd508ce6 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/PairComparer{T}.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/PairComparer{T}.cs @@ -13,8 +13,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class PairComparer: WrappingComparer, T> { - protected override IAdvancedComparer> CreateNew(ComparisonRules rules) - => new PairComparer(Provider, ComparisonRules.Combine(rules)); + protected override PairComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(Pair x, Pair y) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/SByteComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/SByteComparer.cs index 720d62b58..5ae937bbf 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/SByteComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/SByteComparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class SByteComparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new SByteComparer(Provider, ComparisonRules.Combine(rules)); + protected override SByteComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/SingleComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/SingleComparer.cs index a7c901bbe..f6b790a9e 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/SingleComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/SingleComparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class SingleComparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new SingleComparer(Provider, ComparisonRules.Combine(rules)); + protected override SingleComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/StringComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/StringComparer.cs index 006eacfcf..aa749126f 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/StringComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/StringComparer.cs @@ -22,10 +22,7 @@ internal sealed class StringComparer: AdvancedComparerBase, [NonSerialized] private Func stringIsSuffix; - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - { - return new StringComparer(Provider, ComparisonRules.Combine(rules)); - } + protected override StringComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(string x, string y) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/TupleComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/TupleComparer.cs index 98fd93171..6b3f54a02 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/TupleComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/TupleComparer.cs @@ -17,8 +17,7 @@ internal sealed class TupleComparer : AdvancedComparerBase, [NonSerialized] private int nullHashCode; - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new TupleComparer(Provider, ComparisonRules.Combine(rules)); + protected override TupleComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(Tuple x, Tuple y) => throw new NotSupportedException(); diff --git a/Orm/Xtensive.Orm/Comparison/Internals/TupleDescriptorComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/TupleDescriptorComparer.cs index 8252629eb..d1c17f341 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/TupleDescriptorComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/TupleDescriptorComparer.cs @@ -19,8 +19,7 @@ namespace Xtensive.Comparison internal sealed class TupleDescriptorComparer: WrappingComparer, ISystemComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new TupleDescriptorComparer(Provider, ComparisonRules.Combine(rules)); + protected override TupleDescriptorComparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); public override int Compare(TupleDescriptor x, TupleDescriptor y) => throw new NotSupportedException(); diff --git a/Orm/Xtensive.Orm/Comparison/Internals/TypeComparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/TypeComparer.cs index ada19dc97..118291666 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/TypeComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/TypeComparer.cs @@ -21,8 +21,7 @@ internal sealed class TypeComparer: WrappingComparer, [NonSerialized] private ConcurrentDictionary<(Type, Type, TypeComparer), int> results; - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new TypeComparer(Provider, ComparisonRules.Combine(rules)); + protected override TypeComparer CreateNew(ComparisonRules rules) => new TypeComparer(Provider, ComparisonRules.Combine(rules)); public override int Compare(Type x, Type y) { diff --git a/Orm/Xtensive.Orm/Comparison/Internals/UInt16Comparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/UInt16Comparer.cs index 19c230f0f..750ba0171 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/UInt16Comparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/UInt16Comparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class UInt16Comparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new UInt16Comparer(Provider, ComparisonRules.Combine(rules)); + protected override UInt16Comparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/UInt32Comparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/UInt32Comparer.cs index 31c0fecb5..37522d85d 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/UInt32Comparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/UInt32Comparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class UInt32Comparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new UInt32Comparer(Provider, ComparisonRules.Combine(rules)); + protected override UInt32Comparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Comparison/Internals/UInt64Comparer.cs b/Orm/Xtensive.Orm/Comparison/Internals/UInt64Comparer.cs index 5fc58bfe5..e928554ff 100644 --- a/Orm/Xtensive.Orm/Comparison/Internals/UInt64Comparer.cs +++ b/Orm/Xtensive.Orm/Comparison/Internals/UInt64Comparer.cs @@ -12,8 +12,7 @@ namespace Xtensive.Comparison [Serializable] internal sealed class UInt64Comparer : ValueTypeComparer { - protected override IAdvancedComparer CreateNew(ComparisonRules rules) - => new UInt64Comparer(Provider, ComparisonRules.Combine(rules)); + protected override UInt64Comparer CreateNew(ComparisonRules rules) => new(Provider, ComparisonRules.Combine(rules)); // Constructors diff --git a/Orm/Xtensive.Orm/Orm/Configuration/DatabaseConfigurationCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/DatabaseConfigurationCollection.cs index b7b469f7a..8f7e93ce5 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/DatabaseConfigurationCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/DatabaseConfigurationCollection.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -27,7 +27,13 @@ public IDatabaseConfigurationFlow Add(string name) } /// - public object Clone() + object ICloneable.Clone() => Clone(); + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public DatabaseConfigurationCollection Clone() { var result = new DatabaseConfigurationCollection(); foreach (var alias in this) diff --git a/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs index f5df3414b..02349340f 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs @@ -779,14 +779,14 @@ protected override void CopyFrom(ConfigurationBase source) connectionInfo = configuration.ConnectionInfo; defaultSchema = configuration.DefaultSchema; defaultDatabase = configuration.DefaultDatabase; - types = (DomainTypeRegistry) configuration.Types.Clone(); - linqExtensions = (LinqExtensionRegistry) configuration.LinqExtensions.Clone(); - namingConvention = (NamingConvention) configuration.NamingConvention.Clone(); + types = configuration.Types.Clone(); + linqExtensions = configuration.LinqExtensions.Clone(); + namingConvention = configuration.NamingConvention.Clone(); keyCacheSize = configuration.KeyCacheSize; keyGeneratorCacheSize = configuration.KeyGeneratorCacheSize; queryCacheSize = configuration.QueryCacheSize; recordSetMappingCacheSize = configuration.RecordSetMappingCacheSize; - sessions = (SessionConfigurationCollection) configuration.Sessions.Clone(); + sessions = configuration.Sessions.Clone(); upgradeMode = configuration.UpgradeMode; foreignKeyMode = configuration.ForeignKeyMode; serviceContainerType = configuration.ServiceContainerType; @@ -800,15 +800,15 @@ protected override void CopyFrom(ConfigurationBase source) multidatabaseKeys = configuration.MultidatabaseKeys; ensureConnectionIsAlive = configuration.EnsureConnectionIsAlive; options = configuration.Options; - databases = (DatabaseConfigurationCollection) configuration.Databases.Clone(); - mappingRules = (MappingRuleCollection) configuration.MappingRules.Clone(); - keyGenerators = (KeyGeneratorConfigurationCollection) configuration.KeyGenerators.Clone(); - ignoreRules = (IgnoreRuleCollection) configuration.IgnoreRules.Clone(); + databases = configuration.Databases.Clone(); + mappingRules = configuration.MappingRules.Clone(); + keyGenerators = configuration.KeyGenerators.Clone(); + ignoreRules = configuration.IgnoreRules.Clone(); shareStorageSchemaOverNodes = configuration.ShareStorageSchemaOverNodes; - versioningConvention = (VersioningConvention) configuration.VersioningConvention.Clone(); + versioningConvention = configuration.VersioningConvention.Clone(); preferTypeIdsAsQueryParameters = configuration.PreferTypeIdsAsQueryParameters; maxNumberOfConditons = configuration.MaxNumberOfConditions; - extensionConfigurations = (ExtensionConfigurationCollection) configuration.ExtensionConfigurations.Clone(); + extensionConfigurations = configuration.ExtensionConfigurations.Clone(); } /// diff --git a/Orm/Xtensive.Orm/Orm/Configuration/DomainTypeRegistry.cs b/Orm/Xtensive.Orm/Orm/Configuration/DomainTypeRegistry.cs index 803720f5b..5040c9615 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/DomainTypeRegistry.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/DomainTypeRegistry.cs @@ -266,7 +266,7 @@ public static bool IsDbConnectionAccessor(Type type) #region ICloneable members /// - public override object Clone() => new DomainTypeRegistry(this); + public override DomainTypeRegistry Clone() => new DomainTypeRegistry(this); #endregion diff --git a/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs index ec6fee1c6..e90da338b 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs @@ -86,7 +86,7 @@ public override void Lock(bool recursive) #region ICloneable methods /// - public object Clone() + public ExtensionConfigurationCollection Clone() { return new ExtensionConfigurationCollection(this); } diff --git a/Orm/Xtensive.Orm/Orm/Configuration/IgnoreRuleCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/IgnoreRuleCollection.cs index 4d8698921..9fb739731 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/IgnoreRuleCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/IgnoreRuleCollection.cs @@ -51,7 +51,13 @@ public IIgnoreRuleConstructionFlow IgnoreIndex(string indexName) } /// - public object Clone() + object ICloneable.Clone() => Clone(); + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public IgnoreRuleCollection Clone() { var result = new IgnoreRuleCollection(); foreach (var rule in this) diff --git a/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfiguration.cs index e7fb4d1ca..70a20cc13 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfiguration.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov diff --git a/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfigurationCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfigurationCollection.cs index faa0f1234..b1da1dd4a 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfigurationCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfigurationCollection.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -42,7 +42,13 @@ public IKeyGeneratorConfigurationFlow Add() } /// - public object Clone() + object ICloneable.Clone() => Clone(); + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public KeyGeneratorConfigurationCollection Clone() { var result = new KeyGeneratorConfigurationCollection(); foreach (var generator in this) diff --git a/Orm/Xtensive.Orm/Orm/Configuration/LinqExtensionRegistry.cs b/Orm/Xtensive.Orm/Orm/Configuration/LinqExtensionRegistry.cs index 1c4d27c8d..cf8197dca 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/LinqExtensionRegistry.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/LinqExtensionRegistry.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2011 Xtensive LLC. +// Copyright (C) 2011 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -78,10 +78,13 @@ IEnumerator IEnumerable.GetEnumerator() /// Clones this instance. /// /// Clone of this instance. - public object Clone() - { - return new LinqExtensionRegistry(this); - } + object ICloneable.Clone() => Clone(); + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public LinqExtensionRegistry Clone() => new LinqExtensionRegistry(this); // Constructors diff --git a/Orm/Xtensive.Orm/Orm/Configuration/MappingRuleCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/MappingRuleCollection.cs index a347ad783..a9772857f 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/MappingRuleCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/MappingRuleCollection.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -51,7 +51,13 @@ public IMappingRuleConstructionFlow Map(Assembly assembly, string @namespace) } /// - public object Clone() + object ICloneable.Clone() => Clone(); + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public MappingRuleCollection Clone() { var result = new MappingRuleCollection(); foreach (var rule in this) diff --git a/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs index 12569674d..1e245df78 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs @@ -99,10 +99,13 @@ IEnumerator IEnumerable.GetEnumerator() /// Creates clone of this instance. /// /// Clone of this instance. - public object Clone() - { - return new NameMappingCollection(this); - } + object ICloneable.Clone() => Clone(); + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public NameMappingCollection Clone() => new NameMappingCollection(this); /// /// Initializes new instance of this type. diff --git a/Orm/Xtensive.Orm/Orm/Configuration/NamingConvention.cs b/Orm/Xtensive.Orm/Orm/Configuration/NamingConvention.cs index 5a71e0f53..8929073ee 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/NamingConvention.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/NamingConvention.cs @@ -96,14 +96,20 @@ public override void Lock(bool recursive) #region ICloneable members /// - public object Clone() + object ICloneable.Clone() => Clone(); + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public NamingConvention Clone() { - EnsureNotLocked(); - var result = new NamingConvention(); - result.letterCasePolicy = letterCasePolicy; - result.namespacePolicy = namespacePolicy; - result.namingRules = namingRules; - result.namespaceSynonyms = new Dictionary(namespaceSynonyms); + var result = new NamingConvention { + letterCasePolicy = letterCasePolicy, + namespacePolicy = namespacePolicy, + namingRules = namingRules, + namespaceSynonyms = new Dictionary(namespaceSynonyms) + }; return result; } diff --git a/Orm/Xtensive.Orm/Orm/Configuration/NodeConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/NodeConfiguration.cs index e18509b4d..617146e66 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/NodeConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/NodeConfiguration.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2014 Xtensive LLC. +// Copyright (C) 2014 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -98,18 +98,20 @@ public override void Lock(bool recursive) databaseMapping.Lock(); } + object ICloneable.Clone() => Clone(); + /// /// Creates clone of this instance. /// /// Clone of this instance. - public object Clone() + public NodeConfiguration Clone() { var clone = new NodeConfiguration { nodeId = nodeId, connectionInfo = connectionInfo, connectionInitializationSql = connectionInitializationSql, - databaseMapping = (NameMappingCollection) databaseMapping.Clone(), - schemaMapping = (NameMappingCollection) schemaMapping.Clone(), + databaseMapping = databaseMapping.Clone(), + schemaMapping = schemaMapping.Clone(), }; return clone; } diff --git a/Orm/Xtensive.Orm/Orm/Configuration/SessionConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/SessionConfiguration.cs index e593097f5..a191a6bc6 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/SessionConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/SessionConfiguration.cs @@ -272,7 +272,7 @@ protected override void CopyFrom(ConfigurationBase source) /// Clones this configuration. /// /// The clone of this configuration. - public new SessionConfiguration Clone() + public override SessionConfiguration Clone() { return (SessionConfiguration) base.Clone(); } diff --git a/Orm/Xtensive.Orm/Orm/Configuration/SessionConfigurationCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/SessionConfigurationCollection.cs index 42db6d470..b9d22dfc5 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/SessionConfigurationCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/SessionConfigurationCollection.cs @@ -150,7 +150,13 @@ public override void Lock(bool recursive) } /// - public object Clone() + object ICloneable.Clone() => Clone(); + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public SessionConfigurationCollection Clone() { var result = new SessionConfigurationCollection(); foreach (var configuration in this) diff --git a/Orm/Xtensive.Orm/Orm/Configuration/VersioningConvention.cs b/Orm/Xtensive.Orm/Orm/Configuration/VersioningConvention.cs index 6217c87f4..6b4984165 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/VersioningConvention.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/VersioningConvention.cs @@ -45,11 +45,18 @@ public bool DenyEntitySetOwnerVersionChange } /// - public object Clone() + object ICloneable.Clone() => Clone(); + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public VersioningConvention Clone() { - var result = new VersioningConvention(); - result.EntityVersioningPolicy = entityVersioningPolicy; - result.DenyEntitySetOwnerVersionChange = denyEntitySetOwnerVersionChange; + var result = new VersioningConvention { + entityVersioningPolicy = entityVersioningPolicy, + denyEntitySetOwnerVersionChange = denyEntitySetOwnerVersionChange + }; return result; } diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs index 0d6c2bd7d..96ab1c451 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs @@ -34,13 +34,13 @@ protected override Expression Visit(Expression e) return e; } - protected override Expression VisitParameter(ParameterExpression p) + protected override ParameterExpression VisitParameter(ParameterExpression p) { ValidateParameter(p); return p; } - protected override Expression VisitLambda(LambdaExpression l) + protected override LambdaExpression VisitLambda(LambdaExpression l) { var oldParameter = currentParameter; currentParameter = l.Parameters.First(); @@ -49,7 +49,7 @@ protected override Expression VisitLambda(LambdaExpression l) return l; } - protected override Expression VisitMethodCall(MethodCallExpression call) + protected override MethodCallExpression VisitMethodCall(MethodCallExpression call) { // Unpack nested "target.Prefetch(lambda)" call // We will directly map lambda to target to simplify work for NodeBuilder. @@ -80,7 +80,7 @@ protected override Expression VisitMethodCall(MethodCallExpression call) return call; } - protected override Expression VisitMemberAccess(MemberExpression m) + protected override MemberExpression VisitMemberAccess(MemberExpression m) { ValidateMemberAccess(m); result.RegisterChild(m.Expression, m); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ColumnGatherer.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ColumnGatherer.cs index 4516c5a72..53cbd57a6 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ColumnGatherer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ColumnGatherer.cs @@ -70,20 +70,20 @@ public static IEnumerable GetColumns(Expression expression, ColumnExtractio return ordered; } - protected override Expression VisitMarker(MarkerExpression expression) + protected override MarkerExpression VisitMarker(MarkerExpression expression) { Visit(expression.Target); return expression; } - protected override Expression VisitFieldExpression(FieldExpression f) + protected override FieldExpression VisitFieldExpression(FieldExpression f) { ProcessFieldOwner(f); AddColumns(f, f.Mapping.GetItems()); return f; } - protected override Expression VisitStructureFieldExpression(StructureFieldExpression s) + protected override StructureFieldExpression VisitStructureFieldExpression(StructureFieldExpression s) { ProcessFieldOwner(s); AddColumns(s, @@ -93,13 +93,13 @@ protected override Expression VisitStructureFieldExpression(StructureFieldExpres return s; } - protected override Expression VisitKeyExpression(KeyExpression k) + protected override KeyExpression VisitKeyExpression(KeyExpression k) { AddColumns(k, k.Mapping.GetItems()); return k; } - protected override Expression VisitEntityExpression(EntityExpression e) + protected override EntityExpression VisitEntityExpression(EntityExpression e) { if (TreatEntityAsKey) { var keyExpression = (KeyExpression) e.Fields.First(f => f.ExtendedType==ExtendedExpressionType.Key); @@ -110,15 +110,16 @@ protected override Expression VisitEntityExpression(EntityExpression e) else { AddColumns(e, e.Fields - .OfType() - .Where(f => f.ExtendedType==ExtendedExpressionType.Field) + //.OfType() + .Where(static f => f.ExtendedType == ExtendedExpressionType.Field) + .Cast() .Where(f => !(OmitLazyLoad && f.Field.IsLazyLoad)) .Select(f => f.Mapping.Offset)); } return e; } - protected override Expression VisitEntityFieldExpression(EntityFieldExpression ef) + protected override EntityFieldExpression VisitEntityFieldExpression(EntityFieldExpression ef) { var keyExpression = (KeyExpression) ef.Fields.First(f => f.ExtendedType==ExtendedExpressionType.Key); AddColumns(ef, keyExpression.Mapping.GetItems()); @@ -127,19 +128,19 @@ protected override Expression VisitEntityFieldExpression(EntityFieldExpression e return ef; } - protected override Expression VisitEntitySetExpression(EntitySetExpression es) + protected override EntitySetExpression VisitEntitySetExpression(EntitySetExpression es) { VisitEntityExpression((EntityExpression) es.Owner); return es; } - protected override Expression VisitColumnExpression(ColumnExpression c) + protected override ColumnExpression VisitColumnExpression(ColumnExpression c) { AddColumns(c, c.Mapping.GetItems()); return c; } - protected override Expression VisitStructureExpression(StructureExpression expression) + protected override StructureExpression VisitStructureExpression(StructureExpression expression) { AddColumns(expression, expression.Fields @@ -148,14 +149,14 @@ protected override Expression VisitStructureExpression(StructureExpression expre return expression; } - protected override Expression VisitGroupingExpression(GroupingExpression expression) + protected override GroupingExpression VisitGroupingExpression(GroupingExpression expression) { Visit(expression.KeyExpression); VisitSubQueryExpression(expression); return expression; } - protected override Expression VisitSubQueryExpression(SubQueryExpression subQueryExpression) + protected override SubQueryExpression VisitSubQueryExpression(SubQueryExpression subQueryExpression) { bool isTopSubquery = false; @@ -178,7 +179,7 @@ protected override Expression VisitSubQueryExpression(SubQueryExpression subQuer return subQueryExpression; } - protected override Expression VisitLocalCollectionExpression(LocalCollectionExpression expression) + protected override LocalCollectionExpression VisitLocalCollectionExpression(LocalCollectionExpression expression) { foreach (var field in expression.Fields) Visit((Expression) field.Value); @@ -228,7 +229,7 @@ private void AddColumns(ParameterizedExpression parameterizedExpression, IEnumer columns.AddRange(expressionColumns.Select(i=>new Pair(i, parameterizedExpression))); } - protected override Expression VisitFullTextExpression(FullTextExpression expression) + protected override FullTextExpression VisitFullTextExpression(FullTextExpression expression) { VisitEntityExpression(expression.EntityExpression); VisitColumnExpression(expression.RankExpression); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs index a9b281f6d..b2af570ac 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs @@ -30,7 +30,7 @@ protected override Expression Visit(Expression e) return result ?? base.Visit(e); } - protected override Expression VisitProjectionExpression(ProjectionExpression projectionExpression) + protected override ProjectionExpression VisitProjectionExpression(ProjectionExpression projectionExpression) { var item = Visit(projectionExpression.ItemProjector.Item); var provider = providerVisitor.VisitCompilable(projectionExpression.ItemProjector.DataSource); @@ -43,7 +43,7 @@ protected override Expression VisitProjectionExpression(ProjectionExpression pro return projectionExpression; } - protected override Expression VisitGroupingExpression(GroupingExpression expression) + protected override GroupingExpression VisitGroupingExpression(GroupingExpression expression) { var keyExpression = Visit(expression.KeyExpression); if (keyExpression!=expression.KeyExpression) @@ -58,7 +58,7 @@ protected override Expression VisitGroupingExpression(GroupingExpression express return expression; } - protected override Expression VisitFullTextExpression(FullTextExpression expression) + protected override FullTextExpression VisitFullTextExpression(FullTextExpression expression) { var rankExpression = (ColumnExpression) Visit(expression.RankExpression); var entityExpression = (EntityExpression) Visit(expression.EntityExpression); @@ -67,7 +67,7 @@ protected override Expression VisitFullTextExpression(FullTextExpression express return expression; } - protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + protected override SubQueryExpression VisitSubQueryExpression(SubQueryExpression expression) { return expression; } @@ -78,42 +78,42 @@ private Expression TranslateExpression(CompilableProvider provider, Expression o return result ?? original; } - protected override Expression VisitFieldExpression(FieldExpression expression) + protected override FieldExpression VisitFieldExpression(FieldExpression expression) { return expression; } - protected override Expression VisitStructureFieldExpression(StructureFieldExpression expression) + protected override StructureFieldExpression VisitStructureFieldExpression(StructureFieldExpression expression) { return expression; } - protected override Expression VisitKeyExpression(KeyExpression expression) + protected override KeyExpression VisitKeyExpression(KeyExpression expression) { return expression; } - protected override Expression VisitEntityExpression(EntityExpression expression) + protected override EntityExpression VisitEntityExpression(EntityExpression expression) { return expression; } - protected override Expression VisitEntityFieldExpression(EntityFieldExpression expression) + protected override EntityFieldExpression VisitEntityFieldExpression(EntityFieldExpression expression) { return expression; } - protected override Expression VisitEntitySetExpression(EntitySetExpression expression) + protected override EntitySetExpression VisitEntitySetExpression(EntitySetExpression expression) { return expression; } - protected override Expression VisitColumnExpression(ColumnExpression expression) + protected override ColumnExpression VisitColumnExpression(ColumnExpression expression) { return expression; } - protected override Expression VisitConstructorExpression(ConstructorExpression expression) + protected override ConstructorExpression VisitConstructorExpression(ConstructorExpression expression) { var arguments = new List(); var bindings = new Dictionary(expression.Bindings.Count); @@ -147,7 +147,7 @@ protected override Expression VisitConstructorExpression(ConstructorExpression e arguments); } - protected override Expression VisitMarker(MarkerExpression expression) + protected override MarkerExpression VisitMarker(MarkerExpression expression) { var target = Visit(expression.Target); return target == expression.Target diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs index 7aead4010..bb28d0374 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs @@ -51,7 +51,7 @@ public static MappingEntry[] Gather(Expression filterExpression, Expression filt return mapping; } - protected override Expression VisitBinary(BinaryExpression b) + protected override BinaryExpression VisitBinary(BinaryExpression b) { var result = (BinaryExpression) base.VisitBinary(b); var expressions = new[] {result.Left, result.Right}; diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs index 6ec15951c..8265e303b 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs @@ -18,40 +18,40 @@ public static Expression RemoveOwner(Expression target) return remover.Visit(target); } - protected override Expression VisitGroupingExpression(GroupingExpression expression) + protected override GroupingExpression VisitGroupingExpression(GroupingExpression expression) { return expression; } - protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + protected override SubQueryExpression VisitSubQueryExpression(SubQueryExpression expression) { return expression; } - protected override Expression VisitFieldExpression(FieldExpression expression) + protected override FieldExpression VisitFieldExpression(FieldExpression expression) { return expression.RemoveOwner(); } - protected override Expression VisitStructureFieldExpression(StructureFieldExpression expression) + protected override FieldExpression VisitStructureFieldExpression(StructureFieldExpression expression) { return expression.RemoveOwner(); } - protected override Expression VisitKeyExpression(KeyExpression expression) + protected override KeyExpression VisitKeyExpression(KeyExpression expression) { return expression; } - protected override Expression VisitConstructorExpression(ConstructorExpression expression) + protected override ConstructorExpression VisitConstructorExpression(ConstructorExpression expression) { var oldConstructorArguments = expression.ConstructorArguments.ToList().AsReadOnly(); var newConstructorArguments = VisitExpressionList(oldConstructorArguments); - var oldBindings = expression.Bindings.Select(b => b.Value).ToList().AsReadOnly(); + var oldBindings = expression.Bindings.SelectToList(b => b.Value).AsReadOnly(); var newBindings = VisitExpressionList(oldBindings); - var oldNativeBindings = expression.NativeBindings.Select(b => b.Value).ToList().AsReadOnly(); + var oldNativeBindings = expression.NativeBindings.SelectToList(b => b.Value).AsReadOnly(); var newNativeBindings = VisitExpressionList(oldNativeBindings); var notChanged = @@ -71,22 +71,22 @@ protected override Expression VisitConstructorExpression(ConstructorExpression e return new ConstructorExpression(expression.Type, bindings, nativeBingings, expression.Constructor, newConstructorArguments); } - protected override Expression VisitEntityExpression(EntityExpression expression) + protected override EntityExpression VisitEntityExpression(EntityExpression expression) { return expression; } - protected override Expression VisitEntityFieldExpression(EntityFieldExpression expression) + protected override FieldExpression VisitEntityFieldExpression(EntityFieldExpression expression) { return expression.RemoveOwner(); } - protected override Expression VisitEntitySetExpression(EntitySetExpression expression) + protected override EntitySetExpression VisitEntitySetExpression(EntitySetExpression expression) { return expression; } - protected override Expression VisitColumnExpression(ColumnExpression expression) + protected override ColumnExpression VisitColumnExpression(ColumnExpression expression) { return expression; } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs b/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs index 9bd31023d..9b71b8671 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs @@ -283,7 +283,7 @@ protected override Expression VisitConstructorExpression(ConstructorExpression e return expression.NativeBindings.Count == 0 ? newExpression - : (Expression) Expression.MemberInit(newExpression, expression + : Expression.MemberInit(newExpression, expression .NativeBindings .Where(item => Translator.FilterBindings(item.Key, item.Key.Name, item.Value.Type)) .Select(item => Expression.Bind(item.Key, Visit(item.Value))).Cast()); diff --git a/Orm/Xtensive.Orm/Orm/Linq/ParameterExtractor.cs b/Orm/Xtensive.Orm/Orm/Linq/ParameterExtractor.cs index 3e9ff9bcc..409479af9 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/ParameterExtractor.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/ParameterExtractor.cs @@ -33,7 +33,7 @@ protected override Expression VisitMemberAccess(MemberExpression m) protected override Expression VisitUnknown(Expression e) => e; - protected override Expression VisitConstant(ConstantExpression c) + protected override ConstantExpression VisitConstant(ConstantExpression c) { isParameter = c.GetMemberType() switch { MemberType.Entity => true, diff --git a/Orm/Xtensive.Orm/Orm/Linq/Rewriters/SubqueryFilterRemover.cs b/Orm/Xtensive.Orm/Orm/Linq/Rewriters/SubqueryFilterRemover.cs index 53fdc4eb4..71bd822a6 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Rewriters/SubqueryFilterRemover.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Rewriters/SubqueryFilterRemover.cs @@ -31,14 +31,14 @@ public bool Check(Expression expression) return matchFound && @continue && meaningfulLefts.Count==meaningfulRights.Count; } - protected override Expression VisitConstant(ConstantExpression c) + protected override ConstantExpression VisitConstant(ConstantExpression c) { if (c.Value==filterParameter) matchFound = true; return c; } - protected override Expression VisitBinary(BinaryExpression b) + protected override BinaryExpression VisitBinary(BinaryExpression b) { if (b.NodeType==ExpressionType.Equal) { var leftAccess = b.Left.AsTupleAccess(); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs index bab027c3f..3fe9cf903 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs @@ -322,7 +322,7 @@ private ProjectionExpression VisitOfType(Expression source, Type targetType, Typ currentIndex++; } - var recordSet = targetTypeInfo.Indexes.PrimaryIndex.GetQuery().Alias(context.GetNextAlias()).Select(indexes); + CompilableProvider recordSet = targetTypeInfo.Indexes.PrimaryIndex.GetQuery().Alias(context.GetNextAlias()).Select(indexes); var keySegment = visitedSource.ItemProjector.GetColumns(ColumnExtractionModes.TreatEntityAsKey); var keyPairs = keySegment .Select((leftIndex, rightIndex) => new Pair(leftIndex, rightIndex)) diff --git a/Orm/Xtensive.Orm/Orm/Model/Internals/TypePairComparer.cs b/Orm/Xtensive.Orm/Orm/Model/Internals/TypePairComparer.cs index 1dad31984..8d0d9535d 100644 --- a/Orm/Xtensive.Orm/Orm/Model/Internals/TypePairComparer.cs +++ b/Orm/Xtensive.Orm/Orm/Model/Internals/TypePairComparer.cs @@ -50,7 +50,7 @@ public override int GetHashCode(Pair obj) return obj.GetHashCode(); } - protected override IAdvancedComparer> CreateNew(ComparisonRules rules) + protected override TypePairComparer CreateNew(ComparisonRules rules) { return new TypePairComparer(Provider, rules); } diff --git a/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs b/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs index e20a9cfa3..54b6c1654 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs @@ -461,7 +461,7 @@ protected override SqlExpression VisitNew(NewExpression n) return CompileMember(n.Constructor, null, n.Arguments.SelectToArray(a => Visit(a))); } - protected override SqlExpression VisitNewArray(NewArrayExpression expression) + protected override SqlContainer VisitNewArray(NewArrayExpression expression) { if (expression.NodeType!=ExpressionType.NewArrayInit) throw new NotSupportedException(); diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Include.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Include.cs index 7e87b7c90..3f38981f0 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Include.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Include.cs @@ -18,7 +18,7 @@ namespace Xtensive.Orm.Providers public partial class SqlCompiler { /// - protected override SqlProvider VisitInclude(IncludeProvider provider) + protected override SqlIncludeProvider VisitInclude(IncludeProvider provider) { var source = Compile(provider.Source); var resultQuery = ExtractSqlSelect(provider, source); diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.cs index 526be3b8b..d6f08c732 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.cs @@ -388,7 +388,7 @@ protected override SqlProvider VisitSort(SortProvider provider) } /// - protected override SqlProvider VisitStore(StoreProvider provider) + protected override SqlStoreProvider VisitStore(StoreProvider provider) { var source = provider.Source is RawProvider rawProvider ? (ExecutableProvider) (new Rse.Providers.ExecutableRawProvider(rawProvider)) diff --git a/Orm/Xtensive.Orm/Orm/Providers/TemporaryTables/RealTemporaryTableBackEnd.cs b/Orm/Xtensive.Orm/Orm/Providers/TemporaryTables/RealTemporaryTableBackEnd.cs index d96fd67d4..8b821c9cb 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/TemporaryTables/RealTemporaryTableBackEnd.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/TemporaryTables/RealTemporaryTableBackEnd.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -10,7 +10,7 @@ namespace Xtensive.Orm.Providers { public class RealTemporaryTableBackEnd : TemporaryTableBackEnd { - public override Table CreateTemporaryTable(Schema schema, string tableName) + public override TemporaryTable CreateTemporaryTable(Schema schema, string tableName) { return schema.CreateTemporaryTable(tableName); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/AggregateColumn.cs b/Orm/Xtensive.Orm/Orm/Rse/AggregateColumn.cs index 0a3708fba..f1a622624 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/AggregateColumn.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/AggregateColumn.cs @@ -39,13 +39,13 @@ public override string ToString() } /// - public override Column Clone(int newIndex) + public override AggregateColumn Clone(int newIndex) { return new AggregateColumn(this, newIndex); } /// - public override Column Clone(string newName) + public override AggregateColumn Clone(string newName) { return new AggregateColumn(this, newName); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/CalculatedColumn.cs b/Orm/Xtensive.Orm/Orm/Rse/CalculatedColumn.cs index 3c0016062..08d19d322 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/CalculatedColumn.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/CalculatedColumn.cs @@ -35,13 +35,13 @@ public override string ToString() } /// - public override Column Clone(int newIndex) + public override CalculatedColumn Clone(int newIndex) { return new CalculatedColumn(this, newIndex); } /// - public override Column Clone(string newName) + public override CalculatedColumn Clone(string newName) { return new CalculatedColumn(this, newName); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/MappedColumn.cs b/Orm/Xtensive.Orm/Orm/Rse/MappedColumn.cs index 445a5f70b..7cd71fb2e 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/MappedColumn.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/MappedColumn.cs @@ -30,13 +30,13 @@ public override string ToString() } /// - public override Column Clone(int newIndex) + public override MappedColumn Clone(int newIndex) { return new MappedColumn(ColumnInfoRef, Name, newIndex, Type); } /// - public override Column Clone(string newName) + public override MappedColumn Clone(string newName) { return new MappedColumn(this, newName); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/SystemColumn.cs b/Orm/Xtensive.Orm/Orm/Rse/SystemColumn.cs index 95c1a744e..7835222b5 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/SystemColumn.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/SystemColumn.cs @@ -16,13 +16,13 @@ namespace Xtensive.Orm.Rse public class SystemColumn : Column { /// - public override Column Clone(int newIndex) + public override SystemColumn Clone(int newIndex) { return new SystemColumn(this, newIndex); } /// - public override Column Clone(string newName) + public override SystemColumn Clone(string newName) { return new SystemColumn(this, newName); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyProviderCorrectorRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyProviderCorrectorRewriter.cs index f92588217..e22d2f8ba 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyProviderCorrectorRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyProviderCorrectorRewriter.cs @@ -191,7 +191,7 @@ protected override CompilableProvider VisitFilter(FilterProvider provider) return predicateCollector.TryAdd(newProvider) ? source : newProvider; } - protected override CompilableProvider VisitAlias(AliasProvider provider) + protected override AliasProvider VisitAlias(AliasProvider provider) { var source = VisitCompilable(provider.Source); var newProvider = source!=provider.Source ? new AliasProvider(source, provider.Alias) : provider; @@ -254,7 +254,7 @@ protected override ExceptProvider VisitExcept(ExceptProvider provider) : provider; } - protected override CompilableProvider VisitConcat(ConcatProvider provider) + protected override ConcatProvider VisitConcat(ConcatProvider provider) { VisitBinaryProvider(provider, out var left, out var right); return left != provider.Left || right != provider.Right @@ -270,7 +270,7 @@ protected override UnionProvider VisitUnion(UnionProvider provider) : provider; } - protected override CompilableProvider VisitAggregate(AggregateProvider provider) + protected override AggregateProvider VisitAggregate(AggregateProvider provider) { var source = VisitCompilable(provider.Source); var newProvider = provider; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs index 352e2ba58..aebd9f8c0 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs @@ -62,7 +62,7 @@ protected override CompilableProvider VisitSort(SortProvider provider) return source; } - protected override CompilableProvider VisitSelect(SelectProvider provider) + protected override SelectProvider VisitSelect(SelectProvider provider) { var result = provider; var source = VisitCompilable(provider.Source); @@ -93,7 +93,7 @@ protected override CompilableProvider VisitSelect(SelectProvider provider) return result; } - protected override CompilableProvider VisitAggregate(AggregateProvider provider) + protected override AggregateProvider VisitAggregate(AggregateProvider provider) { var result = provider; var source = VisitCompilable(provider.Source); @@ -118,19 +118,19 @@ protected override CompilableProvider VisitAggregate(AggregateProvider provider) return result; } - protected override CompilableProvider VisitIndex(IndexProvider provider) + protected override IndexProvider VisitIndex(IndexProvider provider) { sortOrder = new DirectionCollection(); return provider; } - protected override CompilableProvider VisitFreeText(FreeTextProvider provider) + protected override FreeTextProvider VisitFreeText(FreeTextProvider provider) { sortOrder = new DirectionCollection(); return provider; } - protected override CompilableProvider VisitContainsTable(ContainsTableProvider provider) + protected override ContainsTableProvider VisitContainsTable(ContainsTableProvider provider) { sortOrder = new DirectionCollection(); return provider; @@ -142,7 +142,7 @@ protected override RawProvider VisitRaw(RawProvider provider) return provider; } - protected override CompilableProvider VisitStore(StoreProvider provider) + protected override StoreProvider VisitStore(StoreProvider provider) { sortOrder = new DirectionCollection(); return provider; diff --git a/Orm/Xtensive.Orm/Orm/Session.cs b/Orm/Xtensive.Orm/Orm/Session.cs index 64c73d566..b4273b108 100644 --- a/Orm/Xtensive.Orm/Orm/Session.cs +++ b/Orm/Xtensive.Orm/Orm/Session.cs @@ -576,7 +576,7 @@ internal Session(Domain domain, StorageNode selectedStorageNode, SessionConfigur // Validation context ValidationContext = Configuration.Supports(SessionOptions.ValidateEntities) - ? (ValidationContext) new RealValidationContext() + ? new RealValidationContext() : new VoidValidationContext(); // Creating Services diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs index da8257834..cd1c4b8fb 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs @@ -82,7 +82,7 @@ protected override IPathNode Visit(Orm.Model.Node node) } /// - protected override IPathNode VisitDomainModel(DomainModel domainModel) + protected override StorageModel VisitDomainModel(DomainModel domainModel) { // Build tables, columns and primary indexes foreach (var primaryIndex in domainModel.RealIndexes.Where(i => i.IsPrimary)) @@ -176,7 +176,7 @@ private void VisitIndexInfo(IndexInfo primaryIndex, IndexInfo index) } /// - protected override IPathNode VisitColumnInfo(ColumnInfo column) + protected override StorageColumnInfo VisitColumnInfo(ColumnInfo column) { var nonNullableType = column.ValueType; var nullableType = ToNullable(nonNullableType, column.IsNullable); @@ -236,7 +236,7 @@ protected override IPathNode VisitAssociationInfo(AssociationInfo association) } /// - protected override IPathNode VisitKeyInfo(KeyInfo keyInfo) + protected override StorageSequenceInfo VisitKeyInfo(KeyInfo keyInfo) { if (keyInfo.Sequence==null || !keyInfo.IsFirstAmongSimilarKeys) return null; @@ -260,7 +260,7 @@ protected override IPathNode VisitSequenceInfo(Orm.Model.SequenceInfo info) } /// - protected override IPathNode VisitFullTextIndexInfo(FullTextIndexInfo fullTextIndex) + protected override StorageFullTextIndexInfo VisitFullTextIndexInfo(FullTextIndexInfo fullTextIndex) { if (!providerInfo.Supports(ProviderFeatures.FullText)) { UpgradeLog.Warning(nameof(Strings.LogFullTextIndexesAreNotSupportedByCurrentStorageIgnoringIndexX), fullTextIndex.Name); @@ -293,7 +293,7 @@ protected override IPathNode VisitFullTextIndexInfo(FullTextIndexInfo fullTextIn /// /// The index. /// Visit result. - private IPathNode VisitPrimaryIndexInfo(IndexInfo index) + private PrimaryIndexInfo VisitPrimaryIndexInfo(IndexInfo index) { foreach (var column in index.Columns) Visit(column); diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs index d1858fdfa..6c316682a 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs @@ -83,7 +83,7 @@ protected override IPathNode Visit(Node node) } /// - protected override IPathNode VisitTable(Table table) + protected override TableInfo VisitTable(Table table) { var tableInfo = new TableInfo(targetModel, resolver.GetNodeName(table)); @@ -106,7 +106,7 @@ protected override IPathNode VisitTable(Table table) } /// - protected override IPathNode VisitTableColumn(TableColumn tableColumn) + protected override StorageColumnInfo VisitTableColumn(TableColumn tableColumn) { var tableInfo = currentTable; var typeInfo = ExtractType(tableColumn); @@ -115,7 +115,7 @@ protected override IPathNode VisitTableColumn(TableColumn tableColumn) } /// - protected override IPathNode VisitForeignKey(ForeignKey key) + protected override ForeignKeyInfo VisitForeignKey(ForeignKey key) { var referencingTable = targetModel.Tables[resolver.GetNodeName(key.Owner)]; var referencingColumns = new List(); @@ -138,7 +138,7 @@ protected override IPathNode VisitForeignKey(ForeignKey key) } /// - protected override IPathNode VisitPrimaryKey(PrimaryKey key) + protected override PrimaryIndexInfo VisitPrimaryKey(PrimaryKey key) { var tableInfo = currentTable; var primaryIndexInfo = new PrimaryIndexInfo(tableInfo, key.Name) {IsClustered = key.IsClustered}; @@ -153,7 +153,7 @@ protected override IPathNode VisitPrimaryKey(PrimaryKey key) } /// - protected override IPathNode VisitFullTextIndex(FullTextIndex index) + protected override StorageFullTextIndexInfo VisitFullTextIndex(FullTextIndex index) { var tableInfo = currentTable; var name = index.Name.IsNullOrEmpty() @@ -174,7 +174,7 @@ protected override IPathNode VisitFullTextIndex(FullTextIndex index) } /// - protected override IPathNode VisitIndex(Index index) + protected override SecondaryIndexInfo VisitIndex(Index index) { var tableInfo = currentTable; var secondaryIndexInfo = new SecondaryIndexInfo(tableInfo, index.Name) { @@ -209,7 +209,7 @@ private PartialIndexFilterInfo GetFilter(Index index) } /// - protected override IPathNode VisitSequence(Sequence sequence) + protected override StorageSequenceInfo VisitSequence(Sequence sequence) { var sequenceInfo = new StorageSequenceInfo(targetModel, resolver.GetNodeName(sequence)) { Increment = sequence.SequenceDescriptor.Increment.Value @@ -237,7 +237,7 @@ protected override IPathNode VisitCatalog(Catalog catalog) /// /// The generator table. /// Visit result. - private IPathNode VisitGeneratorTable(Table generatorTable) + private StorageSequenceInfo VisitGeneratorTable(Table generatorTable) { var idColumn = generatorTable.TableColumns[0]; var startValue = idColumn.SequenceDescriptor.StartValue; diff --git a/Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlAlterIdentityInfo.cs b/Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlAlterIdentityInfo.cs index 5c570540b..a7f7db158 100644 --- a/Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlAlterIdentityInfo.cs +++ b/Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlAlterIdentityInfo.cs @@ -16,7 +16,7 @@ public class SqlAlterIdentityInfo : SqlAction internal override SqlAlterIdentityInfo Clone(SqlNodeCloneContext context) => context.GetOrAdd(this, static (t, c) => - new SqlAlterIdentityInfo(t.Column, (SequenceDescriptor) t.SequenceDescriptor.Clone(), t.InfoOption)); + new SqlAlterIdentityInfo(t.Column, t.SequenceDescriptor.Clone(), t.InfoOption)); internal SqlAlterIdentityInfo(TableColumn column, SequenceDescriptor sequenceDescriptor, SqlAlterIdentityInfoOptions infoOption) { diff --git a/Orm/Xtensive.Orm/Sql/Ddl/SqlAlterSequence.cs b/Orm/Xtensive.Orm/Sql/Ddl/SqlAlterSequence.cs index 9c6b74aa7..ce3fc9cd4 100644 --- a/Orm/Xtensive.Orm/Sql/Ddl/SqlAlterSequence.cs +++ b/Orm/Xtensive.Orm/Sql/Ddl/SqlAlterSequence.cs @@ -26,7 +26,7 @@ public SqlAlterIdentityInfoOptions InfoOption internal override SqlAlterSequence Clone(SqlNodeCloneContext context) => context.GetOrAdd(this, static (t, c) => - new SqlAlterSequence(t.sequence, (SequenceDescriptor)t.sequenceDescriptor.Clone(), t.infoOption)); + new SqlAlterSequence(t.sequence, t.sequenceDescriptor.Clone(), t.infoOption)); public override void AcceptVisitor(ISqlVisitor visitor) { diff --git a/Orm/Xtensive.Orm/Sql/Model/SequenceDescriptor.cs b/Orm/Xtensive.Orm/Sql/Model/SequenceDescriptor.cs index 7817a6937..a8479f613 100644 --- a/Orm/Xtensive.Orm/Sql/Model/SequenceDescriptor.cs +++ b/Orm/Xtensive.Orm/Sql/Model/SequenceDescriptor.cs @@ -131,19 +131,23 @@ public bool? IsCyclic } } - + #region IClonable Members + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// A new object that is a copy of this instance. + public SequenceDescriptor Clone() => new SequenceDescriptor(owner, startValue, increment, maxValue, minValue, isCyclic); + /// ///Creates a new object that is a copy of the current instance. /// /// ///A new object that is a copy of this instance. /// - public object Clone() - { - return new SequenceDescriptor(owner, startValue, increment, maxValue, minValue, isCyclic); - } + object ICloneable.Clone() => Clone(); #endregion diff --git a/Orm/Xtensive.Orm/Tuples/DifferentialTuple.cs b/Orm/Xtensive.Orm/Tuples/DifferentialTuple.cs index e221bd07f..7cc9cac8a 100644 --- a/Orm/Xtensive.Orm/Tuples/DifferentialTuple.cs +++ b/Orm/Xtensive.Orm/Tuples/DifferentialTuple.cs @@ -105,7 +105,7 @@ internal void RestoreDifference() internal void BackupDifference() { if (difference != null) - backupedDifference = (DifferentialTuple) this.Clone(); + backupedDifference = this.Clone(); } internal void DropBackedUpDifference() @@ -170,13 +170,13 @@ public override void SetValue(int fieldIndex, object fieldValue) #region CreateNew, Clone, Reset methods /// - public override Tuple CreateNew() + public override DifferentialTuple CreateNew() { return new DifferentialTuple(origin.CreateNew()); } /// - public override Tuple Clone() + public override DifferentialTuple Clone() { return new DifferentialTuple( origin.Clone(), diff --git a/Orm/Xtensive.Orm/Tuples/Packed/PackedTuple.cs b/Orm/Xtensive.Orm/Tuples/Packed/PackedTuple.cs index 22185d43d..3a0d6f8e8 100644 --- a/Orm/Xtensive.Orm/Tuples/Packed/PackedTuple.cs +++ b/Orm/Xtensive.Orm/Tuples/Packed/PackedTuple.cs @@ -20,12 +20,12 @@ public override TupleDescriptor Descriptor get { return PackedDescriptor; } } - public override Tuple Clone() + public override PackedTuple Clone() { return new PackedTuple(this); } - public override Tuple CreateNew() + public override PackedTuple CreateNew() { return new PackedTuple(PackedDescriptor); } From 182622b968a7d852fda75f2cdc8723b0ae3e82bc Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 25 Feb 2026 16:26:02 +0500 Subject: [PATCH 10/55] IPriorityQueue marked obsolete - no implementations --- Orm/Xtensive.Orm/Collections/Interfaces/IPriorityQueue.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Orm/Xtensive.Orm/Collections/Interfaces/IPriorityQueue.cs b/Orm/Xtensive.Orm/Collections/Interfaces/IPriorityQueue.cs index f346f8ca7..84ea144aa 100644 --- a/Orm/Xtensive.Orm/Collections/Interfaces/IPriorityQueue.cs +++ b/Orm/Xtensive.Orm/Collections/Interfaces/IPriorityQueue.cs @@ -16,6 +16,7 @@ namespace Xtensive.Collections /// /// of items to be stored in queue. /// of priority value. + [Obsolete] public interface IPriorityQueue : IEnumerable, ICloneable where TPriority : IComparable From 31a5f2f8991d35e21cb7065f33fc6b533ffb1e2d Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Tue, 24 Feb 2026 12:11:05 +0500 Subject: [PATCH 11/55] Create LeftJoinEx extension to not conflict with .NET10 LeftJoin --- ChangeLog/7.2.1-dev.txt | 2 ++ ...Github0114_QueryRootReuseCauseNoRefJoin.cs | 6 ++-- ...b0171_ReadDateTimeOffsetFromPackedTuple.cs | 4 +-- ...3_IncorrectLeftJoinOnNotNullEntityField.cs | 8 ++--- ...ira0584_IncorrectMappingOfColumnInQuery.cs | 22 ++++++------ ...ssueJira0586_AnonymousTypeComparisonBug.cs | 2 +- ...a0617_IncorrectRemoveOfRedundantColumns.cs | 22 ++++++------ ...JoiningExpressionCausesWrongTranslation.cs | 6 ++-- .../Linq/DynamicallyDefinedFields.cs | 2 +- Orm/Xtensive.Orm.Tests/Linq/InTest.cs | 2 +- Orm/Xtensive.Orm.Tests/Linq/JoinTest.cs | 6 ++-- Orm/Xtensive.Orm.Tests/Linq/TagTest.cs | 4 +-- Orm/Xtensive.Orm/Orm/QueryableExtensions.cs | 35 +++++++++++++++++++ 13 files changed, 79 insertions(+), 42 deletions(-) diff --git a/ChangeLog/7.2.1-dev.txt b/ChangeLog/7.2.1-dev.txt index e69de29bb..cf3f48a14 100644 --- a/ChangeLog/7.2.1-dev.txt +++ b/ChangeLog/7.2.1-dev.txt @@ -0,0 +1,2 @@ +[main] LeftJoin extension marked as Obsolete to prepare movement to .NET 10, LeftJoinEx provided as substitution +[main] IPriorityQueue interface became Obsolete diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0114_QueryRootReuseCauseNoRefJoin.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0114_QueryRootReuseCauseNoRefJoin.cs index 007c8748d..fcb47e498 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0114_QueryRootReuseCauseNoRefJoin.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0114_QueryRootReuseCauseNoRefJoin.cs @@ -2389,7 +2389,7 @@ public void LeftJoinQueryReuse() .Select(promo => new { promo, notifications = session.Query.All() - .LeftJoin(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }) + .LeftJoinEx(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }) }) .Select(anon => new { contacted = anon.notifications.Select(c => c.n.Recipient.User.Id) @@ -2401,9 +2401,9 @@ public void LeftJoinQueryReuse() .Select(promo => new { promo }) .Select(anon => new { contacted = session.Query.All() - .LeftJoin(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }).Select(c => c.n.Recipient.User.Id) + .LeftJoinEx(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }).Select(c => c.n.Recipient.User.Id) .Concat(session.Query.All() - .LeftJoin(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }).Select(c => c.n.Recipient.User.Id)), + .LeftJoinEx(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }).Select(c => c.n.Recipient.User.Id)), promo = anon.promo }).ToArray(); diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0171_ReadDateTimeOffsetFromPackedTuple.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0171_ReadDateTimeOffsetFromPackedTuple.cs index 25c8fc0ae..a3b20892b 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0171_ReadDateTimeOffsetFromPackedTuple.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0171_ReadDateTimeOffsetFromPackedTuple.cs @@ -78,7 +78,7 @@ public void DateTimeOffsetCase() var loadWithCargo = new CargoLoad(session, cargo); var query = session.Query.All() - .LeftJoin(session.Query.All(), + .LeftJoinEx(session.Query.All(), cl => cl.Cargo, c => c, (cl, c) => new { CargoLoad = cl, Cargo = c }) @@ -102,7 +102,7 @@ public void DateTimeCase() var loadWithCargo = new CargoLoad(session, cargo); var query = session.Query.All() - .LeftJoin(session.Query.All(), + .LeftJoinEx(session.Query.All(), cl => cl.Cargo, c => c, (cl, c) => new { CargoLoad = cl, Cargo = c }) diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0553_IncorrectLeftJoinOnNotNullEntityField.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0553_IncorrectLeftJoinOnNotNullEntityField.cs index d57ad764a..d887e1c85 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0553_IncorrectLeftJoinOnNotNullEntityField.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0553_IncorrectLeftJoinOnNotNullEntityField.cs @@ -136,7 +136,7 @@ public void BadWorkTest() using (var session = Domain.OpenSession()) using (var t = session.OpenTransaction()) { var badResult = session.Query.All() - .LeftJoin( + .LeftJoinEx( session.Query.All(), e => e.Id, ewc => ewc.Id, @@ -155,7 +155,7 @@ public void GoodWorkTest() using (var session = Domain.OpenSession()) using (var transaction = session.OpenTransaction()) { var goodResult = session.Query.All() - .LeftJoin( + .LeftJoinEx( session.Query.All(), e => e.Id, ewc => ewc.Id, @@ -173,7 +173,7 @@ public void WorkaroundTest() using (var session = Domain.OpenSession()) using (var transaction = session.OpenTransaction()) { var wordaround = session.Query.All() - .LeftJoin( + .LeftJoinEx( session.Query.All(), e => e.Id, ewc => ewc.Id, @@ -181,7 +181,7 @@ public void WorkaroundTest() e.Id, CarId = ewc.Car.Id }) - .LeftJoin( + .LeftJoinEx( session.Query.All(), e => e.CarId, c => c.Id, diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0584_IncorrectMappingOfColumnInQuery.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0584_IncorrectMappingOfColumnInQuery.cs index 7dd95c703..272fdf6f0 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0584_IncorrectMappingOfColumnInQuery.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0584_IncorrectMappingOfColumnInQuery.cs @@ -526,8 +526,8 @@ public void IncludeProviderOptimizationTest01() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting() { Id = item.Id, @@ -609,8 +609,8 @@ public void IncludeProviderOptimizationTest02() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -692,8 +692,8 @@ public void IncludeProviderOptimizationTest03() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -776,8 +776,8 @@ public void IncludeProviderOptimizationTest04() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -859,8 +859,8 @@ public void IncludeProviderOptimizationTest05() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -1029,7 +1029,7 @@ public void JoinAsSourceOfSetOperation() var result = from r in preResult.Join(tp.Distinct(), a => a.MasterAccount, a => a.Account, (a, pm) => new {pp = a, pm}) - .LeftJoin(Query.All(), a => a.pm.FinToolKind, a => a.Id, (a, b) => new {pp = a.pp, pm = a.pm, fk = b}) + .LeftJoinEx(Query.All(), a => a.pm.FinToolKind, a => a.Id, (a, b) => new {pp = a.pp, pm = a.pm, fk = b}) let q = r.pp select new { diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0586_AnonymousTypeComparisonBug.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0586_AnonymousTypeComparisonBug.cs index d7f82c498..8080bfd0a 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0586_AnonymousTypeComparisonBug.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0586_AnonymousTypeComparisonBug.cs @@ -108,7 +108,7 @@ public void MainTest() var masterCredit = Query.All(); - var join = from r in masterCredit.LeftJoin( + var join = from r in masterCredit.LeftJoinEx( tableParts, a => a.CreditAccount.Id, a => a.Account.Id, diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0617_IncorrectRemoveOfRedundantColumns.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0617_IncorrectRemoveOfRedundantColumns.cs index 399c2443a..a2b9c6687 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0617_IncorrectRemoveOfRedundantColumns.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0617_IncorrectRemoveOfRedundantColumns.cs @@ -68,8 +68,8 @@ public void Test01() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting() { Id = item.Id, @@ -149,8 +149,8 @@ public void Test02() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -230,8 +230,8 @@ public void Test03() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -312,8 +312,8 @@ public void Test04() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -393,8 +393,8 @@ public void Test05() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -562,7 +562,7 @@ public void Test08() var result = from r in preResult.Join(tp.Distinct(), a => a.MasterAccount, a => a.Account, (a, pm) => new {pp = a, pm}) - .LeftJoin(Query.All(), a => a.pm.FinToolKind, a => a.Id, (a, b) => new {pp = a.pp, pm = a.pm, fk = b}) + .LeftJoinEx(Query.All(), a => a.pm.FinToolKind, a => a.Id, (a, b) => new {pp = a.pp, pm = a.pm, fk = b}) let q = r.pp select new { diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0803_ReuseOfJoiningExpressionCausesWrongTranslation.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0803_ReuseOfJoiningExpressionCausesWrongTranslation.cs index 08b2cc6c4..0aaaa34e7 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0803_ReuseOfJoiningExpressionCausesWrongTranslation.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0803_ReuseOfJoiningExpressionCausesWrongTranslation.cs @@ -66,7 +66,7 @@ public void LeftJoinOneVariableUsage() using (var tx = session.OpenTransaction()) { var leftJoinWithExpression = session.Query.All() - .LeftJoin(session.Query.All().Where(it => it.Description == null), + .LeftJoinEx(session.Query.All().Where(it => it.Description == null), o => o.Id, key, (o, i) => o) @@ -78,7 +78,7 @@ public void LeftJoinOneVariableUsage() Assert.AreEqual(3, leftJoinWithExpression.Count); leftJoinWithExpression = session.Query.All() - .LeftJoin(session.Query.All().Where(it => it.Description == null), + .LeftJoinEx(session.Query.All().Where(it => it.Description == null), key, i => i.Id, (o, i) => o) @@ -101,7 +101,7 @@ public void LeftJoinTwoVariableUsage() var ex = Assert.Throws(() => _ = session.Query.All() - .LeftJoin(session.Query.All().Where(it => it.Description == null), + .LeftJoinEx(session.Query.All().Where(it => it.Description == null), key, key, (o, i) => o) diff --git a/Orm/Xtensive.Orm.Tests/Linq/DynamicallyDefinedFields.cs b/Orm/Xtensive.Orm.Tests/Linq/DynamicallyDefinedFields.cs index 275e7429b..2c91b9afd 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/DynamicallyDefinedFields.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/DynamicallyDefinedFields.cs @@ -1265,7 +1265,7 @@ public void LeftJoinTest() using (session.Activate()) using (var transction = session.OpenTransaction()) { Assert.DoesNotThrow(() => { - session.Query.All().LeftJoin(session.Query.All(), area => (Group)area[testData.GroupFieldName], + session.Query.All().LeftJoinEx(session.Query.All(), area => (Group)area[testData.GroupFieldName], group => group, (area, @group) => new { Area = area, Group = group }); }); } diff --git a/Orm/Xtensive.Orm.Tests/Linq/InTest.cs b/Orm/Xtensive.Orm.Tests/Linq/InTest.cs index 05a57056c..83fed9a22 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/InTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/InTest.cs @@ -76,7 +76,7 @@ public async Task StringContainsAsyncTest() public void MartinTest() { _ = Session.Query.All() - .LeftJoin(Session.Query.All(), c => c, i => i.Customer, (c, i) => new { Customer = c, Invoice = i }) + .LeftJoinEx(Session.Query.All(), c => c, i => i.Customer, (c, i) => new { Customer = c, Invoice = i }) .GroupBy(i => new { i.Customer.FirstName, i.Customer.LastName }) .Select(g => new { Key = g.Key, Count = g.Count(j => j.Invoice != null) }) .ToList(); diff --git a/Orm/Xtensive.Orm.Tests/Linq/JoinTest.cs b/Orm/Xtensive.Orm.Tests/Linq/JoinTest.cs index dd60c3db2..649d25a25 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/JoinTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/JoinTest.cs @@ -143,7 +143,7 @@ public void SimpleLeftTest() { var traclCount = Session.Query.All().Count(); var result = Session.Query.All() - .LeftJoin(Session.Query.All(), + .LeftJoinEx(Session.Query.All(), track => track.Album.AlbumId, album => album.AlbumId, (track, album) => new {track.Name, album.Title, album.AlbumId}); @@ -159,7 +159,7 @@ public void LeftJoin1Test() Session.Current.SaveChanges(); var tracks = Session.Query.All(); var albums = Session.Query.All(); - var result = tracks.LeftJoin( + var result = tracks.LeftJoinEx( albums, track => track.Album, album => album, @@ -179,7 +179,7 @@ public void LeftJoin2Test() Session.Current.SaveChanges(); var tracks = Session.Query.All(); var albums = Session.Query.All(); - var result = tracks.LeftJoin( + var result = tracks.LeftJoinEx( albums, track => track.Album.AlbumId, album => album.AlbumId, diff --git a/Orm/Xtensive.Orm.Tests/Linq/TagTest.cs b/Orm/Xtensive.Orm.Tests/Linq/TagTest.cs index 54c80bd4c..c7f23e550 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/TagTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/TagTest.cs @@ -256,7 +256,7 @@ public void TagInJoin() var inner = session.Query.All().Tag("inner"); var outer = session.Query.All().Tag("outer"); - var query = outer.LeftJoin(inner, o => o.Owner.Id, i => i.Id, (i, o) => new { i, o }); + var query = outer.LeftJoinEx(inner, o => o.Owner.Id, i => i.Id, (i, o) => new { i, o }); var queryFormatter = session.Services.Demand(); var queryString = queryFormatter.ToSqlString(query); @@ -514,7 +514,7 @@ public void TagInGrouping() .Tag("AfterSelect") .Where(g => g.Items.Count() >= 0) .Tag("AfterWhere") - .LeftJoin(session.Query.All().Tag("WithinJoin"), g => g.Key, bu => bu.Id, (g, bu) => new { Key = bu, Items = g.Items }); + .LeftJoinEx(session.Query.All().Tag("WithinJoin"), g => g.Key, bu => bu.Id, (g, bu) => new { Key = bu, Items = g.Items }); using (var tagScope = session.Tag("sessionTag6")) { session.Events.DbCommandExecuting += SqlCapturer; diff --git a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs index 250ff8372..40d26b3d0 100644 --- a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs @@ -272,6 +272,7 @@ public static bool In(this T source, IncludeAlgorithm algorithm, IEnumerable< /// /// One of provided arguments is . /// Queryable is not a query. + [Obsolete(".NET 10 has its own LeftJoin method declared, which will conflict with this. Use LeftJoinEx to prepare your code for future .NET change")] public static IQueryable LeftJoin(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { ArgumentValidator.EnsureArgumentNotNull(outer, nameof(outer)); @@ -291,6 +292,40 @@ public static IQueryable LeftJoin(this I return outer.Provider.CreateQuery(expression); } + /// + /// Correlates the elements of two sequences based on matching keys. + /// + /// The type of the elements of the first sequence. + /// The type of the elements of the second sequence. + /// The type of the keys returned by the key selector functions. + /// The type of the result elements. + /// The first sequence to join. + /// The sequence to join to the first sequence. + /// A function to extract the join key from each element of the first sequence. + /// A function to extract the join key from each element of the second sequence. + /// A function to create a result element from two matching elements. + /// + /// One of provided arguments is . + /// Queryable is not a query. + public static IQueryable LeftJoinEx(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) + { + ArgumentValidator.EnsureArgumentNotNull(outer, nameof(outer)); + ArgumentValidator.EnsureArgumentNotNull(inner, nameof(inner)); + ArgumentValidator.EnsureArgumentNotNull(outerKeySelector, nameof(outerKeySelector)); + ArgumentValidator.EnsureArgumentNotNull(innerKeySelector, nameof(innerKeySelector)); + ArgumentValidator.EnsureArgumentNotNull(resultSelector, nameof(resultSelector)); + + var outerProviderType = outer.Provider.GetType(); + if (outerProviderType != WellKnownOrmTypes.QueryProvider) { + var errorMessage = Strings.ExLeftJoinDoesNotSupportQueryProviderOfTypeX; + throw new NotSupportedException(string.Format(errorMessage, outerProviderType)); + } + + var genericMethod = WellKnownMembers.Queryable.ExtensionLeftJoin.MakeGenericMethod(new[] { typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult) }); + var expression = Expression.Call(null, genericMethod, new[] { outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector }); + return outer.Provider.CreateQuery(expression); + } + /// /// Runs query to database asynchronously and returns completed task for other . /// From a1d442719e3d291537e2290ea3d490829d829bf9 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 25 Feb 2026 16:25:27 +0500 Subject: [PATCH 12/55] Segment comparison/equality fixed --- Orm/Xtensive.Orm/Core/Segment.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Orm/Xtensive.Orm/Core/Segment.cs b/Orm/Xtensive.Orm/Core/Segment.cs index a04902dcd..b2e976f25 100644 --- a/Orm/Xtensive.Orm/Core/Segment.cs +++ b/Orm/Xtensive.Orm/Core/Segment.cs @@ -44,26 +44,26 @@ public T EndOffset { } /// - public bool Equals(Pair other) + public bool Equals(Segment other) { - return AdvancedComparerStruct.System.Equals(Offset, other.First) && - AdvancedComparerStruct.System.Equals(Length, other.Second); + return AdvancedComparerStruct.System.Equals(Offset, other.Offset) && + AdvancedComparerStruct.System.Equals(Length, other.Length); } /// - public int CompareTo(Pair other) + public int CompareTo(Segment other) { - int result = AdvancedComparerStruct.System.Compare(Offset, other.First); + int result = AdvancedComparerStruct.System.Compare(Offset, other.Offset); if (result!=0) return result; - return AdvancedComparerStruct.System.Compare(Length, other.Second); + return AdvancedComparerStruct.System.Compare(Length, other.Length); } #region Equals, GetHashCode /// public override bool Equals(object obj) => - obj is Pair other && Equals(other); + obj is Segment other && Equals(other); /// public override int GetHashCode() From 49f3280db4b2c8948d43e8d96f4bb6fb1c65b545 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 25 Feb 2026 17:17:15 +0500 Subject: [PATCH 13/55] Collections usage improvements --- Orm/Xtensive.Orm/Collections/Deque.cs | 2 +- Orm/Xtensive.Orm/Linq/ConstantExtractor.cs | 2 +- ...essionToSerializableExpressionConverter.cs | 74 +++++++++---------- ...alizableExpressionToExpressionConverter.cs | 3 +- .../Orm/Building/FixupActionProcessor.cs | 6 +- .../Orm/Building/PrefetchActionContainer.cs | 2 +- .../Linq/Expressions/ConstructorExpression.cs | 8 +- .../MemberCompilerProvider.cs | 11 ++- .../Orm/Upgrade/Internals/CatalogCloner.cs | 14 ++-- .../Upgrade/Internals/DomainModelConverter.cs | 41 +++++----- .../Orm/Upgrade/Internals/SchemaComparer.cs | 2 +- .../Orm/Upgrade/Model/PrimaryIndexInfo.cs | 12 +-- .../Orm/Upgrade/Model/SecondaryIndexInfo.cs | 4 +- .../Upgrade/Model/StorageFullTextIndexInfo.cs | 3 +- .../Orm/Upgrade/SystemUpgradeHandler.cs | 8 +- .../Orm/Upgrade/UpgradingDomainBuilder.cs | 11 ++- Orm/Xtensive.Orm/Reflection/MethodHelper.cs | 2 +- .../Collections/SqlInsertValuesCollection.cs | 2 +- .../Sql/Dml/Expressions/SqlArray{T}.cs | 4 +- .../Dml/Expressions/SqlUserFunctionCall.cs | 2 +- .../Sql/Dml/Hints/SqlForceJoinOrderHint.cs | 2 +- Orm/Xtensive.Orm/Sql/Model/Domain.cs | 13 +--- Orm/Xtensive.Orm/Sql/Model/Table.cs | 10 +-- Orm/Xtensive.Orm/Sql/Model/View.cs | 6 +- Orm/Xtensive.Orm/Sql/SqlDml.cs | 4 +- 25 files changed, 121 insertions(+), 127 deletions(-) diff --git a/Orm/Xtensive.Orm/Collections/Deque.cs b/Orm/Xtensive.Orm/Collections/Deque.cs index 2de039b41..6b8a4f2ba 100644 --- a/Orm/Xtensive.Orm/Collections/Deque.cs +++ b/Orm/Xtensive.Orm/Collections/Deque.cs @@ -610,7 +610,7 @@ public Deque(int initialCapacity, float growFactor) /// The initial contents of the . public Deque(IEnumerable source) { - items = new List(source).ToArray(); + items = source.ToArray(); headPos = -1; tailPos = items.Length; count = items.Length; diff --git a/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs b/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs index 732d97268..95e29d2bf 100644 --- a/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs +++ b/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs @@ -49,7 +49,7 @@ public LambdaExpression Process() if (constantValues != null) throw new InvalidOperationException(); constantValues = new List(); - var parameters = EnumerableUtils.One(ConstantParameter).Concat(lambda.Parameters).ToArray(); + var parameters = EnumerableUtils.One(ConstantParameter).Concat(lambda.Parameters).ToArray(lambda.Parameters.Count + 1); var body = Visit(lambda.Body); // Preserve original delegate type because it may differ from types of parameters / return value return FastExpression.Lambda(FixDelegateType(lambda.Type), body, parameters); diff --git a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ExpressionToSerializableExpressionConverter.cs b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ExpressionToSerializableExpressionConverter.cs index df87b52d0..fa2bf0b2e 100644 --- a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ExpressionToSerializableExpressionConverter.cs +++ b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ExpressionToSerializableExpressionConverter.cs @@ -192,56 +192,48 @@ protected override SerializableInvocationExpression VisitInvocation(InvocationEx #region Private / internal methods - private SerializableMemberBinding[] VisitMemberBindingSequence(IEnumerable bindings) - { - var result = new List(); - foreach (var binding in bindings) - switch (binding.BindingType) { - case MemberBindingType.Assignment: - result.Add(new SerializableMemberAssignment - { - BindingType = MemberBindingType.Assignment, - Member = binding.Member, - Expression = Visit(((MemberAssignment) binding).Expression) - }); - break; - case MemberBindingType.ListBinding: - result.Add(new SerializableMemberListBinding - { - BindingType = MemberBindingType.ListBinding, - Member = binding.Member, - Initializers = VisitElementInitSequence(((MemberListBinding) binding).Initializers) - }); - break; - case MemberBindingType.MemberBinding: - result.Add(new SerializableMemberMemberBinding - { - BindingType = MemberBindingType.MemberBinding, - Member = binding.Member, - Bindings = VisitMemberBindingSequence(((MemberMemberBinding) binding).Bindings) - }); - break; - default: - throw new ArgumentOutOfRangeException(); - } - return result.ToArray(); - } - - private SerializableElementInit[] VisitElementInitSequence(IEnumerable initializers) + private SerializableMemberBinding[] VisitMemberBindingSequence(IReadOnlyList bindings) + { + var arrayResult = new SerializableMemberBinding[bindings.Count]; + for (int i = 0, count = bindings.Count; i < count; i++) { + var binding = bindings[i]; + arrayResult[i] = binding.BindingType switch { + MemberBindingType.Assignment => new SerializableMemberAssignment() { + BindingType = MemberBindingType.Assignment, + Member = binding.Member, + Expression = Visit(((MemberAssignment) binding).Expression) + }, + MemberBindingType.ListBinding => new SerializableMemberListBinding { + BindingType = MemberBindingType.ListBinding, + Member = binding.Member, + Initializers = VisitElementInitSequence(((MemberListBinding) binding).Initializers) + }, + MemberBindingType.MemberBinding => new SerializableMemberMemberBinding { + BindingType = MemberBindingType.MemberBinding, + Member = binding.Member, + Bindings = VisitMemberBindingSequence(((MemberMemberBinding) binding).Bindings) + }, + _ => throw new ArgumentOutOfRangeException() + + }; + } + return arrayResult; + } + + private SerializableElementInit[] VisitElementInitSequence(IList initializers) { return initializers - .Select(initializer => new SerializableElementInit + .SelectToArray(initializer => new SerializableElementInit { AddMethod = initializer.AddMethod, Arguments = VisitExpressionSequence(initializer.Arguments) - }) - .ToArray(); + }); } - private SerializableExpression[] VisitExpressionSequence(IEnumerable expressions) + private SerializableExpression[] VisitExpressionSequence(IList expressions) where T : Expression { - return expressions.Select(e => Visit(e)).ToArray(); + return expressions.SelectToArray(e => Visit(e)); } #endregion diff --git a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/SerializableExpressionToExpressionConverter.cs b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/SerializableExpressionToExpressionConverter.cs index 78ee7b4d8..8ca36d21e 100644 --- a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/SerializableExpressionToExpressionConverter.cs +++ b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/SerializableExpressionToExpressionConverter.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; +using Xtensive.Core; namespace Xtensive.Linq.SerializableExpressions.Internals { @@ -177,7 +178,7 @@ private Expression VisitMethodCall(SerializableMethodCallExpression mc) private Expression VisitLambda(SerializableLambdaExpression l) { - var parameters = l.Parameters.Select(p => (ParameterExpression) Visit(p)).ToList(); + var parameters = l.Parameters.SelectToArray(p => (ParameterExpression) Visit(p)); using (CreateParameterScope(parameters)) { return FastExpression.Lambda(l.Type, Visit(l.Body), parameters); } diff --git a/Orm/Xtensive.Orm/Orm/Building/FixupActionProcessor.cs b/Orm/Xtensive.Orm/Orm/Building/FixupActionProcessor.cs index 9de81fbf6..d8ebaa0a8 100644 --- a/Orm/Xtensive.Orm/Orm/Building/FixupActionProcessor.cs +++ b/Orm/Xtensive.Orm/Orm/Building/FixupActionProcessor.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Xtensive.Core; using Xtensive.Orm.Building.Builders; using Xtensive.Orm.Building.Definitions; using Xtensive.Orm.Building.DependencyGraph; @@ -92,9 +93,8 @@ public void Process(BuildGenericTypeInstancesAction action) var typeSubstitutions = new Type[arguments.Length][]; for (var i = 0; i < arguments.Length; i++) { var argument = arguments[i]; - var constraints = argument.GetGenericParameterConstraints() - .ToList(); - if (constraints.Count==0 || !constraints.Any(c => WellKnownOrmInterfaces.Entity.IsAssignableFrom(c))) + var constraints = argument.GetGenericParameterConstraints(); + if (constraints.Length==0 || !constraints.Any(c => WellKnownOrmInterfaces.Entity.IsAssignableFrom(c))) return; // No IEntity / Entity constraints var queue = new Queue( from hierarchy in hierarchies diff --git a/Orm/Xtensive.Orm/Orm/Building/PrefetchActionContainer.cs b/Orm/Xtensive.Orm/Orm/Building/PrefetchActionContainer.cs index cd69a075d..324b31a94 100644 --- a/Orm/Xtensive.Orm/Orm/Building/PrefetchActionContainer.cs +++ b/Orm/Xtensive.Orm/Orm/Building/PrefetchActionContainer.cs @@ -25,7 +25,7 @@ internal sealed class PrefetchActionContainer public Action> BuildPrefetchAction(IEnumerable associations) { fields = associations.Select(static association => new PrefetchFieldDescriptor(association.OwnerField, true, false)) - .ToList(); + .ToArray(); return fields.Count > 0 ? Prefetch : null; } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs index 3b199e6ae..8c3c08637 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs @@ -35,10 +35,10 @@ public Expression BindParameter(ParameterExpression parameter, Dictionary GenericExpressionVisitor.Process(e, mapped => mapped.BindParameter(parameter, processedExpressions)); return new ConstructorExpression( Type, - Bindings.ToDictionary(kvp => kvp.Key, kvp => genericBinder(kvp.Value)), - NativeBindings.ToDictionary(kvp=>kvp.Key, kvp => genericBinder(kvp.Value)), + Bindings.ToDictionary(kvp => kvp.Key, kvp => genericBinder(kvp.Value), Bindings.Count), + NativeBindings.ToDictionary(kvp=>kvp.Key, kvp => genericBinder(kvp.Value), NativeBindings.Count), Constructor, - ConstructorArguments.Select(genericBinder).ToList()); + ConstructorArguments.Select(genericBinder).ToArray()); } public Expression RemoveOuterParameter(Dictionary processedExpressions) @@ -50,7 +50,7 @@ public Expression RemoveOuterParameter(Dictionary proces Bindings.ToDictionary(kvp => kvp.Key, kvp => genericRemover(kvp.Value)), NativeBindings = NativeBindings.ToDictionary(kvp => kvp.Key, kvp => genericRemover(kvp.Value)), Constructor, - ConstructorArguments.Select(genericRemover).ToList()); + ConstructorArguments.Select(genericRemover).ToArray()); return result; } diff --git a/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs b/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs index 11aa2e1ad..4928eed95 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs @@ -174,7 +174,7 @@ private static (MemberInfo targetMember, Delegate compilerInvoker) ProcessCompil bool isGenericMethod = attribute.NumberOfGenericArguments > 0; bool isGenericType = targetType.IsGenericType; bool isGeneric = isGenericType || isGenericMethod; - + string memberName = attribute.TargetMember; if (memberName.IsNullOrEmpty()) @@ -191,18 +191,21 @@ private static (MemberInfo targetMember, Delegate compilerInvoker) ProcessCompil if (isCtor) bindingFlags |= BindingFlags.Instance; - else + else { if (!isStatic) { - if (parameterTypes.Length==0) + if (parameterTypes.Length == 0) throw new InvalidOperationException(string.Format( Strings.ExCompilerXShouldHaveThisParameter, compiler.GetFullName(true))); - parameterTypes = parameterTypes.Skip(1).ToArray(); + var noInstanceParameter = new Type[parameterTypes.Length - 1]; + Array.Copy(parameterTypes, 1, noInstanceParameter, 0, noInstanceParameter.Length); + parameterTypes = noInstanceParameter; bindingFlags |= BindingFlags.Instance; } else bindingFlags |= BindingFlags.Static; + } if (isPropertyGetter) { bindingFlags |= BindingFlags.GetProperty; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs index d59ef708b..b9f4c2cc1 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs @@ -31,7 +31,7 @@ public Catalog Clone(Catalog source, MappingResolver mappingResolver, string new private Dictionary CloneSchemas(Catalog newCatalog, Catalog sourceCatalog, MappingResolver mappingResolver) { - var schemaMap = new Dictionary(); + var schemaMap = new Dictionary(sourceCatalog.Schemas.Count); foreach (var schema in sourceCatalog.Schemas) { var complexName = mappingResolver.GetNodeName(newCatalog.Name, schema.Name, "Dummy"); var names = complexName.Split(NameElementSeparator); @@ -336,16 +336,14 @@ private void CloneTableConstraint(Table newTable, TableConstraint sourceConstrai return; } - var uniqueConstraint = sourceConstraint as UniqueConstraint; - if (uniqueConstraint!=null) { - var primaryKey = sourceConstraint as PrimaryKey; - if (primaryKey!=null) { - var columns = primaryKey.Columns.Select(c => newTable.TableColumns[c.Name]).ToArray(); - var pk =newTable.CreatePrimaryKey(primaryKey.Name, columns); + if (sourceConstraint is UniqueConstraint uniqueConstraint) { + if (sourceConstraint is PrimaryKey primaryKey) { + var columns = primaryKey.Columns.SelectToArray(c => newTable.TableColumns[c.Name]); + var pk = newTable.CreatePrimaryKey(primaryKey.Name, columns); CopyDbName(pk, primaryKey); } else { - var columns = uniqueConstraint.Columns.Select(c => newTable.TableColumns[c.Name]).ToArray(); + var columns = uniqueConstraint.Columns.SelectToArray(c => newTable.TableColumns[c.Name]); var uc = newTable.CreateUniqueConstraint(uniqueConstraint.Name, columns); CopyDbName(uc, uniqueConstraint); } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs index cd1c4b8fb..a280e1db7 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs @@ -113,17 +113,17 @@ protected override StorageModel VisitDomainModel(DomainModel domainModel) // Build hierarchy foreign keys var indexPairs = new Dictionary, object>(); foreach (var type in domainModel.Types.Entities) { - if (type.Hierarchy==null || type.Hierarchy.InheritanceSchema==InheritanceSchema.ConcreteTable) + if (type.Hierarchy is null || type.Hierarchy.InheritanceSchema==InheritanceSchema.ConcreteTable) continue; if (type.Indexes.PrimaryIndex.IsVirtual) { - Dictionary typeOrder = type.Ancestors + var typeOrder = type.Ancestors .Append(type) - .Select((t, i) => (Type: t, Index: i)) - .ToDictionary(a => a.Type, a => a.Index); - List realPrimaryIndexes = type.Indexes.RealPrimaryIndexes + .Select(static (t, i) => (Type: t, Index: i)) + .ToDictionary(static a => a.Type, static a => a.Index, capacity: type.Ancestors.Count); + var realPrimaryIndexes = type.Indexes.RealPrimaryIndexes .OrderBy(index => typeOrder[index.ReflectedType]) - .ToList(); - for (int i = 0; i < realPrimaryIndexes.Count - 1; i++) { + .ToArray(type.Indexes.RealPrimaryIndexes.Count); + for (int i = 0, edge = realPrimaryIndexes.Length - 1; i < edge; i++) { if (realPrimaryIndexes[i]!=realPrimaryIndexes[i + 1]) { var pair = new Pair(realPrimaryIndexes[i], realPrimaryIndexes[i + 1]); indexPairs[pair] = null; @@ -137,7 +137,7 @@ protected override StorageModel VisitDomainModel(DomainModel domainModel) var referencingTable = targetModel.Tables[resolver.GetNodeName(referencingIndex.ReflectedType)]; var referencedTable = targetModel.Tables[resolver.GetNodeName(referencedIndex.ReflectedType)]; var storageReferencingIndex = FindIndex( - referencingTable, referencingIndex.KeyColumns.Select(ci => ci.Key.Name).ToList()); + referencingTable, referencingIndex.KeyColumns.Select(static ci => ci.Key.Name).ToArray()); string foreignKeyName = nameBuilder.BuildHierarchyForeignKeyName(referencingIndex.ReflectedType, referencedIndex.ReflectedType); CreateHierarchyForeignKey(referencingTable, referencedTable, storageReferencingIndex, foreignKeyName); @@ -320,19 +320,19 @@ private PrimaryIndexInfo VisitPrimaryIndexInfo(IndexInfo index) return primaryIndex; } - private IEnumerable CreateTables(IndexInfo index) + private IReadOnlyList CreateTables(IndexInfo index) { - var result = new List(); var type = index.ReflectedType; - if (configuration.IsMultidatabase && type.UnderlyingType.Namespace==MetadataNamespace) { + if (configuration.IsMultidatabase && type.UnderlyingType.Namespace == MetadataNamespace) { + var parts = new List(sourceModel.Databases.Count); foreach (var db in sourceModel.Databases) { var name = resolver.GetNodeName(db.Name, type.MappingSchema, type.MappingName); - result.Add(new TableInfo(targetModel, name)); + parts.Add(new TableInfo(targetModel, name)); } + return parts; } else - result.Add(new TableInfo(targetModel, resolver.GetNodeName(type))); - return result; + return new[] { new TableInfo(targetModel, resolver.GetNodeName(type)) }; } #region Not supported @@ -401,17 +401,24 @@ private string GetColumnDefaultSqlExpression(ColumnInfo column) private static StorageIndexInfo FindIndex(TableInfo table, ICollection keyColumns) { - var primaryKeyColumns = table.PrimaryIndex.KeyColumns.Select(cr => cr.Value.Name).ToList(); + var primaryIndex = table.PrimaryIndex; + var primaryKeyColumns = primaryIndex.KeyColumns.Select(ColumnNameSelector).ToList(primaryIndex.KeyColumns.Count); if (!primaryKeyColumns.Except(keyColumns).Union(keyColumns.Except(primaryKeyColumns)).Any()) return table.PrimaryIndex; foreach (SecondaryIndexInfo index in table.SecondaryIndexes) { - var secondaryKeyColumns = index.KeyColumns.Select(cr => cr.Value.Name).ToList(); + var secondaryKeyColumns = index.KeyColumns.Select(ColumnNameSelector).ToList(index.KeyColumns.Count); if (!secondaryKeyColumns.Except(keyColumns).Union(keyColumns.Except(secondaryKeyColumns)).Any()) return index; } return null; + + + static string ColumnNameSelector(KeyColumnRef cr) + { + return cr.Value.Name; + } } private TableInfo GetTable(TypeInfo type) @@ -440,7 +447,7 @@ private static string GetPrimaryIndexColumnName(IndexInfo primaryIndex, ColumnIn private static void CreateReferenceForeignKey(TableInfo referencingTable, TableInfo referencedTable, FieldInfo referencingField, string foreignKeyName) { - var foreignColumns = referencingField.Columns.Select(column => referencingTable.Columns[column.Name]).ToList(); + var foreignColumns = referencingField.Columns.SelectToArray(column => referencingTable.Columns[column.Name]); var foreignKey = new ForeignKeyInfo(referencingTable, foreignKeyName) { PrimaryKey = referencedTable.PrimaryIndex, OnRemoveAction = ReferentialAction.None, diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SchemaComparer.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SchemaComparer.cs index d992ef9fb..df24b00cc 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SchemaComparer.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SchemaComparer.cs @@ -103,7 +103,7 @@ public static SchemaComparisonResult Compare( createTableActions.Cast() .Concat(createColumnActions.Cast()) .Concat(columnTypeChangeActions.Cast()) - .ToList(); + .ToArray(createTableActions.Count + createColumnActions.Count + columnTypeChangeActions.Count); return new SchemaComparisonResult( comparisonStatus, columnTypeChangeActions.Count > 0, isCompatibleInLegacyMode, diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs index b9b01a627..0e84154af 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs @@ -45,11 +45,9 @@ protected override void ValidateState() base.ValidateState(); var tableColumns = Parent.Columns; - var keys = KeyColumns.Select(keyRef => keyRef.Value).ToList(); - var values = ValueColumns.Select(valueRef => valueRef.Value).ToList(); - var all = keys.Concat(values).ToList(); + var keys = KeyColumns.Select(keyRef => keyRef.Value).ToArray(KeyColumns.Count); - if (keys.Count==0) + if (keys.Length==0) ea.Execute(() => { throw new ValidationException(Strings.ExEmptyKeyColumnsCollection, Path); }); @@ -58,11 +56,13 @@ protected override void ValidateState() throw new ValidationException(Strings.ExPrimaryKeyColumnCanNotBeNullable, Path); }); - if (all.Count!=tableColumns.Count) + var values = ValueColumns.Select(valueRef => valueRef.Value).ToArray(KeyColumns.Count); + var allCount = keys.Length + values.Length; + if (allCount!=tableColumns.Count) ea.Execute(() => { throw new ValidationException(Strings.ExInvalidPrimaryKeyStructure, Path); }); - if (all.Zip(tableColumns, (column, tableColumn) => new Pair(column, tableColumn)).Any(p => p.First!=p.Second)) + if (keys.Concat(values).Zip(tableColumns, (column, tableColumn) => new Pair(column, tableColumn)).Any(p => p.First!=p.Second)) ea.Execute(() => { throw new ValidationException(Strings.ExInvalidPrimaryKeyStructure, Path); }); diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Model/SecondaryIndexInfo.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Model/SecondaryIndexInfo.cs index 81887eef1..bc8d1a02f 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Model/SecondaryIndexInfo.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Model/SecondaryIndexInfo.cs @@ -67,8 +67,8 @@ protected override void ValidateState() ea.Execute(base.ValidateState); // Secondary key columns: empty set, duplicates - var keyColumns = KeyColumns.Select(valueRef => valueRef.Value).ToList(); - if (keyColumns.Count==0) + var keyColumns = KeyColumns.Select(valueRef => valueRef.Value).ToArray(KeyColumns.Count); + if (keyColumns.Length==0) ea.Execute(() => { throw new ValidationException(Strings.ExEmptyKeyColumnsCollection, Path); }); diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Model/StorageFullTextIndexInfo.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Model/StorageFullTextIndexInfo.cs index c2b19636f..b683a05b4 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Model/StorageFullTextIndexInfo.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Model/StorageFullTextIndexInfo.cs @@ -61,9 +61,8 @@ protected override void ValidateState() base.ValidateState(); var tableColumns = Parent.Columns; - var columns = Columns.Select(keyRef => keyRef.Value).ToList(); - if (columns.Count == 0) { + if (Columns.Select(keyRef => keyRef.Value).Any()) { ea.Execute(() => { throw new ValidationException(Strings.ExEmptyColumnsCollection, Path); }); diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/SystemUpgradeHandler.cs b/Orm/Xtensive.Orm/Orm/Upgrade/SystemUpgradeHandler.cs index fa3a0498e..37974b6d2 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/SystemUpgradeHandler.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/SystemUpgradeHandler.cs @@ -192,9 +192,13 @@ private Dictionary BuildMetadata(Domain domain, TypeIdRegis var database = group.Key; var metadata = group.Value; Func filter = t => t.MappingDatabase==database; - var types = model.Types.Where(filter).ToList(); + var types = new List(model.Types.Count); + var assemblies = new HashSet(); + foreach (var databaseType in model.Types.Where(filter)) { + types.Add(databaseType); + _ = assemblies.Add(databaseType.UnderlyingType.Assembly); + } var typeMetadata = GetTypeMetadata(types, registry); - var assemblies = types.Select(t => t.UnderlyingType.Assembly).ToHashSet(); var assemblyMetadata = GetAssemblyMetadata(assemblies); var storedModel = model.ToStoredModel(registry, filter); // Since we support storage nodes, stored domain model and real model of a node diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs index 9895fce1b..d1af87131 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs @@ -352,7 +352,11 @@ private void BuildExternalServices(UpgradeServiceAccessor serviceAccessor, Domai private static void BuildModules(UpgradeServiceAccessor serviceAccessor, IServiceContainer serviceContainer) { +#if NET8_0_OR_GREATER + serviceAccessor.Modules = serviceContainer.GetAll().ToArray().AsReadOnly(); +#else serviceAccessor.Modules = serviceContainer.GetAll().ToList().AsReadOnly(); +#endif } private static void BuildUpgradeHandlers(UpgradeServiceAccessor serviceAccessor, IServiceContainer serviceContainer) @@ -398,7 +402,12 @@ where handler.IsEnabled // Storing the result serviceAccessor.UpgradeHandlers = new ReadOnlyDictionary(handlers); - serviceAccessor.OrderedUpgradeHandlers = sortedHandlers.ToList().AsReadOnly(); +#if NET8_0_OR_GREATER + serviceAccessor.OrderedUpgradeHandlers = sortedHandlers.ToArray(handlers.Count).AsReadOnly(); +#else + serviceAccessor.OrderedUpgradeHandlers = sortedHandlers.ToList(handlers.Count).AsReadOnly(); +#endif + } private static void BuildFullTextCatalogResolver(UpgradeServiceAccessor serviceAccessor, IServiceContainer serviceContainer) diff --git a/Orm/Xtensive.Orm/Reflection/MethodHelper.cs b/Orm/Xtensive.Orm/Reflection/MethodHelper.cs index aa9f859ea..80f11c60c 100644 --- a/Orm/Xtensive.Orm/Reflection/MethodHelper.cs +++ b/Orm/Xtensive.Orm/Reflection/MethodHelper.cs @@ -112,7 +112,7 @@ public static ConstructorInfo GetConstructorEx(this Type type, BindingFlags bind } else if (parameterTypes.All(o => o is Type)) { return type.GetConstructor(bindingFlags, null, - parameterTypes.Select(o => (Type) o).ToArray(parameterTypes.Length), null); + parameterTypes.SelectToArray(o => (Type) o), null); } ConstructorInfo lastMatch = null; diff --git a/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlInsertValuesCollection.cs b/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlInsertValuesCollection.cs index 62347d57b..d9f631dee 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlInsertValuesCollection.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlInsertValuesCollection.cs @@ -65,7 +65,7 @@ public void Add(Dictionary row) else { //re-arrange values to be the same order //and also make sure all columns exist - var rowList = new List(); + var rowList = new List(columns.Count); foreach (var column in columns) { if (row.TryGetValue(column, out var value)) { rowList.Add(value); diff --git a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlArray{T}.cs b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlArray{T}.cs index e923ebbe9..fe55c454b 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlArray{T}.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlArray{T}.cs @@ -27,7 +27,7 @@ public class SqlArray : SqlArray public override object[] GetValues() { - return Values.Cast().ToArray(); + return Values.Cast().ToArray(Values.Length); } public static implicit operator SqlArray(T[] value) @@ -56,7 +56,7 @@ internal SqlArray(T[] values) // do not remove, they used by reflection internal SqlArray(List values) { - Values = values.Cast().ToArray(); + Values = values.Cast().ToArray(values.Count); } internal SqlArray(object[] values) diff --git a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlUserFunctionCall.cs b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlUserFunctionCall.cs index 9559951ba..45f796530 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlUserFunctionCall.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlUserFunctionCall.cs @@ -27,7 +27,7 @@ public override void ReplaceWith(SqlExpression expression) internal override SqlUserFunctionCall Clone(SqlNodeCloneContext context) => context.GetOrAdd(this, static (t, c) => - new SqlUserFunctionCall(t.Name, t.Arguments.Select(o => (SqlExpression) o.Clone(c)).ToArray(t.Arguments.Count))); + new SqlUserFunctionCall(t.Name, t.Arguments.Select(o => o.Clone(c)).ToArray(t.Arguments.Count))); internal SqlUserFunctionCall(string name, IEnumerable arguments) : base(SqlFunctionType.UserDefined, arguments) diff --git a/Orm/Xtensive.Orm/Sql/Dml/Hints/SqlForceJoinOrderHint.cs b/Orm/Xtensive.Orm/Sql/Dml/Hints/SqlForceJoinOrderHint.cs index ebc9f9f30..6a151f503 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Hints/SqlForceJoinOrderHint.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Hints/SqlForceJoinOrderHint.cs @@ -21,7 +21,7 @@ public class SqlForceJoinOrderHint : SqlHint internal override SqlForceJoinOrderHint Clone(SqlNodeCloneContext context) => context.GetOrAdd(this, static (t, c) => - new SqlForceJoinOrderHint(t.tables?.Select(table => (SqlTable) table.Clone()).ToArray(t.tables.Length))); + new SqlForceJoinOrderHint(t.tables?.SelectToArray(table => (SqlTable) table.Clone()))); public override void AcceptVisitor(ISqlVisitor visitor) { diff --git a/Orm/Xtensive.Orm/Sql/Model/Domain.cs b/Orm/Xtensive.Orm/Sql/Model/Domain.cs index 660cf1f1d..2ad096c53 100644 --- a/Orm/Xtensive.Orm/Sql/Model/Domain.cs +++ b/Orm/Xtensive.Orm/Sql/Model/Domain.cs @@ -79,10 +79,7 @@ public Collation Collation /// Gets the constraints. /// /// The constraints. - public PairedNodeCollection DomainConstraints - { - get { return constraints; } - } + public PairedNodeCollection DomainConstraints => constraints; #region IConstrainable members @@ -90,13 +87,7 @@ public PairedNodeCollection DomainConstraints /// Gets the constraints. /// /// The constraints. - IList IConstrainable.Constraints - { - get - { - return constraints.ToArray().Convert(i => (Constraint)i); - } - } + IList IConstrainable.Constraints => constraints.SelectToArray(i => (Constraint) i); #endregion diff --git a/Orm/Xtensive.Orm/Sql/Model/Table.cs b/Orm/Xtensive.Orm/Sql/Model/Table.cs index e5b945526..d67e421ad 100644 --- a/Orm/Xtensive.Orm/Sql/Model/Table.cs +++ b/Orm/Xtensive.Orm/Sql/Model/Table.cs @@ -148,10 +148,7 @@ public string Filegroup /// Gets the columns. /// /// The columns. - public override IList Columns - { - get { return TableColumns.ToArray().Convert(i => (DataTableColumn) i); } - } + public override IList Columns => TableColumns.SelectToArray(i => (DataTableColumn) i); #endregion @@ -161,10 +158,7 @@ public override IList Columns /// Gets the node constraints. /// /// The constraints. - IList IConstrainable.Constraints - { - get { return constraints.ToArray().Convert(i => (Constraint)i); } - } + IList IConstrainable.Constraints => constraints.SelectToArray(i => (Constraint) i); #endregion diff --git a/Orm/Xtensive.Orm/Sql/Model/View.cs b/Orm/Xtensive.Orm/Sql/Model/View.cs index f8920b6d5..1a717054f 100644 --- a/Orm/Xtensive.Orm/Sql/Model/View.cs +++ b/Orm/Xtensive.Orm/Sql/Model/View.cs @@ -89,11 +89,7 @@ protected override void ChangeSchema(Schema value) /// Gets the columns. /// /// The columns. - public override IList Columns { - get { - return ViewColumns.ToArray().Convert(i => (DataTableColumn) i); - } - } + public override IList Columns => ViewColumns.SelectToArray(i => (DataTableColumn) i); #endregion diff --git a/Orm/Xtensive.Orm/Sql/SqlDml.cs b/Orm/Xtensive.Orm/Sql/SqlDml.cs index fd212b526..984b25a5e 100644 --- a/Orm/Xtensive.Orm/Sql/SqlDml.cs +++ b/Orm/Xtensive.Orm/Sql/SqlDml.cs @@ -146,8 +146,8 @@ public static SqlBinary Modulo(SqlExpression left, SqlExpression right) public static SqlArray Array(IEnumerable values) { - var valueList = values.ToList(); - if (valueList.Count==0) + var valueList = values.ToArray(); + if (valueList.Length==0) return Array(System.Array.Empty()); var itemType = valueList[0].GetType(); foreach (var t in values.Select(value => value.GetType())) { From 820673b8e78f526b939109993dea3c28d1444b66 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 25 Feb 2026 17:25:18 +0500 Subject: [PATCH 14/55] Less .AsReadOnly() calls or array based ReadOnlyCollections for memory-efficiency --- Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs | 69 ++++++++++++++++--- .../Linq/ExpressionVisitor{TResult}.cs | 14 ++++ Orm/Xtensive.Orm/Linq/ExpressionWriter.cs | 31 ++++++++- .../Orm/Configuration/LoggingConfiguration.cs | 14 ++-- .../Prefetch/Nodes/IHasNestedNodes.cs | 6 +- .../Prefetch/Nodes/KeyExtractorNode.cs | 12 ++-- .../Prefetch/Nodes/NodeAggregator.cs | 9 ++- .../Internals/Prefetch/Nodes/NodeBuilder.cs | 4 +- .../Internals/Prefetch/Nodes/NodeVisitor.cs | 6 +- .../Internals/Prefetch/Nodes/ReferenceNode.cs | 8 +-- .../Orm/Internals/Prefetch/Nodes/SetNode.cs | 8 +-- .../Orm/Internals/Prefetch/PrefetchHelper.cs | 3 +- .../Linq/Expressions/Visitors/OwnerRemover.cs | 6 +- .../Orm/Linq/Translator.Expressions.cs | 2 +- .../Sql/Compiler/Internals/JoinSequence.cs | 56 +++++++-------- 15 files changed, 167 insertions(+), 81 deletions(-) diff --git a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs index 3ec665726..d5e776ed3 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs @@ -31,6 +31,19 @@ protected override ReadOnlyCollection VisitExpressionList(ReadOnlyCo return isChanged ? results.AsReadOnly() : expressions; } + protected override IReadOnlyList VisitExpressionList(IReadOnlyList expressions) + { + bool isChanged = false; + var results = new Expression[expressions.Count]; + for (int i = 0, n = expressions.Count; i < n; i++) { + var expression = expressions[i]; + var p = Visit(expression); + results[i] = p; + isChanged |= !ReferenceEquals(expression, p); + } + return isChanged ? results : expressions; + } + /// /// Visits the element initializer expression. /// @@ -38,7 +51,7 @@ protected override ReadOnlyCollection VisitExpressionList(ReadOnlyCo /// Visit result. protected virtual ElementInit VisitElementInitializer(ElementInit initializer) { - ReadOnlyCollection arguments = VisitExpressionList(initializer.Arguments); + var arguments = VisitExpressionList((IReadOnlyList)initializer.Arguments); if (arguments!=initializer.Arguments) { return Expression.ElementInit(initializer.AddMethod, arguments); } @@ -63,6 +76,24 @@ protected virtual ReadOnlyCollection VisitElementInitializerList(Re return isChanged ? results.AsReadOnly() : original; } + /// + /// Visits the element initializer list. + /// + /// The original element initializer list. + /// Visit result. + protected virtual IReadOnlyList VisitElementInitializerList(IReadOnlyList original) + { + var results = new ElementInit[original.Count]; + bool isChanged = false; + for (int i = 0, n = original.Count; i < n; i++) { + var originalIntializer = original[i]; + ElementInit p = VisitElementInitializer(originalIntializer); + results[i] = p; + isChanged |= !ReferenceEquals(originalIntializer, p); + } + return isChanged ? results : original; + } + /// protected override Expression VisitUnary(UnaryExpression u) { @@ -133,7 +164,7 @@ protected override Expression VisitMemberAccess(MemberExpression m) protected override Expression VisitMethodCall(MethodCallExpression mc) { Expression instance = Visit(mc.Object); - IEnumerable arguments = VisitExpressionList(mc.Arguments); + IEnumerable arguments = VisitExpressionList((IReadOnlyList) mc.Arguments); if ((instance==mc.Object) && (arguments==mc.Arguments)) return mc; return Expression.Call(instance, mc.Method, arguments); @@ -164,7 +195,7 @@ protected override Expression VisitLambda(LambdaExpression l) /// protected override Expression VisitNew(NewExpression n) { - IEnumerable arguments = VisitExpressionList(n.Arguments); + IEnumerable arguments = VisitExpressionList((IReadOnlyList) n.Arguments); if (arguments==n.Arguments) return n; if (n.Members!=null) @@ -176,7 +207,7 @@ protected override Expression VisitNew(NewExpression n) protected override Expression VisitMemberInit(MemberInitExpression mi) { var newExpression = (NewExpression) VisitNew(mi.NewExpression); - IEnumerable bindings = VisitBindingList(mi.Bindings); + IEnumerable bindings = VisitBindingList((IReadOnlyList)mi.Bindings); if ((newExpression==mi.NewExpression) && (bindings==mi.Bindings)) return mi; return Expression.MemberInit(newExpression, bindings); @@ -186,7 +217,7 @@ protected override Expression VisitMemberInit(MemberInitExpression mi) protected override Expression VisitListInit(ListInitExpression li) { var newExpression = (NewExpression) VisitNew(li.NewExpression); - IEnumerable initializers = VisitElementInitializerList(li.Initializers); + IEnumerable initializers = VisitElementInitializerList((IReadOnlyList) li.Initializers); if ((newExpression==li.NewExpression) && (initializers==li.Initializers)) return li; return Expression.ListInit(newExpression, initializers); @@ -195,7 +226,7 @@ protected override Expression VisitListInit(ListInitExpression li) /// protected override Expression VisitNewArray(NewArrayExpression na) { - IEnumerable initializers = VisitExpressionList(na.Expressions); + IEnumerable initializers = VisitExpressionList((IReadOnlyList) na.Expressions); if (initializers==na.Expressions) return na; if (na.NodeType==ExpressionType.NewArrayInit) @@ -206,7 +237,7 @@ protected override Expression VisitNewArray(NewArrayExpression na) /// protected override Expression VisitInvocation(InvocationExpression i) { - IEnumerable arguments = VisitExpressionList(i.Arguments); + IEnumerable arguments = VisitExpressionList((IReadOnlyList) i.Arguments); Expression expression = Visit(i.Expression); if ((arguments==i.Arguments) && (expression==i.Expression)) return i; @@ -241,7 +272,7 @@ protected virtual MemberBinding VisitBinding(MemberBinding binding) /// Visit result. protected virtual MemberMemberBinding VisitMemberMemberBinding(MemberMemberBinding binding) { - IEnumerable bindings = VisitBindingList(binding.Bindings); + IEnumerable bindings = VisitBindingList((IReadOnlyList) binding.Bindings); if (bindings!=binding.Bindings) { return Expression.MemberBind(binding.Member, bindings); } @@ -255,7 +286,7 @@ protected virtual MemberMemberBinding VisitMemberMemberBinding(MemberMemberBindi /// Visit result. protected virtual ReadOnlyCollection VisitBindingList(ReadOnlyCollection original) { - var results = new List(); + var results = new List(original.Count); bool isChanged = false; for (int i = 0, n = original.Count; i < n; i++) { var originalBinding = original[i]; @@ -266,9 +297,27 @@ protected virtual ReadOnlyCollection VisitBindingList(ReadOnlyCol return isChanged ? results.AsReadOnly() : original; } + /// + /// Visits the binding list. + /// + /// The original binding list. + /// Visit result. + protected virtual IReadOnlyList VisitBindingList(IReadOnlyList original) + { + var results = new MemberBinding[original.Count]; + bool isChanged = false; + for (int i = 0, n = original.Count; i < n; i++) { + var originalBinding = original[i]; + MemberBinding p = VisitBinding(originalBinding); + results[i] = p; + isChanged |= !ReferenceEquals(originalBinding, p); + } + return isChanged ? results : original; + } + protected virtual MemberListBinding VisitMemberListBinding(MemberListBinding binding) { - IEnumerable initializers = VisitElementInitializerList(binding.Initializers); + IEnumerable initializers = VisitElementInitializerList((IReadOnlyList) binding.Initializers); if (initializers!=binding.Initializers) return Expression.ListBind(binding.Member, initializers); return binding; diff --git a/Orm/Xtensive.Orm/Linq/ExpressionVisitor{TResult}.cs b/Orm/Xtensive.Orm/Linq/ExpressionVisitor{TResult}.cs index b9900b549..d7cca3e9b 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionVisitor{TResult}.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionVisitor{TResult}.cs @@ -152,6 +152,20 @@ protected virtual ReadOnlyCollection VisitExpressionList(ReadOnlyCollec return results.AsReadOnly(); } + /// + /// Visits the expression list. + /// + /// The expression list. + /// Visit result. + protected virtual IReadOnlyList VisitExpressionList(IReadOnlyList expressions) + { + var results = new TResult[expressions.Count]; + for (int i = 0, n = expressions.Count; i < n; i++) { + results[i] = Visit(expressions[i]); + } + return results; + } + /// /// Visits the unknown expression. /// diff --git a/Orm/Xtensive.Orm/Linq/ExpressionWriter.cs b/Orm/Xtensive.Orm/Linq/ExpressionWriter.cs index 7b42ebc7f..e8fdd0208 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionWriter.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionWriter.cs @@ -6,6 +6,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; @@ -442,6 +443,20 @@ protected override System.Collections.ObjectModel.ReadOnlyCollection + protected override IReadOnlyList VisitElementInitializerList(IReadOnlyList original) + { + for (int i = 0, n = original.Count; i < n; i++) { + VisitElementInitializer(original[i]); + if (i < n - 1) { + Write(","); + WriteLine(IndentType.Same); + } + } + + return original; + } + /// protected override System.Collections.ObjectModel.ReadOnlyCollection VisitExpressionList( System.Collections.ObjectModel.ReadOnlyCollection expressions) @@ -457,6 +472,20 @@ protected override System.Collections.ObjectModel.ReadOnlyCollection return expressions; } + /// + protected override IReadOnlyList VisitExpressionList(IReadOnlyList expressions) + { + for (int i = 0, n = expressions.Count; i < n; i++) { + Visit(expressions[i]); + if (i < n - 1) { + Write(","); + WriteLine(IndentType.Same); + } + } + + return expressions; + } + /// protected override InvocationExpression VisitInvocation(InvocationExpression i) { @@ -576,7 +605,7 @@ protected override MethodCallExpression VisitMethodCall(MethodCallExpression mc) if (mc.Method.GetAttributes(AttributeSearchOptions.InheritNone).Count > 0) { // A special case: extension method Visit(mc.Arguments[0]); - arguments = new System.Collections.ObjectModel.ReadOnlyCollection(mc.Arguments.Skip(1).ToList()); + arguments = new System.Collections.ObjectModel.ReadOnlyCollection(mc.Arguments.Skip(1).ToList(mc.Arguments.Count - 1)); } else { Write(GetTypeName(mc.Method.DeclaringType)); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs index ed8e7cbaa..17823668c 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs @@ -43,12 +43,14 @@ public IList Logs { public override void Lock(bool recursive) { - if (logs is ListnativeList) { - logs = nativeList.AsReadOnly(); - } - else { - logs = logs.ToList().AsReadOnly(); - } +#if NET8_0_OR_GREATER + logs = logs.AsReadOnly(); +#else + logs = logs switch { + List nativeList1 => nativeList1.AsReadOnly(), + _ => logs.ToList().AsReadOnly() + }; +#endif base.Lock(recursive); foreach (var log in logs) { diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/IHasNestedNodes.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/IHasNestedNodes.cs index 50d135403..d179e3e0b 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/IHasNestedNodes.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/IHasNestedNodes.cs @@ -11,10 +11,10 @@ namespace Xtensive.Orm.Internals.Prefetch { internal interface IHasNestedNodes { - ReadOnlyCollection NestedNodes { get; } + IReadOnlyList NestedNodes { get; } - IReadOnlyCollection ExtractKeys(object target); + IReadOnlyList ExtractKeys(object target); - IHasNestedNodes ReplaceNestedNodes(ReadOnlyCollection nestedNodes); + IHasNestedNodes ReplaceNestedNodes(IReadOnlyList nestedNodes); } } diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/KeyExtractorNode.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/KeyExtractorNode.cs index 9b3af6a0e..4e11dd5cc 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/KeyExtractorNode.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/KeyExtractorNode.cs @@ -13,21 +13,21 @@ namespace Xtensive.Orm.Internals.Prefetch { internal class KeyExtractorNode : Node, IHasNestedNodes { - public Func> KeyExtractor { get; } + public Func> KeyExtractor { get; } - public ReadOnlyCollection NestedNodes { get; } + public IReadOnlyList NestedNodes { get; } - IReadOnlyCollection IHasNestedNodes.ExtractKeys(object target) + IReadOnlyList IHasNestedNodes.ExtractKeys(object target) { return ExtractKeys((T) target); } - public IReadOnlyCollection ExtractKeys(T target) + public IReadOnlyList ExtractKeys(T target) { return KeyExtractor.Invoke(target); } - public IHasNestedNodes ReplaceNestedNodes(ReadOnlyCollection nestedNodes) + public IHasNestedNodes ReplaceNestedNodes(IReadOnlyList nestedNodes) { return new KeyExtractorNode(KeyExtractor, nestedNodes); } @@ -42,7 +42,7 @@ protected override string GetDescription() return $"KeyExtraction<{typeof(T).Name}>"; } - public KeyExtractorNode(Func> extractor, ReadOnlyCollection nestedNodes) + public KeyExtractorNode(Func> extractor, IReadOnlyList nestedNodes) : base("*") { ArgumentValidator.EnsureArgumentNotNull(extractor, nameof(extractor)); diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeAggregator.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeAggregator.cs index d239cce2a..c498ab19f 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeAggregator.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeAggregator.cs @@ -18,15 +18,14 @@ public static IList> Aggregate(IEnumerable ken.Path, (path, @group) => (Node) @group.First().ReplaceNestedNodes( - new ReadOnlyCollection( - @group.SelectMany(ken => ken.NestedNodes).ToList()))) + @group.SelectMany(ken => ken.NestedNodes).ToList())) .Select(aggregator.Visit) .Cast>() .ToList(); return result; } - public override ReadOnlyCollection VisitNodeList(ReadOnlyCollection nodes) + public override IReadOnlyList VisitNodeList(IReadOnlyList nodes) { var result = new List(); foreach (var group in nodes.Where(n => n!=null).GroupBy(n => n.Path)) { @@ -36,11 +35,11 @@ public override ReadOnlyCollection VisitNodeList(ReadOnlyCollecti result.Add(node); else { var nodeToVisit = (BaseFieldNode) container.ReplaceNestedNodes( - new ReadOnlyCollection(group.Cast().SelectMany(c => c.NestedNodes).ToList())); + group.Cast().SelectMany(c => c.NestedNodes).ToList()); result.Add((BaseFieldNode) Visit(nodeToVisit)); } } - return new ReadOnlyCollection(result); + return result; } // Constructor diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeBuilder.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeBuilder.cs index ebc5ad3fa..8dd751300 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeBuilder.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2020 Xtensive LLC. +// Copyright (C) 2012-2020 Xtensive LLC. // This code is distributed under MIT license terms. // See the License.txt file in the project root for more information. // Created by: Denis Krjuchkov @@ -34,7 +34,7 @@ public static KeyExtractorNode Build(DomainModel model, Expression return new KeyExtractorNode(GetExtractor(), nestedNodes); } - private static Func> GetExtractor() + private static Func> GetExtractor() { return target => new[] {((IEntity) target).Key}; } diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeVisitor.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeVisitor.cs index ce371ec87..bf69038fd 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeVisitor.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeVisitor.cs @@ -4,7 +4,7 @@ // Created by: Alexis Kochetov // Created: 2011.01.14 -using System.Collections.ObjectModel; +using System.Collections.Generic; namespace Xtensive.Orm.Internals.Prefetch { @@ -17,7 +17,7 @@ public virtual Node Visit(Node node) return node.Accept(this); } - public virtual ReadOnlyCollection VisitNodeList(ReadOnlyCollection nodes) + public virtual IReadOnlyList VisitNodeList(IReadOnlyList nodes) { BaseFieldNode[] list = null; var index = 0; @@ -37,7 +37,7 @@ public virtual ReadOnlyCollection VisitNodeList(ReadOnlyCollectio } return list==null ? nodes - : new ReadOnlyCollection(list); + : list; } public virtual Node VisitKeyExtractorNode(KeyExtractorNode keyExtractorNode) diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ReferenceNode.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ReferenceNode.cs index 5bceb8dc8..f84142877 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ReferenceNode.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ReferenceNode.cs @@ -15,9 +15,9 @@ internal sealed class ReferenceNode : BaseFieldNode, IHasNestedNodes { public TypeInfo ReferenceType { get; private set; } - public ReadOnlyCollection NestedNodes { get; private set; } + public IReadOnlyList NestedNodes { get; private set; } - public IReadOnlyCollection ExtractKeys(object target) + public IReadOnlyList ExtractKeys(object target) { if (target == null) { return Array.Empty(); @@ -30,7 +30,7 @@ public IReadOnlyCollection ExtractKeys(object target) : new[] {referenceKey}; } - public IHasNestedNodes ReplaceNestedNodes(ReadOnlyCollection nestedNodes) + public IHasNestedNodes ReplaceNestedNodes(IReadOnlyList nestedNodes) { return new ReferenceNode(Path, Field, ReferenceType, NestedNodes); } @@ -42,7 +42,7 @@ public override Node Accept(NodeVisitor visitor) // Constructors - public ReferenceNode(string path, FieldInfo field, TypeInfo referenceType, ReadOnlyCollection nestedNodes) + public ReferenceNode(string path, FieldInfo field, TypeInfo referenceType, IReadOnlyList nestedNodes) : base(path, field) { ReferenceType = referenceType; diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/SetNode.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/SetNode.cs index 5650ef97a..ee0c486b5 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/SetNode.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/SetNode.cs @@ -14,11 +14,11 @@ namespace Xtensive.Orm.Internals.Prefetch { internal class SetNode : BaseFieldNode, IHasNestedNodes { - public ReadOnlyCollection NestedNodes { get; } + public IReadOnlyList NestedNodes { get; } public TypeInfo ElementType { get; } - public IReadOnlyCollection ExtractKeys(object target) + public IReadOnlyList ExtractKeys(object target) { if (target == null) { return Array.Empty(); @@ -30,7 +30,7 @@ public IReadOnlyCollection ExtractKeys(object target) return fetchedKeys.ToArray(fetchedKeys.Count); } - public IHasNestedNodes ReplaceNestedNodes(ReadOnlyCollection nestedNodes) => + public IHasNestedNodes ReplaceNestedNodes(IReadOnlyList nestedNodes) => new SetNode(Path, Field, ElementType, NestedNodes); public override Node Accept(NodeVisitor visitor) => visitor.VisitSetNode(this); @@ -38,7 +38,7 @@ public IHasNestedNodes ReplaceNestedNodes(ReadOnlyCollection nest // Constructors - public SetNode(string path, FieldInfo field, TypeInfo elementType, ReadOnlyCollection nestedNodes) + public SetNode(string path, FieldInfo field, TypeInfo elementType, IReadOnlyList nestedNodes) : base(path, field) { ElementType = elementType; diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchHelper.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchHelper.cs index 4bc650e67..4e3d8c8de 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchHelper.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchHelper.cs @@ -17,8 +17,7 @@ internal static class PrefetchHelper type.Fields .Where(field => field.Parent == null && IsFieldToBeLoadedByDefault(field)) .Select(field => new PrefetchFieldDescriptor(field, false, false)) - .ToList() - .AsReadOnly(); + .ToArray(); public static bool IsFieldToBeLoadedByDefault(FieldInfo field) { diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs index 8265e303b..6b36a68a7 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs @@ -45,13 +45,13 @@ protected override KeyExpression VisitKeyExpression(KeyExpression expression) protected override ConstructorExpression VisitConstructorExpression(ConstructorExpression expression) { - var oldConstructorArguments = expression.ConstructorArguments.ToList().AsReadOnly(); + var oldConstructorArguments = expression.ConstructorArguments.ToList(); var newConstructorArguments = VisitExpressionList(oldConstructorArguments); - var oldBindings = expression.Bindings.SelectToList(b => b.Value).AsReadOnly(); + var oldBindings = expression.Bindings.SelectToList(b => b.Value); var newBindings = VisitExpressionList(oldBindings); - var oldNativeBindings = expression.NativeBindings.SelectToList(b => b.Value).AsReadOnly(); + var oldNativeBindings = expression.NativeBindings.SelectToList(b => b.Value); var newNativeBindings = VisitExpressionList(oldNativeBindings); var notChanged = diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs index 78bfb4428..9f51a7ba1 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs @@ -1370,7 +1370,7 @@ protected override Expression VisitMemberInit(MemberInitExpression mi) { var newExpression = mi.NewExpression; VisitNewExpressionArgumentsSkipResults(newExpression); - var bindings = VisitBindingList(mi.Bindings).Cast(); + var bindings = VisitBindingList((IReadOnlyList) mi.Bindings).Cast(); var constructorExpression = (ConstructorExpression) VisitNew(mi.NewExpression); foreach (var binding in bindings) { var member = binding.Member.MemberType == MemberTypes.Property diff --git a/Orm/Xtensive.Orm/Sql/Compiler/Internals/JoinSequence.cs b/Orm/Xtensive.Orm/Sql/Compiler/Internals/JoinSequence.cs index 0b2677b82..e2f4673ba 100644 --- a/Orm/Xtensive.Orm/Sql/Compiler/Internals/JoinSequence.cs +++ b/Orm/Xtensive.Orm/Sql/Compiler/Internals/JoinSequence.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -10,66 +10,60 @@ namespace Xtensive.Sql.Compiler { - internal sealed class JoinSequence + internal readonly struct JoinSequence { - public SqlTable Pivot { get; private set; } + public SqlTable Pivot { get; } - public IList Tables { get; private set; } + public IReadOnlyList Tables { get; } - public IList JoinTypes { get; private set; } + public IReadOnlyList JoinTypes { get; } - public IList Conditions { get; private set; } + public IReadOnlyList Conditions { get; } public static JoinSequence Build(SqlJoinedTable root) { var joins = new List(); Traverse(root, joins); - var result = new JoinSequence(); + var tables = new List(); + var joinTypes = new List(joins.Count); + var conditions = new List(joins.Count); foreach (var item in joins) { - if (!(item.Left is SqlJoinedTable)) - result.Tables.Add(item.Left); - if (!(item.Right is SqlJoinedTable)) - result.Tables.Add(item.Right); - result.JoinTypes.Add(item.JoinType); - result.Conditions.Add(item.Expression); + if (item.Left is not SqlJoinedTable) + tables.Add(item.Left); + if (item.Right is not SqlJoinedTable) + tables.Add(item.Right); + joinTypes.Add(item.JoinType); + conditions.Add(item.Expression); } - var pivot = result.Tables[0]; - result.Pivot = pivot; - result.Tables.RemoveAt(0); - - result.Tables = new ReadOnlyCollection(result.Tables); - result.JoinTypes = new ReadOnlyCollection(result.JoinTypes); - result.Conditions = new ReadOnlyCollection(result.Conditions); - - return result; + var pivot = tables[0]; + tables.RemoveAt(0); + return new JoinSequence(pivot, tables, joinTypes, conditions); } private static void Traverse(SqlJoinedTable root, ICollection output) { var left = root.JoinExpression.Left; - var joinedLeft = left as SqlJoinedTable; - if (joinedLeft!=null) + if (left is SqlJoinedTable joinedLeft) Traverse(joinedLeft, output); output.Add(root.JoinExpression); var right = root.JoinExpression.Right; - var joinedRight = right as SqlJoinedTable; - if (joinedRight!=null) + if (right is SqlJoinedTable joinedRight) Traverse(joinedRight, output); } // Constructors - - private JoinSequence() + private JoinSequence(SqlTable pivot, IReadOnlyList tables, IReadOnlyList joinTypes, IReadOnlyList conditions) { - Tables = new List(); - JoinTypes = new List(); - Conditions = new List(); + Pivot = pivot; + Tables = tables; + JoinTypes = joinTypes; + Conditions = conditions; } } } \ No newline at end of file From 21df864b9da9389e0cac85b41bae5b94d6b573d6 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 25 Feb 2026 17:33:36 +0500 Subject: [PATCH 15/55] Improved FieldExpressionCollections traversal --- .../Orm/Linq/Expressions/EntityExpression.cs | 4 +- .../ParameterizedExpressionExtensions.cs | 44 +++++++++++++++++++ .../Linq/Expressions/StructureExpression.cs | 2 +- .../Expressions/StructureFieldExpression.cs | 2 +- .../Materialization/ExpressionMaterializer.cs | 21 ++++----- 5 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 Orm/Xtensive.Orm/Orm/Linq/Expressions/ParameterizedExpressionExtensions.cs diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/EntityExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/EntityExpression.cs index 575b18d80..410838602 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/EntityExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/EntityExpression.cs @@ -26,7 +26,7 @@ public List Fields get => fields; private set { fields = value; - foreach (var fieldExpression in fields.OfType()) { + foreach (var fieldExpression in fields.OfAnyFieldExpression()) { fieldExpression.Owner = this; } } @@ -137,7 +137,7 @@ public static void Fill(EntityExpression entityExpression, int offset) _ = entityExpression.Remap(offset, new Dictionary()); } var typeInfo = entityExpression.PersistentType; - foreach (var nestedField in typeInfo.Fields.Except(entityExpression.Fields.OfType().Select(field => field.Field))) { + foreach (var nestedField in typeInfo.Fields.Except(entityExpression.Fields.OfAnyFieldExpression().Select(field => field.Field))) { var nestedFieldExpression = BuildNestedFieldExpression(nestedField, offset); if (nestedFieldExpression is FieldExpression fieldExpression) { fieldExpression.Owner = entityExpression; diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ParameterizedExpressionExtensions.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ParameterizedExpressionExtensions.cs new file mode 100644 index 000000000..c24082639 --- /dev/null +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ParameterizedExpressionExtensions.cs @@ -0,0 +1,44 @@ +// Copyright (C) 2009-2020 Xtensive LLC. +// This code is distributed under MIT license terms. +// See the License.txt file in the project root for more information. +// Created by: Alexis Kochetov +// Created: 2009.05.05 + +using System.Linq; +using System.Collections.Generic; + +namespace Xtensive.Orm.Linq.Expressions +{ + internal static class ParameterizedExpressionExtensions + { + /// + /// Gets instances of any implementation of + /// + /// Sequence of expressions. + /// Filtered results. + public static IEnumerable OfAnyFieldExpression(this IEnumerable fields) + { + // Faster that .OfType() + return fields + .Where(static f => f.ExtendedType is ExtendedExpressionType.Field + or ExtendedExpressionType.EntityField + or ExtendedExpressionType.EntitySet + or ExtendedExpressionType.StructureField) + .Cast(); + } + + /// + /// Gets instances of only type. + /// + /// Sequence of expressions. + /// Filtered results. + public static IEnumerable OfExactlyFieldExpression(this IEnumerable fields) + { + // A lot faster than fields.OfType().Where(static f => f.ExtendedType is ExtendedExpressionType.Field) + // because contains less casts and more basic comparisons + return fields + .Where(static f => f.ExtendedType is ExtendedExpressionType.Field) + .Cast(); + } + } +} \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs index bb31cd358..6348b8d9e 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs @@ -29,7 +29,7 @@ public List Fields get => fields; private set { fields = value; - foreach (var fieldExpression in fields.OfType()) { + foreach (var fieldExpression in fields.OfAnyFieldExpression()) { fieldExpression.Owner = this; } } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureFieldExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureFieldExpression.cs index f08de19cd..7bcc90a4f 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureFieldExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureFieldExpression.cs @@ -26,7 +26,7 @@ public List Fields get => fields; private set { fields = value; - foreach (var fieldExpression in fields.OfType()) { + foreach (var fieldExpression in fields.OfAnyFieldExpression()) { fieldExpression.Owner = this; } } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs b/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs index 9b71b8671..77e236c4c 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs @@ -247,10 +247,9 @@ protected override Expression VisitStructureFieldExpression(StructureFieldExpres var typeInfo = expression.PersistentType; var tuplePrototype = typeInfo.TuplePrototype; var mappingInfo = expression.Fields - .OfType() - .Where(f => f.ExtendedType == ExtendedExpressionType.Field) - .OrderBy(f => f.Field.MappingInfo.Offset) - .Select(f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) + .OfExactlyFieldExpression() + .OrderBy(static f => f.Field.MappingInfo.Offset) + .Select(static f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) .Distinct() .ToArray(); @@ -296,10 +295,9 @@ protected override Expression VisitStructureExpression(StructureExpression expre var typeInfo = expression.PersistentType; var tuplePrototype = typeInfo.TuplePrototype; var mappingInfo = expression.Fields - .OfType() - .Where(f => f.ExtendedType == ExtendedExpressionType.Field) - .OrderBy(f => f.Field.MappingInfo.Offset) - .Select(f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) + .OfExactlyFieldExpression() + .OrderBy(static f => f.Field.MappingInfo.Offset) + .Select(static f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) .Distinct() .ToArray(); @@ -361,10 +359,9 @@ private Expression CreateEntity(IEntityExpression expression, Expression tupleEx var typeIdIndex = typeIdField == null ? -1 : typeIdField.Mapping.Offset; var mappingInfo = expression.Fields - .OfType() - .Where(f => f.ExtendedType == ExtendedExpressionType.Field) - .OrderBy(f => f.Field.MappingInfo.Offset) - .Select(f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) + .OfExactlyFieldExpression() + .OrderBy(static f => f.Field.MappingInfo.Offset) + .Select(static f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) .Distinct() .ToArray(); From ba2b66a3c5c4d090e7149a387403c1fd4569d97d Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Thu, 26 Feb 2026 16:39:31 +0500 Subject: [PATCH 16/55] Argument validation via standard mechanism instead of ArgumentValidator also null check (??) applied if possible also addes some missing validation --- .../LocalizationConfiguration.cs | 6 +- .../Internals/TypeLocalizationMap.cs | 2 +- .../LocalizationContext.cs | 3 +- .../ReprocessingConfiguration.cs | 6 +- .../Configuration/SecurityConfiguration.cs | 6 +- .../ImpersonationContext.cs | 4 +- .../Services/GenericAuthenticationService.cs | 2 +- .../SessionExtensions.cs | 16 +- .../Internals/TrackingStackFrame.cs | 3 +- .../Sql.Drivers.Firebird/v2_5/Extractor.cs | 4 +- .../Sql.Drivers.Firebird/v3_0/Extractor.cs | 4 +- .../Sql.Drivers.Firebird/v4_0/Extractor.cs | 4 +- .../PostgresqlSqlDml.cs | 47 +- .../ErrorMessageParser.cs | 15 +- .../Sql.Drivers.SqlServer/InternalHelpers.cs | 2 +- .../Sql.Drivers.SqlServer/v09/Extractor.cs | 4 +- .../Modelling/IndexingModel/TypeInfo.cs | 4 +- .../DelegateHelperCreateDelegateTest.cs | 2 +- .../Tuples/DummyTuple.cs | 2 +- .../Internals/InstanceGeneratorBase.cs | 2 +- .../TestSqlDriver.cs | 4 +- .../Linq/FullTextColumnsDeclarationTest.cs | 4 +- Orm/Xtensive.Orm/Arithmetic/ArithmeticBase.cs | 3 +- .../Arithmetic/WrappingArithmetic{T,TBase}.cs | 2 +- Orm/Xtensive.Orm/Caching/CacheBase.cs | 2 +- .../FastConcurrentLruCache{TKey, TItem}.cs | 2 +- Orm/Xtensive.Orm/Caching/InfiniteCache.cs | 4 +- Orm/Xtensive.Orm/Caching/Interfaces/ICache.cs | 2 +- .../Caching/LruCache{TKey, TItem, TCached}.cs | 6 +- .../Caching/LruCache{TKey, TItem}.cs | 8 +- Orm/Xtensive.Orm/Caching/MfLruCache.cs | 6 +- Orm/Xtensive.Orm/Caching/WeakCache.cs | 5 +- Orm/Xtensive.Orm/Caching/WeakestCache.cs | 9 +- Orm/Xtensive.Orm/Collections/ChainedBuffer.cs | 6 +- Orm/Xtensive.Orm/Collections/Deque.cs | 8 +- .../Collections/EnumerableUtils.cs | 4 +- .../Collections/ExtensionCollection.cs | 6 +- Orm/Xtensive.Orm/Collections/Graphs/Edge.cs | 6 +- Orm/Xtensive.Orm/Collections/Graphs/Graph.cs | 2 +- .../Collections/Graphs/TopologicalSorter.cs | 2 +- .../Collections/TypeRegistration.cs | 9 +- .../TypeRegistrationProcessorBase.cs | 4 +- Orm/Xtensive.Orm/Collections/TypeRegistry.cs | 11 +- .../Comparison/AdvancedComparer.cs | 2 +- .../Comparison/AdvancedComparerBase.cs | 3 +- .../Comparison/ComparisonRules.cs | 2 +- .../WrappingComparer{T,TBase1,TBase2}.cs | 2 +- .../Comparison/WrappingComparer{T,TBase}.cs | 2 +- .../Conversion/AdvancedConverterBase.cs | 3 +- .../Conversion/ConvertingEnumerable.cs | 6 +- .../Internals/ConvertingEnumerator.cs | 6 +- .../NullableForwardAdvancedConverter.cs | 2 +- Orm/Xtensive.Orm/Core/ArgumentValidator.cs | 5 +- Orm/Xtensive.Orm/Core/AsyncFutureResult.cs | 4 +- Orm/Xtensive.Orm/Core/DisposableSet.cs | 2 +- Orm/Xtensive.Orm/Core/Exceptions.cs | 8 +- .../Core/Extensions/ArrayExtensions.cs | 8 +- .../Core/Extensions/CollectionExtensions.cs | 14 +- .../Core/Extensions/EnumerableExtensions.cs | 16 +- .../Core/Extensions/ExpressionExtensions.cs | 10 +- .../Core/Extensions/HasServicesExtensions.cs | 2 +- .../Core/Extensions/ListExtensions.cs | 10 +- .../Extensions/StringBuilderExtensions.cs | 6 +- .../Core/Extensions/StringExtensions.cs | 31 +- Orm/Xtensive.Orm/Core/Parameter.cs | 4 +- Orm/Xtensive.Orm/Core/SimpleXmlSerializer.cs | 7 +- .../Core/SynchronousFutureResult.cs | 6 +- Orm/Xtensive.Orm/IoC/ServiceContainer.cs | 2 +- Orm/Xtensive.Orm/IoC/ServiceRegistration.cs | 2 +- Orm/Xtensive.Orm/Linq/ConstantExtractor.cs | 3 +- Orm/Xtensive.Orm/Linq/ExpressionTree.cs | 3 +- .../Internals/ExpressionHashCodeCalculator.cs | 2 +- .../Internals/ReflectionExtensions.cs | 2 +- .../Modelling/Actions/ActionSequence.cs | 4 +- .../Modelling/Actions/CreateNodeAction.cs | 4 +- .../Modelling/Actions/GroupingNodeAction.cs | 2 +- .../Modelling/Actions/MoveNodeAction.cs | 2 +- .../Modelling/Actions/NodeAction.cs | 2 +- .../Modelling/Actions/PropertyChangeAction.cs | 2 +- .../Modelling/Actions/RemoveNodeAction.cs | 2 +- .../Modelling/Comparison/Comparer.cs | 6 +- .../Comparison/Hints/CopyDataHint.cs | 2 +- .../Modelling/Comparison/Hints/DataHint.cs | 2 +- .../Modelling/Comparison/Hints/HintSet.cs | 10 +- .../Comparison/Hints/UpdateDataHint.cs | 2 +- .../Modelling/Comparison/Upgrader.cs | 4 +- Orm/Xtensive.Orm/Modelling/Nesting.cs | 3 +- Orm/Xtensive.Orm/Modelling/Node.cs | 10 +- Orm/Xtensive.Orm/Modelling/NodeCollection.cs | 3 +- .../Orm/Attributes/IndexAttribute.cs | 2 +- .../Orm/Building/Builders/DomainBuilder.cs | 3 +- .../Builders/MemberCompilerProviderBuilder.cs | 4 +- .../Builders/PartialIndexFilterBuilder.cs | 2 +- .../Orm/Building/Builders/TypeIdBuilder.cs | 7 +- .../Orm/Building/BuildingContext.cs | 8 +- .../Definitions/HierarchyDefCollection.cs | 4 +- .../Orm/Building/Definitions/IndexDef.cs | 3 +- .../Orm/Building/Definitions/TypeDef.cs | 4 +- .../Building/Definitions/TypeDefCollection.cs | 4 +- .../Orm/Configuration/DomainConfiguration.cs | 16 +- .../ExtensionConfigurationCollection.cs | 4 +- .../Internals/LoggingConfigurationReader.cs | 8 +- .../LinqExtensionRegistration.cs | 16 +- .../Orm/Configuration/LoggingConfiguration.cs | 2 +- .../Configuration/NameMappingCollection.cs | 2 +- .../Options/NamedOptionsCollection{T}.cs | 4 +- .../Options/OptionsCollection{T}.cs | 2 +- .../Orm/ConnectionErrorEventData.cs | 3 +- Orm/Xtensive.Orm/Orm/ConnectionEventData.cs | 4 +- Orm/Xtensive.Orm/Orm/ConnectionInfo.cs | 4 +- Orm/Xtensive.Orm/Orm/DelayedQuery.cs | 6 +- Orm/Xtensive.Orm/Orm/Domain.cs | 4 +- Orm/Xtensive.Orm/Orm/DomainBound.cs | 3 +- Orm/Xtensive.Orm/Orm/Entity.cs | 8 +- Orm/Xtensive.Orm/Orm/EntityEventBroker.cs | 12 +- Orm/Xtensive.Orm/Orm/EntitySet{T}.cs | 8 +- Orm/Xtensive.Orm/Orm/EntityState.cs | 3 +- .../Nodes/ComplexTerm.cs | 6 +- .../Nodes/CustomProximityTerm.cs | 2 +- .../Nodes/GenerationTerm.cs | 6 +- .../FullTextSearchCondition/Nodes/Operator.cs | 12 +- .../NonPairedReferenceChangesRegistry.cs | 12 +- .../ReferenceFieldsChangesRegistry.cs | 14 +- .../FieldAccessors/StructureFieldAccessor.cs | 2 +- Orm/Xtensive.Orm/Orm/Internals/KeyFactory.cs | 2 +- .../KeyGenerators/Caching/CachingSequence.cs | 6 +- .../Caching/DomainCachingSequenceProvider.cs | 7 +- .../Caching/SessionCachingSequenceProvider.cs | 7 +- .../Orm/Internals/Prefetch/EntityContainer.cs | 7 +- .../Orm/Internals/Prefetch/EntityGroupTask.cs | 8 +- .../Orm/Internals/Prefetch/EntitySetTask.cs | 10 +- .../Orm/Internals/Prefetch/Fetcher.cs | 4 +- .../Orm/Internals/Prefetch/GraphContainer.cs | 12 +- .../Prefetch/Nodes/KeyExtractorNode.cs | 7 +- .../Prefetch/PrefetchFieldDescriptor.cs | 6 +- .../Orm/Internals/Prefetch/PrefetchManager.cs | 10 +- .../Prefetch/ReferencedEntityContainer.cs | 6 +- .../Internals/Prefetch/RootEntityContainer.cs | 2 +- Orm/Xtensive.Orm/Orm/Internals/QueryTask.cs | 3 +- .../ReferentialIntegrity/RemovalProcessor.cs | 2 +- .../Orm/Internals/RemapContext.cs | 10 +- .../Orm/Internals/StorageNodeRegistry.cs | 10 +- .../Orm/Internals/VersionGenerator.cs | 2 +- Orm/Xtensive.Orm/Orm/Key.cs | 22 +- .../Linq/LocalCollectionKeyTypeExtractor.cs | 2 +- .../Materialization/MaterializationContext.cs | 2 +- .../MemberCompilerProvider.cs | 6 +- .../MemberCompilerProviderFactory.cs | 2 +- Orm/Xtensive.Orm/Orm/Linq/Queryable.cs | 2 +- .../Orm/Linq/TranslatorContext.cs | 6 +- Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs | 4 +- .../Orm/Logging/Internals/InternalLog.cs | 5 +- Orm/Xtensive.Orm/Orm/Logging/LogManager.cs | 4 +- Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs | 2 +- Orm/Xtensive.Orm/Orm/Model/FieldInfo.cs | 2 +- .../Stored/Internals/TypeMappingUpdater.cs | 9 +- Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs | 8 +- .../Orm/Model/TypeInfoCollection.cs | 2 +- .../Orm/Operations/EntityFieldOperation.cs | 3 +- .../Orm/Operations/EntityOperation.cs | 2 +- .../Orm/Operations/EntitySetItemOperation.cs | 3 +- .../Internals/OperationRegistrationScope.cs | 2 +- .../Orm/Operations/KeyGenerateOperation.cs | 2 +- .../Orm/Operations/MethodCallOperation.cs | 3 +- .../Orm/Operations/OperationCapturer.cs | 3 +- .../Operations/ValidateVersionOperation.cs | 2 +- .../CommandProcessing/CommandFactory.cs | 14 +- .../CommandProcessing/CommandProcessor.cs | 4 +- .../CommandProcessing/SqlLoadTask.cs | 8 +- .../Orm/Providers/CommandWithDataReader.cs | 9 +- .../Orm/Providers/CompilationService.cs | 14 +- .../Expressions/ExpressionProcessor.cs | 6 +- .../Expressions/QueryParameterIdentity.cs | 6 +- .../Orm/Providers/MappingResolver.cs | 10 +- Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs | 40 +- .../Orm/Providers/Requests/PersistRequest.cs | 12 +- .../Requests/QueryParameterBinding.cs | 6 +- .../Orm/Providers/Requests/QueryRequest.cs | 16 +- .../Providers/Requests/UserQueryRequest.cs | 10 +- .../Orm/Providers/SequenceQuery.cs | 16 +- .../Orm/Providers/SequenceQueryBuilder.cs | 2 +- Orm/Xtensive.Orm/Orm/Providers/SqlExecutor.cs | 7 +- .../Orm/Providers/SqlProviderPreparer.cs | 3 +- .../Orm/Providers/SqlSelectProcessor.cs | 10 +- .../SqlSessionHandler.IDirectSqlService.cs | 2 +- .../Orm/Providers/StorageDriver.cs | 10 +- .../Orm/Providers/StorageSequenceAccessor.cs | 2 +- Orm/Xtensive.Orm/Orm/QueryEndpoint.cs | 28 +- .../Orm/QueryableExtensions.Async.cs | 194 +++---- Orm/Xtensive.Orm/Orm/QueryableExtensions.cs | 52 +- .../Orm/RecycledFieldDefinition.cs | 10 +- .../Orm/Rse/ProviderExtensions.cs | 8 +- .../Providers/Compilable/AggregateProvider.cs | 2 +- .../Rse/Providers/Compilable/AliasProvider.cs | 3 +- .../Rse/Providers/Compilable/ApplyProvider.cs | 2 +- .../Providers/Compilable/BinaryProvider.cs | 6 +- .../Providers/Compilable/CalculateProvider.cs | 2 +- .../Compilable/ContainsTableProvider.cs | 2 +- .../Providers/Compilable/ExistenceProvider.cs | 2 + .../Providers/Compilable/FreeTextProvider.cs | 4 +- .../Providers/Compilable/IncludeProvider.cs | 8 +- .../Rse/Providers/Compilable/LockProvider.cs | 12 +- .../Providers/Compilable/OrderProviderBase.cs | 2 +- .../Compilable/PredicateJoinProvider.cs | 2 +- .../Rse/Providers/Compilable/RawProvider.cs | 4 +- .../Providers/Compilable/SelectProvider.cs | 2 + .../Rse/Providers/Compilable/StoreProvider.cs | 12 +- .../Rse/Providers/Compilable/TagProvider.cs | 2 +- .../Rse/Providers/Compilable/UnaryProvider.cs | 4 +- .../Rse/Providers/Compilable/VoidProvider.cs | 7 +- .../Orm/Rse/Providers/ExecutableProvider.cs | 4 +- .../Orm/Rse/Providers/TagScope.cs | 4 +- Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs | 4 +- .../Transformation/ColumnMappingInspector.cs | 2 +- .../Internals/ApplyFilterRewriter.cs | 6 +- .../Internals/ApplyParameterSearcher.cs | 2 +- .../Internals/ApplyPredicateCollector.cs | 3 +- .../Internals/CalculateProviderCollector.cs | 3 +- .../CalculateRelatedExpressionRewriter.cs | 13 +- .../Internals/OrderingRewriter.cs | 5 +- .../Internals/ParameterRewriter.cs | 10 +- .../Rse/Transformation/OrderingCorrector.cs | 3 +- .../Rse/Transformation/TupleAccessGatherer.cs | 4 +- .../Rse/Transformation/TupleAccessRewriter.cs | 4 +- .../Orm/Serialization/SerializationContext.cs | 3 +- .../Orm/Services/DirectEntityAccessor.cs | 2 +- .../Orm/Services/DirectEntitySetAccessor.cs | 8 +- .../Orm/Services/DirectPersistentAccessor.cs | 16 +- .../Orm/Services/Old/DirectStateAccessor.cs | 8 +- .../Services/QueryBuilding/QueryBuilder.cs | 14 +- .../Orm/Services/QueryFormatter.cs | 7 +- Orm/Xtensive.Orm/Orm/Session.Persist.cs | 2 +- Orm/Xtensive.Orm/Orm/Session.Query.cs | 4 +- Orm/Xtensive.Orm/Orm/StorageNode.cs | 10 +- Orm/Xtensive.Orm/Orm/Transaction.cs | 4 +- .../Orm/Upgrade/Hints/ChangeFieldTypeHint.cs | 2 +- .../Orm/Upgrade/Hints/CopyFieldHint.cs | 6 +- .../Orm/Upgrade/Hints/MergeTypeHint.cs | 7 +- .../Orm/Upgrade/Hints/MoveFieldHint.cs | 6 +- .../Orm/Upgrade/Hints/RecycledTypeHint.cs | 4 +- .../Orm/Upgrade/Hints/RemoveFieldHint.cs | 2 +- .../Orm/Upgrade/Hints/RenameFieldHint.cs | 4 +- .../Orm/Upgrade/Hints/RenameTypeHint.cs | 2 +- .../Internals/DomainExtractedModelBuilder.cs | 4 +- .../Upgrade/Internals/DomainModelConverter.cs | 13 +- .../Internals/ExtractedModelBuilderFactory.cs | 6 +- .../Orm/Upgrade/Internals/HintGenerator.cs | 12 +- .../Upgrade/Internals/IgnoreRulesHandler.cs | 5 +- .../Internals/Metadata/ExtensionMetadata.cs | 7 +- .../Internals/Metadata/MetadataExtractor.cs | 7 +- .../Internals/Metadata/MetadataWriter.cs | 13 +- .../Internals/Metadata/TypeMetadata.cs | 3 +- .../Internals/NodeExtractedModelBuilder.cs | 9 +- .../Internals/NullUpgradeHintsProcessor.cs | 4 +- .../Upgrade/Internals/PartialIndexInfoMap.cs | 4 +- .../Upgrade/Internals/SqlActionTranslator.cs | 23 +- .../Upgrade/Internals/SqlModelConverter.cs | 6 +- .../Orm/Upgrade/Internals/StageModelFilter.cs | 4 +- .../Orm/Upgrade/Internals/TypeIdProvider.cs | 5 +- .../Internals/UpgradeActionSequenceBuilder.cs | 8 +- .../Internals/UpgradeHintsProcessingResult.cs | 29 +- .../Internals/UpgradeHintsProcessor.cs | 14 +- .../Internals/UpgradeServiceAccessor.cs | 6 +- .../Orm/Upgrade/Model/StorageTypeInfo.cs | 2 +- .../Orm/Upgrade/TypeConversionVerifier.cs | 8 +- .../Orm/Upgrade/UpgradeActionSequence.cs | 8 +- .../Orm/Upgrade/UpgradeContext.cs | 6 +- .../Orm/Upgrade/UpgradeHandler.cs | 4 +- .../Orm/Upgrade/UpgradingDomainBuilder.cs | 12 +- .../Orm/Validation/EntityErrorInfo.cs | 7 +- .../Orm/Validation/ValidationResult.cs | 3 +- Orm/Xtensive.Orm/Orm/VersionCapturer.cs | 2 +- Orm/Xtensive.Orm/Orm/VersionInfo.cs | 2 +- Orm/Xtensive.Orm/Orm/VersionSet.cs | 12 +- Orm/Xtensive.Orm/Orm/VersionValidator.cs | 2 +- Orm/Xtensive.Orm/Reflection/DelegateHelper.cs | 14 +- Orm/Xtensive.Orm/Reflection/MethodHelper.cs | 4 +- Orm/Xtensive.Orm/Reflection/TypeHelper.cs | 19 +- Orm/Xtensive.Orm/Sorting/Node.cs | 5 +- Orm/Xtensive.Orm/Sorting/NodeConnection.cs | 6 +- Orm/Xtensive.Orm/Sorting/TopologicalSorter.cs | 20 +- Orm/Xtensive.Orm/Sql/Compiler/SqlCompiler.cs | 26 +- .../Compiler/SqlPostCompilerConfiguration.cs | 8 +- .../Dml/Collections/SqlColumnCollection.cs | 8 +- .../Sql/Dml/Expressions/SqlCase.cs | 8 +- .../Sql/Dml/Expressions/SqlCursor.cs | 4 +- .../Dml/Expressions/SqlCustomFunctionCall.cs | 2 +- .../Sql/Dml/Expressions/SqlDefaultValue.cs | 2 +- .../Sql/Dml/Expressions/SqlExpression.cs | 2 +- .../Sql/Dml/Expressions/SqlExpressionList.cs | 5 +- .../Sql/Dml/Expressions/SqlTableColumn.cs | 4 +- .../Sql/Dml/SqlCustomFunctionType.cs | 4 +- Orm/Xtensive.Orm/Sql/Dml/Statements/SqlIf.cs | 4 +- .../Sql/Dml/Statements/SqlWhile.cs | 2 +- Orm/Xtensive.Orm/Sql/Info/DataTypeInfo.cs | 4 +- Orm/Xtensive.Orm/Sql/Info/ServerInfo.cs | 3 +- .../Sql/Internals/SqlValidator.cs | 10 +- Orm/Xtensive.Orm/Sql/Model/Catalog.cs | 4 +- Orm/Xtensive.Orm/Sql/Model/CatalogNode.cs | 11 +- .../Model/Constraints/DefaultConstraint.cs | 3 +- Orm/Xtensive.Orm/Sql/Model/DataTableNode.cs | 3 +- Orm/Xtensive.Orm/Sql/Model/FullTextIndex.cs | 2 +- Orm/Xtensive.Orm/Sql/Model/Index.cs | 8 +- .../Sql/Model/PairedNodeCollection.cs | 10 +- Orm/Xtensive.Orm/Sql/Model/SchemaNode.cs | 3 +- Orm/Xtensive.Orm/Sql/Model/Sequence.cs | 4 +- Orm/Xtensive.Orm/Sql/SqlConnection.cs | 4 +- Orm/Xtensive.Orm/Sql/SqlDdl.cs | 225 ++++---- Orm/Xtensive.Orm/Sql/SqlDml.cs | 524 +++++++++--------- Orm/Xtensive.Orm/Sql/SqlDriver.cs | 22 +- Orm/Xtensive.Orm/Sql/SqlDriverFactory.cs | 15 +- Orm/Xtensive.Orm/Sql/SqlExtractionTask.cs | 12 +- Orm/Xtensive.Orm/Sql/SqlHelper.cs | 4 +- .../TypeMappingRegistryBuilder.cs | 5 +- Orm/Xtensive.Orm/Tuples/DifferentialTuple.cs | 5 +- .../Transform/Internals/MapTransformTuple.cs | 3 +- .../Tuples/Transform/MapTransform.cs | 9 +- .../Tuples/Transform/ReadOnlyTransform.cs | 2 +- .../Transform/WrappingTransformTupleBase.cs | 3 +- Orm/Xtensive.Orm/Tuples/Tuple.cs | 2 +- Orm/Xtensive.Orm/Tuples/TupleDescriptor.cs | 2 +- .../Tuples/TupleFormatExtensions.cs | 4 +- Orm/Xtensive.Orm/Tuples/TupleUpdater.cs | 5 +- 323 files changed, 1404 insertions(+), 1570 deletions(-) diff --git a/Extensions/Xtensive.Orm.Localization/Configuration/LocalizationConfiguration.cs b/Extensions/Xtensive.Orm.Localization/Configuration/LocalizationConfiguration.cs index 6b84a40dd..85bc6d95c 100644 --- a/Extensions/Xtensive.Orm.Localization/Configuration/LocalizationConfiguration.cs +++ b/Extensions/Xtensive.Orm.Localization/Configuration/LocalizationConfiguration.cs @@ -140,7 +140,7 @@ private static LocalizationConfiguration GetConfigurationFromSection(Configurati /// Loaded configuration or default configuration if loading failed for some reason. public static LocalizationConfiguration Load(IConfiguration configuration, string sectionName = null) { - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration); if (configuration is IConfigurationRoot configurationRoot) { return new LocalizationConfigurationReader().Read(configurationRoot, sectionName ?? DefaultSectionName); @@ -161,7 +161,7 @@ public static LocalizationConfiguration Load(IConfiguration configuration, strin /// Loaded configuration or default configuration if loading failed for some reason. public static LocalizationConfiguration Load(IConfigurationSection configurationSection) { - ArgumentValidator.EnsureArgumentNotNull(configurationSection, nameof(configurationSection)); + ArgumentNullException.ThrowIfNull(configurationSection); return new LocalizationConfigurationReader().Read(configurationSection); } @@ -175,7 +175,7 @@ public static LocalizationConfiguration Load(IConfigurationSection configuration /// Loaded configuration or default configuration if loading failed for some reason. public static LocalizationConfiguration Load(IConfigurationRoot configurationRoot, string sectionName = null) { - ArgumentValidator.EnsureArgumentNotNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot); return new LocalizationConfigurationReader().Read(configurationRoot, sectionName ?? DefaultSectionName); } diff --git a/Extensions/Xtensive.Orm.Localization/Internals/TypeLocalizationMap.cs b/Extensions/Xtensive.Orm.Localization/Internals/TypeLocalizationMap.cs index 2ac7db18c..2fdcf20b3 100644 --- a/Extensions/Xtensive.Orm.Localization/Internals/TypeLocalizationMap.cs +++ b/Extensions/Xtensive.Orm.Localization/Internals/TypeLocalizationMap.cs @@ -22,7 +22,7 @@ internal class TypeLocalizationMap public static void Initialize(Domain domain) { - ArgumentValidator.EnsureArgumentNotNull(domain, nameof(domain)); + ArgumentNullException.ThrowIfNull(domain); var existing = domain.Extensions.Get(); if (existing != null) { diff --git a/Extensions/Xtensive.Orm.Localization/LocalizationContext.cs b/Extensions/Xtensive.Orm.Localization/LocalizationContext.cs index 6944a8b21..4b1e76b91 100644 --- a/Extensions/Xtensive.Orm.Localization/LocalizationContext.cs +++ b/Extensions/Xtensive.Orm.Localization/LocalizationContext.cs @@ -77,8 +77,7 @@ public LocalizationContext(CultureInfo culture) /// public LocalizationContext(CultureInfo culture, LocalizationPolicy policy) { - ArgumentValidator.EnsureArgumentNotNull(culture, "culture"); - Culture = culture; + Culture = culture ?? throw new ArgumentNullException(nameof(culture)); CultureName = culture.Name; Policy = policy; } diff --git a/Extensions/Xtensive.Orm.Reprocessing/Configuration/ReprocessingConfiguration.cs b/Extensions/Xtensive.Orm.Reprocessing/Configuration/ReprocessingConfiguration.cs index 6e7adbc45..ae25d7e45 100644 --- a/Extensions/Xtensive.Orm.Reprocessing/Configuration/ReprocessingConfiguration.cs +++ b/Extensions/Xtensive.Orm.Reprocessing/Configuration/ReprocessingConfiguration.cs @@ -128,7 +128,7 @@ private static ReprocessingConfiguration GetConfigurationFromSection(Configurati /// Loaded configuration or configuration with default settings. public static ReprocessingConfiguration Load(IConfiguration configuration, string sectionName = null) { - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration); if (configuration is IConfigurationRoot configurationRoot) { return new ReprocessingConfigurationReader().Read(configurationRoot, sectionName ?? DefaultSectionName); @@ -149,7 +149,7 @@ public static ReprocessingConfiguration Load(IConfiguration configuration, strin /// Loaded configuration or configuration with default settings. public static ReprocessingConfiguration Load(IConfigurationRoot configurationRoot, string sectionName = null) { - ArgumentValidator.EnsureArgumentNotNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot); return new ReprocessingConfigurationReader().Read(configurationRoot, sectionName ?? DefaultSectionName); } @@ -161,7 +161,7 @@ public static ReprocessingConfiguration Load(IConfigurationRoot configurationRoo /// Loaded configuration or configuration with default settings. public static ReprocessingConfiguration Load(IConfigurationSection configurationSection) { - ArgumentValidator.EnsureArgumentNotNull(configurationSection, nameof(configurationSection)); + ArgumentNullException.ThrowIfNull(configurationSection); return new ReprocessingConfigurationReader().Read(configurationSection); } diff --git a/Extensions/Xtensive.Orm.Security/Configuration/SecurityConfiguration.cs b/Extensions/Xtensive.Orm.Security/Configuration/SecurityConfiguration.cs index 2ecd46f8c..43ecd54b9 100644 --- a/Extensions/Xtensive.Orm.Security/Configuration/SecurityConfiguration.cs +++ b/Extensions/Xtensive.Orm.Security/Configuration/SecurityConfiguration.cs @@ -140,7 +140,7 @@ private static SecurityConfiguration GetConfigurationFromSection(ConfigurationSe /// Loaded configuration or configuration with default settings. public static SecurityConfiguration Load(IConfiguration configuration, string sectionName = null) { - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration); if (configuration is IConfigurationRoot configurationRoot) { return Load(configurationRoot, sectionName); @@ -161,7 +161,7 @@ public static SecurityConfiguration Load(IConfiguration configuration, string se /// Loaded configuration or configuration with default settings. public static SecurityConfiguration Load(IConfigurationRoot configurationRoot, string sectionName = null) { - ArgumentValidator.EnsureArgumentNotNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot); var configuration = new NamelessFormatSecurityConfigurationReader().Read(configurationRoot, sectionName ?? DefaultSectionName); if (configuration != null) { @@ -179,7 +179,7 @@ public static SecurityConfiguration Load(IConfigurationRoot configurationRoot, s /// Loaded configuration or configuration with default settings. public static SecurityConfiguration Load(IConfigurationSection configurationSection) { - ArgumentValidator.EnsureArgumentNotNull(configurationSection, nameof(configurationSection)); + ArgumentNullException.ThrowIfNull(configurationSection); var configuration = new NamelessFormatSecurityConfigurationReader().Read(configurationSection); if (configuration != null) { diff --git a/Extensions/Xtensive.Orm.Security/ImpersonationContext.cs b/Extensions/Xtensive.Orm.Security/ImpersonationContext.cs index 2987438f6..3101fd7f2 100644 --- a/Extensions/Xtensive.Orm.Security/ImpersonationContext.cs +++ b/Extensions/Xtensive.Orm.Security/ImpersonationContext.cs @@ -1,4 +1,4 @@ -using System; +using System; using Xtensive.Core; namespace Xtensive.Orm.Security @@ -63,7 +63,7 @@ protected virtual void Dispose(bool disposing) public ImpersonationContext(IPrincipal principal, ImpersonationContext outerContext) : base(principal.Session) { - ArgumentValidator.EnsureArgumentNotNull(principal, "principal"); + ArgumentNullException.ThrowIfNull(principal); this.outerContext = outerContext; Principal = principal; diff --git a/Extensions/Xtensive.Orm.Security/Services/GenericAuthenticationService.cs b/Extensions/Xtensive.Orm.Security/Services/GenericAuthenticationService.cs index 719c83ac0..d8988f25d 100644 --- a/Extensions/Xtensive.Orm.Security/Services/GenericAuthenticationService.cs +++ b/Extensions/Xtensive.Orm.Security/Services/GenericAuthenticationService.cs @@ -22,7 +22,7 @@ public class GenericAuthenticationService : SessionBound, IAuthenticationService /// public IPrincipal Authenticate(IIdentity identity, params object[] args) { - ArgumentValidator.EnsureArgumentNotNull(identity, "identity"); + ArgumentNullException.ThrowIfNull(identity); ArgumentValidator.EnsureArgumentNotNullOrEmpty(identity.Name, "identity.Name"); return Authenticate(identity.Name, args); diff --git a/Extensions/Xtensive.Orm.Security/SessionExtensions.cs b/Extensions/Xtensive.Orm.Security/SessionExtensions.cs index 39f02e4c8..5478a7f7e 100644 --- a/Extensions/Xtensive.Orm.Security/SessionExtensions.cs +++ b/Extensions/Xtensive.Orm.Security/SessionExtensions.cs @@ -45,7 +45,7 @@ public static SecurityConfiguration GetSecurityConfiguration(this Session sessio /// instance. public static ImpersonationContext GetImpersonationContext(this Session session) { - ArgumentValidator.EnsureArgumentNotNull(session, "session"); + ArgumentNullException.ThrowIfNull(session); return session.Extensions.Get(); } @@ -58,8 +58,8 @@ public static ImpersonationContext GetImpersonationContext(this Session session) /// instance. public static ImpersonationContext Impersonate(this Session session, IPrincipal principal) { - ArgumentValidator.EnsureArgumentNotNull(session, "session"); - ArgumentValidator.EnsureArgumentNotNull(principal, "principal"); + ArgumentNullException.ThrowIfNull(session); + ArgumentNullException.ThrowIfNull(principal); var currentContext = session.GetImpersonationContext(); @@ -101,23 +101,23 @@ public static IPrincipal Authenticate(this Session session, string name, params private static void ClearImpersonationContext(this Session session) { - ArgumentValidator.EnsureArgumentNotNull(session, "session"); + ArgumentNullException.ThrowIfNull(session); session.Extensions.Set(null); } private static void SetImpersonationContext(this Session session, ImpersonationContext context) { - ArgumentValidator.EnsureArgumentNotNull(session, "session"); - ArgumentValidator.EnsureArgumentNotNull(context, "context"); + ArgumentNullException.ThrowIfNull(session); + ArgumentNullException.ThrowIfNull(context); session.Extensions.Set(context); } internal static void UndoImpersonation(this Session session, ImpersonationContext innerContext, ImpersonationContext outerContext) { - ArgumentValidator.EnsureArgumentNotNull(session, "session"); - ArgumentValidator.EnsureArgumentNotNull(innerContext, "innerContext"); + ArgumentNullException.ThrowIfNull(session); + ArgumentNullException.ThrowIfNull(innerContext); // outerContext can be null var currentContext = session.GetImpersonationContext(); diff --git a/Extensions/Xtensive.Orm.Tracking/Internals/TrackingStackFrame.cs b/Extensions/Xtensive.Orm.Tracking/Internals/TrackingStackFrame.cs index be2efa7bd..739d2c272 100644 --- a/Extensions/Xtensive.Orm.Tracking/Internals/TrackingStackFrame.cs +++ b/Extensions/Xtensive.Orm.Tracking/Internals/TrackingStackFrame.cs @@ -4,6 +4,7 @@ // Created by: Dmitri Maximov // Created: 2012.05.16 +using System; using System.Collections; using System.Collections.Generic; using Xtensive.Core; @@ -18,7 +19,7 @@ namespace Xtensive.Orm.Tracking public void Register(TrackingItem item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var key = item.Key; if (!items.TryGetValue(key, out var existing)) { diff --git a/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v2_5/Extractor.cs b/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v2_5/Extractor.cs index 764ef611b..4b4d68e7e 100644 --- a/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v2_5/Extractor.cs +++ b/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v2_5/Extractor.cs @@ -96,7 +96,7 @@ public override Task ExtractCatalogAsync(string catalogName, Cancellati public override Catalog ExtractSchemes(string catalogName, string[] schemaNames) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(catalogName, nameof(catalogName)); - ArgumentValidator.EnsureArgumentNotNull(schemaNames, nameof(schemaNames)); + ArgumentNullException.ThrowIfNull(schemaNames); var targetSchema = schemaNames.Length > 0 ? schemaNames[0] : null; var catalog = new Catalog(catalogName); @@ -109,7 +109,7 @@ public override async Task ExtractSchemesAsync( string catalogName, string[] schemaNames, CancellationToken token = default) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(catalogName, nameof(catalogName)); - ArgumentValidator.EnsureArgumentNotNull(schemaNames, nameof(schemaNames)); + ArgumentNullException.ThrowIfNull(schemaNames); var targetSchema = schemaNames.Length > 0 ? schemaNames[0] : null; var catalog = new Catalog(catalogName); diff --git a/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v3_0/Extractor.cs b/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v3_0/Extractor.cs index 128b6fb38..1abf63836 100644 --- a/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v3_0/Extractor.cs +++ b/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v3_0/Extractor.cs @@ -95,7 +95,7 @@ public override Task ExtractCatalogAsync(string catalogName, Cancellati public override Catalog ExtractSchemes(string catalogName, string[] schemaNames) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(catalogName, nameof(catalogName)); - ArgumentValidator.EnsureArgumentNotNull(schemaNames, nameof(schemaNames)); + ArgumentNullException.ThrowIfNull(schemaNames); var targetSchema = schemaNames.Length > 0 ? schemaNames[0] : null; var catalog = new Catalog(catalogName); @@ -108,7 +108,7 @@ public override async Task ExtractSchemesAsync( string catalogName, string[] schemaNames, CancellationToken token = default) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(catalogName, nameof(catalogName)); - ArgumentValidator.EnsureArgumentNotNull(schemaNames, nameof(schemaNames)); + ArgumentNullException.ThrowIfNull(schemaNames); var targetSchema = schemaNames.Length > 0 ? schemaNames[0] : null; var catalog = new Catalog(catalogName); diff --git a/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v4_0/Extractor.cs b/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v4_0/Extractor.cs index 51cd4f4c1..3c4447770 100644 --- a/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v4_0/Extractor.cs +++ b/Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v4_0/Extractor.cs @@ -95,7 +95,7 @@ public override Task ExtractCatalogAsync(string catalogName, Cancellati public override Catalog ExtractSchemes(string catalogName, string[] schemaNames) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(catalogName, nameof(catalogName)); - ArgumentValidator.EnsureArgumentNotNull(schemaNames, nameof(schemaNames)); + ArgumentNullException.ThrowIfNull(schemaNames); var targetSchema = schemaNames.Length > 0 ? schemaNames[0] : null; var catalog = new Catalog(catalogName); @@ -108,7 +108,7 @@ public override async Task ExtractSchemesAsync( string catalogName, string[] schemaNames, CancellationToken token = default) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(catalogName, nameof(catalogName)); - ArgumentValidator.EnsureArgumentNotNull(schemaNames, nameof(schemaNames)); + ArgumentNullException.ThrowIfNull(schemaNames); var targetSchema = schemaNames.Length > 0 ? schemaNames[0] : null; var catalog = new Catalog(catalogName); diff --git a/Orm/Xtensive.Orm.PostgreSql/Orm.Providers.PostgreSql/PostgresqlSqlDml.cs b/Orm/Xtensive.Orm.PostgreSql/Orm.Providers.PostgreSql/PostgresqlSqlDml.cs index 174ba4dfe..2a530e46b 100644 --- a/Orm/Xtensive.Orm.PostgreSql/Orm.Providers.PostgreSql/PostgresqlSqlDml.cs +++ b/Orm/Xtensive.Orm.PostgreSql/Orm.Providers.PostgreSql/PostgresqlSqlDml.cs @@ -4,6 +4,7 @@ // Created by: Alena Mikshina // Created: 2014.05.06; +using System; using Xtensive.Core; using Xtensive.Sql; using Xtensive.Sql.Dml; @@ -22,7 +23,7 @@ public class PostgresqlSqlDml /// public static SqlExpression DecimalTrimScale(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, nameof(operand)); + ArgumentNullException.ThrowIfNull(operand); return SqlDml.FunctionCall("TRIM_SCALE", operand); } @@ -35,8 +36,8 @@ public static SqlExpression DecimalTrimScale(SqlExpression operand) /// public static SqlExpression NpgsqlTypeExtractPoint(SqlExpression operand, SqlExpression pointIndex) { - ArgumentValidator.EnsureArgumentNotNull(operand, nameof(operand)); - ArgumentValidator.EnsureArgumentNotNull(pointIndex, nameof(pointIndex)); + ArgumentNullException.ThrowIfNull(operand); + ArgumentNullException.ThrowIfNull(pointIndex); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlTypeExtractPoint, operand, pointIndex); } @@ -46,8 +47,8 @@ public static SqlExpression NpgsqlTypeExtractPoint(SqlExpression operand, SqlExp /// public static SqlExpression NpgsqlTypeOperatorEquality(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlTypeOperatorEquality, left, right); } @@ -58,8 +59,8 @@ public static SqlExpression NpgsqlTypeOperatorEquality(SqlExpression left, SqlEx /// public static SqlExpression NpgsqlPointConstructor(SqlExpression x, SqlExpression y) { - ArgumentValidator.EnsureArgumentNotNull(x, "x"); - ArgumentValidator.EnsureArgumentNotNull(y, "y"); + ArgumentNullException.ThrowIfNull(x); + ArgumentNullException.ThrowIfNull(y); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlPointConstructor, x, y); } @@ -68,7 +69,7 @@ public static SqlExpression NpgsqlPointConstructor(SqlExpression x, SqlExpressio /// public static SqlExpression NpgsqlPointExtractX(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlPointExtractX, operand); } @@ -77,7 +78,7 @@ public static SqlExpression NpgsqlPointExtractX(SqlExpression operand) /// public static SqlExpression NpgsqlPointExtractY(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlPointExtractY, operand); } @@ -92,8 +93,8 @@ public static SqlExpression NpgsqlPointExtractY(SqlExpression operand) /// An for the "point'(x2,y2)'" representing the lower left corner of the box. public static SqlExpression NpgsqlBoxConstructor(SqlExpression upperRight, SqlExpression lowerLeft) { - ArgumentValidator.EnsureArgumentNotNull(upperRight, "upperRight"); - ArgumentValidator.EnsureArgumentNotNull(lowerLeft, "lowerLeft"); + ArgumentNullException.ThrowIfNull(upperRight); + ArgumentNullException.ThrowIfNull(lowerLeft); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlBoxConstructor, upperRight, lowerLeft); } @@ -102,7 +103,7 @@ public static SqlExpression NpgsqlBoxConstructor(SqlExpression upperRight, SqlEx /// public static SqlExpression NpgsqlBoxExtractHeight(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlBoxExtractHeight, operand); } @@ -111,7 +112,7 @@ public static SqlExpression NpgsqlBoxExtractHeight(SqlExpression operand) /// public static SqlExpression NpgsqlBoxExtractWidth(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlBoxExtractWidth, operand); } @@ -127,8 +128,8 @@ public static SqlExpression NpgsqlBoxExtractWidth(SqlExpression operand) /// public static SqlExpression NpgsqlCircleConstructor(SqlExpression center, SqlExpression radius) { - ArgumentValidator.EnsureArgumentNotNull(center, "center"); - ArgumentValidator.EnsureArgumentNotNull(radius, "radius"); + ArgumentNullException.ThrowIfNull(center); + ArgumentNullException.ThrowIfNull(radius); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlCircleConstructor, center, radius); } @@ -138,7 +139,7 @@ public static SqlExpression NpgsqlCircleConstructor(SqlExpression center, SqlExp /// public static SqlExpression NpgsqlCircleExtractCenter(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlCircleExtractCenter, operand); } @@ -148,7 +149,7 @@ public static SqlExpression NpgsqlCircleExtractCenter(SqlExpression operand) /// public static SqlExpression NpgsqlCircleExtractRadius(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlCircleExtractRadius, operand); } @@ -163,8 +164,8 @@ public static SqlExpression NpgsqlCircleExtractRadius(SqlExpression operand) /// An for the "point'(x2,y2)'" representing ending point of the segment. public static SqlExpression NpgsqlLSegConstructor(SqlExpression start, SqlExpression end) { - ArgumentValidator.EnsureArgumentNotNull(start, "start"); - ArgumentValidator.EnsureArgumentNotNull(end, "end"); + ArgumentNullException.ThrowIfNull(start); + ArgumentNullException.ThrowIfNull(end); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlLSegConstructor, start, end); } @@ -178,7 +179,7 @@ public static SqlExpression NpgsqlLSegConstructor(SqlExpression start, SqlExpres /// public static SqlExpression NpgsqlPathAndPolygonCount(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlPathAndPolygonCount, operand); } @@ -188,7 +189,7 @@ public static SqlExpression NpgsqlPathAndPolygonCount(SqlExpression operand) /// public static SqlExpression NpgsqlPathAndPolygonOpen(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlPathAndPolygonOpen, operand); } @@ -198,8 +199,8 @@ public static SqlExpression NpgsqlPathAndPolygonOpen(SqlExpression operand) /// public static SqlExpression NpgsqlPathAndPolygonContains(SqlExpression operand, SqlExpression point) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); - ArgumentValidator.EnsureArgumentNotNull(point, "point"); + ArgumentNullException.ThrowIfNull(operand); + ArgumentNullException.ThrowIfNull(point); return new SqlCustomFunctionCall(PostgresqlSqlFunctionType.NpgsqlPathAndPolygonContains, operand, point); } diff --git a/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/ErrorMessageParser.cs b/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/ErrorMessageParser.cs index db6693774..95bb5c59e 100644 --- a/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/ErrorMessageParser.cs +++ b/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/ErrorMessageParser.cs @@ -47,9 +47,10 @@ public PreparedTemplate(string regex, IReadOnlyList indexes) /// All placeholder values taken from message with their position numbers. public Dictionary Parse(int code, string message) { - ArgumentValidator.EnsureArgumentNotNull(message, "message"); - PreparedTemplate template; - if (!templates.TryGetValue(code, out template)) + ArgumentNullException.ThrowIfNull(message); + ArgumentNullException.ThrowIfNull(message); + + if (!templates.TryGetValue(code, out var template)) throw new InvalidOperationException(string.Format(Strings.ExNoMessageTemplateIsRegisteredForCodeX, code)); // Fill result with empty string for each expected index for more simple API var result = template.Indexes.ToDictionary(index => index, index => string.Empty); @@ -78,7 +79,7 @@ public Dictionary Parse(int code, string message) /// otherwise original . public static string ExtractQuotedText(string text) { - ArgumentValidator.EnsureArgumentNotNull(text, "text"); + ArgumentNullException.ThrowIfNull(text); var quoted = ExtractQuotedText(text, '\''); return quoted==text ? ExtractQuotedText(text, '"') : quoted; } @@ -91,7 +92,7 @@ public static string ExtractQuotedText(string text) /// with schema prefix removed. public static string CutSchemaPrefix(string table) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); + ArgumentNullException.ThrowIfNull(table); return CutPrefix(table); } @@ -103,7 +104,7 @@ public static string CutSchemaPrefix(string table) /// with database and schema prefix removed. public static string CutDatabaseAndSchemaPrefix(string table) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); + ArgumentNullException.ThrowIfNull(table); return CutPrefix(CutPrefix(table)); } @@ -240,7 +241,7 @@ public ErrorMessageParser() /// Indicates whether the provided are in English. public ErrorMessageParser(IEnumerable> messageTemplates, bool isEnglish) { - ArgumentValidator.EnsureArgumentNotNull(messageTemplates, "messageTemplates"); + ArgumentNullException.ThrowIfNull(messageTemplates); templates = isEnglish ? messageTemplates.ToDictionary(item => item.Key, item => PrepareEnglishTemplate(item.Value)) : messageTemplates.ToDictionary(item => item.Key, item => PrepareNonEnglishTemplate(item.Value)); diff --git a/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/InternalHelpers.cs b/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/InternalHelpers.cs index bc767a3c2..0af5cf609 100644 --- a/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/InternalHelpers.cs +++ b/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/InternalHelpers.cs @@ -32,7 +32,7 @@ internal static class InternalHelpers /// public static bool ShouldRetryOn(Exception ex) { - ArgumentValidator.EnsureArgumentNotNull(ex, "ex"); + ArgumentNullException.ThrowIfNull(ex); if (ex is SqlException sqlException) { foreach (SqlError err in sqlException.Errors) { switch (err.Number) { diff --git a/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v09/Extractor.cs b/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v09/Extractor.cs index 8453dcaec..41422eb06 100644 --- a/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v09/Extractor.cs +++ b/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v09/Extractor.cs @@ -53,8 +53,8 @@ public string PerformReplacements(string rawQueryText) public ExtractionContext(Catalog catalog, IReadOnlyCollection targetSchemas) { - ArgumentValidator.EnsureArgumentNotNull(catalog, nameof(catalog)); - ArgumentValidator.EnsureArgumentNotNull(targetSchemas, nameof(targetSchemas)); + ArgumentNullException.ThrowIfNull(catalog); + ArgumentNullException.ThrowIfNull(targetSchemas); Catalog = catalog; TargetSchemas = targetSchemas; diff --git a/Orm/Xtensive.Orm.Tests.Core/Modelling/IndexingModel/TypeInfo.cs b/Orm/Xtensive.Orm.Tests.Core/Modelling/IndexingModel/TypeInfo.cs index 435407435..9fd0c3101 100644 --- a/Orm/Xtensive.Orm.Tests.Core/Modelling/IndexingModel/TypeInfo.cs +++ b/Orm/Xtensive.Orm.Tests.Core/Modelling/IndexingModel/TypeInfo.cs @@ -188,7 +188,7 @@ public TypeInfo(Type type, int length, int scale, int precision) public TypeInfo(Type type, bool isNullable) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); if (isNullable && type.IsValueType && !type.IsNullable()) ArgumentValidator.EnsureArgumentIsInRange(true, false, false, "isNullable"); Type = type; @@ -205,7 +205,7 @@ public TypeInfo(Type type, bool isNullable, int length) public TypeInfo(Type type, bool isNullable, int length, CultureInfo culture) : this(type, isNullable, length) { - ArgumentValidator.EnsureArgumentNotNull(culture, "culture"); + ArgumentNullException.ThrowIfNull(culture); Culture = culture; } diff --git a/Orm/Xtensive.Orm.Tests.Core/Reflection/DelegateHelperCreateDelegateTest.cs b/Orm/Xtensive.Orm.Tests.Core/Reflection/DelegateHelperCreateDelegateTest.cs index 596505b3e..9116e071e 100644 --- a/Orm/Xtensive.Orm.Tests.Core/Reflection/DelegateHelperCreateDelegateTest.cs +++ b/Orm/Xtensive.Orm.Tests.Core/Reflection/DelegateHelperCreateDelegateTest.cs @@ -132,7 +132,7 @@ private static void LogicTest(Type[] types, object callTarget, Type type, string public static IEnumerable Reverse(IList list) { - ArgumentValidator.EnsureArgumentNotNull(list, "list"); + ArgumentNullException.ThrowIfNull(list); for (int i = list.Count-1; i>=0; i--) yield return list[i]; } diff --git a/Orm/Xtensive.Orm.Tests.Core/Tuples/DummyTuple.cs b/Orm/Xtensive.Orm.Tests.Core/Tuples/DummyTuple.cs index 6a0997aa8..a82e35f3f 100644 --- a/Orm/Xtensive.Orm.Tests.Core/Tuples/DummyTuple.cs +++ b/Orm/Xtensive.Orm.Tests.Core/Tuples/DummyTuple.cs @@ -81,7 +81,7 @@ public override void SetValue(int fieldIndex, object fieldValue) public DummyTuple(TupleDescriptor descriptor) { - ArgumentValidator.EnsureArgumentNotNull(descriptor, "descriptor"); + ArgumentNullException.ThrowIfNull(descriptor); this.descriptor = descriptor; values = new object[descriptor.Count]; available = new BitArray(new bool[descriptor.Count]); diff --git a/Orm/Xtensive.Orm.Tests.Framework/Internals/InstanceGeneratorBase.cs b/Orm/Xtensive.Orm.Tests.Framework/Internals/InstanceGeneratorBase.cs index d51ce30d3..107244d5e 100644 --- a/Orm/Xtensive.Orm.Tests.Framework/Internals/InstanceGeneratorBase.cs +++ b/Orm/Xtensive.Orm.Tests.Framework/Internals/InstanceGeneratorBase.cs @@ -64,7 +64,7 @@ IEnumerable IInstanceGeneratorBase.GetInstances(Random random, int? count) /// Instance generator provider this generator is bound to. public InstanceGeneratorBase(IInstanceGeneratorProvider provider) { - ArgumentValidator.EnsureArgumentNotNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(provider); this.provider = provider; } diff --git a/Orm/Xtensive.Orm.Tests.Framework/TestSqlDriver.cs b/Orm/Xtensive.Orm.Tests.Framework/TestSqlDriver.cs index ad793b3d9..18ab54ba4 100644 --- a/Orm/Xtensive.Orm.Tests.Framework/TestSqlDriver.cs +++ b/Orm/Xtensive.Orm.Tests.Framework/TestSqlDriver.cs @@ -18,7 +18,7 @@ public static class TestSqlDriver public static SqlDriver Create(UrlInfo connectionUrl) { - ArgumentValidator.EnsureArgumentNotNull(connectionUrl, "connectionUrl"); + ArgumentNullException.ThrowIfNull(connectionUrl); return BuildDriver(new ConnectionInfo(connectionUrl)); } @@ -37,7 +37,7 @@ public static SqlDriver Create(string provider, string connectionString) public static SqlDriver Create(ConnectionInfo connectionInfo) { - ArgumentValidator.EnsureArgumentNotNull(connectionInfo, "connectionInfo"); + ArgumentNullException.ThrowIfNull(connectionInfo); return BuildDriver(connectionInfo); } diff --git a/Orm/Xtensive.Orm.Tests/Linq/FullTextColumnsDeclarationTest.cs b/Orm/Xtensive.Orm.Tests/Linq/FullTextColumnsDeclarationTest.cs index 0bc5c38bc..9a3954d7d 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/FullTextColumnsDeclarationTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/FullTextColumnsDeclarationTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -103,7 +103,7 @@ private void RunQuery(Expression>[] columns) private Expression>[] MakeUpColumns(Expression> column, params Expression>[] additionalColumns) where T : Entity { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); + ArgumentNullException.ThrowIfNull(column); var columns = new List>>(); columns.Add(column); if (additionalColumns!=null) { diff --git a/Orm/Xtensive.Orm/Arithmetic/ArithmeticBase.cs b/Orm/Xtensive.Orm/Arithmetic/ArithmeticBase.cs index 22819604e..dbe159dfc 100644 --- a/Orm/Xtensive.Orm/Arithmetic/ArithmeticBase.cs +++ b/Orm/Xtensive.Orm/Arithmetic/ArithmeticBase.cs @@ -117,8 +117,7 @@ public Arithmetic ApplyRules(ArithmeticRules rules) /// Arithmetic rules. public ArithmeticBase(IArithmeticProvider provider, ArithmeticRules rules) { - ArgumentValidator.EnsureArgumentNotNull(provider, "provider"); - this.provider = provider; + this.provider = provider ?? throw new ArgumentNullException(nameof(provider)); Rules = rules; OverflowAllowed = (rules.OverflowBehavior==OverflowBehavior.AllowOverflow); NullIsZero = (rules.NullBehavior==NullBehavior.ThreatNullAsZero); diff --git a/Orm/Xtensive.Orm/Arithmetic/WrappingArithmetic{T,TBase}.cs b/Orm/Xtensive.Orm/Arithmetic/WrappingArithmetic{T,TBase}.cs index 3aee2b519..8f2933728 100644 --- a/Orm/Xtensive.Orm/Arithmetic/WrappingArithmetic{T,TBase}.cs +++ b/Orm/Xtensive.Orm/Arithmetic/WrappingArithmetic{T,TBase}.cs @@ -34,7 +34,7 @@ public abstract class WrappingArithmetic : ArithmeticBase public WrappingArithmetic(IArithmeticProvider provider, ArithmeticRules rules) : base(provider, rules) { - ArgumentValidator.EnsureArgumentNotNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(provider, "provider"); BaseArithmetic = provider.GetArithmetic(); } } diff --git a/Orm/Xtensive.Orm/Caching/CacheBase.cs b/Orm/Xtensive.Orm/Caching/CacheBase.cs index bdcc5f7d4..ffe20a3a4 100755 --- a/Orm/Xtensive.Orm/Caching/CacheBase.cs +++ b/Orm/Xtensive.Orm/Caching/CacheBase.cs @@ -39,7 +39,7 @@ public abstract class CacheBase : ICache /// public virtual void Remove(TItem item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); RemoveKey(KeyExtractor(item)); } diff --git a/Orm/Xtensive.Orm/Caching/FastConcurrentLruCache{TKey, TItem}.cs b/Orm/Xtensive.Orm/Caching/FastConcurrentLruCache{TKey, TItem}.cs index 5fcd8e86b..4521555bf 100755 --- a/Orm/Xtensive.Orm/Caching/FastConcurrentLruCache{TKey, TItem}.cs +++ b/Orm/Xtensive.Orm/Caching/FastConcurrentLruCache{TKey, TItem}.cs @@ -40,7 +40,7 @@ public class FastConcurrentLruCache : /// public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); var key = KeyExtractor(item); if (replaceIfExists) { realCache.AddOrUpdate(key, item); diff --git a/Orm/Xtensive.Orm/Caching/InfiniteCache.cs b/Orm/Xtensive.Orm/Caching/InfiniteCache.cs index d44904cf1..33238c0cb 100644 --- a/Orm/Xtensive.Orm/Caching/InfiniteCache.cs +++ b/Orm/Xtensive.Orm/Caching/InfiniteCache.cs @@ -53,7 +53,7 @@ public override bool ContainsKey(TKey key) /// public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); var key = KeyExtractor(item); TItem cachedItem; @@ -114,7 +114,7 @@ public InfiniteCache(Converter keyExtractor) /// capacity is out of range. public InfiniteCache(int capacity, Converter keyExtractor) { - ArgumentValidator.EnsureArgumentNotNull(keyExtractor, "keyExtractor"); + ArgumentNullException.ThrowIfNull(keyExtractor, "keyExtractor"); if (capacity < 0) throw new ArgumentOutOfRangeException("capacity", capacity, Strings.ExArgumentValueMustBeGreaterThanOrEqualToZero); this.KeyExtractor = keyExtractor; diff --git a/Orm/Xtensive.Orm/Caching/Interfaces/ICache.cs b/Orm/Xtensive.Orm/Caching/Interfaces/ICache.cs index d9aa76a80..5255e9a06 100644 --- a/Orm/Xtensive.Orm/Caching/Interfaces/ICache.cs +++ b/Orm/Xtensive.Orm/Caching/Interfaces/ICache.cs @@ -92,7 +92,7 @@ public interface ICache : IEnumerable, IInvalidatable /// The item to remove. void Remove(TItem item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); RemoveKey(KeyExtractor(item)); } diff --git a/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem, TCached}.cs b/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem, TCached}.cs index 4ab9bd12b..822047a30 100644 --- a/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem, TCached}.cs +++ b/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem, TCached}.cs @@ -113,7 +113,7 @@ public override bool ContainsKey(TKey key) /// public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); var key = KeyExtractor(item); TCached cached = cacheConverter.ConvertForward(item); TCached oldCached; @@ -243,9 +243,9 @@ public LruCache(long maxSize, Converter keyExtractor, { if (maxSize <= 0) ArgumentValidator.EnsureArgumentIsInRange(maxSize, 1, long.MaxValue, "maxSize"); - ArgumentValidator.EnsureArgumentNotNull(keyExtractor, "keyExtractor"); + this.maxSize = maxSize; - this.KeyExtractor = keyExtractor; + this.KeyExtractor = keyExtractor ?? throw new ArgumentNullException(nameof(keyExtractor)); this.cacheConverter = cacheConverter; this.chainedCache = chainedCache; // deque = new TopDeque(1 + (int) maxSize); diff --git a/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem}.cs b/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem}.cs index a0e06a916..50280e220 100644 --- a/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem}.cs +++ b/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem}.cs @@ -106,7 +106,7 @@ public override bool ContainsKey(TKey key) /// public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); var key = KeyExtractor(item); var cached = new KeyValuePair(key, item); KeyValuePair oldCached; @@ -236,11 +236,9 @@ public LruCache(long maxSize, Converter keyExtractor, { if (maxSize <= 0) ArgumentValidator.EnsureArgumentIsInRange(maxSize, 1, long.MaxValue, "maxSize"); - ArgumentValidator.EnsureArgumentNotNull(keyExtractor, "keyExtractor"); - ArgumentValidator.EnsureArgumentNotNull(sizeExtractor, "sizeExtractor"); this.maxSize = maxSize; - this.KeyExtractor = keyExtractor; - this.sizeExtractor = sizeExtractor; + this.KeyExtractor = keyExtractor ?? throw new ArgumentNullException(nameof(keyExtractor)); + this.sizeExtractor = sizeExtractor ?? throw new ArgumentNullException(nameof(sizeExtractor)); this.chainedCache = chainedCache; // deque = new TopDeque>(1 + (int) maxSize); deque = new TopDeque>(); diff --git a/Orm/Xtensive.Orm/Caching/MfLruCache.cs b/Orm/Xtensive.Orm/Caching/MfLruCache.cs index c220da06f..7a256b96b 100644 --- a/Orm/Xtensive.Orm/Caching/MfLruCache.cs +++ b/Orm/Xtensive.Orm/Caching/MfLruCache.cs @@ -153,7 +153,7 @@ public override bool ContainsKey(TKey key) /// public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); OnOperation2(); var key = KeyExtractor(item); CachedItem cached; @@ -409,14 +409,14 @@ public MfLruCache(int lruCapacity, int mfuCapacity, int efficiencyFactor, ArgumentValidator.EnsureArgumentIsInRange(lruCapacity , 1, int.MaxValue, "lruCapacity"); if (mfuCapacity < 0) ArgumentValidator.EnsureArgumentIsInRange(lruCapacity , 0, int.MaxValue, "mfuCapacity"); - ArgumentValidator.EnsureArgumentNotNull(keyExtractor, "keyExtractor"); + this.lruCapacity = lruCapacity; this.mfuCapacity = mfuCapacity; capacity = lruCapacity + mfuCapacity; this.efficiencyFactor = efficiencyFactor; if (efficiencyFactor<0) timeShift = -efficiencyFactor-1; // Constant timeShift is defined - this.KeyExtractor = keyExtractor; + this.KeyExtractor = keyExtractor ?? throw new ArgumentNullException(nameof(keyExtractor)); this.chainedCache = chainedCache; // items = new Dictionary(1 + capacity); items = new Dictionary(); diff --git a/Orm/Xtensive.Orm/Caching/WeakCache.cs b/Orm/Xtensive.Orm/Caching/WeakCache.cs index 0f4596956..ec1b2b570 100644 --- a/Orm/Xtensive.Orm/Caching/WeakCache.cs +++ b/Orm/Xtensive.Orm/Caching/WeakCache.cs @@ -87,7 +87,7 @@ public override bool TryGetItem(TKey key, bool markAsHit, out TItem item) [SecuritySafeCritical] public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentValidator.EnsureArgumentNotNull(item, nameof(item)); + ArgumentNullException.ThrowIfNull(item, nameof(item)); RegisterOperation(2); var key = KeyExtractor(item); if (items == null) { @@ -225,9 +225,8 @@ private void RegisterOperation(int weight) /// property value. public WeakCache(bool trackResurrection, Converter keyExtractor) { - ArgumentValidator.EnsureArgumentNotNull(keyExtractor, "keyExtractor"); this.trackResurrection = trackResurrection; - this.KeyExtractor = keyExtractor; + this.KeyExtractor = keyExtractor ?? throw new ArgumentNullException(nameof(keyExtractor)); } // Dispose pattern diff --git a/Orm/Xtensive.Orm/Caching/WeakestCache.cs b/Orm/Xtensive.Orm/Caching/WeakestCache.cs index f544c1649..a8e8cab41 100644 --- a/Orm/Xtensive.Orm/Caching/WeakestCache.cs +++ b/Orm/Xtensive.Orm/Caching/WeakestCache.cs @@ -210,9 +210,9 @@ public override bool ContainsKey(TKey key) [SecuritySafeCritical] public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); var key = KeyExtractor(item); - ArgumentValidator.EnsureArgumentNotNull(key, "KeyExtractor.Invoke(item)"); + ArgumentNullException.ThrowIfNull(key, "KeyExtractor.Invoke(item)"); RegisterOperation(4); WeakEntry entry; if (items.TryGetValue(key, out entry)) { @@ -235,7 +235,7 @@ public override TItem Add(TItem item, bool replaceIfExists) [SecuritySafeCritical] public override void RemoveKey(TKey key) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); + ArgumentNullException.ThrowIfNull(key, "key"); if (items.Remove(key, out var entry)) { entry.Dispose(); } @@ -360,10 +360,9 @@ private TItem GetItemByKeyInternal(TKey key, bool markAsHit) /// property value. public WeakestCache(bool trackKeyResurrection, bool trackItemResurrection, Converter keyExtractor) { - ArgumentValidator.EnsureArgumentNotNull(keyExtractor, "keyExtractor"); this.trackKeyResurrection = trackKeyResurrection; this.trackItemResurrection = trackItemResurrection; - this.KeyExtractor = keyExtractor; + this.KeyExtractor = keyExtractor ?? throw new ArgumentNullException(nameof(keyExtractor)); items = new Dictionary(1024, new WeakEntryEqualityComparer()); } diff --git a/Orm/Xtensive.Orm/Collections/ChainedBuffer.cs b/Orm/Xtensive.Orm/Collections/ChainedBuffer.cs index fffd5b397..a3884b8bf 100644 --- a/Orm/Xtensive.Orm/Collections/ChainedBuffer.cs +++ b/Orm/Xtensive.Orm/Collections/ChainedBuffer.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2020 Xtensive LLC. +// Copyright (C) 2013-2020 Xtensive LLC. // This code is distributed under MIT license terms. // See the License.txt file in the project root for more information. // Created by: Alena Mikshina @@ -116,7 +116,7 @@ public bool Contains(T item) /// public void CopyTo(T[] array, int arrayIndex) { - ArgumentValidator.EnsureArgumentNotNull(array, "array"); + ArgumentNullException.ThrowIfNull(array, "array"); ArgumentValidator.EnsureArgumentIsInRange(arrayIndex, 0, int.MaxValue, "arrayIndex"); if (array.Length < totalItemCount + arrayIndex) @@ -135,7 +135,7 @@ public bool Remove(T item) /// public void AddRange(IEnumerable items) { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); + ArgumentNullException.ThrowIfNull(items, "items"); foreach (var item in items) Add(item); } diff --git a/Orm/Xtensive.Orm/Collections/Deque.cs b/Orm/Xtensive.Orm/Collections/Deque.cs index 6b8a4f2ba..8845a8ce5 100644 --- a/Orm/Xtensive.Orm/Collections/Deque.cs +++ b/Orm/Xtensive.Orm/Collections/Deque.cs @@ -6,6 +6,7 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Runtime.Serialization; using System.Security; using System.Security.Permissions; @@ -271,7 +272,7 @@ public bool Contains(T item) /// public void CopyTo(T[] array, int arrayIndex) { - ArgumentValidator.EnsureArgumentNotNull(array, "array"); + ArgumentNullException.ThrowIfNull(array, "array"); array.EnsureIndexIsValid(arrayIndex); if (arrayIndex + count > array.Length) @@ -282,7 +283,7 @@ public void CopyTo(T[] array, int arrayIndex) /// public void CopyTo(Array array, int index) { - ArgumentValidator.EnsureArgumentNotNull(array, "array"); + ArgumentNullException.ThrowIfNull(array, "array"); array.EnsureIndexIsValid(index); if (array.Rank!=1) @@ -389,9 +390,6 @@ public void RemoveRange(int index, int count) ArgumentValidator.EnsureArgumentIsInRange(index, 0, this.count-1, "index"); ArgumentValidator.EnsureArgumentIsInRange(count, 0, this.count-index, "count"); - if (count < 0 || (count > this.count - index)) - throw new ArgumentOutOfRangeException("count"); - int bufferIndex = ConvertToBufferIndex(index); if (this.count > 0) { int tailLength = this.count - count - index; diff --git a/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs b/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs index 86219ddf9..4ba5718e1 100644 --- a/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs +++ b/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs @@ -39,7 +39,7 @@ public static IEnumerable One(TItem value) /// starting from the one. public static IEnumerable Unfold(TItem first, Func next) { - ArgumentValidator.EnsureArgumentNotNull(next, "next"); + ArgumentNullException.ThrowIfNull(next, "next"); var current = first; while (current!=null) { yield return current; @@ -62,7 +62,7 @@ public static IEnumerable Unfold(TItem first, Func n /// public static IEnumerable Unfold(TItem first, Func include, Func next) { - ArgumentValidator.EnsureArgumentNotNull(next, "next"); + ArgumentNullException.ThrowIfNull(next, "next"); var current = first; while (include.Invoke(current)) { yield return current; diff --git a/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs b/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs index 57a62944a..18a1de2a5 100644 --- a/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs +++ b/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs @@ -45,7 +45,7 @@ public T Get() /// public object Get(Type extensionType) { - ArgumentValidator.EnsureArgumentNotNull(extensionType, "extensionType"); + ArgumentNullException.ThrowIfNull(extensionType, "extensionType"); if (extensions==null) return null; object result; @@ -68,7 +68,7 @@ public void Set(T value) public void Set(Type extensionType, object value) { EnsureNotLocked(); - ArgumentValidator.EnsureArgumentNotNull(extensionType, "extensionType"); + ArgumentNullException.ThrowIfNull(extensionType, "extensionType"); if (extensionType.IsValueType) throw new ArgumentException(string.Format( Strings.ExTypeXMustBeReferenceType, extensionType.GetShortName()), "extensionType"); @@ -153,7 +153,7 @@ public ExtensionCollection() public ExtensionCollection(IExtensionCollection source) : this() { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); if (source.Count==0) return; if (source is ExtensionCollection sourceLikeMe) { diff --git a/Orm/Xtensive.Orm/Collections/Graphs/Edge.cs b/Orm/Xtensive.Orm/Collections/Graphs/Edge.cs index dea53bd5b..4fa7d59ff 100644 --- a/Orm/Xtensive.Orm/Collections/Graphs/Edge.cs +++ b/Orm/Xtensive.Orm/Collections/Graphs/Edge.cs @@ -80,10 +80,8 @@ public Edge() /// Target node. public Edge(Node source, Node target) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(target, "target"); - Source = source; - Target = target; + Source = source ?? throw new ArgumentNullException(nameof(source)); + Target = target ?? throw new ArgumentNullException(nameof(target)); Attach(); } } diff --git a/Orm/Xtensive.Orm/Collections/Graphs/Graph.cs b/Orm/Xtensive.Orm/Collections/Graphs/Graph.cs index 4d476f797..343a029a2 100644 --- a/Orm/Xtensive.Orm/Collections/Graphs/Graph.cs +++ b/Orm/Xtensive.Orm/Collections/Graphs/Graph.cs @@ -72,7 +72,7 @@ public Graph, Edge> CreateMutableCopy() /// Otherwise is must return null. public void AddEdges(Func connector) { - ArgumentValidator.EnsureArgumentNotNull(connector, "connector"); + ArgumentNullException.ThrowIfNull(connector, "connector"); foreach (var source in Nodes) foreach (var target in Nodes) { var edge = connector.Invoke(source, target); diff --git a/Orm/Xtensive.Orm/Collections/Graphs/TopologicalSorter.cs b/Orm/Xtensive.Orm/Collections/Graphs/TopologicalSorter.cs index 2468332ca..02116dd8f 100644 --- a/Orm/Xtensive.Orm/Collections/Graphs/TopologicalSorter.cs +++ b/Orm/Xtensive.Orm/Collections/Graphs/TopologicalSorter.cs @@ -80,7 +80,7 @@ public static TopologicalSortResult Sort(Graph(); diff --git a/Orm/Xtensive.Orm/Collections/TypeRegistration.cs b/Orm/Xtensive.Orm/Collections/TypeRegistration.cs index 0190877de..69bceb65f 100644 --- a/Orm/Xtensive.Orm/Collections/TypeRegistration.cs +++ b/Orm/Xtensive.Orm/Collections/TypeRegistration.cs @@ -102,8 +102,7 @@ public override int GetHashCode() /// The type to register. public TypeRegistration(Type type) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); - this.type = type; + this.type = type ?? throw new ArgumentNullException(nameof(type)); } /// @@ -112,8 +111,7 @@ public TypeRegistration(Type type) /// The assembly to register. public TypeRegistration(Assembly assembly) { - ArgumentValidator.EnsureArgumentNotNull(assembly, "assembly"); - this.assembly = assembly; + this.assembly = assembly ?? throw new ArgumentNullException(nameof(assembly)); } /// @@ -124,8 +122,7 @@ public TypeRegistration(Assembly assembly) public TypeRegistration(Assembly assembly, string @namespace) : this(assembly) { - ArgumentValidator.EnsureArgumentNotNull(@namespace, "@namespace"); - this.@namespace = @namespace; + this.@namespace = @namespace ?? throw new ArgumentNullException(nameof(@namespace)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs b/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs index fafe28746..8fe3c6f17 100644 --- a/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs +++ b/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs @@ -67,8 +67,8 @@ protected virtual bool IsAcceptable(TypeRegistration registration, Type type) private static IList FindTypes(Assembly assembly, Type baseType, TypeFilter filter) { - ArgumentValidator.EnsureArgumentNotNull(assembly, "assembly"); - ArgumentValidator.EnsureArgumentNotNull(baseType, "baseType"); + ArgumentNullException.ThrowIfNull(assembly, "assembly"); + ArgumentNullException.ThrowIfNull(baseType, "baseType"); Type[] allTypes; try { diff --git a/Orm/Xtensive.Orm/Collections/TypeRegistry.cs b/Orm/Xtensive.Orm/Collections/TypeRegistry.cs index 91603f6be..18e0c8218 100644 --- a/Orm/Xtensive.Orm/Collections/TypeRegistry.cs +++ b/Orm/Xtensive.Orm/Collections/TypeRegistry.cs @@ -58,7 +58,7 @@ public bool Contains(Type type) public void Register(Type type) { EnsureNotLocked(); - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type, "type"); if (!isProcessingPendingActions) Register(new TypeRegistration(type)); else if (typeSet.Add(type)) { @@ -79,7 +79,7 @@ public void Register(Type type) public void Register(Assembly assembly) { EnsureNotLocked(); - ArgumentValidator.EnsureArgumentNotNull(assembly, "assembly"); + ArgumentNullException.ThrowIfNull(assembly, "assembly"); Register(new TypeRegistration(assembly)); } @@ -96,7 +96,7 @@ public void Register(Assembly assembly) public void Register(Assembly assembly, string @namespace) { EnsureNotLocked(); - ArgumentValidator.EnsureArgumentNotNull(assembly, "assembly"); + ArgumentNullException.ThrowIfNull(assembly, "assembly"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(@namespace, "@namespace"); Register(new TypeRegistration(assembly, @namespace)); } @@ -110,7 +110,7 @@ public void Register(Assembly assembly, string @namespace) public bool Register(TypeRegistration action) { EnsureNotLocked(); - ArgumentValidator.EnsureArgumentNotNull(action, "action"); + ArgumentNullException.ThrowIfNull(action, "action"); if (actionSet.Contains(action)) return false; actionSet.Add(action); @@ -198,8 +198,7 @@ public int Count /// The registry action processor. public TypeRegistry(ITypeRegistrationProcessor processor) { - ArgumentValidator.EnsureArgumentNotNull(processor, "processor"); - this.processor = processor; + this.processor = processor ?? throw new ArgumentNullException(nameof(processor)); } /// diff --git a/Orm/Xtensive.Orm/Comparison/AdvancedComparer.cs b/Orm/Xtensive.Orm/Comparison/AdvancedComparer.cs index 1aa4688be..829176e32 100644 --- a/Orm/Xtensive.Orm/Comparison/AdvancedComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/AdvancedComparer.cs @@ -132,7 +132,7 @@ public AdvancedComparer Cast() public AdvancedComparer(IAdvancedComparer implementation) : this(implementation, implementation, implementation) { - ArgumentValidator.EnsureArgumentNotNull(implementation, "implementation"); + ArgumentNullException.ThrowIfNull(implementation, "implementation"); } /// diff --git a/Orm/Xtensive.Orm/Comparison/AdvancedComparerBase.cs b/Orm/Xtensive.Orm/Comparison/AdvancedComparerBase.cs index d435561c8..d6c01121a 100644 --- a/Orm/Xtensive.Orm/Comparison/AdvancedComparerBase.cs +++ b/Orm/Xtensive.Orm/Comparison/AdvancedComparerBase.cs @@ -154,12 +154,11 @@ public AdvancedComparer Cast() /// Comparison rules. public AdvancedComparerBase(IComparerProvider provider, ComparisonRules comparisonRules) { - ArgumentValidator.EnsureArgumentNotNull(provider, "provider"); valueRangeInfo = new ValueRangeInfo( false, default(T), false, default(T), false, default(T)); - this.provider = provider; + this.provider = provider ?? throw new ArgumentNullException(nameof(provider)); ComparisonRules = comparisonRules; DefaultDirectionMultiplier = comparisonRules.Value.Direction == Direction.Negative ? -1 : 1; } diff --git a/Orm/Xtensive.Orm/Comparison/ComparisonRules.cs b/Orm/Xtensive.Orm/Comparison/ComparisonRules.cs index f72e43309..6f4cb4793 100644 --- a/Orm/Xtensive.Orm/Comparison/ComparisonRules.cs +++ b/Orm/Xtensive.Orm/Comparison/ComparisonRules.cs @@ -289,7 +289,7 @@ public ComparisonRules(ComparisonRule value, ComparisonRules[] composite, Compar { if (value.Direction==Direction.None) throw Exceptions.InvalidArgument(value.Direction, "value.Direction"); - ArgumentValidator.EnsureArgumentNotNull(tail, "tail"); + ArgumentNullException.ThrowIfNull(tail, "tail"); this.value = value; if (composite!=null) { int tailIndex = composite.Length-1; diff --git a/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase1,TBase2}.cs b/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase1,TBase2}.cs index 70dcb6260..1ee86594b 100644 --- a/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase1,TBase2}.cs +++ b/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase1,TBase2}.cs @@ -41,7 +41,7 @@ public abstract class WrappingComparer: AdvancedComparerBase< public WrappingComparer(IComparerProvider provider, ComparisonRules comparisonRules) : base(provider, comparisonRules) { - ArgumentValidator.EnsureArgumentNotNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(provider, "provider"); BaseComparer1 = provider.GetComparer().ApplyRules(comparisonRules[0]); BaseComparer2 = provider.GetComparer().ApplyRules(comparisonRules[1]); } diff --git a/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase}.cs b/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase}.cs index 9b802f23a..d436c2fd3 100644 --- a/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase}.cs +++ b/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase}.cs @@ -37,7 +37,7 @@ public abstract class WrappingComparer : AdvancedComparerBase public WrappingComparer(IComparerProvider provider, ComparisonRules comparisonRules) : base(provider, comparisonRules) { - ArgumentValidator.EnsureArgumentNotNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(provider, "provider"); BaseComparer = provider.GetComparer().ApplyRules(comparisonRules); } diff --git a/Orm/Xtensive.Orm/Conversion/AdvancedConverterBase.cs b/Orm/Xtensive.Orm/Conversion/AdvancedConverterBase.cs index e42ed05a7..e9a9f65bc 100644 --- a/Orm/Xtensive.Orm/Conversion/AdvancedConverterBase.cs +++ b/Orm/Xtensive.Orm/Conversion/AdvancedConverterBase.cs @@ -38,8 +38,7 @@ public IAdvancedConverterProvider Provider /// The provider this advanced converter is bound to. public AdvancedConverterBase(IAdvancedConverterProvider provider) { - ArgumentValidator.EnsureArgumentNotNull(provider, "provider"); - this.provider = provider; + this.provider = provider ?? throw new ArgumentNullException(nameof(provider)); } /// diff --git a/Orm/Xtensive.Orm/Conversion/ConvertingEnumerable.cs b/Orm/Xtensive.Orm/Conversion/ConvertingEnumerable.cs index f533c0028..6f9eaa526 100644 --- a/Orm/Xtensive.Orm/Conversion/ConvertingEnumerable.cs +++ b/Orm/Xtensive.Orm/Conversion/ConvertingEnumerable.cs @@ -50,10 +50,8 @@ IEnumerator IEnumerable.GetEnumerator() /// Item converter to use. public ConvertingEnumerable(IEnumerable innerEnumerable, Converter converter) { - ArgumentValidator.EnsureArgumentNotNull(innerEnumerable, "innerEnumerable"); - ArgumentValidator.EnsureArgumentNotNull(converter, "converter"); - this.innerEnumerable = innerEnumerable; - this.converter = converter; + this.innerEnumerable = innerEnumerable ?? throw new ArgumentNullException(nameof(innerEnumerable)); + this.converter = converter ?? throw new ArgumentNullException(nameof(converter)); } } diff --git a/Orm/Xtensive.Orm/Conversion/Internals/ConvertingEnumerator.cs b/Orm/Xtensive.Orm/Conversion/Internals/ConvertingEnumerator.cs index f68f5dc51..19e88478c 100644 --- a/Orm/Xtensive.Orm/Conversion/Internals/ConvertingEnumerator.cs +++ b/Orm/Xtensive.Orm/Conversion/Internals/ConvertingEnumerator.cs @@ -62,10 +62,8 @@ public void Reset() /// The converter. public ConvertingEnumerator(IEnumerator innerEnumerator, Converter converter) { - ArgumentValidator.EnsureArgumentNotNull(innerEnumerator, "innerEnumerator"); - ArgumentValidator.EnsureArgumentNotNull(converter, "converter"); - this.innerEnumerator = innerEnumerator; - this.converter = converter; + this.innerEnumerator = innerEnumerator ?? throw new ArgumentNullException(nameof(innerEnumerator)); + this.converter = converter ?? throw new ArgumentNullException(nameof(converter)); } diff --git a/Orm/Xtensive.Orm/Conversion/Internals/NullableForwardAdvancedConverter.cs b/Orm/Xtensive.Orm/Conversion/Internals/NullableForwardAdvancedConverter.cs index 4bca7a5c8..78d199253 100644 --- a/Orm/Xtensive.Orm/Conversion/Internals/NullableForwardAdvancedConverter.cs +++ b/Orm/Xtensive.Orm/Conversion/Internals/NullableForwardAdvancedConverter.cs @@ -18,7 +18,7 @@ internal class NullableForwardAdvancedConverter : WrappingAdvancedCo public override TTo Convert(TFrom? value) { if (toIsValueType && !value.HasValue) - throw new ArgumentNullException("value"); + throw new ArgumentNullException(nameof(value)); return BaseConverter.Convert(value.GetValueOrDefault()); } diff --git a/Orm/Xtensive.Orm/Core/ArgumentValidator.cs b/Orm/Xtensive.Orm/Core/ArgumentValidator.cs index d8da37ab0..f6e3b7c59 100644 --- a/Orm/Xtensive.Orm/Core/ArgumentValidator.cs +++ b/Orm/Xtensive.Orm/Core/ArgumentValidator.cs @@ -24,6 +24,7 @@ public static class ArgumentValidator /// Value to compare with . /// Name of the method parameter. [MethodImpl(MethodImplOptions.AggressiveInlining)] + [Obsolete("Use ArgumentNullException.ThrowIfNull() instead")] public static void EnsureArgumentNotNull(object value, [InvokerParameterName] string parameterName) { if (value==null) { @@ -99,7 +100,7 @@ public static T EnsureArgumentIs(object value, if (value is T result) { return result; } - EnsureArgumentNotNull(value, parameterName); + ArgumentNullException.ThrowIfNull(value, parameterName); throw new ArgumentException(string.Format(Strings.ExInvalidArgumentType, typeof(T)), parameterName); } @@ -113,7 +114,7 @@ public static T EnsureArgumentIs(object value, [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void EnsureArgumentIs(object value, Type type, [InvokerParameterName] string parameterName) { - EnsureArgumentNotNull(value, parameterName); + ArgumentNullException.ThrowIfNull(value, parameterName); if (!type.IsInstanceOfType(value)) { throw new ArgumentException(string.Format(Strings.ExInvalidArgumentType, type), parameterName); } diff --git a/Orm/Xtensive.Orm/Core/AsyncFutureResult.cs b/Orm/Xtensive.Orm/Core/AsyncFutureResult.cs index c48216f33..c1fd18000 100644 --- a/Orm/Xtensive.Orm/Core/AsyncFutureResult.cs +++ b/Orm/Xtensive.Orm/Core/AsyncFutureResult.cs @@ -75,7 +75,7 @@ public override async ValueTask DisposeAsync() public AsyncFutureResult(Func worker, BaseLog logger) { - ArgumentValidator.EnsureArgumentNotNull(worker, nameof(worker)); + ArgumentNullException.ThrowIfNull(worker, nameof(worker)); this.logger = logger; @@ -84,7 +84,7 @@ public AsyncFutureResult(Func worker, BaseLog logger) public AsyncFutureResult(Func> worker, BaseLog logger, bool startWorker) { - ArgumentValidator.EnsureArgumentNotNull(worker, nameof(worker)); + ArgumentNullException.ThrowIfNull(worker, nameof(worker)); this.logger = logger; diff --git a/Orm/Xtensive.Orm/Core/DisposableSet.cs b/Orm/Xtensive.Orm/Core/DisposableSet.cs index 0b2e88ee0..919c9ed1e 100644 --- a/Orm/Xtensive.Orm/Core/DisposableSet.cs +++ b/Orm/Xtensive.Orm/Core/DisposableSet.cs @@ -85,7 +85,7 @@ private void EnsureInitialized() public DisposableSet(IEnumerable initialContent) : this() { - ArgumentValidator.EnsureArgumentNotNull(initialContent, "initialContent"); + ArgumentNullException.ThrowIfNull(initialContent, "initialContent"); foreach (object o in initialContent) Add(o as IDisposable); } diff --git a/Orm/Xtensive.Orm/Core/Exceptions.cs b/Orm/Xtensive.Orm/Core/Exceptions.cs index 18a80be3a..b13be2234 100644 --- a/Orm/Xtensive.Orm/Core/Exceptions.cs +++ b/Orm/Xtensive.Orm/Core/Exceptions.cs @@ -163,8 +163,8 @@ public static Exception CollectionHasBeenChanged([InvokerParameterName] string p /// Newly created exception. public static InvalidOperationException ContextRequired(Type contextType, Type scopeType) { - ArgumentValidator.EnsureArgumentNotNull(contextType, "contextType"); - ArgumentValidator.EnsureArgumentNotNull(scopeType, "scopeType"); + ArgumentNullException.ThrowIfNull(contextType, "contextType"); + ArgumentNullException.ThrowIfNull(scopeType, "scopeType"); return new InvalidOperationException( string.Format(Strings.ExContextRequired, contextType.GetShortName(), scopeType.GetShortName())); } @@ -189,7 +189,7 @@ public static InvalidOperationException ContextRequired() /// Newly created exception. public static InvalidOperationException ScopeRequired(Type scopeType) { - ArgumentValidator.EnsureArgumentNotNull(scopeType, "scopeType"); + ArgumentNullException.ThrowIfNull(scopeType, "scopeType"); return new InvalidOperationException( string.Format(Strings.ExScopeRequired, scopeType.GetShortName())); } @@ -212,7 +212,7 @@ public static InvalidOperationException ScopeRequired() /// Newly created exception. public static InvalidOperationException LambdaParameterIsOutOfScope(ParameterExpression parameter) { - ArgumentValidator.EnsureArgumentNotNull(parameter, "parameter"); + ArgumentNullException.ThrowIfNull(parameter, "parameter"); return new InvalidOperationException(string.Format(Strings.ExLambdaParameterXIsOutOfScope, parameter.Name)); } } diff --git a/Orm/Xtensive.Orm/Core/Extensions/ArrayExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/ArrayExtensions.cs index 6bcfc1710..a51859794 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/ArrayExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/ArrayExtensions.cs @@ -46,7 +46,7 @@ public static TNewItem[] Cast(this TItem[] source) /// An array of converted elements. public static TNewItem[] Convert(this TItem[] source, Converter converter) { - ArgumentValidator.EnsureArgumentNotNull(converter, "converter"); + ArgumentNullException.ThrowIfNull(converter, "converter"); var items = new TNewItem[source.Length]; int i = 0; foreach (TItem item in source) @@ -69,7 +69,7 @@ public static TNewItem[] Convert(this TItem[] source, Converter /// public static int IndexOf(this TItem[] items, TItem item) { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); + ArgumentNullException.ThrowIfNull(items, "items"); for (int i = 0; i < items.Length; i++) if (AdvancedComparerStruct.System.Equals(item, items[i])) return i; @@ -86,7 +86,7 @@ public static int IndexOf(this TItem[] items, TItem item) /// An enumerable iterating through the segment. public static IEnumerable Segment(this TItem[] items, int offset, int length) { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); + ArgumentNullException.ThrowIfNull(items, "items"); int lastIndex = offset + length; if (offset<0) offset = 0; @@ -114,7 +114,7 @@ public static IEnumerable Segment(this TItem[] items, int offset, /// Value type is passed instead of class. public static int IndexOf(this TItem[] items, TItem item, bool byReference) { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); + ArgumentNullException.ThrowIfNull(items, "items"); if (!byReference) return IndexOf(items, item); if (typeof(TItem).IsValueType) diff --git a/Orm/Xtensive.Orm/Core/Extensions/CollectionExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/CollectionExtensions.cs index 8a34b071c..b2c57db0e 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/CollectionExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/CollectionExtensions.cs @@ -43,8 +43,8 @@ public static TItem[] ToArray(this ICollection source) /// Destination array is too small. public static void Copy(this ICollection source, TItem[] target, int targetIndex) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(target, "target"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(target, "target"); if (targetIndex < 0 || targetIndex > target.Length) throw new ArgumentOutOfRangeException("targetIndex"); if ((target.Length - targetIndex) < source.Count) @@ -67,8 +67,8 @@ public static void Copy(this ICollection source, TItem[] target, i /// Destination array is too small or multidimensional. public static void Copy(this ICollection source, Array target, int targetIndex) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(target, "target"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(target, "target"); if (targetIndex < 0 || targetIndex > target.Length) throw new ArgumentOutOfRangeException("targetIndex"); if ((target.Length - targetIndex) < source.Count) @@ -208,9 +208,9 @@ public static List SelectToList( internal static Pair SelectToArrays( this ICollection source, Func firstArraySelector, Func secondArraySelector) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(firstArraySelector, nameof(firstArraySelector)); - ArgumentValidator.EnsureArgumentNotNull(secondArraySelector, nameof(secondArraySelector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(firstArraySelector, nameof(firstArraySelector)); + ArgumentNullException.ThrowIfNull(secondArraySelector, nameof(secondArraySelector)); var first = new TFirst[source.Count]; var second = new TSecond[source.Count]; diff --git a/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs index 7367d34c9..575e4086a 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs @@ -131,7 +131,7 @@ public static void ForEach(this IEnumerable items, Action action) /// all the items from the sequence. public static ChainedBuffer ToChainedBuffer(this IEnumerable source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); return new ChainedBuffer(source); } @@ -146,8 +146,8 @@ public static ChainedBuffer ToChainedBuffer(this IEnumerable source) /// A sequence of converted elements. public static IEnumerable Convert(this IEnumerable source, Converter converter) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(converter, "converter"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(converter, "converter"); foreach (TItem item in source) yield return converter(item); } @@ -377,9 +377,9 @@ public static Dictionary ToDictionary( IEqualityComparer comparer, int capacity) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(keySelector, nameof(keySelector)); - ArgumentValidator.EnsureArgumentNotNull(elementSelector, nameof(elementSelector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(keySelector, nameof(keySelector)); + ArgumentNullException.ThrowIfNull(elementSelector, nameof(elementSelector)); ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(capacity, 0, nameof(capacity)); var dictionary = comparer != null @@ -574,8 +574,8 @@ public static bool AtMost(this IEnumerable sequence, int numberOfE /// Topologically sorted if no cycles exist, otherwise null. public static List SortTopologically(this IEnumerable values, Func edgeTester) { - ArgumentValidator.EnsureArgumentNotNull(values, "values"); - ArgumentValidator.EnsureArgumentNotNull(edgeTester, "edgeTester"); + ArgumentNullException.ThrowIfNull(values, "values"); + ArgumentNullException.ThrowIfNull(edgeTester, "edgeTester"); var graph = new Graph, Edge>(); graph.Nodes.AddRange(values.Select(p => new Node(p))); diff --git a/Orm/Xtensive.Orm/Core/Extensions/ExpressionExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/ExpressionExtensions.cs index 2196f55ff..c1492d155 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/ExpressionExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/ExpressionExtensions.cs @@ -55,7 +55,7 @@ public static string ToString(this Expression expression, bool inCSharpNotation) /// public static bool IsNull(this Expression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); if (expression.NodeType==ExpressionType.Constant) { var constantExpression = (ConstantExpression) expression; return constantExpression.Value==null; @@ -166,7 +166,7 @@ public static Type GetReturnType(this LambdaExpression lambda) /// The root node of expression isn't of type. public static MemberInfo GetMember(this Expression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); expression = expression.StripLambda().StripCasts(); var me = expression as MemberExpression; if (me==null) @@ -215,7 +215,7 @@ public static PropertyInfo GetProperty(this Expression expression) /// Expression must reference event. public static MethodInfo GetMethod(this Expression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); expression = expression.StripLambda().StripCasts(); var mce = expression as MethodCallExpression; if (mce==null) @@ -232,7 +232,7 @@ public static MethodInfo GetMethod(this Expression expression) /// Expression must reference event. public static PropertyInfo GetIndexer(this Expression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); expression = expression.StripLambda().StripCasts(); var ie = expression as IndexExpression; if (ie==null) @@ -249,7 +249,7 @@ public static PropertyInfo GetIndexer(this Expression expression) /// Expression must reference event. public static ConstructorInfo GetConstructor(this Expression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); expression = expression.StripLambda().StripCasts(); var ne = expression as NewExpression; if (ne==null) diff --git a/Orm/Xtensive.Orm/Core/Extensions/HasServicesExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/HasServicesExtensions.cs index 4e65fb95e..ae8fc3967 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/HasServicesExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/HasServicesExtensions.cs @@ -32,7 +32,7 @@ public static class HasServicesExtensions public static T GetService(this IHasServices serviceProvider, bool failIfNone) where T: class { - ArgumentValidator.EnsureArgumentNotNull(serviceProvider, "serviceProvider"); + ArgumentNullException.ThrowIfNull(serviceProvider, "serviceProvider"); var service = serviceProvider.GetService(); if (failIfNone && service == null) throw new InvalidOperationException( diff --git a/Orm/Xtensive.Orm/Core/Extensions/ListExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/ListExtensions.cs index d50fdcb84..3a31a6f2b 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/ListExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/ListExtensions.cs @@ -52,9 +52,9 @@ public static int IndexOf(this IReadOnlyList list, T item) /// Destination array is too small. public static void Copy(this IList source, TItem[] target, int targetIndex) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(target, "target"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(target, "target"); if (targetIndex < 0 || targetIndex > target.Length) throw new ArgumentOutOfRangeException("targetIndex"); if ((target.Length - targetIndex) < source.Count) @@ -78,8 +78,8 @@ public static void Copy(this IList source, TItem[] target, int tar /// Destination array is too small or multidimensional. public static void Copy(this IList source, Array target, int targetIndex) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(target, "target"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(target, "target"); if (targetIndex < 0 || targetIndex > target.Length) throw new ArgumentOutOfRangeException("targetIndex"); if ((target.Length - targetIndex) < source.Count) diff --git a/Orm/Xtensive.Orm/Core/Extensions/StringBuilderExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/StringBuilderExtensions.cs index 741b692b6..9d137e0d3 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/StringBuilderExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/StringBuilderExtensions.cs @@ -76,8 +76,8 @@ public static StringBuilder AppendIndented(this StringBuilder builder, int inden /// Original . public static StringBuilder AppendHexArray(this StringBuilder builder, byte[] values) { - ArgumentValidator.EnsureArgumentNotNull(builder, "builder"); - ArgumentValidator.EnsureArgumentNotNull(values, "values"); + ArgumentNullException.ThrowIfNull(builder, "builder"); + ArgumentNullException.ThrowIfNull(values, "values"); const string lowerHexChars = "0123456789abcdef"; foreach (var item in values) { @@ -97,7 +97,7 @@ public static StringBuilder AppendHexArray(this StringBuilder builder, byte[] va /// Original . public static StringBuilder AppendHexArray(this StringBuilder builder, in ReadOnlySpan values) { - ArgumentValidator.EnsureArgumentNotNull(builder, "builder"); + ArgumentNullException.ThrowIfNull(builder, "builder"); const string lowerHexChars = "0123456789abcdef"; foreach (var item in values) { diff --git a/Orm/Xtensive.Orm/Core/Extensions/StringExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/StringExtensions.cs index 9548948a0..7467a8bb5 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/StringExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/StringExtensions.cs @@ -94,7 +94,7 @@ public static string Indent(this string value, int indentSize) /// Indented . public static string Indent(this string value, int indentSize, bool indentFirstLine) { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); var indent = new string(' ', indentSize); var sb = new ValueStringBuilder(stackalloc char[4096]); if (indentFirstLine) @@ -202,7 +202,7 @@ public static bool GreaterThanOrEqual(this string x, string y) /// ==. public static string RevertibleJoin(this IEnumerable source, char escape, char delimiter) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); if (escape==delimiter) throw new ArgumentException( Strings.ExEscapeCharacterMustDifferFromDelimiterCharacter); @@ -239,7 +239,7 @@ public static string RevertibleJoin(this IEnumerable source, char escape /// ==. public static IEnumerable RevertibleSplit(this string source, char escape, char delimiter) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); if (escape==delimiter) throw new ArgumentException( Strings.ExEscapeCharacterMustDifferFromDelimiterCharacter); @@ -278,7 +278,7 @@ public static IEnumerable RevertibleSplit(this string source, char escap /// ==. public static Pair RevertibleSplitFirstAndTail(this string source, char escape, char delimiter) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); if (escape==delimiter) throw new ArgumentException( Strings.ExEscapeCharacterMustDifferFromDelimiterCharacter); @@ -310,10 +310,9 @@ public static Pair RevertibleSplitFirstAndTail(this string source, char /// Chars to escape. public static string Escape(this string source, char escape, char[] escapedChars) { - if (source==null) - throw new ArgumentNullException("source"); - if (escapedChars==null) - throw new ArgumentNullException("escapedChars"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(escapedChars); + var chars = escapedChars.Append(escape); var sb = new ValueStringBuilder(stackalloc char[4096]); foreach (var c in source) { @@ -334,8 +333,8 @@ public static string Escape(this string source, char escape, char[] escapedChars /// The escape char. public static string Unescape(this string source, char escape) { - if (source==null) - throw new ArgumentNullException("source"); + ArgumentNullException.ThrowIfNull(source); + var sb = new ValueStringBuilder(source.Length); var previousCharIsEscape = false; foreach (var c in source) { @@ -361,8 +360,8 @@ public static string Unescape(this string source, char escape) /// public static bool Like(this string value, string sqlLikePattern) { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); - ArgumentValidator.EnsureArgumentNotNull(sqlLikePattern, "sqlLikePattern"); + ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(sqlLikePattern, "sqlLikePattern"); var regexPattern = Regex.Replace(sqlLikePattern, @"[%_]|[^%_]+", match => { @@ -388,8 +387,8 @@ public static bool Like(this string value, string sqlLikePattern) /// public static bool Like(this string value, string sqlLikePattern, char escapeCharacter) { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); - ArgumentValidator.EnsureArgumentNotNull(sqlLikePattern, "sqlLikePattern"); + ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(sqlLikePattern, "sqlLikePattern"); const string regExSpecialChars = @"[]\/^$.|?*+(){}"; if(char.IsControl(escapeCharacter)) @@ -438,8 +437,8 @@ public static string StripRoundBrackets(this string value) internal static bool Contains(this string str, string value, StringComparison comparison) { - ArgumentValidator.EnsureArgumentNotNull(str, nameof(str)); - ArgumentValidator.EnsureArgumentNotNull(value, nameof(value)); + ArgumentNullException.ThrowIfNull(str, nameof(str)); + ArgumentNullException.ThrowIfNull(value, nameof(value)); return str.IndexOf(value, comparison) >= 0; } diff --git a/Orm/Xtensive.Orm/Core/Parameter.cs b/Orm/Xtensive.Orm/Core/Parameter.cs index 76d2b3cba..b41e1b067 100644 --- a/Orm/Xtensive.Orm/Core/Parameter.cs +++ b/Orm/Xtensive.Orm/Core/Parameter.cs @@ -4,6 +4,7 @@ // Created by: Alex Kofman // Created: 2008.08.14 +using System; using System.Diagnostics; @@ -31,8 +32,7 @@ public abstract class Parameter [DebuggerStepThrough] protected Parameter(string name) { - ArgumentValidator.EnsureArgumentNotNull(name, nameof(name)); - Name = name; + Name = name ?? throw new ArgumentNullException(nameof(name)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Core/SimpleXmlSerializer.cs b/Orm/Xtensive.Orm/Core/SimpleXmlSerializer.cs index 9a8e50c4f..2b24b6928 100644 --- a/Orm/Xtensive.Orm/Core/SimpleXmlSerializer.cs +++ b/Orm/Xtensive.Orm/Core/SimpleXmlSerializer.cs @@ -1,9 +1,10 @@ -// Copyright (C) 2013 Xtensive LLC +// Copyright (C) 2013 Xtensive LLC // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov // Created: 2013.07.18 +using System; using System.IO; using System.Xml.Serialization; @@ -24,7 +25,7 @@ public sealed class SimpleXmlSerializer /// Deserialized instance. public T Deserialize(string value) { - ArgumentValidator.EnsureArgumentNotNull(value, "serialized"); + ArgumentNullException.ThrowIfNull(value, "serialized"); using (var reader = new StringReader(value)) return (T) serializer.Deserialize(reader); @@ -37,7 +38,7 @@ public T Deserialize(string value) /// Serialized instance. public string Serialize(T value) { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); using (var writer = new StringWriter()) { serializer.Serialize(writer, value); diff --git a/Orm/Xtensive.Orm/Core/SynchronousFutureResult.cs b/Orm/Xtensive.Orm/Core/SynchronousFutureResult.cs index b517a8cef..717ac7fc5 100644 --- a/Orm/Xtensive.Orm/Core/SynchronousFutureResult.cs +++ b/Orm/Xtensive.Orm/Core/SynchronousFutureResult.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2020 Xtensive LLC. +// Copyright (C) 2014-2020 Xtensive LLC. // This code is distributed under MIT license terms. // See the License.txt file in the project root for more information. // Created by: Denis Krjuchkov @@ -38,9 +38,7 @@ public override void Dispose() public SynchronousFutureResult(Func worker) { - ArgumentValidator.EnsureArgumentNotNull(worker, nameof(worker)); - - this.worker = worker; + this.worker = worker ?? throw new ArgumentNullException(nameof(worker)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/IoC/ServiceContainer.cs b/Orm/Xtensive.Orm/IoC/ServiceContainer.cs index 50575b5f0..6a86dff9e 100644 --- a/Orm/Xtensive.Orm/IoC/ServiceContainer.cs +++ b/Orm/Xtensive.Orm/IoC/ServiceContainer.cs @@ -202,7 +202,7 @@ public static IServiceContainer Create(Type containerType, object configuration) /// Wrong container type. public static IServiceContainer Create(Type containerType, object configuration, IServiceContainer parent) { - ArgumentValidator.EnsureArgumentNotNull(containerType, "containerType"); + ArgumentNullException.ThrowIfNull(containerType, "containerType"); if (!iServiceContainerType.IsAssignableFrom(containerType)) throw new ArgumentException(string.Format( Strings.ExContainerTypeMustImplementX, iServiceContainerType.Name), "containerType"); diff --git a/Orm/Xtensive.Orm/IoC/ServiceRegistration.cs b/Orm/Xtensive.Orm/IoC/ServiceRegistration.cs index 230b08031..d2e02530e 100644 --- a/Orm/Xtensive.Orm/IoC/ServiceRegistration.cs +++ b/Orm/Xtensive.Orm/IoC/ServiceRegistration.cs @@ -81,7 +81,7 @@ public static ServiceRegistration[] CreateAll(Type type, bool defaultOnly) => private static Lazy ServiceRegistrationsExtractorImpl(ServiceRegistrationKey key) => new Lazy(() => { (var type, var defaultOnly) = key; - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type, "type"); if (type.IsAbstract) { return Array.Empty(); } diff --git a/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs b/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs index 95e29d2bf..1a96e58e9 100644 --- a/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs +++ b/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs @@ -104,8 +104,7 @@ public ConstantExtractor(LambdaExpression lambda) /// public ConstantExtractor(LambdaExpression lambda, Func constantFilter) { - ArgumentValidator.EnsureArgumentNotNull(lambda, "lambda"); - this.lambda = lambda; + this.lambda = lambda ?? throw new ArgumentNullException(nameof(lambda)); this.constantFilter = constantFilter ?? DefaultConstantFilter; } } diff --git a/Orm/Xtensive.Orm/Linq/ExpressionTree.cs b/Orm/Xtensive.Orm/Linq/ExpressionTree.cs index 5b8e03464..d09567e3d 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionTree.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionTree.cs @@ -114,8 +114,7 @@ public static int GetHashCode(Expression expression) internal ExpressionTree(Expression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); - this.expression = expression; + this.expression = expression ?? throw new ArgumentNullException(nameof(expression)); hashCode = new ExpressionHashCodeCalculator().CalculateHashCode(expression); } } diff --git a/Orm/Xtensive.Orm/Linq/Internals/ExpressionHashCodeCalculator.cs b/Orm/Xtensive.Orm/Linq/Internals/ExpressionHashCodeCalculator.cs index e1386eae5..585946a67 100644 --- a/Orm/Xtensive.Orm/Linq/Internals/ExpressionHashCodeCalculator.cs +++ b/Orm/Xtensive.Orm/Linq/Internals/ExpressionHashCodeCalculator.cs @@ -20,7 +20,7 @@ internal sealed class ExpressionHashCodeCalculator : ExpressionVisitor public int CalculateHashCode(Expression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); try { return Visit(expression); } diff --git a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ReflectionExtensions.cs b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ReflectionExtensions.cs index e10da7298..433eea61d 100644 --- a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ReflectionExtensions.cs +++ b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ReflectionExtensions.cs @@ -88,7 +88,7 @@ public static ConstructorInfo GetConstructorFromSerializableForm(this string ser public static void AddArray(this SerializationInfo info, string key, T[] array) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(key, "key"); - ArgumentValidator.EnsureArgumentNotNull(array, "array"); + ArgumentNullException.ThrowIfNull(array, "array"); info.AddValue($"{key}Count", array.Length); for (int i = 0; i < array.Length; i++) diff --git a/Orm/Xtensive.Orm/Modelling/Actions/ActionSequence.cs b/Orm/Xtensive.Orm/Modelling/Actions/ActionSequence.cs index a64e5389c..234258f6b 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/ActionSequence.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/ActionSequence.cs @@ -41,7 +41,7 @@ public ActionScope LogAction() /// public void Add(NodeAction action) { - ArgumentValidator.EnsureArgumentNotNull(action, "action"); + ArgumentNullException.ThrowIfNull(action, "action"); EnsureNotLocked(); // Only locked actions can be added var ca = action as PropertyChangeAction; @@ -63,7 +63,7 @@ public void Add(NodeAction action) /// public void Add(IEnumerable actions) { - ArgumentValidator.EnsureArgumentNotNull(actions, "actions"); + ArgumentNullException.ThrowIfNull(actions, "actions"); foreach (NodeAction action in actions) Add(action); } diff --git a/Orm/Xtensive.Orm/Modelling/Actions/CreateNodeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/CreateNodeAction.cs index 6e8bc62a3..305591c68 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/CreateNodeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/CreateNodeAction.cs @@ -31,7 +31,7 @@ public class CreateNodeAction : NodeAction public Type Type { get { return type; } set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); EnsureNotLocked(); type = value; } @@ -80,7 +80,7 @@ public object[] Parameters { /// Required constructor isn't found. protected override void PerformExecute(IModel model, IPathNode item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); var parent = (Node) item; var node = TryConstructor(model, parent, name); // Regular node if (node==null) diff --git a/Orm/Xtensive.Orm/Modelling/Actions/GroupingNodeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/GroupingNodeAction.cs index 2248dd96b..9d6588e16 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/GroupingNodeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/GroupingNodeAction.cs @@ -45,7 +45,7 @@ public IList Actions { /// The action to add. public void Add(NodeAction action) { - ArgumentValidator.EnsureArgumentNotNull(action, "action"); + ArgumentNullException.ThrowIfNull(action, "action"); EnsureNotLocked(); // Only locked actions can be added var ca = action as PropertyChangeAction; diff --git a/Orm/Xtensive.Orm/Modelling/Actions/MoveNodeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/MoveNodeAction.cs index 709f71764..db89f42a2 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/MoveNodeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/MoveNodeAction.cs @@ -74,7 +74,7 @@ public string NewPath { /// Required constructor isn't found. protected override void PerformExecute(IModel model, IPathNode item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); var node = (Node) item; var newParent = parent==null ? node.Parent : (Node) model.Resolve(parent, true); if ((node is IModel) && (newParent is IModel)) diff --git a/Orm/Xtensive.Orm/Modelling/Actions/NodeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/NodeAction.cs index a3d79ae76..b3ffca0c3 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/NodeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/NodeAction.cs @@ -49,7 +49,7 @@ public Difference Difference { /// public virtual void Execute(IModel model) { - ArgumentValidator.EnsureArgumentNotNull(model, "model"); + ArgumentNullException.ThrowIfNull(model, "model"); var item = model.Resolve(path, true); ActionHandler.Current.Execute(this); PerformExecute(model, item); diff --git a/Orm/Xtensive.Orm/Modelling/Actions/PropertyChangeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/PropertyChangeAction.cs index b9acdb975..5ae5b00f2 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/PropertyChangeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/PropertyChangeAction.cs @@ -29,7 +29,7 @@ public IDictionary Properties { /// protected override void PerformExecute(IModel model, IPathNode item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); var node = (Node) item; foreach (var pair in properties) node.SetProperty(pair.Key, PathNodeReference.Resolve(model, pair.Value)); diff --git a/Orm/Xtensive.Orm/Modelling/Actions/RemoveNodeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/RemoveNodeAction.cs index 74efa2352..0acf2fb69 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/RemoveNodeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/RemoveNodeAction.cs @@ -19,7 +19,7 @@ public class RemoveNodeAction : NodeAction /// protected override void PerformExecute(IModel model, IPathNode item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); var node = (Node) item; node.Remove(); } diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs index b32e8da39..36ed8bf98 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs @@ -126,7 +126,7 @@ protected Difference Visit(object source, object target) /// , if they're equal. protected virtual Difference Visit(Type type, object source, object target) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type, "type"); if (typeof (Node).IsAssignableFrom(type)) return VisitNode((Node) source, (Node) target); if (typeof(NodeCollection).IsAssignableFrom(type)) @@ -697,7 +697,7 @@ protected virtual ComparisonContext CreateContext() /// The path of the target node. protected virtual string GetTargetPath(Node source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); if (source.Model==Source) { var renameHint = Hints.GetHint(source); if (renameHint!=null) @@ -720,7 +720,7 @@ protected virtual string GetTargetPath(Node source) /// The name of the target node. protected virtual string GetTargetName(Node source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); if (source.Model==Source) { var renameHint = Hints.GetHint(source); if (renameHint!=null) diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/CopyDataHint.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/CopyDataHint.cs index d171ce4eb..d1bdb04ac 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/CopyDataHint.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/CopyDataHint.cs @@ -65,7 +65,7 @@ public CopyDataHint(string sourceTablePath, IList identities, IList> copiedColumns) : base(sourceTablePath, identities) { - ArgumentValidator.EnsureArgumentNotNull(copiedColumns, "copiedColumns"); + ArgumentNullException.ThrowIfNull(copiedColumns, "copiedColumns"); CopiedColumns = new ReadOnlyCollection>(copiedColumns); } diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/DataHint.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/DataHint.cs index 59cb05663..14e0125ec 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/DataHint.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/DataHint.cs @@ -50,7 +50,7 @@ public override IEnumerable GetTargets() protected DataHint(string sourceTablePath, IList identities) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceTablePath, "sourceTablePath"); - ArgumentValidator.EnsureArgumentNotNull(identities, "pairs"); + ArgumentNullException.ThrowIfNull(identities, "pairs"); SourceTablePath = sourceTablePath; Identities = new ReadOnlyCollection(identities); diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/HintSet.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/HintSet.cs index d11fbffd8..b6364670f 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/HintSet.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/HintSet.cs @@ -66,7 +66,7 @@ public int Count { /// method isn't found. public void Add(Hint hint) { - ArgumentValidator.EnsureArgumentNotNull(hint, "hint"); + ArgumentNullException.ThrowIfNull(hint, "hint"); if (set.Contains(hint)) throw new InvalidOperationException(Strings.ExItemAlreadyExists); @@ -165,7 +165,7 @@ IEnumerator IEnumerable.GetEnumerator() private Dictionary GetNodeHints(Node node) { - ArgumentValidator.EnsureArgumentNotNull(node, "node"); + ArgumentNullException.ThrowIfNull(node, "node"); if (!hintMap.TryGetValue(node, out var nodeHintMap)) { hintMap.Add(node, nodeHintMap = new Dictionary()); @@ -206,10 +206,8 @@ public override string ToString() /// The target model. public HintSet(IModel sourceModel, IModel targetModel) { - ArgumentValidator.EnsureArgumentNotNull(sourceModel, "sourceModel"); - ArgumentValidator.EnsureArgumentNotNull(targetModel, "targetModel"); - SourceModel = sourceModel; - TargetModel = targetModel; + SourceModel = sourceModel ?? throw new ArgumentNullException(nameof(sourceModel)); + TargetModel = targetModel ?? throw new ArgumentNullException(nameof(targetModel)); } private HintSet() diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/UpdateDataHint.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/UpdateDataHint.cs index 344a949cb..08c6c3c91 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/UpdateDataHint.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/UpdateDataHint.cs @@ -60,7 +60,7 @@ public UpdateDataHint( IList> updateParameters) : base(sourceTablePath, identities) { - ArgumentValidator.EnsureArgumentNotNull(updateParameters, "updateParameters"); + ArgumentNullException.ThrowIfNull(updateParameters, "updateParameters"); UpdateParameter = new ReadOnlyCollection>(updateParameters); } diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs index ac08660c5..5b72cabfe 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs @@ -119,8 +119,8 @@ public IReadOnlyList GetUpgradeSequence(Difference difference, HintS /// Upgrade sequence validation has failed. public IReadOnlyList GetUpgradeSequence(Difference difference, HintSet hints, IComparer comparer) { - ArgumentValidator.EnsureArgumentNotNull(hints, nameof(hints)); - ArgumentValidator.EnsureArgumentNotNull(comparer, nameof(comparer)); + ArgumentNullException.ThrowIfNull(hints, nameof(hints)); + ArgumentNullException.ThrowIfNull(comparer, nameof(comparer)); if (difference == null) { return Array.Empty(); } diff --git a/Orm/Xtensive.Orm/Modelling/Nesting.cs b/Orm/Xtensive.Orm/Modelling/Nesting.cs index 2f786f948..f88d81770 100644 --- a/Orm/Xtensive.Orm/Modelling/Nesting.cs +++ b/Orm/Xtensive.Orm/Modelling/Nesting.cs @@ -72,9 +72,8 @@ internal virtual void Initialize() internal Nesting(Node node, string propertyName) { - ArgumentValidator.EnsureArgumentNotNull(node, "node"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(propertyName, "propertyName"); - Node = node; + Node = node ?? throw new ArgumentNullException(nameof(node)); PropertyName = propertyName; Initialize(); } diff --git a/Orm/Xtensive.Orm/Modelling/Node.cs b/Orm/Xtensive.Orm/Modelling/Node.cs index 824d6d28f..4609f6469 100644 --- a/Orm/Xtensive.Orm/Modelling/Node.cs +++ b/Orm/Xtensive.Orm/Modelling/Node.cs @@ -66,7 +66,7 @@ public Node Parent { get { return parent; } [DebuggerStepThrough] set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); if (value==Parent) return; NodeCollection collection = null; @@ -338,10 +338,10 @@ public virtual Node Clone(Node newParent, string newName) using (CloningScope.Open()) { var isModel = this is IModel; if (!isModel) { - ArgumentValidator.EnsureArgumentNotNull(newParent, nameof(newParent)); + ArgumentNullException.ThrowIfNull(newParent, nameof(newParent)); } - ArgumentValidator.EnsureArgumentNotNull(newName, nameof(newName)); + ArgumentNullException.ThrowIfNull(newName, nameof(newName)); // Cloning the instance var model = isModel ? null : (IModel) newParent.Model; @@ -850,7 +850,7 @@ private void UpdateModel() private static PropertyAccessorDictionary GetPropertyAccessors(Type type) { - ArgumentValidator.EnsureArgumentNotNull(type, nameof(type)); + ArgumentNullException.ThrowIfNull(type, nameof(type)); static Lazy PropertyAccessorExtractor(Type entityType) { @@ -1006,7 +1006,7 @@ public override string ToString() protected Node(Node parent, string name) { if (!(this is IModel)) { - ArgumentValidator.EnsureArgumentNotNull(parent, nameof(parent)); + ArgumentNullException.ThrowIfNull(parent, nameof(parent)); } if (!(this is IUnnamedNode)) { diff --git a/Orm/Xtensive.Orm/Modelling/NodeCollection.cs b/Orm/Xtensive.Orm/Modelling/NodeCollection.cs index 1884f675b..d5821197d 100644 --- a/Orm/Xtensive.Orm/Modelling/NodeCollection.cs +++ b/Orm/Xtensive.Orm/Modelling/NodeCollection.cs @@ -370,10 +370,9 @@ protected virtual void Initialize() /// property value. protected NodeCollection(Node parent, string name) { - ArgumentValidator.EnsureArgumentNotNull(parent, "parent"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); this.name = name; - this.parent = parent; + this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); Initialize(); } diff --git a/Orm/Xtensive.Orm/Orm/Attributes/IndexAttribute.cs b/Orm/Xtensive.Orm/Orm/Attributes/IndexAttribute.cs index cc60ba07e..07ded1246 100644 --- a/Orm/Xtensive.Orm/Orm/Attributes/IndexAttribute.cs +++ b/Orm/Xtensive.Orm/Orm/Attributes/IndexAttribute.cs @@ -89,7 +89,7 @@ public bool Unique /// The other (optional) key fields. public IndexAttribute(string keyField, params string[] keyFields) { - ArgumentValidator.EnsureArgumentNotNull(keyField, "keyField"); + ArgumentNullException.ThrowIfNull(keyField, "keyField"); if (keyFields==null || keyFields.Length==0) { KeyFields = new[] {keyField}; diff --git a/Orm/Xtensive.Orm/Orm/Building/Builders/DomainBuilder.cs b/Orm/Xtensive.Orm/Orm/Building/Builders/DomainBuilder.cs index 74cd2ddbb..f731632e9 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Builders/DomainBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Builders/DomainBuilder.cs @@ -4,6 +4,7 @@ // Created by: Dmitri Maximov // Created: 2007.08.03 +using System; using System.Collections.Generic; using System.Linq; using Xtensive.Core; @@ -30,7 +31,7 @@ internal sealed class DomainBuilder /// Built domain. public static Domain Run(DomainBuilderConfiguration builderConfiguration) { - ArgumentValidator.EnsureArgumentNotNull(builderConfiguration, nameof(builderConfiguration)); + ArgumentNullException.ThrowIfNull(builderConfiguration, nameof(builderConfiguration)); var context = new BuildingContext(builderConfiguration); using (BuildLog.InfoRegion(nameof(Strings.LogBuildingX), typeof(Domain).Name)) { diff --git a/Orm/Xtensive.Orm/Orm/Building/Builders/MemberCompilerProviderBuilder.cs b/Orm/Xtensive.Orm/Orm/Building/Builders/MemberCompilerProviderBuilder.cs index 910dddd04..425fab413 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Builders/MemberCompilerProviderBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Builders/MemberCompilerProviderBuilder.cs @@ -24,8 +24,8 @@ internal sealed class MemberCompilerProviderBuilder public static Dictionary Build(DomainConfiguration configuration, IEnumerable systemCompilerContainers) { - ArgumentValidator.EnsureArgumentNotNull(configuration, "configuration"); - ArgumentValidator.EnsureArgumentNotNull(systemCompilerContainers, "systemCompilerContainers"); + ArgumentNullException.ThrowIfNull(configuration, "configuration"); + ArgumentNullException.ThrowIfNull(systemCompilerContainers, "systemCompilerContainers"); var builder = new MemberCompilerProviderBuilder(configuration, systemCompilerContainers); builder.Build(); return builder.memberCompilerProviders; diff --git a/Orm/Xtensive.Orm/Orm/Building/Builders/PartialIndexFilterBuilder.cs b/Orm/Xtensive.Orm/Orm/Building/Builders/PartialIndexFilterBuilder.cs index 0b2f73371..c890d49fc 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Builders/PartialIndexFilterBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Builders/PartialIndexFilterBuilder.cs @@ -36,7 +36,7 @@ internal class PartialIndexFilterBuilder : ExpressionVisitor public static void BuildFilter(IndexInfo index) { - ArgumentValidator.EnsureArgumentNotNull(index, "index"); + ArgumentNullException.ThrowIfNull(index, "index"); var builder = new PartialIndexFilterBuilder(index); var body = builder.Visit(index.FilterExpression.Body); var filter = new PartialIndexFilterInfo { diff --git a/Orm/Xtensive.Orm/Orm/Building/Builders/TypeIdBuilder.cs b/Orm/Xtensive.Orm/Orm/Building/Builders/TypeIdBuilder.cs index 032815ebe..668b0f112 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Builders/TypeIdBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Builders/TypeIdBuilder.cs @@ -117,11 +117,8 @@ private IEnumerable GetTypesWithoutTypeId(TypeIdRegistry registry) public TypeIdBuilder(Domain domain, ITypeIdProvider typeIdProvider) { - ArgumentValidator.EnsureArgumentNotNull(domain, "domain"); - ArgumentValidator.EnsureArgumentNotNull(typeIdProvider, "typeIdProvider"); - - this.domain = domain; - this.typeIdProvider = typeIdProvider; + this.domain = domain ?? throw new ArgumentNullException(nameof(domain)); + this.typeIdProvider = typeIdProvider ?? throw new ArgumentNullException(nameof(typeIdProvider)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Building/BuildingContext.cs b/Orm/Xtensive.Orm/Orm/Building/BuildingContext.cs index e911e81c5..b9ef50160 100644 --- a/Orm/Xtensive.Orm/Orm/Building/BuildingContext.cs +++ b/Orm/Xtensive.Orm/Orm/Building/BuildingContext.cs @@ -77,9 +77,7 @@ public sealed class BuildingContext internal BuildingContext(DomainBuilderConfiguration builderConfiguration) { - ArgumentValidator.EnsureArgumentNotNull(builderConfiguration, "builderConfiguration"); - - BuilderConfiguration = builderConfiguration; + BuilderConfiguration = builderConfiguration ?? throw new ArgumentNullException(nameof(builderConfiguration)); PairedAssociations = new List>(); DiscardedAssociations = new HashSet(); ModelInspectionResult = new ModelInspectionResult(); @@ -88,8 +86,8 @@ internal BuildingContext(DomainBuilderConfiguration builderConfiguration) Modules = BuilderConfiguration.Services.Modules.ToList(BuilderConfiguration.Services.Modules.Count).AsReadOnly(); Modules2 = Modules.OfType().ToList().AsReadOnly(); - Validator = new Validator(builderConfiguration.Services.ProviderInfo.SupportedTypes); - DefaultSchemaInfo = builderConfiguration.DefaultSchemaInfo; + Validator = new Validator(BuilderConfiguration.Services.ProviderInfo.SupportedTypes); + DefaultSchemaInfo = BuilderConfiguration.DefaultSchemaInfo; } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Building/Definitions/HierarchyDefCollection.cs b/Orm/Xtensive.Orm/Orm/Building/Definitions/HierarchyDefCollection.cs index 44393df99..7c817b1b2 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Definitions/HierarchyDefCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Definitions/HierarchyDefCollection.cs @@ -36,7 +36,7 @@ public class HierarchyDefCollection : CollectionBaseSlim /// public override bool Contains(HierarchyDef item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); return TryGetValue(item.Root) != null; } @@ -115,7 +115,7 @@ public override void Clear() /// instance or if hierarchy is not found. public HierarchyDef Find(TypeDef item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); var itemUnderlyingType = item.UnderlyingType; HierarchyDef hierarchyDef; diff --git a/Orm/Xtensive.Orm/Orm/Building/Definitions/IndexDef.cs b/Orm/Xtensive.Orm/Orm/Building/Definitions/IndexDef.cs index dc4e5656a..aaa0d485e 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Definitions/IndexDef.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Definitions/IndexDef.cs @@ -170,8 +170,7 @@ protected override void ValidateName(string newName) internal IndexDef(TypeDef type, Validator validator) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); - Type = type; + Type = type ?? throw new ArgumentNullException(nameof(type)); this.validator = validator; } } diff --git a/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDef.cs b/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDef.cs index b53e13c8b..c9e20524b 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDef.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDef.cs @@ -151,7 +151,7 @@ public IndexDef DefineIndex(string name) /// public FieldDef DefineField(PropertyInfo property) { - ArgumentValidator.EnsureArgumentNotNull(property, nameof(property)); + ArgumentNullException.ThrowIfNull(property, nameof(property)); if (property.ReflectedType != UnderlyingType) { throw new DomainBuilderException( @@ -172,7 +172,7 @@ public FieldDef DefineField(PropertyInfo property) public FieldDef DefineField(string name, Type valueType) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, nameof(name)); - ArgumentValidator.EnsureArgumentNotNull(valueType, nameof(valueType)); + ArgumentNullException.ThrowIfNull(valueType, nameof(valueType)); var field = builder.DefineField(UnderlyingType, name, valueType); fields.Add(field); diff --git a/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDefCollection.cs b/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDefCollection.cs index 4d09822e9..e422daa53 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDefCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDefCollection.cs @@ -47,7 +47,7 @@ public sealed class TypeDefCollection : NodeCollection /// When is . public TypeDef FindAncestor(TypeDef item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); if (item.IsInterface) return null; @@ -75,7 +75,7 @@ private TypeDef FindAncestor(Type type) => /// When is . public IEnumerable FindInterfaces(Type type) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type, "type"); var interfaces = TypeHelper.GetInterfacesUnordered(type); return interfaces.Select(TryGetValue).Where(result => result != null); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs index 02349340f..e264c0c60 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs @@ -187,7 +187,7 @@ public string Name get => name; set { EnsureNotLocked(); - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); name = value; } } @@ -376,7 +376,7 @@ public SessionConfigurationCollection Sessions { get => sessions; set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); EnsureNotLocked(); sessions = value; } @@ -389,7 +389,7 @@ public MappingRuleCollection MappingRules { get => mappingRules; set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); EnsureNotLocked(); mappingRules = value; } @@ -402,7 +402,7 @@ public DatabaseConfigurationCollection Databases { get => databases; set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); EnsureNotLocked(); databases = value; } @@ -415,7 +415,7 @@ public KeyGeneratorConfigurationCollection KeyGenerators { get => keyGenerators; set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); EnsureNotLocked(); keyGenerators = value; } @@ -918,7 +918,7 @@ private static DomainConfiguration LoadConfigurationFromSection(ConfigurationSec /// The "domains" section is not found or domain with requested name is not found. public static DomainConfiguration Load(IConfigurationSection configurationSection, string name) { - ArgumentValidator.EnsureArgumentNotNull(configurationSection, nameof(configurationSection)); + ArgumentNullException.ThrowIfNull(configurationSection, nameof(configurationSection)); var jsonParser = new JsonToDomainConfigurationReader(); var xmlParser = new XmlToDomainConfigurationReader(); @@ -936,7 +936,7 @@ public static DomainConfiguration Load(IConfigurationSection configurationSectio public static DomainConfiguration Load(IConfigurationRoot configurationRoot, string name) { - ArgumentValidator.EnsureArgumentNotNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot, nameof(configurationRoot)); var jsonParser = new JsonToDomainConfigurationReader(); var xmlParser = new XmlToDomainConfigurationReader(); @@ -954,7 +954,7 @@ public static DomainConfiguration Load(IConfigurationRoot configurationRoot, str public static DomainConfiguration Load(IConfigurationRoot configurationRoot, string sectionName, string name) { - ArgumentValidator.EnsureArgumentNotNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot, nameof(configurationRoot)); var jsonParser = new JsonToDomainConfigurationReader(); var xmlParser = new XmlToDomainConfigurationReader(); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs index e90da338b..54f867337 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs @@ -53,7 +53,7 @@ public void Set(T value) where T : ConfigurationBase { EnsureNotLocked(); - ArgumentValidator.EnsureArgumentNotNull(value, nameof(value)); + ArgumentNullException.ThrowIfNull(value, nameof(value)); var extensionConfigurationType = typeof(T); @@ -126,7 +126,7 @@ public ExtensionConfigurationCollection() public ExtensionConfigurationCollection(ExtensionConfigurationCollection source) : this() { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); if (source.Count == 0) return; extensionConfigurations = new Dictionary(source.extensionConfigurations); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/Internals/LoggingConfigurationReader.cs b/Orm/Xtensive.Orm/Orm/Configuration/Internals/LoggingConfigurationReader.cs index 6308dc9fd..e4332542d 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/Internals/LoggingConfigurationReader.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/Internals/LoggingConfigurationReader.cs @@ -23,7 +23,7 @@ internal sealed class LoggingConfigurationReader : IConfigurationSectionReader public LoggingConfiguration Read(IConfigurationRoot configurationRoot, string sectionName) { - ArgumentValidator.EnsureArgumentNotNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot, nameof(configurationRoot)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sectionName, nameof(sectionName)); return Read(configurationRoot.GetSection(sectionName)); @@ -32,7 +32,7 @@ public LoggingConfiguration Read(IConfigurationRoot configurationRoot, string se /// public LoggingConfiguration Read(IConfigurationRoot configurationRoot) { - ArgumentValidator.EnsureArgumentNotNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot, nameof(configurationRoot)); return Read(configurationRoot.GetSection(WellKnown.DefaultConfigurationSection)); } @@ -40,7 +40,7 @@ public LoggingConfiguration Read(IConfigurationRoot configurationRoot) /// public LoggingConfiguration Read(IConfigurationRoot configurationRoot, string sectionName, string nameOfConfiguration) { - ArgumentValidator.EnsureArgumentNotNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot, nameof(configurationRoot)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sectionName, nameof(sectionName)); return Read(configurationRoot.GetSection(sectionName)); @@ -49,7 +49,7 @@ public LoggingConfiguration Read(IConfigurationRoot configurationRoot, string se /// public LoggingConfiguration Read(IConfigurationSection configurationSection) { - ArgumentValidator.EnsureArgumentNotNull(configurationSection, nameof(configurationSection)); + ArgumentNullException.ThrowIfNull(configurationSection, nameof(configurationSection)); var ormConfigurationSection = configurationSection; diff --git a/Orm/Xtensive.Orm/Orm/Configuration/LinqExtensionRegistration.cs b/Orm/Xtensive.Orm/Orm/Configuration/LinqExtensionRegistration.cs index 35330064d..5789ae8ae 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/LinqExtensionRegistration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/LinqExtensionRegistration.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2011 Xtensive LLC. +// Copyright (C) 2011 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -42,11 +42,8 @@ public sealed class LinqExtensionRegistration /// Value for . public LinqExtensionRegistration(MemberInfo member, LambdaExpression substitution) { - ArgumentValidator.EnsureArgumentNotNull(member, "member"); - ArgumentValidator.EnsureArgumentNotNull(substitution, "substitution"); - - Member = member; - Substitution = substitution; + Member = member ?? throw new ArgumentNullException(nameof(member)); + Substitution = substitution ?? throw new ArgumentNullException(nameof(substitution)); } /// @@ -56,11 +53,8 @@ public LinqExtensionRegistration(MemberInfo member, LambdaExpression substitutio /// Value for . public LinqExtensionRegistration(MemberInfo member, Func compiler) { - ArgumentValidator.EnsureArgumentNotNull(member, "member"); - ArgumentValidator.EnsureArgumentNotNull(compiler, "compiler"); - - Member = member; - Compiler = compiler; + Member = member ?? throw new ArgumentNullException(nameof(member)); + Compiler = compiler ?? throw new ArgumentNullException(nameof(compiler)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs index 17823668c..92aca9c87 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs @@ -116,7 +116,7 @@ public static LoggingConfiguration Load(System.Configuration.Configuration confi /// Loaded configuration. public static LoggingConfiguration Load(System.Configuration.Configuration configuration, string sectionName) { - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sectionName, nameof(sectionName)); var section = (ConfigurationSection) configuration.GetSection(sectionName); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs index 1e245df78..701ef207f 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs @@ -120,7 +120,7 @@ public NameMappingCollection() /// Mappings to add to this instance. public NameMappingCollection([NotNull] IEnumerable> items) { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); + ArgumentNullException.ThrowIfNull(items, "items"); foreach (var item in items) Add(item.Key, item.Value); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/Options/NamedOptionsCollection{T}.cs b/Orm/Xtensive.Orm/Orm/Configuration/Options/NamedOptionsCollection{T}.cs index 342a60140..8583f8f6f 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/Options/NamedOptionsCollection{T}.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/Options/NamedOptionsCollection{T}.cs @@ -64,10 +64,8 @@ public T this[string key] public void Add(string name, T value) { ValidateName(name); + ArgumentNullException.ThrowIfNull(value); - if (value == null) { - throw new ArgumentNullException(nameof(value)); - } value.Name = name; if (!internalDictionary.TryAdd(name, value)) { diff --git a/Orm/Xtensive.Orm/Orm/Configuration/Options/OptionsCollection{T}.cs b/Orm/Xtensive.Orm/Orm/Configuration/Options/OptionsCollection{T}.cs index a8bd0d8bc..ff8299d87 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/Options/OptionsCollection{T}.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/Options/OptionsCollection{T}.cs @@ -81,7 +81,7 @@ public bool Remove(T item) public void CopyTo(T[] array, int arrayIndex) { - ArgumentValidator.EnsureArgumentNotNull(array, nameof(array)); + ArgumentNullException.ThrowIfNull(array, nameof(array)); ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(arrayIndex, 0, nameof(arrayIndex)); if (array.Length - arrayIndex < map.Count) { diff --git a/Orm/Xtensive.Orm/Orm/ConnectionErrorEventData.cs b/Orm/Xtensive.Orm/Orm/ConnectionErrorEventData.cs index 1e8ff7121..64e083111 100644 --- a/Orm/Xtensive.Orm/Orm/ConnectionErrorEventData.cs +++ b/Orm/Xtensive.Orm/Orm/ConnectionErrorEventData.cs @@ -21,8 +21,7 @@ public class ConnectionErrorEventData : ConnectionEventData public ConnectionErrorEventData(Exception exception, DbConnection connection, bool reconnect = false) : base(connection, reconnect) { - ArgumentValidator.EnsureArgumentNotNull(exception, nameof(exception)); - Exception = exception; + Exception = exception ?? throw new ArgumentNullException(nameof(exception)); } } } diff --git a/Orm/Xtensive.Orm/Orm/ConnectionEventData.cs b/Orm/Xtensive.Orm/Orm/ConnectionEventData.cs index 3230ca686..a05b41bed 100644 --- a/Orm/Xtensive.Orm/Orm/ConnectionEventData.cs +++ b/Orm/Xtensive.Orm/Orm/ConnectionEventData.cs @@ -2,6 +2,7 @@ // This code is distributed under MIT license terms. // See the License.txt file in the project root for more information. +using System; using System.Data.Common; using Xtensive.Core; @@ -24,8 +25,7 @@ public class ConnectionEventData public ConnectionEventData(DbConnection connection, bool reconnect = false) { - ArgumentValidator.EnsureArgumentNotNull(connection, nameof(connection)); - Connection = connection; + Connection = connection ?? throw new ArgumentNullException(nameof(connection)); Reconnect = reconnect; } } diff --git a/Orm/Xtensive.Orm/Orm/ConnectionInfo.cs b/Orm/Xtensive.Orm/Orm/ConnectionInfo.cs index e0ccc9765..5ddbde308 100644 --- a/Orm/Xtensive.Orm/Orm/ConnectionInfo.cs +++ b/Orm/Xtensive.Orm/Orm/ConnectionInfo.cs @@ -114,9 +114,7 @@ public ConnectionInfo(string provider, string connectionString) /// A value for . public ConnectionInfo(UrlInfo connectionUrl) { - ArgumentValidator.EnsureArgumentNotNull(connectionUrl, "connectionUrl"); - - ConnectionUrl = connectionUrl; + ConnectionUrl = connectionUrl ?? throw new ArgumentNullException(nameof(connectionUrl)); Provider = connectionUrl.Protocol.ToLowerInvariant(); } diff --git a/Orm/Xtensive.Orm/Orm/DelayedQuery.cs b/Orm/Xtensive.Orm/Orm/DelayedQuery.cs index b77e2db2c..d63f1d043 100644 --- a/Orm/Xtensive.Orm/Orm/DelayedQuery.cs +++ b/Orm/Xtensive.Orm/Orm/DelayedQuery.cs @@ -89,9 +89,9 @@ protected async ValueTask> MaterializeAsync(CancellationToken /// The parameter context. internal DelayedQuery(Session session, TranslatedQuery translatedQuery, ParameterContext outerParameterContext) { - ArgumentValidator.EnsureArgumentNotNull(session, nameof(session)); - ArgumentValidator.EnsureArgumentNotNull(translatedQuery, nameof(translatedQuery)); - ArgumentValidator.EnsureArgumentNotNull(outerParameterContext, nameof(outerParameterContext)); + ArgumentNullException.ThrowIfNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(translatedQuery, nameof(translatedQuery)); + ArgumentNullException.ThrowIfNull(outerParameterContext, nameof(outerParameterContext)); Session = session; LifetimeToken = session.GetLifetimeToken(); diff --git a/Orm/Xtensive.Orm/Orm/Domain.cs b/Orm/Xtensive.Orm/Orm/Domain.cs index b10c4ec9f..ad16b9844 100644 --- a/Orm/Xtensive.Orm/Orm/Domain.cs +++ b/Orm/Xtensive.Orm/Orm/Domain.cs @@ -226,7 +226,7 @@ public Session OpenSession(SessionConfiguration configuration) => internal Session OpenSessionInternal(SessionConfiguration configuration, StorageNode storageNode, bool activate) { - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); configuration.Lock(true); if (isDebugEventLoggingEnabled) { @@ -300,7 +300,7 @@ public Task OpenSessionAsync(SessionType type, CancellationToken cancel /// public Task OpenSessionAsync(SessionConfiguration configuration, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); SessionScope sessionScope = null; try { diff --git a/Orm/Xtensive.Orm/Orm/DomainBound.cs b/Orm/Xtensive.Orm/Orm/DomainBound.cs index da0b8a871..38e1b0d28 100644 --- a/Orm/Xtensive.Orm/Orm/DomainBound.cs +++ b/Orm/Xtensive.Orm/Orm/DomainBound.cs @@ -56,8 +56,7 @@ protected DomainBound() /// is . protected DomainBound(Domain domain) { - ArgumentValidator.EnsureArgumentNotNull(domain, "domain"); - this.domain = domain; + this.domain = domain ?? throw new ArgumentNullException(nameof(domain)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Entity.cs b/Orm/Xtensive.Orm/Orm/Entity.cs index 1d5363623..5013be02d 100644 --- a/Orm/Xtensive.Orm/Orm/Entity.cs +++ b/Orm/Xtensive.Orm/Orm/Entity.cs @@ -89,7 +89,7 @@ internal EntityState State { return state; } set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); if (state!=null) throw Exceptions.AlreadyInitialized("State"); state = value; @@ -858,7 +858,7 @@ internal Entity(Session session, Tuple keyTuple) : base(session) { try { - ArgumentValidator.EnsureArgumentNotNull(keyTuple, "keyTuple"); + ArgumentNullException.ThrowIfNull(keyTuple, "keyTuple"); var key = Key.Create(Session.Domain, Session.StorageNodeId, GetTypeInfo(), TypeReferenceAccuracy.ExactType, keyTuple); State = Session.CreateEntityState(key, true); changeVersionOnSetAttempt = ShouldChangeOnSetAttempt(); @@ -891,7 +891,7 @@ internal Entity(Session session, Tuple keyTuple) protected Entity(params object[] values) { try { - ArgumentValidator.EnsureArgumentNotNull(values, "values"); + ArgumentNullException.ThrowIfNull(values, "values"); var key = Key.Create(Session.Domain, Session.StorageNodeId, GetTypeInfo(), TypeReferenceAccuracy.ExactType, values); State = Session.CreateEntityState(key, true); changeVersionOnSetAttempt = ShouldChangeOnSetAttempt(); @@ -943,7 +943,7 @@ protected Entity(Session session, params object[] values) : base(session) { try { - ArgumentValidator.EnsureArgumentNotNull(values, "values"); + ArgumentNullException.ThrowIfNull(values, "values"); var key = Key.Create(Session.Domain, Session.StorageNodeId, GetTypeInfo(), TypeReferenceAccuracy.ExactType, values); State = Session.CreateEntityState(key, true); changeVersionOnSetAttempt = ShouldChangeOnSetAttempt(); diff --git a/Orm/Xtensive.Orm/Orm/EntityEventBroker.cs b/Orm/Xtensive.Orm/Orm/EntityEventBroker.cs index 8c53137a7..76fe905ba 100644 --- a/Orm/Xtensive.Orm/Orm/EntityEventBroker.cs +++ b/Orm/Xtensive.Orm/Orm/EntityEventBroker.cs @@ -132,9 +132,9 @@ public sealed class EntityEventBroker /// The delegate. public void AddSubscriber(Key key, FieldInfo fieldInfo, object eventKey, Delegate subscriber) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); - ArgumentValidator.EnsureArgumentNotNull(eventKey, "eventKey"); - ArgumentValidator.EnsureArgumentNotNull(subscriber, "subscriber"); + ArgumentNullException.ThrowIfNull(key, "key"); + ArgumentNullException.ThrowIfNull(eventKey, "eventKey"); + ArgumentNullException.ThrowIfNull(subscriber, "subscriber"); if (subscribers == null) subscribers = new Dictionary<(Key, FieldInfo, object), Delegate>(); var subscriberKey = (key, fieldInfo, eventKey); @@ -166,9 +166,9 @@ public void AddSubscriber(Key key, object eventKey, Delegate subscriber) /// The delegate. public void RemoveSubscriber(Key key, FieldInfo fieldInfo, object eventKey, Delegate subscriber) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); - ArgumentValidator.EnsureArgumentNotNull(eventKey, "eventKey"); - ArgumentValidator.EnsureArgumentNotNull(subscriber, "subscriber"); + ArgumentNullException.ThrowIfNull(key, "key"); + ArgumentNullException.ThrowIfNull(eventKey, "eventKey"); + ArgumentNullException.ThrowIfNull(subscriber, "subscriber"); if (subscribers == null) return; var subscriberKey = (key, fieldInfo, eventKey); diff --git a/Orm/Xtensive.Orm/Orm/EntitySet{T}.cs b/Orm/Xtensive.Orm/Orm/EntitySet{T}.cs index 91d56f510..3cc69f709 100644 --- a/Orm/Xtensive.Orm/Orm/EntitySet{T}.cs +++ b/Orm/Xtensive.Orm/Orm/EntitySet{T}.cs @@ -114,7 +114,7 @@ public bool Remove(TItem item) public new void AddRange(IEnumerable items) where TElement: TItem { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); + ArgumentNullException.ThrowIfNull(items, "items"); base.AddRange(items); } @@ -127,7 +127,7 @@ public bool Remove(TItem item) public new void IntersectWith(IEnumerable other) where TElement : TItem { - ArgumentValidator.EnsureArgumentNotNull(other, "other"); + ArgumentNullException.ThrowIfNull(other, "other"); base.IntersectWith(other); } @@ -140,7 +140,7 @@ public bool Remove(TItem item) public new void UnionWith(IEnumerable other) where TElement : TItem { - ArgumentValidator.EnsureArgumentNotNull(other, "other"); + ArgumentNullException.ThrowIfNull(other, "other"); base.UnionWith(other); } @@ -152,7 +152,7 @@ public bool Remove(TItem item) public new void ExceptWith(IEnumerable other) where TElement : TItem { - ArgumentValidator.EnsureArgumentNotNull(other, "other"); + ArgumentNullException.ThrowIfNull(other, "other"); base.ExceptWith(other); } diff --git a/Orm/Xtensive.Orm/Orm/EntityState.cs b/Orm/Xtensive.Orm/Orm/EntityState.cs index 6c83167a4..f4b706abc 100644 --- a/Orm/Xtensive.Orm/Orm/EntityState.cs +++ b/Orm/Xtensive.Orm/Orm/EntityState.cs @@ -330,8 +330,7 @@ public override string ToString() internal EntityState(Session session, Key key, Tuple data) : base(session) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); - this.key = key; + this.key = key ?? throw new ArgumentNullException(nameof(key)); Tuple = data; } diff --git a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/ComplexTerm.cs b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/ComplexTerm.cs index a3c69bf93..d81b367b8 100644 --- a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/ComplexTerm.cs +++ b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/ComplexTerm.cs @@ -1,9 +1,10 @@ -// Copyright (C) 2003-2016 Xtensive LLC. +// Copyright (C) 2003-2016 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Alexey Kulakov // Created: 2016.12.09 +using System; using Xtensive.Core; using Xtensive.Orm.FullTextSearchCondition.Interfaces; @@ -25,8 +26,7 @@ protected override void AcceptVisitorInternal(ISearchConditionNodeVisitor visito internal ComplexTerm(IOperator source, IOperand operandsSequenceRoot) : base(SearchConditionNodeType.ComplexTerm, source) { - ArgumentValidator.EnsureArgumentNotNull(operandsSequenceRoot, "operandsSequenceRoot"); - RootOperand = operandsSequenceRoot; + RootOperand = operandsSequenceRoot ?? throw new ArgumentNullException(nameof(operandsSequenceRoot)); } } } diff --git a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/CustomProximityTerm.cs b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/CustomProximityTerm.cs index 38a8a5549..afbb11a8b 100644 --- a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/CustomProximityTerm.cs +++ b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/CustomProximityTerm.cs @@ -47,7 +47,7 @@ internal CustomProximityTerm(IOperator source, ICollection pr { if (proximityTerms.Count < 2) throw new ArgumentException(string.Format(Strings.ExCollectionShouldContainAtLeastXElements, 2)); - ArgumentValidator.EnsureArgumentNotNull(proximityTerms, "proximityTerms"); + ArgumentNullException.ThrowIfNull(proximityTerms, "proximityTerms"); ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(maxDistance, 0, "maxDistance"); Terms = proximityTerms.ToList().AsReadOnly(); diff --git a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/GenerationTerm.cs b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/GenerationTerm.cs index ae7f92cdc..a5b5f2ffa 100644 --- a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/GenerationTerm.cs +++ b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/GenerationTerm.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2003-2016 Xtensive LLC. +// Copyright (C) 2003-2016 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Alexey Kulakov @@ -32,8 +32,8 @@ protected override void AcceptVisitorInternal(ISearchConditionNodeVisitor visito internal GenerationTerm(IOperator source, GenerationType generationType, ICollection terms) : base(SearchConditionNodeType.GenerationTerm, source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(terms, "terms"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(terms, "terms"); if (terms.Count==0) throw new ArgumentException(Strings.ExCollectionIsEmpty, "terms"); if (terms.Any(c=>c.IsNullOrEmpty() || c.Trim().IsNullOrEmpty())) diff --git a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/Operator.cs b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/Operator.cs index d88e1caf7..e4227444a 100644 --- a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/Operator.cs +++ b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/Operator.cs @@ -44,7 +44,7 @@ public IGenerationTerm GenerationTerm(GenerationType generationType, ICollection /// public IProximityTerm GenericProximityTerm(Func proximityTermsConstructor) { - ArgumentValidator.EnsureArgumentNotNull(proximityTermsConstructor, "proximityTermsConstructor"); + ArgumentNullException.ThrowIfNull(proximityTermsConstructor, "proximityTermsConstructor"); var proximityOperandRoot = new ProximityOperandEndpoint(); var constructionFlow = proximityTermsConstructor.Invoke(proximityOperandRoot); @@ -54,7 +54,7 @@ public IProximityTerm GenericProximityTerm(Func public ICustomProximityTerm CustomProximityTerm(Func proximityTermsConstructor) { - ArgumentValidator.EnsureArgumentNotNull(proximityTermsConstructor, "proximityTermsConstructor"); + ArgumentNullException.ThrowIfNull(proximityTermsConstructor, "proximityTermsConstructor"); var proximityOperandRoot = new ProximityOperandEndpoint(); var constructionFlow = proximityTermsConstructor.Invoke(proximityOperandRoot); @@ -64,7 +64,7 @@ public ICustomProximityTerm CustomProximityTerm(Func public ICustomProximityTerm CustomProximityTerm(Func proximityTermsConstructor, long maximumDistance) { - ArgumentValidator.EnsureArgumentNotNull(proximityTermsConstructor, "proximityTermsConstructor"); + ArgumentNullException.ThrowIfNull(proximityTermsConstructor, "proximityTermsConstructor"); var proximityOperandRoot = new ProximityOperandEndpoint(); var constructionFlow = proximityTermsConstructor.Invoke(proximityOperandRoot); @@ -74,7 +74,7 @@ public ICustomProximityTerm CustomProximityTerm(Func public ICustomProximityTerm CustomProximityTerm(Func proximityTermsConstructor, long maximumDistance, bool matchOrder) { - ArgumentValidator.EnsureArgumentNotNull(proximityTermsConstructor, "proximityTermsConstructor"); + ArgumentNullException.ThrowIfNull(proximityTermsConstructor, "proximityTermsConstructor"); var proximityOperandRoot = new ProximityOperandEndpoint(); var constructionFlow = proximityTermsConstructor.Invoke(proximityOperandRoot); @@ -84,7 +84,7 @@ public ICustomProximityTerm CustomProximityTerm(Func public IWeightedTerm WeightedTerm(Func weightedTermsConstructor) { - ArgumentValidator.EnsureArgumentNotNull(weightedTermsConstructor, "weightedTermsConstructor"); + ArgumentNullException.ThrowIfNull(weightedTermsConstructor, "weightedTermsConstructor"); var endpoint = new WeightedTermEndpoint(); var constructionFlow = weightedTermsConstructor.Invoke(endpoint); @@ -94,7 +94,7 @@ public IWeightedTerm WeightedTerm(Func public IComplexTerm ComplexTerm(Func complexTermConstructor) { - ArgumentValidator.EnsureArgumentNotNull(complexTermConstructor, "complexTermConstructor"); + ArgumentNullException.ThrowIfNull(complexTermConstructor, "complexTermConstructor"); var endpoint = SearchConditionNodeFactory.CreateConditonRoot(); return SearchConditionNodeFactory.CreateComplexTerm(this, complexTermConstructor.Invoke(endpoint)); diff --git a/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/NonPairedReferenceChangesRegistry.cs b/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/NonPairedReferenceChangesRegistry.cs index 55ed4334a..fcb6e1fdb 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/NonPairedReferenceChangesRegistry.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/NonPairedReferenceChangesRegistry.cs @@ -53,8 +53,8 @@ public Identifier(EntityState entityState, AssociationInfo association) public IEnumerable GetRemovedReferencesTo(EntityState target, AssociationInfo association) { - ArgumentValidator.EnsureArgumentNotNull(target, "target"); - ArgumentValidator.EnsureArgumentNotNull(association, "association"); + ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(association, "association"); return association.IsPaired || !removedReferences.TryGetValue(Identifier.Make(target, association), out var removedMap) ? Array.Empty() @@ -63,8 +63,8 @@ public IEnumerable GetRemovedReferencesTo(EntityState target, Assoc public IEnumerable GetAddedReferenceTo(EntityState target, AssociationInfo association) { - ArgumentValidator.EnsureArgumentNotNull(target, "target"); - ArgumentValidator.EnsureArgumentNotNull(association, "association"); + ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(association, "association"); return association.IsPaired || !addedReferences.TryGetValue(Identifier.Make(target, association), out var removedMap) ? Array.Empty() @@ -83,8 +83,8 @@ public void Clear() private void RegisterChange(EntityState referencedState, EntityState referencingState, EntityState noLongerReferencedState, AssociationInfo association) { - ArgumentValidator.EnsureArgumentNotNull(association, "association"); - ArgumentValidator.EnsureArgumentNotNull(referencingState, "referencingState"); + ArgumentNullException.ThrowIfNull(association, "association"); + ArgumentNullException.ThrowIfNull(referencingState, "referencingState"); if (!Session.DisableAutoSaveChanges || association.IsPaired || (referencedState == null && noLongerReferencedState == null)) { diff --git a/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/ReferenceFieldsChangesRegistry.cs b/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/ReferenceFieldsChangesRegistry.cs index 450da3440..eae27605b 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/ReferenceFieldsChangesRegistry.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/ReferenceFieldsChangesRegistry.cs @@ -26,9 +26,9 @@ internal sealed class ReferenceFieldsChangesRegistry : SessionBoundRegistry /// Field which value was set./ public void Register(Key fieldOwner, Key fieldValue, FieldInfo field) { - ArgumentValidator.EnsureArgumentNotNull(fieldOwner, "fieldOwner"); - ArgumentValidator.EnsureArgumentNotNull(fieldValue, "fieldValue"); - ArgumentValidator.EnsureArgumentNotNull(field, "field"); + ArgumentNullException.ThrowIfNull(fieldOwner, "fieldOwner"); + ArgumentNullException.ThrowIfNull(fieldValue, "fieldValue"); + ArgumentNullException.ThrowIfNull(field, "field"); Register(new ReferenceFieldChangeInfo(fieldOwner, fieldValue, field)); } @@ -41,10 +41,10 @@ public void Register(Key fieldOwner, Key fieldValue, FieldInfo field) /// Field which value was set. public void Register(Key fieldOwner, Key fieldValue, Key auxiliaryEntity, FieldInfo field) { - ArgumentValidator.EnsureArgumentNotNull(fieldOwner, "fieldOwner"); - ArgumentValidator.EnsureArgumentNotNull(fieldValue, "fieldValue"); - ArgumentValidator.EnsureArgumentNotNull(auxiliaryEntity, "auxiliaryEntity"); - ArgumentValidator.EnsureArgumentNotNull(field, "field"); + ArgumentNullException.ThrowIfNull(fieldOwner, "fieldOwner"); + ArgumentNullException.ThrowIfNull(fieldValue, "fieldValue"); + ArgumentNullException.ThrowIfNull(auxiliaryEntity, "auxiliaryEntity"); + ArgumentNullException.ThrowIfNull(field, "field"); Register(new ReferenceFieldChangeInfo(fieldOwner, fieldValue, auxiliaryEntity, field)); } diff --git a/Orm/Xtensive.Orm/Orm/Internals/FieldAccessors/StructureFieldAccessor.cs b/Orm/Xtensive.Orm/Orm/Internals/FieldAccessors/StructureFieldAccessor.cs index 0936daf0b..7fd31f123 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/FieldAccessors/StructureFieldAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/FieldAccessors/StructureFieldAccessor.cs @@ -22,7 +22,7 @@ public override bool AreSameValues(object oldValue, object newValue) public override void SetValue(Persistent obj, T value) { var field = Field; - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value, "value"); var valueType = value.GetType(); if (field.ValueType != valueType) throw new InvalidOperationException(String.Format( diff --git a/Orm/Xtensive.Orm/Orm/Internals/KeyFactory.cs b/Orm/Xtensive.Orm/Orm/Internals/KeyFactory.cs index 32a8eda87..ea1ff3546 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/KeyFactory.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/KeyFactory.cs @@ -94,7 +94,7 @@ public static Key Materialize(Domain domain, string nodeId, tupleIndex++; for (int valueIndex = 0; valueIndex < values.Length; valueIndex++) { var value = values[valueIndex]; - ArgumentValidator.EnsureArgumentNotNull(value, $"values[{valueIndex}]"); + ArgumentNullException.ThrowIfNull(value, $"values[{valueIndex}]"); var entity = value as Entity; if (entity!=null) { entity.EnsureNotRemoved(); diff --git a/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/CachingSequence.cs b/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/CachingSequence.cs index 7654d2375..6e727d723 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/CachingSequence.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/CachingSequence.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -61,9 +61,7 @@ private TValue GetNextValueUnsafe(SequenceInfo sequenceInfo, Session session) public CachingSequence(IStorageSequenceAccessor accessor, bool threadSafe) { - ArgumentValidator.EnsureArgumentNotNull(accessor, "accessor"); - - this.accessor = accessor; + this.accessor = accessor ?? throw new ArgumentNullException(nameof(accessor)); if (threadSafe) syncRoot = new object(); diff --git a/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/DomainCachingSequenceProvider.cs b/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/DomainCachingSequenceProvider.cs index 8458c61e7..08f45580a 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/DomainCachingSequenceProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/DomainCachingSequenceProvider.cs @@ -1,9 +1,10 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov // Created: 2012.05.17 +using System; using Xtensive.Core; using Xtensive.Orm.Model; using Xtensive.Orm.Providers; @@ -30,9 +31,7 @@ private object CreateSequence(SequenceInfo sequenceInfo) public DomainCachingSequenceProvider(IStorageSequenceAccessor accessor) { - ArgumentValidator.EnsureArgumentNotNull(accessor, "accessor"); - - this.accessor = accessor; + this.accessor = accessor ?? throw new ArgumentNullException(nameof(accessor)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/SessionCachingSequenceProvider.cs b/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/SessionCachingSequenceProvider.cs index eacc00c93..6153ab85f 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/SessionCachingSequenceProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/KeyGenerators/Caching/SessionCachingSequenceProvider.cs @@ -1,9 +1,10 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov // Created: 2012.05.17 +using System; using System.Collections.Generic; using Xtensive.Core; using Xtensive.Orm.Model; @@ -58,9 +59,7 @@ public CachingSequence GetSequence(SequenceInfo sequenceInfo, Session se public SessionCachingSequenceProvider(IStorageSequenceAccessor accessor) { - ArgumentValidator.EnsureArgumentNotNull(accessor, "accessor"); - - this.accessor = accessor; + this.accessor = accessor ?? throw new ArgumentNullException(nameof(accessor)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityContainer.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityContainer.cs index 81e2deac9..af532fa3a 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityContainer.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityContainer.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using Xtensive.Core; using Xtensive.Orm.Model; using Xtensive.Tuples; @@ -89,12 +90,10 @@ private List CreateColumnIndexCollection() protected EntityContainer(Key key, TypeInfo type, bool exactType, PrefetchManager manager) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); - ArgumentValidator.EnsureArgumentNotNull(manager, "processor"); Key = key; - Type = type; + Type = type ?? throw new ArgumentNullException(nameof(type)); ExactType = exactType; - Manager = manager; + Manager = manager ?? throw new ArgumentNullException(nameof(manager)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityGroupTask.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityGroupTask.cs index 09d9abdcf..bafdf54e2 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityGroupTask.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityGroupTask.cs @@ -203,13 +203,11 @@ private void MarkMissedEntityState(Key key, bool exactType) public EntityGroupTask(TypeInfo type, int[] columnIndexes, PrefetchManager manager) { - ArgumentValidator.EnsureArgumentNotNull(type, nameof(type)); - ArgumentValidator.EnsureArgumentNotNull(columnIndexes, nameof(columnIndexes)); + ArgumentNullException.ThrowIfNull(columnIndexes, nameof(columnIndexes)); ArgumentValidator.EnsureArgumentIsGreaterThan(columnIndexes.Length, 0, "columnIndexes.Length"); - ArgumentValidator.EnsureArgumentNotNull(manager, nameof(manager)); - this.type = type; - this.manager = manager; + this.type = type ?? throw new ArgumentNullException(nameof(type)); + this.manager = manager ?? throw new ArgumentNullException(nameof(manager)); var cachedHashCode = 0; foreach (var columnIndex in columnIndexes) { cachedHashCode = unchecked (379 * cachedHashCode + columnIndex); diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntitySetTask.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntitySetTask.cs index 2bf5073d7..618f3a6b1 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntitySetTask.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntitySetTask.cs @@ -260,15 +260,11 @@ private static Pair[] GetJoiningColumnIndexes(IndexInfo primaryIndex, Index public EntitySetTask(Key ownerKey, PrefetchFieldDescriptor referencingFieldDescriptor, bool isOwnerCached, PrefetchManager manager) { - ArgumentValidator.EnsureArgumentNotNull(ownerKey, "ownerKey"); - ArgumentValidator.EnsureArgumentNotNull(referencingFieldDescriptor, "referencingFieldDescriptor"); - ArgumentValidator.EnsureArgumentNotNull(manager, "processor"); - - this.ownerKey = ownerKey; - this.referencingFieldDescriptor = referencingFieldDescriptor; + this.ownerKey = ownerKey ?? throw new ArgumentNullException(nameof(ownerKey)); + this.referencingFieldDescriptor = referencingFieldDescriptor ?? throw new ArgumentNullException(nameof(referencingFieldDescriptor)); this.isOwnerCached = isOwnerCached; ItemCountLimit = referencingFieldDescriptor.EntitySetItemCountLimit; - this.manager = manager; + this.manager = manager ?? throw new ArgumentNullException(nameof(manager)); cacheKey = new ItemsQueryCacheKey(ReferencingField, ItemCountLimit); } } diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Fetcher.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Fetcher.cs index 9cbfff473..76715cb1c 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Fetcher.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Fetcher.cs @@ -4,6 +4,7 @@ // Created by: Alexander Nikolaev // Created: 2009.10.20 +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -127,8 +128,7 @@ public Fetcher(PrefetchManager manager) { tasks = new HashSet(); foundKeys = new HashSet(); - ArgumentValidator.EnsureArgumentNotNull(manager, nameof(manager)); - this.manager = manager; + this.manager = manager ?? throw new ArgumentNullException(nameof(manager)); } } } diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/GraphContainer.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/GraphContainer.cs index ed4300d2f..344cb5d8b 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/GraphContainer.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/GraphContainer.cs @@ -9,6 +9,7 @@ using Xtensive.Core; using Xtensive.Tuples; using Xtensive.Orm.Model; +using System; namespace Xtensive.Orm.Internals.Prefetch { @@ -188,14 +189,9 @@ private void RegisterFetchByUnknownForeignKey(PrefetchFieldDescriptor referencin public GraphContainer(Key key, TypeInfo type, bool exactType, PrefetchManager manager) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); - ArgumentValidator.EnsureArgumentNotNull(type, "type"); - ArgumentValidator.EnsureArgumentNotNull(manager, "processor"); - - Key = key; - Type = type; - - Manager = manager; + Key = key ?? throw new ArgumentNullException(nameof(key)); + Type = type ?? throw new ArgumentNullException(nameof(type)); + Manager = manager ?? throw new ArgumentNullException(nameof(manager)); this.exactType = exactType; } } diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/KeyExtractorNode.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/KeyExtractorNode.cs index 4e11dd5cc..38df32825 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/KeyExtractorNode.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/KeyExtractorNode.cs @@ -45,11 +45,8 @@ protected override string GetDescription() public KeyExtractorNode(Func> extractor, IReadOnlyList nestedNodes) : base("*") { - ArgumentValidator.EnsureArgumentNotNull(extractor, nameof(extractor)); - ArgumentValidator.EnsureArgumentNotNull(nestedNodes, nameof(nestedNodes)); - - KeyExtractor = extractor; - NestedNodes = nestedNodes; + KeyExtractor = extractor ?? throw new ArgumentNullException(nameof(extractor)); + NestedNodes = nestedNodes ?? throw new ArgumentNullException(nameof(nestedNodes)); } } } diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchFieldDescriptor.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchFieldDescriptor.cs index 9d9b41397..9d49ade53 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchFieldDescriptor.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchFieldDescriptor.cs @@ -137,12 +137,11 @@ public PrefetchFieldDescriptor( bool fetchLazyFields, Action keyExtractionSubscriber) { - ArgumentValidator.EnsureArgumentNotNull(field, "field"); if (entitySetItemCountLimit != null) { ArgumentValidator.EnsureArgumentIsGreaterThan(entitySetItemCountLimit.Value, 0, "entitySetItemCountLimit"); } - Field = field; + Field = field ?? throw new ArgumentNullException(nameof(field)); FetchFieldsOfReferencedEntity = fetchFieldsOfReferencedEntity; EntitySetItemCountLimit = entitySetItemCountLimit; FetchLazyFields = fetchLazyFields; @@ -172,12 +171,11 @@ private PrefetchFieldDescriptor( Action keyExtractionSubscriber, Guid? prefetchOperationId) { - ArgumentValidator.EnsureArgumentNotNull(field, "field"); if (entitySetItemCountLimit != null) { ArgumentValidator.EnsureArgumentIsGreaterThan(entitySetItemCountLimit.Value, 0, "entitySetItemCountLimit"); } - Field = field; + Field = field ?? throw new ArgumentNullException(nameof(field)); FetchFieldsOfReferencedEntity = fetchFieldsOfReferencedEntity; EntitySetItemCountLimit = entitySetItemCountLimit; FetchLazyFields = fetchLazyFields; diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchManager.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchManager.cs index d8ac2ebf4..3a81cd6cc 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchManager.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchManager.cs @@ -110,8 +110,8 @@ public async Task PrefetchAsync(Key key, TypeInfo type private async ValueTask Prefetch( Key key, TypeInfo type, IReadOnlyList descriptors, bool isAsync, CancellationToken token) { - ArgumentValidator.EnsureArgumentNotNull(key, nameof(key)); - ArgumentValidator.EnsureArgumentNotNull(descriptors, nameof(descriptors)); + ArgumentNullException.ThrowIfNull(key, nameof(key)); + ArgumentNullException.ThrowIfNull(descriptors, nameof(descriptors)); if (descriptors.Count == 0) { return null; @@ -134,7 +134,7 @@ private async ValueTask Prefetch( EnsureAllFieldsBelongToSpecifiedType(descriptors, currentType); } else { - ArgumentValidator.EnsureArgumentNotNull(currentType, "type"); + ArgumentNullException.ThrowIfNull(currentType, "type"); EnsureAllFieldsBelongToSpecifiedType(descriptors, currentType); _ = SetUpContainers(currentKey, currentKey.TypeReference.Type, PrefetchHelper.GetCachedDescriptorsForFieldsLoadedByDefault(session.Domain, currentKey.TypeReference.Type), @@ -348,9 +348,7 @@ private bool TrySetCachedColumnIndexes( public PrefetchManager(Session session) { - ArgumentValidator.EnsureArgumentNotNull(session, "session"); - - this.session = session; + this.session = session ?? throw new ArgumentNullException(nameof(session)); fetcher = new Fetcher(this); columnsCache = new LruCache( diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/ReferencedEntityContainer.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/ReferencedEntityContainer.cs index b5f6305c0..0802be3b7 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/ReferencedEntityContainer.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/ReferencedEntityContainer.cs @@ -121,10 +121,8 @@ public ReferencedEntityContainer(Key ownerKey, PrefetchFieldDescriptor referenci bool isOwnerTypeKnown, PrefetchManager manager) : base(null, referencingFieldDescriptor.Field.Associations.Last().TargetType, true, manager) { - ArgumentValidator.EnsureArgumentNotNull(referencingFieldDescriptor, "referencingFieldDescriptor"); - ArgumentValidator.EnsureArgumentNotNull(ownerKey, "ownerKey"); - this.ownerKey = ownerKey; - this.referencingFieldDescriptor = referencingFieldDescriptor; + this.ownerKey = ownerKey ?? throw new ArgumentNullException(nameof(ownerKey)); + this.referencingFieldDescriptor = referencingFieldDescriptor ?? throw new ArgumentNullException(nameof(referencingFieldDescriptor)); this.isOwnerTypeKnown = isOwnerTypeKnown; } } diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/RootEntityContainer.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/RootEntityContainer.cs index dc0a1f7a4..61b9c5ce0 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/RootEntityContainer.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/RootEntityContainer.cs @@ -44,7 +44,7 @@ public void NotifyOwnerAboutKeyWithUnknownType() public RootEntityContainer(Key key, TypeInfo type, bool exactType, PrefetchManager manager) : base(key, type, exactType, manager) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); + ArgumentNullException.ThrowIfNull(key, "key"); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Internals/QueryTask.cs b/Orm/Xtensive.Orm/Orm/Internals/QueryTask.cs index 3a9517948..f74ac3d16 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/QueryTask.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/QueryTask.cs @@ -67,8 +67,7 @@ IEnumerator IEnumerable.GetEnumerator() /// The parameter value context. public QueryTask(ExecutableProvider dataSource, StateLifetimeToken lifetimeToken, ParameterContext parameterContext) { - ArgumentValidator.EnsureArgumentNotNull(dataSource, "dataSource"); - DataSource = dataSource; + DataSource = dataSource ?? throw new ArgumentNullException(nameof(dataSource)); LifetimeToken = lifetimeToken; ParameterContext = parameterContext; } diff --git a/Orm/Xtensive.Orm/Orm/Internals/ReferentialIntegrity/RemovalProcessor.cs b/Orm/Xtensive.Orm/Orm/Internals/ReferentialIntegrity/RemovalProcessor.cs index d91a50e11..b78912cf8 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/ReferentialIntegrity/RemovalProcessor.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/ReferentialIntegrity/RemovalProcessor.cs @@ -49,7 +49,7 @@ public void EnqueueForRemoval(IEnumerable entities, EntityRemoveReason r public void Remove(IEnumerable entities, EntityRemoveReason reason) { - ArgumentValidator.EnsureArgumentNotNull(entities, "entities"); + ArgumentNullException.ThrowIfNull(entities, "entities"); var isEmpty = true; foreach (var entity in entities) { isEmpty = false; diff --git a/Orm/Xtensive.Orm/Orm/Internals/RemapContext.cs b/Orm/Xtensive.Orm/Orm/Internals/RemapContext.cs index 74c6d882d..b7e9a6bd3 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/RemapContext.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/RemapContext.cs @@ -1,9 +1,10 @@ -// Copyright (C) 2014 Xtensive LLC. +// Copyright (C) 2014 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Alexey Kulakov // Created: 2014.04.07 +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Xtensive.Core; @@ -37,8 +38,8 @@ public IEnumerable EntitiesToRemap /// Actual key public void RegisterKeyMap(Key localKey, Key realKey) { - ArgumentValidator.EnsureArgumentNotNull(localKey, "localKey"); - ArgumentValidator.EnsureArgumentNotNull(realKey, "realKey"); + ArgumentNullException.ThrowIfNull(localKey, "localKey"); + ArgumentNullException.ThrowIfNull(realKey, "realKey"); if(localKey!=realKey) keyMap.Add(localKey, realKey); } @@ -58,8 +59,7 @@ public Key TryRemapKey(Key oldKey) public RemapContext(EntityChangeRegistry registry) { - ArgumentValidator.EnsureArgumentNotNull(registry, "registry"); - this.registry = registry; + this.registry = registry ?? throw new ArgumentNullException(nameof(registry)); keyMap = new Dictionary(); } } diff --git a/Orm/Xtensive.Orm/Orm/Internals/StorageNodeRegistry.cs b/Orm/Xtensive.Orm/Orm/Internals/StorageNodeRegistry.cs index 8e42e0784..0c9e7bbe8 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/StorageNodeRegistry.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/StorageNodeRegistry.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2014 Xtensive LLC. +// Copyright (C) 2014 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -17,13 +17,13 @@ internal sealed class StorageNodeRegistry public bool Add(StorageNode node) { - ArgumentValidator.EnsureArgumentNotNull(node, "node"); + ArgumentNullException.ThrowIfNull(node, "node"); return nodes.TryAdd(node.Id, node); } public bool Remove(string nodeId) { - ArgumentValidator.EnsureArgumentNotNull(nodeId, "nodeId"); + ArgumentNullException.ThrowIfNull(nodeId, "nodeId"); if (nodeId==WellKnown.DefaultNodeId) throw new InvalidOperationException(Strings.ExDefaultStorageNodeCanNotBeRemoved); StorageNode dummy; @@ -32,7 +32,7 @@ public bool Remove(string nodeId) public StorageNode TryGet(string nodeId) { - ArgumentValidator.EnsureArgumentNotNull(nodeId, "nodeId"); + ArgumentNullException.ThrowIfNull(nodeId, "nodeId"); StorageNode result; nodes.TryGetValue(nodeId, out result); return result; @@ -40,7 +40,7 @@ public StorageNode TryGet(string nodeId) public StorageNode Get(string nodeId) { - ArgumentValidator.EnsureArgumentNotNull(nodeId, "nodeId"); + ArgumentNullException.ThrowIfNull(nodeId, "nodeId"); StorageNode result; if (!nodes.TryGetValue(nodeId, out result)) throw new KeyNotFoundException(string.Format(Strings.ExStorageNodeWithIdXIsNotFound, nodeId)); diff --git a/Orm/Xtensive.Orm/Orm/Internals/VersionGenerator.cs b/Orm/Xtensive.Orm/Orm/Internals/VersionGenerator.cs index 5093c8aa7..7ffe41cca 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/VersionGenerator.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/VersionGenerator.cs @@ -24,7 +24,7 @@ public static class VersionGenerator /// Unsupported type. public static object GenerateNextVersion(object currentVersion) { - ArgumentValidator.EnsureArgumentNotNull(currentVersion, "currentValue"); + ArgumentNullException.ThrowIfNull(currentVersion, "currentValue"); TypeCode code = Type.GetTypeCode(currentVersion.GetType()); switch (code) { diff --git a/Orm/Xtensive.Orm/Orm/Key.cs b/Orm/Xtensive.Orm/Orm/Key.cs index 893febf90..778d2742d 100644 --- a/Orm/Xtensive.Orm/Orm/Key.cs +++ b/Orm/Xtensive.Orm/Orm/Key.cs @@ -94,7 +94,7 @@ public bool IsTemporary(Domain domain) [NotNull] public TypeInfo ResolveTypeInfo([NotNull, InstantHandle] Session session) { - ArgumentValidator.EnsureArgumentNotNull(session, "session"); + ArgumentNullException.ThrowIfNull(session, "session"); if (TypeReference.Accuracy==TypeReferenceAccuracy.ExactType) return TypeReference.Type; @@ -280,7 +280,7 @@ public static Key Parse([NotNull] Domain domain, string source) if (source==null) return null; - ArgumentValidator.EnsureArgumentNotNull(domain, "domain"); + ArgumentNullException.ThrowIfNull(domain, "domain"); var parts = source.RevertibleSplit(KeyFormatEscape, KeyFormatDelimiter).ToList(); if (parts.Count!=2 && parts.Count!=3 || parts.Contains(null)) @@ -350,8 +350,8 @@ public static Key Generate([NotNull] Session session) /// public static Key Generate([NotNull] Session session, [NotNull] Type type) { - ArgumentValidator.EnsureArgumentNotNull(session, "session"); - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(session, "session"); + ArgumentNullException.ThrowIfNull(type, "type"); return Generate(session, session.Domain.Model.Types[type]); } @@ -424,9 +424,9 @@ public static Key Create([NotNull] Domain domain, [NotNull] Type type, TypeRefer /// A newly created or existing instance. public static Key Create([NotNull] Domain domain, [NotNull] string nodeId, [NotNull] Type type, TypeReferenceAccuracy accuracy, [NotNull] Tuple value) { - ArgumentValidator.EnsureArgumentNotNull(domain, "domain"); - ArgumentValidator.EnsureArgumentNotNull(type, "type"); - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(domain, "domain"); + ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(value, "value"); return Create(domain, nodeId, domain.Model.Types[type], accuracy, value); } @@ -497,10 +497,10 @@ public static Key Create([NotNull] Domain domain, [NotNull] Type type, TypeRefer /// A newly created or existing instance. public static Key Create([NotNull] Domain domain, [NotNull] string nodeId, [NotNull] Type type, TypeReferenceAccuracy accuracy, [NotNull] params object[] values) { - ArgumentValidator.EnsureArgumentNotNull(domain, "domain"); - ArgumentValidator.EnsureArgumentNotNull(nodeId, "nodeId"); - ArgumentValidator.EnsureArgumentNotNull(type, "type"); - ArgumentValidator.EnsureArgumentNotNull(values, "values"); + ArgumentNullException.ThrowIfNull(domain, "domain"); + ArgumentNullException.ThrowIfNull(nodeId, "nodeId"); + ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(values, "values"); return Create(domain, nodeId, domain.Model.Types[type], accuracy, values); } diff --git a/Orm/Xtensive.Orm/Orm/Linq/LocalCollectionKeyTypeExtractor.cs b/Orm/Xtensive.Orm/Orm/Linq/LocalCollectionKeyTypeExtractor.cs index 0afc1c4d4..6494a9991 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/LocalCollectionKeyTypeExtractor.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/LocalCollectionKeyTypeExtractor.cs @@ -19,7 +19,7 @@ internal static class LocalCollectionKeyTypeExtractor { public static Type Extract(BinaryExpression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); if (expression.Right.StripMarkers() is KeyExpression key) { return key.EntityType.UnderlyingType; } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Materialization/MaterializationContext.cs b/Orm/Xtensive.Orm/Orm/Linq/Materialization/MaterializationContext.cs index 98374dec3..d40234869 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Materialization/MaterializationContext.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Materialization/MaterializationContext.cs @@ -108,7 +108,7 @@ public TypeMapping GetTypeMapping(int entityIndex, TypeInfo approximateType, int private int ResolveTypeToNodeSpecificTypeIdentifier(TypeInfo typeInfo) { - ArgumentValidator.EnsureArgumentNotNull(typeInfo, "typeInfo"); + ArgumentNullException.ThrowIfNull(typeInfo, "typeInfo"); return TypeIdRegistry[typeInfo]; } diff --git a/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs b/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs index 4928eed95..81e6b186b 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs @@ -48,7 +48,7 @@ private readonly Dictionary compilers public Delegate GetUntypedCompiler(MemberInfo target) { - ArgumentValidator.EnsureArgumentNotNull(target, nameof(target)); + ArgumentNullException.ThrowIfNull(target, nameof(target)); return compilers.GetValueOrDefault(GetCompilerKey(target)); } @@ -66,7 +66,7 @@ public void RegisterCompilers(Type compilerContainer) public void RegisterCompilers(Type compilerContainer, ConflictHandlingMethod conflictHandlingMethod) { - ArgumentValidator.EnsureArgumentNotNull(compilerContainer, "compilerContainer"); + ArgumentNullException.ThrowIfNull(compilerContainer, "compilerContainer"); EnsureNotLocked(); if (compilerContainer.IsGenericType) @@ -87,7 +87,7 @@ public void RegisterCompilers(IEnumerable>> compilerDefinitions, ConflictHandlingMethod conflictHandlingMethod) { - ArgumentValidator.EnsureArgumentNotNull(compilerDefinitions, "compilerDefinitions"); + ArgumentNullException.ThrowIfNull(compilerDefinitions, "compilerDefinitions"); EnsureNotLocked(); var newItems = compilerDefinitions.Select(item => (item.Key, (Delegate) item.Value)); diff --git a/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProviderFactory.cs b/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProviderFactory.cs index 6e646fc6f..71e86f319 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProviderFactory.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProviderFactory.cs @@ -22,7 +22,7 @@ public static class MemberCompilerProviderFactory /// The type. public static IMemberCompilerProvider Create(Type type) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type, "type"); var concreteType = typeof (MemberCompilerProvider<>).CachedMakeGenericType(type); return (IMemberCompilerProvider) Activator.CreateInstance(concreteType); } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Queryable.cs b/Orm/Xtensive.Orm/Orm/Linq/Queryable.cs index 42affc9d5..f8200fd05 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Queryable.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Queryable.cs @@ -61,7 +61,7 @@ public async IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati /// is out of range. public Queryable(QueryProvider provider, Expression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression, nameof(expression)); if (!typeof (IQueryable).IsAssignableFrom(expression.Type)) { throw new ArgumentOutOfRangeException(nameof(expression)); } diff --git a/Orm/Xtensive.Orm/Orm/Linq/TranslatorContext.cs b/Orm/Xtensive.Orm/Orm/Linq/TranslatorContext.cs index 39af224ed..c465aad1d 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/TranslatorContext.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/TranslatorContext.cs @@ -140,9 +140,9 @@ private Expression ApplyPreprocessor(IQueryPreprocessor preprocessor, Session se public TranslatorContext(Session session, CompilerConfiguration rseCompilerConfiguration, Expression query, CompiledQueryProcessingScope compiledQueryScope) { - ArgumentValidator.EnsureArgumentNotNull(session, nameof(session)); - ArgumentValidator.EnsureArgumentNotNull(rseCompilerConfiguration, nameof(rseCompilerConfiguration)); - ArgumentValidator.EnsureArgumentNotNull(query, nameof(query)); + ArgumentNullException.ThrowIfNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(rseCompilerConfiguration, nameof(rseCompilerConfiguration)); + ArgumentNullException.ThrowIfNull(query, nameof(query)); Domain = session.Domain; RseCompilerConfiguration = rseCompilerConfiguration; diff --git a/Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs b/Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs index 523c36c20..357943d87 100644 --- a/Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs +++ b/Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs @@ -37,7 +37,7 @@ public abstract class BaseLog /// object. Region will closed by disposing of this object. public IndentManager.IndentScope DebugRegion(string messageId, params object[] parameters) { - ArgumentValidator.EnsureArgumentNotNull(messageId, "message"); + ArgumentNullException.ThrowIfNull(messageId, "message"); if (!IsLogged(LogLevel.Debug)) return IndentManager.IncreaseIndent(); var message = Strings.ResourceManager.GetString(messageId, Strings.Culture) ?? messageId; @@ -60,7 +60,7 @@ public IndentManager.IndentScope DebugRegion(string messageId, params object[] p /// object. Region will closed by disposing of this object. public IndentManager.IndentScope InfoRegion(string messageId, params object[] parameters) { - ArgumentValidator.EnsureArgumentNotNull(messageId, "message"); + ArgumentNullException.ThrowIfNull(messageId, "message"); if (!IsLogged(LogLevel.Info)) return IndentManager.IncreaseIndent(); var message = Strings.ResourceManager.GetString(messageId, Strings.Culture) ?? messageId; diff --git a/Orm/Xtensive.Orm/Orm/Logging/Internals/InternalLog.cs b/Orm/Xtensive.Orm/Orm/Logging/Internals/InternalLog.cs index ece26a04a..ad3419e22 100644 --- a/Orm/Xtensive.Orm/Orm/Logging/Internals/InternalLog.cs +++ b/Orm/Xtensive.Orm/Orm/Logging/Internals/InternalLog.cs @@ -4,7 +4,7 @@ // Created by: Alexey Kulakov // Created: 2013.09.27 -using Xtensive.Core; +using System; namespace Xtensive.Orm.Logging { @@ -25,8 +25,7 @@ public override void Write(in LogEventInfo info) public InternalLog(string name, LogWriter writer) : base(name) { - ArgumentValidator.EnsureArgumentNotNull(writer, "writer"); - this.writer = writer; + this.writer = writer ?? throw new ArgumentNullException(nameof(writer)); } } } diff --git a/Orm/Xtensive.Orm/Orm/Logging/LogManager.cs b/Orm/Xtensive.Orm/Orm/Logging/LogManager.cs index a87682153..e49d4a392 100644 --- a/Orm/Xtensive.Orm/Orm/Logging/LogManager.cs +++ b/Orm/Xtensive.Orm/Orm/Logging/LogManager.cs @@ -41,7 +41,7 @@ public void Initialize(System.Configuration.Configuration configuration) /// Instance of class, which implements . public void Initialize(LogProvider logProvider) { - ArgumentValidator.EnsureArgumentNotNull(logProvider, "logProvider"); + ArgumentNullException.ThrowIfNull(logProvider, "logProvider"); lock (syncObj) { EnsureIsNotInitialized(); provider = logProvider; @@ -54,7 +54,7 @@ public void Initialize(LogProvider logProvider) /// Configuration of logging. public void Initialize(LoggingConfiguration configuration) { - ArgumentValidator.EnsureArgumentNotNull(configuration, "configuration"); + ArgumentNullException.ThrowIfNull(configuration, "configuration"); lock (syncObj) { EnsureIsNotInitialized(); if (!string.IsNullOrEmpty(configuration.Provider)) { diff --git a/Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs b/Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs index 5e5c1856c..966e87d21 100644 --- a/Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs +++ b/Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs @@ -100,7 +100,7 @@ public override string ToString() => /// The instance. public ColumnInfoRef(ColumnInfo columnInfo) { - ArgumentValidator.EnsureArgumentNotNull(columnInfo, "columnInfo"); + ArgumentNullException.ThrowIfNull(columnInfo, "columnInfo"); TypeName = columnInfo.Field.DeclaringType.Name; FieldName = columnInfo.Field.Name; ColumnName = columnInfo.Name; diff --git a/Orm/Xtensive.Orm/Orm/Model/FieldInfo.cs b/Orm/Xtensive.Orm/Orm/Model/FieldInfo.cs index c7def21ad..a0144281e 100644 --- a/Orm/Xtensive.Orm/Orm/Model/FieldInfo.cs +++ b/Orm/Xtensive.Orm/Orm/Model/FieldInfo.cs @@ -478,7 +478,7 @@ public FieldInfo Parent [DebuggerStepThrough] set { EnsureNotLocked(); - ArgumentValidator.EnsureArgumentNotNull(value, "Parent"); + ArgumentNullException.ThrowIfNull(value, "Parent"); parent = value; parent.Fields.Add(this); reflectedType = value.ReflectedType; diff --git a/Orm/Xtensive.Orm/Orm/Model/Stored/Internals/TypeMappingUpdater.cs b/Orm/Xtensive.Orm/Orm/Model/Stored/Internals/TypeMappingUpdater.cs index cb20b47a3..759740bf4 100644 --- a/Orm/Xtensive.Orm/Orm/Model/Stored/Internals/TypeMappingUpdater.cs +++ b/Orm/Xtensive.Orm/Orm/Model/Stored/Internals/TypeMappingUpdater.cs @@ -1,5 +1,8 @@ - +// Copyright (C) 2016-2020 Xtensive LLC. +// This code is distributed under MIT license terms. +// See the License.txt file in the project root for more information. +using System; using Xtensive.Core; using Xtensive.Orm.Configuration; @@ -9,8 +12,8 @@ internal sealed class TypeMappingUpdater { public void UpdateMappings(StoredDomainModel model, NodeConfiguration nodeConfiguration) { - ArgumentValidator.EnsureArgumentNotNull(model, "model"); - ArgumentValidator.EnsureArgumentNotNull(nodeConfiguration, "nodeConfiguration"); + ArgumentNullException.ThrowIfNull(model, "model"); + ArgumentNullException.ThrowIfNull(nodeConfiguration, "nodeConfiguration"); foreach (var storedType in model.Types) { if (!storedType.MappingDatabase.IsNullOrEmpty()) diff --git a/Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs b/Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs index 88eced72c..67791809b 100644 --- a/Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs +++ b/Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs @@ -37,7 +37,7 @@ public sealed class TypeIdRegistry : LockableBase public int this[TypeInfo type] { get { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type, "type"); return !mapping.TryGetValue(type, out var result) ? throw new KeyNotFoundException(string.Format(Strings.ExTypeXIsNotRegistered, type.Name)) : result; @@ -62,7 +62,7 @@ public int this[TypeInfo type] /// otherwise false. public bool Contains(TypeInfo type) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type, "type"); return mapping.ContainsKey(type); } @@ -77,7 +77,7 @@ public bool Contains(TypeInfo type) /// otherwise . public int GetTypeId(TypeInfo type) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type, "type"); return !mapping.TryGetValue(type, out var result) ? TypeInfo.NoTypeId : result; } @@ -100,7 +100,7 @@ public void Clear() /// Type. public void Register(int typeId, TypeInfo type) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type, "type"); EnsureNotLocked(); mapping[type] = typeId; diff --git a/Orm/Xtensive.Orm/Orm/Model/TypeInfoCollection.cs b/Orm/Xtensive.Orm/Orm/Model/TypeInfoCollection.cs index 00105cbb1..d30c00e45 100644 --- a/Orm/Xtensive.Orm/Orm/Model/TypeInfoCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Model/TypeInfoCollection.cs @@ -162,7 +162,7 @@ public override bool Contains(TypeInfo item) /// , if there is no type with specified full name. public TypeInfo Find(string fullName) { - ArgumentValidator.EnsureArgumentNotNull(fullName, "fullName"); + ArgumentNullException.ThrowIfNull(fullName, "fullName"); TypeInfo result; return fullNameTable.TryGetValue(fullName, out result) ? result : null; } diff --git a/Orm/Xtensive.Orm/Orm/Operations/EntityFieldOperation.cs b/Orm/Xtensive.Orm/Orm/Operations/EntityFieldOperation.cs index 9b1c67dca..cc82032fc 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/EntityFieldOperation.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/EntityFieldOperation.cs @@ -44,8 +44,7 @@ public override string Description { protected EntityFieldOperation(Key key, FieldInfo field) : base(key) { - ArgumentValidator.EnsureArgumentNotNull(field, "field"); - Field = field; + Field = field ?? throw new ArgumentNullException(nameof(field)); } // Serialization diff --git a/Orm/Xtensive.Orm/Orm/Operations/EntityOperation.cs b/Orm/Xtensive.Orm/Orm/Operations/EntityOperation.cs index 61437c70c..1149fc140 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/EntityOperation.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/EntityOperation.cs @@ -27,7 +27,7 @@ public abstract class EntityOperation : KeyOperation protected EntityOperation(Key key) : base(key) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); + ArgumentNullException.ThrowIfNull(key, "key"); } /// diff --git a/Orm/Xtensive.Orm/Orm/Operations/EntitySetItemOperation.cs b/Orm/Xtensive.Orm/Orm/Operations/EntitySetItemOperation.cs index 3840c3e46..6c155b0f8 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/EntitySetItemOperation.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/EntitySetItemOperation.cs @@ -52,8 +52,7 @@ protected override void PrepareSelf(OperationExecutionContext context) protected EntitySetItemOperation(Key key, FieldInfo field, Key itemKey) : base(key, field) { - ArgumentValidator.EnsureArgumentNotNull(itemKey, "itemKey"); - ItemKey = itemKey; + ItemKey = itemKey ?? throw new ArgumentNullException(nameof(itemKey)); } // Serialization diff --git a/Orm/Xtensive.Orm/Orm/Operations/Internals/OperationRegistrationScope.cs b/Orm/Xtensive.Orm/Orm/Operations/Internals/OperationRegistrationScope.cs index 9b788a7b3..6c1b40c65 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/Internals/OperationRegistrationScope.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/Internals/OperationRegistrationScope.cs @@ -39,7 +39,7 @@ public void Complete() /// public void RegisterEntityIdentifier(Key key, string identifier) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); + ArgumentNullException.ThrowIfNull(key, "key"); // Initializing dictionaries, if necessary if (IdentifierByKey == null) { diff --git a/Orm/Xtensive.Orm/Orm/Operations/KeyGenerateOperation.cs b/Orm/Xtensive.Orm/Orm/Operations/KeyGenerateOperation.cs index cbc3852cc..724022075 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/KeyGenerateOperation.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/KeyGenerateOperation.cs @@ -109,7 +109,7 @@ protected override Operation CloneSelf(Operation clone) public KeyGenerateOperation(Key key) : base(key) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); + ArgumentNullException.ThrowIfNull(key, "key"); } /// diff --git a/Orm/Xtensive.Orm/Orm/Operations/MethodCallOperation.cs b/Orm/Xtensive.Orm/Orm/Operations/MethodCallOperation.cs index 629f2632e..dcd184234 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/MethodCallOperation.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/MethodCallOperation.cs @@ -104,9 +104,8 @@ public MethodCallOperation( Action executeAction, params object[] arguments) { - ArgumentValidator.EnsureArgumentNotNull(executeAction, "executeAction"); this.prepareAction = prepareAction; - this.executeAction = executeAction; + this.executeAction = executeAction ?? throw new ArgumentNullException(nameof(executeAction)); this.arguments = arguments; } } diff --git a/Orm/Xtensive.Orm/Orm/Operations/OperationCapturer.cs b/Orm/Xtensive.Orm/Orm/Operations/OperationCapturer.cs index b76bbd4f1..586f95ea4 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/OperationCapturer.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/OperationCapturer.cs @@ -121,8 +121,7 @@ public static OperationCapturer Attach(Session session, IOperationLogger operati private OperationCapturer(Session session, IOperationLogger operations) : base(session) { - ArgumentValidator.EnsureArgumentNotNull(operations, "operations"); - Operations = operations; + Operations = operations ?? throw new ArgumentNullException(nameof(operations)); AttachEventHandlers(); } diff --git a/Orm/Xtensive.Orm/Orm/Operations/ValidateVersionOperation.cs b/Orm/Xtensive.Orm/Orm/Operations/ValidateVersionOperation.cs index b0244467c..3f893d499 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/ValidateVersionOperation.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/ValidateVersionOperation.cs @@ -90,7 +90,7 @@ protected override Operation CloneSelf(Operation clone) public ValidateVersionOperation(Key key, VersionInfo version) : base(key) { - ArgumentValidator.EnsureArgumentNotNull(version, "version"); + ArgumentNullException.ThrowIfNull(version, "version"); Version = version; } diff --git a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandFactory.cs b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandFactory.cs index 7316d5dd2..b75c3caca 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandFactory.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandFactory.cs @@ -44,7 +44,7 @@ public IEnumerable CreatePersistParts(SqlPersistTask task) public virtual IEnumerable CreatePersistParts(SqlPersistTask task, in string parameterNamePrefix) { - ArgumentValidator.EnsureArgumentNotNull(task, "task"); + ArgumentNullException.ThrowIfNull(task, "task"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(parameterNamePrefix, "parameterNamePrefix"); var upgradeContext = Upgrade.UpgradeContext.GetCurrent(Session.Domain.UpgradeContextCookie); @@ -95,7 +95,7 @@ public CommandPart CreateQueryPart(IQueryRequest request, ParameterContext param public virtual CommandPart CreateQueryPart(IQueryRequest request, in string parameterNamePrefix, ParameterContext parameterContext) { - ArgumentValidator.EnsureArgumentNotNull(request, "request"); + ArgumentNullException.ThrowIfNull(request, "request"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(parameterNamePrefix, "parameterNamePrefix"); int parameterIndex = 0; @@ -291,13 +291,9 @@ private string GetParameterName(in string prefix, ref int index) public CommandFactory(StorageDriver driver, Session session, SqlConnection connection) { - ArgumentValidator.EnsureArgumentNotNull(driver, "driver"); - ArgumentValidator.EnsureArgumentNotNull(session, "session"); - ArgumentValidator.EnsureArgumentNotNull(connection, "connection"); - - Driver = driver; - Session = session; - Connection = connection; + Driver = driver ?? throw new ArgumentNullException(nameof(driver)); + Session = session ?? throw new ArgumentNullException(nameof(session)); + Connection = connection ?? throw new ArgumentNullException(nameof(connection)); emptyStringIsNull = driver.ProviderInfo.Supports(ProviderFeatures.TreatEmptyStringAsNull); shareStorageNodesOverNodes = session.Domain.Configuration.ShareStorageSchemaOverNodes; diff --git a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandProcessor.cs b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandProcessor.cs index 7c2e3a5d6..b364a6c47 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandProcessor.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandProcessor.cs @@ -4,6 +4,7 @@ // Created by: Denis Krjuchkov // Created: 2009.08.20 +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -162,9 +163,8 @@ protected ExecutionBehavior GetCommandExecutionBehavior(ICollection /// The maximum parameter count per query. protected CommandProcessor(CommandFactory factory, int maxQueryParameterCount) { - ArgumentValidator.EnsureArgumentNotNull(factory, "factory"); ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(maxQueryParameterCount, 0, "maxQueryParameterCount"); - Factory = factory; + Factory = factory ?? throw new ArgumentNullException(nameof(factory)); MaxQueryParameterCount = maxQueryParameterCount; } } diff --git a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/SqlLoadTask.cs b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/SqlLoadTask.cs index ecde7725d..df1011bd9 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/SqlLoadTask.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/SqlLoadTask.cs @@ -4,6 +4,7 @@ // Created by: Denis Krjuchkov // Created: 2009.08.21 +using System; using System.Collections.Generic; using Xtensive.Core; using Tuple = Xtensive.Tuples.Tuple; @@ -47,12 +48,9 @@ public override void ProcessWith(ISqlTaskProcessor processor, CommandProcessorCo /// A value for . public SqlLoadTask(QueryRequest request, List output, ParameterContext parameterContext) { - ArgumentValidator.EnsureArgumentNotNull(request, "request"); - ArgumentValidator.EnsureArgumentNotNull(output, "output"); - - Request = request; + Request = request ?? throw new ArgumentNullException(nameof(request)); ParameterContext = parameterContext; - Output = output; + Output = output ?? throw new ArgumentNullException(nameof(output)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Providers/CommandWithDataReader.cs b/Orm/Xtensive.Orm/Orm/Providers/CommandWithDataReader.cs index 67f40513c..50137b064 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/CommandWithDataReader.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/CommandWithDataReader.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2020 Xtensive LLC. +// Copyright (C) 2012-2020 Xtensive LLC. // This code is distributed under MIT license terms. // See the License.txt file in the project root for more information. // Created by: Denis Krjuchkov @@ -34,11 +34,8 @@ public async ValueTask DisposeAsync() internal CommandWithDataReader(DbCommand command, DbDataReader reader) { - ArgumentValidator.EnsureArgumentNotNull(command, nameof(command)); - ArgumentValidator.EnsureArgumentNotNull(reader, nameof(reader)); - - Command = command; - Reader = reader; + Command = command ?? throw new ArgumentNullException(nameof(command)); + Reader = reader ?? throw new ArgumentNullException(nameof(reader)); } } diff --git a/Orm/Xtensive.Orm/Orm/Providers/CompilationService.cs b/Orm/Xtensive.Orm/Orm/Providers/CompilationService.cs index 9c44c2c5e..9e9fefab1 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/CompilationService.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/CompilationService.cs @@ -30,8 +30,8 @@ public CompilerConfiguration CreateConfiguration(Session session) => public ExecutableProvider Compile(CompilableProvider provider, CompilerConfiguration configuration) { - ArgumentValidator.EnsureArgumentNotNull(provider, "provider"); - ArgumentValidator.EnsureArgumentNotNull(configuration, "configuration"); + ArgumentNullException.ThrowIfNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(configuration, "configuration"); var preCompiler = preCompilerProvider.Invoke(configuration); var compiler = compilerProvider.Invoke(configuration); @@ -57,13 +57,9 @@ public CompilationService( Func preCompilerProvider, Func postCompilerProvider) { - ArgumentValidator.EnsureArgumentNotNull(compilerProvider, "compilerProvider"); - ArgumentValidator.EnsureArgumentNotNull(compilerProvider, "preCompilerProvider"); - ArgumentValidator.EnsureArgumentNotNull(compilerProvider, "postCompilerProvider"); - - this.compilerProvider = compilerProvider; - this.preCompilerProvider = preCompilerProvider; - this.postCompilerProvider = postCompilerProvider; + this.compilerProvider = compilerProvider ?? throw new ArgumentNullException(nameof(compilerProvider)); + this.preCompilerProvider = preCompilerProvider ?? throw new ArgumentNullException(nameof(preCompilerProvider)); + this.postCompilerProvider = postCompilerProvider ?? throw new ArgumentNullException(nameof(postCompilerProvider)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs b/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs index 54b6c1654..a43f63ded 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs @@ -501,9 +501,9 @@ public ExpressionProcessor(LambdaExpression lambda, in bool preferCaseOverVariant, params IReadOnlyList[] sourceColumns) { - ArgumentValidator.EnsureArgumentNotNull(lambda, "lambda"); - ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers"); - ArgumentValidator.EnsureArgumentNotNull(sourceColumns, "sourceColumns"); + ArgumentNullException.ThrowIfNull(lambda, "lambda"); + ArgumentNullException.ThrowIfNull(handlers, "handlers"); + ArgumentNullException.ThrowIfNull(sourceColumns, "sourceColumns"); if (lambda.Parameters.Count != sourceColumns.Length) throw Exceptions.InternalError(Strings.ExParametersCountIsNotSameAsSourceColumnListsCount, OrmLog.Instance); diff --git a/Orm/Xtensive.Orm/Orm/Providers/Expressions/QueryParameterIdentity.cs b/Orm/Xtensive.Orm/Orm/Providers/Expressions/QueryParameterIdentity.cs index 344c1a078..8b93469f2 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/Expressions/QueryParameterIdentity.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/Expressions/QueryParameterIdentity.cs @@ -61,12 +61,10 @@ public override bool Equals(object obj) => public QueryParameterIdentity(TypeMapping mapping, object closureObject, string fieldName, QueryParameterBindingType bindingType) { - ArgumentValidator.EnsureArgumentNotNull(mapping, "mapping"); - ArgumentValidator.EnsureArgumentNotNull(closureObject, "closureObject"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(fieldName, "fieldName"); - Mapping = mapping; - ClosureObject = closureObject; + Mapping = mapping ?? throw new ArgumentNullException(nameof(mapping)); + ClosureObject = closureObject ?? throw new ArgumentNullException(nameof(closureObject)); FieldName = fieldName; BindingType = bindingType; } diff --git a/Orm/Xtensive.Orm/Orm/Providers/MappingResolver.cs b/Orm/Xtensive.Orm/Orm/Providers/MappingResolver.cs index 051585089..a214a2970 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/MappingResolver.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/MappingResolver.cs @@ -1,11 +1,11 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov // Created: 2012.03.06 +using System; using System.Collections.Generic; -using Xtensive.Core; using Xtensive.Orm.Configuration; using Xtensive.Orm.Model; using Xtensive.Orm.Upgrade; @@ -43,9 +43,9 @@ public Schema ResolveSchema(SchemaExtractionResult model, string mappingDatabase public static MappingResolver Create(DomainConfiguration configuration, NodeConfiguration nodeConfiguration, DefaultSchemaInfo defaultSchemaInfo) { - ArgumentValidator.EnsureArgumentNotNull(configuration, "configuration"); - ArgumentValidator.EnsureArgumentNotNull(nodeConfiguration, "nodeConfiguration"); - ArgumentValidator.EnsureArgumentNotNull(defaultSchemaInfo, "defaultSchemaInfo"); + ArgumentNullException.ThrowIfNull(configuration, "configuration"); + ArgumentNullException.ThrowIfNull(nodeConfiguration, "nodeConfiguration"); + ArgumentNullException.ThrowIfNull(defaultSchemaInfo, "defaultSchemaInfo"); if (configuration.IsMultidatabase) return new MultidatabaseMappingResolver(configuration, nodeConfiguration); diff --git a/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs b/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs index d82f34614..034c65a01 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs @@ -62,8 +62,8 @@ public sealed class NameBuilder /// Type name. public string BuildTypeName(BuildingContext context, TypeDef type) { - ArgumentValidator.EnsureArgumentNotNull(context, "context"); - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(context, "context"); + ArgumentNullException.ThrowIfNull(type, "type"); if (type.UnderlyingType.IsGenericType) return ApplyNamingRules(BuildGenericTypeName(context, type.UnderlyingType, type.MappingName)); @@ -152,7 +152,7 @@ public string BuildTableName(IndexInfo indexInfo) /// Column name. public string BuildTableColumnName(ColumnInfo columnInfo) { - ArgumentValidator.EnsureArgumentNotNull(columnInfo, "columnInfo"); + ArgumentNullException.ThrowIfNull(columnInfo, "columnInfo"); return ApplyNamingRules(columnInfo.Name); } @@ -162,9 +162,9 @@ public string BuildTableColumnName(ColumnInfo columnInfo) /// Foreign key name. public string BuildReferenceForeignKeyName(TypeInfo ownerType, FieldInfo ownerField, TypeInfo targetType) { - ArgumentValidator.EnsureArgumentNotNull(ownerType, "ownerType"); - ArgumentValidator.EnsureArgumentNotNull(ownerField, "ownerField"); - ArgumentValidator.EnsureArgumentNotNull(targetType, "targetType"); + ArgumentNullException.ThrowIfNull(ownerType, "ownerType"); + ArgumentNullException.ThrowIfNull(ownerField, "ownerField"); + ArgumentNullException.ThrowIfNull(targetType, "targetType"); return ApplyNamingRules(string.Format(ReferenceForeignKeyFormat, ownerType.Name, ownerField.Name, targetType.Name)); } @@ -174,8 +174,8 @@ public string BuildReferenceForeignKeyName(TypeInfo ownerType, FieldInfo ownerFi /// Foreign key name. public string BuildHierarchyForeignKeyName(TypeInfo baseType, TypeInfo descendantType) { - ArgumentValidator.EnsureArgumentNotNull(baseType, "baseType"); - ArgumentValidator.EnsureArgumentNotNull(descendantType, "descendantType"); + ArgumentNullException.ThrowIfNull(baseType, "baseType"); + ArgumentNullException.ThrowIfNull(descendantType, "descendantType"); return ApplyNamingRules(string.Format(HierarchyForeignKeyFormat, baseType.Name, descendantType.Name)); } @@ -186,7 +186,7 @@ public string BuildHierarchyForeignKeyName(TypeInfo baseType, TypeInfo descendan /// Field name. public string BuildFieldName(FieldDef field) { - ArgumentValidator.EnsureArgumentNotNull(field, "field"); + ArgumentNullException.ThrowIfNull(field, "field"); string result = field.Name; if (field.UnderlyingProperty != null) return BuildFieldNameInternal(field.UnderlyingProperty); @@ -203,7 +203,7 @@ private string BuildFieldNameInternal(PropertyInfo propertyInfo) /// The property info. public string BuildFieldName(PropertyInfo propertyInfo) { - ArgumentValidator.EnsureArgumentNotNull(propertyInfo, "propertyInfo"); + ArgumentNullException.ThrowIfNull(propertyInfo, "propertyInfo"); return BuildFieldNameInternal(propertyInfo); } @@ -226,8 +226,8 @@ public string BuildExplicitFieldName(TypeInfo type, string name) /// Nested field name. public string BuildNestedFieldName(FieldInfo complexField, FieldInfo childField) { - ArgumentValidator.EnsureArgumentNotNull(complexField, "complexField"); - ArgumentValidator.EnsureArgumentNotNull(childField, "childField"); + ArgumentNullException.ThrowIfNull(complexField, "complexField"); + ArgumentNullException.ThrowIfNull(childField, "childField"); var nameSource = complexField; while (nameSource.Parent != null) nameSource = nameSource.Parent; @@ -257,8 +257,8 @@ public string BuildMappingName(FieldInfo complexField, FieldInfo childField) /// Column name. public string BuildColumnName(FieldInfo field, ColumnInfo baseColumn) { - ArgumentValidator.EnsureArgumentNotNull(field, "field"); - ArgumentValidator.EnsureArgumentNotNull(baseColumn, "baseColumn"); + ArgumentNullException.ThrowIfNull(field, "field"); + ArgumentNullException.ThrowIfNull(baseColumn, "baseColumn"); var result = field.MappingName ?? field.Name; return ApplyNamingRules(result); @@ -272,7 +272,7 @@ public string BuildColumnName(FieldInfo field, ColumnInfo baseColumn) /// Column name. public string BuildColumnName(ColumnInfo column) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); + ArgumentNullException.ThrowIfNull(column, "column"); if (column.Name.StartsWith(column.Field.DeclaringType.Name + ".", StringComparison.Ordinal)) throw new InvalidOperationException(); string result = string.Concat(column.Field.DeclaringType.Name, ".", column.Name); @@ -287,7 +287,7 @@ public string BuildColumnName(ColumnInfo column) /// Index name. public string BuildIndexName(TypeDef type, IndexDef index) { - ArgumentValidator.EnsureArgumentNotNull(index, "index"); + ArgumentNullException.ThrowIfNull(index, "index"); string result = string.Empty; if (!index.Name.IsNullOrEmpty()) @@ -319,7 +319,7 @@ public string BuildIndexName(TypeDef type, IndexDef index) /// Index name. public string BuildIndexName(TypeInfo type, IndexInfo index) { - ArgumentValidator.EnsureArgumentNotNull(index, "index"); + ArgumentNullException.ThrowIfNull(index, "index"); if (!index.Name.IsNullOrEmpty()) return index.Name; @@ -597,9 +597,9 @@ private static string FormatKeyGeneratorName(string database, string name) internal NameBuilder(DomainConfiguration configuration, ProviderInfo providerInfo) { - ArgumentValidator.EnsureArgumentNotNull(configuration, "configuration"); - ArgumentValidator.EnsureArgumentNotNull(configuration.NamingConvention, "configuration.NamingConvention"); - ArgumentValidator.EnsureArgumentNotNull(providerInfo, "providerInfo"); + ArgumentNullException.ThrowIfNull(configuration, "configuration"); + ArgumentNullException.ThrowIfNull(configuration.NamingConvention, "configuration.NamingConvention"); + ArgumentNullException.ThrowIfNull(providerInfo, "providerInfo"); namingConvention = configuration.NamingConvention; isMultidatabase = configuration.IsMultidatabase; diff --git a/Orm/Xtensive.Orm/Orm/Providers/Requests/PersistRequest.cs b/Orm/Xtensive.Orm/Orm/Providers/Requests/PersistRequest.cs index 8f2581035..3f4843f49 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/Requests/PersistRequest.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/Requests/PersistRequest.cs @@ -45,15 +45,9 @@ public void Prepare() public PersistRequest( StorageDriver driver, SqlStatement statement, IEnumerable parameterBindings) { - ArgumentValidator.EnsureArgumentNotNull(driver, "driver"); - ArgumentValidator.EnsureArgumentNotNull(statement, "statement"); - - var compileUnit = statement as ISqlCompileUnit - ?? throw new ArgumentException("Statement is not ISqlCompileUnit"); - - this.driver = driver; - Statement = statement; - CompileUnit = compileUnit; + this.driver = driver ?? throw new ArgumentNullException(nameof(driver)); + Statement = statement ?? throw new ArgumentNullException(nameof(statement)); + CompileUnit = statement as ISqlCompileUnit ?? throw new ArgumentException("Statement is not ISqlCompileUnit"); ParameterBindings = ParameterBinding.NormalizeBindings(parameterBindings); } } diff --git a/Orm/Xtensive.Orm/Orm/Providers/Requests/QueryParameterBinding.cs b/Orm/Xtensive.Orm/Orm/Providers/Requests/QueryParameterBinding.cs index 4f6f21ad9..0b0238b62 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/Requests/QueryParameterBinding.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/Requests/QueryParameterBinding.cs @@ -25,16 +25,14 @@ private QueryParameterBinding(TypeMapping typeMapping, Func parameterBindings, TupleDescriptor tupleDescriptor, QueryRequestOptions options) { - ArgumentValidator.EnsureArgumentNotNull(driver, "driver"); - ArgumentValidator.EnsureArgumentNotNull(statement, "statement"); - ArgumentValidator.EnsureArgumentNotNull(tupleDescriptor, "tupleDescriptor"); + ArgumentValidator.EnsureArgumentIsNotDefault(tupleDescriptor, "tupleDescriptor"); - this.driver = driver; - Statement = statement; + this.driver = driver ?? throw new ArgumentNullException(nameof(driver)); + Statement = statement ?? throw new ArgumentNullException(nameof(statement)); ParameterBindings = ParameterBinding.NormalizeBindings(parameterBindings); TupleDescriptor = tupleDescriptor; Options = options; @@ -82,12 +80,10 @@ public QueryRequest( StorageDriver driver, SqlSelect statement, IEnumerable parameterBindings, TupleDescriptor tupleDescriptor, QueryRequestOptions options, NodeConfiguration nodeConfiguration) { - ArgumentValidator.EnsureArgumentNotNull(driver, "driver"); - ArgumentValidator.EnsureArgumentNotNull(statement, "statement"); - ArgumentValidator.EnsureArgumentNotNull(tupleDescriptor, "tupleDescriptor"); + ArgumentValidator.EnsureArgumentIsNotDefault(tupleDescriptor, "tupleDescriptor"); - this.driver = driver; - Statement = statement; + this.driver = driver ?? throw new ArgumentNullException(nameof(driver)); + Statement = statement ?? throw new ArgumentNullException(nameof(statement)); ParameterBindings = ParameterBinding.NormalizeBindings(parameterBindings); TupleDescriptor = tupleDescriptor; Options = options; diff --git a/Orm/Xtensive.Orm/Orm/Providers/Requests/UserQueryRequest.cs b/Orm/Xtensive.Orm/Orm/Providers/Requests/UserQueryRequest.cs index 2f0264cf9..c1336a949 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/Requests/UserQueryRequest.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/Requests/UserQueryRequest.cs @@ -1,9 +1,10 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov // Created: 2012.02.25 +using System; using System.Collections.Generic; using Xtensive.Core; using Xtensive.Sql.Compiler; @@ -25,11 +26,8 @@ public SqlCompilationResult GetCompiledStatement() public UserQueryRequest(SqlCompilationResult compiledStatement, IEnumerable parameterBindings) { - ArgumentValidator.EnsureArgumentNotNull(compiledStatement, "compiledStatement"); - ArgumentValidator.EnsureArgumentNotNull(parameterBindings, "parameterBindings"); - - this.compiledStatement = compiledStatement; - ParameterBindings = ParameterBinding.NormalizeBindings(parameterBindings); + this.compiledStatement = compiledStatement ?? throw new ArgumentNullException(nameof(compiledStatement)); + ParameterBindings = ParameterBinding.NormalizeBindings(parameterBindings ?? throw new ArgumentNullException(nameof(parameterBindings))); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Providers/SequenceQuery.cs b/Orm/Xtensive.Orm/Orm/Providers/SequenceQuery.cs index 5f540cefa..84881d878 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SequenceQuery.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SequenceQuery.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -32,13 +32,9 @@ public long ExecuteWith(ISqlExecutor sqlExecutor) public SequenceQuery(string deleteQuery, string insertQuery, string selectQuery, SequenceQueryCompartment compartment) { - ArgumentValidator.EnsureArgumentNotNull(deleteQuery, "deleteQuery"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(insertQuery, "insertQuery"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(selectQuery, "selectQuery"); - - DeleteQuery = deleteQuery; - InsertQuery = insertQuery; - SelectQuery = selectQuery; + DeleteQuery = deleteQuery ?? throw new ArgumentNullException(nameof(deleteQuery)); + InsertQuery = insertQuery ?? throw new ArgumentNullException(nameof(insertQuery)); + SelectQuery = selectQuery ?? throw new ArgumentNullException(nameof(selectQuery)); Compartment = compartment; } @@ -47,8 +43,8 @@ public SequenceQuery(string insertQuery, string selectQuery, SequenceQueryCompar ArgumentValidator.EnsureArgumentNotNullOrEmpty(insertQuery, "insertQuery"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(selectQuery, "selectQuery"); - InsertQuery = insertQuery; - SelectQuery = selectQuery; + InsertQuery = insertQuery ?? throw new ArgumentNullException(nameof(insertQuery)); + SelectQuery = selectQuery ?? throw new ArgumentNullException(nameof(selectQuery)); Compartment = compartment; } diff --git a/Orm/Xtensive.Orm/Orm/Providers/SequenceQueryBuilder.cs b/Orm/Xtensive.Orm/Orm/Providers/SequenceQueryBuilder.cs index 6455e4a12..1bc809542 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SequenceQueryBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SequenceQueryBuilder.cs @@ -116,7 +116,7 @@ private static TableColumn GetColumn(Table table, string columnName) public SequenceQueryBuilder(StorageDriver driver) { - ArgumentValidator.EnsureArgumentNotNull(driver, "driver"); + ArgumentNullException.ThrowIfNull(driver, "driver"); this.driver = driver; diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlExecutor.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlExecutor.cs index e81f6f1cf..6d3d290ea 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlExecutor.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlExecutor.cs @@ -4,6 +4,7 @@ // Created by: Denis Krjuchkov // Created: 2012.02.29 +using System; using System.Collections.Generic; using System.Data; using System.Data.Common; @@ -294,10 +295,8 @@ private Task EnsureConnectionIsOpenAsync(CancellationToken token) => public SqlExecutor(StorageDriver driver, SqlConnection connection) { - ArgumentValidator.EnsureArgumentNotNull(driver, nameof(driver)); - ArgumentValidator.EnsureArgumentNotNull(connection, nameof(connection)); - this.driver = driver; - this.connection = connection; + this.driver = driver ?? throw new ArgumentNullException(nameof(driver)); + this.connection = connection ?? throw new ArgumentNullException(nameof(connection)); } public SqlExecutor(StorageDriver driver, SqlConnection connection, Session session) diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlProviderPreparer.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlProviderPreparer.cs index 850461513..73dc1b8e6 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlProviderPreparer.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlProviderPreparer.cs @@ -32,8 +32,7 @@ public ExecutableProvider Process(ExecutableProvider rootProvider) public SqlProviderPreparer(HandlerAccessor handlers) { - ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers"); - this.handlers = handlers; + this.handlers = handlers ?? throw new ArgumentNullException(nameof(handlers)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlSelectProcessor.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlSelectProcessor.cs index e8e098b63..1df33714f 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlSelectProcessor.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlSelectProcessor.cs @@ -1,6 +1,10 @@ +// Copyright (C) 2012-2026 Xtensive LLC. +// This code is distributed under MIT license terms. +// See the License.txt file in the project root for more information. + +using System; using System.Collections.Generic; using System.Linq; -using Xtensive.Core; using Xtensive.Sql; using Xtensive.Sql.Ddl; using Xtensive.Sql.Dml; @@ -580,8 +584,8 @@ public void Visit(SqlComment comment) public static void Process(SqlSelect select, ProviderInfo providerInfo) { - ArgumentValidator.EnsureArgumentNotNull(select, "select"); - ArgumentValidator.EnsureArgumentNotNull(providerInfo, "providerInfo"); + ArgumentNullException.ThrowIfNull(select, "select"); + ArgumentNullException.ThrowIfNull(providerInfo, "providerInfo"); new SqlSelectProcessor(select, providerInfo).Visit(select); } diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlSessionHandler.IDirectSqlService.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlSessionHandler.IDirectSqlService.cs index d5e3b5788..abc009f48 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlSessionHandler.IDirectSqlService.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlSessionHandler.IDirectSqlService.cs @@ -39,7 +39,7 @@ DbTransaction IDirectSqlService.Transaction { /// void IDirectSqlService.RegisterInitializationSql(string sql) { - ArgumentValidator.EnsureArgumentNotNull(sql, "sql"); + ArgumentNullException.ThrowIfNull(sql, "sql"); initializationSqlScripts.Add(sql); } diff --git a/Orm/Xtensive.Orm/Orm/Providers/StorageDriver.cs b/Orm/Xtensive.Orm/Orm/Providers/StorageDriver.cs index 363078b2d..43327a6ec 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/StorageDriver.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/StorageDriver.cs @@ -95,7 +95,7 @@ public DbDataReaderAccessor GetDataReaderAccessor(in TupleDescriptor descriptor) public StorageDriver CreateNew(Domain domain) { - ArgumentValidator.EnsureArgumentNotNull(domain, "domain"); + ArgumentNullException.ThrowIfNull(domain, "domain"); return new StorageDriver(underlyingDriver, ProviderInfo, domain.Configuration, GetModelProvider(domain), connectionAccessorFactories); } @@ -213,8 +213,8 @@ private static Func CreateNewAccessor() where T : IDbC public static StorageDriver Create(SqlDriverFactory driverFactory, DomainConfiguration configuration) { - ArgumentValidator.EnsureArgumentNotNull(driverFactory, nameof(driverFactory)); - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(driverFactory, nameof(driverFactory)); + ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); var accessors = CreateConnectionAccessors(configuration.Types.DbConnectionAccessors, out var factories); var driverConfiguration = new SqlDriverConfiguration(accessors) { @@ -232,8 +232,8 @@ public static StorageDriver Create(SqlDriverFactory driverFactory, DomainConfigu public static async Task CreateAsync( SqlDriverFactory driverFactory, DomainConfiguration configuration, CancellationToken token) { - ArgumentValidator.EnsureArgumentNotNull(driverFactory, nameof(driverFactory)); - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(driverFactory, nameof(driverFactory)); + ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); var accessors = CreateConnectionAccessors(configuration.Types.DbConnectionAccessors, out var factories); var driverConfiguration = new SqlDriverConfiguration(accessors) { diff --git a/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs b/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs index b8e44781e..636885d86 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs @@ -112,7 +112,7 @@ private SequenceQuery GetSequenceQuery(SequenceInfo sequenceInfo, Session sessio [ServiceConstructor] public StorageSequenceAccessor(HandlerAccessor handlers) { - ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers"); + ArgumentNullException.ThrowIfNull(handlers, "handlers"); queryBuilder = handlers.SequenceQueryBuilder; domain = handlers.Domain; diff --git a/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs b/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs index df131a909..be4b13cd2 100644 --- a/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs +++ b/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs @@ -95,7 +95,7 @@ public IQueryable All(Type elementType) public IQueryable> FreeText(string searchCriteria) where T : Entity { - ArgumentValidator.EnsureArgumentNotNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); var method = WellKnownMembers.Query.FreeTextString.CachedMakeGenericMethod(typeof(T)); var expression = Expression.Call(method, Expression.Constant(searchCriteria)); return Provider.CreateQuery>(expression); @@ -115,7 +115,7 @@ public IQueryable> FreeText(string searchCriteria) public IQueryable> FreeText(string searchCriteria, int topNByRank) where T : Entity { - ArgumentValidator.EnsureArgumentNotNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, "topNByRank"); var method = WellKnownMembers.Query.FreeTextStringTopNByRank.CachedMakeGenericMethod(typeof (T)); var expression = Expression.Call(method, Expression.Constant(searchCriteria), Expression.Constant(topNByRank)); @@ -134,7 +134,7 @@ public IQueryable> FreeText(string searchCriteria, int topNB public IQueryable> FreeText(Expression> searchCriteria) where T : Entity { - ArgumentValidator.EnsureArgumentNotNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); var method = WellKnownMembers.Query.FreeTextExpression.CachedMakeGenericMethod(typeof(T)); var expression = Expression.Call(null, method, new[] { searchCriteria }); return Provider.CreateQuery>(expression); @@ -154,7 +154,7 @@ public IQueryable> FreeText(Expression> searchC public IQueryable> FreeText(Expression> searchCriteria, int topNByRank) where T : Entity { - ArgumentValidator.EnsureArgumentNotNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, "topNByRank"); var method = WellKnownMembers.Query.FreeTextExpressionTopNByRank.CachedMakeGenericMethod(typeof (T)); var expression = Expression.Call(null, method, searchCriteria, Expression.Constant(topNByRank)); @@ -173,7 +173,7 @@ public IQueryable> FreeText(Expression> searchC public IQueryable> ContainsTable([NotNull] Expression> searchCriteria) where T: Entity { - ArgumentValidator.EnsureArgumentNotNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); var method = WellKnownMembers.Query.ContainsTableExpr.CachedMakeGenericMethod(typeof (T)); var expression = Expression.Call(null, method, searchCriteria); return Provider.CreateQuery>(expression); @@ -194,8 +194,8 @@ public IQueryable> ContainsTable( [NotNull] Expression>[] targetFields) where T : Entity { - ArgumentValidator.EnsureArgumentNotNull(searchCriteria, "searchCriteria"); - ArgumentValidator.EnsureArgumentNotNull(targetFields, "targetFields"); + ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(targetFields, "targetFields"); var method = WellKnownMembers.Query.ContainsTableExprWithColumns.CachedMakeGenericMethod(typeof(T)); var expression = Expression.Call(null, method, searchCriteria, Expression.Constant(targetFields)); return Provider.CreateQuery>(expression); @@ -217,7 +217,7 @@ public IQueryable> ContainsTable( public IQueryable> ContainsTable([NotNull] Expression> searchCriteria, int topNByRank) where T : Entity { - ArgumentValidator.EnsureArgumentNotNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, "topNByRank"); var method = WellKnownMembers.Query.ContainsTableExprTopNByRank.CachedMakeGenericMethod(typeof(T)); var expression = Expression.Call(null, method, searchCriteria, Expression.Constant(topNByRank)); @@ -244,8 +244,8 @@ public IQueryable> ContainsTable( int topNByRank) where T : Entity { - ArgumentValidator.EnsureArgumentNotNull(searchCriteria, "searchCriteria"); - ArgumentValidator.EnsureArgumentNotNull(targetFields, "targetFields"); + ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(targetFields, "targetFields"); ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, "topNByRank"); var method = WellKnownMembers.Query.ContainsTableExprTopNByRank.CachedMakeGenericMethod(typeof(T)); var expression = Expression.Call(null, method, searchCriteria, Expression.Constant(targetFields), Expression.Constant(topNByRank)); @@ -839,7 +839,7 @@ public IQueryable Items(Expression> private Key GetKeyByValues(object[] keyValues) where T : class, IEntity { - ArgumentValidator.EnsureArgumentNotNull(keyValues, "keyValues"); + ArgumentNullException.ThrowIfNull(keyValues, "keyValues"); if (keyValues.Length == 0) throw new ArgumentException(Strings.ExKeyValuesArrayIsEmpty, "keyValues"); if (keyValues.Length == 1) { @@ -867,15 +867,15 @@ private Expression BuildRootExpression(Type elementType) internal QueryEndpoint(QueryProvider provider) { - ArgumentValidator.EnsureArgumentNotNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(provider, "provider"); Provider = provider; session = provider.Session; } internal QueryEndpoint(QueryEndpoint outerEndpoint, IQueryRootBuilder queryRootBuilder) { - ArgumentValidator.EnsureArgumentNotNull(outerEndpoint, "outerEndpoint"); - ArgumentValidator.EnsureArgumentNotNull(queryRootBuilder, "queryRootBuilder"); + ArgumentNullException.ThrowIfNull(outerEndpoint, "outerEndpoint"); + ArgumentNullException.ThrowIfNull(queryRootBuilder, "queryRootBuilder"); Provider = outerEndpoint.Provider; session = outerEndpoint.session; RootBuilder = queryRootBuilder; diff --git a/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs b/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs index 0d5e4ced9..4817387e9 100644 --- a/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs +++ b/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs @@ -67,8 +67,8 @@ public QueryAsAsyncEnumerable(QueryProvider queryProvider, Expression expression public static Task AllAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); return ExecuteScalarAsync(WellKnownMembers.Queryable.All, source, predicate, cancellationToken); } @@ -91,7 +91,7 @@ public static Task AllAsync(this IQueryable source, public static Task AnyAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.Any, source, cancellationToken); } @@ -116,8 +116,8 @@ public static Task AnyAsync(this IQueryable source, public static Task AnyAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AnyWithPredicate, source, predicate, cancellationToken); @@ -144,7 +144,7 @@ public static Task AnyAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.Int32], source, cancellationToken); @@ -167,7 +167,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.NullableInt32], source, cancellationToken); @@ -193,8 +193,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.Int32], @@ -221,8 +221,8 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.NullableInt32], @@ -248,7 +248,7 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.Int64], source, cancellationToken); @@ -271,7 +271,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.NullableInt64], source, cancellationToken); @@ -297,8 +297,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.Int64], @@ -325,8 +325,8 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.NullableInt64], @@ -352,7 +352,7 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.Double], source, cancellationToken); @@ -375,7 +375,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.NullableDouble], source, cancellationToken); @@ -401,8 +401,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.Double], @@ -429,8 +429,8 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.NullableDouble], @@ -456,7 +456,7 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.Single], source, cancellationToken); @@ -479,7 +479,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.NullableSingle], source, cancellationToken); @@ -505,8 +505,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.Single], @@ -533,8 +533,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.NullableSingle], @@ -560,7 +560,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.Decimal], source, cancellationToken); @@ -583,7 +583,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.NullableDecimal], source, cancellationToken); @@ -609,8 +609,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.Decimal], @@ -637,8 +637,8 @@ public static Task AverageAsync(this IQueryable sourc public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.NullableDecimal], @@ -668,7 +668,7 @@ public static Task AverageAsync(this IQueryable sourc public static Task ContainsAsync(this IQueryable source, TSource item, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.Contains, source, Expression.Constant(item, typeof(TSource)), cancellationToken); @@ -694,7 +694,7 @@ public static Task ContainsAsync(this IQueryable source, public static Task CountAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.Count, source, cancellationToken); } @@ -718,8 +718,8 @@ public static Task CountAsync(this IQueryable source, public static Task CountAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); return ExecuteScalarAsync(WellKnownMembers.Queryable.CountWithPredicate, source, predicate, cancellationToken); @@ -749,7 +749,7 @@ public static Task CountAsync(this IQueryable source, public static Task FirstAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.First, source, cancellationToken); } @@ -773,8 +773,8 @@ public static Task FirstAsync(this IQueryable source, public static Task FirstAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); return ExecuteScalarAsync(WellKnownMembers.Queryable.FirstWithPredicate, source, predicate, cancellationToken); @@ -801,7 +801,7 @@ public static Task FirstAsync(this IQueryable source, public static Task FirstOrDefaultAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.FirstOrDefault, source, cancellationToken); } @@ -827,8 +827,8 @@ public static Task FirstOrDefaultAsync(this IQueryable FirstOrDefaultAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); return ExecuteScalarAsync(WellKnownMembers.Queryable.FirstOrDefaultWithPredicate, source, predicate, cancellationToken); @@ -857,7 +857,7 @@ public static Task FirstOrDefaultAsync(this IQueryable LastAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.Last, source, cancellationToken); } @@ -881,8 +881,8 @@ public static Task LastAsync(this IQueryable source, public static Task LastAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); return ExecuteScalarAsync(WellKnownMembers.Queryable.LastWithPredicate, source, predicate, cancellationToken); @@ -909,7 +909,7 @@ public static Task LastAsync(this IQueryable source, public static Task LastOrDefaultAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.LastOrDefault, source, cancellationToken); } @@ -935,8 +935,8 @@ public static Task LastOrDefaultAsync(this IQueryable public static Task LastOrDefaultAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); return ExecuteScalarAsync(WellKnownMembers.Queryable.LastOrDefaultWithPredicate, source, predicate, cancellationToken); @@ -965,7 +965,7 @@ public static Task LastOrDefaultAsync(this IQueryable public static Task LongCountAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.LongCount, source, cancellationToken); } @@ -991,8 +991,8 @@ public static Task LongCountAsync(this IQueryable source public static Task LongCountAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); return ExecuteScalarAsync(WellKnownMembers.Queryable.LongCountWithPredicate, source, predicate, cancellationToken); @@ -1022,7 +1022,7 @@ public static Task LongCountAsync(this IQueryable source public static Task MaxAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.Max, source, cancellationToken); } @@ -1048,8 +1048,8 @@ public static Task MaxAsync(this IQueryable source, public static Task MaxAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync(WellKnownMembers.Queryable.MaxWithSelector, source, selector, cancellationToken); @@ -1074,7 +1074,7 @@ public static Task MaxAsync(this IQueryable public static Task MinAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.Min, source, cancellationToken); } @@ -1099,8 +1099,8 @@ public static Task MinAsync(this IQueryable source, public static Task MinAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync(WellKnownMembers.Queryable.MinWithSelector, source, selector, cancellationToken); @@ -1131,7 +1131,7 @@ public static Task MinAsync(this IQueryable public static Task SingleAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.Single, source, cancellationToken); } @@ -1156,8 +1156,8 @@ public static Task SingleAsync(this IQueryable source public static Task SingleAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); return ExecuteScalarAsync(WellKnownMembers.Queryable.SingleWithPredicate, source, predicate, cancellationToken); @@ -1186,7 +1186,7 @@ public static Task SingleAsync(this IQueryable source public static Task SingleOrDefaultAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync(WellKnownMembers.Queryable.SingleOrDefault, source, cancellationToken); @@ -1214,8 +1214,8 @@ public static Task SingleOrDefaultAsync(this IQueryable SingleOrDefaultAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); return ExecuteScalarAsync(WellKnownMembers.Queryable.SingleOrDefaultWithPredicate, source, predicate, cancellationToken); @@ -1244,7 +1244,7 @@ public static Task SingleOrDefaultAsync(this IQueryable SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.Int32], source, cancellationToken); @@ -1267,7 +1267,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.NullableInt32], source, cancellationToken); @@ -1293,8 +1293,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.Int32], @@ -1321,8 +1321,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.NullableInt32], @@ -1348,7 +1348,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.Int64], source, cancellationToken); @@ -1371,7 +1371,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.NullableInt64], source, cancellationToken); @@ -1397,8 +1397,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.Int64], @@ -1425,8 +1425,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.NullableInt64], @@ -1452,7 +1452,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.Double], source, cancellationToken); @@ -1475,7 +1475,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.NullableDouble], source, cancellationToken); @@ -1501,8 +1501,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.Double], @@ -1529,8 +1529,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.NullableDouble], @@ -1556,7 +1556,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.Single], source, cancellationToken); @@ -1579,7 +1579,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.NullableSingle], source, cancellationToken); @@ -1605,8 +1605,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.Single], @@ -1633,8 +1633,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.NullableSingle], @@ -1660,7 +1660,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.Decimal], source, cancellationToken); @@ -1683,7 +1683,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.NullableDecimal], source, cancellationToken); @@ -1709,8 +1709,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.Decimal], @@ -1737,8 +1737,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(selector, nameof(selector)); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.NullableDecimal], @@ -1991,7 +1991,7 @@ public static async Task> ToLookupAsyncThe query results. public static IAsyncEnumerable AsAsyncEnumerable(this IQueryable source) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); if (source is IAsyncEnumerable nativeAsyncEnumerable) { return nativeAsyncEnumerable; diff --git a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs index 40d26b3d0..507528dad 100644 --- a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs @@ -37,8 +37,8 @@ public static partial class QueryableExtensions /// The same sequence, but with "comment" applied to query. public static IQueryable Tag(this IQueryable source, string tag) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(tag, "tag"); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(tag, nameof(tag)); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -61,8 +61,8 @@ public static IQueryable Tag(this IQueryable source, /// The same sequence, but with "comment" applied to query. public static IQueryable Tag(this IQueryable source, string tag) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(tag, "tag"); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(tag, nameof(tag)); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -81,7 +81,7 @@ public static IQueryable Tag(this IQueryable source, string tag) /// The source sequence. public static int Count([InstantHandle] this IQueryable source) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); return (int) source.Provider.Execute( Expression.Call( WellKnownTypes.Queryable, nameof(Queryable.Count), @@ -98,8 +98,8 @@ public static int Count([InstantHandle] this IQueryable source) /// The same result as its original version. public static IQueryable Take(this IQueryable source, Expression> count) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(count, nameof(count)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(count, nameof(count)); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -122,8 +122,8 @@ public static IQueryable Take(this IQueryable source, /// The same result as its original version. public static IQueryable Skip(this IQueryable source, Expression> count) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(count, nameof(count)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(count, nameof(count)); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -146,8 +146,8 @@ public static IQueryable Skip(this IQueryable source, /// The same result as its original version. public static TSource ElementAt(this IQueryable source, Expression> index) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(index, nameof(index)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(index, nameof(index)); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -170,8 +170,8 @@ public static TSource ElementAt(this IQueryable source, Expres /// The same result as its original version. public static TSource ElementAtOrDefault(this IQueryable source, Expression> index) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(index, nameof(index)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(index, nameof(index)); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -194,9 +194,9 @@ public static TSource ElementAtOrDefault(this IQueryable sourc /// The same sequence, but with "apply lock" hint. public static IQueryable Lock(this IQueryable source, LockMode lockMode, LockBehavior lockBehavior) { - ArgumentValidator.EnsureArgumentNotNull(source, nameof(source)); - ArgumentValidator.EnsureArgumentNotNull(lockMode, nameof(lockMode)); - ArgumentValidator.EnsureArgumentNotNull(lockBehavior, nameof(lockBehavior)); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(lockMode, nameof(lockMode)); + ArgumentNullException.ThrowIfNull(lockBehavior, nameof(lockBehavior)); var providerType = source.Provider.GetType(); if (providerType!=WellKnownOrmTypes.QueryProvider) { @@ -275,11 +275,11 @@ public static bool In(this T source, IncludeAlgorithm algorithm, IEnumerable< [Obsolete(".NET 10 has its own LeftJoin method declared, which will conflict with this. Use LeftJoinEx to prepare your code for future .NET change")] public static IQueryable LeftJoin(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { - ArgumentValidator.EnsureArgumentNotNull(outer, nameof(outer)); - ArgumentValidator.EnsureArgumentNotNull(inner, nameof(inner)); - ArgumentValidator.EnsureArgumentNotNull(outerKeySelector, nameof(outerKeySelector)); - ArgumentValidator.EnsureArgumentNotNull(innerKeySelector, nameof(innerKeySelector)); - ArgumentValidator.EnsureArgumentNotNull(resultSelector, nameof(resultSelector)); + ArgumentNullException.ThrowIfNull(outer, nameof(outer)); + ArgumentNullException.ThrowIfNull(inner, nameof(inner)); + ArgumentNullException.ThrowIfNull(outerKeySelector, nameof(outerKeySelector)); + ArgumentNullException.ThrowIfNull(innerKeySelector, nameof(innerKeySelector)); + ArgumentNullException.ThrowIfNull(resultSelector, nameof(resultSelector)); var outerProviderType = outer.Provider.GetType(); if (outerProviderType!=WellKnownOrmTypes.QueryProvider) { @@ -309,11 +309,11 @@ public static IQueryable LeftJoin(this I /// Queryable is not a query. public static IQueryable LeftJoinEx(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { - ArgumentValidator.EnsureArgumentNotNull(outer, nameof(outer)); - ArgumentValidator.EnsureArgumentNotNull(inner, nameof(inner)); - ArgumentValidator.EnsureArgumentNotNull(outerKeySelector, nameof(outerKeySelector)); - ArgumentValidator.EnsureArgumentNotNull(innerKeySelector, nameof(innerKeySelector)); - ArgumentValidator.EnsureArgumentNotNull(resultSelector, nameof(resultSelector)); + ArgumentNullException.ThrowIfNull(outer, nameof(outer)); + ArgumentNullException.ThrowIfNull(inner, nameof(inner)); + ArgumentNullException.ThrowIfNull(outerKeySelector, nameof(outerKeySelector)); + ArgumentNullException.ThrowIfNull(innerKeySelector, nameof(innerKeySelector)); + ArgumentNullException.ThrowIfNull(resultSelector, nameof(resultSelector)); var outerProviderType = outer.Provider.GetType(); if (outerProviderType != WellKnownOrmTypes.QueryProvider) { diff --git a/Orm/Xtensive.Orm/Orm/RecycledFieldDefinition.cs b/Orm/Xtensive.Orm/Orm/RecycledFieldDefinition.cs index 4ff6cf1be..5a08dcebe 100644 --- a/Orm/Xtensive.Orm/Orm/RecycledFieldDefinition.cs +++ b/Orm/Xtensive.Orm/Orm/RecycledFieldDefinition.cs @@ -55,20 +55,18 @@ public RecycledFieldDefinition(Type ownerType, string fieldName, Type fieldType) public RecycledFieldDefinition(Type ownerType, string fieldName, Type fieldType, string originalFieldName) { Initialize(ownerType, fieldName, fieldType); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(originalFieldName, "originalFieldName"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(originalFieldName, nameof(originalFieldName)); OriginalFieldName = originalFieldName; } private void Initialize(Type ownerType, string fieldName, Type fieldType) { - ArgumentValidator.EnsureArgumentNotNull(ownerType, "ownerType"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(fieldName, "fieldName"); - ArgumentValidator.EnsureArgumentNotNull(fieldType, "fieldType"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(fieldName, nameof(fieldName)); - OwnerType = ownerType; + OwnerType = ownerType ?? throw new ArgumentNullException(nameof(ownerType)); FieldName = fieldName; - FieldType = fieldType; + FieldType = fieldType ?? throw new ArgumentNullException(nameof(fieldType)); } public override string ToString() diff --git a/Orm/Xtensive.Orm/Orm/Rse/ProviderExtensions.cs b/Orm/Xtensive.Orm/Orm/Rse/ProviderExtensions.cs index 3d8219476..0d14f42e2 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/ProviderExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/ProviderExtensions.cs @@ -27,8 +27,8 @@ public static class ProviderExtensions public static RecordSetReader GetRecordSetReader( this CompilableProvider provider, Session session, ParameterContext parameterContext) { - ArgumentValidator.EnsureArgumentNotNull(provider, nameof(provider)); - ArgumentValidator.EnsureArgumentNotNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(provider, nameof(provider)); + ArgumentNullException.ThrowIfNull(session, nameof(session)); var executableProvider = session.Compile(provider); return executableProvider.GetRecordSetReader(session, parameterContext); } @@ -40,8 +40,8 @@ public static RecordSetReader GetRecordSetReader( /// The session. public static long Count(this CompilableProvider provider, Session session) { - ArgumentValidator.EnsureArgumentNotNull(provider, nameof(provider)); - ArgumentValidator.EnsureArgumentNotNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(provider, nameof(provider)); + ArgumentNullException.ThrowIfNull(session, nameof(session)); using var recordSetReader = provider .Aggregate(null, new AggregateColumnDescriptor("$Count", 0, AggregateType.Count)) .GetRecordSetReader(session, new ParameterContext()); diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AggregateProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AggregateProvider.cs index a3bbe643b..1847a2bc3 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AggregateProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AggregateProvider.cs @@ -199,7 +199,7 @@ private static NotSupportedException AggregateNotSupported(Type sourceColumnType public AggregateProvider(CompilableProvider source, int[] groupIndexes, IReadOnlyList columnDescriptors) : base(ProviderType.Aggregate, source) { - ArgumentValidator.EnsureArgumentNotNull(columnDescriptors, nameof(columnDescriptors)); + ArgumentNullException.ThrowIfNull(columnDescriptors, nameof(columnDescriptors)); groupIndexes = groupIndexes ?? Array.Empty(); var columns = new AggregateColumn[columnDescriptors.Count]; for (int i = 0, count = columnDescriptors.Count; i < count; i++) { diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AliasProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AliasProvider.cs index 46eee42e6..437b30eff 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AliasProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AliasProvider.cs @@ -6,7 +6,7 @@ using System; using Xtensive.Collections; - +using Xtensive.Core; using Xtensive.Orm.Rse.Providers; namespace Xtensive.Orm.Rse.Providers @@ -45,6 +45,7 @@ protected override string ParametersToString() public AliasProvider(CompilableProvider source, string alias) : base(ProviderType.Alias, source) { + ArgumentValidator.EnsureArgumentNotNullOrEmpty(alias, nameof(alias)); Alias = alias; Initialize(); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ApplyProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ApplyProvider.cs index 6dfaf0f40..8c60a47c8 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ApplyProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ApplyProvider.cs @@ -77,7 +77,7 @@ public ApplyProvider(ApplyParameter applyParameter, CompilableProvider left, Com public ApplyProvider(ApplyParameter applyParameter, CompilableProvider left, CompilableProvider right, bool isInlined, ApplySequenceType applySequenceType, JoinType applyType) : base(ProviderType.Apply, left, right) { - ApplyParameter = applyParameter; + ApplyParameter = applyParameter ?? throw new ArgumentNullException(nameof(applyParameter)); IsInlined = isInlined; SequenceType = applySequenceType; ApplyType = applyType; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/BinaryProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/BinaryProvider.cs index c209d1e6c..006022937 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/BinaryProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/BinaryProvider.cs @@ -45,10 +45,8 @@ protected override RecordSetHeader BuildHeader() protected BinaryProvider(ProviderType type, CompilableProvider left, CompilableProvider right) : base(type, left, right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); - Left = left; - Right = right; + Left = left ?? throw new ArgumentNullException(nameof(left)); + Right = right ?? throw new ArgumentNullException(nameof(right)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/CalculateProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/CalculateProvider.cs index 32bedb497..127f7c782 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/CalculateProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/CalculateProvider.cs @@ -70,7 +70,7 @@ protected override void Initialize() public CalculateProvider(CompilableProvider source, IReadOnlyList columnDescriptors, bool isInlined = false) : base(ProviderType.Calculate, source) { - ArgumentValidator.EnsureArgumentNotNull(columnDescriptors, nameof(columnDescriptors)); + ArgumentNullException.ThrowIfNull(columnDescriptors, nameof(columnDescriptors)); IsInlined = isInlined; var columns = new CalculatedColumn[columnDescriptors.Count]; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ContainsTableProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ContainsTableProvider.cs index 4e761819c..7f26e926c 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ContainsTableProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ContainsTableProvider.cs @@ -50,7 +50,7 @@ public ContainsTableProvider(FullTextIndexInfo index, Func searchCriteria, string rankColumnName, IList targetColumns, Func topNByRank, bool fullFeatured) : base(ProviderType.ContainsTable) { - SearchCriteria = searchCriteria; + SearchCriteria = searchCriteria ?? throw new ArgumentNullException(nameof(searchCriteria)); FullFeatured = fullFeatured; PrimaryIndex = new IndexInfoRef(index.PrimaryIndex); TargetColumns = targetColumns.SelectToList(tc => index.Columns.First(c => c.Column == tc)) diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ExistenceProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ExistenceProvider.cs index b27996056..f021d48cd 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ExistenceProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ExistenceProvider.cs @@ -7,6 +7,7 @@ using System; using System.Diagnostics; using Xtensive.Collections; +using Xtensive.Core; using Xtensive.Reflection; using Xtensive.Tuples; using Tuple = Xtensive.Tuples.Tuple; @@ -43,6 +44,7 @@ protected override RecordSetHeader BuildHeader() public ExistenceProvider(CompilableProvider source, string existenceColumnName) : base(ProviderType.Existence, source) { + ArgumentValidator.EnsureArgumentNotNullOrEmpty(existenceColumnName, nameof(existenceColumnName)); ExistenceColumnName = existenceColumnName; Initialize(); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/FreeTextProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/FreeTextProvider.cs index 071260228..7674c408f 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/FreeTextProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/FreeTextProvider.cs @@ -47,9 +47,9 @@ public FreeTextProvider( FullTextIndexInfo index, Func searchCriteria, string rankColumnName, Func topN, bool fullFeatured) : base(ProviderType.FreeText) { - SearchCriteria = searchCriteria; + SearchCriteria = searchCriteria ?? throw new ArgumentNullException(nameof(searchCriteria)); FullFeatured = fullFeatured; - TopN = topN; + TopN = topN ?? throw new ArgumentNullException(nameof(topN)); PrimaryIndex = new IndexInfoRef(index.PrimaryIndex); if (FullFeatured) { var primaryIndexRecordsetHeader = index.PrimaryIndex.ReflectedType.Indexes.PrimaryIndex.GetRecordSetHeader(); diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/IncludeProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/IncludeProvider.cs index b59453444..d08e74c11 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/IncludeProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/IncludeProvider.cs @@ -89,12 +89,12 @@ public IncludeProvider(CompilableProvider source, IncludeAlgorithm algorithm, bo Expression>> filterDataSource, string resultColumnName, IReadOnlyList filteredColumns) : base(ProviderType.Include, source) { - ArgumentValidator.EnsureArgumentNotNull(filterDataSource, "filterDataSource"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(resultColumnName, "resultColumnName"); - ArgumentValidator.EnsureArgumentNotNull(filteredColumns, "filteredColumns"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(resultColumnName, nameof (resultColumnName)); + ArgumentNullException.ThrowIfNull(filteredColumns, nameof(filteredColumns)); + Algorithm = algorithm; IsInlined = isInlined; - FilterDataSource = filterDataSource; + FilterDataSource = filterDataSource ?? throw new ArgumentNullException(nameof(filterDataSource)); ResultColumnName = resultColumnName; switch (filteredColumns) { diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/LockProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/LockProvider.cs index 17d7bcb97..f24546ba2 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/LockProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/LockProvider.cs @@ -34,8 +34,8 @@ public sealed class LockProvider : UnaryProvider /// The property value. /// The mode of the lock to be acquired. /// The behavior of the lock. - public LockProvider(CompilableProvider source, LockMode lockMode, LockBehavior lockBehavior) : - base(ProviderType.Lock, source) + public LockProvider(CompilableProvider source, LockMode lockMode, LockBehavior lockBehavior) + : base(ProviderType.Lock, source) { LockMode = () => lockMode; LockBehavior = () => lockBehavior; @@ -48,11 +48,11 @@ public LockProvider(CompilableProvider source, LockMode lockMode, LockBehavior l /// The property value. /// The delegate returning the mode of the lock to be acquired. /// The delegate returning the behavior of the lock. - public LockProvider(CompilableProvider source, Func lockMode, Func lockBehavior) : - base(ProviderType.Lock, source) + public LockProvider(CompilableProvider source, Func lockMode, Func lockBehavior) + : base(ProviderType.Lock, source) { - LockMode = lockMode; - LockBehavior = lockBehavior; + LockMode = lockMode ?? throw new ArgumentNullException(nameof(lockMode)); + LockBehavior = lockBehavior ?? throw new ArgumentNullException(nameof(lockMode)); Initialize(); } } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/OrderProviderBase.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/OrderProviderBase.cs index 661f8c9b4..153e4ab0c 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/OrderProviderBase.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/OrderProviderBase.cs @@ -97,7 +97,7 @@ protected override void Initialize() protected OrderProviderBase(ProviderType providerType, CompilableProvider source, DirectionCollection order) : base(providerType, source) { - Order = order; + Order = order ?? throw new ArgumentNullException(nameof(order)); } } } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/PredicateJoinProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/PredicateJoinProvider.cs index 2b24c1c3e..bb6b520a8 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/PredicateJoinProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/PredicateJoinProvider.cs @@ -44,7 +44,7 @@ public PredicateJoinProvider(CompilableProvider left, CompilableProvider right, Expression> predicate, JoinType joinType) : base(ProviderType.PredicateJoin, left, right) { - Predicate = predicate; + Predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); JoinType = joinType; Initialize(); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/RawProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/RawProvider.cs index 60a89bd07..cdabb9db2 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/RawProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/RawProvider.cs @@ -65,8 +65,8 @@ protected override string ParametersToString() public RawProvider(RecordSetHeader header, Expression>> source) : base(ProviderType.Raw) { - Source = source; - this.header = header; + Source = source ?? throw new ArgumentNullException(nameof(source)); + this.header = header ?? throw new ArgumentNullException(nameof(header)); Initialize(); } } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/SelectProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/SelectProvider.cs index 181e0054d..e00684ee8 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/SelectProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/SelectProvider.cs @@ -44,6 +44,8 @@ protected override string ParametersToString() public SelectProvider(CompilableProvider provider, IReadOnlyList columnIndexes) : base(ProviderType.Select, provider) { + ArgumentNullException.ThrowIfNull(columnIndexes, nameof(columnIndexes)); + switch (columnIndexes) { case int[] indexArray: ColumnIndexes = Array.AsReadOnly(indexArray); diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/StoreProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/StoreProvider.cs index b5ec29d67..c5a8d742f 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/StoreProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/StoreProvider.cs @@ -51,12 +51,10 @@ protected override string ParametersToString() public StoreProvider(RecordSetHeader header, string name) : base (ProviderType.Store) { - ArgumentValidator.EnsureArgumentNotNull(header, "header"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); - Name = name; - this.header = header; + this.header = header ?? throw new ArgumentNullException(nameof(header)); Initialize(); } @@ -69,8 +67,8 @@ public StoreProvider(RecordSetHeader header, string name) public StoreProvider(CompilableProvider source, string name) : base(ProviderType.Store, source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); + ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, nameof(name)); Name = name; Source = source; @@ -87,10 +85,8 @@ public StoreProvider(CompilableProvider source, string name) public StoreProvider(CompilableProvider source) : base(ProviderType.Store, source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - Name = Guid.NewGuid().ToString(); - Source = source; + Source = source ?? throw new ArgumentNullException(nameof(source)); header = source.Header; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/TagProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/TagProvider.cs index 059fa632b..27178dd2b 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/TagProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/TagProvider.cs @@ -23,7 +23,7 @@ public sealed class TagProvider : UnaryProvider public TagProvider(CompilableProvider source, string tag) : base(ProviderType.Tag, source) { - ArgumentValidator.EnsureArgumentNotNullOrEmptyOrWhiteSpace(tag, "tag"); + ArgumentValidator.EnsureArgumentNotNullOrEmptyOrWhiteSpace(tag, nameof(tag)); Tag = tag; Initialize(); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/UnaryProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/UnaryProvider.cs index 9a91549a3..d54b2c87a 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/UnaryProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/UnaryProvider.cs @@ -4,6 +4,7 @@ // Created by: Alexey Kochetov // Created: 2008.07.22 +using System; using Xtensive.Collections; using Xtensive.Core; @@ -36,8 +37,7 @@ protected override RecordSetHeader BuildHeader() protected UnaryProvider(ProviderType type, CompilableProvider source) : base(type, source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - Source = source; + Source = source ?? throw new ArgumentNullException(nameof(source)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/VoidProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/VoidProvider.cs index 84997c868..59c2d9bd4 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/VoidProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/VoidProvider.cs @@ -1,10 +1,10 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov // Created: 2012.01.29 -using Xtensive.Core; +using System; namespace Xtensive.Orm.Rse.Providers { @@ -20,8 +20,7 @@ protected override RecordSetHeader BuildHeader() public VoidProvider(RecordSetHeader header) : base(ProviderType.Void) { - ArgumentValidator.EnsureArgumentNotNull(header, "header"); - this.header = header; + this.header = header ?? throw new ArgumentNullException(nameof(header)); Initialize(); } } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/ExecutableProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/ExecutableProvider.cs index 3fdfd41e4..5152cc3f9 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/ExecutableProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/ExecutableProvider.cs @@ -142,7 +142,7 @@ public IEnumerable ToEnumerable(EnumerationContext context) /// New bound to specified . public RecordSetReader GetRecordSetReader(Session session, ParameterContext parameterContext) { - ArgumentValidator.EnsureArgumentNotNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(session, nameof(session)); var enumerationContext = session.CreateEnumerationContext(parameterContext); return RecordSetReader.Create(enumerationContext, this); } @@ -160,7 +160,7 @@ public RecordSetReader GetRecordSetReader(Session session, ParameterContext para public async Task GetRecordSetReaderAsync( Session session, ParameterContext parameterContext, CancellationToken token) { - ArgumentValidator.EnsureArgumentNotNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(session, nameof(session)); var enumerationContext = await session.CreateEnumerationContextAsync(parameterContext, token).ConfigureAwait(false); return await RecordSetReader.CreateAsync(enumerationContext, this, token).ConfigureAwait(false); diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/TagScope.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/TagScope.cs index e6a1f28bc..0c69bb27e 100755 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/TagScope.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/TagScope.cs @@ -17,8 +17,8 @@ public void Dispose() => internal TagScope(List tags, string tag) { - ArgumentValidator.EnsureArgumentNotNull(tags, nameof(tags)); - ArgumentValidator.EnsureArgumentNotNull(tag, nameof(tag)); + ArgumentNullException.ThrowIfNull(tags, nameof(tags)); + ArgumentNullException.ThrowIfNull(tag, nameof(tag)); (this.tags = tags).Add(tag); } } diff --git a/Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs b/Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs index 11ab77fbc..a9db9b389 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs @@ -377,8 +377,8 @@ public RecordSetHeader( TupleDescriptor? orderKeyDescriptor, DirectionCollection order) { - ArgumentValidator.EnsureArgumentNotNull(tupleDescriptor, "tupleDescriptor"); - ArgumentValidator.EnsureArgumentNotNull(columns, "columns"); + ArgumentValidator.EnsureArgumentIsNotDefault(tupleDescriptor, "tupleDescriptor"); + ArgumentNullException.ThrowIfNull(columns, "columns"); TupleDescriptor = tupleDescriptor; // Unsafe perf. optimization: if you pass a list, it should be immutable! diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs index 7125f3cc7..b5c46e155 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs @@ -335,7 +335,7 @@ protected override RowNumberProvider VisitRowNumber(RowNumberProvider provider) protected override CompilableProvider VisitStore(StoreProvider provider) { - if (!(provider.Source is CompilableProvider compilableSource)) { + if (provider.Source is not CompilableProvider compilableSource) { return provider; } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyFilterRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyFilterRewriter.cs index bf68c109e..3ac5f583a 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyFilterRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyFilterRewriter.cs @@ -46,9 +46,9 @@ protected override Expression VisitMethodCall(MethodCallExpression mc) private void Initialize(Expression> predicate, ColumnCollection predicateColumns, ColumnCollection currentColumns) { - ArgumentValidator.EnsureArgumentNotNull(predicate, "predicate"); - ArgumentValidator.EnsureArgumentNotNull(predicateColumns, "predicateColumns"); - ArgumentValidator.EnsureArgumentNotNull(currentColumns, "currentColumns"); + ArgumentNullException.ThrowIfNull(predicate, "predicate"); + ArgumentNullException.ThrowIfNull(predicateColumns, "predicateColumns"); + ArgumentNullException.ThrowIfNull(currentColumns, "currentColumns"); if (predicateColumns.Count == 0) throw Exceptions.CollectionIsEmpty("predicateColumns"); if (currentColumns.Count == 0) diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyParameterSearcher.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyParameterSearcher.cs index 72c7beae3..5d5e4d7e2 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyParameterSearcher.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyParameterSearcher.cs @@ -17,7 +17,7 @@ internal sealed class ApplyParameterSearcher : ExpressionVisitor public ApplyParameter Find(LambdaExpression predicate) { - ArgumentValidator.EnsureArgumentNotNull(predicate, "predicate"); + ArgumentNullException.ThrowIfNull(predicate, "predicate"); result = null; Visit(predicate); return result; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyPredicateCollector.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyPredicateCollector.cs index 7b0556010..1e747056a 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyPredicateCollector.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyPredicateCollector.cs @@ -88,8 +88,7 @@ private bool CheckPredicatesExist() => public ApplyPredicateCollector(ApplyProviderCorrectorRewriter owner) { - ArgumentValidator.EnsureArgumentNotNull(owner, "owner"); - this.owner = owner; + this.owner = owner ?? throw new ArgumentNullException(nameof(owner)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateProviderCollector.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateProviderCollector.cs index 8fea005bd..b2a99c88d 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateProviderCollector.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateProviderCollector.cs @@ -135,8 +135,7 @@ private void AddCalculateFilter(CalculateProvider calculateProvider, FilterProvi public CalculateProviderCollector(ApplyProviderCorrectorRewriter owner) { - ArgumentValidator.EnsureArgumentNotNull(owner, "owner"); - this.owner = owner; + this.owner = owner ?? throw new ArgumentNullException(nameof(owner)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateRelatedExpressionRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateRelatedExpressionRewriter.cs index 5d082bd80..a7f85e5b0 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateRelatedExpressionRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateRelatedExpressionRewriter.cs @@ -10,6 +10,7 @@ using Xtensive.Orm.Internals; using Tuple = Xtensive.Tuples.Tuple; using ExpressionVisitor = Xtensive.Linq.ExpressionVisitor; +using System; namespace Xtensive.Orm.Rse.Transformation { @@ -23,13 +24,11 @@ public LambdaExpression Rewrite(LambdaExpression expression, ParameterExpression substituteParameter, ColumnCollection sourceColumns, ColumnCollection targetColumns) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); - ArgumentValidator.EnsureArgumentNotNull(substituteParameter, "substituteParameter"); - ArgumentValidator.EnsureArgumentNotNull(sourceColumns, "sourceColumns"); - ArgumentValidator.EnsureArgumentNotNull(targetColumns, "targetColumns"); - substitute = substituteParameter; - this.sourceColumns = sourceColumns; - this.targetColumns = targetColumns; + ArgumentNullException.ThrowIfNull(expression, "expression"); + + substitute = substituteParameter ?? throw new ArgumentNullException(nameof(substituteParameter)); + this.sourceColumns = sourceColumns ?? throw new ArgumentNullException(nameof(sourceColumns)); + this.targetColumns = targetColumns ?? throw new ArgumentNullException(nameof(targetColumns)); return (LambdaExpression) Visit(expression); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs index aebd9f8c0..b294e6023 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs @@ -24,7 +24,7 @@ public static CompilableProvider Rewrite( CompilableProvider originProvider, Func orderingDescriptorResolver) { - ArgumentValidator.EnsureArgumentNotNull(originProvider, "originProvider"); + ArgumentNullException.ThrowIfNull(originProvider, nameof(originProvider)); var rewriter = new OrderingRewriter(orderingDescriptorResolver); if (originProvider.Type == ProviderType.Select) { var selectProvider = (SelectProvider) originProvider; @@ -227,8 +227,7 @@ private static DirectionCollection ComputeBinaryOrder(BinaryProvider provid private OrderingRewriter(Func orderingDescriptorResolver) { - ArgumentValidator.EnsureArgumentNotNull(orderingDescriptorResolver, "orderingDescriptorResolver"); - descriptorResolver = orderingDescriptorResolver; + descriptorResolver = orderingDescriptorResolver ?? throw new ArgumentNullException(nameof(orderingDescriptorResolver)); sortOrder = new DirectionCollection(); } } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ParameterRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ParameterRewriter.cs index dc3d53bd3..724bd3551 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ParameterRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ParameterRewriter.cs @@ -4,6 +4,7 @@ // Created by: Alexander Nikolaev // Created: 2009.05.15 +using System; using System.Linq.Expressions; using Xtensive.Core; using Xtensive.Linq; @@ -19,11 +20,10 @@ internal sealed class ParameterRewriter : ExpressionVisitor public LambdaExpression Replace(LambdaExpression sourceExpression, ParameterExpression oldParameter, ParameterExpression newParameter) { - ArgumentValidator.EnsureArgumentNotNull(sourceExpression, "sourceExpression"); - ArgumentValidator.EnsureArgumentNotNull(oldParameter, "oldParameter"); - ArgumentValidator.EnsureArgumentNotNull(newParameter, "newParameter"); - this.oldParameter = oldParameter; - this.newParameter = newParameter; + ArgumentNullException.ThrowIfNull(sourceExpression, nameof(sourceExpression)); + + this.oldParameter = oldParameter ?? throw new ArgumentNullException(nameof(oldParameter)); + this.newParameter = newParameter ?? throw new ArgumentNullException(nameof(newParameter)); return (LambdaExpression)Visit(sourceExpression); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/OrderingCorrector.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/OrderingCorrector.cs index 0314b07a6..5a3a10c7c 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/OrderingCorrector.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/OrderingCorrector.cs @@ -36,8 +36,7 @@ CompilableProvider IPreCompiler.Process(CompilableProvider rootProvider) /// . public OrderingCorrector(Func orderingDescriptorResolver) { - ArgumentValidator.EnsureArgumentNotNull(orderingDescriptorResolver, "orderingDescriptorResolver"); - this.orderingDescriptorResolver = orderingDescriptorResolver; + this.orderingDescriptorResolver = orderingDescriptorResolver ?? throw new ArgumentNullException(nameof(orderingDescriptorResolver)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessGatherer.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessGatherer.cs index 7442886e8..38b45c4c4 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessGatherer.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessGatherer.cs @@ -64,8 +64,8 @@ public virtual List Gather(Expression expression) /// List containing all used columns (order and uniqueness are not guaranteed). public List Gather(Expression expression, ParameterExpression parameter) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); - ArgumentValidator.EnsureArgumentNotNull(parameter, "parameter"); + ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(parameter, "parameter"); tupleParameter = parameter; var result = Gather(expression); tupleParameter = null; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessRewriter.cs index d0b00e565..31cb200ec 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessRewriter.cs @@ -68,8 +68,8 @@ public virtual Expression Rewrite(Expression expression) /// public virtual Expression Rewrite(Expression expression, ParameterExpression parameter) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); - ArgumentValidator.EnsureArgumentNotNull(parameter, "parameter"); + ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(parameter, "parameter"); tupleParameter = parameter; return Visit(expression); } diff --git a/Orm/Xtensive.Orm/Orm/Serialization/SerializationContext.cs b/Orm/Xtensive.Orm/Orm/Serialization/SerializationContext.cs index d09b3818c..fa1e20870 100644 --- a/Orm/Xtensive.Orm/Orm/Serialization/SerializationContext.cs +++ b/Orm/Xtensive.Orm/Orm/Serialization/SerializationContext.cs @@ -112,8 +112,7 @@ public SerializationContext(SerializationKind serializationKind) /// The getter. public SerializationContext(Func serializationKindGetter) { - ArgumentValidator.EnsureArgumentNotNull(serializationKindGetter, "serializationKindGetter"); - this.serializationKindGetter = serializationKindGetter; + this.serializationKindGetter = serializationKindGetter ?? throw new ArgumentNullException(nameof(serializationKindGetter)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Services/DirectEntityAccessor.cs b/Orm/Xtensive.Orm/Orm/Services/DirectEntityAccessor.cs index d863a2c4a..dd1030be2 100644 --- a/Orm/Xtensive.Orm/Orm/Services/DirectEntityAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Services/DirectEntityAccessor.cs @@ -39,7 +39,7 @@ public bool UpdateVersionInfo(Entity targetEntity, FieldInfo changedField) /// The target entity. public EntityState GetEntityState(Entity target) { - ArgumentValidator.EnsureArgumentNotNull(target, "target"); + ArgumentNullException.ThrowIfNull(target, "target"); return target.State; } diff --git a/Orm/Xtensive.Orm/Orm/Services/DirectEntitySetAccessor.cs b/Orm/Xtensive.Orm/Orm/Services/DirectEntitySetAccessor.cs index 317ca24e2..3534dfbb9 100644 --- a/Orm/Xtensive.Orm/Orm/Services/DirectEntitySetAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Services/DirectEntitySetAccessor.cs @@ -139,13 +139,13 @@ public void Clear(Entity target, FieldInfo field) private static void ValidateArguments(object target) { - ArgumentValidator.EnsureArgumentNotNull(target, "target"); + ArgumentNullException.ThrowIfNull(target, "target"); } private static void ValidateArguments(Persistent target, FieldInfo field) { ValidateArguments(target); - ArgumentValidator.EnsureArgumentNotNull(field, "field"); + ArgumentNullException.ThrowIfNull(field, "field"); if (!target.TypeInfo.Fields.Contains(field)) throw new InvalidOperationException(string.Format( Strings.ExTypeXDoesNotContainYField, target.TypeInfo.Name, field.Name)); @@ -157,13 +157,13 @@ private static void ValidateArguments(Persistent target, FieldInfo field) private static void ValidateArguments(EntitySetBase target, Entity item) { ValidateArguments(target); - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); } private static void ValidateArguments(Persistent target, FieldInfo field, Entity item) { ValidateArguments(target, field); - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item, "item"); } #endregion diff --git a/Orm/Xtensive.Orm/Orm/Services/DirectPersistentAccessor.cs b/Orm/Xtensive.Orm/Orm/Services/DirectPersistentAccessor.cs index 5aa8ab947..80a364de4 100644 --- a/Orm/Xtensive.Orm/Orm/Services/DirectPersistentAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Services/DirectPersistentAccessor.cs @@ -33,7 +33,7 @@ public class DirectPersistentAccessor : SessionBound, public Entity CreateEntity(Type entityType) { using (Session.OpenSystemLogicOnlyRegion()) { - ArgumentValidator.EnsureArgumentNotNull(entityType, "entityType"); + ArgumentNullException.ThrowIfNull(entityType, "entityType"); if (!WellKnownOrmTypes.Entity.IsAssignableFrom(entityType)) throw new InvalidOperationException( string.Format(Strings.TypeXIsNotAnYDescendant, entityType, WellKnownOrmTypes.Entity)); @@ -52,8 +52,8 @@ public Entity CreateEntity(Type entityType) public Entity CreateEntity(Type entityType, Tuple tuple) { using (Session.OpenSystemLogicOnlyRegion()) { - ArgumentValidator.EnsureArgumentNotNull(entityType, "entityType"); - ArgumentValidator.EnsureArgumentNotNull(tuple, "tuple"); + ArgumentNullException.ThrowIfNull(entityType, "entityType"); + ArgumentNullException.ThrowIfNull(tuple, "tuple"); if (!WellKnownOrmTypes.Entity.IsAssignableFrom(entityType)) throw new InvalidOperationException( string.Format(Strings.TypeXIsNotAnYDescendant, entityType, WellKnownOrmTypes.Entity)); @@ -73,7 +73,7 @@ public Entity CreateEntity(Key key) { using (Session.OpenSystemLogicOnlyRegion()) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); + ArgumentNullException.ThrowIfNull(key, "key"); if (key.TypeReference.Accuracy != TypeReferenceAccuracy.ExactType) throw new InvalidOperationException(string.Format(Strings.ExKeyXShouldHaveExactType, key)); var entityType = key.TypeReference.Type; @@ -102,7 +102,7 @@ public Structure CreateStructure(Type structureType) public Structure CreateStructure(Type structureType, Tuple structureData) { using (Session.OpenSystemLogicOnlyRegion()) { - ArgumentValidator.EnsureArgumentNotNull(structureType, "structureType"); + ArgumentNullException.ThrowIfNull(structureType, "structureType"); if (!WellKnownOrmTypes.Structure.IsAssignableFrom(structureType)) { throw new InvalidOperationException( string.Format(Strings.TypeXIsNotAnYDescendant, structureType, WellKnownOrmTypes.Structure)); @@ -233,7 +233,7 @@ public void SetFieldValue(Persistent target, FieldInfo field, T value) public void Remove(Entity target) { using (Session.OpenSystemLogicOnlyRegion()) { - ArgumentValidator.EnsureArgumentNotNull(target, "target"); + ArgumentNullException.ThrowIfNull(target, "target"); target.RemoveInternal(EntityRemoveReason.User); } } @@ -249,8 +249,8 @@ public void Remove(Entity target) /// The field of persistent type. protected static void ValidateArguments(Persistent target, FieldInfo field) { - ArgumentValidator.EnsureArgumentNotNull(target, "target"); - ArgumentValidator.EnsureArgumentNotNull(field, "field"); + ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(field, "field"); if (!target.TypeInfo.Fields.Contains(field)) throw new InvalidOperationException(string.Format( Strings.ExTypeXDoesNotContainYField, target.TypeInfo.Name, field.Name)); diff --git a/Orm/Xtensive.Orm/Orm/Services/Old/DirectStateAccessor.cs b/Orm/Xtensive.Orm/Orm/Services/Old/DirectStateAccessor.cs index 8b887d0f2..8fdacc0fa 100644 --- a/Orm/Xtensive.Orm/Orm/Services/Old/DirectStateAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Services/Old/DirectStateAccessor.cs @@ -4,7 +4,7 @@ // Created by: Alex Yakunin // Created: 2010.01.14 -using Xtensive.Core; +using System; namespace Xtensive.Orm.Services { @@ -19,7 +19,7 @@ public static class DirectStateAccessor /// public static SessionStateAccessor Get(Session source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); return new SessionStateAccessor(source); } @@ -28,7 +28,7 @@ public static SessionStateAccessor Get(Session source) /// public static PersistentStateAccessor Get(Persistent source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); return new PersistentStateAccessor(source); } @@ -37,7 +37,7 @@ public static PersistentStateAccessor Get(Persistent source) /// public static EntitySetStateAccessor Get(EntitySetBase source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); return new EntitySetStateAccessor(source); } } diff --git a/Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryBuilder.cs b/Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryBuilder.cs index e13cf06a2..34b67e1b1 100644 --- a/Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryBuilder.cs @@ -35,7 +35,7 @@ public sealed class QueryBuilder : SessionBound, ISessionService /// Translated query. public QueryTranslationResult TranslateQuery(IQueryable query) { - ArgumentValidator.EnsureArgumentNotNull(query, "query"); + ArgumentNullException.ThrowIfNull(query, "query"); var configuration = Session.CompilationService.CreateConfiguration(Session); configuration.PrepareRequest = false; @@ -64,7 +64,7 @@ public QueryTranslationResult TranslateQuery(IQueryable query) /// Compiled query. public SqlCompilationResult CompileQuery(ISqlCompileUnit query) { - ArgumentValidator.EnsureArgumentNotNull(query, "query"); + ArgumentNullException.ThrowIfNull(query, "query"); return driver.Compile(query); } @@ -77,8 +77,8 @@ public SqlCompilationResult CompileQuery(ISqlCompileUnit query) /// Created binding. public QueryParameterBinding CreateParameterBinding(Type valueType, Func valueAccessor) { - ArgumentValidator.EnsureArgumentNotNull(valueType, "valueType"); - ArgumentValidator.EnsureArgumentNotNull(valueAccessor, "valueAccessor"); + ArgumentNullException.ThrowIfNull(valueType, "valueType"); + ArgumentNullException.ThrowIfNull(valueAccessor, "valueAccessor"); var mapping = driver.GetTypeMapping(valueType); return new QueryParameterBinding( @@ -91,8 +91,8 @@ public QueryParameterBinding CreateParameterBinding(Type valueType, FuncBuilt request. public QueryRequest CreateRequest(SqlCompilationResult compiledQuery, IEnumerable bindings) { - ArgumentValidator.EnsureArgumentNotNull(compiledQuery, "compiledQuery"); - ArgumentValidator.EnsureArgumentNotNull(bindings, "bindings"); + ArgumentNullException.ThrowIfNull(compiledQuery, "compiledQuery"); + ArgumentNullException.ThrowIfNull(bindings, "bindings"); return new QueryRequest(new UserQueryRequest( compiledQuery, @@ -107,7 +107,7 @@ public QueryRequest CreateRequest(SqlCompilationResult compiledQuery, IEnumerabl /// Created command. public QueryCommand CreateCommand(QueryRequest request) { - ArgumentValidator.EnsureArgumentNotNull(request, "request"); + ArgumentNullException.ThrowIfNull(request, "request"); var command = commandFactory.CreateCommand(); command.AddPart(commandFactory.CreateQueryPart(request.RealRequest, new ParameterContext())); diff --git a/Orm/Xtensive.Orm/Orm/Services/QueryFormatter.cs b/Orm/Xtensive.Orm/Orm/Services/QueryFormatter.cs index 2218ea6cc..373ebb83a 100644 --- a/Orm/Xtensive.Orm/Orm/Services/QueryFormatter.cs +++ b/Orm/Xtensive.Orm/Orm/Services/QueryFormatter.cs @@ -4,6 +4,7 @@ // Created by: Dmitri Maximov // Created: 2011.03.02 +using System; using System.Collections.Generic; using System.Data.Common; using System.Linq; @@ -29,7 +30,7 @@ public sealed class QueryFormatter : SessionBound, ISessionService /// A string containing formatted query. public string ToSqlString(IQueryable query) { - ArgumentValidator.EnsureArgumentNotNull(query, "query"); + ArgumentNullException.ThrowIfNull(query, "query"); var part = GetCommandPart(query); return part!=null ? part.Statement : string.Empty; @@ -43,7 +44,7 @@ public string ToSqlString(IQueryable query) /// A string containing formatted query. public string ToString(IQueryable query) { - ArgumentValidator.EnsureArgumentNotNull(query, "query"); + ArgumentNullException.ThrowIfNull(query, "query"); return query.Expression.ToString(true); } @@ -56,7 +57,7 @@ public string ToString(IQueryable query) /// A . public DbCommand ToDbCommand(IQueryable query) { - ArgumentValidator.EnsureArgumentNotNull(query, "query"); + ArgumentNullException.ThrowIfNull(query, "query"); var part = GetCommandPart(query); if (part==null) diff --git a/Orm/Xtensive.Orm/Orm/Session.Persist.cs b/Orm/Xtensive.Orm/Orm/Session.Persist.cs index 27e91a691..2efec3e05 100644 --- a/Orm/Xtensive.Orm/Orm/Session.Persist.cs +++ b/Orm/Xtensive.Orm/Orm/Session.Persist.cs @@ -246,7 +246,7 @@ private async ValueTask Persist(PersistReason reason, bool isAsync, Cancellation public IDisposable DisableSaveChanges(IEntity target) { EnsureNotDisposed(); - ArgumentValidator.EnsureArgumentNotNull(target, "target"); + ArgumentNullException.ThrowIfNull(target, "target"); if (!Configuration.Supports(SessionOptions.AutoSaveChanges)) return null; // No need to pin in this case diff --git a/Orm/Xtensive.Orm/Orm/Session.Query.cs b/Orm/Xtensive.Orm/Orm/Session.Query.cs index 438b3370c..0c0002902 100644 --- a/Orm/Xtensive.Orm/Orm/Session.Query.cs +++ b/Orm/Xtensive.Orm/Orm/Session.Query.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2003-2010 Xtensive LLC. +// Copyright (C) 2003-2010 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Alexis Kochetov @@ -35,7 +35,7 @@ partial class Session /// once is called. public IDisposable OverrideQueryRoot(IQueryRootBuilder queryRootBuilder) { - ArgumentValidator.EnsureArgumentNotNull(queryRootBuilder, "queryRootBuilder"); + ArgumentNullException.ThrowIfNull(queryRootBuilder, "queryRootBuilder"); var oldQuery = Query; var newQuery = new QueryEndpoint(oldQuery, queryRootBuilder); Query = newQuery; diff --git a/Orm/Xtensive.Orm/Orm/StorageNode.cs b/Orm/Xtensive.Orm/Orm/StorageNode.cs index e800f24cf..8b775007b 100644 --- a/Orm/Xtensive.Orm/Orm/StorageNode.cs +++ b/Orm/Xtensive.Orm/Orm/StorageNode.cs @@ -97,7 +97,7 @@ public Task OpenSessionAsync(SessionType type, CancellationToken cancel /// public Task OpenSessionAsync(SessionConfiguration configuration, CancellationToken cancellationToken = default) { - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); SessionScope sessionScope = null; try { @@ -116,10 +116,10 @@ public Task OpenSessionAsync(SessionConfiguration configuration, Cancel internal StorageNode(Domain domain, NodeConfiguration configuration, ModelMapping mapping, TypeIdRegistry typeIdRegistry) { - ArgumentValidator.EnsureArgumentNotNull(domain, nameof(domain)); - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); - ArgumentValidator.EnsureArgumentNotNull(mapping, nameof(mapping)); - ArgumentValidator.EnsureArgumentNotNull(typeIdRegistry, nameof(typeIdRegistry)); + ArgumentNullException.ThrowIfNull(domain, nameof(domain)); + ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(mapping, nameof(mapping)); + ArgumentNullException.ThrowIfNull(typeIdRegistry, nameof(typeIdRegistry)); EntityLockProviderCache = new ConcurrentDictionary<(TypeInfo, LockMode, LockBehavior), ExecutableProvider>(); EntityFetchQueryCache = new ConcurrentDictionary(); diff --git a/Orm/Xtensive.Orm/Orm/Transaction.cs b/Orm/Xtensive.Orm/Orm/Transaction.cs index 60490b54f..938836926 100644 --- a/Orm/Xtensive.Orm/Orm/Transaction.cs +++ b/Orm/Xtensive.Orm/Orm/Transaction.cs @@ -63,7 +63,7 @@ public static Transaction Demand() /// is . public static void Require(Session session) { - ArgumentValidator.EnsureArgumentNotNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(session, nameof(session)); session.DemandTransaction(); } @@ -155,7 +155,7 @@ public static void Require(Session session) /// public bool AreChangesVisibleTo(Transaction otherTransaction) { - ArgumentValidator.EnsureArgumentNotNull(otherTransaction, "otherTransaction"); + ArgumentNullException.ThrowIfNull(otherTransaction, "otherTransaction"); if (Outermost != otherTransaction.Outermost) { return false; } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/ChangeFieldTypeHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/ChangeFieldTypeHint.cs index 64df8b31c..6628ef562 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/ChangeFieldTypeHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/ChangeFieldTypeHint.cs @@ -74,7 +74,7 @@ public override int GetHashCode() /// Name of field that changes type. public ChangeFieldTypeHint(Type type, string fieldName) { - ArgumentValidator.EnsureArgumentNotNull(type, nameof(type)); + ArgumentNullException.ThrowIfNull(type, nameof(type)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(fieldName, nameof(fieldName)); Type = type; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/CopyFieldHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/CopyFieldHint.cs index b001e748f..10d72cf82 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/CopyFieldHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/CopyFieldHint.cs @@ -87,7 +87,7 @@ public CopyFieldHint(string sourceTypeName, string sourceFieldName, Type targetT { ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceTypeName, nameof(sourceTypeName)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceFieldName, nameof(sourceFieldName)); - ArgumentValidator.EnsureArgumentNotNull(targetType, nameof(targetType)); + ArgumentNullException.ThrowIfNull(targetType, nameof(targetType)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(targetFieldName, nameof(targetFieldName)); SourceType = sourceTypeName; SourceField = sourceFieldName; @@ -115,9 +115,9 @@ public CopyFieldHint(Type sourceType, string fieldName, Type targetType) /// The target field name. public CopyFieldHint(Type sourceType, string sourceFieldName, Type targetType, string targetFieldName) { - ArgumentValidator.EnsureArgumentNotNull(sourceType, nameof(sourceType)); + ArgumentNullException.ThrowIfNull(sourceType, nameof(sourceType)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceFieldName, nameof(sourceFieldName)); - ArgumentValidator.EnsureArgumentNotNull(targetType, nameof(targetType)); + ArgumentNullException.ThrowIfNull(targetType, nameof(targetType)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(targetFieldName, nameof(targetFieldName)); SourceType = sourceType.FullName; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MergeTypeHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MergeTypeHint.cs index 11f6ed1e3..99180bf54 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MergeTypeHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MergeTypeHint.cs @@ -70,11 +70,8 @@ public override string ToString() => /// The new type. public MergeTypeHint(Type oldType, Type newType) { - ArgumentValidator.EnsureArgumentNotNull(newType, nameof(newType)); - ArgumentValidator.EnsureArgumentNotNull(oldType, nameof(oldType)); - - OldType = oldType; - NewType = newType; + OldType = oldType ?? throw new ArgumentNullException(nameof(oldType)); + NewType = newType ?? throw new ArgumentNullException(nameof(newType)); throw new NotImplementedException(); } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MoveFieldHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MoveFieldHint.cs index 0a8069668..2b10cb85b 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MoveFieldHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MoveFieldHint.cs @@ -88,7 +88,7 @@ public MoveFieldHint(string sourceTypeName, string sourceFieldName, Type targetT { ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceTypeName, nameof(sourceTypeName)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceFieldName, nameof(sourceFieldName)); - ArgumentValidator.EnsureArgumentNotNull(targetType, nameof(targetType)); + ArgumentNullException.ThrowIfNull(targetType, nameof(targetType)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(targetFieldName, nameof(targetFieldName)); SourceType = sourceTypeName; SourceField = sourceFieldName; @@ -116,9 +116,9 @@ public MoveFieldHint(Type sourceType, string fieldName, Type targetType) /// The target field name. public MoveFieldHint(Type sourceType, string sourceFieldName, Type targetType, string targetFieldName) { - ArgumentValidator.EnsureArgumentNotNull(sourceType, nameof(sourceType)); + ArgumentNullException.ThrowIfNull(sourceType, nameof(sourceType)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceFieldName, nameof(sourceFieldName)); - ArgumentValidator.EnsureArgumentNotNull(targetType, nameof(targetType)); + ArgumentNullException.ThrowIfNull(targetType, nameof(targetType)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(targetFieldName, nameof(targetFieldName)); SourceType = sourceType.FullName; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RecycledTypeHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RecycledTypeHint.cs index 655175377..92c44cbd2 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RecycledTypeHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RecycledTypeHint.cs @@ -61,9 +61,7 @@ public override int GetHashCode() /// The recycled type. public RecycledTypeHint(Type type) { - ArgumentValidator.EnsureArgumentNotNull(type, nameof(type)); - - Type = type; + Type = type ?? throw new ArgumentNullException(nameof(type)); throw new NotImplementedException(); } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RemoveFieldHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RemoveFieldHint.cs index f86f45cfe..547e657cd 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RemoveFieldHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RemoveFieldHint.cs @@ -92,7 +92,7 @@ public RemoveFieldHint(string typeName, string fieldName) /// Removing field name. public RemoveFieldHint(Type type, string fieldName) { - ArgumentValidator.EnsureArgumentNotNull(type, nameof(type)); + ArgumentNullException.ThrowIfNull(type, nameof(type)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(fieldName, nameof(fieldName)); Type = type.FullName; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameFieldHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameFieldHint.cs index 465531cb0..cb782a83d 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameFieldHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameFieldHint.cs @@ -76,9 +76,9 @@ public override string ToString() => /// New name of the field. public RenameFieldHint(Type targetType, string oldFieldName, string newFieldName) { - ArgumentValidator.EnsureArgumentNotNull(targetType, "targetType"); + ArgumentNullException.ThrowIfNull(targetType, "targetType"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(oldFieldName, "oldFieldName"); - ArgumentValidator.EnsureArgumentNotNull(newFieldName, "newFieldName"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(newFieldName, "newFieldName"); TargetType = targetType; OldFieldName = oldFieldName; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameTypeHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameTypeHint.cs index 070e654a1..3b40064a2 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameTypeHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameTypeHint.cs @@ -70,7 +70,7 @@ public override string ToString() => /// The new type. public RenameTypeHint(string oldType, Type newType) { - ArgumentValidator.EnsureArgumentNotNull(newType, nameof(newType)); + ArgumentNullException.ThrowIfNull(newType, nameof(newType)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(oldType, nameof(oldType)); if (!oldType.Contains(".", StringComparison.Ordinal)) diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainExtractedModelBuilder.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainExtractedModelBuilder.cs index 542eba21c..626cf3631 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainExtractedModelBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainExtractedModelBuilder.cs @@ -274,8 +274,8 @@ private static ReferentialAction ConvertReferentialAction(Model.ReferentialActio internal DomainExtractedModelBuilder(UpgradeServiceAccessor services, StorageModel model, bool makeSharedFinally) { - ArgumentValidator.EnsureArgumentNotNull(services, "services"); - ArgumentValidator.EnsureArgumentNotNull(model, "model"); + ArgumentNullException.ThrowIfNull(services, "services"); + ArgumentNullException.ThrowIfNull(model, "model"); this.model = model; this.makeSharedFinally = makeSharedFinally; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs index a280e1db7..9eadf3925 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs @@ -621,15 +621,10 @@ public DomainModelConverter( IFullTextCatalogNameBuilder fulltextCatalogNameBuilder, bool isUpgradingStage) { - ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers"); - ArgumentValidator.EnsureArgumentNotNull(typeIdProvider, "typeIdProvider"); - ArgumentValidator.EnsureArgumentNotNull(compiler, "compiler"); - ArgumentValidator.EnsureArgumentNotNull(resolver, "resolver"); - - this.handlers = handlers; - this.compiler = compiler; - this.typeIdProvider = typeIdProvider; - this.resolver = resolver; + this.handlers = handlers ?? throw new ArgumentNullException(nameof(handlers)); + this.compiler = compiler ?? throw new ArgumentNullException(nameof(compiler)); + this.typeIdProvider = typeIdProvider ?? throw new ArgumentNullException(nameof(typeIdProvider)); + this.resolver = resolver ?? throw new ArgumentNullException(nameof(resolver)); this.isUpgradingStage = isUpgradingStage; this.fulltextCatalogNameBuilder = fulltextCatalogNameBuilder; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/ExtractedModelBuilderFactory.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/ExtractedModelBuilderFactory.cs index ac30e6911..70acbc138 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/ExtractedModelBuilderFactory.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/ExtractedModelBuilderFactory.cs @@ -1,10 +1,10 @@ -// Copyright (C) 2016 Xtensive LLC. +// Copyright (C) 2016 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Alexey Kulakov // Created: 2016.02.23 -using Xtensive.Core; +using System; using Xtensive.Orm.Upgrade.Internals.Interfaces; namespace Xtensive.Orm.Upgrade.Internals @@ -13,7 +13,7 @@ internal static class ExtractedModelBuilderFactory { public static ISchemaExtractionResultBuilder GetBuilder(UpgradeContext context) { - ArgumentValidator.EnsureArgumentNotNull(context, "context"); + ArgumentNullException.ThrowIfNull(context, "context"); if (context.ParentDomain==null) { var makeShared = context.Configuration.ShareStorageSchemaOverNodes; return new DomainExtractedModelBuilder(context.Services, context.TargetStorageModel, makeShared); diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/HintGenerator.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/HintGenerator.cs index f958da1f9..48c58c055 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/HintGenerator.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/HintGenerator.cs @@ -1002,12 +1002,12 @@ public HintGenerator(UpgradeHintsProcessingResult hintsProcessingResult, StoredDomainModel currentDomainModel, StoredDomainModel extractedDomainModel) { - ArgumentValidator.EnsureArgumentNotNull(hintsProcessingResult, nameof(hintsProcessingResult)); - ArgumentValidator.EnsureArgumentNotNull(handlers, nameof(handlers)); - ArgumentValidator.EnsureArgumentNotNull(resolver, nameof(resolver)); - ArgumentValidator.EnsureArgumentNotNull(extractedStorageModel, nameof(extractedStorageModel)); - ArgumentValidator.EnsureArgumentNotNull(currentDomainModel, nameof(currentDomainModel)); - ArgumentValidator.EnsureArgumentNotNull(extractedDomainModel, nameof(extractedDomainModel)); + ArgumentNullException.ThrowIfNull(hintsProcessingResult); + ArgumentNullException.ThrowIfNull(handlers); + ArgumentNullException.ThrowIfNull(resolver); + ArgumentNullException.ThrowIfNull(extractedStorageModel); + ArgumentNullException.ThrowIfNull(currentDomainModel); + ArgumentNullException.ThrowIfNull(extractedDomainModel); typeMapping = hintsProcessingResult.TypeMapping; reverseTypeMapping = hintsProcessingResult.ReverseTypeMapping; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/IgnoreRulesHandler.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/IgnoreRulesHandler.cs index 3c86bce2d..988cab6e3 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/IgnoreRulesHandler.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/IgnoreRulesHandler.cs @@ -161,9 +161,8 @@ private void RemoveIndexes(DataTable table, string columnName) /// to be used. public IgnoreRulesHandler(SchemaExtractionResult model, DomainConfiguration configuration, MappingResolver resolver) { - ArgumentValidator.EnsureArgumentNotNull(model, "model"); - ArgumentValidator.EnsureArgumentNotNull(configuration, "configuration"); - targetModel = model; + ArgumentNullException.ThrowIfNull(configuration); + targetModel = model ?? throw new ArgumentNullException(nameof(model)); ignoreRules = configuration.IgnoreRules; mappingResolver = resolver; } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/ExtensionMetadata.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/ExtensionMetadata.cs index 96e255e2f..ec999df4b 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/ExtensionMetadata.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/ExtensionMetadata.cs @@ -1,10 +1,10 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov // Created: 2012.02.16 -using Xtensive.Core; +using System; namespace Xtensive.Orm.Upgrade { @@ -23,8 +23,7 @@ public override string ToString() public ExtensionMetadata(string name, string value) { - ArgumentValidator.EnsureArgumentNotNull(name, "name"); - Name = name; + Name = name ?? throw new ArgumentNullException(nameof(name)); Value = value; } } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/MetadataExtractor.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/MetadataExtractor.cs index 90dc5eed2..e2f216a1e 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/MetadataExtractor.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/MetadataExtractor.cs @@ -175,11 +175,8 @@ private int ReadInt(DbDataReader reader, int index) => public MetadataExtractor(MetadataMapping mapping, ISqlExecutor executor) { - ArgumentValidator.EnsureArgumentNotNull(mapping, nameof(mapping)); - ArgumentValidator.EnsureArgumentNotNull(executor, nameof(executor)); - - this.mapping = mapping; - this.executor = executor; + this.mapping = mapping ?? throw new ArgumentNullException(nameof(mapping)); + this.executor = executor ?? throw new ArgumentNullException(nameof(executor)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/MetadataWriter.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/MetadataWriter.cs index 0dd9e741d..66bb9d95a 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/MetadataWriter.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/MetadataWriter.cs @@ -131,15 +131,10 @@ private IPersistDescriptor CreateDescriptor(string tableName, public MetadataWriter(StorageDriver driver, MetadataMapping mapping, SqlExtractionTask task, IProviderExecutor executor) { - ArgumentValidator.EnsureArgumentNotNull(driver, "driver"); - ArgumentValidator.EnsureArgumentNotNull(mapping, "mapping"); - ArgumentValidator.EnsureArgumentNotNull(task, "task"); - ArgumentValidator.EnsureArgumentNotNull(executor, "executor"); - - this.driver = driver; - this.mapping = mapping; - this.task = task; - this.executor = executor; + this.driver = driver ?? throw new ArgumentNullException(nameof(driver)); + this.mapping = mapping ?? throw new ArgumentNullException(nameof(mapping)); + this.task = task ?? throw new ArgumentNullException(nameof(task)); + this.executor = executor ?? throw new ArgumentNullException(nameof(executor)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/TypeMetadata.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/TypeMetadata.cs index ded92925f..3cce4f69b 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/TypeMetadata.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/TypeMetadata.cs @@ -4,6 +4,7 @@ // Created by: Denis Krjuchkov // Created: 2012.02.16 +using System; using Xtensive.Core; using Xtensive.Reflection; @@ -22,7 +23,7 @@ public override string ToString() => public TypeMetadata(int id, string name) { - ArgumentValidator.EnsureArgumentNotNull(name, "name"); + ArgumentNullException.ThrowIfNull(name); Id = id; Name = name; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/NodeExtractedModelBuilder.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/NodeExtractedModelBuilder.cs index 2096b8da4..cd435c46b 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/NodeExtractedModelBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/NodeExtractedModelBuilder.cs @@ -1,9 +1,10 @@ -// Copyright (C) 2016 Xtensive LLC. +// Copyright (C) 2016 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Alexey Kulakov // Created: 2016.02.23 +using System; using System.Collections.Generic; using System.Linq; using Xtensive.Core; @@ -61,9 +62,9 @@ private IList GetDefaultNodeCatalogs() internal NodeExtractedModelBuilder(UpgradeServiceAccessor services, StorageNode defaultNode, NodeConfiguration buildingNodeConfiguration, bool defaultNodeIsUnreadable) { - ArgumentValidator.EnsureArgumentNotNull(services, "services"); - ArgumentValidator.EnsureArgumentNotNull(defaultNode, "defaultNode"); - ArgumentValidator.EnsureArgumentNotNull(buildingNodeConfiguration, "buildingNodeConfiguration"); + ArgumentNullException.ThrowIfNull(services); + ArgumentNullException.ThrowIfNull(defaultNode); + ArgumentNullException.ThrowIfNull(buildingNodeConfiguration); mappingResolver = services.MappingResolver; this.buildingNodeConfiguration = buildingNodeConfiguration; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/NullUpgradeHintsProcessor.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/NullUpgradeHintsProcessor.cs index 5ec0f40bd..cd3b6b467 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/NullUpgradeHintsProcessor.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/NullUpgradeHintsProcessor.cs @@ -35,9 +35,7 @@ public UpgradeHintsProcessingResult Process(IEnumerable inputHints) public NullUpgradeHintsProcessor(StoredDomainModel currentDomainModel) { - ArgumentValidator.EnsureArgumentNotNull(currentDomainModel, nameof(currentDomainModel)); - - this.currentDomainModel = currentDomainModel; + this.currentDomainModel = currentDomainModel ?? throw new ArgumentNullException(nameof(currentDomainModel)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/PartialIndexInfoMap.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/PartialIndexInfoMap.cs index d49208859..464afffc5 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/PartialIndexInfoMap.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/PartialIndexInfoMap.cs @@ -29,8 +29,8 @@ public StoredPartialIndexFilterInfo FindIndex(string table, string index) public PartialIndexInfoMap(MappingResolver resolver, IEnumerable indexes) { - ArgumentValidator.EnsureArgumentNotNull(resolver, "resolver"); - ArgumentValidator.EnsureArgumentNotNull(indexes, "indexes"); + ArgumentNullException.ThrowIfNull(resolver); + ArgumentNullException.ThrowIfNull(indexes); items = new Dictionary>(Comparer); diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlActionTranslator.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlActionTranslator.cs index 8ad51cbaf..f6bd74df8 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlActionTranslator.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlActionTranslator.cs @@ -1325,27 +1325,20 @@ public SqlActionTranslator( ActionSequence actions, SchemaExtractionResult sqlModel, StorageModel sourceModel, StorageModel targetModel, List enforceChangedColumns, bool allowCreateConstraints) { - ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers"); - ArgumentValidator.EnsureArgumentNotNull(sqlExecutor, "sqlExecutor"); - ArgumentValidator.EnsureArgumentNotNull(resolver, "resolver"); - ArgumentValidator.EnsureArgumentNotNull(actions, "actions"); - ArgumentValidator.EnsureArgumentNotNull(sqlModel, "sqlModel"); - ArgumentValidator.EnsureArgumentNotNull(sourceModel, "sourceModel"); - ArgumentValidator.EnsureArgumentNotNull(targetModel, "targetModel"); - ArgumentValidator.EnsureArgumentNotNull(enforceChangedColumns, "enforceChangedColumns"); + ArgumentNullException.ThrowIfNull(handlers); driver = handlers.StorageDriver; providerInfo = handlers.ProviderInfo; sequenceQueryBuilder = handlers.SequenceQueryBuilder; typeIdColumnName = handlers.NameBuilder.TypeIdColumnName; - this.resolver = resolver; - this.sqlModel = sqlModel; - this.actions = actions; - this.sourceModel = sourceModel; - this.targetModel = targetModel; - this.enforceChangedColumns = enforceChangedColumns; - this.sqlExecutor = sqlExecutor; + this.resolver = resolver ?? throw new ArgumentNullException(nameof(resolver)); + this.sqlModel = sqlModel ?? throw new ArgumentNullException(nameof(sqlModel)); + this.actions = actions ?? throw new ArgumentNullException(nameof(actions)); + this.sourceModel = sourceModel ?? throw new ArgumentNullException(nameof(sourceModel)); + this.targetModel = targetModel ?? throw new ArgumentNullException(nameof(targetModel)); + this.enforceChangedColumns = enforceChangedColumns ?? throw new ArgumentNullException(nameof(enforceChangedColumns)); + this.sqlExecutor = sqlExecutor ?? throw new ArgumentNullException(nameof(sqlExecutor)); this.allowCreateConstraints = allowCreateConstraints; if (providerInfo.Supports(ProviderFeatures.Collations)) { diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs index 6c316682a..e85ecab9a 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs @@ -342,9 +342,9 @@ private bool IsGeneratorTable(Table table) public SqlModelConverter(UpgradeServiceAccessor services, SchemaExtractionResult sourceModel, IEnumerable partialIndexes) { - ArgumentValidator.EnsureArgumentNotNull(services, "handlers"); - ArgumentValidator.EnsureArgumentNotNull(sourceModel, "sourceModel"); - ArgumentValidator.EnsureArgumentNotNull(partialIndexes, "partialIndexes"); + ArgumentNullException.ThrowIfNull(services); + ArgumentNullException.ThrowIfNull(sourceModel); + ArgumentNullException.ThrowIfNull(partialIndexes); this.sourceModel = sourceModel; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/StageModelFilter.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/StageModelFilter.cs index 56e061850..b12a7620d 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/StageModelFilter.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/StageModelFilter.cs @@ -30,9 +30,7 @@ public bool IsTypeAvailable(Type type) => public StageModelFilter(IReadOnlyDictionary handlers, UpgradeStage stage) { - ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers"); - - this.handlers = handlers; + this.handlers = handlers ?? throw new ArgumentNullException(nameof(handlers)); this.stage = stage; } } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/TypeIdProvider.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/TypeIdProvider.cs index 773b2fba5..c447547ae 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/TypeIdProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/TypeIdProvider.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2020 Xtensive LLC. +// Copyright (C) 2012-2020 Xtensive LLC. // This code is distributed under MIT license terms. // See the License.txt file in the project root for more information. // Created by: Denis Krjuchkov @@ -59,8 +59,7 @@ private int FindTypeId(IDictionary typeIdMap, string typeName) public TypeIdProvider(UpgradeContext context) { - ArgumentValidator.EnsureArgumentNotNull(context, "context"); - this.context = context; + this.context = context ?? throw new ArgumentNullException(nameof(context)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeActionSequenceBuilder.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeActionSequenceBuilder.cs index 06137103d..0a70f0ff2 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeActionSequenceBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeActionSequenceBuilder.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -58,7 +58,7 @@ private static List SelectOutput(UpgradeActionSequence result, SqlUpgrad case SqlUpgradeStage.Cleanup: return result.CleanupCommands; default: - throw new ArgumentOutOfRangeException("stage"); + throw new ArgumentOutOfRangeException(nameof(stage)); } } @@ -66,8 +66,8 @@ private static List SelectOutput(UpgradeActionSequence result, SqlUpgrad public UpgradeActionSequenceBuilder(StorageDriver driver, UpgradeActionSequence result, SqlUpgradeStage stage) { - ArgumentValidator.EnsureArgumentNotNull(driver, "driver"); - ArgumentValidator.EnsureArgumentNotNull(result, "result"); + ArgumentNullException.ThrowIfNull(driver); + ArgumentNullException.ThrowIfNull(result); this.driver = driver; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeHintsProcessingResult.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeHintsProcessingResult.cs index 4727ba40a..db0bc08e9 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeHintsProcessingResult.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeHintsProcessingResult.cs @@ -4,6 +4,7 @@ // Created by: Alexey Kulakov // Created: 2015.01.22 +using System; using System.Collections.Generic; using System.Linq; using Xtensive.Collections; @@ -53,25 +54,15 @@ public UpgradeHintsProcessingResult(NativeTypeClassifier hints, IReadOnlyList currentNonConnectorTypes, IReadOnlyList extractedNonConnectorTypes) { - ArgumentValidator.EnsureArgumentNotNull(hints, nameof(hints)); - ArgumentValidator.EnsureArgumentNotNull(typeMapping, nameof(typeMapping)); - ArgumentValidator.EnsureArgumentNotNull(reverseTypeMapping, nameof(reverseTypeMapping)); - ArgumentValidator.EnsureArgumentNotNull(fieldMapping, nameof(fieldMapping)); - ArgumentValidator.EnsureArgumentNotNull(reverseFieldMapping, nameof(reverseFieldMapping)); - ArgumentValidator.EnsureArgumentNotNull(currentModelTypes, nameof(currentModelTypes)); - ArgumentValidator.EnsureArgumentNotNull(suspiciousTypes, nameof(suspiciousTypes)); - ArgumentValidator.EnsureArgumentNotNull(currentNonConnectorTypes, nameof(suspiciousTypes)); - ArgumentValidator.EnsureArgumentNotNull(extractedNonConnectorTypes, nameof(suspiciousTypes)); - - Hints = hints; - TypeMapping = typeMapping; - ReverseTypeMapping = reverseTypeMapping; - FieldMapping = fieldMapping; - ReverseFieldMapping = reverseFieldMapping; - CurrentModelTypes = currentModelTypes; - SuspiciousTypes = suspiciousTypes; - CurrentNonConnectorTypes = currentNonConnectorTypes; - ExtractedNonConnectorTypes = extractedNonConnectorTypes; + Hints = hints ?? throw new ArgumentNullException(nameof(hints)); + TypeMapping = typeMapping ?? throw new ArgumentNullException(nameof(typeMapping)); + ReverseTypeMapping = reverseTypeMapping ?? throw new ArgumentNullException(nameof(reverseTypeMapping)); + FieldMapping = fieldMapping ?? throw new ArgumentNullException(nameof(fieldMapping)); + ReverseFieldMapping = reverseFieldMapping ?? throw new ArgumentNullException(nameof(reverseFieldMapping)); + CurrentModelTypes = currentModelTypes ?? throw new ArgumentNullException(nameof(currentModelTypes)); + SuspiciousTypes = suspiciousTypes ?? throw new ArgumentNullException(nameof(suspiciousTypes)); + CurrentNonConnectorTypes = currentNonConnectorTypes ?? throw new ArgumentNullException(nameof(currentNonConnectorTypes)); + ExtractedNonConnectorTypes = extractedNonConnectorTypes ?? throw new ArgumentNullException(nameof(extractedNonConnectorTypes)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeHintsProcessor.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeHintsProcessor.cs index e90f7eaf4..cfcc2a2ad 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeHintsProcessor.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeHintsProcessor.cs @@ -45,7 +45,7 @@ internal sealed class UpgradeHintsProcessor : IUpgradeHintsProcessor public UpgradeHintsProcessingResult Process(IEnumerable inputHints) { - ArgumentValidator.EnsureArgumentNotNull(inputHints, "inputHints"); + ArgumentNullException.ThrowIfNull(inputHints); ProcessGenericTypeHints(inputHints); ProcessTypeChanges(); @@ -209,8 +209,6 @@ private void BuildTypeMapping(IReadOnlyDictionary rename currentNonConnectorTypes = GetNonConnectorTypes(currentModel); var newModelTypes = currentNonConnectorTypes.ToDictionary(type => type.UnderlyingType, currentModel.Types.Length); - //var renameLookup = renameTypeHints.ToDictionary(hint => hint.OldType, renameTypeHints.Count); - //var removeLookup = removeTypeHints.ToDictionary(hint => hint.Type, removeTypeHints.Count); // Types that are neither mapped nor removed. var suspects = new HashSet(); @@ -606,11 +604,11 @@ public UpgradeHintsProcessor( StorageModel extractedStorageModel, bool autoDetectTypesMovements) { - ArgumentValidator.EnsureArgumentNotNull(handlers, nameof(handlers)); - ArgumentValidator.EnsureArgumentNotNull(resolver, nameof(resolver)); - ArgumentValidator.EnsureArgumentNotNull(currentDomainModel, nameof(currentDomainModel)); - ArgumentValidator.EnsureArgumentNotNull(extractedDomainModel, nameof(extractedDomainModel)); - ArgumentValidator.EnsureArgumentNotNull(extractedStorageModel, nameof(extractedStorageModel)); + ArgumentNullException.ThrowIfNull(handlers); + ArgumentNullException.ThrowIfNull(resolver); + ArgumentNullException.ThrowIfNull(currentDomainModel); + ArgumentNullException.ThrowIfNull(extractedDomainModel); + ArgumentNullException.ThrowIfNull(extractedStorageModel); // since type mapping is intersection of current types and extracted types // it will be equal or less than min size of these two sets diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeServiceAccessor.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeServiceAccessor.cs index 5eb3ae100..3090ae5f7 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeServiceAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/UpgradeServiceAccessor.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -155,7 +155,7 @@ public void ClearTemporaryResources() public void RegisterTemporaryResource(IDisposable resource) { - ArgumentValidator.EnsureArgumentNotNull(resource, "resource"); + ArgumentNullException.ThrowIfNull(resource); lock (resourcesSyncRoot) { temporaryResources.Add(resource); } @@ -163,7 +163,7 @@ public void RegisterTemporaryResource(IDisposable resource) public void RegisterResource(IDisposable resource) { - ArgumentValidator.EnsureArgumentNotNull(resource, "resource"); + ArgumentNullException.ThrowIfNull(resource); lock (resourcesSyncRoot) { resources.Add(resource); } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Model/StorageTypeInfo.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Model/StorageTypeInfo.cs index ea3c319e1..661071e5e 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Model/StorageTypeInfo.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Model/StorageTypeInfo.cs @@ -242,7 +242,7 @@ public StorageTypeInfo(Type type, SqlValueType nativeType, int? length, int? pre /// Indicates whether type is nullable. public StorageTypeInfo(Type type, SqlValueType nativeType, bool isNullable) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); if (isNullable && type.IsValueType && !type.IsNullable()) ArgumentValidator.EnsureArgumentIsInRange(true, false, false, "isNullable"); Type = type; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/TypeConversionVerifier.cs b/Orm/Xtensive.Orm/Orm/Upgrade/TypeConversionVerifier.cs index 9341982e2..a4931d3d8 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/TypeConversionVerifier.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/TypeConversionVerifier.cs @@ -31,8 +31,8 @@ public static class TypeConversionVerifier /// public static bool CanConvert(StorageTypeInfo from, StorageTypeInfo to) { - ArgumentValidator.EnsureArgumentNotNull(from, "from"); - ArgumentValidator.EnsureArgumentNotNull(to, "to"); + ArgumentNullException.ThrowIfNull(from); + ArgumentNullException.ThrowIfNull(to); // Truncation and precision loss is ALLOWED by this method @@ -65,8 +65,8 @@ public static bool CanConvert(StorageTypeInfo from, StorageTypeInfo to) /// public static bool CanConvertSafely(StorageTypeInfo from, StorageTypeInfo to) { - ArgumentValidator.EnsureArgumentNotNull(from, "from"); - ArgumentValidator.EnsureArgumentNotNull(to, "to"); + ArgumentNullException.ThrowIfNull(from); + ArgumentNullException.ThrowIfNull(to); // Truncation and precision loss is NOT ALLOWED by this method diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeActionSequence.cs b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeActionSequence.cs index f9a596748..2936087f6 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeActionSequence.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeActionSequence.cs @@ -94,8 +94,8 @@ public sealed class UpgradeActionSequence : IEnumerable /// Non-transactional processor. public void ProcessWith(Action> regularProcessor, Action> nonTransactionalProcessor) { - ArgumentValidator.EnsureArgumentNotNull(regularProcessor, nameof(regularProcessor)); - ArgumentValidator.EnsureArgumentNotNull(nonTransactionalProcessor, nameof(nonTransactionalProcessor)); + ArgumentNullException.ThrowIfNull(regularProcessor); + ArgumentNullException.ThrowIfNull(nonTransactionalProcessor); if (NonTransactionalPrologCommands.Count > 0) { nonTransactionalProcessor.Invoke(NonTransactionalPrologCommands); @@ -123,8 +123,8 @@ public async Task ProcessWithAsync( Func, CancellationToken, Task> nonTransactionalProcessor, CancellationToken token) { - ArgumentValidator.EnsureArgumentNotNull(regularProcessor, nameof(regularProcessor)); - ArgumentValidator.EnsureArgumentNotNull(nonTransactionalProcessor, nameof(nonTransactionalProcessor)); + ArgumentNullException.ThrowIfNull(regularProcessor); + ArgumentNullException.ThrowIfNull(nonTransactionalProcessor); if (NonTransactionalPrologCommands.Count > 0) { await nonTransactionalProcessor.Invoke(NonTransactionalPrologCommands, token).ConfigureAwait(false); diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeContext.cs b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeContext.cs index fb01486de..6d8dee0de 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeContext.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeContext.cs @@ -233,8 +233,8 @@ private void Initialize() internal UpgradeContext(Domain parentDomain, NodeConfiguration nodeConfiguration) { - ArgumentValidator.EnsureArgumentNotNull(parentDomain, "parentDomain"); - ArgumentValidator.EnsureArgumentNotNull(nodeConfiguration, "nodeConfiguration"); + ArgumentNullException.ThrowIfNull(parentDomain); + ArgumentNullException.ThrowIfNull(nodeConfiguration); UpgradeMode = nodeConfiguration.UpgradeMode; Configuration = parentDomain.Configuration; @@ -249,7 +249,7 @@ internal UpgradeContext(Domain parentDomain, NodeConfiguration nodeConfiguration internal UpgradeContext(DomainConfiguration configuration) { - ArgumentValidator.EnsureArgumentNotNull(configuration, "configuration"); + ArgumentNullException.ThrowIfNull(configuration); UpgradeMode = configuration.UpgradeMode; Configuration = configuration; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeHandler.cs b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeHandler.cs index 6f3c0a89b..ee7e93108 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeHandler.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradeHandler.cs @@ -227,7 +227,7 @@ public virtual bool CanUpgradeFrom(string oldVersion) /// UpgradeContext.Stage is out of range. public virtual bool IsTypeAvailable(Type type, UpgradeStage upgradeStage) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); if (type.Assembly!=Assembly) throw new ArgumentOutOfRangeException("type"); switch (upgradeStage) { @@ -243,7 +243,7 @@ public virtual bool IsTypeAvailable(Type type, UpgradeStage upgradeStage) /// UpgradeContext.Stage is out of range. public virtual bool IsFieldAvailable(PropertyInfo field, UpgradeStage upgradeStage) { - ArgumentValidator.EnsureArgumentNotNull(field, "field"); + ArgumentNullException.ThrowIfNull(field); var type = field.DeclaringType; if (type.Assembly!=Assembly) throw new ArgumentOutOfRangeException("field"); diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs index d1af87131..f25f051b3 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs @@ -40,7 +40,7 @@ internal sealed class UpgradingDomainBuilder public static Domain Build(DomainConfiguration configuration) { - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration); if (configuration.ConnectionInfo==null) { throw new ArgumentException(Strings.ExConnectionInfoIsMissing, nameof(configuration)); @@ -66,7 +66,7 @@ public static Domain Build(DomainConfiguration configuration) public static async Task BuildAsync(DomainConfiguration configuration, CancellationToken token) { - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration); if (configuration.ConnectionInfo==null) { throw new ArgumentException(Strings.ExConnectionInfoIsMissing, nameof(configuration)); @@ -92,8 +92,8 @@ public static async Task BuildAsync(DomainConfiguration configuration, C public static StorageNode BuildNode(Domain parentDomain, NodeConfiguration nodeConfiguration) { - ArgumentValidator.EnsureArgumentNotNull(parentDomain, nameof(parentDomain)); - ArgumentValidator.EnsureArgumentNotNull(nodeConfiguration, nameof(nodeConfiguration)); + ArgumentNullException.ThrowIfNull(parentDomain); + ArgumentNullException.ThrowIfNull(nodeConfiguration); nodeConfiguration.Validate(parentDomain.Configuration); if (!nodeConfiguration.IsLocked) { @@ -112,8 +112,8 @@ public static StorageNode BuildNode(Domain parentDomain, NodeConfiguration nodeC public static async Task BuildNodeAsync( Domain parentDomain, NodeConfiguration nodeConfiguration, CancellationToken token) { - ArgumentValidator.EnsureArgumentNotNull(parentDomain, nameof(parentDomain)); - ArgumentValidator.EnsureArgumentNotNull(nodeConfiguration, nameof(nodeConfiguration)); + ArgumentNullException.ThrowIfNull(parentDomain); + ArgumentNullException.ThrowIfNull(nodeConfiguration); nodeConfiguration.Validate(parentDomain.Configuration); if (!nodeConfiguration.IsLocked) { diff --git a/Orm/Xtensive.Orm/Orm/Validation/EntityErrorInfo.cs b/Orm/Xtensive.Orm/Orm/Validation/EntityErrorInfo.cs index ac5f87c9f..bc4057ff0 100644 --- a/Orm/Xtensive.Orm/Orm/Validation/EntityErrorInfo.cs +++ b/Orm/Xtensive.Orm/Orm/Validation/EntityErrorInfo.cs @@ -1,9 +1,10 @@ -// Copyright (C) 2013-2020 Xtensive LLC. +// Copyright (C) 2013-2020 Xtensive LLC. // This code is distributed under MIT license terms. // See the License.txt file in the project root for more information. // Created by: Denis Krjuchkov // Created: 2013.09.09 +using System; using System.Collections.Generic; using Xtensive.Core; @@ -31,8 +32,8 @@ public sealed class EntityErrorInfo /// A collection of s for an errors discovered. public EntityErrorInfo(Entity target, IList errors) { - ArgumentValidator.EnsureArgumentNotNull(target, "target"); - ArgumentValidator.EnsureArgumentNotNull(errors, "errors"); + ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(errors, "errors"); Target = target; Errors = errors; diff --git a/Orm/Xtensive.Orm/Orm/Validation/ValidationResult.cs b/Orm/Xtensive.Orm/Orm/Validation/ValidationResult.cs index 82dc95a91..68a4c246c 100644 --- a/Orm/Xtensive.Orm/Orm/Validation/ValidationResult.cs +++ b/Orm/Xtensive.Orm/Orm/Validation/ValidationResult.cs @@ -1,3 +1,4 @@ +using System; using Xtensive.Core; using Xtensive.Orm.Model; @@ -59,7 +60,7 @@ private ValidationResult() /// Validated value. public ValidationResult(IValidator source, string errorMessage, FieldInfo field = null, object value = null) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(errorMessage, "errorMessage"); isError = true; diff --git a/Orm/Xtensive.Orm/Orm/VersionCapturer.cs b/Orm/Xtensive.Orm/Orm/VersionCapturer.cs index 1d96ac0da..2364f377d 100644 --- a/Orm/Xtensive.Orm/Orm/VersionCapturer.cs +++ b/Orm/Xtensive.Orm/Orm/VersionCapturer.cs @@ -130,7 +130,7 @@ public static VersionCapturer Attach(Session session, VersionSet versions) private VersionCapturer(Session session, VersionSet versions) : base(session) { - ArgumentValidator.EnsureArgumentNotNull(versions, "versions"); + ArgumentNullException.ThrowIfNull(versions); Versions = versions; AttachEventHandlers(); } diff --git a/Orm/Xtensive.Orm/Orm/VersionInfo.cs b/Orm/Xtensive.Orm/Orm/VersionInfo.cs index ff38fcc6c..31a581b98 100644 --- a/Orm/Xtensive.Orm/Orm/VersionInfo.cs +++ b/Orm/Xtensive.Orm/Orm/VersionInfo.cs @@ -58,7 +58,7 @@ internal Tuple Value { /// Combined version info. internal VersionInfo Combine(Key key, VersionInfo versionInfo) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); + ArgumentNullException.ThrowIfNull(key); Tuple resultVersion = Value; if (resultVersion==null) diff --git a/Orm/Xtensive.Orm/Orm/VersionSet.cs b/Orm/Xtensive.Orm/Orm/VersionSet.cs index 09cf4ee34..973d20c3d 100644 --- a/Orm/Xtensive.Orm/Orm/VersionSet.cs +++ b/Orm/Xtensive.Orm/Orm/VersionSet.cs @@ -102,7 +102,7 @@ public bool Contains(Key key) /// public bool Validate(Entity entity) { - ArgumentValidator.EnsureArgumentNotNull(entity, "entity"); + ArgumentNullException.ThrowIfNull(entity); return Validate(entity.Key, entity.VersionInfo); } @@ -117,7 +117,7 @@ public bool Validate(Entity entity) /// public bool Validate(Entity entity, bool throwOnFailure) { - ArgumentValidator.EnsureArgumentNotNull(entity, "entity"); + ArgumentNullException.ThrowIfNull(entity); return Validate(entity.Key, entity.VersionInfo, throwOnFailure); } @@ -181,7 +181,7 @@ public bool Validate(Key key, VersionInfo version, bool throwOnFailure) /// otherwise, . public bool Add(Entity entity, bool overwrite) { - ArgumentValidator.EnsureArgumentNotNull(entity, "entity"); + ArgumentNullException.ThrowIfNull(entity); var key = entity.Key; var version = entity.VersionInfo; return Add(key, version, overwrite); @@ -198,7 +198,7 @@ public bool Add(Entity entity, bool overwrite) /// otherwise, . public bool Add(Key key, VersionInfo version, bool overwrite) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); + ArgumentNullException.ThrowIfNull(key); if (!Contains(key)) { if (version.IsVoid) return false; @@ -227,7 +227,7 @@ public bool Add(Key key, VersionInfo version, bool overwrite) /// otherwise, . public bool Remove(Entity entity) { - ArgumentValidator.EnsureArgumentNotNull(entity, "entity"); + ArgumentNullException.ThrowIfNull(entity); return Remove(entity.Key); } @@ -239,7 +239,7 @@ public bool Remove(Entity entity) /// otherwise, . public bool Remove(Key key) { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); + ArgumentNullException.ThrowIfNull(key); return versions.Remove(key); } diff --git a/Orm/Xtensive.Orm/Orm/VersionValidator.cs b/Orm/Xtensive.Orm/Orm/VersionValidator.cs index 93955fc90..e343b8d58 100644 --- a/Orm/Xtensive.Orm/Orm/VersionValidator.cs +++ b/Orm/Xtensive.Orm/Orm/VersionValidator.cs @@ -332,7 +332,7 @@ public static VersionValidator Attach(Session session, Func ex private VersionValidator(Session session, Func expectedVersionProvider) : base(session) { - ArgumentValidator.EnsureArgumentNotNull(expectedVersionProvider, "expectedVersionProvider"); + ArgumentNullException.ThrowIfNull(expectedVersionProvider, "expectedVersionProvider"); if (session.IsPersisting) throw new InvalidOperationException( Strings.ExServiceCanNotBeAttachedToSessionWhileItIsPersistingTheChanges); diff --git a/Orm/Xtensive.Orm/Reflection/DelegateHelper.cs b/Orm/Xtensive.Orm/Reflection/DelegateHelper.cs index 88fe84a71..60a31abad 100644 --- a/Orm/Xtensive.Orm/Reflection/DelegateHelper.cs +++ b/Orm/Xtensive.Orm/Reflection/DelegateHelper.cs @@ -351,9 +351,9 @@ static Lazy DelegateFactory(MethodCallDelegateKey methodKey, (Type sou public static TDelegate CreateDelegate(object callTarget, Type type, string methodName, params Type[] genericArgumentTypes) where TDelegate : class { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); ArgumentValidator.EnsureArgumentNotNullOrEmpty(methodName, "methodName"); - ArgumentValidator.EnsureArgumentNotNull(genericArgumentTypes, "genericArgumentTypes"); + ArgumentNullException.ThrowIfNull(genericArgumentTypes); Type delegateType = typeof (TDelegate); if (!WellKnownTypes.Delegate.IsAssignableFrom(delegateType)) throw new ArgumentException(string.Format(Strings.ExGenericParameterShouldBeOfTypeT, @@ -398,9 +398,9 @@ public static TDelegate CreateDelegate(object callTarget, Type type, public static TDelegate[] CreateDelegates(object callTarget, Type type, string methodName, IList genericArgumentVariants) where TDelegate : class { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); ArgumentValidator.EnsureArgumentNotNullOrEmpty(methodName, "methodName"); - ArgumentValidator.EnsureArgumentNotNull(genericArgumentVariants, "genericArgumentVariants"); + ArgumentNullException.ThrowIfNull(genericArgumentVariants); Type delegateType = typeof (TDelegate); if (!WellKnownTypes.Delegate.IsAssignableFrom(delegateType)) throw new ArgumentException(string.Format(Strings.ExGenericParameterShouldBeOfTypeT, @@ -475,7 +475,7 @@ public static void ExecuteDelegates(ExecutionSequenceHandler[] delegates, /// Created delegate type. public static Type MakeDelegateType(Type returnType, params Type[] parameterTypes) { - ArgumentValidator.EnsureArgumentNotNull(parameterTypes, "parameterTypes"); + ArgumentNullException.ThrowIfNull(parameterTypes); if (parameterTypes.Length > MaxNumberOfGenericDelegateParameters) throw new NotSupportedException(); if (returnType == WellKnownTypes.Void || returnType == null) { @@ -495,7 +495,7 @@ public static Type MakeDelegateType(Type returnType, params Type[] parameterType /// Created delegate type. public static Type MakeDelegateType(Type returnType, IEnumerable parameterTypes) { - ArgumentValidator.EnsureArgumentNotNull(parameterTypes, "parameterTypes"); + ArgumentNullException.ThrowIfNull(parameterTypes); return MakeDelegateType(returnType, parameterTypes.ToArray()); } @@ -506,7 +506,7 @@ public static Type MakeDelegateType(Type returnType, IEnumerable parameter /// A pair that contains return type as first element and parameter types as second arguments. public static Pair GetDelegateSignature(Type delegateType) { - ArgumentValidator.EnsureArgumentNotNull(delegateType, "delegateType"); + ArgumentNullException.ThrowIfNull(delegateType); // check for non-generic Action if (delegateType == ActionTypes[0]) return new Pair(WellKnownTypes.Void, Array.Empty()); diff --git a/Orm/Xtensive.Orm/Reflection/MethodHelper.cs b/Orm/Xtensive.Orm/Reflection/MethodHelper.cs index 80f11c60c..f81574312 100644 --- a/Orm/Xtensive.Orm/Reflection/MethodHelper.cs +++ b/Orm/Xtensive.Orm/Reflection/MethodHelper.cs @@ -44,7 +44,7 @@ public struct AnyArrayPlaceholder [CanBeNull] public static MethodInfo GetMethodEx(this Type type, string name, BindingFlags bindingFlags, string[] genericArgumentNames, object[] parameterTypes) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); if (genericArgumentNames == null) { @@ -105,7 +105,7 @@ public static MethodInfo GetMethodEx(this Type type, string name, BindingFlags b [CanBeNull] public static ConstructorInfo GetConstructorEx(this Type type, BindingFlags bindingFlags, object[] parameterTypes) { - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); if (parameterTypes == null) { parameterTypes = Array.Empty(); diff --git a/Orm/Xtensive.Orm/Reflection/TypeHelper.cs b/Orm/Xtensive.Orm/Reflection/TypeHelper.cs index 19e5d6ec5..17c63c7f7 100644 --- a/Orm/Xtensive.Orm/Reflection/TypeHelper.cs +++ b/Orm/Xtensive.Orm/Reflection/TypeHelper.cs @@ -163,7 +163,7 @@ public static T CreateAssociate(Type forType, out Type foundForType, string[] object[] constructorParams, IEnumerable> highPriorityLocations, bool exactTypeMatch) where T : class { - ArgumentValidator.EnsureArgumentNotNull(forType, nameof(forType)); + ArgumentNullException.ThrowIfNull(forType); if (forType.IsGenericTypeDefinition) { throw new InvalidOperationException(string.Format( Strings.ExCantCreateAssociateForGenericTypeDefinitions, GetShortName(forType))); @@ -423,8 +423,7 @@ private static T CreateAssociateInternal(Type originalForType, public static Type CreateDummyType(string namePrefix, Type inheritFrom, bool implementProtectedConstructorAccessor) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(namePrefix, nameof(namePrefix)); - ArgumentValidator.EnsureArgumentNotNull(inheritFrom, nameof(inheritFrom)); - + ArgumentNullException.ThrowIfNull(inheritFrom); var n = Interlocked.Increment(ref createDummyTypeNumber); var typeName = $"{TypeHelperNamespace}.Internal.{namePrefix}{n}"; @@ -444,7 +443,7 @@ public static Type CreateInheritedDummyType(string typeName, Type inheritFrom, bool implementProtectedConstructorAccessor) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(typeName, nameof(typeName)); - ArgumentValidator.EnsureArgumentNotNull(inheritFrom, nameof(inheritFrom)); + ArgumentNullException.ThrowIfNull(inheritFrom); EnsureEmitInitialized(); lock (EmitLock) { var typeBuilder = moduleBuilder.DefineType( @@ -550,7 +549,7 @@ public static string AddSuffix(string typeName, string suffix) public static object Activate(Assembly assembly, string typeName, Type[] genericArguments, params object[] arguments) { - ArgumentValidator.EnsureArgumentNotNull(assembly, nameof(assembly)); + ArgumentNullException.ThrowIfNull(assembly); ArgumentValidator.EnsureArgumentNotNullOrEmpty(typeName, nameof(typeName)); var type = assembly.GetType(typeName, false); return type == null ? null : Activate(type, genericArguments, arguments); @@ -1140,7 +1139,7 @@ public static Type GetGenericInterface(this Type type, Type openGenericInterface /// public static Type ToNullable(this Type type) { - ArgumentValidator.EnsureArgumentNotNull(type, nameof(type)); + ArgumentNullException.ThrowIfNull(type); return type.IsValueType && !type.IsNullable() ? WellKnownTypes.NullableOfT.CachedMakeGenericType(type) : type; @@ -1158,7 +1157,7 @@ public static Type ToNullable(this Type type) /// public static Type StripNullable(this Type type) { - ArgumentValidator.EnsureArgumentNotNull(type, nameof(type)); + ArgumentNullException.ThrowIfNull(type); return type.IsNullable() ? type.GetGenericArguments()[0] : type; @@ -1208,8 +1207,8 @@ public static bool IsClosure(this Type type) /// public static bool IsPublicNonAbstractInheritorOf(this Type type, Type baseType) { - ArgumentValidator.EnsureArgumentNotNull(type, nameof(type)); - ArgumentValidator.EnsureArgumentNotNull(baseType, nameof(baseType)); + ArgumentNullException.ThrowIfNull(type); + ArgumentNullException.ThrowIfNull(baseType); return type.IsPublic && !type.IsAbstract && baseType.IsAssignableFrom(type); } @@ -1223,7 +1222,7 @@ public static bool IsPublicNonAbstractInheritorOf(this Type type, Type baseType) /// public static bool IsNumericType(this Type type) { - ArgumentValidator.EnsureArgumentNotNull(type, nameof(type)); + ArgumentNullException.ThrowIfNull(type); var nonNullableType = type.StripNullable(); if (nonNullableType.IsEnum) { return false; diff --git a/Orm/Xtensive.Orm/Sorting/Node.cs b/Orm/Xtensive.Orm/Sorting/Node.cs index e07541db0..5158f3ac4 100644 --- a/Orm/Xtensive.Orm/Sorting/Node.cs +++ b/Orm/Xtensive.Orm/Sorting/Node.cs @@ -124,7 +124,7 @@ internal void RemoveIncomingConnection(NodeConnectionItem of connection. public NodeConnection AddConnection(Node node, TConnectionItem connectionItem) { - ArgumentValidator.EnsureArgumentNotNull(node, "node"); + ArgumentNullException.ThrowIfNull(node); var connection = new NodeConnection(this, node, connectionItem); connection.BindToNodes(); return connection; @@ -138,7 +138,6 @@ public NodeConnection AddConnection(NodeType of connection. public NodeConnection AddConnection(Node node, TConnectionItem connectionItem, ConnectionType connectionType) { - ArgumentValidator.EnsureArgumentNotNull(node, "node"); var connection = new NodeConnection(this, node, connectionItem, connectionType); connection.BindToNodes(); return connection; @@ -150,7 +149,7 @@ public NodeConnection AddConnection(NodePaired node. public IEnumerable> RemoveConnections(Node destination) { - ArgumentValidator.EnsureArgumentNotNull(destination, "destination"); + ArgumentNullException.ThrowIfNull(destination); if (outgoingConnections==null) return Enumerable.Empty>(); diff --git a/Orm/Xtensive.Orm/Sorting/NodeConnection.cs b/Orm/Xtensive.Orm/Sorting/NodeConnection.cs index a877b65e8..e362bd84f 100644 --- a/Orm/Xtensive.Orm/Sorting/NodeConnection.cs +++ b/Orm/Xtensive.Orm/Sorting/NodeConnection.cs @@ -80,11 +80,9 @@ public NodeConnection(Node source, NodeConnection type. public NodeConnection(Node source, Node destination, TConnectionItem connectionItem, ConnectionType connectionType) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(destination, "destination"); ConnectionItem = connectionItem; - Source = source; - Destination = destination; + Source = source ?? throw new ArgumentNullException(nameof(source)); + Destination = destination ?? throw new ArgumentNullException(nameof(destination)); ConnectionType = connectionType; } } diff --git a/Orm/Xtensive.Orm/Sorting/TopologicalSorter.cs b/Orm/Xtensive.Orm/Sorting/TopologicalSorter.cs index 282ee0354..1186be6ed 100644 --- a/Orm/Xtensive.Orm/Sorting/TopologicalSorter.cs +++ b/Orm/Xtensive.Orm/Sorting/TopologicalSorter.cs @@ -69,8 +69,8 @@ public static IEnumerable Sort( Predicate connector, out List> loops) { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); - ArgumentValidator.EnsureArgumentNotNull(connector, "connector"); + ArgumentNullException.ThrowIfNull(items); + ArgumentNullException.ThrowIfNull(connector); var nodes = GetNodes(items, connector); return Sort(nodes, out loops); } @@ -94,8 +94,8 @@ public static IReadOnlyList SortToList( Predicate connector, out List> loops) { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); - ArgumentValidator.EnsureArgumentNotNull(connector, "connector"); + ArgumentNullException.ThrowIfNull(items); + ArgumentNullException.ThrowIfNull(connector); var nodes = GetNodes(items, connector); return SortToList(nodes, out loops); } @@ -155,8 +155,8 @@ public static IEnumerable Sort( Predicate connector, out List> removedEdges, bool removeWholeNode) { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); - ArgumentValidator.EnsureArgumentNotNull(connector, "connector"); + ArgumentNullException.ThrowIfNull(items); + ArgumentNullException.ThrowIfNull(connector); var nodes = GetNodes(items, connector); return Sort(nodes, out removedEdges, removeWholeNode); } @@ -180,8 +180,8 @@ public static IReadOnlyList SortToList( Predicate connector, out List> removedEdges, bool removeWholeNode) { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); - ArgumentValidator.EnsureArgumentNotNull(connector, "connector"); + ArgumentNullException.ThrowIfNull(items); + ArgumentNullException.ThrowIfNull(connector); var nodes = GetNodes(items, connector); return SortToList(GetNodes(items, connector), out removedEdges, removeWholeNode); } @@ -296,7 +296,7 @@ public static IReadOnlyList SortToList( private static (IEnumerable sorted, int count) SortInternal( IEnumerable> nodes, out List> removedEdges, bool removeWholeNode) { - ArgumentValidator.EnsureArgumentNotNull(nodes, "nodes"); + ArgumentNullException.ThrowIfNull(nodes); var head = new Queue(); var tail = new Queue(); removedEdges = new List>(); @@ -364,7 +364,7 @@ private static (IEnumerable sorted, int count) SortInternalsorted, int count) SortInternal( List> nodes, out List> loops) { - ArgumentValidator.EnsureArgumentNotNull(nodes, "nodes"); + ArgumentNullException.ThrowIfNull(nodes); var head = new Queue(); var tail = new Queue(); var nodeList = nodes.ToList(); diff --git a/Orm/Xtensive.Orm/Sql/Compiler/SqlCompiler.cs b/Orm/Xtensive.Orm/Sql/Compiler/SqlCompiler.cs index 4e9f32eb6..09d2f9016 100644 --- a/Orm/Xtensive.Orm/Sql/Compiler/SqlCompiler.cs +++ b/Orm/Xtensive.Orm/Sql/Compiler/SqlCompiler.cs @@ -39,7 +39,7 @@ public class SqlCompiler : SqlDriverBound, /// public SqlCompilationResult Compile(ISqlCompileUnit unit, SqlCompilerConfiguration compilerConfiguration) { - ArgumentValidator.EnsureArgumentNotNull(unit, "unit"); + ArgumentNullException.ThrowIfNull(unit); configuration = compilerConfiguration; context = new SqlCompilerContext(configuration); unit.AcceptVisitor(this); @@ -521,7 +521,7 @@ public virtual void Visit(SqlCreateAssertion node) /// Statement to visit. public virtual void Visit(SqlCreateCharacterSet node) { - // ArgumentValidator.EnsureArgumentNotNull(node.CharacterSet.CharacterSetSource, "CharacterSetSource"); + // ArgumentNullException.ThrowIfNull(node.CharacterSet.CharacterSetSource, "CharacterSetSource"); // AppendTranslated(node); } @@ -531,7 +531,7 @@ public virtual void Visit(SqlCreateCharacterSet node) /// Statement to visit. public virtual void Visit(SqlCreateCollation node) { - // ArgumentValidator.EnsureArgumentNotNull(node.Collation.CharacterSet, "CharacterSet"); + // ArgumentNullException.ThrowIfNull(node.Collation.CharacterSet, "CharacterSet"); // AppendTranslated(node); } @@ -541,7 +541,7 @@ public virtual void Visit(SqlCreateCollation node) /// Statement to visit. public virtual void Visit(SqlCreateDomain node) { - ArgumentValidator.EnsureArgumentNotNull(node.Domain.DataType, "DataType"); + ArgumentNullException.ThrowIfNull(node.Domain.DataType, "node.Domain.DataType"); using (context.EnterScope(node)) { AppendTranslatedEntry(node); @@ -572,7 +572,7 @@ public virtual void Visit(SqlCreateDomain node) /// Statement to visit. public virtual void Visit(SqlCreateIndex node) { - ArgumentValidator.EnsureArgumentNotNull(node.Index.DataTable, "DataTable"); + ArgumentNullException.ThrowIfNull(node.Index.DataTable, "node.Index.DataTable"); AppendTranslatedEntry(node); if (node.Index.Columns.Count > 0) { @@ -639,7 +639,7 @@ public virtual void Visit(SqlCreateIndex node, IndexColumn item) /// Statement to visit. public virtual void Visit(SqlCreatePartitionFunction node) { - ArgumentValidator.EnsureArgumentNotNull(node.PartitionFunction.DataType, "DataType"); + ArgumentNullException.ThrowIfNull(node.PartitionFunction.DataType, "node.PartitionFunction.DataType"); translator.Translate(context, node); } @@ -649,7 +649,7 @@ public virtual void Visit(SqlCreatePartitionFunction node) /// Statement to visit. public virtual void Visit(SqlCreatePartitionScheme node) { - ArgumentValidator.EnsureArgumentNotNull(node.PartitionSchema.PartitionFunction, "PartitionFunction"); + ArgumentNullException.ThrowIfNull(node.PartitionSchema.PartitionFunction, "node.PartitionSchema.PartitionFunction"); translator.Translate(context, node); } @@ -752,7 +752,7 @@ public virtual void Visit(SqlCreateSchema node) /// Statement to visit. public virtual void Visit(SqlCreateSequence node) { - ArgumentValidator.EnsureArgumentNotNull(node.Sequence.SequenceDescriptor, "SequenceDescriptor"); + ArgumentNullException.ThrowIfNull(node.Sequence.SequenceDescriptor, "node.Sequence.SequenceDescriptor"); if (node.Sequence.SequenceDescriptor.Increment.HasValue && node.Sequence.SequenceDescriptor.Increment.Value == 0) { throw new SqlCompilerException(Strings.ExIncrementMustNotBeZero); @@ -879,9 +879,9 @@ protected virtual bool VisitCreateTableColumns(SqlCreateTable node, IEnumerable< /// Statement to visit. public virtual void Visit(SqlCreateTranslation node) { - // ArgumentValidator.EnsureArgumentNotNull(node.Translation.SourceCharacterSet, "SourceCharacterSet"); - // ArgumentValidator.EnsureArgumentNotNull(node.Translation.TargetCharacterSet, "TargetCharacterSet"); - // ArgumentValidator.EnsureArgumentNotNull(node.Translation.TranslationSource, "TranslationSource"); + // ArgumentNullException.ThrowIfNull(node.Translation.SourceCharacterSet, "SourceCharacterSet"); + // ArgumentNullException.ThrowIfNull(node.Translation.TargetCharacterSet, "TargetCharacterSet"); + // ArgumentNullException.ThrowIfNull(node.Translation.TranslationSource, "TranslationSource"); // AppendTranslated(node); } @@ -1063,7 +1063,7 @@ protected virtual void VisitDeleteLimit(SqlDelete node) /// Statement to visit. public virtual void Visit(SqlDropIndex node) { - ArgumentValidator.EnsureArgumentNotNull(node.Index.DataTable, "DataTable"); + ArgumentNullException.ThrowIfNull(node.Index.DataTable, "node.Index.DataTable"); translator.Translate(context, node); } @@ -2046,7 +2046,7 @@ public virtual void Visit(TableColumn column) AppendTranslated(column, TableColumnSection.Entry); if (column.Expression is null) { if (column.Domain == null) { - ArgumentValidator.EnsureArgumentNotNull(column.DataType, "DataType"); + ArgumentNullException.ThrowIfNull(column.DataType, "column.DataType"); } AppendTranslated(column, TableColumnSection.Type); diff --git a/Orm/Xtensive.Orm/Sql/Compiler/SqlPostCompilerConfiguration.cs b/Orm/Xtensive.Orm/Sql/Compiler/SqlPostCompilerConfiguration.cs index 8e4b3d181..534b07662 100644 --- a/Orm/Xtensive.Orm/Sql/Compiler/SqlPostCompilerConfiguration.cs +++ b/Orm/Xtensive.Orm/Sql/Compiler/SqlPostCompilerConfiguration.cs @@ -4,6 +4,7 @@ // Created by: Denis Krjuchkov // Created: 2009.11.07 +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using JetBrains.Annotations; @@ -44,11 +45,8 @@ public SqlPostCompilerConfiguration() public SqlPostCompilerConfiguration([NotNull] IReadOnlyDictionary databaseMapping, [NotNull] IReadOnlyDictionary schemaMapping) { - ArgumentValidator.EnsureArgumentNotNull(databaseMapping, "databaseMapping"); - ArgumentValidator.EnsureArgumentNotNull(schemaMapping, "schemaMapping"); - - DatabaseMapping = databaseMapping; - SchemaMapping = schemaMapping; + DatabaseMapping = databaseMapping ?? throw new ArgumentNullException(nameof(databaseMapping)); + SchemaMapping = schemaMapping ?? throw new ArgumentNullException(nameof(schemaMapping)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlColumnCollection.cs b/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlColumnCollection.cs index 17d856871..5692cb60c 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlColumnCollection.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlColumnCollection.cs @@ -74,7 +74,7 @@ public SqlColumn this[int index] /// is null. public void Add(SqlColumn column, string alias) { - ArgumentValidator.EnsureArgumentNotNull(alias, nameof(alias)); + ArgumentNullException.ThrowIfNull(alias); columnList.Add(SqlDml.ColumnRef(column, alias)); } @@ -92,7 +92,7 @@ public void Add(SqlExpression expression) => /// is . public void Add(SqlExpression expression, string alias) { - ArgumentValidator.EnsureArgumentNotNull(alias, nameof(alias)); + ArgumentNullException.ThrowIfNull(alias); columnList.Add(SqlDml.ColumnRef(SqlDml.Column(expression), alias)); } @@ -105,7 +105,7 @@ public void Add(SqlExpression expression, string alias) /// -or- is greater than . public void Insert(int index, SqlExpression expression, string alias) { - ArgumentValidator.EnsureArgumentNotNull(alias, nameof(alias)); + ArgumentNullException.ThrowIfNull(alias); columnList.Insert(index, SqlDml.ColumnRef(SqlDml.Column(expression), alias)); } @@ -115,7 +115,7 @@ public void Insert(int index, SqlExpression expression, string alias) /// Columns to be added. public void AddRange(params SqlColumn[] columns) { - ArgumentValidator.EnsureArgumentNotNull(columns, nameof(columns)); + ArgumentNullException.ThrowIfNull(columns); columnList.AddRange(columns); } diff --git a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCase.cs b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCase.cs index d1bf306a1..1f2908139 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCase.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCase.cs @@ -18,8 +18,8 @@ public class SqlCase: SqlExpression, IEnumerable(key, value)); return this; } @@ -66,8 +66,8 @@ public SqlExpression this[SqlExpression key] } set { - ArgumentValidator.EnsureArgumentNotNull(key, "key"); - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(key); + ArgumentNullException.ThrowIfNull(value); int index = IndexOf(key); KeyValuePair @case = new KeyValuePair(key, value); if (index >= 0) diff --git a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCursor.cs b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCursor.cs index cd1b59c6b..876510823 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCursor.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCursor.cs @@ -59,7 +59,7 @@ public ISqlQueryExpression Query get { return query; } set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); query = value; } } @@ -133,7 +133,7 @@ public SqlFetch Fetch(SqlFetchOption option, SqlExpression rowCount, params ISql throw new ArgumentException(Strings.ExInvalidUsageOfTheOrientationArgument, "option"); if (target != null) for (int i = 0, l = target.Length; i < l; i++) - ArgumentValidator.EnsureArgumentNotNull(target[i], "target"); + ArgumentNullException.ThrowIfNull(target[i], "target"); return new SqlFetch(option, rowCount, this, target); } diff --git a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCustomFunctionCall.cs b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCustomFunctionCall.cs index f7bc62f71..6eb3c6808 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCustomFunctionCall.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCustomFunctionCall.cs @@ -22,7 +22,7 @@ public class SqlCustomFunctionCall : SqlFunctionCallBase public override void ReplaceWith(SqlExpression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); var replacingExpression = ArgumentValidator.EnsureArgumentIs(expression); FunctionType = replacingExpression.FunctionType; Arguments = replacingExpression.Arguments; diff --git a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlDefaultValue.cs b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlDefaultValue.cs index b95b79dbf..a575d9d5e 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlDefaultValue.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlDefaultValue.cs @@ -12,7 +12,7 @@ public class SqlDefaultValue : SqlExpression { public override void ReplaceWith(SqlExpression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); ArgumentValidator.EnsureArgumentIs(expression); } diff --git a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlExpression.cs b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlExpression.cs index 1c041a8ca..a205dcf7a 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlExpression.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlExpression.cs @@ -196,7 +196,7 @@ public static implicit operator SqlExpression(decimal value) public static implicit operator SqlExpression(string value) { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); return new SqlLiteral(value); } diff --git a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlExpressionList.cs b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlExpressionList.cs index 16ae8026b..38fc046fa 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlExpressionList.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlExpressionList.cs @@ -4,6 +4,7 @@ // Created by: Dmitri Maximov // Created: 2009.09.01 +using System; using System.Collections; using System.Collections.Generic; using Xtensive.Core; @@ -20,7 +21,7 @@ public SqlExpression this[int index] get { return expressions[index]; } set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); expressions[index] = value; } } @@ -40,7 +41,7 @@ public bool IsReadOnly /// public void Add(SqlExpression item) { - ArgumentValidator.EnsureArgumentNotNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); expressions.Add(item); } diff --git a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlTableColumn.cs b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlTableColumn.cs index d6e16595a..758cf8f24 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlTableColumn.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlTableColumn.cs @@ -17,8 +17,8 @@ public class SqlTableColumn : SqlColumn, ISqlLValue public override void ReplaceWith(SqlExpression expression) { var replacingExpression = (SqlColumn) expression; - ArgumentValidator.EnsureArgumentNotNull(replacingExpression.SqlTable, "SqlTable"); - ArgumentValidator.EnsureArgumentNotNull(replacingExpression.Name, "Name"); + ArgumentNullException.ThrowIfNull(replacingExpression.SqlTable, "SqlTable"); + ArgumentNullException.ThrowIfNull(replacingExpression.Name, "Name"); base.ReplaceWith(expression); } diff --git a/Orm/Xtensive.Orm/Sql/Dml/SqlCustomFunctionType.cs b/Orm/Xtensive.Orm/Sql/Dml/SqlCustomFunctionType.cs index 5f2798c77..a2d26d7db 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/SqlCustomFunctionType.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/SqlCustomFunctionType.cs @@ -61,9 +61,7 @@ public override int GetHashCode() public SqlCustomFunctionType(string name) { - ArgumentValidator.EnsureArgumentNotNull(name, "name"); - - Name = name; + Name = name ?? throw new ArgumentNullException(nameof(name)); } } } diff --git a/Orm/Xtensive.Orm/Sql/Dml/Statements/SqlIf.cs b/Orm/Xtensive.Orm/Sql/Dml/Statements/SqlIf.cs index d93947481..2369cb1ea 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Statements/SqlIf.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Statements/SqlIf.cs @@ -25,7 +25,7 @@ public SqlExpression Condition { return condition; } set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); SqlValidator.EnsureIsBooleanExpression(value); condition = value; } @@ -39,7 +39,7 @@ public SqlStatement True { return trueStatement; } set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); trueStatement = value; } } diff --git a/Orm/Xtensive.Orm/Sql/Dml/Statements/SqlWhile.cs b/Orm/Xtensive.Orm/Sql/Dml/Statements/SqlWhile.cs index d571ce5f1..617f6d050 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Statements/SqlWhile.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Statements/SqlWhile.cs @@ -37,7 +37,7 @@ public SqlExpression Condition { return condition; } set { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); SqlValidator.EnsureIsBooleanExpression(value); condition = value; } diff --git a/Orm/Xtensive.Orm/Sql/Info/DataTypeInfo.cs b/Orm/Xtensive.Orm/Sql/Info/DataTypeInfo.cs index 23cacaa9c..95d56ef8e 100644 --- a/Orm/Xtensive.Orm/Sql/Info/DataTypeInfo.cs +++ b/Orm/Xtensive.Orm/Sql/Info/DataTypeInfo.cs @@ -61,7 +61,7 @@ public static DataTypeInfo Fractional( int maxPrecision, params string[] nativeTypes) { - ArgumentValidator.EnsureArgumentNotNull(valueRange, "valueRange"); + ArgumentNullException.ThrowIfNull(valueRange); ArgumentValidator.EnsureArgumentIsGreaterThan(maxPrecision, 0, "maxPrecision"); return new DataTypeInfo { @@ -82,7 +82,7 @@ public static DataTypeInfo Range( ValueRange valueRange, params string[] nativeTypes) { - ArgumentValidator.EnsureArgumentNotNull(valueRange, "valueRange"); + ArgumentNullException.ThrowIfNull(valueRange); return new DataTypeInfo { Type = sqlType, diff --git a/Orm/Xtensive.Orm/Sql/Info/ServerInfo.cs b/Orm/Xtensive.Orm/Sql/Info/ServerInfo.cs index e2ecddae2..45a9ee190 100644 --- a/Orm/Xtensive.Orm/Sql/Info/ServerInfo.cs +++ b/Orm/Xtensive.Orm/Sql/Info/ServerInfo.cs @@ -2,6 +2,7 @@ // All rights reserved. // For conditions of distribution and use, see license. +using System; using Xtensive.Core; namespace Xtensive.Sql.Info @@ -169,7 +170,7 @@ public class ServerInfo : LockableBase /// The provider. public static ServerInfo Build(ServerInfoProvider provider) { - ArgumentValidator.EnsureArgumentNotNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(provider); var info = new ServerInfo { Assertion = provider.GetAssertionInfo(), CharacterSet = provider.GetCharacterSetInfo(), diff --git a/Orm/Xtensive.Orm/Sql/Internals/SqlValidator.cs b/Orm/Xtensive.Orm/Sql/Internals/SqlValidator.cs index a42e9cbad..3d0405597 100644 --- a/Orm/Xtensive.Orm/Sql/Internals/SqlValidator.cs +++ b/Orm/Xtensive.Orm/Sql/Internals/SqlValidator.cs @@ -39,9 +39,9 @@ internal static class SqlValidator public static void EnsureAreSqlRowArguments(IEnumerable nodes) { - ArgumentValidator.EnsureArgumentNotNull(nodes, "expressions"); + ArgumentNullException.ThrowIfNull(nodes); foreach (SqlExpression expression in nodes) - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); } public static void EnsureIsBooleanExpression(SqlExpression node) @@ -58,7 +58,7 @@ public static void EnsureIsCharacterExpression(SqlExpression node) public static void EnsureIsRowValueConstructor(SqlExpression node) { - ArgumentValidator.EnsureArgumentNotNull(node, "expression"); + ArgumentNullException.ThrowIfNull(node); if (!(IsArithmeticExpression(node) || node is SqlRow || node is SqlSubQuery)) throw new ArgumentException(Strings.ExInvalidExpressionType); } @@ -71,14 +71,14 @@ public static void EnsureIsArithmeticExpression(SqlExpression node) public static void EnsureIsSubSelect(SqlExpression node) { - ArgumentValidator.EnsureArgumentNotNull(node, "expression"); + ArgumentNullException.ThrowIfNull(node); if (!(node is SqlSubQuery)) throw new ArgumentException(Strings.ExInvalidExpressionType); } public static void EnsureIsLimitOffsetArgument(SqlExpression node) { - ArgumentValidator.EnsureArgumentNotNull(node, "node"); + ArgumentNullException.ThrowIfNull(node); if (!IsLimitOffsetArgument(node)) throw new InvalidOperationException(Strings.ExOnlySqlLiteralOrSqlPlaceholderCanBeUsedInLimitOffset); } diff --git a/Orm/Xtensive.Orm/Sql/Model/Catalog.cs b/Orm/Xtensive.Orm/Sql/Model/Catalog.cs index c3c66c4b8..c81feb7dd 100644 --- a/Orm/Xtensive.Orm/Sql/Model/Catalog.cs +++ b/Orm/Xtensive.Orm/Sql/Model/Catalog.cs @@ -164,8 +164,8 @@ internal string GetActualName(IReadOnlyDictionary catalogNameMap { if (!IsNamesReadingDenied) return Name; - if (catalogNameMap==null) - throw new ArgumentNullException("catalogNameMap"); + + ArgumentNullException.ThrowIfNull(catalogNameMap); var name = GetNameInternal(); return catalogNameMap.TryGetValue(name, out var actualName) ? actualName : name; diff --git a/Orm/Xtensive.Orm/Sql/Model/CatalogNode.cs b/Orm/Xtensive.Orm/Sql/Model/CatalogNode.cs index e3e1e3ac8..8d0f58cb1 100644 --- a/Orm/Xtensive.Orm/Sql/Model/CatalogNode.cs +++ b/Orm/Xtensive.Orm/Sql/Model/CatalogNode.cs @@ -94,8 +94,8 @@ internal string GetActualName(IReadOnlyDictionary nodeNameMap) { if (!IsNamesReadingDenied) return Name; - if (nodeNameMap==null) - throw new ArgumentNullException("nodeNameMap"); + + ArgumentNullException.ThrowIfNull(nodeNameMap); var name = GetNameInternal(); string actualName; @@ -108,8 +108,8 @@ internal string GetActualDbName(IReadOnlyDictionary nodeNameMap) { if (!IsNamesReadingDenied) return DbName; - if (nodeNameMap==null) - throw new ArgumentNullException("nodeNameMap"); + + ArgumentNullException.ThrowIfNull(nodeNameMap); var name = GetDbNameInternal(); if (nodeNameMap.TryGetValue(name, out var actualName)) @@ -127,8 +127,7 @@ internal string GetActualDbName(IReadOnlyDictionary nodeNameMap) protected CatalogNode(Catalog catalog, string name) : base(name) { - ArgumentValidator.EnsureArgumentNotNull(catalog, "catalog"); - Catalog = catalog; + Catalog = catalog ?? throw new ArgumentNullException(nameof(catalog)); } #endregion diff --git a/Orm/Xtensive.Orm/Sql/Model/Constraints/DefaultConstraint.cs b/Orm/Xtensive.Orm/Sql/Model/Constraints/DefaultConstraint.cs index d866545bc..d26ac4684 100644 --- a/Orm/Xtensive.Orm/Sql/Model/Constraints/DefaultConstraint.cs +++ b/Orm/Xtensive.Orm/Sql/Model/Constraints/DefaultConstraint.cs @@ -30,8 +30,7 @@ public sealed class DefaultConstraint : TableConstraint internal DefaultConstraint(Table table, string name, TableColumn column) : base(table, name) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); - Column = column; + Column = column ?? throw new ArgumentNullException(nameof(column)); NameIsStale = false; } } diff --git a/Orm/Xtensive.Orm/Sql/Model/DataTableNode.cs b/Orm/Xtensive.Orm/Sql/Model/DataTableNode.cs index f2989807f..f6595ab3c 100644 --- a/Orm/Xtensive.Orm/Sql/Model/DataTableNode.cs +++ b/Orm/Xtensive.Orm/Sql/Model/DataTableNode.cs @@ -62,8 +62,7 @@ void IPairedNode.UpdatePairedProperty(string property, DataTable valu /// The name. protected DataTableNode(DataTable dataTable, string name) : base(name) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); - DataTable = dataTable; + DataTable = dataTable ?? throw new ArgumentNullException(nameof(dataTable)); } #endregion diff --git a/Orm/Xtensive.Orm/Sql/Model/FullTextIndex.cs b/Orm/Xtensive.Orm/Sql/Model/FullTextIndex.cs index 4cc843da5..968e04aa5 100644 --- a/Orm/Xtensive.Orm/Sql/Model/FullTextIndex.cs +++ b/Orm/Xtensive.Orm/Sql/Model/FullTextIndex.cs @@ -68,7 +68,7 @@ public string UnderlyingUniqueIndex /// Newly created object. public new IndexColumn CreateIndexColumn(DataTableColumn column) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); + ArgumentNullException.ThrowIfNull(column); return new IndexColumn(this, column, true); } diff --git a/Orm/Xtensive.Orm/Sql/Model/Index.cs b/Orm/Xtensive.Orm/Sql/Model/Index.cs index 8731bc024..b52b98f50 100644 --- a/Orm/Xtensive.Orm/Sql/Model/Index.cs +++ b/Orm/Xtensive.Orm/Sql/Model/Index.cs @@ -40,7 +40,7 @@ public IndexColumn CreateIndexColumn(DataTableColumn column) /// The sort direction. public IndexColumn CreateIndexColumn(DataTableColumn column, bool ascending) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); + ArgumentNullException.ThrowIfNull(column); return new IndexColumn(this, column, ascending); } @@ -63,9 +63,9 @@ public IndexColumn CreateIndexColumn(SqlExpression expression) /// instance. public IndexColumn CreateIndexColumn(SqlExpression expression, bool ascending) { - if (expression is null) - throw new ArgumentNullException("expression"); - return new IndexColumn(this, expression, ascending); + return new IndexColumn(this, + expression ?? throw new ArgumentNullException(nameof(expression)), + ascending); } /// diff --git a/Orm/Xtensive.Orm/Sql/Model/PairedNodeCollection.cs b/Orm/Xtensive.Orm/Sql/Model/PairedNodeCollection.cs index 80dd0fa13..37f885f1f 100644 --- a/Orm/Xtensive.Orm/Sql/Model/PairedNodeCollection.cs +++ b/Orm/Xtensive.Orm/Sql/Model/PairedNodeCollection.cs @@ -86,9 +86,8 @@ public PairedNodeCollection(TOwner owner, string property) public PairedNodeCollection(TOwner owner, string property, int capacity) : base(capacity) { - ArgumentValidator.EnsureArgumentNotNull(owner, "owner"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(property, "property"); - this.owner = owner; + ArgumentValidator.EnsureArgumentNotNullOrEmpty(property, nameof(property)); + this.owner = owner ?? throw new ArgumentNullException(nameof(owner)); this.property = property; } @@ -102,11 +101,10 @@ public PairedNodeCollection(TOwner owner, string property, int capacity) public PairedNodeCollection(TOwner owner, string property, int capacity, IEqualityComparer equalityComparer) : base(capacity, equalityComparer) { - ArgumentValidator.EnsureArgumentNotNull(owner, nameof(owner)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(property, nameof(property)); - ArgumentValidator.EnsureArgumentNotNull(equalityComparer, nameof(equalityComparer)); + ArgumentNullException.ThrowIfNull(equalityComparer); - this.owner = owner; + this.owner = owner ?? throw new ArgumentNullException(nameof(owner)); this.property = property; } diff --git a/Orm/Xtensive.Orm/Sql/Model/SchemaNode.cs b/Orm/Xtensive.Orm/Sql/Model/SchemaNode.cs index 497d81cf6..f7d349c3d 100644 --- a/Orm/Xtensive.Orm/Sql/Model/SchemaNode.cs +++ b/Orm/Xtensive.Orm/Sql/Model/SchemaNode.cs @@ -58,8 +58,7 @@ void IPairedNode.UpdatePairedProperty(string property, Schema value) /// The name. protected SchemaNode(Schema schema, string name) : base(name) { - ArgumentValidator.EnsureArgumentNotNull(schema, "schema"); - Schema = schema; + Schema = schema ?? throw new ArgumentNullException(nameof(schema)); } #endregion diff --git a/Orm/Xtensive.Orm/Sql/Model/Sequence.cs b/Orm/Xtensive.Orm/Sql/Model/Sequence.cs index 3dcecaf34..dc87d2c12 100644 --- a/Orm/Xtensive.Orm/Sql/Model/Sequence.cs +++ b/Orm/Xtensive.Orm/Sql/Model/Sequence.cs @@ -24,8 +24,8 @@ public SequenceDescriptor SequenceDescriptor get { return sequenceDescriptor; } set { EnsureNotLocked(); - ArgumentValidator.EnsureArgumentNotNull(value, "value"); - sequenceDescriptor = value; + ArgumentNullException.ThrowIfNull(value); + SequenceDescriptor old = sequenceDescriptor; sequenceDescriptor = value; if (old!=null && old.Owner==this) diff --git a/Orm/Xtensive.Orm/Sql/SqlConnection.cs b/Orm/Xtensive.Orm/Sql/SqlConnection.cs index b1f0c9b3b..4a5860724 100644 --- a/Orm/Xtensive.Orm/Sql/SqlConnection.cs +++ b/Orm/Xtensive.Orm/Sql/SqlConnection.cs @@ -56,7 +56,7 @@ public ConnectionInfo ConnectionInfo { get => connectionInfo; set { - ArgumentValidator.EnsureArgumentNotNull(value, nameof(value)); + ArgumentNullException.ThrowIfNull(value); EnsureIsNotDisposed(); UnderlyingConnection.ConnectionString = Driver.GetConnectionString(value); @@ -109,7 +109,7 @@ public DbCommand CreateCommand() /// Created command. public DbCommand CreateCommand(ISqlCompileUnit statement) { - ArgumentValidator.EnsureArgumentNotNull(statement, nameof(statement)); + ArgumentNullException.ThrowIfNull(statement); EnsureIsNotDisposed(); var command = CreateCommand(); diff --git a/Orm/Xtensive.Orm/Sql/SqlDdl.cs b/Orm/Xtensive.Orm/Sql/SqlDdl.cs index 2a0351f11..3bc4ba52f 100644 --- a/Orm/Xtensive.Orm/Sql/SqlDdl.cs +++ b/Orm/Xtensive.Orm/Sql/SqlDdl.cs @@ -20,289 +20,293 @@ public static class SqlDdl { public static SqlCreateAssertion Create(Assertion assertion) { - ArgumentValidator.EnsureArgumentNotNull(assertion, "assertion"); + ArgumentNullException.ThrowIfNull(assertion); return new SqlCreateAssertion(assertion); } public static SqlCreateCharacterSet Create(CharacterSet characterSet) { - ArgumentValidator.EnsureArgumentNotNull(characterSet, "characterSet"); + ArgumentNullException.ThrowIfNull(characterSet); return new SqlCreateCharacterSet(characterSet); } public static SqlCreateCollation Create(Collation collation) { - ArgumentValidator.EnsureArgumentNotNull(collation, "collation"); + ArgumentNullException.ThrowIfNull(collation); return new SqlCreateCollation(collation); } public static SqlCreateDomain Create(Domain domain) { - ArgumentValidator.EnsureArgumentNotNull(domain, "domain"); + ArgumentNullException.ThrowIfNull(domain); return new SqlCreateDomain(domain); } public static SqlCreateIndex Create(Index index) { - ArgumentValidator.EnsureArgumentNotNull(index, "index"); + ArgumentNullException.ThrowIfNull(index); return new SqlCreateIndex(index); } public static SqlCreatePartitionFunction Create(PartitionFunction partitionFunction) { - ArgumentValidator.EnsureArgumentNotNull(partitionFunction, "partitionFunction"); + ArgumentNullException.ThrowIfNull(partitionFunction); return new SqlCreatePartitionFunction(partitionFunction); } public static SqlCreatePartitionScheme Create(PartitionSchema partitionSchema) { - ArgumentValidator.EnsureArgumentNotNull(partitionSchema, "partitionSchema"); + ArgumentNullException.ThrowIfNull(partitionSchema); return new SqlCreatePartitionScheme(partitionSchema); } public static SqlCreateSchema Create(Schema schema) { - ArgumentValidator.EnsureArgumentNotNull(schema, "schema"); + ArgumentNullException.ThrowIfNull(schema); return new SqlCreateSchema(schema); } public static SqlCreateSequence Create(Sequence sequence) { - ArgumentValidator.EnsureArgumentNotNull(sequence, "sequence"); + ArgumentNullException.ThrowIfNull(sequence); return new SqlCreateSequence(sequence); } public static SqlCreateTable Create(Table table) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); + ArgumentNullException.ThrowIfNull(table); return new SqlCreateTable(table); } public static SqlCreateTranslation Create(Translation translation) { - ArgumentValidator.EnsureArgumentNotNull(translation, "translation"); + ArgumentNullException.ThrowIfNull(translation); return new SqlCreateTranslation(translation); } public static SqlCreateView Create(View view) { - ArgumentValidator.EnsureArgumentNotNull(view, "view"); + ArgumentNullException.ThrowIfNull(view); return new SqlCreateView(view); } public static SqlDropAssertion Drop(Assertion assertion) { - ArgumentValidator.EnsureArgumentNotNull(assertion, "assertion"); + ArgumentNullException.ThrowIfNull(assertion); return new SqlDropAssertion(assertion); } public static SqlDropCharacterSet Drop(CharacterSet characterSet) { - ArgumentValidator.EnsureArgumentNotNull(characterSet, "characterSet"); + ArgumentNullException.ThrowIfNull(characterSet); return new SqlDropCharacterSet(characterSet); } public static SqlDropCollation Drop(Collation collation) { - ArgumentValidator.EnsureArgumentNotNull(collation, "collation"); + ArgumentNullException.ThrowIfNull(collation); return new SqlDropCollation(collation); } public static SqlDropDomain Drop(Domain domain) { - ArgumentValidator.EnsureArgumentNotNull(domain, "domain"); + ArgumentNullException.ThrowIfNull(domain); return new SqlDropDomain(domain); } public static SqlDropIndex Drop(Index index) { - ArgumentValidator.EnsureArgumentNotNull(index, "index"); + ArgumentNullException.ThrowIfNull(index); return new SqlDropIndex(index); } //public static SqlDropIndex Drop(IIndex index, bool? online) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, online, null); //} //public static SqlDropIndex Drop(IIndex index, byte? maxDegreeOfParallelism) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, null, maxDegreeOfParallelism); //} //public static SqlDropIndex Drop(IIndex index, bool? online, byte? maxDegreeOfParallelism) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, online, maxDegreeOfParallelism); //} //public static SqlDropIndex Drop(IIndex index, bool? online, byte? maxDegreeOfParallelism, IPartitionDescriptor partitioningDescriptor) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, online, maxDegreeOfParallelism, partitioningDescriptor); //} //public static SqlDropIndex Drop(IIndex index, bool? online, byte? maxDegreeOfParallelism, string tableSpace) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, online, maxDegreeOfParallelism, tableSpace); //} //public static SqlDropIndex Drop(IIndex index, byte? maxDegreeOfParallelism, IPartitionDescriptor partitioningDescriptor) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, null, maxDegreeOfParallelism, partitioningDescriptor); //} //public static SqlDropIndex Drop(IIndex index, byte? maxDegreeOfParallelism, string tableSpace) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, null, maxDegreeOfParallelism, tableSpace); //} //public static SqlDropIndex Drop(IIndex index, bool? online, IPartitionDescriptor partitioningDescriptor) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, online, null, partitioningDescriptor); //} //public static SqlDropIndex Drop(IIndex index, bool? online, string tableSpace) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, online, null, tableSpace); //} //public static SqlDropIndex Drop(IIndex index, IPartitionDescriptor partitioningDescriptor) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, null, null, partitioningDescriptor); //} //public static SqlDropIndex Drop(IIndex index, string tableSpace) //{ - // ArgumentValidator.EnsureArgumentNotNull(index, "index"); + // ArgumentNullException.ThrowIfNull(index, "index"); // return new SqlDropIndex(index, null, null, tableSpace); //} public static SqlDropPartitionFunction Drop(PartitionFunction partitionFunction) { - ArgumentValidator.EnsureArgumentNotNull(partitionFunction, "partitionFunction"); + ArgumentNullException.ThrowIfNull(partitionFunction); return new SqlDropPartitionFunction(partitionFunction); } public static SqlDropPartitionScheme Drop(PartitionSchema partitionSchema) { - ArgumentValidator.EnsureArgumentNotNull(partitionSchema, "partitionSchema"); + ArgumentNullException.ThrowIfNull(partitionSchema); return new SqlDropPartitionScheme(partitionSchema); } public static SqlDropDomain Drop(Domain domain, bool cascade) { - ArgumentValidator.EnsureArgumentNotNull(domain, "domain"); + ArgumentNullException.ThrowIfNull(domain); return new SqlDropDomain(domain, cascade); } public static SqlDropSchema Drop(Schema schema) { - ArgumentValidator.EnsureArgumentNotNull(schema, "schema"); + ArgumentNullException.ThrowIfNull(schema); return new SqlDropSchema(schema); } public static SqlDropSchema Drop(Schema schema, bool cascade) { - ArgumentValidator.EnsureArgumentNotNull(schema, "schema"); + ArgumentNullException.ThrowIfNull(schema); return new SqlDropSchema(schema, cascade); } public static SqlDropSequence Drop(Sequence sequence) { - ArgumentValidator.EnsureArgumentNotNull(sequence, "sequence"); + ArgumentNullException.ThrowIfNull(sequence); return new SqlDropSequence(sequence); } public static SqlDropSequence Drop(Sequence sequence, bool cascade) { - ArgumentValidator.EnsureArgumentNotNull(sequence, "sequence"); + ArgumentNullException.ThrowIfNull(sequence); return new SqlDropSequence(sequence, cascade); } public static SqlDropTable Drop(Table table) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); + ArgumentNullException.ThrowIfNull(table); return new SqlDropTable(table); } public static SqlDropTable Drop(Table table, bool cascade) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); + ArgumentNullException.ThrowIfNull(table); return new SqlDropTable(table, cascade); } public static SqlDropTranslation Drop(Translation translation) { - ArgumentValidator.EnsureArgumentNotNull(translation, "translation"); + ArgumentNullException.ThrowIfNull(translation); return new SqlDropTranslation(translation); } public static SqlDropView Drop(View view) { - ArgumentValidator.EnsureArgumentNotNull(view, "view"); + ArgumentNullException.ThrowIfNull(view); return new SqlDropView(view); } public static SqlDropView Drop(View view, bool cascade) { - ArgumentValidator.EnsureArgumentNotNull(view, "view"); + ArgumentNullException.ThrowIfNull(view); return new SqlDropView(view, cascade); } public static SqlTruncateTable Truncate(Table table) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); + ArgumentNullException.ThrowIfNull(table); return new SqlTruncateTable(table); } public static SqlAlterTable Alter(Table table, SqlAction action) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); - ArgumentValidator.EnsureArgumentNotNull(action, "action"); - if (action is SqlSetDefault && ((SqlSetDefault)action).Column==null || - action is SqlDropDefault && ((SqlDropDefault)action).Column==null) - throw new ArgumentException(Strings.ExInvalidActionType, "action"); - if (action is SqlAddColumn && ((SqlAddColumn)action).Column.DataTable!=null && - ((SqlAddColumn)action).Column.DataTable!=table || - action is SqlSetDefault && ((SqlSetDefault)action).Column.DataTable!=null && - ((SqlSetDefault)action).Column.DataTable!=table || - action is SqlDropDefault && ((SqlDropDefault)action).Column.DataTable!=null && - ((SqlDropDefault)action).Column.DataTable!=table || - action is SqlDropColumn && ((SqlDropColumn)action).Column.DataTable!=null && - ((SqlDropColumn)action).Column.DataTable!=table || - action is SqlAlterIdentityInfo && ((SqlAlterIdentityInfo)action).Column.DataTable!=null && - ((SqlAlterIdentityInfo)action).Column.DataTable!=table) - throw new ArgumentException(Strings.ExColumnBelongsToOtherTable, "action"); - else if (action is SqlAddConstraint) { - var constraint = ((SqlAddConstraint) action).Constraint as TableConstraint; - if (constraint==null) - throw new ArgumentException(Strings.ExInvalidConstraintType, "action"); - else if (constraint.Table!=null && constraint.Table!=table) - throw new ArgumentException(Strings.ExConstraintBelongsToOtherTable, "action"); - } - else if (action is SqlDropConstraint) { - var constraint = ((SqlDropConstraint) action).Constraint as TableConstraint; - if (constraint==null) - throw new ArgumentException(Strings.ExInvalidConstraintType, "action"); - else if (constraint.Table!=null && constraint.Table!=table) - throw new ArgumentException(Strings.ExConstraintBelongsToOtherTable, "action"); + ArgumentNullException.ThrowIfNull(table); + ArgumentNullException.ThrowIfNull(action); + + switch (action) { + case SqlSetDefault setDefaultAction2 when setDefaultAction2.Column is null: + throw new ArgumentException(Strings.ExInvalidActionType, nameof(action)); + case SqlSetDefault setDefaultAction2 when setDefaultAction2.Column.DataTable!=table: + throw new ArgumentException(Strings.ExColumnBelongsToOtherTable, nameof(action)); + case SqlDropDefault dropDefaultAction2 when dropDefaultAction2.Column is null: + throw new ArgumentException(Strings.ExInvalidActionType, nameof(action)); + case SqlDropDefault dropDefaultAction2 when dropDefaultAction2.Column.DataTable!=table: + throw new ArgumentException(Strings.ExColumnBelongsToOtherTable, nameof(action)); + case SqlAddColumn addColumnAction2 when addColumnAction2.Column.DataTable != table: + throw new ArgumentException(Strings.ExColumnBelongsToOtherTable, nameof(action)); + case SqlDropColumn dropColumnAction2 when dropColumnAction2.Column.DataTable != table : + throw new ArgumentException(Strings.ExColumnBelongsToOtherTable, nameof(action)); + case SqlAlterIdentityInfo alterIdentityAction2 when alterIdentityAction2.Column.DataTable != table: + throw new ArgumentException(Strings.ExColumnBelongsToOtherTable, nameof(action)); + case SqlAddConstraint addConstraint2: { + if (addConstraint2.Constraint is not TableConstraint tConstraint) + throw new ArgumentException(Strings.ExInvalidConstraintType, nameof(action)); + else if (tConstraint.Table != null && tConstraint.Table != table) + throw new ArgumentException(Strings.ExConstraintBelongsToOtherTable, nameof(action)); + break; + } + case SqlDropConstraint dropConstraint2: { + if (dropConstraint2.Constraint is not TableConstraint tConstraint) + throw new ArgumentException(Strings.ExInvalidConstraintType, nameof(action)); + else if (tConstraint.Table != null && tConstraint.Table != table) + throw new ArgumentException(Strings.ExConstraintBelongsToOtherTable, nameof(action)); + break; + } + } return new SqlAlterTable(table, action); } public static SqlRenameTable Rename(Table table, string newName) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(newName, "newName"); + ArgumentNullException.ThrowIfNull(table); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(newName, nameof(newName)); if (table.Name==newName) throw new ArgumentException(Strings.ExTableAlreadyHasSpecifiedName); return new SqlRenameTable(table, newName); @@ -310,8 +314,8 @@ public static SqlRenameTable Rename(Table table, string newName) public static SqlAlterTable Rename(TableColumn column, string newName) { - ArgumentValidator.EnsureArgumentNotNull(column, "table"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(newName, "newName"); + ArgumentNullException.ThrowIfNull(column); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(newName, nameof(newName)); if (column.Name==newName) throw new ArgumentException(Strings.ExColumnAlreadyHasSpecifiedName); return Alter(column.Table, new SqlRenameColumn(column, newName)); @@ -319,118 +323,116 @@ public static SqlAlterTable Rename(TableColumn column, string newName) public static SqlAlterSequence Alter(Sequence sequence, SequenceDescriptor descriptor, SqlAlterIdentityInfoOptions infoOption) { - ArgumentValidator.EnsureArgumentNotNull(sequence, "sequence"); - ArgumentValidator.EnsureArgumentNotNull(descriptor, "info"); + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(descriptor); return new SqlAlterSequence(sequence, descriptor, infoOption); } public static SqlAlterSequence Alter(Sequence sequence, SequenceDescriptor descriptor) { - ArgumentValidator.EnsureArgumentNotNull(sequence, "sequence"); - ArgumentValidator.EnsureArgumentNotNull(descriptor, "info"); + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(descriptor); return new SqlAlterSequence(sequence, descriptor, SqlAlterIdentityInfoOptions.All); } public static SqlAlterDomain Alter(Domain domain, SqlAction action) { - ArgumentValidator.EnsureArgumentNotNull(domain, "domain"); - ArgumentValidator.EnsureArgumentNotNull(action, "action"); - if (action is SqlAddConstraint) { - DomainConstraint constraint = ((SqlAddConstraint)action).Constraint as DomainConstraint; - if (constraint==null) - throw new ArgumentException(Strings.ExInvalidConstraintType, "action"); - else if (constraint.Domain!=null && constraint.Domain!=domain) - throw new ArgumentException(Strings.ExConstraintBelongsToOtherDomain, "action"); + ArgumentNullException.ThrowIfNull(domain); + ArgumentNullException.ThrowIfNull(action); + if (action is SqlAddConstraint addConstraint) { + if (addConstraint.Constraint is not DomainConstraint domainConstraint) + throw new ArgumentException(Strings.ExInvalidConstraintType, nameof(action)); + else if (domainConstraint.Domain!=null && domainConstraint.Domain!=domain) + throw new ArgumentException(Strings.ExConstraintBelongsToOtherDomain, nameof(action)); } - else if (action is SqlDropConstraint) { - DomainConstraint constraint = ((SqlDropConstraint)action).Constraint as DomainConstraint; - if (constraint==null) - throw new ArgumentException(Strings.ExInvalidConstraintType, "action"); - else if (constraint.Domain!=null && constraint.Domain!=domain) - throw new ArgumentException(Strings.ExConstraintBelongsToOtherDomain, "action"); + else if (action is SqlDropConstraint dropConstraint) { + if (dropConstraint.Constraint is not DomainConstraint domainConstraint) + throw new ArgumentException(Strings.ExInvalidConstraintType, nameof(action)); + else if (domainConstraint.Domain!=null && domainConstraint.Domain!=domain) + throw new ArgumentException(Strings.ExConstraintBelongsToOtherDomain, nameof(action)); } - else if (action is SqlSetDefault && ((SqlSetDefault)action).Column!=null || - action is SqlDropDefault && ((SqlDropDefault)action).Column!=null) - throw new ArgumentException(Strings.ExInvalidActionType, "action"); + else if (action is SqlSetDefault setDefaultAction && setDefaultAction.Column!=null || + action is SqlDropDefault dropDefaultAction && dropDefaultAction.Column!=null) + throw new ArgumentException(Strings.ExInvalidActionType, nameof(action)); else if (action is SqlAddColumn || action is SqlDropColumn || action is SqlAlterIdentityInfo) - throw new ArgumentException(Strings.ExInvalidActionType, "action"); + throw new ArgumentException(Strings.ExInvalidActionType, nameof(action)); return new SqlAlterDomain(domain, action); } public static SqlAlterPartitionFunction Alter( PartitionFunction partitionFunction, string booundary, SqlAlterPartitionFunctionOption option) { - ArgumentValidator.EnsureArgumentNotNull(partitionFunction, "partitionFunction"); - ArgumentValidator.EnsureArgumentNotNull(booundary, "booundary"); + ArgumentNullException.ThrowIfNull(partitionFunction); + ArgumentNullException.ThrowIfNull(booundary); return new SqlAlterPartitionFunction(partitionFunction, booundary, option); } public static SqlAlterPartitionScheme Alter(PartitionSchema partitionSchema) { - ArgumentValidator.EnsureArgumentNotNull(partitionSchema, "partitionSchema"); + ArgumentNullException.ThrowIfNull(partitionSchema); return new SqlAlterPartitionScheme(partitionSchema, null); } public static SqlAlterPartitionScheme Alter(PartitionSchema partitionSchema, string filegroup) { - ArgumentValidator.EnsureArgumentNotNull(partitionSchema, "partitionSchema"); + ArgumentNullException.ThrowIfNull(partitionSchema); return new SqlAlterPartitionScheme(partitionSchema, filegroup); } public static SqlAlterIdentityInfo Alter(TableColumn column, SequenceDescriptor descriptor) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); - ArgumentValidator.EnsureArgumentNotNull(descriptor, "info"); + ArgumentNullException.ThrowIfNull(column); + ArgumentNullException.ThrowIfNull(descriptor); return new SqlAlterIdentityInfo(column, descriptor, SqlAlterIdentityInfoOptions.All); } public static SqlAlterIdentityInfo Alter( TableColumn column, SequenceDescriptor descriptor, SqlAlterIdentityInfoOptions infoOption) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); - ArgumentValidator.EnsureArgumentNotNull(descriptor, "info"); + ArgumentNullException.ThrowIfNull(column); + ArgumentNullException.ThrowIfNull(descriptor); return new SqlAlterIdentityInfo(column, descriptor, infoOption); } public static SqlAddColumn AddColumn(TableColumn column) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); + ArgumentNullException.ThrowIfNull(column); return new SqlAddColumn(column); } public static SqlAddConstraint AddConstraint(Constraint constraint) { - ArgumentValidator.EnsureArgumentNotNull(constraint, "constraint"); + ArgumentNullException.ThrowIfNull(constraint); return new SqlAddConstraint(constraint); } public static SqlDropColumn DropColumn(TableColumn column) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); + ArgumentNullException.ThrowIfNull(column); return new SqlDropColumn(column); } public static SqlDropColumn DropColumn(TableColumn column, bool cascade) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); + ArgumentNullException.ThrowIfNull(column); return new SqlDropColumn(column, cascade); } public static SqlDropConstraint DropConstraint(Constraint constraint) { - ArgumentValidator.EnsureArgumentNotNull(constraint, "constraint"); + ArgumentNullException.ThrowIfNull(constraint); return new SqlDropConstraint(constraint); } public static SqlDropConstraint DropConstraint(Constraint constraint, bool cascade) { - ArgumentValidator.EnsureArgumentNotNull(constraint, "constraint"); + ArgumentNullException.ThrowIfNull(constraint); return new SqlDropConstraint(constraint, cascade); } public static SqlSetDefault SetDefault(SqlExpression defaulValue, TableColumn column) { - ArgumentValidator.EnsureArgumentNotNull(defaulValue, "defaulValue"); + ArgumentNullException.ThrowIfNull(defaulValue); return new SqlSetDefault(defaulValue, column); } @@ -441,6 +443,7 @@ public static SqlSetDefault SetDefault(SqlExpression defaulValue) public static SqlDropDefault DropDefault(TableColumn column) { + ArgumentNullException.ThrowIfNull(column); return new SqlDropDefault(column); } diff --git a/Orm/Xtensive.Orm/Sql/SqlDml.cs b/Orm/Xtensive.Orm/Sql/SqlDml.cs index 984b25a5e..b029674cf 100644 --- a/Orm/Xtensive.Orm/Sql/SqlDml.cs +++ b/Orm/Xtensive.Orm/Sql/SqlDml.cs @@ -54,7 +54,7 @@ public static SqlAggregate Avg(SqlExpression expression) public static SqlAggregate Avg(SqlExpression expression, bool distinct) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); return new SqlAggregate(SqlNodeType.Avg, expression, distinct); } @@ -65,7 +65,7 @@ public static SqlAggregate Sum(SqlExpression expression) public static SqlAggregate Sum(SqlExpression expression, bool distinct) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); return new SqlAggregate(SqlNodeType.Sum, expression, distinct); } @@ -76,7 +76,7 @@ public static SqlAggregate Min(SqlExpression expression) public static SqlAggregate Min(SqlExpression expression, bool distinct) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); return new SqlAggregate(SqlNodeType.Min, expression, distinct); } @@ -87,7 +87,7 @@ public static SqlAggregate Max(SqlExpression expression) public static SqlAggregate Max(SqlExpression expression, bool distinct) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); return new SqlAggregate(SqlNodeType.Max, expression, distinct); } @@ -97,8 +97,8 @@ public static SqlAggregate Max(SqlExpression expression, bool distinct) public static SqlBinary Add(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.Add, left, right); @@ -106,8 +106,8 @@ public static SqlBinary Add(SqlExpression left, SqlExpression right) public static SqlBinary Subtract(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.Subtract, left, right); @@ -115,8 +115,8 @@ public static SqlBinary Subtract(SqlExpression left, SqlExpression right) public static SqlBinary Multiply(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.Multiply, left, right); @@ -124,8 +124,8 @@ public static SqlBinary Multiply(SqlExpression left, SqlExpression right) public static SqlBinary Divide(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.Divide, left, right); @@ -133,8 +133,8 @@ public static SqlBinary Divide(SqlExpression left, SqlExpression right) public static SqlBinary Modulo(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.Modulo, left, right); @@ -266,8 +266,8 @@ public static SqlArray Array(params TimeSpan[] value) public static SqlBinary BitAnd(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.BitAnd, left, right); @@ -275,8 +275,8 @@ public static SqlBinary BitAnd(SqlExpression left, SqlExpression right) public static SqlBinary BitOr(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.BitOr, left, right); @@ -284,8 +284,8 @@ public static SqlBinary BitOr(SqlExpression left, SqlExpression right) public static SqlBinary BitXor(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.BitXor, left, right); @@ -293,8 +293,8 @@ public static SqlBinary BitXor(SqlExpression left, SqlExpression right) public static SqlBinary And(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsBooleanExpression(left); SqlValidator.EnsureIsBooleanExpression(right); return Binary(SqlNodeType.And, left, right); @@ -302,8 +302,8 @@ public static SqlBinary And(SqlExpression left, SqlExpression right) public static SqlBinary Or(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsBooleanExpression(left); SqlValidator.EnsureIsBooleanExpression(right); return Binary(SqlNodeType.Or, left, right); @@ -321,8 +321,8 @@ public static SqlQueryExpression ExceptAll(ISqlQueryExpression left, ISqlQueryEx private static SqlQueryExpression Except(ISqlQueryExpression left, ISqlQueryExpression right, bool all) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlQueryExpression(SqlNodeType.Except, left, right, all); } @@ -338,8 +338,8 @@ public static SqlQueryExpression IntersectAll(ISqlQueryExpression left, ISqlQuer private static SqlQueryExpression Intersect(ISqlQueryExpression left, ISqlQueryExpression right, bool all) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlQueryExpression(SqlNodeType.Intersect, left, right, all); } @@ -355,50 +355,50 @@ public static SqlQueryExpression UnionAll(ISqlQueryExpression left, ISqlQueryExp private static SqlQueryExpression Union(ISqlQueryExpression left, ISqlQueryExpression right, bool all) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlQueryExpression(SqlNodeType.Union, left, right, all); } public static SqlBinary In(SqlExpression left, ISqlQueryExpression right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.In, left, SubQuery(right)); } public static SqlBinary In(SqlExpression left, SqlRow right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.In, left, right); } public static SqlBinary In(SqlExpression left, SqlArray right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.In, left, right); } public static SqlBinary NotIn(SqlExpression left, ISqlQueryExpression right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.NotIn, left, SubQuery(right)); } public static SqlBinary NotIn(SqlExpression left, SqlRow right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.NotIn, left, right); } public static SqlBinary NotIn(SqlExpression left, SqlArray right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.NotIn, left, right); } @@ -435,32 +435,32 @@ internal static SqlBinary Binary(SqlNodeType nodeType, SqlExpression left, SqlEx public static SqlCast Cast(SqlExpression operand, SqlValueType type) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); - ArgumentValidator.EnsureArgumentNotNull(type, "type"); + ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(type, "type"); return new SqlCast(operand, type); } public static SqlCast Cast(SqlExpression operand, SqlType type) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return new SqlCast(operand, new SqlValueType(type)); } public static SqlCast Cast(SqlExpression operand, SqlType type, int size) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return new SqlCast(operand, new SqlValueType(type, size)); } public static SqlCast Cast(SqlExpression operand, SqlType type, short precision, short scale) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return new SqlCast(operand, new SqlValueType(type, precision, scale)); } public static SqlCast Cast(SqlExpression operand, SqlType type, short precision) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return new SqlCast(operand, new SqlValueType(type, precision, 0)); } @@ -470,43 +470,43 @@ public static SqlCast Cast(SqlExpression operand, SqlType type, short precision) public static SqlBinary Equals(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.Equals, left, right); } public static SqlBinary NotEquals(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.NotEquals, left, right); } public static SqlBinary GreaterThan(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.GreaterThan, left, right); } public static SqlBinary LessThan(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.LessThan, left, right); } public static SqlBinary GreaterThanOrEquals(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.GreaterThanOrEquals, left, right); } public static SqlBinary LessThanOrEquals(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return Binary(SqlNodeType.LessThanOrEquals, left, right); } @@ -555,7 +555,7 @@ public static SqlFunctionCall CurrentTimeStamp(SqlExpression precision) public static SqlExtract Extract(SqlDateTimePart part, SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsArithmeticExpression(operand); if (part == SqlDateTimePart.Nothing) { throw new ArgumentException(string.Format("Unable to extract {0} part", SqlDateTimePart.Nothing.ToString())); @@ -585,7 +585,7 @@ public static SqlExtract Extract(SqlTimePart part, SqlExpression operand) public static SqlExtract Extract(SqlIntervalPart part, SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsArithmeticExpression(operand); if (part == SqlIntervalPart.Nothing) { throw new ArgumentException(string.Format("Unable to extract {0} part", SqlIntervalPart.Nothing.ToString())); @@ -595,9 +595,9 @@ public static SqlExtract Extract(SqlIntervalPart part, SqlExpression operand) public static SqlFunctionCall DateTimeConstruct(SqlExpression year, SqlExpression month, SqlExpression day) { - ArgumentValidator.EnsureArgumentNotNull(year, "year"); - ArgumentValidator.EnsureArgumentNotNull(month, "month"); - ArgumentValidator.EnsureArgumentNotNull(day, "day"); + ArgumentNullException.ThrowIfNull(year, "year"); + ArgumentNullException.ThrowIfNull(month, "month"); + ArgumentNullException.ThrowIfNull(day, "day"); SqlValidator.EnsureIsArithmeticExpression(year); SqlValidator.EnsureIsArithmeticExpression(month); SqlValidator.EnsureIsArithmeticExpression(day); @@ -642,8 +642,8 @@ public static SqlFunctionCall TimeConstruct(SqlExpression ticks) public static SqlBinary DateTimePlusInterval(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlBinary(SqlNodeType.DateTimePlusInterval, left, right); } @@ -663,29 +663,29 @@ public static SqlBinary TimeMinusTime(SqlExpression left, SqlExpression right) public static SqlBinary DateTimeMinusInterval(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlBinary(SqlNodeType.DateTimeMinusInterval, left, right); } public static SqlBinary DateTimeMinusDateTime(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlBinary(SqlNodeType.DateTimeMinusDateTime, left, right); } public static SqlFunctionCall DateTimeAddYears(SqlExpression source, SqlExpression years) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(years, "years"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(years, "years"); return new SqlFunctionCall(SqlFunctionType.DateTimeAddYears, source, years); } public static SqlFunctionCall DateTimeAddMonths(SqlExpression source, SqlExpression months) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(months, "months"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(months, "months"); return new SqlFunctionCall(SqlFunctionType.DateTimeAddMonths, source, months); } @@ -780,43 +780,43 @@ public static SqlFunctionCall TimeToDateTimeOffset(SqlExpression expression) public static SqlFunctionCall DateTimeToStringIso(SqlExpression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); return new SqlFunctionCall(SqlFunctionType.DateTimeToStringIso, expression); } public static SqlFunctionCall DateTimeTruncate(SqlExpression source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); return new SqlFunctionCall(SqlFunctionType.DateTimeTruncate, source); } public static SqlFunctionCall IntervalConstruct(SqlExpression nanoseconds) { - ArgumentValidator.EnsureArgumentNotNull(nanoseconds, "nanoseconds"); + ArgumentNullException.ThrowIfNull(nanoseconds, "nanoseconds"); return new SqlFunctionCall(SqlFunctionType.IntervalConstruct, nanoseconds); } public static SqlFunctionCall IntervalToMilliseconds(SqlExpression source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); return new SqlFunctionCall(SqlFunctionType.IntervalToMilliseconds, source); } public static SqlFunctionCall IntervalToNanoseconds(SqlExpression source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); return new SqlFunctionCall(SqlFunctionType.IntervalToNanoseconds, source); } public static SqlFunctionCall IntervalAbs(SqlExpression source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); return new SqlFunctionCall(SqlFunctionType.IntervalAbs, source); } public static SqlFunctionCall IntervalNegate(SqlExpression source) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(source, "source"); return new SqlFunctionCall(SqlFunctionType.IntervalNegate, source); } @@ -831,7 +831,7 @@ public static SqlFunctionCall CurrentDateTimeOffset() public static SqlExtract Extract(SqlDateTimeOffsetPart part, SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsArithmeticExpression(operand); if (part==SqlDateTimeOffsetPart.Nothing) throw new ArgumentException(); @@ -840,74 +840,74 @@ public static SqlExtract Extract(SqlDateTimeOffsetPart part, SqlExpression opera public static SqlFunctionCall DateTimeOffsetConstruct(SqlExpression dateTime, SqlExpression offset) { - ArgumentValidator.EnsureArgumentNotNull(dateTime, "dateTime"); - ArgumentValidator.EnsureArgumentNotNull(offset, "offset"); + ArgumentNullException.ThrowIfNull(dateTime, "dateTime"); + ArgumentNullException.ThrowIfNull(offset, "offset"); SqlValidator.EnsureIsArithmeticExpression(offset); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetConstruct, dateTime, offset); } public static SqlBinary DateTimeOffsetPlusInterval(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlBinary(SqlNodeType.DateTimeOffsetPlusInterval, left, right); } public static SqlBinary DateTimeOffsetMinusInterval(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlBinary(SqlNodeType.DateTimeOffsetMinusInterval, left, right); } public static SqlBinary DateTimeOffsetMinusDateTimeOffset(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlBinary(SqlNodeType.DateTimeOffsetMinusDateTimeOffset, left, right); } public static SqlFunctionCall DateTimeOffsetAddYears(SqlExpression source, SqlExpression years) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(years, "years"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(years, "years"); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetAddYears, source, years); } public static SqlFunctionCall DateTimeOffsetAddMonths(SqlExpression source, SqlExpression months) { - ArgumentValidator.EnsureArgumentNotNull(source, "source"); - ArgumentValidator.EnsureArgumentNotNull(months, "months"); + ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(months, "months"); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetAddMonths, source, months); } public static SqlFunctionCall DateTimeOffsetTimeOfDay(SqlExpression dateTimeOffset) { - ArgumentValidator.EnsureArgumentNotNull(dateTimeOffset, "dateTimeOffset"); + ArgumentNullException.ThrowIfNull(dateTimeOffset, "dateTimeOffset"); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetTimeOfDay, dateTimeOffset); } public static SqlFunctionCall DateTimeOffsetToLocalTime(SqlExpression dateTimeOffset) { - ArgumentValidator.EnsureArgumentNotNull(dateTimeOffset, "dateTimeOffset"); + ArgumentNullException.ThrowIfNull(dateTimeOffset, "dateTimeOffset"); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToLocalTime, dateTimeOffset); } public static SqlFunctionCall DateTimeOffsetToUtcTime(SqlExpression dateTimeOffset) { - ArgumentValidator.EnsureArgumentNotNull(dateTimeOffset, "dateTimeOffset"); + ArgumentNullException.ThrowIfNull(dateTimeOffset, "dateTimeOffset"); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToUtcTime, dateTimeOffset); } public static SqlFunctionCall DateTimeToDateTimeOffset(SqlExpression dateTime) { - ArgumentValidator.EnsureArgumentNotNull(dateTime, "dateTime"); + ArgumentNullException.ThrowIfNull(dateTime, "dateTime"); return new SqlFunctionCall(SqlFunctionType.DateTimeToDateTimeOffset, dateTime); } public static SqlFunctionCall DateTimeOffsetToDateTime(SqlExpression dateTimeOffset) { - ArgumentValidator.EnsureArgumentNotNull(dateTimeOffset, nameof(dateTimeOffset)); + ArgumentNullException.ThrowIfNull(dateTimeOffset, nameof(dateTimeOffset)); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToDateTime, dateTimeOffset); } @@ -919,7 +919,7 @@ public static SqlFunctionCall DateTimeOffsetToTime(SqlExpression dateTimeOffset) public static SqlFunctionCall DateTimeOffsetToDate(SqlExpression dateTimeOffset) { - ArgumentValidator.EnsureArgumentNotNull(dateTimeOffset, nameof(dateTimeOffset)); + ArgumentNullException.ThrowIfNull(dateTimeOffset, nameof(dateTimeOffset)); ArgumentNullException.ThrowIfNull(dateTimeOffset, nameof(dateTimeOffset)); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToDate, dateTimeOffset); } @@ -965,8 +965,8 @@ public static SqlFunctionCall User() public static SqlFunctionCall NullIf(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); //SqlCase c = new SqlCase(null); @@ -978,8 +978,8 @@ public static SqlFunctionCall NullIf(SqlExpression left, SqlExpression right) public static SqlFunctionCall Coalesce(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); //SqlCase c = new SqlCase(null); @@ -999,7 +999,7 @@ public static SqlFunctionCall Coalesce( // for (int i = 1, l = values.Length; i leftColumns, IReadOnlyList rightColumns, SqlExpression expression) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); if (expression is not null && (joinType == SqlJoinType.CrossApply || joinType == SqlJoinType.LeftOuterApply)) throw new ArgumentException(Strings.ExJoinExpressionShouldBeNullForCrossApplyAndOuterApply, "expression"); return new SqlJoinedTable(new SqlJoinExpression(joinType, left, right, expression), leftColumns, rightColumns); @@ -1066,8 +1066,8 @@ public static SqlJoinedTable Join(SqlJoinType joinType, SqlTable left, SqlTable public static SqlJoinedTable Join(SqlTable left, SqlTable right, params SqlColumn[] columns) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlJoinedTable(new SqlJoinExpression(SqlJoinType.UsingJoin, left, right, Row(columns))); } @@ -1200,8 +1200,8 @@ public static SqlExpression LiteralOrContainer(object value) public static SqlMatch Match(SqlRow value, ISqlQueryExpression query, bool unique, SqlMatchType matchType) { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); - ArgumentValidator.EnsureArgumentNotNull(query, "query"); + ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(query, "query"); return new SqlMatch(value, SubQuery(query), unique, matchType); } @@ -1222,8 +1222,8 @@ public static SqlMatch Match(SqlRow value, ISqlQueryExpression query) public static SqlMatch Match(ISqlQueryExpression value, ISqlQueryExpression query, bool unique, SqlMatchType matchType) { - ArgumentValidator.EnsureArgumentNotNull(value, "value"); - ArgumentValidator.EnsureArgumentNotNull(query, "query"); + ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(query, "query"); return new SqlMatch(SubQuery(value), SubQuery(query), unique, matchType); } @@ -1248,36 +1248,36 @@ public static SqlMatch Match(ISqlQueryExpression value, ISqlQueryExpression quer public static SqlFunctionCall Abs(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Abs, argument); } public static SqlFunctionCall Acos(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Acos, argument); } public static SqlFunctionCall Asin(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Asin, argument); } public static SqlFunctionCall Atan(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Atan, argument); } public static SqlFunctionCall Atan2(SqlExpression argument1, SqlExpression argument2) { - ArgumentValidator.EnsureArgumentNotNull(argument1, "argument1"); - ArgumentValidator.EnsureArgumentNotNull(argument2, "argument2"); + ArgumentNullException.ThrowIfNull(argument1, "argument1"); + ArgumentNullException.ThrowIfNull(argument2, "argument2"); SqlValidator.EnsureIsArithmeticExpression(argument1); SqlValidator.EnsureIsArithmeticExpression(argument2); return new SqlFunctionCall(SqlFunctionType.Atan2, argument1, argument2); @@ -1285,56 +1285,56 @@ public static SqlFunctionCall Atan2(SqlExpression argument1, SqlExpression argum public static SqlFunctionCall Ceiling(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Ceiling, argument); } public static SqlFunctionCall Cos(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Cos, argument); } public static SqlFunctionCall Cot(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Cot, argument); } public static SqlFunctionCall Degrees(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Degrees, argument); } public static SqlFunctionCall Exp(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Exp, argument); } public static SqlFunctionCall Floor(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Floor, argument); } public static SqlFunctionCall Log(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Log, argument); } public static SqlFunctionCall Log10(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Log10, argument); } @@ -1346,16 +1346,16 @@ public static SqlFunctionCall Pi() public static SqlFunctionCall Power(SqlExpression argument, SqlExpression power) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); - ArgumentValidator.EnsureArgumentNotNull(power, "power"); + ArgumentNullException.ThrowIfNull(power, "power"); SqlValidator.EnsureIsArithmeticExpression(power); return new SqlFunctionCall(SqlFunctionType.Power, argument, power); } public static SqlFunctionCall Radians(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Radians, argument); } @@ -1377,23 +1377,23 @@ public static SqlFunctionCall Rand() public static SqlFunctionCall Round(SqlExpression argument, SqlExpression length) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); - ArgumentValidator.EnsureArgumentNotNull(length, "length"); + ArgumentNullException.ThrowIfNull(length, "length"); SqlValidator.EnsureIsArithmeticExpression(length); return new SqlFunctionCall(SqlFunctionType.Round, argument, length); } public static SqlFunctionCall Round(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Round, argument); } public static SqlRound Round(SqlExpression argument, SqlExpression length, TypeCode type, MidpointRounding mode) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); if (type!=TypeCode.Decimal && type!=TypeCode.Double) throw new ArgumentOutOfRangeException("type"); return new SqlRound(argument, length, type, mode); @@ -1401,42 +1401,42 @@ public static SqlRound Round(SqlExpression argument, SqlExpression length, TypeC public static SqlFunctionCall Truncate(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Truncate, argument); } public static SqlFunctionCall Sign(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Sign, argument); } public static SqlFunctionCall Sin(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Sin, argument); } public static SqlFunctionCall Sqrt(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Sqrt, argument); } public static SqlFunctionCall Square(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Square, argument); } public static SqlFunctionCall Tan(SqlExpression argument) { - ArgumentValidator.EnsureArgumentNotNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument, "argument"); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Tan, argument); } @@ -1453,13 +1453,13 @@ public static SqlNative Native(string value) public static SqlMetadata Metadata(SqlExpression expression, object value) { - ArgumentValidator.EnsureArgumentNotNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression, nameof(expression)); return new SqlMetadata(expression, value); } public static SqlSubQuery SubQuery(ISqlQueryExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return new SqlSubQuery(operand); } @@ -1476,7 +1476,7 @@ public static SqlCursor Cursor(string name, ISqlQueryExpression query) public static SqlParameterRef ParameterRef(object parameter) { - ArgumentValidator.EnsureArgumentNotNull(parameter, "parameter"); + ArgumentNullException.ThrowIfNull(parameter, "parameter"); return new SqlParameterRef(parameter); } @@ -1498,13 +1498,13 @@ public static SqlCase Case() public static SqlNextValue NextValue(Sequence sequence) { - ArgumentValidator.EnsureArgumentNotNull(sequence, "sequence"); + ArgumentNullException.ThrowIfNull(sequence, "sequence"); return new SqlNextValue(sequence); } public static SqlNextValue NextValue(Sequence sequence, int increment) { - ArgumentValidator.EnsureArgumentNotNull(sequence, "sequence"); + ArgumentNullException.ThrowIfNull(sequence, "sequence"); return new SqlNextValue(sequence, increment); } @@ -1515,21 +1515,21 @@ public static SqlStatementBlock StatementBlock() public static SqlVariant Variant(object id, SqlExpression main, SqlExpression alternative) { - ArgumentValidator.EnsureArgumentNotNull(id, "id"); - ArgumentValidator.EnsureArgumentNotNull(main, "main"); - ArgumentValidator.EnsureArgumentNotNull(alternative, "alternative"); + ArgumentNullException.ThrowIfNull(id, "id"); + ArgumentNullException.ThrowIfNull(main, "main"); + ArgumentNullException.ThrowIfNull(alternative, "alternative"); return new SqlVariant(id, main, alternative); } public static SqlPlaceholder Placeholder(object id) { - ArgumentValidator.EnsureArgumentNotNull(id, "id"); + ArgumentNullException.ThrowIfNull(id, "id"); return new SqlPlaceholder(id); } public static SqlDynamicFilter DynamicFilter(object id) { - ArgumentValidator.EnsureArgumentNotNull(id, "id"); + ArgumentNullException.ThrowIfNull(id, "id"); return new SqlDynamicFilter(id); } @@ -1559,7 +1559,7 @@ public static SqlOrder Order(SqlExpression expression) public static SqlOrder Order(SqlExpression expression, bool ascending) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); return new SqlOrder(expression, ascending); } @@ -1604,13 +1604,13 @@ public static SqlRow Row() public static SqlFragment Fragment(SqlExpression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); return new SqlFragment(expression); } public static SqlWhile While(SqlExpression condition) { - ArgumentValidator.EnsureArgumentNotNull(condition, "condition"); + ArgumentNullException.ThrowIfNull(condition, "condition"); SqlValidator.EnsureIsBooleanExpression(condition); return new SqlWhile(condition); } @@ -1622,25 +1622,25 @@ public static SqlBatch Batch() public static SqlAssignment Assign(SqlVariable left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(right); return new SqlAssignment(left, right); } public static SqlAssignment Assign(SqlParameterRef left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsArithmeticExpression(right); return new SqlAssignment(left, right); } public static SqlIf If(SqlExpression condition, SqlStatement ifTrue, SqlStatement ifFalse) { - ArgumentValidator.EnsureArgumentNotNull(condition, "condition"); + ArgumentNullException.ThrowIfNull(condition, "condition"); SqlValidator.EnsureIsBooleanExpression(condition); - ArgumentValidator.EnsureArgumentNotNull(ifTrue, "ifTrue"); + ArgumentNullException.ThrowIfNull(ifTrue, "ifTrue"); return new SqlIf(condition, ifTrue, ifFalse); } @@ -1656,7 +1656,7 @@ public static SqlDelete Delete() public static SqlDelete Delete(SqlTableRef table) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); + ArgumentNullException.ThrowIfNull(table, "table"); return new SqlDelete(table); } @@ -1667,7 +1667,7 @@ public static SqlUpdate Update() public static SqlUpdate Update(SqlTableRef tableRef) { - ArgumentValidator.EnsureArgumentNotNull(tableRef, "table"); + ArgumentNullException.ThrowIfNull(tableRef, "table"); return new SqlUpdate(tableRef); } @@ -1678,7 +1678,7 @@ public static SqlInsert Insert() public static SqlInsert Insert(SqlTableRef tableRef) { - ArgumentValidator.EnsureArgumentNotNull(tableRef, "table"); + ArgumentNullException.ThrowIfNull(tableRef, "table"); return new SqlInsert(tableRef); } @@ -1689,7 +1689,7 @@ public static SqlSelect Select() public static SqlSelect Select(SqlExpression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); var result = new SqlSelect(); result.Columns.Add(expression); return result; @@ -1697,7 +1697,7 @@ public static SqlSelect Select(SqlExpression expression) public static SqlSelect Select(SqlTable table) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); + ArgumentNullException.ThrowIfNull(table, "table"); return new SqlSelect(table); } @@ -1712,7 +1712,7 @@ public static SqlConcat Concat(SqlExpression left, SqlExpression right) public static SqlConcat Concat(params SqlExpression[] items) { - ArgumentValidator.EnsureArgumentNotNull(items, "items"); + ArgumentNullException.ThrowIfNull(items, "items"); foreach (var item in items) SqlValidator.EnsureIsCharacterExpression(item); return new SqlConcat(items); @@ -1726,8 +1726,8 @@ public static SqlConcat Concat(params SqlExpression[] items) /// New expression. public static SqlBinary RawConcat(SqlExpression left, SqlExpression right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); SqlValidator.EnsureIsCharacterExpression(left); SqlValidator.EnsureIsCharacterExpression(right); return new SqlBinary(SqlNodeType.RawConcat, left, right); @@ -1740,7 +1740,7 @@ public static SqlFunctionCall Substring(SqlExpression operand, int start) public static SqlFunctionCall Substring(SqlExpression operand, int start, int? length) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsCharacterExpression(operand); if (length<0) throw new ArgumentException(Strings.ExLengthShouldBeNotNegativeValue, "length"); @@ -1755,8 +1755,8 @@ public static SqlFunctionCall Substring(SqlExpression operand, int start, int? l public static SqlFunctionCall Substring( SqlExpression operand, SqlExpression start, SqlExpression length = null) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); - ArgumentValidator.EnsureArgumentNotNull(start, "start"); + ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(start, "start"); SqlValidator.EnsureIsCharacterExpression(operand); SqlValidator.EnsureIsArithmeticExpression(start); if (length != null) { @@ -1768,29 +1768,29 @@ public static SqlFunctionCall Substring( public static SqlFunctionCall Upper(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsCharacterExpression(operand); return new SqlFunctionCall(SqlFunctionType.Upper, operand); } public static SqlFunctionCall Lower(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsCharacterExpression(operand); return new SqlFunctionCall(SqlFunctionType.Lower, operand); } public static SqlTrim Trim(SqlExpression operand, SqlTrimType trimType, string trimCharacters) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsCharacterExpression(operand); - ArgumentValidator.EnsureArgumentNotNull(trimCharacters, "trimCharacters"); + ArgumentNullException.ThrowIfNull(trimCharacters, "trimCharacters"); return new SqlTrim(operand, trimCharacters, trimType); } public static SqlTrim Trim(SqlExpression operand, SqlTrimType trimType) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsCharacterExpression(operand); return new SqlTrim(operand, null, trimType); } @@ -1803,8 +1803,8 @@ public static SqlTrim Trim(SqlExpression operand) public static SqlLike Like( SqlExpression expression, SqlExpression pattern, SqlExpression escape) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); - ArgumentValidator.EnsureArgumentNotNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(pattern, "pattern"); SqlValidator.EnsureIsCharacterExpression(expression); SqlValidator.EnsureIsCharacterExpression(pattern); SqlValidator.EnsureIsCharacterExpression(escape); @@ -1818,22 +1818,22 @@ public static SqlLike Like(SqlExpression expression, SqlExpression pattern) public static SqlLike Like(SqlExpression expression, string pattern) { - ArgumentValidator.EnsureArgumentNotNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(pattern, "pattern"); return Like(expression, new SqlLiteral(pattern), null); } public static SqlLike Like(SqlExpression expression, string pattern, char escape) { SqlValidator.EnsureIsCharacterExpression(expression); - ArgumentValidator.EnsureArgumentNotNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(pattern, "pattern"); return Like(expression, new SqlLiteral(pattern), new SqlLiteral(escape)); } public static SqlLike NotLike( SqlExpression expression, SqlExpression pattern, SqlExpression escape) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); - ArgumentValidator.EnsureArgumentNotNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(pattern, "pattern"); SqlValidator.EnsureIsCharacterExpression(expression); SqlValidator.EnsureIsCharacterExpression(pattern); SqlValidator.EnsureIsCharacterExpression(escape); @@ -1847,14 +1847,14 @@ public static SqlLike NotLike(SqlExpression expression, SqlExpression pattern) public static SqlLike NotLike(SqlExpression expression, string pattern) { - ArgumentValidator.EnsureArgumentNotNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(pattern, "pattern"); return NotLike(expression, new SqlLiteral(pattern), null); } public static SqlLike NotLike(SqlExpression expression, string pattern, char escape) { SqlValidator.EnsureIsCharacterExpression(expression); - ArgumentValidator.EnsureArgumentNotNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(pattern, "pattern"); return NotLike(expression, new SqlLiteral(pattern), new SqlLiteral(escape)); } @@ -1870,59 +1870,59 @@ public static SqlBinary Overlaps(DateTime from1, DateTime to1, DateTime from2, D public static SqlBinary Overlaps(SqlExpression from1, SqlExpression toOrSpan1, SqlExpression from2, SqlExpression toOrSpan2) { - ArgumentValidator.EnsureArgumentNotNull(from1, "from1"); - ArgumentValidator.EnsureArgumentNotNull(toOrSpan1, "toOrSpan1"); - ArgumentValidator.EnsureArgumentNotNull(from2, "from2"); - ArgumentValidator.EnsureArgumentNotNull(toOrSpan2, "toOrSpan2"); + ArgumentNullException.ThrowIfNull(from1, "from1"); + ArgumentNullException.ThrowIfNull(toOrSpan1, "toOrSpan1"); + ArgumentNullException.ThrowIfNull(from2, "from2"); + ArgumentNullException.ThrowIfNull(toOrSpan2, "toOrSpan2"); return new SqlBinary(SqlNodeType.Overlaps, Row(from1, toOrSpan1), Row(from2, toOrSpan2)); } public static SqlBinary Overlaps(SqlRow left, SqlRow right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlBinary(SqlNodeType.Overlaps, left, right); } public static SqlBinary Overlaps(SqlSelect left, SqlRow right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlBinary(SqlNodeType.Overlaps, SubQuery(left), right); } public static SqlBinary Overlaps(SqlRow left, SqlSelect right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlBinary(SqlNodeType.Overlaps, left, SubQuery(right)); } public static SqlBinary Overlaps(SqlSelect left, SqlSelect right) { - ArgumentValidator.EnsureArgumentNotNull(left, "left"); - ArgumentValidator.EnsureArgumentNotNull(right, "right"); + ArgumentNullException.ThrowIfNull(left, "left"); + ArgumentNullException.ThrowIfNull(right, "right"); return new SqlBinary(SqlNodeType.Overlaps, left, right); } public static SqlFunctionCall BinaryLength(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsCharacterExpression(operand); return new SqlFunctionCall(SqlFunctionType.BinaryLength, operand); } public static SqlFunctionCall CharLength(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsCharacterExpression(operand); return new SqlFunctionCall(SqlFunctionType.CharLength, operand); } public static SqlFunctionCall Position(SqlExpression pattern, SqlExpression source) { - ArgumentValidator.EnsureArgumentNotNull(pattern, "pattern"); - ArgumentValidator.EnsureArgumentNotNull(source, "source"); + ArgumentNullException.ThrowIfNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(source, "source"); SqlValidator.EnsureIsCharacterExpression(pattern); SqlValidator.EnsureIsCharacterExpression(source); return new SqlFunctionCall(SqlFunctionType.Position, pattern, source); @@ -1930,9 +1930,9 @@ public static SqlFunctionCall Position(SqlExpression pattern, SqlExpression sour public static SqlFunctionCall Replace(SqlExpression text, SqlExpression from, SqlExpression to) { - ArgumentValidator.EnsureArgumentNotNull(text, "text"); - ArgumentValidator.EnsureArgumentNotNull(from, "from"); - ArgumentValidator.EnsureArgumentNotNull(to, "to"); + ArgumentNullException.ThrowIfNull(text, "text"); + ArgumentNullException.ThrowIfNull(from, "from"); + ArgumentNullException.ThrowIfNull(to, "to"); SqlValidator.EnsureIsCharacterExpression(text); SqlValidator.EnsureIsCharacterExpression(from); SqlValidator.EnsureIsCharacterExpression(to); @@ -1941,40 +1941,40 @@ public static SqlFunctionCall Replace(SqlExpression text, SqlExpression from, Sq public static SqlCollate Collate(SqlExpression operand, Collation collation) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsCharacterExpression(operand); - ArgumentValidator.EnsureArgumentNotNull(collation, "collation"); + ArgumentNullException.ThrowIfNull(collation, "collation"); return new SqlCollate(operand, collation); } public static SqlFunctionCall PadLeft(SqlExpression operand, SqlExpression length) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); - ArgumentValidator.EnsureArgumentNotNull(length, "length"); + ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(length, "length"); return new SqlFunctionCall(SqlFunctionType.PadLeft, operand, length); } public static SqlFunctionCall PadLeft(SqlExpression operand, SqlExpression length, SqlExpression padChar) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); - ArgumentValidator.EnsureArgumentNotNull(length, "length"); - ArgumentValidator.EnsureArgumentNotNull(padChar, "padChar"); + ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(length, "length"); + ArgumentNullException.ThrowIfNull(padChar, "padChar"); return new SqlFunctionCall(SqlFunctionType.PadLeft, operand, length, padChar); } public static SqlFunctionCall PadRight(SqlExpression operand, SqlExpression length) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); - ArgumentValidator.EnsureArgumentNotNull(length, "length"); + ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(length, "length"); return new SqlFunctionCall(SqlFunctionType.PadRight, operand, length); } public static SqlFunctionCall PadRight(SqlExpression operand, SqlExpression length, SqlExpression padChar) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); - ArgumentValidator.EnsureArgumentNotNull(length, "length"); - ArgumentValidator.EnsureArgumentNotNull(padChar, "padChar"); + ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(length, "length"); + ArgumentNullException.ThrowIfNull(padChar, "padChar"); return new SqlFunctionCall(SqlFunctionType.PadRight, operand, length, padChar); } @@ -1984,141 +1984,141 @@ public static SqlFunctionCall PadRight(SqlExpression operand, SqlExpression leng public static SqlTableColumn TableColumn(SqlTable sqlTable) { - ArgumentValidator.EnsureArgumentNotNull(sqlTable, "table"); + ArgumentNullException.ThrowIfNull(sqlTable, "table"); return new SqlTableColumn(sqlTable, string.Empty); } public static SqlTableColumn TableColumn(SqlTable sqlTable, string name) { - ArgumentValidator.EnsureArgumentNotNull(sqlTable, "table"); + ArgumentNullException.ThrowIfNull(sqlTable, "table"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); return new SqlTableColumn(sqlTable, name); } public static SqlUserColumn Column(SqlExpression expression) { - ArgumentValidator.EnsureArgumentNotNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression, "expression"); return new SqlUserColumn(expression); } public static SqlColumnRef ColumnRef(SqlColumn column) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); + ArgumentNullException.ThrowIfNull(column, "column"); return new SqlColumnRef(column); } public static SqlColumnRef ColumnRef(SqlColumn column, string alias) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); + ArgumentNullException.ThrowIfNull(column, "column"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(alias, "alias"); return new SqlColumnRef(column, alias); } public static SqlColumnStub ColumnStub(SqlColumn column) { - ArgumentValidator.EnsureArgumentNotNull(column, "column"); + ArgumentNullException.ThrowIfNull(column, "column"); return new SqlColumnStub(column); } public static SqlFreeTextTable FreeTextTable(DataTable dataTable, SqlExpression freeText, IList columnNames) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNull(freeText, "freeText"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(freeText, "freeText"); return new SqlFreeTextTable(dataTable, freeText, columnNames); } public static SqlFreeTextTable FreeTextTable(DataTable dataTable, SqlExpression freeText, IList columnNames, IList targetColumnNames) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNull(freeText, "freeText"); - ArgumentValidator.EnsureArgumentNotNull(columnNames, "columnNames"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(freeText, "freeText"); + ArgumentNullException.ThrowIfNull(columnNames, "columnNames"); return new SqlFreeTextTable(dataTable, freeText, columnNames, targetColumnNames); } public static SqlFreeTextTable FreeTextTable(DataTable dataTable, SqlExpression freeText, IList columnNames, SqlExpression topN) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNull(freeText, "freeText"); - ArgumentValidator.EnsureArgumentNotNull(topN, "topN"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(freeText, "freeText"); + ArgumentNullException.ThrowIfNull(topN, "topN"); return new SqlFreeTextTable(dataTable, freeText, columnNames, topN); } public static SqlFreeTextTable FreeTextTable(DataTable dataTable, SqlExpression freeText, IList columnNames, IList targetColumNames, SqlExpression topN) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNull(freeText, "freeText"); - ArgumentValidator.EnsureArgumentNotNull(targetColumNames, "targetColumNames"); - ArgumentValidator.EnsureArgumentNotNull(topN, "topN"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(freeText, "freeText"); + ArgumentNullException.ThrowIfNull(targetColumNames, "targetColumNames"); + ArgumentNullException.ThrowIfNull(topN, "topN"); return new SqlFreeTextTable(dataTable, freeText, columnNames, targetColumNames, topN); } public static SqlContainsTable ContainsTable(DataTable dataTable, SqlExpression searchText, IList columnNames) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNull(searchText, "searchText"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(searchText, "searchText"); return new SqlContainsTable(dataTable, searchText, columnNames); } public static SqlContainsTable ContainsTable(DataTable dataTable, SqlExpression searchText, IList columnNames, IList targetColumnNames) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNull(searchText, "searchText"); - ArgumentValidator.EnsureArgumentNotNull(columnNames, "columnNames"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(searchText, "searchText"); + ArgumentNullException.ThrowIfNull(columnNames, "columnNames"); return new SqlContainsTable(dataTable, searchText, columnNames, targetColumnNames); } public static SqlContainsTable ContainsTable(DataTable dataTable, SqlExpression searchText, IList columnNames, SqlExpression topN) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNull(searchText, "searchText"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(searchText, "searchText"); return new SqlContainsTable(dataTable, searchText, columnNames, topN); } public static SqlContainsTable ContainsTable(DataTable dataTable, SqlExpression searchText, IList columnNames, IList targetColumnNames, SqlExpression topN) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNull(searchText, "searchText"); - ArgumentValidator.EnsureArgumentNotNull(columnNames, "columnNames"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(searchText, "searchText"); + ArgumentNullException.ThrowIfNull(columnNames, "columnNames"); return new SqlContainsTable(dataTable, searchText, columnNames, targetColumnNames, topN); } public static SqlTableRef TableRef(DataTable dataTable) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); return new SqlTableRef(dataTable); } public static SqlTableRef TableRef(DataTable dataTable, IEnumerable columnNames) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNull(columnNames, "columnNames"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(columnNames, "columnNames"); return new SqlTableRef(dataTable, string.Empty, columnNames.ToArray()); } public static SqlTableRef TableRef(DataTable dataTable, string name) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); return new SqlTableRef(dataTable, name); } public static SqlTableRef TableRef(DataTable dataTable, string name, IEnumerable columnNames) { - ArgumentValidator.EnsureArgumentNotNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); - ArgumentValidator.EnsureArgumentNotNull(columnNames, "columnNames"); + ArgumentNullException.ThrowIfNull(columnNames, "columnNames"); return new SqlTableRef(dataTable, name, columnNames.ToArray()); } public static SqlQueryRef QueryRef(ISqlQueryExpression query) { - ArgumentValidator.EnsureArgumentNotNull(query, "query"); + ArgumentNullException.ThrowIfNull(query, "query"); return new SqlQueryRef(query); } public static SqlQueryRef QueryRef(ISqlQueryExpression query, string alias) { - ArgumentValidator.EnsureArgumentNotNull(query, "query"); + ArgumentNullException.ThrowIfNull(query, "query"); ArgumentValidator.EnsureArgumentNotNullOrEmpty(alias, "alias"); return new SqlQueryRef(query, alias); } @@ -2129,64 +2129,64 @@ public static SqlQueryRef QueryRef(ISqlQueryExpression query, string alias) public static SqlUnary BitNot(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsArithmeticExpression(operand); return Unary(SqlNodeType.BitNot, operand); } public static SqlUnary Negate(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsArithmeticExpression(operand); return Unary(SqlNodeType.Negate, operand); } public static SqlUnary Not(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); SqlValidator.EnsureIsBooleanExpression(operand); return Unary(SqlNodeType.Not, operand); } public static SqlUnary IsNull(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return Unary(SqlNodeType.IsNull, operand); } public static SqlUnary IsNotNull(SqlExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return Unary(SqlNodeType.IsNotNull, operand); } public static SqlUnary Unique(ISqlQueryExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return Unary(SqlNodeType.Unique, SubQuery(operand)); } public static SqlUnary Exists(ISqlQueryExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return new SqlUnary(SqlNodeType.Exists, SubQuery(operand)); } public static SqlUnary All(ISqlQueryExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return Unary(SqlNodeType.All, SubQuery(operand)); } public static SqlUnary Any(ISqlQueryExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return Unary(SqlNodeType.Any, SubQuery(operand)); } public static SqlUnary Some(ISqlQueryExpression operand) { - ArgumentValidator.EnsureArgumentNotNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand, "operand"); return Unary(SqlNodeType.Some, SubQuery(operand)); } @@ -2234,7 +2234,7 @@ public static SqlVariable Variable(string name, SqlType type, short precision) public static SqlJoinHint JoinHint(SqlJoinMethod method, SqlTable table) { - ArgumentValidator.EnsureArgumentNotNull(table, "table"); + ArgumentNullException.ThrowIfNull(table, "table"); return new SqlJoinHint(method, table); } @@ -2245,7 +2245,7 @@ public static SqlForceJoinOrderHint ForceJoinOrderHint() public static SqlForceJoinOrderHint ForceJoinOrderHint(params SqlTable[] sqlTables) { - ArgumentValidator.EnsureArgumentNotNull(sqlTables, "sqlTables"); + ArgumentNullException.ThrowIfNull(sqlTables); return new SqlForceJoinOrderHint(sqlTables); } diff --git a/Orm/Xtensive.Orm/Sql/SqlDriver.cs b/Orm/Xtensive.Orm/Sql/SqlDriver.cs index 24dd3b175..2f170f946 100644 --- a/Orm/Xtensive.Orm/Sql/SqlDriver.cs +++ b/Orm/Xtensive.Orm/Sql/SqlDriver.cs @@ -59,7 +59,7 @@ public abstract class SqlDriver /// Result of compilation. public SqlCompilationResult Compile(ISqlCompileUnit statement) { - ArgumentValidator.EnsureArgumentNotNull(statement, nameof(statement)); + ArgumentNullException.ThrowIfNull(statement); return CreateCompiler().Compile(statement, new SqlCompilerConfiguration()); } @@ -71,8 +71,8 @@ public SqlCompilationResult Compile(ISqlCompileUnit statement) /// Result of compilation. public SqlCompilationResult Compile(ISqlCompileUnit statement, SqlCompilerConfiguration configuration) { - ArgumentValidator.EnsureArgumentNotNull(statement, nameof(statement)); - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(statement); + ArgumentNullException.ThrowIfNull(configuration); ValidateCompilerConfiguration(configuration); return CreateCompiler().Compile(statement, configuration); } @@ -84,7 +84,7 @@ public SqlCompilationResult Compile(ISqlCompileUnit statement, SqlCompilerConfig /// for the specified . public DefaultSchemaInfo GetDefaultSchema(SqlConnection connection) { - ArgumentValidator.EnsureArgumentNotNull(connection, nameof(connection)); + ArgumentNullException.ThrowIfNull(connection); if (connection.Driver != this) { throw new ArgumentException(Strings.ExSpecifiedConnectionDoesNotBelongToThisDriver); } @@ -102,7 +102,7 @@ public DefaultSchemaInfo GetDefaultSchema(SqlConnection connection) /// for the specified . public Task GetDefaultSchemaAsync(SqlConnection connection, CancellationToken token) { - ArgumentValidator.EnsureArgumentNotNull(connection, nameof(connection)); + ArgumentNullException.ThrowIfNull(connection); if (connection.Driver != this) { throw new ArgumentException(Strings.ExSpecifiedConnectionDoesNotBelongToThisDriver); } @@ -118,8 +118,8 @@ public Task GetDefaultSchemaAsync(SqlConnection connection, C /// Extracted catalogs. public SqlExtractionResult Extract(SqlConnection connection, IEnumerable tasks) { - ArgumentValidator.EnsureArgumentNotNull(connection, nameof(connection)); - ArgumentValidator.EnsureArgumentNotNull(tasks, nameof(tasks)); + ArgumentNullException.ThrowIfNull(connection); + ArgumentNullException.ThrowIfNull(tasks); if (connection.Driver != this) { throw new ArgumentException(Strings.ExSpecifiedConnectionDoesNotBelongToThisDriver); @@ -137,7 +137,7 @@ public SqlExtractionResult Extract(SqlConnection connection, IEnumerable !t.AllSchemas)) { // extracting all the schemes we need - var schemasToExtract = tasksForCatalog.Select(t => t.Schema).ToArray(); + var schemasToExtract = tasksForCatalog.Select(static t => t.Schema).ToArray(); var catalog = BuildExtractor(connection) .ExtractSchemes(catalogName, schemasToExtract); CleanSchemas(catalog, schemasToExtract); @@ -165,8 +165,8 @@ public SqlExtractionResult Extract(SqlConnection connection, IEnumerable ExtractAsync(SqlConnection connection, IEnumerable tasks, CancellationToken token = default) { - ArgumentValidator.EnsureArgumentNotNull(connection, nameof(connection)); - ArgumentValidator.EnsureArgumentNotNull(tasks, nameof(tasks)); + ArgumentNullException.ThrowIfNull(connection); + ArgumentNullException.ThrowIfNull(tasks); if (connection.Driver != this) { throw new ArgumentException(Strings.ExSpecifiedConnectionDoesNotBelongToThisDriver); @@ -182,7 +182,7 @@ public async Task ExtractAsync(SqlConnection connection, IE var extractor = await BuildExtractorAsync(connection, token).ConfigureAwait(false); if (sqlExtractionTasks.All(t => !t.AllSchemas)) { // extracting all the schemes we need - var schemasToExtract = sqlExtractionTasks.Select(t => t.Schema).ToArray(); + var schemasToExtract = sqlExtractionTasks.Select(static t => t.Schema).ToArray(); var catalog = await extractor.ExtractSchemesAsync(catalogName, schemasToExtract, token).ConfigureAwait(false); CleanSchemas(catalog, schemasToExtract); result.Catalogs.Add(catalog); diff --git a/Orm/Xtensive.Orm/Sql/SqlDriverFactory.cs b/Orm/Xtensive.Orm/Sql/SqlDriverFactory.cs index 14fd6c46f..6e26d37a9 100644 --- a/Orm/Xtensive.Orm/Sql/SqlDriverFactory.cs +++ b/Orm/Xtensive.Orm/Sql/SqlDriverFactory.cs @@ -4,6 +4,7 @@ // Created by: Denis Krjuchkov // Created: 2009.06.23 +using System; using System.Data.Common; using System.Threading; using System.Threading.Tasks; @@ -68,8 +69,8 @@ public Task GetDriverAsync( /// Created driver. public SqlDriver GetDriver(ConnectionInfo connectionInfo, SqlDriverConfiguration configuration) { - ArgumentValidator.EnsureArgumentNotNull(connectionInfo, nameof(connectionInfo)); - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(connectionInfo); + ArgumentNullException.ThrowIfNull(configuration); var connectionString = GetConnectionString(connectionInfo); configuration = configuration.Clone(); @@ -91,8 +92,8 @@ public SqlDriver GetDriver(ConnectionInfo connectionInfo, SqlDriverConfiguration public async Task GetDriverAsync( ConnectionInfo connectionInfo, SqlDriverConfiguration configuration, CancellationToken token) { - ArgumentValidator.EnsureArgumentNotNull(connectionInfo, nameof(connectionInfo)); - ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(connectionInfo); + ArgumentNullException.ThrowIfNull(configuration); var connectionString = GetConnectionString(connectionInfo); configuration = configuration.Clone(); @@ -108,7 +109,7 @@ public async Task GetDriverAsync( /// Connection string for . public string GetConnectionString(ConnectionInfo connectionInfo) { - ArgumentValidator.EnsureArgumentNotNull(connectionInfo, nameof(connectionInfo)); + ArgumentNullException.ThrowIfNull(connectionInfo); return connectionInfo.ConnectionString ?? BuildConnectionString(connectionInfo.ConnectionUrl); } @@ -121,7 +122,7 @@ public string GetConnectionString(ConnectionInfo connectionInfo) /// for the specified . public DefaultSchemaInfo GetDefaultSchema(DbConnection connection, DbTransaction transaction = null) { - ArgumentValidator.EnsureArgumentNotNull(connection, nameof(connection)); + ArgumentNullException.ThrowIfNull(connection); return ReadDefaultSchema(connection, transaction); } @@ -137,7 +138,7 @@ public DefaultSchemaInfo GetDefaultSchema(DbConnection connection, DbTransaction public Task GetDefaultSchemaAsync( DbConnection connection, DbTransaction transaction = null, CancellationToken token = default) { - ArgumentValidator.EnsureArgumentNotNull(connection, nameof(connection)); + ArgumentNullException.ThrowIfNull(connection); return ReadDefaultSchemaAsync(connection, transaction, token); } diff --git a/Orm/Xtensive.Orm/Sql/SqlExtractionTask.cs b/Orm/Xtensive.Orm/Sql/SqlExtractionTask.cs index 24433c524..c8b4fb09d 100644 --- a/Orm/Xtensive.Orm/Sql/SqlExtractionTask.cs +++ b/Orm/Xtensive.Orm/Sql/SqlExtractionTask.cs @@ -1,3 +1,4 @@ +using System; using Xtensive.Core; using Xtensive.Sql.Model; @@ -28,18 +29,13 @@ public sealed class SqlExtractionTask public SqlExtractionTask(string catalog) { - ArgumentValidator.EnsureArgumentNotNull(catalog, "catalog"); - - Catalog = catalog; + Catalog = catalog ?? throw new ArgumentNullException(nameof(catalog)); } public SqlExtractionTask(string catalog, string schema) { - ArgumentValidator.EnsureArgumentNotNull(catalog, "catalog"); - ArgumentValidator.EnsureArgumentNotNull(schema, "schema"); - - Catalog = catalog; - Schema = schema; + Catalog = catalog ?? throw new ArgumentNullException(nameof(catalog)); + Schema = schema ?? throw new ArgumentNullException(nameof(schema)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Sql/SqlHelper.cs b/Orm/Xtensive.Orm/Sql/SqlHelper.cs index ebb6f764d..33c41c048 100644 --- a/Orm/Xtensive.Orm/Sql/SqlHelper.cs +++ b/Orm/Xtensive.Orm/Sql/SqlHelper.cs @@ -367,7 +367,7 @@ public static SqlExpression GenericPad(SqlFunctionCall node, bool padStringRequi public static DefaultSchemaInfo ReadDatabaseAndSchema(string queryText, DbConnection connection, DbTransaction transaction) { - ArgumentValidator.EnsureArgumentNotNull(connection, nameof(connection)); + ArgumentNullException.ThrowIfNull(connection); ArgumentValidator.EnsureArgumentNotNullOrEmpty(queryText, nameof(queryText)); using var command = connection.CreateCommand(); @@ -395,7 +395,7 @@ public static DefaultSchemaInfo ReadDatabaseAndSchema(string queryText, public static async Task ReadDatabaseAndSchemaAsync(string queryText, DbConnection connection, DbTransaction transaction, CancellationToken token) { - ArgumentValidator.EnsureArgumentNotNull(connection, nameof(connection)); + ArgumentNullException.ThrowIfNull(connection); ArgumentValidator.EnsureArgumentNotNullOrEmpty(queryText, nameof(queryText)); var command = connection.CreateCommand(); diff --git a/Orm/Xtensive.Orm/Sql/ValueTypeMapping/TypeMappingRegistryBuilder.cs b/Orm/Xtensive.Orm/Sql/ValueTypeMapping/TypeMappingRegistryBuilder.cs index 89e0fd794..029777512 100644 --- a/Orm/Xtensive.Orm/Sql/ValueTypeMapping/TypeMappingRegistryBuilder.cs +++ b/Orm/Xtensive.Orm/Sql/ValueTypeMapping/TypeMappingRegistryBuilder.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2012 Xtensive LLC. +// Copyright (C) 2012 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -56,8 +56,7 @@ public TypeMappingRegistry Build() public TypeMappingRegistryBuilder(TypeMapper mapper) { - ArgumentValidator.EnsureArgumentNotNull(mapper, "mapper"); - Mapper = mapper; + Mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Tuples/DifferentialTuple.cs b/Orm/Xtensive.Orm/Tuples/DifferentialTuple.cs index 7cc9cac8a..77d75817f 100644 --- a/Orm/Xtensive.Orm/Tuples/DifferentialTuple.cs +++ b/Orm/Xtensive.Orm/Tuples/DifferentialTuple.cs @@ -202,8 +202,7 @@ public void Reset() /// Initial property value. public DifferentialTuple(Tuple origin) { - ArgumentValidator.EnsureArgumentNotNull(origin, "origin"); - this.origin = origin; + this.origin = origin ?? throw new ArgumentNullException(nameof(origin)); difference = null; backupedDifference = null; } @@ -216,7 +215,7 @@ public DifferentialTuple(Tuple origin) /// Tuple descriptors mismatch. public DifferentialTuple(Tuple origin, Tuple difference) { - ArgumentValidator.EnsureArgumentNotNull(origin, "origin"); + ArgumentNullException.ThrowIfNull(origin); if (difference!=null && origin.Descriptor!=difference.Descriptor) throw new ArgumentException( string.Format(Strings.ExInvalidTupleDescriptorExpectedDescriptorIs, origin.Descriptor), diff --git a/Orm/Xtensive.Orm/Tuples/Transform/Internals/MapTransformTuple.cs b/Orm/Xtensive.Orm/Tuples/Transform/Internals/MapTransformTuple.cs index 19628222c..de90a2805 100644 --- a/Orm/Xtensive.Orm/Tuples/Transform/Internals/MapTransformTuple.cs +++ b/Orm/Xtensive.Orm/Tuples/Transform/Internals/MapTransformTuple.cs @@ -79,9 +79,8 @@ protected internal override Pair GetMappedContainer(int fieldIndex, public MapTransformTuple(MapTransform transform, params Tuple[] sources) : base(transform) { - ArgumentValidator.EnsureArgumentNotNull(sources, "tuples"); // Other checks are omitted: this transform should be fast, so delayed errors are ok - this.tuples = sources; + this.tuples = sources ?? throw new ArgumentNullException(nameof(sources)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Tuples/Transform/MapTransform.cs b/Orm/Xtensive.Orm/Tuples/Transform/MapTransform.cs index 0bed3c1f9..3fe1c110a 100644 --- a/Orm/Xtensive.Orm/Tuples/Transform/MapTransform.cs +++ b/Orm/Xtensive.Orm/Tuples/Transform/MapTransform.cs @@ -67,7 +67,7 @@ public IReadOnlyList> Map protected void SetSingleSourceMap(IReadOnlyList singleSourceMap) { - ArgumentValidator.EnsureArgumentNotNull(singleSourceMap, nameof(singleSourceMap)); + ArgumentNullException.ThrowIfNull(singleSourceMap); var newMap = new Pair[Descriptor.Count]; var index = 0; for (; index < newMap.Length && index < singleSourceMap.Count; index++) { @@ -84,7 +84,7 @@ protected void SetSingleSourceMap(IReadOnlyList singleSourceMap) protected void SetMap(Pair[] map) { - ArgumentValidator.EnsureArgumentNotNull(map, nameof(map)); + ArgumentNullException.ThrowIfNull(map); int[] newFirstSourceMap = new int[map.Length]; int index = 0; int newSourceCount = -1; @@ -105,7 +105,7 @@ protected void SetMap(Pair[] map) /// public override Tuple Apply(TupleTransformType transformType, params object[] arguments) { - ArgumentValidator.EnsureArgumentNotNull(arguments, "arguments"); + ArgumentNullException.ThrowIfNull(arguments); switch (sourceCount) { case 1: return Apply(transformType, (Tuple)arguments[0]); @@ -128,7 +128,7 @@ public override Tuple Apply(TupleTransformType transformType, params object[] ar /// dependently on specified . public Tuple Apply(TupleTransformType transformType, params Tuple[] sources) { - ArgumentValidator.EnsureArgumentNotNull(sources, "sources"); + ArgumentNullException.ThrowIfNull(sources); if (sourceCount>sources.Length) throw new InvalidOperationException(string.Format(Strings.ExTheNumberOfSourcesIsTooSmallExpected, sourceCount)); switch (sourceCount) { @@ -294,7 +294,6 @@ public MapTransform(bool isReadOnly, TupleDescriptor descriptor, IReadOnlyList public override Tuple Apply(TupleTransformType transformType, params object[] arguments) { - ArgumentValidator.EnsureArgumentNotNull(arguments, "arguments"); + ArgumentNullException.ThrowIfNull(arguments); return Apply(transformType, arguments[0]); } diff --git a/Orm/Xtensive.Orm/Tuples/Transform/WrappingTransformTupleBase.cs b/Orm/Xtensive.Orm/Tuples/Transform/WrappingTransformTupleBase.cs index 5d2c9aba6..8ebb1b274 100644 --- a/Orm/Xtensive.Orm/Tuples/Transform/WrappingTransformTupleBase.cs +++ b/Orm/Xtensive.Orm/Tuples/Transform/WrappingTransformTupleBase.cs @@ -82,8 +82,7 @@ public sealed override int GetHashCode() /// Tuple to provide the wrapper for. protected WrappingTransformTupleBase(Tuple tuple) { - ArgumentValidator.EnsureArgumentNotNull(tuple, "tuple"); - origin = tuple; + origin = tuple ?? throw new ArgumentNullException(nameof(tuple)); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Tuples/Tuple.cs b/Orm/Xtensive.Orm/Tuples/Tuple.cs index a6ea9ecf7..f355c827c 100644 --- a/Orm/Xtensive.Orm/Tuples/Tuple.cs +++ b/Orm/Xtensive.Orm/Tuples/Tuple.cs @@ -312,7 +312,7 @@ public static RegularTuple Create(params Type[] fieldTypes) public static RegularTuple Create(TupleDescriptor descriptor) => descriptor != default ? new PackedTuple(descriptor) - : throw new ArgumentNullException("descriptor"); + : throw new ArgumentNullException(nameof(descriptor)); #endregion diff --git a/Orm/Xtensive.Orm/Tuples/TupleDescriptor.cs b/Orm/Xtensive.Orm/Tuples/TupleDescriptor.cs index 0882646c7..3bbc924de 100644 --- a/Orm/Xtensive.Orm/Tuples/TupleDescriptor.cs +++ b/Orm/Xtensive.Orm/Tuples/TupleDescriptor.cs @@ -170,7 +170,7 @@ public static TupleDescriptor Create(Type t1, Type t2, Type t3, Type t4) /// describing the specified set of fields. public static TupleDescriptor Create(Type[] fieldTypes) { - ArgumentValidator.EnsureArgumentNotNull(fieldTypes, nameof(fieldTypes)); + ArgumentNullException.ThrowIfNull(fieldTypes); if (fieldTypes.Length == 0) { return Empty; } diff --git a/Orm/Xtensive.Orm/Tuples/TupleFormatExtensions.cs b/Orm/Xtensive.Orm/Tuples/TupleFormatExtensions.cs index b131f5da5..d718a3690 100644 --- a/Orm/Xtensive.Orm/Tuples/TupleFormatExtensions.cs +++ b/Orm/Xtensive.Orm/Tuples/TupleFormatExtensions.cs @@ -51,7 +51,7 @@ public static string ToString(this Tuple source, bool format) /// public static string Format(this Tuple source) { - ArgumentValidator.EnsureArgumentNotNull(source, "tuple"); + ArgumentNullException.ThrowIfNull(source); var descriptor = source.Descriptor; var count = source.Count; var targets = new string[count]; @@ -71,7 +71,7 @@ public static string Format(this Tuple source) /// can't be parsed to a with specified . public static Tuple Parse(this TupleDescriptor descriptor, string source) { - ArgumentValidator.EnsureArgumentNotNull(descriptor, "descriptor"); + ArgumentNullException.ThrowIfNull(descriptor); var target = Tuple.Create(descriptor); var count = target.Count; var sources = source.RevertibleSplit(Escape, Comma).ToArray(); diff --git a/Orm/Xtensive.Orm/Tuples/TupleUpdater.cs b/Orm/Xtensive.Orm/Tuples/TupleUpdater.cs index 201a731c8..9cf096c4e 100644 --- a/Orm/Xtensive.Orm/Tuples/TupleUpdater.cs +++ b/Orm/Xtensive.Orm/Tuples/TupleUpdater.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2003-2010 Xtensive LLC. +// Copyright (C) 2003-2010 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Alexander Nikolaev @@ -45,8 +45,7 @@ public TupleUpdater SetValue(int fieldIndex, object value) /// The tuple to wrap. public TupleUpdater(Tuple tuple) { - ArgumentValidator.EnsureArgumentNotNull(tuple, "tuple"); - this.tuple = tuple; + this.tuple = tuple ?? throw new ArgumentNullException(nameof(tuple)); } } } \ No newline at end of file From e804014284d1a4b041a9c3a591a8cbb15618d1d7 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 27 Feb 2026 11:48:51 +0500 Subject: [PATCH 17/55] Other small code improvements - is/is not null applied - some "result is never used" warnings eliminated - summaries to public extension methods added - other things --- .../Modelling/Comparison/Comparer.cs | 2 +- .../Orm/Rse/CompilableProviderExtensions.cs | 535 +++++++++++------- .../Orm/Upgrade/Internals/CatalogCloner.cs | 94 ++- .../Upgrade/Internals/DomainModelConverter.cs | 85 ++- .../Upgrade/Internals/SqlModelConverter.cs | 93 ++- 5 files changed, 471 insertions(+), 338 deletions(-) diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs index 36ed8bf98..af4920501 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs @@ -490,7 +490,7 @@ from diff in newDiffs let nodeDiff = diff as NodeDifference where nodeDiff!=null && (nodeDiff.MovementInfo & MovementInfo.Changed)!=0 select nodeDiff; - // query = query.ToList(); + return query.Any(); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/CompilableProviderExtensions.cs b/Orm/Xtensive.Orm/Orm/Rse/CompilableProviderExtensions.cs index 9e648f29a..c9e8cddf4 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/CompilableProviderExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/CompilableProviderExtensions.cs @@ -23,210 +23,367 @@ namespace Xtensive.Orm.Rse /// public static class CompilableProviderExtensions { - public static CalculateProvider Calculate(this CompilableProvider source, - params CalculatedColumnDescriptor[] columns) - { - return new CalculateProvider(source, columns, false); - } - - public static CalculateProvider Calculate(this CompilableProvider source, bool isInlined, - params CalculatedColumnDescriptor[] columns) - { - return new CalculateProvider(source, columns, isInlined); - } - + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Calculated columns' descriptors. + /// instance. + public static CalculateProvider Calculate(this CompilableProvider source, params CalculatedColumnDescriptor[] columns) + => new CalculateProvider(source, columns, false); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Columns should be inlined or not. + /// Calculated columns' descriptors. + /// instance. + public static CalculateProvider Calculate(this CompilableProvider source, bool isInlined, params CalculatedColumnDescriptor[] columns) + => new CalculateProvider(source, columns, isInlined); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Calculated columns' descriptors. + /// instance. public static CalculateProvider Calculate(this CompilableProvider source, IReadOnlyList columns) - { - return new CalculateProvider(source, columns); - } - + => new CalculateProvider(source, columns); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Columns should be inlined or not. + /// Calculated columns' descriptors. + /// instance. public static CalculateProvider Calculate(this CompilableProvider source, bool isInlined, IReadOnlyList columns) - { - return new CalculateProvider(source, columns, isInlined); - } - - public static CompilableProvider RowNumber(this CompilableProvider source, string columnName) - { - return new RowNumberProvider(source, columnName); - } - - public static CompilableProvider Join(this CompilableProvider left, CompilableProvider right, - params Pair[] joinedColumnIndexes) - { - return new JoinProvider(left, right, JoinType.Inner, joinedColumnIndexes); - } - - public static CompilableProvider Join(this CompilableProvider left, CompilableProvider right, - params int[] joinedColumnIndexes) - { - return new JoinProvider(left, right, JoinType.Inner, joinedColumnIndexes); - } - - public static CompilableProvider LeftJoin(this CompilableProvider left, CompilableProvider right, - params Pair[] joinedColumnIndexes) - { - return new JoinProvider(left, right, JoinType.LeftOuter, joinedColumnIndexes); - } - - public static CompilableProvider LeftJoin(this CompilableProvider left, CompilableProvider right, - params int[] joinedColumnIndexes) - { - return new JoinProvider(left, right, JoinType.LeftOuter, joinedColumnIndexes); - } - - public static CompilableProvider OrderBy(this CompilableProvider source, DirectionCollection columnIndexes) - { - return new SortProvider(source, columnIndexes); - } - - public static CompilableProvider Alias(this CompilableProvider source, string alias) - { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(alias, "alias"); - return new AliasProvider(source, alias); - } - - public static CompilableProvider Filter(this CompilableProvider source, Expression> predicate) - { - return new FilterProvider(source, predicate); - } - - public static CompilableProvider Select(this CompilableProvider source, IReadOnlyList columnIndexes) - { - ArgumentValidator.EnsureArgumentNotNull(columnIndexes, "columnIndexes"); - return new SelectProvider(source, columnIndexes); - } - - public static CompilableProvider Seek(this CompilableProvider source, Func key) - { - return new SeekProvider(source, key); - } - - public static CompilableProvider Seek(this CompilableProvider source, Tuple key) - { - return new SeekProvider(source, key); - } - + => new CalculateProvider(source, columns, isInlined); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Name of column. + /// instance. + public static CompilableProvider RowNumber(this CompilableProvider source, string columnName) => new RowNumberProvider(source, columnName); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Compilable provider. + /// Predicate to join. + /// Join Type + /// instance. + public static CompilableProvider Join(this CompilableProvider left, CompilableProvider right, Expression> predicate, JoinType joinType) + => new PredicateJoinProvider(left, right, predicate, joinType); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Compilable provider. + /// Pair of column indexes to join. + /// instance. + public static CompilableProvider Join(this CompilableProvider left, CompilableProvider right, params Pair[] joinedColumnIndexes) + => new JoinProvider(left, right, JoinType.Inner, joinedColumnIndexes); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Compilable provider. + /// Pair of column indexes to join. + /// instance. + public static CompilableProvider Join(this CompilableProvider left, CompilableProvider right, params int[] joinedColumnIndexes) + => new JoinProvider(left, right, JoinType.Inner, joinedColumnIndexes); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Compilable provider. + /// Pair of column indexes to join. + /// instance. + public static CompilableProvider LeftJoin(this CompilableProvider left, CompilableProvider right, params Pair[] joinedColumnIndexes) + => new JoinProvider(left, right, JoinType.LeftOuter, joinedColumnIndexes); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Compilable provider. + /// Pair of column indexes to join. + /// instance. + public static CompilableProvider LeftJoin(this CompilableProvider left, CompilableProvider right, params int[] joinedColumnIndexes) + => new JoinProvider(left, right, JoinType.LeftOuter, joinedColumnIndexes); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Column indexes to order. + /// instance. + public static CompilableProvider OrderBy(this CompilableProvider source, DirectionCollection columnIndexes) => new SortProvider(source, columnIndexes); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Alias. + /// instance. + public static CompilableProvider Alias(this CompilableProvider source, string alias) => new AliasProvider(source, alias); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Filtration predicate. + /// instance. + public static CompilableProvider Filter(this CompilableProvider source, Expression> predicate) => new FilterProvider(source, predicate); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Column indexes to select from the source. + /// instance. + public static CompilableProvider Select(this CompilableProvider source, IReadOnlyList columnIndexes) => new SelectProvider(source, columnIndexes); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Seek parameter. + /// instance. + public static CompilableProvider Seek(this CompilableProvider source, Func key) => new SeekProvider(source, key); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Seek parameter. + /// instance. + public static CompilableProvider Seek(this CompilableProvider source, Tuple key) => new SeekProvider(source, key); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Column indexes to group by. + /// Descriptors of aggregate columns. + /// instance. public static CompilableProvider Aggregate(this CompilableProvider recordQuery, int[] groupIndexes, params AggregateColumnDescriptor[] descriptors) - { - return new AggregateProvider(recordQuery, groupIndexes, (IReadOnlyList) descriptors); - } - - public static CompilableProvider Skip(this CompilableProvider source, Func count) - { - return new SkipProvider(source, count); - } - - public static CompilableProvider Skip(this CompilableProvider source, int count) - { - return new SkipProvider(source, count); - } - - public static CompilableProvider Take(this CompilableProvider source, Func count) - { - return new TakeProvider(source, count); - } - - public static CompilableProvider Take(this CompilableProvider source, int count) - { - return new TakeProvider(source, count); - } - - public static CompilableProvider Save(this CompilableProvider source) - { - return new StoreProvider(source); - } - - public static CompilableProvider Save(this CompilableProvider source, string name) - { - return new StoreProvider(source, name); - } - - public static CompilableProvider Distinct(this CompilableProvider source) - { - return new DistinctProvider(source); - } - - public static CompilableProvider Apply(this CompilableProvider source, - ApplyParameter applyParameter, CompilableProvider right) - { - return new ApplyProvider(applyParameter, source, right); - } - + => new AggregateProvider(recordQuery, groupIndexes, descriptors); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Column indexes to group by. + /// Descriptors of aggregate columns. + /// instance. + public static CompilableProvider Aggregate(this CompilableProvider recordQuery, + int[] groupIndexes, IReadOnlyList descriptors) + => new AggregateProvider(recordQuery, groupIndexes, descriptors); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Skip amout function. + /// instance. + public static CompilableProvider Skip(this CompilableProvider source, Func count) => new SkipProvider(source, count); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Number of skippable items. + /// instance. + public static CompilableProvider Skip(this CompilableProvider source, int count) => new SkipProvider(source, count); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Take amount function. + /// instance. + public static TakeProvider Take(this CompilableProvider source, Func count) => new TakeProvider(source, count); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Number of items to take. + /// instance. + public static CompilableProvider Take(this CompilableProvider source, int count) => new TakeProvider(source, count); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// instance. + public static CompilableProvider Save(this CompilableProvider source) => new StoreProvider(source); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Name of saved data. + /// instance. + public static CompilableProvider Save(this CompilableProvider source, string name) => new StoreProvider(source, name); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// instance. + public static CompilableProvider Distinct(this CompilableProvider source) => new DistinctProvider(source); + + /// + /// Applies to the given source. + /// + /// Left source. + /// Apply parameter. + /// Compilable provider for right source (on each itteration of source). + /// instance. + public static CompilableProvider Apply(this CompilableProvider source, ApplyParameter applyParameter, CompilableProvider right) + => new ApplyProvider(applyParameter, source, right); + + /// + /// Applies to the given source. + /// + /// Left source. + /// Apply parameter. + /// Compilable provider for right source (on each itteration of source). + /// Inline column of apply provider or not. + /// Sequence type. + /// Apply type. + /// instance. public static CompilableProvider Apply(this CompilableProvider source, ApplyParameter applyParameter, CompilableProvider right, bool isInlined, ApplySequenceType sequenceType, JoinType applyType) - { - return new ApplyProvider(applyParameter, source, right, isInlined, sequenceType, applyType); - } - - public static CompilableProvider Existence(this CompilableProvider source, string existenceColumnName) - { - return new ExistenceProvider(source, existenceColumnName); - } - + => new ApplyProvider(applyParameter, source, right, isInlined, sequenceType, applyType); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Name of the existance column. + /// instance. + public static CompilableProvider Existence(this CompilableProvider source, string existenceColumnName) => new ExistenceProvider(source, existenceColumnName); + + /// + /// Applies to the given source. + /// + /// /// Compilable provider. + /// Filter data. + /// Result column name. + /// Filtered columns + /// instance. public static CompilableProvider Include(this CompilableProvider source, Expression>> filterDataSource, string resultColumnName, int[] filteredColumns) - { - return new IncludeProvider( - source, IncludeAlgorithm.Auto, false, filterDataSource, resultColumnName, filteredColumns); - } - + => new IncludeProvider(source, IncludeAlgorithm.Auto, false, filterDataSource, resultColumnName, filteredColumns); + + /// + /// Applies to the given source. + /// + /// /// Compilable provider. + /// Include algorithm. + /// Filter data. + /// Result column name. + /// Filtered columns + /// instance. public static CompilableProvider Include(this CompilableProvider source, IncludeAlgorithm algorithm, Expression>> filterDataSource, string resultColumnName, int[] filteredColumns) - { - return new IncludeProvider(source, algorithm, false, filterDataSource, resultColumnName, filteredColumns); - } - + => new IncludeProvider(source, algorithm, false, filterDataSource, resultColumnName, filteredColumns); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Include algorithm. + /// Result column should be inlined or not. + /// Filter data. + /// Result column name. + /// Filtered columns + /// instance. public static CompilableProvider Include(this CompilableProvider source, IncludeAlgorithm algorithm, bool isInlined, Expression>> filterDataSource, string resultColumnName, int[] filteredColumns) - { - return new IncludeProvider(source, algorithm, isInlined, filterDataSource, resultColumnName, filteredColumns); - } - - public static CompilableProvider Intersect(this CompilableProvider left, CompilableProvider right) - { - return new IntersectProvider(left, right); - } - - public static CompilableProvider Except(this CompilableProvider left, CompilableProvider right) - { - return new ExceptProvider(left, right); - } - - public static CompilableProvider Concat(this CompilableProvider left, CompilableProvider right) - { - return new ConcatProvider(left, right); - } - - public static CompilableProvider Union(this CompilableProvider left, CompilableProvider right) - { - return new UnionProvider(left, right); - } - - public static CompilableProvider Lock(this CompilableProvider source, - LockMode lockMode, LockBehavior lockBehavior) - { - return new LockProvider(source, lockMode, lockBehavior); - } - - public static CompilableProvider Lock(this CompilableProvider source, - Func lockMode, Func lockBehavior) - { - return new LockProvider(source, lockMode, lockBehavior); - } - - public static CompilableProvider Tag(this CompilableProvider source, string tag) - { - return new TagProvider(source, tag); - } - - public static CompilableProvider MakeVoid(this CompilableProvider source) - { - return new VoidProvider(source.Header); - } + => new IncludeProvider(source, algorithm, isInlined, filterDataSource, resultColumnName, filteredColumns); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Compilable provider. + /// instance. + public static CompilableProvider Intersect(this CompilableProvider left, CompilableProvider right) => new IntersectProvider(left, right); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Compilable provider. + /// instance. + public static CompilableProvider Except(this CompilableProvider left, CompilableProvider right) => new ExceptProvider(left, right); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Compilable provider. + /// instance. + public static CompilableProvider Concat(this CompilableProvider left, CompilableProvider right) => new ConcatProvider(left, right); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Compilable provider. + /// instance. + public static CompilableProvider Union(this CompilableProvider left, CompilableProvider right) => new UnionProvider(left, right); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Lock mode. + /// Lock behavior + /// instance. + public static CompilableProvider Lock(this CompilableProvider source, LockMode lockMode, LockBehavior lockBehavior) + => new LockProvider(source, lockMode, lockBehavior); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Lock mode. + /// Lock behavior + /// instance. + public static CompilableProvider Lock(this CompilableProvider source, Func lockMode, Func lockBehavior) + => new LockProvider(source, lockMode, lockBehavior); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// Tag string + /// instance. + public static CompilableProvider Tag(this CompilableProvider source, string tag) => new TagProvider(source, tag); + + /// + /// Applies to the given source. + /// + /// Compilable provider. + /// instance. + public static CompilableProvider MakeVoid(this CompilableProvider source) => new VoidProvider(source.Header); internal static bool CheckIfLeftJoinPrefered(this CompilableProvider provider) { diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs index b9f4c2cc1..82046944d 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs @@ -59,7 +59,7 @@ private void ClonePartitionFuctionsAndSchemas(Catalog newCatalog, Catalog source } foreach (var partitionSchema in source.PartitionSchemas) - newCatalog.CreatePartitionSchema(partitionSchema.Name, pfMap[partitionSchema.PartitionFunction], partitionSchema.Filegroups.ToArray()); + _ = newCatalog.CreatePartitionSchema(partitionSchema.Name, pfMap[partitionSchema.PartitionFunction], partitionSchema.Filegroups.ToArray()); } private void CloneSchemas(Catalog newCatalog, Catalog source, Dictionary schemaMap) @@ -110,9 +110,9 @@ private void CloneDomains(Schema newSchema, Schema sourceSchema, Dictionary table.TableColumns[el.Column.Name]).Cast().ToArray(); + if (newTable is Table table) + return sourceIndex.Columns.SelectToArray(el => table.TableColumns[el.Column.Name] as DataTableColumn); - var view = newTable as View; - if (view!=null) - return sourceIndex.Columns.Select(el => view.ViewColumns[el.Column.Name]).Cast().ToArray(); + if (newTable is View view) + return sourceIndex.Columns.SelectToArray(el => view.ViewColumns[el.Column.Name] as DataTableColumn); throw new ArgumentOutOfRangeException("newTable", Strings.ExUnexpectedTypeOfParameter); } private DataTableColumn[] GetNonKeyColumns(DataTable newTable, Index sourceIndex) { - var table = newTable as Table; - if (table!=null) - return sourceIndex.NonkeyColumns.Select(el => table.TableColumns[el.Name]).Cast().ToArray(); + if (newTable is Table table) + return sourceIndex.NonkeyColumns.SelectToArray(el => table.TableColumns[el.Name] as DataTableColumn); - var view = newTable as View; - if (view!=null) - return sourceIndex.NonkeyColumns.Select(el => view.ViewColumns[el.Name]).Cast().ToArray(); + if (newTable is View view) + return sourceIndex.NonkeyColumns.SelectToArray(el => view.ViewColumns[el.Name] as DataTableColumn); throw new ArgumentOutOfRangeException("newTable", Strings.ExUnexpectedTypeOfParameter); } private void CloneTableConstraint(Table newTable, TableConstraint sourceConstraint) { - var checkConstraint = sourceConstraint as CheckConstraint; - if (checkConstraint!=null) { + if (sourceConstraint is CheckConstraint checkConstraint) { var c = newTable.CreateCheckConstraint(checkConstraint.Name, checkConstraint.Condition.Clone()); CopyDbName(c, checkConstraint); return; } - var defaultConstraint = sourceConstraint as DefaultConstraint; - if (defaultConstraint!=null) { + if (sourceConstraint is DefaultConstraint defaultConstraint) { var c = newTable.CreateDefaultConstraint(defaultConstraint.Name, newTable.TableColumns[defaultConstraint.Column.Name]); c.NameIsStale = defaultConstraint.NameIsStale; CopyDbName(c, defaultConstraint); @@ -349,13 +341,13 @@ private void CloneTableConstraint(Table newTable, TableConstraint sourceConstrai } return; } - throw new ArgumentOutOfRangeException("sourceConstraint", Strings.ExUnexpectedTypeOfParameter); + throw new ArgumentOutOfRangeException(nameof(sourceConstraint), Strings.ExUnexpectedTypeOfParameter); } private void ClonePartitionDescriptor(IPartitionable newObject, IPartitionable oldObject) { var oldPartitionDescriptor = oldObject.PartitionDescriptor; - if (oldPartitionDescriptor==null) + if (oldPartitionDescriptor is null) return; var column = GetPartitionColumn(newObject, oldPartitionDescriptor); @@ -369,41 +361,35 @@ private void ClonePartitionDescriptor(IPartitionable newObject, IPartitionable o private void ClonePartition(PartitionDescriptor newPartitionDescriptor, Partition oldPartition) { - var hashPartition = oldPartition as HashPartition; - if (hashPartition!=null) { + if (oldPartition is HashPartition hashPartition) { var newPartition = newPartitionDescriptor.CreateHashPartition(hashPartition.Filegroup); CopyDbName(oldPartition, newPartition); return; } - var listPartition = oldPartition as ListPartition; - if (listPartition!=null) { + if (oldPartition is ListPartition listPartition) { var newPartition = newPartitionDescriptor.CreateListPartition(listPartition.Filegroup, (string[]) listPartition.Values.Clone()); CopyDbName(oldPartition, newPartition); return; } - var rangePartition = oldPartition as RangePartition; - if (rangePartition!=null) { + if (oldPartition is RangePartition rangePartition) { var newPartition = newPartitionDescriptor.CreateRangePartition(rangePartition.Filegroup, rangePartition.Boundary); CopyDbName(oldPartition, newPartition); return; } - throw new ArgumentOutOfRangeException("oldPartition", Strings.ExUnexpectedTypeOfParameter); + throw new ArgumentOutOfRangeException(nameof(oldPartition), Strings.ExUnexpectedTypeOfParameter); } private TableColumn GetPartitionColumn(IPartitionable newObject, PartitionDescriptor oldPartitionDescriptor) { - var table = newObject as Table; - if (table!=null) + if (newObject is Table table) return table.TableColumns[oldPartitionDescriptor.Column.Name]; - var index = newObject as Index; - if (index!=null) { - var tableColumn = index.Columns[oldPartitionDescriptor.Column.Name].Column as TableColumn; - if (tableColumn!=null) + if (newObject is Index index) { + if (index.Columns[oldPartitionDescriptor.Column.Name].Column is TableColumn tableColumn) return tableColumn; throw new InvalidOperationException(Strings.ExUnableToGetTableColumnInstanceFromIndex); } - throw new ArgumentOutOfRangeException("newObject", Strings.ExUnexpectedTypeOfParameter); + throw new ArgumentOutOfRangeException(nameof(newObject), Strings.ExUnexpectedTypeOfParameter); } private void CopyDbName(Node newNode, Node sourceNode) diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs index 9eadf3925..a450f3830 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Xtensive.Collections; using Xtensive.Core; using Xtensive.Modelling; using Xtensive.Orm.Building.Builders; @@ -59,7 +58,7 @@ public StorageModel Run() { if (targetModel==null) { targetModel = new StorageModel(); - Visit(sourceModel); + _ = Visit(sourceModel); } return targetModel; @@ -69,10 +68,10 @@ public StorageModel Run() protected override IPathNode Visit(Orm.Model.Node node) { var indexInfo = node as IndexInfo; - if (indexInfo!=null && indexInfo.IsPrimary) { + if (indexInfo is not null && indexInfo.IsPrimary) { foreach (var table in CreateTables(indexInfo)) { currentTable = table; - var result = VisitPrimaryIndexInfo(indexInfo); + _ = VisitPrimaryIndexInfo(indexInfo); currentTable = null; } return null; @@ -85,24 +84,25 @@ protected override IPathNode Visit(Orm.Model.Node node) protected override StorageModel VisitDomainModel(DomainModel domainModel) { // Build tables, columns and primary indexes - foreach (var primaryIndex in domainModel.RealIndexes.Where(i => i.IsPrimary)) - Visit(primaryIndex); + foreach (var primaryIndex in domainModel.RealIndexes.Where(static i => i.IsPrimary)) + _ = Visit(primaryIndex); // Build full-text indexes foreach (var fullTextIndex in domainModel.FullTextIndexes) - Visit(fullTextIndex); + _ = Visit(fullTextIndex); // Build foreign keys var buildForeignKeys = BuildForeignKeys && providerInfo.Supports(ProviderFeatures.ForeignKeyConstraints); - if (buildForeignKeys) + if (buildForeignKeys) { foreach (var group in domainModel.Associations.Where(a => a.Ancestors.Count==0)) - Visit(group); + _ = Visit(group); + } // Build keys and sequences foreach (KeyInfo keyInfo in domainModel.Hierarchies.Select(h => h.Key)) - Visit(keyInfo); + _ = Visit(keyInfo); var buildHierarchyForeignKeys = BuildHierarchyForeignKeys && providerInfo.Supports(ProviderFeatures.ForeignKeyConstraints); @@ -139,7 +139,7 @@ protected override StorageModel VisitDomainModel(DomainModel domainModel) var storageReferencingIndex = FindIndex( referencingTable, referencingIndex.KeyColumns.Select(static ci => ci.Key.Name).ToArray()); - string foreignKeyName = nameBuilder.BuildHierarchyForeignKeyName(referencingIndex.ReflectedType, referencedIndex.ReflectedType); + var foreignKeyName = nameBuilder.BuildHierarchyForeignKeyName(referencingIndex.ReflectedType, referencedIndex.ReflectedType); CreateHierarchyForeignKey(referencingTable, referencedTable, storageReferencingIndex, foreignKeyName); } @@ -154,9 +154,9 @@ private void VisitIndexInfo(IndexInfo primaryIndex, IndexInfo index) var isClustered = index.IsClustered && providerInfo.Supports(ProviderFeatures.ClusteredIndexes); secondaryIndex.IsClustered = isClustered; foreach (KeyValuePair pair in index.KeyColumns) { - string columName = GetPrimaryIndexColumnName(primaryIndex, pair.Key, index); - StorageColumnInfo column = table.Columns[columName]; - new KeyColumnRef(secondaryIndex, column, + var columName = GetPrimaryIndexColumnName(primaryIndex, pair.Key, index); + var column = table.Columns[columName]; + _ = new KeyColumnRef(secondaryIndex, column, providerInfo.Supports(ProviderFeatures.KeyColumnSortOrder) ? pair.Value : Direction.Positive); @@ -167,9 +167,9 @@ private void VisitIndexInfo(IndexInfo primaryIndex, IndexInfo index) // and simply ignore included columns for clustered indexes. if (providerInfo.Supports(ProviderFeatures.IncludedColumns) && !isClustered) { foreach (var includedColumn in index.IncludedColumns) { - string columName = GetPrimaryIndexColumnName(primaryIndex, includedColumn, index); - StorageColumnInfo column = table.Columns[columName]; - new IncludedColumnRef(secondaryIndex, column); + var columName = GetPrimaryIndexColumnName(primaryIndex, includedColumn, index); + var column = table.Columns[columName]; + _ = new IncludedColumnRef(secondaryIndex, column); } } secondaryIndex.PopulatePrimaryKeyColumns(); @@ -214,7 +214,7 @@ protected override IPathNode VisitAssociationInfo(AssociationInfo association) if (association.OnTargetRemove==OnRemoveAction.None) return null; - if (association.AuxiliaryType==null && !association.OwnerField.IsEntitySet) { + if (association.AuxiliaryType is null && !association.OwnerField.IsEntitySet) { if (!IsValidForeignKeyTarget(association.TargetType)) return null; if (association.OwnerType.IsInterface) { @@ -229,7 +229,7 @@ protected override IPathNode VisitAssociationInfo(AssociationInfo association) } } } - else if (association.AuxiliaryType!=null && association.IsMaster) { + else if (association.AuxiliaryType is not null && association.IsMaster) { ProcessIndirectAssociation(association.AuxiliaryType); } return null; @@ -238,7 +238,7 @@ protected override IPathNode VisitAssociationInfo(AssociationInfo association) /// protected override StorageSequenceInfo VisitKeyInfo(KeyInfo keyInfo) { - if (keyInfo.Sequence==null || !keyInfo.IsFirstAmongSimilarKeys) + if (keyInfo.Sequence is null || !keyInfo.IsFirstAmongSimilarKeys) return null; var sequenceInfo = keyInfo.Sequence; long increment = 1; @@ -274,12 +274,12 @@ protected override StorageFullTextIndexInfo VisitFullTextIndexInfo(FullTextIndex var column = table.Columns[fullTextColumn.Name]; string typeColumn = null; if(providerInfo.Supports(ProviderFeatures.FullTextColumnDataTypeSpecification)) { - if (fullTextColumn.TypeColumn!=null) + if (fullTextColumn.TypeColumn is not null) typeColumn = table.Columns[fullTextColumn.TypeColumn.Name].Name; } else UpgradeLog.Warning(nameof(Strings.LogSpecificationOfTypeColumnForFulltextColumnIsNotSupportedByCurrentStorageIgnoringTypeColumnSpecificationForColumnX), fullTextColumn.Column.Name); - new FullTextColumnRef(ftIndex, column, fullTextColumn.Configuration, typeColumn); + _ = new FullTextColumnRef(ftIndex, column, fullTextColumn.Configuration, typeColumn); } ftIndex.FullTextCatalog = @@ -296,18 +296,18 @@ protected override StorageFullTextIndexInfo VisitFullTextIndexInfo(FullTextIndex private PrimaryIndexInfo VisitPrimaryIndexInfo(IndexInfo index) { foreach (var column in index.Columns) - Visit(column); + _ = Visit(column); // Support for mysql as primary indexes there always have name 'PRIMARY' - string name = providerInfo.ConstantPrimaryIndexName; + var name = providerInfo.ConstantPrimaryIndexName; if (string.IsNullOrEmpty(name)) name = index.MappingName; var primaryIndex = new PrimaryIndexInfo(currentTable, name); - foreach (KeyValuePair pair in index.KeyColumns) { - string columName = GetPrimaryIndexColumnName(index, pair.Key, index); + foreach (var pair in index.KeyColumns) { + var columName = GetPrimaryIndexColumnName(index, pair.Key, index); var column = currentTable.Columns[columName]; - new KeyColumnRef(primaryIndex, column, + _ = new KeyColumnRef(primaryIndex, column, providerInfo.Supports(ProviderFeatures.KeyColumnSortOrder) ? pair.Value : Direction.Positive); @@ -315,7 +315,7 @@ private PrimaryIndexInfo VisitPrimaryIndexInfo(IndexInfo index) primaryIndex.PopulateValueColumns(); primaryIndex.IsClustered = index.IsClustered && providerInfo.Supports(ProviderFeatures.ClusteredIndexes); - foreach (var secondaryIndex in index.ReflectedType.Indexes.Where(i => i.IsSecondary && !i.IsVirtual)) + foreach (var secondaryIndex in index.ReflectedType.Indexes.Where(static i => i.IsSecondary && !i.IsVirtual)) VisitIndexInfo(index, secondaryIndex); return primaryIndex; } @@ -378,7 +378,7 @@ protected override IPathNode VisitIndexInfo(IndexInfo index) private object GetColumnDefaultValue(ColumnInfo column, StorageTypeInfo typeInfo) { - if (column.DefaultValue!=null) + if (column.DefaultValue is not null) return column.DefaultValue; if (column.IsNullable) @@ -423,7 +423,7 @@ static string ColumnNameSelector(KeyColumnRef cr) private TableInfo GetTable(TypeInfo type) { - if (type.Hierarchy==null || type.Hierarchy.InheritanceSchema!=InheritanceSchema.SingleTable) { + if (type.Hierarchy is null || type.Hierarchy.InheritanceSchema!=InheritanceSchema.SingleTable) { var name = resolver.GetNodeName(type); return targetModel.Tables.FirstOrDefault(t => t.Name==name); } @@ -454,13 +454,12 @@ private static void CreateReferenceForeignKey(TableInfo referencingTable, TableI OnUpdateAction = ReferentialAction.None }; foreach (var foreignColumn in foreignColumns) - new ForeignKeyColumnRef(foreignKey, foreignColumn); + _ = new ForeignKeyColumnRef(foreignKey, foreignColumn); } private static void CreateHierarchyForeignKey(TableInfo referencingTable, TableInfo referencedTable, StorageIndexInfo referencingIndex, string foreignKeyName) { - var foreignKey = new ForeignKeyInfo(referencingTable, foreignKeyName) - { + var foreignKey = new ForeignKeyInfo(referencingTable, foreignKeyName) { PrimaryKey = referencedTable.PrimaryIndex, OnRemoveAction = ReferentialAction.None, OnUpdateAction = ReferentialAction.None @@ -479,7 +478,7 @@ private void ProcessDirectAssociation(TypeInfo ownerType, FieldInfo ownerField, return; var referencingTable = GetTable(ownerType); var referencedTable = GetTable(targetType); - if (referencedTable==null || referencingTable==null) + if (referencedTable is null || referencingTable is null) return; var foreignKeyName = nameBuilder.BuildReferenceForeignKeyName(ownerType, ownerField, targetType); CreateReferenceForeignKey(referencingTable, referencedTable, ownerField, foreignKeyName); @@ -488,14 +487,14 @@ private void ProcessDirectAssociation(TypeInfo ownerType, FieldInfo ownerField, private void ProcessIndirectAssociation(TypeInfo auxiliaryType) { var referencingTable = GetTable(auxiliaryType); - if (referencingTable==null) + if (referencingTable is null) return; - foreach (var field in auxiliaryType.Fields.Where(fieldInfo => fieldInfo.IsEntity)) { + foreach (var field in auxiliaryType.Fields.Where(static fieldInfo => fieldInfo.IsEntity)) { var referencedType = sourceModel.Types[field.ValueType]; if (!IsValidForeignKeyTarget(referencedType) || !AreMappedToSameDatabase(auxiliaryType, referencedType)) continue; var referencedTable = GetTable(referencedType); - if (referencedTable==null) + if (referencedTable is null) continue; var foreignKeyName = nameBuilder.BuildReferenceForeignKeyName(auxiliaryType, field, referencedType); CreateReferenceForeignKey(referencingTable, referencedTable, field, foreignKeyName); @@ -509,17 +508,17 @@ private bool AreMappedToSameDatabase(TypeInfo type1, TypeInfo type2) private IEnumerable GetForeignKeyOwners(TypeInfo type) { - if (type.Hierarchy == null) + if (type.Hierarchy is null) yield break; yield return type; if (type.Hierarchy.InheritanceSchema == InheritanceSchema.ConcreteTable) - foreach (var descendant in type.AllDescendants.Where(static descendant => descendant.Indexes.PrimaryIndex != null)) + foreach (var descendant in type.AllDescendants.Where(static descendant => descendant.Indexes.PrimaryIndex is not null)) yield return descendant; } private static bool IsValidForeignKeyTarget(TypeInfo targetType) { - return targetType.Hierarchy != null && (targetType.Hierarchy.InheritanceSchema != InheritanceSchema.ConcreteTable || targetType.IsLeaf); + return targetType.Hierarchy is not null && (targetType.Hierarchy.InheritanceSchema != InheritanceSchema.ConcreteTable || targetType.IsLeaf); } #endregion @@ -536,7 +535,7 @@ private SecondaryIndexInfo CreateSecondaryIndex(TableInfo owningTable, string in { var index = new SecondaryIndexInfo(owningTable, indexName); - if (originalModelIndex.Filter!=null) { + if (originalModelIndex.Filter is not null) { if (providerInfo.Supports(ProviderFeatures.PartialIndexes)) index.Filter = new PartialIndexFilterInfo(compiler.Compile(handlers, originalModelIndex)); else @@ -575,7 +574,7 @@ private StoredFieldInfo GetExtractedStoredColumn(ColumnInfo column) var currentType = CurrentModelTypes.GetValueOrDefault(typeName); if(currentType==null) throw new InvalidOperationException(string.Format(Strings.ExUnableToFindTypeXInCurrentModel, typeName)); - var currentField = currentType.Fields.Flatten(f=>f.Fields, info => { }, true).FirstOrDefault(el => el.MappingName==column.Field.MappingName); + var currentField = currentType.Fields.Flatten(static f => f.Fields, info => { }, true).FirstOrDefault(el => el.MappingName==column.Field.MappingName); if (currentField==null) throw new InvalidOperationException(string.Format(Strings.UnableToFindColumnXInTypeYOfCurrentModel, column.Field.MappingName, typeName)); @@ -587,7 +586,7 @@ private StorageTypeInfo GetStorageTypeInfo(StorageTypeInfo typeInfo, StorageColu { if (!isUpgradingStage) return typeInfo; - if (extractedConnectedColumn==null) + if (extractedConnectedColumn is null) return typeInfo; var extractedTypeInfo = extractedConnectedColumn.Type; if (IsOnlyNullableChanged(typeInfo, extractedTypeInfo)) { diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs index e85ecab9a..65bcce61e 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlModelConverter.cs @@ -42,10 +42,11 @@ internal sealed class SqlModelConverter : SqlModelVisitor /// The storage model. public StorageModel Run() { - if (targetModel==null) { + if (targetModel is null) { targetModel = new StorageModel(); - foreach (var catalog in sourceModel.Catalogs) - VisitCatalog(catalog); + foreach (var catalog in sourceModel.Catalogs) { + _ = VisitCatalog(catalog); + } } return targetModel; @@ -58,14 +59,14 @@ protected override IPathNode VisitSchema(Schema schema) { // Build tables, columns and indexes. foreach (var table in schema.Tables) - Visit(table); + _ = Visit(table); // Build foreign keys. var foreignKeys = schema.Tables.SelectMany(t => t.TableConstraints.OfType()); foreach (var foreignKey in foreignKeys) - Visit(foreignKey); + _ = Visit(foreignKey); foreach (var sequence in schema.Sequences) - VisitSequence(sequence); + _ = VisitSequence(sequence); return null; } @@ -74,8 +75,7 @@ protected override IPathNode VisitSchema(Schema schema) protected override IPathNode Visit(Node node) { if (!providerInfo.Supports(ProviderFeatures.Sequences)) { - var table = node as Table; - if (table!=null && IsGeneratorTable(table)) + if (node is Table table && IsGeneratorTable(table)) return VisitGeneratorTable(table); } @@ -90,15 +90,15 @@ protected override TableInfo VisitTable(Table table) currentTable = tableInfo; foreach (var column in table.TableColumns) - Visit(column); + _ = Visit(column); var primaryKey = table.TableConstraints .SingleOrDefault(constraint => constraint is PrimaryKey); - if (primaryKey!=null) - Visit(primaryKey); + if (primaryKey is not null) + _ = Visit(primaryKey); foreach (var index in table.Indexes) - Visit(index); + _ = Visit(index); currentTable = null; @@ -131,8 +131,9 @@ protected override ForeignKeyInfo VisitForeignKey(ForeignKey key) var referencedTable = targetModel.Tables[resolver.GetNodeName(key.ReferencedTable)]; foreignKeyInfo.PrimaryKey = referencedTable.PrimaryIndex; - foreach (var column in referencingColumns) - new ForeignKeyColumnRef(foreignKeyInfo, column); + foreach (var column in referencingColumns) { + _ = new ForeignKeyColumnRef(foreignKeyInfo, column); + } return foreignKeyInfo; } @@ -141,11 +142,11 @@ protected override ForeignKeyInfo VisitForeignKey(ForeignKey key) protected override PrimaryIndexInfo VisitPrimaryKey(PrimaryKey key) { var tableInfo = currentTable; - var primaryIndexInfo = new PrimaryIndexInfo(tableInfo, key.Name) {IsClustered = key.IsClustered}; + var primaryIndexInfo = new PrimaryIndexInfo(tableInfo, key.Name) { IsClustered = key.IsClustered }; foreach (var keyColumn in key.Columns) - new KeyColumnRef(primaryIndexInfo, tableInfo.Columns[keyColumn.Name], - Direction.Positive); + _ = new KeyColumnRef(primaryIndexInfo, tableInfo.Columns[keyColumn.Name]); + // TODO: Get direction for key columns primaryIndexInfo.PopulateValueColumns(); @@ -165,10 +166,11 @@ protected override StorageFullTextIndexInfo VisitFullTextIndex(FullTextIndex ind }; foreach (var column in index.Columns) { var columnInfo = tableInfo.Columns[column.Column.Name]; - string typeColumn = null; - if (column.TypeColumn!=null) - typeColumn = tableInfo.Columns[column.TypeColumn.Name].Name; - new FullTextColumnRef(ftIndex, columnInfo, column.Languages.Single().Name, typeColumn); + var typeColumnName = (column.TypeColumn is not null) + ? tableInfo.Columns[column.TypeColumn.Name].Name + : null; + + _ = new FullTextColumnRef(ftIndex, columnInfo, column.Languages.Single().Name, typeColumnName); } return ftIndex; } @@ -185,13 +187,13 @@ protected override SecondaryIndexInfo VisitIndex(Index index) foreach (var keyColumn in index.Columns) { var columnInfo = tableInfo.Columns[keyColumn.Column.Name]; - new KeyColumnRef(secondaryIndexInfo, + _ = new KeyColumnRef(secondaryIndexInfo, columnInfo, keyColumn.Ascending ? Direction.Positive : Direction.Negative); } foreach (var valueColumn in index.NonkeyColumns) { var columnInfo = tableInfo.Columns[valueColumn.Name]; - new IncludedColumnRef(secondaryIndexInfo, columnInfo); + _ = new IncludedColumnRef(secondaryIndexInfo, columnInfo); } secondaryIndexInfo.PopulatePrimaryKeyColumns(); @@ -203,7 +205,7 @@ private PartialIndexFilterInfo GetFilter(Index index) { var tableName = resolver.GetNodeName(index.DataTable); var result = partialIndexMap.FindIndex(tableName, index.DbName); - if (result==null) + if (result is null) return null; return new PartialIndexFilterInfo(result.Filter); } @@ -284,20 +286,14 @@ private StorageTypeInfo ExtractType(TableColumn column) /// Converted action. private ReferentialAction ConvertReferentialAction(Sql.ReferentialAction toConvert) { - switch (toConvert) { - case Sql.ReferentialAction.NoAction: - return ReferentialAction.None; - case Sql.ReferentialAction.Restrict: - return ReferentialAction.Restrict; - case Sql.ReferentialAction.Cascade: - return ReferentialAction.Cascade; - case Sql.ReferentialAction.SetNull: - return ReferentialAction.Clear; - case Sql.ReferentialAction.SetDefault: - return ReferentialAction.Default; - default: - return ReferentialAction.Default; - } + return toConvert switch { + Sql.ReferentialAction.NoAction => ReferentialAction.None, + Sql.ReferentialAction.Restrict => ReferentialAction.Restrict, + Sql.ReferentialAction.Cascade => ReferentialAction.Cascade, + Sql.ReferentialAction.SetNull => ReferentialAction.Clear, + Sql.ReferentialAction.SetDefault => ReferentialAction.Default, + _ => ReferentialAction.Default, + }; } /// @@ -307,18 +303,13 @@ private ReferentialAction ConvertReferentialAction(Sql.ReferentialAction toConve /// Converted mode. private FullTextChangeTrackingMode ConvertChangeTrackingMode(ChangeTrackingMode toConvert) { - switch (toConvert) { - case ChangeTrackingMode.Auto: - return FullTextChangeTrackingMode.Auto; - case ChangeTrackingMode.Manual: - return FullTextChangeTrackingMode.Manual; - case ChangeTrackingMode.Off: - return FullTextChangeTrackingMode.Off; - case ChangeTrackingMode.OffWithNoPopulation: - return FullTextChangeTrackingMode.OffWithNoPopulation; - default: - return FullTextChangeTrackingMode.Default; - } + return toConvert switch { + ChangeTrackingMode.Auto => FullTextChangeTrackingMode.Auto, + ChangeTrackingMode.Manual => FullTextChangeTrackingMode.Manual, + ChangeTrackingMode.Off => FullTextChangeTrackingMode.Off, + ChangeTrackingMode.OffWithNoPopulation => FullTextChangeTrackingMode.OffWithNoPopulation, + _ => FullTextChangeTrackingMode.Default, + }; } /// @@ -333,7 +324,7 @@ private bool IsGeneratorTable(Table table) { int columnNumber = providerInfo.Supports(ProviderFeatures.InsertDefaultValues) ? 1 : 2; return table.TableColumns.Count==columnNumber && - table.TableColumns[0].SequenceDescriptor!=null; + table.TableColumns[0].SequenceDescriptor is not null; } From 4139e260e024f93e34501f29354c450ca0eb79eb Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 27 Feb 2026 19:08:18 +0500 Subject: [PATCH 18/55] DataReader correcly handles disposal of preloaded tuple collection --- .../Orm/Providers/CommandProcessing/DataReader.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/DataReader.cs b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/DataReader.cs index 410e31b2e..9cc78e098 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/DataReader.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/DataReader.cs @@ -95,7 +95,16 @@ public async ValueTask DisposeAsync() await command.DisposeAsync().ConfigureAwait(false); } else { - await ((IAsyncEnumerator) source).DisposeAsync().ConfigureAwait(false); + if (source is IAsyncEnumerator asyncSource) { + // true async enumerable source + await asyncSource.DisposeAsync().ConfigureAwait(false); + } + else { + // preloaded collection of elements, + // like in case of delayed query which has already been read from database + // or greedy enumeration + ((IEnumerator) source).Dispose(); + } } } From b78928335ff8651c6da09e8c2325908af0671a2a Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Mon, 2 Mar 2026 13:41:53 +0500 Subject: [PATCH 19/55] Improve changlog --- ChangeLog/7.2.1-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog/7.2.1-dev.txt b/ChangeLog/7.2.1-dev.txt index d1073f9ad..436cde815 100644 --- a/ChangeLog/7.2.1-dev.txt +++ b/ChangeLog/7.2.1-dev.txt @@ -1,3 +1,4 @@ [main] Added Query.SingleAsync()/SingleOrDefaultAsync and QueryEndpoint.SingleAsync()/SingleOrDefaultAsync methods [main] Addressed issue of not disposing IAsyncEnumerator which caused query being open [main] Addressed issue of overwriting exception on attempt to rollback the transaction of Domain upgrade if commit operation failed +[postgresql] Update Npgsql to 9.0.4 From 454b937716caee4d4debcd57eef36887bf5ef948 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Tue, 3 Mar 2026 16:42:21 +0500 Subject: [PATCH 20/55] Fixed certain issues, appeared during changes in branch --- Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs | 4 +--- Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityContainer.cs | 3 --- Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs | 1 + Orm/Xtensive.Orm/Orm/Linq/WellknownMembers.Queryable.cs | 1 + .../Orm/Rse/Providers/Compilable/FreeTextProvider.cs | 2 +- Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs | 2 +- Orm/Xtensive.Orm/Orm/VersionCapturer.cs | 3 +-- Orm/Xtensive.Orm/Reflection/WellKnown.QueryableExtensions.cs | 1 + Orm/Xtensive.Orm/Tuples/Transform/MapTransform.cs | 1 + 9 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs index 5b72cabfe..496360e2c 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs @@ -119,8 +119,6 @@ public IReadOnlyList GetUpgradeSequence(Difference difference, HintS /// Upgrade sequence validation has failed. public IReadOnlyList GetUpgradeSequence(Difference difference, HintSet hints, IComparer comparer) { - ArgumentNullException.ThrowIfNull(hints, nameof(hints)); - ArgumentNullException.ThrowIfNull(comparer, nameof(comparer)); if (difference == null) { return Array.Empty(); } @@ -129,7 +127,7 @@ public IReadOnlyList GetUpgradeSequence(Difference difference, HintS SourceModel = (IModel) difference.Source; TargetModel = (IModel) difference.Target; Hints = hints ?? new HintSet(SourceModel, TargetModel); - Comparer = comparer; + Comparer = comparer ?? throw new ArgumentNullException(nameof(comparer)); if (Hints.SourceModel != SourceModel) { throw new ArgumentOutOfRangeException("hints.SourceModel"); } diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityContainer.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityContainer.cs index af532fa3a..c77520703 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityContainer.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityContainer.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using Xtensive.Core; using Xtensive.Orm.Model; using Xtensive.Tuples; @@ -17,8 +16,6 @@ namespace Xtensive.Orm.Internals.Prefetch [Serializable] internal abstract class EntityContainer { - private static readonly Parameter seekParameter = new Parameter(WellKnown.KeyFieldName); - private SortedDictionary columns; protected readonly PrefetchManager Manager; diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs index 9f51a7ba1..b43452c27 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs @@ -506,6 +506,7 @@ protected override Expression VisitMethodCall(MethodCallExpression mc) if (methodDeclaringType == typeof(QueryableExtensions)) { return methodName switch { Reflection.WellKnown.QueryableExtensions.LeftJoin => VisitLeftJoin(mc), + Reflection.WellKnown.QueryableExtensions.LeftJoinEx => VisitLeftJoin(mc), Reflection.WellKnown.QueryableExtensions.In => VisitIn(mc), Reflection.WellKnown.QueryableExtensions.Lock => VisitLock(mc), Reflection.WellKnown.QueryableExtensions.Take => VisitTake(mc.Arguments[0], mc.Arguments[1]), diff --git a/Orm/Xtensive.Orm/Orm/Linq/WellknownMembers.Queryable.cs b/Orm/Xtensive.Orm/Orm/Linq/WellknownMembers.Queryable.cs index 1c91d3c03..3f289e0ea 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/WellknownMembers.Queryable.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/WellknownMembers.Queryable.cs @@ -80,6 +80,7 @@ public static class Queryable // Queryable extensions public static readonly MethodInfo ExtensionCount = GetQueryableExtensionsMethod(nameof(QueryableExtensions.Count), 0, 1); public static readonly MethodInfo ExtensionLeftJoin = GetQueryableExtensionsMethod(nameof(QueryableExtensions.LeftJoin), 4, 5); + public static readonly MethodInfo ExtensionLeftJoinEx = GetQueryableExtensionsMethod(nameof(QueryableExtensions.LeftJoinEx), 4, 5); public static readonly MethodInfo ExtensionLock = GetQueryableExtensionsMethod(nameof(QueryableExtensions.Lock), 1, 3); public static readonly MethodInfo ExtensionTake = GetQueryableExtensionsMethod(nameof(QueryableExtensions.Take), 1, 2); public static readonly MethodInfo ExtensionSkip = GetQueryableExtensionsMethod(nameof(QueryableExtensions.Skip), 1, 2); diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/FreeTextProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/FreeTextProvider.cs index 7674c408f..3d492016c 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/FreeTextProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/FreeTextProvider.cs @@ -49,7 +49,7 @@ public FreeTextProvider( { SearchCriteria = searchCriteria ?? throw new ArgumentNullException(nameof(searchCriteria)); FullFeatured = fullFeatured; - TopN = topN ?? throw new ArgumentNullException(nameof(topN)); + TopN = topN; PrimaryIndex = new IndexInfoRef(index.PrimaryIndex); if (FullFeatured) { var primaryIndexRecordsetHeader = index.PrimaryIndex.ReflectedType.Indexes.PrimaryIndex.GetRecordSetHeader(); diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs index 0e84154af..2bd67e6ba 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs @@ -56,7 +56,7 @@ protected override void ValidateState() throw new ValidationException(Strings.ExPrimaryKeyColumnCanNotBeNullable, Path); }); - var values = ValueColumns.Select(valueRef => valueRef.Value).ToArray(KeyColumns.Count); + var values = ValueColumns.Select(valueRef => valueRef.Value).ToArray(ValueColumns.Count); var allCount = keys.Length + values.Length; if (allCount!=tableColumns.Count) ea.Execute(() => { diff --git a/Orm/Xtensive.Orm/Orm/VersionCapturer.cs b/Orm/Xtensive.Orm/Orm/VersionCapturer.cs index 2364f377d..d0826d8eb 100644 --- a/Orm/Xtensive.Orm/Orm/VersionCapturer.cs +++ b/Orm/Xtensive.Orm/Orm/VersionCapturer.cs @@ -130,8 +130,7 @@ public static VersionCapturer Attach(Session session, VersionSet versions) private VersionCapturer(Session session, VersionSet versions) : base(session) { - ArgumentNullException.ThrowIfNull(versions); - Versions = versions; + Versions = versions ?? throw new ArgumentNullException(nameof(versions)); AttachEventHandlers(); } diff --git a/Orm/Xtensive.Orm/Reflection/WellKnown.QueryableExtensions.cs b/Orm/Xtensive.Orm/Reflection/WellKnown.QueryableExtensions.cs index 6583e68d7..1a345db95 100644 --- a/Orm/Xtensive.Orm/Reflection/WellKnown.QueryableExtensions.cs +++ b/Orm/Xtensive.Orm/Reflection/WellKnown.QueryableExtensions.cs @@ -13,6 +13,7 @@ public static class QueryableExtensions { public const string Count = nameof(Orm.QueryableExtensions.Count); public const string LeftJoin = nameof(Orm.QueryableExtensions.LeftJoin); + public const string LeftJoinEx = nameof(Orm.QueryableExtensions.LeftJoinEx); public const string Lock = nameof(Orm.QueryableExtensions.Lock); public const string Take = nameof(Orm.QueryableExtensions.Take); public const string Skip = nameof(Orm.QueryableExtensions.Skip); diff --git a/Orm/Xtensive.Orm/Tuples/Transform/MapTransform.cs b/Orm/Xtensive.Orm/Tuples/Transform/MapTransform.cs index 3fe1c110a..afc03c40e 100644 --- a/Orm/Xtensive.Orm/Tuples/Transform/MapTransform.cs +++ b/Orm/Xtensive.Orm/Tuples/Transform/MapTransform.cs @@ -294,6 +294,7 @@ public MapTransform(bool isReadOnly, TupleDescriptor descriptor, IReadOnlyList Date: Wed, 4 Mar 2026 16:08:26 +0500 Subject: [PATCH 21/55] ConstructorExpression: No many clones of empty collection --- .../Linq/Expressions/ConstructorExpression.cs | 31 +++++++++++++++---- .../Visitors/ExtendedExpressionReplacer.cs | 5 +-- .../Linq/Expressions/Visitors/OwnerRemover.cs | 21 +++++++++++-- .../Orm/Linq/Translator.Expressions.cs | 6 ++-- 4 files changed, 51 insertions(+), 12 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs index 8c3c08637..963486d0e 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs @@ -14,6 +14,7 @@ using Xtensive.Orm.Linq.Expressions; using Xtensive.Orm.Linq.Expressions.Visitors; using System.Linq; +using System.Net.Http.Headers; namespace Xtensive.Orm.Linq { @@ -33,24 +34,30 @@ public Expression BindParameter(ParameterExpression parameter, Dictionary genericBinder = e => GenericExpressionVisitor.Process(e, mapped => mapped.BindParameter(parameter, processedExpressions)); + return new ConstructorExpression( Type, Bindings.ToDictionary(kvp => kvp.Key, kvp => genericBinder(kvp.Value), Bindings.Count), NativeBindings.ToDictionary(kvp=>kvp.Key, kvp => genericBinder(kvp.Value), NativeBindings.Count), Constructor, - ConstructorArguments.Select(genericBinder).ToArray()); + ReferenceEquals(ConstructorArguments, Array.Empty()) + ? ConstructorArguments + : ConstructorArguments.Select(genericBinder).ToArray()); } public Expression RemoveOuterParameter(Dictionary processedExpressions) { Func genericRemover = e => GenericExpressionVisitor.Process(e, mapped => mapped.RemoveOuterParameter(processedExpressions)); + var result = new ConstructorExpression( Type, Bindings.ToDictionary(kvp => kvp.Key, kvp => genericRemover(kvp.Value)), NativeBindings = NativeBindings.ToDictionary(kvp => kvp.Key, kvp => genericRemover(kvp.Value)), Constructor, - ConstructorArguments.Select(genericRemover).ToArray()); + ReferenceEquals(ConstructorArguments, Array.Empty()) + ? ConstructorArguments + : ConstructorArguments.Select(genericRemover).ToArray()); return result; } @@ -62,8 +69,11 @@ public Expression Remap(int offset, Dictionary processed return mapped.Remap(offset, new Dictionary()); return (Expression) mapped; }; + var newBindings = Bindings.ToDictionary(kvp => kvp.Key, kvp => GenericExpressionVisitor.Process(kvp.Value, remapper)); - var newConstructorArguments = ConstructorArguments.Select(arg => GenericExpressionVisitor.Process(arg, remapper)); + var newConstructorArguments = ReferenceEquals(ConstructorArguments, Array.Empty()) + ? ConstructorArguments + : ConstructorArguments.Select(arg => GenericExpressionVisitor.Process(arg, remapper)); var newNativeBindings = NativeBindings.ToDictionary(kvp => kvp.Key, kvp => GenericExpressionVisitor.Process(kvp.Value, remapper)); var result = new ConstructorExpression( Type, @@ -82,18 +92,27 @@ public Expression Remap(IReadOnlyList map, Dictionary()); return (Expression) mapped; }; + var newBindings = Bindings.ToDictionary(kvp => kvp.Key, kvp => GenericExpressionVisitor.Process(kvp.Value, remapper)); - var newConstructorArguments = ConstructorArguments.Select(arg => GenericExpressionVisitor.Process(arg, remapper)); + var newConstructorArguments = ReferenceEquals(ConstructorArguments, Array.Empty()) + ? ConstructorArguments + : ConstructorArguments.Select(arg => GenericExpressionVisitor.Process(arg, remapper)); var newNativeBindings = NativeBindings.ToDictionary(kvp => kvp.Key, kvp => GenericExpressionVisitor.Process(kvp.Value, remapper)); return new ConstructorExpression(Type, newBindings, newNativeBindings, Constructor, newConstructorArguments); } - public ConstructorExpression(Type type, Dictionary bindings, Dictionary nativeBindings, ConstructorInfo constructor, IEnumerable constructorArguments) + public ConstructorExpression(Type type, + Dictionary bindings, + Dictionary nativeBindings, + ConstructorInfo constructor, + IEnumerable constructorArguments) : base(ExtendedExpressionType.Constructor, type, null, false) { Bindings = bindings ?? new Dictionary(); NativeBindings = nativeBindings; - ConstructorArguments = constructorArguments ?? Enumerable.Empty(); + // consistently use keep empty array instead of any other empty collection, + // there are checks that help to not instanciate collections + ConstructorArguments = constructorArguments ?? Array.Empty(); Constructor = constructor; } } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs index b2af570ac..97001f39d 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Linq.Expressions; using System.Reflection; using Xtensive.Orm.Rse.Providers; @@ -115,7 +116,7 @@ protected override ColumnExpression VisitColumnExpression(ColumnExpression expre protected override ConstructorExpression VisitConstructorExpression(ConstructorExpression expression) { - var arguments = new List(); + IList arguments = new List(); var bindings = new Dictionary(expression.Bindings.Count); var nativeBindings = new Dictionary(expression.NativeBindings.Count); bool recreate = false; @@ -144,7 +145,7 @@ protected override ConstructorExpression VisitConstructorExpression(ConstructorE bindings, nativeBindings, expression.Constructor, - arguments); + arguments.Count > 0 ? arguments : Array.Empty()); } protected override MarkerExpression VisitMarker(MarkerExpression expression) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs index 6b36a68a7..a6d5d2950 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs @@ -4,6 +4,8 @@ // Created by: Alexis Kochetov // Created: 2009.05.26 +using System; +using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using Xtensive.Core; @@ -45,8 +47,23 @@ protected override KeyExpression VisitKeyExpression(KeyExpression expression) protected override ConstructorExpression VisitConstructorExpression(ConstructorExpression expression) { - var oldConstructorArguments = expression.ConstructorArguments.ToList(); - var newConstructorArguments = VisitExpressionList(oldConstructorArguments); + IReadOnlyList oldConstructorArguments; + IReadOnlyList newConstructorArguments; + + if (ReferenceEquals(expression.ConstructorArguments, Array.Empty())) { + oldConstructorArguments = newConstructorArguments = Array.Empty(); + } + else if (expression.ConstructorArguments is IReadOnlyList argsAsList) { + oldConstructorArguments = argsAsList; + newConstructorArguments = VisitExpressionList(argsAsList); // creates a copy internally + } + else { + oldConstructorArguments = expression.ConstructorArguments.ToList(); + if (oldConstructorArguments.Count == 0) + oldConstructorArguments = newConstructorArguments = Array.Empty(); + else + newConstructorArguments = VisitExpressionList(oldConstructorArguments); + } var oldBindings = expression.Bindings.SelectToList(b => b.Value); var newBindings = VisitExpressionList(oldBindings); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs index b43452c27..507cb8aa7 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs @@ -690,9 +690,11 @@ protected override Expression VisitNew(NewExpression newExpression) // ReSharper restore ConditionIsAlwaysTrueOrFalse // ReSharper restore HeuristicUnreachableCode - var arguments = VisitNewExpressionArguments(newExpression); + IList arguments = VisitNewExpressionArguments(newExpression); + if (arguments.Count == 0) + arguments = Array.Empty(); if (newExpression.IsAnonymousConstructor()) { - return newExpression.Members==null + return newExpression.Members == null ? Expression.New(newExpression.Constructor, arguments) : Expression.New(newExpression.Constructor, arguments, newExpression.Members); } From d87bcf39837557e57f0bf798ec89202f749fa64f Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 4 Mar 2026 16:11:01 +0500 Subject: [PATCH 22/55] Remove accedentally added namespace + summary updates --- .../Orm/Linq/Expressions/ConstructorExpression.cs | 9 +++------ .../Expressions/Visitors/ExtendedExpressionReplacer.cs | 2 +- .../Orm/Linq/Expressions/Visitors/OwnerRemover.cs | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs index 963486d0e..76008aab6 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs @@ -1,20 +1,17 @@ -// Copyright (C) 2003-2010 Xtensive LLC. -// All rights reserved. -// For conditions of distribution and use, see license. +// Copyright (C) 2009-2026 Xtensive LLC. +// This code is distributed under MIT license terms. +// See the License.txt file in the project root for more information. // Created by: Alexey Gamzov // Created: 2009.10.16 using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq.Expressions; using System.Reflection; -using Xtensive.Collections; using Xtensive.Core; using Xtensive.Orm.Linq.Expressions; using Xtensive.Orm.Linq.Expressions.Visitors; using System.Linq; -using System.Net.Http.Headers; namespace Xtensive.Orm.Linq { diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs index 97001f39d..c2081d40c 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2024 Xtensive LLC. +// Copyright (C) 2009-2026 Xtensive LLC. // This code is distributed under MIT license terms. // See the License.txt file in the project root for more information. // Created by: Alexis Kochetov diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs index a6d5d2950..fc89792ea 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2020 Xtensive LLC. +// Copyright (C) 2009-2026 Xtensive LLC. // This code is distributed under MIT license terms. // See the License.txt file in the project root for more information. // Created by: Alexis Kochetov From 4f3959ee154c7afa3d74be1be4c9ad30b8b86cae Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 4 Mar 2026 18:26:51 +0500 Subject: [PATCH 23/55] Optimize NewExpression visiting - less enumerations - less collections created --- .../Orm/Linq/Translator.Expressions.cs | 7 ++----- .../Orm/Linq/Translator.Materialization.cs | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs index 507cb8aa7..8f5e0a6a4 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs @@ -690,17 +690,14 @@ protected override Expression VisitNew(NewExpression newExpression) // ReSharper restore ConditionIsAlwaysTrueOrFalse // ReSharper restore HeuristicUnreachableCode - IList arguments = VisitNewExpressionArguments(newExpression); - if (arguments.Count == 0) - arguments = Array.Empty(); + var arguments = VisitNewExpressionArguments(newExpression, out var constructorParameters); if (newExpression.IsAnonymousConstructor()) { return newExpression.Members == null ? Expression.New(newExpression.Constructor, arguments) : Expression.New(newExpression.Constructor, arguments, newExpression.Members); } - var constructorParameters = newExpression.GetConstructorParameters(); - if (constructorParameters.Length != arguments.Count) + if (constructorParameters.Length != arguments.Length) throw Exceptions.InternalError(Strings.ExInvalidNumberOfParametersInNewExpression, OrmLog.Instance); var bindings = GetBindingsForConstructor(constructorParameters, arguments, newExpression); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs index 58e711a71..c873e95f2 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs @@ -152,10 +152,15 @@ private Materializer return new Materializer(projectorExpression.CachingCompile()); } - private List VisitNewExpressionArguments(NewExpression n) + private Expression[] VisitNewExpressionArguments(NewExpression n, out ParameterInfo[] constructorParameters) { - var arguments = new List(); + constructorParameters = n.GetConstructorParameters(); + if (n.Arguments.Count == 0) { + return Array.Empty(); + } + var arguments = new Expression[n.Arguments.Count]; var origArguments = n.Arguments; + for (int i = 0, count = origArguments.Count; i < count; i++) { var argument = origArguments[i]; @@ -169,16 +174,14 @@ private List VisitNewExpressionArguments(NewExpression n) body = body.IsProjection() ? BuildSubqueryResult((ProjectionExpression) body, argument.Type) : ProcessProjectionElement(body); - arguments.Add(body); - } - var constructorParameters = n.GetConstructorParameters(); - for (int i = 0; i < arguments.Count; i++) { - if (arguments[i].Type != constructorParameters[i].ParameterType) - arguments[i] = Expression.Convert(arguments[i], constructorParameters[i].ParameterType); + arguments[i] = body.Type != constructorParameters[i].ParameterType + ? Expression.Convert(body, constructorParameters[i].ParameterType) + : body; } return arguments; } + private void VisitNewExpressionArgumentsSkipResults(NewExpression n) { var origArguments = n.Arguments; From 51d471c08f31016f0f1aad785c6c2346a1d06165 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 6 Mar 2026 17:23:41 +0500 Subject: [PATCH 24/55] Better memory usage --- .../Builders/StorageMappingBuilder.cs | 14 ++-- .../Visitors/IncludeFilterMappingGatherer.cs | 4 +- .../Materialization/ExpressionMaterializer.cs | 70 ++++++++++++++++--- .../Orm/Linq/Translator.Materialization.cs | 5 +- .../Orm/Linq/Translator.Queryable.cs | 24 +++---- 5 files changed, 82 insertions(+), 35 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Building/Builders/StorageMappingBuilder.cs b/Orm/Xtensive.Orm/Orm/Building/Builders/StorageMappingBuilder.cs index 9ad2d578e..72512422a 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Builders/StorageMappingBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Builders/StorageMappingBuilder.cs @@ -74,7 +74,7 @@ private readonly Dictionary mappingCache = new Dictionary(); private readonly bool verbose; - private readonly List mappingRules; + private readonly MappingRule[] mappingRules; private readonly string defaultDatabase; private readonly string defaultSchema; @@ -138,12 +138,16 @@ private static bool RuleMatch(MappingRule rule, Type type) private StorageMappingBuilder(BuildingContext context) { this.context = context; + var configuration = context.Configuration; // Adding a special catch-all rule that maps all types to default schema/database. - - mappingRules = context.Configuration.MappingRules - .Concat(Enumerable.Repeat(new MappingRule(null, null, null, null), 1)) - .ToList(); + if (configuration.MappingRules.Count == 0) + mappingRules = new[] { new MappingRule(null, null, null, null) }; + else { + mappingRules = new MappingRule[context.Configuration.MappingRules.Count + 1]; + configuration.MappingRules.CopyTo(mappingRules, 0); + mappingRules[^1] = new MappingRule(null, null, null, null); + } defaultDatabase = context.Configuration.DefaultDatabase ?? string.Empty; defaultSchema = context.Configuration.DefaultSchema ?? string.Empty; diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs index bb28d0374..4e9dc500a 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs @@ -42,7 +42,9 @@ public MappingEntry(LambdaExpression calculatedColumn) public static MappingEntry[] Gather(Expression filterExpression, Expression filterDataTuple, ApplyParameter filteredTuple, int columnCount) { - var mapping = Enumerable.Repeat((MappingEntry) null, columnCount).ToArray(); + var mapping = new MappingEntry[columnCount]; + System.Array.Fill(mapping, null); + var visitor = new IncludeFilterMappingGatherer(filterDataTuple, filteredTuple, mapping); _ = visitor.Visit(filterExpression); if (mapping.Contains(null)) { diff --git a/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs b/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs index 77e236c4c..23b7894e7 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs @@ -27,7 +27,7 @@ namespace Xtensive.Orm.Linq.Materialization internal class ExpressionMaterializer : PersistentExpressionVisitor { private const string RootQueryTagsPrefix = "Root query tags ->"; - + private const int NumberOfItemsOnStack = 64; private static readonly MethodInfo BuildPersistentTupleMethod = typeof(ExpressionMaterializer).GetMethod(nameof(BuildPersistentTuple), BindingFlags.NonPublic | BindingFlags.Static); private static readonly MethodInfo GetTupleSegmentMethod = typeof(ExpressionMaterializer).GetMethod(nameof(GetTupleSegment), BindingFlags.NonPublic | BindingFlags.Static); private static readonly MethodInfo GetParameterValueMethod = WellKnownOrmTypes.ParameterContext.GetMethod(nameof(ParameterContext.GetValue)); @@ -246,12 +246,29 @@ protected override Expression VisitStructureFieldExpression(StructureFieldExpres if (expression.Owner == null) { var typeInfo = expression.PersistentType; var tuplePrototype = typeInfo.TuplePrototype; - var mappingInfo = expression.Fields + + var mappingSequence = expression.Fields .OfExactlyFieldExpression() .OrderBy(static f => f.Field.MappingInfo.Offset) .Select(static f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) - .Distinct() - .ToArray(); + .Distinct(); + + Pair[] mappingInfo; + if (expression.Fields.Count > NumberOfItemsOnStack * 2) { + mappingInfo = mappingSequence.ToArray(); + } + else { + Span> mappingInfoSpan = (expression.Fields.Count < NumberOfItemsOnStack) + ? stackalloc Pair[expression.Fields.Count] + : new Pair[expression.Fields.Count]; + + int actualCount = 0; + foreach (var map in mappingSequence) { + mappingInfoSpan[actualCount++] = map; + } + + mappingInfo = mappingInfoSpan.Slice(0, actualCount).ToArray(); + } var columnMap = MaterializationHelper.CreateSingleSourceMap(tuplePrototype.Count, mappingInfo); @@ -294,12 +311,29 @@ protected override Expression VisitStructureExpression(StructureExpression expre var typeInfo = expression.PersistentType; var tuplePrototype = typeInfo.TuplePrototype; - var mappingInfo = expression.Fields + + var mappingSequence = expression.Fields .OfExactlyFieldExpression() .OrderBy(static f => f.Field.MappingInfo.Offset) .Select(static f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) - .Distinct() - .ToArray(); + .Distinct(); + + Pair[] mappingInfo; + if (expression.Fields.Count > NumberOfItemsOnStack * 2) { + mappingInfo = mappingSequence.ToArray(); + } + else { + Span> mappingInfoSpan = (expression.Fields.Count < NumberOfItemsOnStack) + ? stackalloc Pair[expression.Fields.Count] + : new Pair[expression.Fields.Count]; + + int actualCount = 0; + foreach (var map in mappingSequence) { + mappingInfoSpan[actualCount++] = map; + } + + mappingInfo = mappingInfoSpan.Slice(0, actualCount).ToArray(); + } var columnMap = MaterializationHelper.CreateSingleSourceMap(tuplePrototype.Count, mappingInfo); @@ -358,12 +392,28 @@ private Expression CreateEntity(IEntityExpression expression, Expression tupleEx var typeIdField = expression.Fields.SingleOrDefault(f => f.Name == WellKnown.TypeIdFieldName); var typeIdIndex = typeIdField == null ? -1 : typeIdField.Mapping.Offset; - var mappingInfo = expression.Fields + var mappingSequence = expression.Fields .OfExactlyFieldExpression() .OrderBy(static f => f.Field.MappingInfo.Offset) .Select(static f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) - .Distinct() - .ToArray(); + .Distinct(); + + Pair[] mappingInfo; + if (expression.Fields.Count > NumberOfItemsOnStack * 4) { + mappingInfo = mappingSequence.ToArray(); + } + else { + Span> mappingInfoSpan = (expression.Fields.Count < NumberOfItemsOnStack) + ? stackalloc Pair[expression.Fields.Count] + : new Pair[expression.Fields.Count]; + + int actualCount = 0; + foreach (var map in mappingSequence) { + mappingInfoSpan[actualCount++] = map; + } + + mappingInfo = mappingInfoSpan.Slice(0, actualCount).ToArray(); + } var isMaterializedExpression = Expression.Call( itemMaterializationContextParameter, diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs index c873e95f2..b85772df6 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs @@ -89,9 +89,8 @@ private static ProjectionExpression Optimize(ProjectionExpression origin) if (usedColumns.Count == 0) usedColumns.Add(0); if (usedColumns.Count < origin.ItemProjector.DataSource.Header.Length) { - var usedColumnsArray = usedColumns.ToArray(); - var resultProvider = new SelectProvider(originProvider, usedColumnsArray); - var itemProjector = origin.ItemProjector.Remap(resultProvider, usedColumnsArray); + var resultProvider = new SelectProvider(originProvider, usedColumns); + var itemProjector = origin.ItemProjector.Remap(resultProvider, usedColumns); var result = origin.ApplyItemProjector(itemProjector); return result; } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs index 3fe9cf903..b2cecaf05 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs @@ -356,7 +356,9 @@ private ProjectionExpression VisitCast(Expression source, Type targetType, Type var recordSet = projection.ItemProjector.DataSource; var targetTypeInfo = context.Model.Types[targetType]; var sourceTypeInfo = context.Model.Types[sourceType]; - var map = Enumerable.Repeat(-1, recordSet.Header.Columns.Count).ToArray(); + var map = new int[recordSet.Header.Columns.Count]; + Array.Fill(map, -1); + var targetFieldIndex = 0; var targetFields = targetTypeInfo.Fields.Where(f => f.IsPrimitive); foreach (var targetField in targetFields) { @@ -1571,22 +1573,12 @@ private Expression VisitSetOperations(Expression outerSource, Expression innerSo var outerItemProjector = outer.ItemProjector.RemoveOwner(); var innerItemProjector = inner.ItemProjector.RemoveOwner(); - var outerColumnList = outerItemProjector.GetColumns(ColumnExtractionModes.Distinct).ToList(); - var innerColumnList = innerItemProjector.GetColumns(ColumnExtractionModes.Distinct).ToList(); - - int[] outerColumns, innerColumns; - if (!outerColumnList.Except(innerColumnList).Any() && outerColumnList.Count == innerColumnList.Count) { - var outerColumnListCopy = outerColumnList.ToArray(); - Array.Sort(outerColumnListCopy); - outerColumns = outerColumnListCopy; + var outerColumns = outerItemProjector.GetColumns(ColumnExtractionModes.Distinct).ToArray(); + var innerColumns = innerItemProjector.GetColumns(ColumnExtractionModes.Distinct).ToArray(); - var innerColumnListCopy = innerColumnList.ToArray(); - Array.Sort(innerColumnListCopy); - innerColumns = innerColumnListCopy; - } - else { - outerColumns = outerColumnList.ToArray(); - innerColumns = innerColumnList.ToArray(); + if (!outerColumns.Except(innerColumns).Any() && outerColumns.Length == innerColumns.Length) { + Array.Sort(outerColumns); + Array.Sort(innerColumns); } var outerRecordSet = ShouldWrapDataSourceWithSelect(outerItemProjector, outerColumns) From 49bbda54aaa4c6d8e08f549c70c70cfbfb9e0343 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 6 Mar 2026 17:24:32 +0500 Subject: [PATCH 25/55] Enumerable.Repeat(xxx, 1) replaced with .Append/EnumerableUtils.One --- .../Orm/Providers/MultidatabaseMappingResolver.cs | 7 +++---- .../Orm/Providers/MultischemaMappingResolver.cs | 7 ++++--- Orm/Xtensive.Orm/Orm/Providers/SimpleMappingResolver.cs | 7 ++++--- Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Helpers.cs | 3 ++- Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs | 3 ++- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Providers/MultidatabaseMappingResolver.cs b/Orm/Xtensive.Orm/Orm/Providers/MultidatabaseMappingResolver.cs index 984cf9a6c..cc55940b2 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/MultidatabaseMappingResolver.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/MultidatabaseMappingResolver.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2014 Xtensive LLC. +// Copyright (C) 2014 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -87,8 +87,7 @@ from rule in configuration.MappingRules where db==database select string.IsNullOrEmpty(rule.Schema) ? configuration.DefaultSchema : rule.Schema; - return userSchemas - .Concat(Enumerable.Repeat(configuration.DefaultSchema, 1)) + return userSchemas.Append(configuration.DefaultSchema) .Distinct(); } @@ -97,7 +96,7 @@ private static IEnumerable GetDatabases(DomainConfiguration configuratio return configuration.MappingRules .Select(r => r.Database) .Where(db => !string.IsNullOrEmpty(db)) - .Concat(Enumerable.Repeat(configuration.DefaultDatabase, 1)) + .Append(configuration.DefaultDatabase) .Distinct(); } diff --git a/Orm/Xtensive.Orm/Orm/Providers/MultischemaMappingResolver.cs b/Orm/Xtensive.Orm/Orm/Providers/MultischemaMappingResolver.cs index 19812c160..64afb59c7 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/MultischemaMappingResolver.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/MultischemaMappingResolver.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2014 Xtensive LLC. +// Copyright (C) 2014 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Xtensive.Collections; using Xtensive.Orm.Configuration; using Xtensive.Orm.Upgrade; using Xtensive.Sql; @@ -54,7 +55,7 @@ public override IEnumerable GetSchemaTasks() public override IEnumerable GetMetadataTasks() { - return Enumerable.Repeat(metadataTask, 1); + return EnumerableUtils.One(metadataTask); } private string FormatNodeName(string mappingSchema, string mappingName) @@ -74,7 +75,7 @@ public MultischemaMappingResolver(DomainConfiguration configuration, NodeConfigu extractionTasks = configuration.MappingRules .Select(r => r.Schema) .Where(s => !string.IsNullOrEmpty(s)) - .Concat(Enumerable.Repeat(configuration.DefaultSchema, 1)) + .Append(configuration.DefaultSchema) .Distinct() .Select(s => new SqlExtractionTask(defaultSchemaInfo.Database, schemaMapping.Apply(s))) .ToList(); diff --git a/Orm/Xtensive.Orm/Orm/Providers/SimpleMappingResolver.cs b/Orm/Xtensive.Orm/Orm/Providers/SimpleMappingResolver.cs index fdd9c8d25..7d8d2a250 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SimpleMappingResolver.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SimpleMappingResolver.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2014 Xtensive LLC. +// Copyright (C) 2014 Xtensive LLC. // All rights reserved. // For conditions of distribution and use, see license. // Created by: Denis Krjuchkov @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; +using Xtensive.Collections; using Xtensive.Orm.Upgrade; using Xtensive.Sql; using Xtensive.Sql.Info; @@ -40,12 +41,12 @@ public override MappingResolveResult Resolve(SchemaExtractionResult model, strin public override IEnumerable GetSchemaTasks() { - return Enumerable.Repeat(extractionTask, 1); + return EnumerableUtils.One(extractionTask); } public override IEnumerable GetMetadataTasks() { - return Enumerable.Repeat(extractionTask, 1); + return EnumerableUtils.One(extractionTask); } // Constructors diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Helpers.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Helpers.cs index faf6e6aba..5653e6bca 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Helpers.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Helpers.cs @@ -16,6 +16,7 @@ using Xtensive.Sql; using Xtensive.Sql.Dml; using Xtensive.Tuples; +using Xtensive.Collections; namespace Xtensive.Orm.Providers { @@ -28,7 +29,7 @@ protected SqlProvider CreateProvider(SqlSelect statement, protected SqlProvider CreateProvider(SqlSelect statement, QueryParameterBinding extraBinding, CompilableProvider origin, params ExecutableProvider[] sources) { - var extraBindings = extraBinding!=null ? Enumerable.Repeat(extraBinding, 1) : null; + var extraBindings = extraBinding!=null ? EnumerableUtils.One(extraBinding) : null; return CreateProvider(statement, extraBindings, origin, sources); } diff --git a/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs b/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs index 636885d86..2c440d91b 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Xtensive.Collections; using Xtensive.Core; using Xtensive.IoC; using Xtensive.Orm.Configuration; @@ -36,7 +37,7 @@ public Segment NextBulk(SequenceInfo sequenceInfo, Session session) long hiValue = Execute(query, session); if (executionFromUpgrade && !hasAISettingsInMemory) - CleanUp(Enumerable.Repeat(sequenceInfo, 1), session); + CleanUp(EnumerableUtils.One(sequenceInfo), session); var increment = sequenceInfo.Increment; var current = hasArbitaryIncrement ? hiValue - increment : (hiValue - 1) * increment; From bb40f29077ab19a54c86689f3800d6b3d57c21fe Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 6 Mar 2026 17:31:26 +0500 Subject: [PATCH 26/55] Fix local function declaration --- .../Orm/Linq/Expressions/KeyExpression.cs | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/KeyExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/KeyExpression.cs index 0d8b6ff21..9e7c89448 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/KeyExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/KeyExpression.cs @@ -37,13 +37,17 @@ private Expression RemapWithNoCheck(int offset, Dictionary(Mapping.Offset + offset, Mapping.Length); - FieldExpression Remap(FieldExpression f) => (FieldExpression) f.Remap(offset, processedExpressions); - var fields = KeyFields.Select(Remap).ToArray(KeyFields.Count); var result = new KeyExpression(EntityType, fields, newMapping, UnderlyingProperty, OuterParameter, DefaultIfEmpty); processedExpressions.Add(this, result); return result; + + + FieldExpression Remap(FieldExpression f) + { + return (FieldExpression) f.Remap(offset, processedExpressions); + } } public override Expression Remap(IReadOnlyList map, Dictionary processedExpressions) @@ -93,14 +97,17 @@ public override Expression BindParameter( private Expression BindParameterWithNoCheck( ParameterExpression parameter, Dictionary processedExpressions) { - FieldExpression BindParameter(FieldExpression f) - => (FieldExpression) f.BindParameter(parameter, processedExpressions); - var fields = KeyFields.Select(BindParameter).ToArray(KeyFields.Count); var result = new KeyExpression(EntityType, fields, Mapping, UnderlyingProperty, parameter, DefaultIfEmpty); processedExpressions.Add(this, result); return result; + + + FieldExpression BindParameter(FieldExpression f) + { + return (FieldExpression) f.BindParameter(parameter, processedExpressions); + } } public override Expression RemoveOuterParameter(Dictionary processedExpressions) @@ -116,22 +123,23 @@ public override Expression RemoveOuterParameter(Dictionary processedExpressions) { - FieldExpression RemoveOuterParameter(FieldExpression f) - => (FieldExpression) f.RemoveOuterParameter(processedExpressions); - var fields = KeyFields.Select(RemoveOuterParameter).ToArray(KeyFields.Count); var result = new KeyExpression(EntityType, fields, Mapping, UnderlyingProperty, null, DefaultIfEmpty); processedExpressions.Add(this, result); return result; + + + FieldExpression RemoveOuterParameter(FieldExpression f) + { + return (FieldExpression) f.RemoveOuterParameter(processedExpressions); + } } public static KeyExpression Create(TypeInfo entityType, int offset) { var mapping = new Segment(offset, entityType.Key.TupleDescriptor.Count); - FieldExpression CreateField(ColumnInfo c) => FieldExpression.CreateField(c.Field, offset); - var fields = entityType.IsLocked ? entityType.Key.Columns.Select(CreateField).ToArray(entityType.Key.Columns.Count) : entityType.Columns @@ -140,6 +148,12 @@ public static KeyExpression Create(TypeInfo entityType, int offset) .Select(CreateField) .ToArray(); return new KeyExpression(entityType, fields, mapping, WellKnownMembers.IEntityKey, null, false); + + + FieldExpression CreateField(ColumnInfo c) + { + return FieldExpression.CreateField(c.Field, offset); + } } From 09551817c47d5c96e6a8cac73e58a773aed6354d Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Mon, 9 Mar 2026 14:44:46 +0500 Subject: [PATCH 27/55] Revert Enumerable.Repeat(value, 1) -> EnumerableUtils.One repeat enumerator is more efficient because it takes into account number of repeats as actual count of items in produced sequence --- Orm/Xtensive.Orm/Orm/Providers/MultischemaMappingResolver.cs | 2 +- Orm/Xtensive.Orm/Orm/Providers/SimpleMappingResolver.cs | 4 ++-- Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Helpers.cs | 2 +- Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Providers/MultischemaMappingResolver.cs b/Orm/Xtensive.Orm/Orm/Providers/MultischemaMappingResolver.cs index 64afb59c7..b0bd5ba72 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/MultischemaMappingResolver.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/MultischemaMappingResolver.cs @@ -55,7 +55,7 @@ public override IEnumerable GetSchemaTasks() public override IEnumerable GetMetadataTasks() { - return EnumerableUtils.One(metadataTask); + return Enumerable.Repeat(metadataTask, 1); } private string FormatNodeName(string mappingSchema, string mappingName) diff --git a/Orm/Xtensive.Orm/Orm/Providers/SimpleMappingResolver.cs b/Orm/Xtensive.Orm/Orm/Providers/SimpleMappingResolver.cs index 7d8d2a250..1bad97452 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SimpleMappingResolver.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SimpleMappingResolver.cs @@ -41,12 +41,12 @@ public override MappingResolveResult Resolve(SchemaExtractionResult model, strin public override IEnumerable GetSchemaTasks() { - return EnumerableUtils.One(extractionTask); + return Enumerable.Repeat(extractionTask, 1); } public override IEnumerable GetMetadataTasks() { - return EnumerableUtils.One(extractionTask); + return Enumerable.Repeat(extractionTask, 1); } // Constructors diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Helpers.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Helpers.cs index 5653e6bca..33cef221b 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Helpers.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Helpers.cs @@ -29,7 +29,7 @@ protected SqlProvider CreateProvider(SqlSelect statement, protected SqlProvider CreateProvider(SqlSelect statement, QueryParameterBinding extraBinding, CompilableProvider origin, params ExecutableProvider[] sources) { - var extraBindings = extraBinding!=null ? EnumerableUtils.One(extraBinding) : null; + var extraBindings = extraBinding!=null ? Enumerable.Repeat(extraBinding, 1) : null; return CreateProvider(statement, extraBindings, origin, sources); } diff --git a/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs b/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs index 2c440d91b..b3c14775e 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs @@ -37,7 +37,7 @@ public Segment NextBulk(SequenceInfo sequenceInfo, Session session) long hiValue = Execute(query, session); if (executionFromUpgrade && !hasAISettingsInMemory) - CleanUp(EnumerableUtils.One(sequenceInfo), session); + CleanUp(Enumerable.Repeat(sequenceInfo, 1), session); var increment = sequenceInfo.Increment; var current = hasArbitaryIncrement ? hiValue - increment : (hiValue - 1) * increment; From aa2bbed42d1ace87ddf241e481d72bc24673de88 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Mon, 9 Mar 2026 14:48:30 +0500 Subject: [PATCH 28/55] Marked EnumerableUtils.One as obsolete to not be in use There are three dotnet alternatives which work better - Repeat, Append and Prepend, which cover all the possible scenarios and track actual number of items in result sequence --- .../Collections/EnumerableExtensionsTest.cs | 2 +- .../Collections/TopologicalSorterTest.cs | 2 +- .../Helpers/TopologicalSorterTest.cs | 4 ++-- Orm/Xtensive.Orm.Tests.Sql/MySQL/MiscTests.cs | 2 +- .../SqlServer/MiscTests.cs | 4 ++-- .../Linq/QueryMethodTests.cs | 4 ++-- .../Storage/Multinode/QueryCachingTest.cs | 2 +- .../Prefetch/PrefetchManagerBasicTest.cs | 4 ++-- .../Storage/Prefetch/PrefetchTest.cs | 20 +++++++++---------- .../Storage/Randomized/Tree.cs | 3 ++- .../Storage/VersionRootTests.cs | 2 +- .../Collections/EnumerableUtils.cs | 1 + .../TypeRegistrationProcessorBase.cs | 4 +++- .../Core/Extensions/EnumerableExtensions.cs | 4 ++-- Orm/Xtensive.Orm/Linq/ConstantExtractor.cs | 2 +- .../ConfigurationSectionExtensions.cs | 2 +- Orm/Xtensive.Orm/Orm/Entity.cs | 4 ++-- .../Internals/Prefetch/Nodes/NodeBuilder.cs | 2 +- .../Expressions/LocalCollectionExpression.cs | 2 +- .../Orm/Linq/ItemToTupleConverter{TItem}.cs | 2 +- .../Orm/Operations/KeySetOperation.cs | 2 +- .../Transformation/ColumnMappingInspector.cs | 4 ++-- Orm/Xtensive.Orm/Orm/Transaction.cs | 2 +- .../Orm/Upgrade/Internals/HintGenerator.cs | 4 ++-- 24 files changed, 44 insertions(+), 40 deletions(-) diff --git a/Orm/Xtensive.Orm.Tests.Core/Collections/EnumerableExtensionsTest.cs b/Orm/Xtensive.Orm.Tests.Core/Collections/EnumerableExtensionsTest.cs index 7b16f3b2e..a15d16405 100644 --- a/Orm/Xtensive.Orm.Tests.Core/Collections/EnumerableExtensionsTest.cs +++ b/Orm/Xtensive.Orm.Tests.Core/Collections/EnumerableExtensionsTest.cs @@ -112,7 +112,7 @@ private static IEnumerable Flatten(Node root, bool rootFirst) private static IEnumerable Flatten(Node root, bool rootFirst, Action exitAction) { - return EnumerableUtils.One(root).Flatten(n => n != null ? n.Children : null, exitAction, rootFirst); + return Enumerable.Repeat(root, 1).Flatten(n => n != null ? n.Children : null, exitAction, rootFirst); } [Test] diff --git a/Orm/Xtensive.Orm.Tests.Core/Collections/TopologicalSorterTest.cs b/Orm/Xtensive.Orm.Tests.Core/Collections/TopologicalSorterTest.cs index 74a37fa23..a27799af0 100644 --- a/Orm/Xtensive.Orm.Tests.Core/Collections/TopologicalSorterTest.cs +++ b/Orm/Xtensive.Orm.Tests.Core/Collections/TopologicalSorterTest.cs @@ -70,7 +70,7 @@ public void SelfReferenceTest() { var node = new Node(1); var edge = new Edge(node, node, 1); - var graph = new Graph, Edge>(EnumerableUtils.One(node)); + var graph = new Graph, Edge>(Enumerable.Repeat(node, 1)); var result = TopologicalSorter.Sort(graph, e => e.Source==e.Target); Assert.AreEqual(1, result.SortedNodes.Count); diff --git a/Orm/Xtensive.Orm.Tests.Core/Helpers/TopologicalSorterTest.cs b/Orm/Xtensive.Orm.Tests.Core/Helpers/TopologicalSorterTest.cs index 379c65a31..0532e0f6f 100644 --- a/Orm/Xtensive.Orm.Tests.Core/Helpers/TopologicalSorterTest.cs +++ b/Orm/Xtensive.Orm.Tests.Core/Helpers/TopologicalSorterTest.cs @@ -126,13 +126,13 @@ public void SelfReferenceTest() var connection2 = new NodeConnection(node2, node2, "ConnectionItem"); connection2.BindToNodes(); - var result = TopologicalSorter.SortToList(EnumerableUtils.One(node1), out var removedEdges1); + var result = TopologicalSorter.SortToList(Enumerable.Repeat(node1, 1), out var removedEdges1); Assert.AreEqual(1, result.Count); Assert.AreEqual(node1.Item, result[0]); Assert.AreEqual(1, removedEdges1.Count); Assert.AreEqual(connection1, removedEdges1[0]); - result = TopologicalSorter.Sort(EnumerableUtils.One(node2), out var removedEdges2).ToList(1); + result = TopologicalSorter.Sort(Enumerable.Repeat(node2, 1), out var removedEdges2).ToList(1); Assert.AreEqual(1, result.Count); Assert.AreEqual(node2.Item, result[0]); Assert.AreEqual(1, removedEdges2.Count); diff --git a/Orm/Xtensive.Orm.Tests.Sql/MySQL/MiscTests.cs b/Orm/Xtensive.Orm.Tests.Sql/MySQL/MiscTests.cs index aac4cc770..54c37efe6 100644 --- a/Orm/Xtensive.Orm.Tests.Sql/MySQL/MiscTests.cs +++ b/Orm/Xtensive.Orm.Tests.Sql/MySQL/MiscTests.cs @@ -353,7 +353,7 @@ public void FreeTextTest() { SqlSelect select = SqlDml.Select(); var table = Catalog.DefaultSchema.Tables["Address"]; - select.From = SqlDml.QueryRef(SqlDml.FreeTextTable(table, "How can I make my own beers and ales?", EnumerableUtils.One(table.Columns[0].Name).ToList(), EnumerableUtils.One(table.Columns[0].Name).ToList())); + select.From = SqlDml.QueryRef(SqlDml.FreeTextTable(table, "How can I make my own beers and ales?", new[] { table.Columns[0].Name }, new[] { table.Columns[0].Name })); select.Columns.Add(select.From.Asterisk); Console.WriteLine(SqlDriver.Compile(select).GetCommandText()); } diff --git a/Orm/Xtensive.Orm.Tests.Sql/SqlServer/MiscTests.cs b/Orm/Xtensive.Orm.Tests.Sql/SqlServer/MiscTests.cs index 295d014ee..cfb60e235 100644 --- a/Orm/Xtensive.Orm.Tests.Sql/SqlServer/MiscTests.cs +++ b/Orm/Xtensive.Orm.Tests.Sql/SqlServer/MiscTests.cs @@ -360,7 +360,7 @@ public void FreeTextTest() { SqlSelect select = SqlDml.Select(); var table = Catalog.Schemas["Person"].Tables["Address"]; - select.From = SqlDml.QueryRef(SqlDml.FreeTextTable(table, "How can I make my own beers and ales?", EnumerableUtils.One(table.Columns[0].Name).ToList(), EnumerableUtils.One(table.Columns[0].Name).ToList())); + select.From = SqlDml.QueryRef(SqlDml.FreeTextTable(table, "How can I make my own beers and ales?", new[] { table.Columns[0].Name }, new[] { table.Columns[0].Name })); select.Columns.Add(select.From.Asterisk); Console.WriteLine(sqlDriver.Compile(select).GetCommandText()); } @@ -372,7 +372,7 @@ public void FreeTextTopNByRankTest() var table = Catalog.Schemas["Person"].Tables["Address"]; select.From = SqlDml.QueryRef( SqlDml.FreeTextTable(table, "How can I make my own beers", - EnumerableUtils.One(table.Columns[0].Name).ToList(), + new[] { table.Columns[0].Name }, (SqlLiteral)5)); Console.WriteLine(sqlDriver.Compile(select).GetCommandText()); } diff --git a/Orm/Xtensive.Orm.Tests/Linq/QueryMethodTests.cs b/Orm/Xtensive.Orm.Tests/Linq/QueryMethodTests.cs index a1ad7ff5a..8d0dff447 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/QueryMethodTests.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/QueryMethodTests.cs @@ -190,9 +190,9 @@ public async Task Store2AsyncTest() private IEnumerable GetExpectedCustomerAsSequence() { if (StorageProviderInfo.Instance.CheckProviderIs(StorageProvider.Firebird)) { - return EnumerableUtils.One(Session.Query.All().OrderBy(c => c.CustomerId).AsEnumerable().First()); + return Session.Query.All().OrderBy(c => c.CustomerId).AsEnumerable().Take(1); } - return EnumerableUtils.One(Customers.First()); + return Enumerable.Repeat(Customers.First(), 1); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm.Tests/Storage/Multinode/QueryCachingTest.cs b/Orm/Xtensive.Orm.Tests/Storage/Multinode/QueryCachingTest.cs index dd1a6fa33..1d41aaa82 100644 --- a/Orm/Xtensive.Orm.Tests/Storage/Multinode/QueryCachingTest.cs +++ b/Orm/Xtensive.Orm.Tests/Storage/Multinode/QueryCachingTest.cs @@ -426,7 +426,7 @@ private int[] GetUnexpectedTypeIds(string nodeId) return (nodeId == WellKnown.DefaultNodeId) ? CustomUpgradeHandler.TypeIdPerNode.Values.ToArray() : CustomUpgradeHandler.TypeIdPerNode.Where(i => i.Key != nodeId) - .Select(i => i.Value).Union(EnumerableUtils.One(100)).ToArray(); + .Select(i => i.Value).Union(Enumerable.Repeat(100, 1)).ToArray(); } private List ExecuteSimpleQueryCaching(Session session) => diff --git a/Orm/Xtensive.Orm.Tests/Storage/Prefetch/PrefetchManagerBasicTest.cs b/Orm/Xtensive.Orm.Tests/Storage/Prefetch/PrefetchManagerBasicTest.cs index f51578c95..8a4fbe9d6 100644 --- a/Orm/Xtensive.Orm.Tests/Storage/Prefetch/PrefetchManagerBasicTest.cs +++ b/Orm/Xtensive.Orm.Tests/Storage/Prefetch/PrefetchManagerBasicTest.cs @@ -951,9 +951,9 @@ private void OpenSessionsAndRunPrefetches() var newOrder = new Order(); var orderDetail = new OrderDetail {Product = new Product()}; session.SaveChanges(); - var order = EnumerableUtils.One(newOrder).Prefetch(o => o.Details).First(); + var order = Enumerable.Repeat(newOrder, 1).Prefetch(o => o.Details).First(); Assert.That(order, Is.Not.Null); - var product = EnumerableUtils.One(orderDetail).Prefetch(d => d.Product).First(); + var product = Enumerable.Repeat(orderDetail, 1).Prefetch(d => d.Product).First(); Assert.That(product, Is.Not.Null); //Query.All().Prefetch(o => o.Details).First(); t.Complete(); diff --git a/Orm/Xtensive.Orm.Tests/Storage/Prefetch/PrefetchTest.cs b/Orm/Xtensive.Orm.Tests/Storage/Prefetch/PrefetchTest.cs index 521dca468..518854075 100644 --- a/Orm/Xtensive.Orm.Tests/Storage/Prefetch/PrefetchTest.cs +++ b/Orm/Xtensive.Orm.Tests/Storage/Prefetch/PrefetchTest.cs @@ -619,7 +619,7 @@ public void ArgumentsTest() AssertEx.Throws(() => session.Query.All() .Prefetch(t => t.PersistenceState) .ToList()); - var d = session.Query.Many(EnumerableUtils.One(Key.Create(Domain, 1))) + var d = session.Query.Many(Enumerable.Repeat(Key.Create(Domain, 1), 1)) .Prefetch(oc => oc.IntermediateOffer.AnotherContainer.RealOffer.Book) .ToList(); } @@ -639,7 +639,7 @@ public async Task ArgumentsAsyncTest() _ = Assert.ThrowsAsync(async () => (await session.Query.All() .Prefetch(t => t.PersistenceState).ExecuteAsync()) .ToList()); - var d = (await session.Query.Many(EnumerableUtils.One(Key.Create(Domain, 1))) + var d = (await session.Query.Many(Enumerable.Repeat(Key.Create(Domain, 1), 1)) .Prefetch(oc => oc.IntermediateOffer.AnotherContainer.RealOffer.Book).ExecuteAsync()) .ToList(); } @@ -699,7 +699,7 @@ public void RootElementIsNullPrefetchTest() } using (var tx = session.OpenTransaction()) { var books = session.Query.All().AsEnumerable() - .Concat(EnumerableUtils.One(null)).Prefetch(b => b.Title); + .Concat(Enumerable.Repeat(null, 1)).Prefetch(b => b.Title); var titleField = Domain.Model.Types[typeof(Model.Book)].Fields[nameof(Model.Book.Title)]; var titleType = Domain.Model.Types[typeof(Model.Title)]; var count = 0; @@ -727,7 +727,7 @@ public async Task RootElementIsNullPrefetchAsyncTest() await using (var tx = session.OpenTransaction()) { var books = session.Query.All().AsEnumerable() - .Concat(EnumerableUtils.One(null)).Prefetch(b => b.Title).AsAsyncEnumerable(); + .Concat(Enumerable.Repeat(null, 1)).Prefetch(b => b.Title).AsAsyncEnumerable(); var titleField = Domain.Model.Types[typeof(Model.Book)].Fields[nameof(Model.Book.Title)]; var titleType = Domain.Model.Types[typeof(Model.Title)]; var count = 0; @@ -804,7 +804,7 @@ public void NestedPrefetchWhenRootElementIsNullTest() tx.Complete(); } using (var tx = session.OpenTransaction()) { - var books = session.Query.All().AsEnumerable().Concat(EnumerableUtils.One(null)) + var books = session.Query.All().AsEnumerable().Concat(Enumerable.Repeat(null, 1)) .Prefetch(b => b.Title.Book); var titleField = Domain.Model.Types[typeof (Model.Book)].Fields["Title"]; var titleType = Domain.Model.Types[typeof (Model.Title)]; @@ -834,7 +834,7 @@ public async Task NestedPrefetchWhenRootElementIsNullAsyncTest() } await using (var tx = session.OpenTransaction()) { - var books = session.Query.All().AsEnumerable().Concat(EnumerableUtils.One(null)) + var books = session.Query.All().AsEnumerable().Concat(Enumerable.Repeat(null, 1)) .Prefetch(b => b.Title.Book).AsAsyncEnumerable(); var titleField = Domain.Model.Types[typeof(Model.Book)].Fields[nameof(Model.Book.Title)]; var titleType = Domain.Model.Types[typeof(Model.Title)]; @@ -861,7 +861,7 @@ public void StructureFieldsPrefetchTest() using (var session = Domain.OpenSession()) using (var tx = session.OpenTransaction()) { - var containers = session.Query.Many(EnumerableUtils.One(containerKey)) + var containers = session.Query.Many(Enumerable.Repeat(containerKey, 1)) .Prefetch(oc => oc.RealOffer.Book) .Prefetch(oc => oc.IntermediateOffer.RealOffer.BookShop); foreach (var key in containers) { @@ -879,7 +879,7 @@ public async Task StructureFieldsPrefetchAsyncTest() await using (var session = await Domain.OpenSessionAsync()) await using (var tx = session.OpenTransaction()) { - var containers = session.Query.Many(EnumerableUtils.One(containerKey)) + var containers = session.Query.Many(Enumerable.Repeat(containerKey, 1)) .Prefetch(oc => oc.RealOffer.Book) .Prefetch(oc => oc.IntermediateOffer.RealOffer.BookShop).AsAsyncEnumerable(); await foreach (var key in containers) { @@ -897,7 +897,7 @@ public void StructurePrefetchTest() using (var session = Domain.OpenSession()) using (var tx = session.OpenTransaction()) { - var containers = session.Query.Many(EnumerableUtils.One(containerKey)) + var containers = session.Query.Many(Enumerable.Repeat(containerKey, 1)) .Prefetch(oc => oc.IntermediateOffer); foreach (var key in containers) { PrefetchTestHelper.AssertOnlySpecifiedColumnsAreLoaded(containerKey, containerKey.TypeInfo, session, @@ -914,7 +914,7 @@ public async Task StructurePrefetchAsyncTest() await using (var session = await Domain.OpenSessionAsync()) await using (var tx = session.OpenTransaction()) { - var containers = session.Query.Many(EnumerableUtils.One(containerKey)) + var containers = session.Query.Many(Enumerable.Repeat(containerKey, 1)) .Prefetch(oc => oc.IntermediateOffer).AsAsyncEnumerable(); await foreach (var key in containers) { PrefetchTestHelper.AssertOnlySpecifiedColumnsAreLoaded(containerKey, containerKey.TypeInfo, session, diff --git a/Orm/Xtensive.Orm.Tests/Storage/Randomized/Tree.cs b/Orm/Xtensive.Orm.Tests/Storage/Randomized/Tree.cs index bf1378d0a..540ef2c5d 100644 --- a/Orm/Xtensive.Orm.Tests/Storage/Randomized/Tree.cs +++ b/Orm/Xtensive.Orm.Tests/Storage/Randomized/Tree.cs @@ -7,6 +7,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using Xtensive.Collections; using Xtensive.Core; @@ -33,7 +34,7 @@ public sealed class Tree : Entity, /// public IEnumerator GetEnumerator() { - return EnumerableUtils.One(Root).Flatten(node => node.Children, null, true).GetEnumerator(); + return Enumerable.Repeat(Root, 1).Flatten(node => node.Children, null, true).GetEnumerator(); } /// diff --git a/Orm/Xtensive.Orm.Tests/Storage/VersionRootTests.cs b/Orm/Xtensive.Orm.Tests/Storage/VersionRootTests.cs index 219dd0f61..6922565a4 100644 --- a/Orm/Xtensive.Orm.Tests/Storage/VersionRootTests.cs +++ b/Orm/Xtensive.Orm.Tests/Storage/VersionRootTests.cs @@ -60,7 +60,7 @@ public IEnumerable GetVersionRoots() if (Order==null) return Enumerable.Empty(); else - return EnumerableUtils.One((Entity) Order); + return Enumerable.Repeat((Entity) Order, 1); } } diff --git a/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs b/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs index 4ba5718e1..32903b82f 100644 --- a/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs +++ b/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs @@ -21,6 +21,7 @@ public static class EnumerableUtils /// /// The type of enumerated item. /// Sequence with value inside. + [Obsolete("Inefficient compared with Enumerable.Repeat(value, 1), or .Append(value)/.Prepend(value) extensions.")] public static IEnumerable One(TItem value) { yield return value; diff --git a/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs b/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs index 8fe3c6f17..e7ab2eb41 100644 --- a/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs +++ b/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs @@ -34,7 +34,9 @@ public virtual void Process(TypeRegistry registry, TypeRegistration registration var types = registration.Type==null ? FindTypes(registration.Assembly, BaseType, (type, typeFilter) => IsAcceptable(registration, type)) - : EnumerableUtils.One(registration.Type).Where(t => IsAcceptable(registration, t)); + : IsAcceptable(registration, registration.Type) + ? Enumerable.Repeat(registration.Type, 1) + : Enumerable.Empty(); foreach (var type in types) Process(registry, registration, type); } diff --git a/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs index 575e4086a..ac3d433a3 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs @@ -417,13 +417,13 @@ public static IEnumerable> Batch(this IEnumerable source, i ArgumentValidator.EnsureArgumentIsInRange(maximalBatchSize, 0, int.MaxValue, "maximalBatchSize"); if(maximalBatchSize < initialBatchSize) throw new ArgumentException(String.Format(Strings.ExArgumentXIsLessThanArgumentY, - "maximalBatchSize", "initialBatchSize")); + nameof(maximalBatchSize), nameof(initialBatchSize))); var currentCount = 0; var currentBatchSize = initialBatchSize; using (var enumerator = source.GetEnumerator()) { while (currentCount < firstFastCount && enumerator.MoveNext()) { currentCount++; - yield return EnumerableUtils.One(enumerator.Current); + yield return Enumerable.Repeat(enumerator.Current, 1); } while (enumerator.MoveNext()) { currentCount = 0; diff --git a/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs b/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs index 1a96e58e9..ae7c1aaeb 100644 --- a/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs +++ b/Orm/Xtensive.Orm/Linq/ConstantExtractor.cs @@ -49,7 +49,7 @@ public LambdaExpression Process() if (constantValues != null) throw new InvalidOperationException(); constantValues = new List(); - var parameters = EnumerableUtils.One(ConstantParameter).Concat(lambda.Parameters).ToArray(lambda.Parameters.Count + 1); + var parameters = lambda.Parameters.Prepend(ConstantParameter).ToArray(lambda.Parameters.Count + 1); var body = Visit(lambda.Body); // Preserve original delegate type because it may differ from types of parameters / return value return FastExpression.Lambda(FixDelegateType(lambda.Type), body, parameters); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/Internals/ConfigurationSectionExtensions.cs b/Orm/Xtensive.Orm/Orm/Configuration/Internals/ConfigurationSectionExtensions.cs index 35f4c1d3e..fe3b8e427 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/Internals/ConfigurationSectionExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/Internals/ConfigurationSectionExtensions.cs @@ -26,7 +26,7 @@ public static IEnumerable GetSelfOrChildren(this IConfigu if (isIndexed) return children; else - return EnumerableUtils.One(section); + return Enumerable.Repeat(section, 1); } return children; } diff --git a/Orm/Xtensive.Orm/Orm/Entity.cs b/Orm/Xtensive.Orm/Orm/Entity.cs index 5013be02d..fe4c7ea34 100644 --- a/Orm/Xtensive.Orm/Orm/Entity.cs +++ b/Orm/Xtensive.Orm/Orm/Entity.cs @@ -397,12 +397,12 @@ public void Validate() internal void RemoveLaterInternal(EntityRemoveReason reason) { - Session.RemovalProcessor.EnqueueForRemoval(EnumerableUtils.One(this), reason); + Session.RemovalProcessor.EnqueueForRemoval(Enumerable.Repeat(this, 1), reason); } internal void RemoveInternal(EntityRemoveReason reason) { - Session.RemovalProcessor.Remove(EnumerableUtils.One(this), reason); + Session.RemovalProcessor.Remove(Enumerable.Repeat(this, 1), reason); } /// Entity is removed. diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeBuilder.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeBuilder.cs index 8dd751300..137bb6c8c 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/NodeBuilder.cs @@ -116,7 +116,7 @@ private IEnumerable VisitMemberAccess(MemberExpression access) result = new FieldNode(path, field); } - return EnumerableUtils.One(result); + return Enumerable.Repeat(result, 1); } private static ObjectModel.ReadOnlyCollection WrapNodes(IEnumerable nodes) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/LocalCollectionExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/LocalCollectionExpression.cs index 2e2eef558..bb700b26b 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/LocalCollectionExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/LocalCollectionExpression.cs @@ -28,7 +28,7 @@ internal class LocalCollectionExpression : ParameterizedExpression, public IEnumerable Columns => Fields .SelectMany(field => field.Value is ColumnExpression - ? EnumerableUtils.One(field.Value) + ? Enumerable.Repeat(field.Value, 1) : ((LocalCollectionExpression) field.Value).Columns.Cast()) .Cast(); diff --git a/Orm/Xtensive.Orm/Orm/Linq/ItemToTupleConverter{TItem}.cs b/Orm/Xtensive.Orm/Orm/Linq/ItemToTupleConverter{TItem}.cs index 9e8cc1188..df3a71abf 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/ItemToTupleConverter{TItem}.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/ItemToTupleConverter{TItem}.cs @@ -42,7 +42,7 @@ private class TupleTypeCollection: IReadOnlyCollection public void Add(Type type) { count++; - types = types==null ? EnumerableUtils.One(type) : types.Concat(EnumerableUtils.One(type)); + types = types==null ? Enumerable.Repeat(type, 1) : types.Append(type); } public void AddRange(IReadOnlyCollection newTypes) diff --git a/Orm/Xtensive.Orm/Orm/Operations/KeySetOperation.cs b/Orm/Xtensive.Orm/Orm/Operations/KeySetOperation.cs index 977f4486c..e4eb0fbaf 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/KeySetOperation.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/KeySetOperation.cs @@ -49,7 +49,7 @@ protected override void PrepareSelf(OperationExecutionContext context) /// public KeySetOperation(Key key) - : this(EnumerableUtils.One(key)) + : this(Enumerable.Repeat(key, 1)) { } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs index b5c46e155..b2e8827a2 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs @@ -45,7 +45,7 @@ protected override IncludeProvider VisitInclude(IncludeProvider provider) var currentMapping = mappings[provider.Source]; var calulatedColumn = provider.Header.Columns.Last(); - mappings[provider] = Merge(currentMapping, EnumerableUtils.One(calulatedColumn.Index)); + mappings[provider] = Merge(currentMapping, Enumerable.Repeat(calulatedColumn.Index, 1)); if (source == provider.Source) { return provider; } @@ -327,7 +327,7 @@ protected override RowNumberProvider VisitRowNumber(RowNumberProvider provider) var newSource = VisitCompilable(provider.Source); var currentMapping = mappings[provider.Source]; var rowNumberColumn = provider.Header.Columns.Last(); - mappings[provider] = Merge(currentMapping, EnumerableUtils.One(rowNumberColumn.Index)); + mappings[provider] = Merge(currentMapping, Enumerable.Repeat(rowNumberColumn.Index, 1)); return newSource == provider.Source ? provider : new RowNumberProvider(newSource, rowNumberColumn.Name); diff --git a/Orm/Xtensive.Orm/Orm/Transaction.cs b/Orm/Xtensive.Orm/Orm/Transaction.cs index 938836926..2d29600ff 100644 --- a/Orm/Xtensive.Orm/Orm/Transaction.cs +++ b/Orm/Xtensive.Orm/Orm/Transaction.cs @@ -276,7 +276,7 @@ private void PromoteLifetimeTokens() private void PromoteLifetimeTokensToSession() { if (Outer == null - && Session.TryPromoteTokens(EnumerableUtils.One(LifetimeToken).Union(lifetimeTokens))) { + && Session.TryPromoteTokens(Enumerable.Repeat(LifetimeToken, 1).Union(lifetimeTokens))) { ClearLifetimeTokens(); } } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/HintGenerator.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/HintGenerator.cs index 48c58c055..47377aa5e 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/HintGenerator.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/HintGenerator.cs @@ -811,7 +811,7 @@ bool IsMovedToAnotherHierarchy(StoredTypeInfo oldType) private static IEnumerable GetAffectedMappedTypes(StoredTypeInfo type, bool includeInheritors) { - var result = EnumerableUtils.One(type); + var result = Enumerable.Repeat(type, 1); if (includeInheritors) { result = result.Concat(type.AllDescendants); } @@ -824,7 +824,7 @@ private static IEnumerable GetAffectedMappedTypes(StoredTypeInfo private static StoredTypeInfo[] GetAffectedMappedTypesAsArray(StoredTypeInfo type, bool includeInheritors) { var count = 1; - var result = EnumerableUtils.One(type); + var result = Enumerable.Repeat(type, 1); if (includeInheritors) { result = result.Concat(type.AllDescendants); count += type.AllDescendants.Length; From 36006f7ef9f85d1b2c543a845fd16edad888c43f Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Tue, 10 Mar 2026 16:01:35 +0500 Subject: [PATCH 29/55] Simplify parameter null validation calls --- .../Arithmetic/WrappingArithmetic{T,TBase}.cs | 2 +- Orm/Xtensive.Orm/Caching/CacheBase.cs | 2 +- .../FastConcurrentLruCache{TKey, TItem}.cs | 2 +- Orm/Xtensive.Orm/Caching/InfiniteCache.cs | 6 +- Orm/Xtensive.Orm/Caching/Interfaces/ICache.cs | 2 +- .../Caching/LruCache{TKey, TItem, TCached}.cs | 2 +- .../Caching/LruCache{TKey, TItem}.cs | 2 +- Orm/Xtensive.Orm/Caching/MfLruCache.cs | 2 +- Orm/Xtensive.Orm/Caching/WeakCache.cs | 2 +- Orm/Xtensive.Orm/Caching/WeakestCache.cs | 4 +- Orm/Xtensive.Orm/Collections/ChainedBuffer.cs | 6 +- Orm/Xtensive.Orm/Collections/Deque.cs | 12 +- .../Collections/EnumerableUtils.cs | 4 +- .../Collections/ExtensionCollection.cs | 10 +- Orm/Xtensive.Orm/Collections/Graphs/Graph.cs | 2 +- .../Collections/Graphs/TopologicalSorter.cs | 2 +- .../TypeRegistrationProcessorBase.cs | 4 +- Orm/Xtensive.Orm/Collections/TypeRegistry.cs | 10 +- .../Comparison/AdvancedComparer.cs | 2 +- .../Comparison/ComparisonRules.cs | 2 +- .../WrappingComparer{T,TBase1,TBase2}.cs | 2 +- .../Comparison/WrappingComparer{T,TBase}.cs | 2 +- Orm/Xtensive.Orm/Core/AsyncFutureResult.cs | 4 +- Orm/Xtensive.Orm/Core/DisposableSet.cs | 2 +- Orm/Xtensive.Orm/Core/Exceptions.cs | 8 +- .../Core/Extensions/ArrayExtensions.cs | 8 +- .../Core/Extensions/CollectionExtensions.cs | 24 +- .../Core/Extensions/EnumerableExtensions.cs | 16 +- .../Core/Extensions/ExpressionExtensions.cs | 18 +- .../Core/Extensions/HasServicesExtensions.cs | 2 +- .../Core/Extensions/ListExtensions.cs | 19 +- .../Extensions/StringBuilderExtensions.cs | 17 +- .../Core/Extensions/StringExtensions.cs | 24 +- Orm/Xtensive.Orm/Core/SimpleXmlSerializer.cs | 4 +- Orm/Xtensive.Orm/IoC/ServiceContainer.cs | 6 +- Orm/Xtensive.Orm/IoC/ServiceRegistration.cs | 2 +- .../Internals/ExpressionHashCodeCalculator.cs | 2 +- .../Internals/ReflectionExtensions.cs | 6 +- .../Modelling/Actions/ActionSequence.cs | 4 +- .../Modelling/Actions/CreateNodeAction.cs | 6 +- .../Modelling/Actions/GroupingNodeAction.cs | 2 +- .../Modelling/Actions/MoveNodeAction.cs | 2 +- .../Modelling/Actions/NodeAction.cs | 2 +- .../Modelling/Actions/PropertyChangeAction.cs | 2 +- .../Modelling/Actions/RemoveNodeAction.cs | 2 +- .../Modelling/Comparison/Comparer.cs | 6 +- .../Comparison/Hints/CopyDataHint.cs | 2 +- .../Modelling/Comparison/Hints/DataHint.cs | 4 +- .../Modelling/Comparison/Hints/HintSet.cs | 4 +- .../Comparison/Hints/UpdateDataHint.cs | 2 +- Orm/Xtensive.Orm/Modelling/Node.cs | 10 +- .../Orm/Attributes/IndexAttribute.cs | 2 +- .../Orm/Building/Builders/DomainBuilder.cs | 2 +- .../Builders/MemberCompilerProviderBuilder.cs | 4 +- .../Builders/PartialIndexFilterBuilder.cs | 2 +- .../Definitions/HierarchyDefCollection.cs | 4 +- .../Orm/Building/Definitions/TypeDef.cs | 4 +- .../Building/Definitions/TypeDefCollection.cs | 4 +- .../Orm/Configuration/DomainConfiguration.cs | 18 +- .../ExtensionConfigurationCollection.cs | 4 +- .../Internals/LoggingConfigurationReader.cs | 8 +- .../Orm/Configuration/LoggingConfiguration.cs | 2 +- .../Configuration/NameMappingCollection.cs | 2 +- .../Options/OptionsCollection{T}.cs | 2 +- Orm/Xtensive.Orm/Orm/DelayedQuery.cs | 6 +- Orm/Xtensive.Orm/Orm/Domain.cs | 4 +- Orm/Xtensive.Orm/Orm/Entity.cs | 10 +- Orm/Xtensive.Orm/Orm/EntityEventBroker.cs | 12 +- Orm/Xtensive.Orm/Orm/EntitySet{T}.cs | 8 +- .../Nodes/CustomProximityTerm.cs | 4 +- .../Nodes/GenerationTerm.cs | 8 +- .../FullTextSearchCondition/Nodes/Operator.cs | 12 +- .../NonPairedReferenceChangesRegistry.cs | 12 +- .../ReferenceFieldsChangesRegistry.cs | 14 +- .../FieldAccessors/StructureFieldAccessor.cs | 2 +- .../Orm/Internals/Prefetch/EntityGroupTask.cs | 2 +- .../Orm/Internals/Prefetch/PrefetchManager.cs | 4 +- .../Internals/Prefetch/RootEntityContainer.cs | 2 +- .../ReferentialIntegrity/RemovalProcessor.cs | 4 +- .../Orm/Internals/RemapContext.cs | 4 +- .../Orm/Internals/StorageNodeRegistry.cs | 8 +- .../Orm/Internals/VersionGenerator.cs | 2 +- Orm/Xtensive.Orm/Orm/Key.cs | 22 +- .../Linq/LocalCollectionKeyTypeExtractor.cs | 2 +- .../Materialization/MaterializationContext.cs | 2 +- .../MemberCompilerProvider.cs | 6 +- .../MemberCompilerProviderFactory.cs | 2 +- Orm/Xtensive.Orm/Orm/Linq/Queryable.cs | 2 +- .../Orm/Linq/TranslatorContext.cs | 6 +- Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs | 4 +- Orm/Xtensive.Orm/Orm/Logging/LogManager.cs | 4 +- Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs | 2 +- .../Stored/Internals/TypeMappingUpdater.cs | 4 +- Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs | 8 +- .../Orm/Model/TypeInfoCollection.cs | 8 +- .../Orm/Operations/EntityOperation.cs | 2 +- .../Internals/OperationRegistrationScope.cs | 2 +- .../Orm/Operations/KeyGenerateOperation.cs | 2 +- .../Operations/ValidateVersionOperation.cs | 2 +- .../CommandProcessing/CommandFactory.cs | 8 +- .../Orm/Providers/CompilationService.cs | 4 +- .../Expressions/ExpressionProcessor.cs | 6 +- .../Orm/Providers/MappingResolver.cs | 6 +- Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs | 38 +- .../Requests/QueryParameterBinding.cs | 2 +- .../Orm/Providers/SequenceQueryBuilder.cs | 2 +- .../Orm/Providers/SqlSelectProcessor.cs | 4 +- .../SqlSessionHandler.IDirectSqlService.cs | 2 +- .../Orm/Providers/StorageDriver.cs | 10 +- .../Orm/Providers/StorageSequenceAccessor.cs | 2 +- Orm/Xtensive.Orm/Orm/QueryEndpoint.cs | 38 +- .../Orm/QueryableExtensions.Async.cs | 194 +++--- Orm/Xtensive.Orm/Orm/QueryableExtensions.cs | 50 +- .../Orm/Rse/ProviderExtensions.cs | 8 +- .../Providers/Compilable/AggregateProvider.cs | 2 +- .../Providers/Compilable/CalculateProvider.cs | 2 +- .../Providers/Compilable/IncludeProvider.cs | 2 +- .../Providers/Compilable/SelectProvider.cs | 2 +- .../Rse/Providers/Compilable/StoreProvider.cs | 2 +- .../Orm/Rse/Providers/ExecutableProvider.cs | 4 +- .../Orm/Rse/Providers/TagScope.cs | 4 +- Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs | 4 +- .../Internals/ApplyFilterRewriter.cs | 10 +- .../Internals/ApplyParameterSearcher.cs | 2 +- .../CalculateRelatedExpressionRewriter.cs | 2 +- .../Internals/OrderingRewriter.cs | 2 +- .../Internals/ParameterRewriter.cs | 2 +- .../Rse/Transformation/TupleAccessGatherer.cs | 4 +- .../Rse/Transformation/TupleAccessRewriter.cs | 4 +- .../Orm/Services/DirectEntityAccessor.cs | 2 +- .../Orm/Services/DirectEntitySetAccessor.cs | 8 +- .../Orm/Services/DirectPersistentAccessor.cs | 16 +- .../Orm/Services/Old/DirectStateAccessor.cs | 6 +- .../Services/QueryBuilding/QueryBuilder.cs | 14 +- .../Orm/Services/QueryFormatter.cs | 6 +- Orm/Xtensive.Orm/Orm/Session.Persist.cs | 2 +- Orm/Xtensive.Orm/Orm/Session.Query.cs | 2 +- Orm/Xtensive.Orm/Orm/StorageNode.cs | 8 +- Orm/Xtensive.Orm/Orm/Transaction.cs | 6 +- .../Orm/Upgrade/Hints/ChangeFieldTypeHint.cs | 2 +- .../Orm/Upgrade/Hints/CopyFieldHint.cs | 6 +- .../Orm/Upgrade/Hints/MoveFieldHint.cs | 6 +- .../Orm/Upgrade/Hints/RenameFieldHint.cs | 6 +- .../Orm/Upgrade/Hints/RenameTypeHint.cs | 2 +- .../Internals/DomainExtractedModelBuilder.cs | 4 +- .../Internals/ExtractedModelBuilderFactory.cs | 2 +- .../Orm/Validation/EntityErrorInfo.cs | 4 +- .../Collections/SqlInsertValuesCollection.cs | 2 +- .../Sql/Dml/Expressions/SqlCursor.cs | 6 +- Orm/Xtensive.Orm/Sql/SqlDml.cs | 597 +++++++++--------- 150 files changed, 828 insertions(+), 851 deletions(-) diff --git a/Orm/Xtensive.Orm/Arithmetic/WrappingArithmetic{T,TBase}.cs b/Orm/Xtensive.Orm/Arithmetic/WrappingArithmetic{T,TBase}.cs index 8f2933728..898817114 100644 --- a/Orm/Xtensive.Orm/Arithmetic/WrappingArithmetic{T,TBase}.cs +++ b/Orm/Xtensive.Orm/Arithmetic/WrappingArithmetic{T,TBase}.cs @@ -34,7 +34,7 @@ public abstract class WrappingArithmetic : ArithmeticBase public WrappingArithmetic(IArithmeticProvider provider, ArithmeticRules rules) : base(provider, rules) { - ArgumentNullException.ThrowIfNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(provider); BaseArithmetic = provider.GetArithmetic(); } } diff --git a/Orm/Xtensive.Orm/Caching/CacheBase.cs b/Orm/Xtensive.Orm/Caching/CacheBase.cs index ffe20a3a4..3463dfb3f 100755 --- a/Orm/Xtensive.Orm/Caching/CacheBase.cs +++ b/Orm/Xtensive.Orm/Caching/CacheBase.cs @@ -39,7 +39,7 @@ public abstract class CacheBase : ICache /// public virtual void Remove(TItem item) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); RemoveKey(KeyExtractor(item)); } diff --git a/Orm/Xtensive.Orm/Caching/FastConcurrentLruCache{TKey, TItem}.cs b/Orm/Xtensive.Orm/Caching/FastConcurrentLruCache{TKey, TItem}.cs index 4521555bf..2f739f7f3 100755 --- a/Orm/Xtensive.Orm/Caching/FastConcurrentLruCache{TKey, TItem}.cs +++ b/Orm/Xtensive.Orm/Caching/FastConcurrentLruCache{TKey, TItem}.cs @@ -40,7 +40,7 @@ public class FastConcurrentLruCache : /// public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var key = KeyExtractor(item); if (replaceIfExists) { realCache.AddOrUpdate(key, item); diff --git a/Orm/Xtensive.Orm/Caching/InfiniteCache.cs b/Orm/Xtensive.Orm/Caching/InfiniteCache.cs index 33238c0cb..65ad244df 100644 --- a/Orm/Xtensive.Orm/Caching/InfiniteCache.cs +++ b/Orm/Xtensive.Orm/Caching/InfiniteCache.cs @@ -53,7 +53,7 @@ public override bool ContainsKey(TKey key) /// public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var key = KeyExtractor(item); TItem cachedItem; @@ -114,9 +114,9 @@ public InfiniteCache(Converter keyExtractor) /// capacity is out of range. public InfiniteCache(int capacity, Converter keyExtractor) { - ArgumentNullException.ThrowIfNull(keyExtractor, "keyExtractor"); + ArgumentNullException.ThrowIfNull(keyExtractor); if (capacity < 0) - throw new ArgumentOutOfRangeException("capacity", capacity, Strings.ExArgumentValueMustBeGreaterThanOrEqualToZero); + throw new ArgumentOutOfRangeException(nameof(capacity), capacity, Strings.ExArgumentValueMustBeGreaterThanOrEqualToZero); this.KeyExtractor = keyExtractor; items = new Dictionary(capacity); } diff --git a/Orm/Xtensive.Orm/Caching/Interfaces/ICache.cs b/Orm/Xtensive.Orm/Caching/Interfaces/ICache.cs index 5255e9a06..7c37bef86 100644 --- a/Orm/Xtensive.Orm/Caching/Interfaces/ICache.cs +++ b/Orm/Xtensive.Orm/Caching/Interfaces/ICache.cs @@ -92,7 +92,7 @@ public interface ICache : IEnumerable, IInvalidatable /// The item to remove. void Remove(TItem item) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); RemoveKey(KeyExtractor(item)); } diff --git a/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem, TCached}.cs b/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem, TCached}.cs index 822047a30..038566e15 100644 --- a/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem, TCached}.cs +++ b/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem, TCached}.cs @@ -113,7 +113,7 @@ public override bool ContainsKey(TKey key) /// public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var key = KeyExtractor(item); TCached cached = cacheConverter.ConvertForward(item); TCached oldCached; diff --git a/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem}.cs b/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem}.cs index 50280e220..264a0eeac 100644 --- a/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem}.cs +++ b/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem}.cs @@ -106,7 +106,7 @@ public override bool ContainsKey(TKey key) /// public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var key = KeyExtractor(item); var cached = new KeyValuePair(key, item); KeyValuePair oldCached; diff --git a/Orm/Xtensive.Orm/Caching/MfLruCache.cs b/Orm/Xtensive.Orm/Caching/MfLruCache.cs index 7a256b96b..ec9ea7f57 100644 --- a/Orm/Xtensive.Orm/Caching/MfLruCache.cs +++ b/Orm/Xtensive.Orm/Caching/MfLruCache.cs @@ -153,7 +153,7 @@ public override bool ContainsKey(TKey key) /// public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); OnOperation2(); var key = KeyExtractor(item); CachedItem cached; diff --git a/Orm/Xtensive.Orm/Caching/WeakCache.cs b/Orm/Xtensive.Orm/Caching/WeakCache.cs index ec1b2b570..2938925ae 100644 --- a/Orm/Xtensive.Orm/Caching/WeakCache.cs +++ b/Orm/Xtensive.Orm/Caching/WeakCache.cs @@ -87,7 +87,7 @@ public override bool TryGetItem(TKey key, bool markAsHit, out TItem item) [SecuritySafeCritical] public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentNullException.ThrowIfNull(item, nameof(item)); + ArgumentNullException.ThrowIfNull(item); RegisterOperation(2); var key = KeyExtractor(item); if (items == null) { diff --git a/Orm/Xtensive.Orm/Caching/WeakestCache.cs b/Orm/Xtensive.Orm/Caching/WeakestCache.cs index a8e8cab41..aab0b5f5d 100644 --- a/Orm/Xtensive.Orm/Caching/WeakestCache.cs +++ b/Orm/Xtensive.Orm/Caching/WeakestCache.cs @@ -210,7 +210,7 @@ public override bool ContainsKey(TKey key) [SecuritySafeCritical] public override TItem Add(TItem item, bool replaceIfExists) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var key = KeyExtractor(item); ArgumentNullException.ThrowIfNull(key, "KeyExtractor.Invoke(item)"); RegisterOperation(4); @@ -235,7 +235,7 @@ public override TItem Add(TItem item, bool replaceIfExists) [SecuritySafeCritical] public override void RemoveKey(TKey key) { - ArgumentNullException.ThrowIfNull(key, "key"); + ArgumentNullException.ThrowIfNull(key); if (items.Remove(key, out var entry)) { entry.Dispose(); } diff --git a/Orm/Xtensive.Orm/Collections/ChainedBuffer.cs b/Orm/Xtensive.Orm/Collections/ChainedBuffer.cs index a3884b8bf..db6fffe85 100644 --- a/Orm/Xtensive.Orm/Collections/ChainedBuffer.cs +++ b/Orm/Xtensive.Orm/Collections/ChainedBuffer.cs @@ -116,8 +116,8 @@ public bool Contains(T item) /// public void CopyTo(T[] array, int arrayIndex) { - ArgumentNullException.ThrowIfNull(array, "array"); - ArgumentValidator.EnsureArgumentIsInRange(arrayIndex, 0, int.MaxValue, "arrayIndex"); + ArgumentNullException.ThrowIfNull(array); + ArgumentValidator.EnsureArgumentIsInRange(arrayIndex, 0, int.MaxValue, nameof(arrayIndex)); if (array.Length < totalItemCount + arrayIndex) throw new ArgumentException(); @@ -135,7 +135,7 @@ public bool Remove(T item) /// public void AddRange(IEnumerable items) { - ArgumentNullException.ThrowIfNull(items, "items"); + ArgumentNullException.ThrowIfNull(items); foreach (var item in items) Add(item); } diff --git a/Orm/Xtensive.Orm/Collections/Deque.cs b/Orm/Xtensive.Orm/Collections/Deque.cs index 8845a8ce5..f6f27b655 100644 --- a/Orm/Xtensive.Orm/Collections/Deque.cs +++ b/Orm/Xtensive.Orm/Collections/Deque.cs @@ -272,26 +272,26 @@ public bool Contains(T item) /// public void CopyTo(T[] array, int arrayIndex) { - ArgumentNullException.ThrowIfNull(array, "array"); + ArgumentNullException.ThrowIfNull(array); array.EnsureIndexIsValid(arrayIndex); if (arrayIndex + count > array.Length) - throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, "array"); + throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, nameof(array)); InnerCopyTo(array, arrayIndex); } /// public void CopyTo(Array array, int index) { - ArgumentNullException.ThrowIfNull(array, "array"); + ArgumentNullException.ThrowIfNull(array); array.EnsureIndexIsValid(index); if (array.Rank!=1) - throw new ArgumentException(Strings.ExArrayIsMultidimensional, "array"); + throw new ArgumentException(Strings.ExArrayIsMultidimensional, nameof(array)); if (array.GetLowerBound(0)!=0) - throw new ArgumentException(Strings.ExArrayDoesNotHaveZeroBasedIndexing, "array"); + throw new ArgumentException(Strings.ExArrayDoesNotHaveZeroBasedIndexing, nameof(array)); if (index + count > array.Length) - throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, "array"); + throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, nameof(array)); InnerCopyTo(array, index); } diff --git a/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs b/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs index 32903b82f..317fb4b11 100644 --- a/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs +++ b/Orm/Xtensive.Orm/Collections/EnumerableUtils.cs @@ -40,7 +40,7 @@ public static IEnumerable One(TItem value) /// starting from the one. public static IEnumerable Unfold(TItem first, Func next) { - ArgumentNullException.ThrowIfNull(next, "next"); + ArgumentNullException.ThrowIfNull(next); var current = first; while (current!=null) { yield return current; @@ -63,7 +63,7 @@ public static IEnumerable Unfold(TItem first, Func n /// public static IEnumerable Unfold(TItem first, Func include, Func next) { - ArgumentNullException.ThrowIfNull(next, "next"); + ArgumentNullException.ThrowIfNull(next); var current = first; while (include.Invoke(current)) { yield return current; diff --git a/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs b/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs index 18a1de2a5..05ba6408e 100644 --- a/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs +++ b/Orm/Xtensive.Orm/Collections/ExtensionCollection.cs @@ -45,7 +45,7 @@ public T Get() /// public object Get(Type extensionType) { - ArgumentNullException.ThrowIfNull(extensionType, "extensionType"); + ArgumentNullException.ThrowIfNull(extensionType); if (extensions==null) return null; object result; @@ -68,13 +68,13 @@ public void Set(T value) public void Set(Type extensionType, object value) { EnsureNotLocked(); - ArgumentNullException.ThrowIfNull(extensionType, "extensionType"); + ArgumentNullException.ThrowIfNull(extensionType); if (extensionType.IsValueType) throw new ArgumentException(string.Format( - Strings.ExTypeXMustBeReferenceType, extensionType.GetShortName()), "extensionType"); + Strings.ExTypeXMustBeReferenceType, extensionType.GetShortName()), nameof(extensionType)); if (value!=null && !extensionType.IsAssignableFrom(value.GetType())) throw new ArgumentException(string.Format( - Strings.ExTypeXMustImplementY, value.GetType(), extensionType.GetShortName()), "value"); + Strings.ExTypeXMustImplementY, value.GetType(), extensionType.GetShortName()), nameof(value)); if (extensions==null) if (value==null) @@ -153,7 +153,7 @@ public ExtensionCollection() public ExtensionCollection(IExtensionCollection source) : this() { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); if (source.Count==0) return; if (source is ExtensionCollection sourceLikeMe) { diff --git a/Orm/Xtensive.Orm/Collections/Graphs/Graph.cs b/Orm/Xtensive.Orm/Collections/Graphs/Graph.cs index 343a029a2..69956d8b1 100644 --- a/Orm/Xtensive.Orm/Collections/Graphs/Graph.cs +++ b/Orm/Xtensive.Orm/Collections/Graphs/Graph.cs @@ -72,7 +72,7 @@ public Graph, Edge> CreateMutableCopy() /// Otherwise is must return null. public void AddEdges(Func connector) { - ArgumentNullException.ThrowIfNull(connector, "connector"); + ArgumentNullException.ThrowIfNull(connector); foreach (var source in Nodes) foreach (var target in Nodes) { var edge = connector.Invoke(source, target); diff --git a/Orm/Xtensive.Orm/Collections/Graphs/TopologicalSorter.cs b/Orm/Xtensive.Orm/Collections/Graphs/TopologicalSorter.cs index 02116dd8f..664be691d 100644 --- a/Orm/Xtensive.Orm/Collections/Graphs/TopologicalSorter.cs +++ b/Orm/Xtensive.Orm/Collections/Graphs/TopologicalSorter.cs @@ -80,7 +80,7 @@ public static TopologicalSortResult Sort(Graph(); diff --git a/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs b/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs index e7ab2eb41..ce0694dd5 100644 --- a/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs +++ b/Orm/Xtensive.Orm/Collections/TypeRegistrationProcessorBase.cs @@ -69,8 +69,8 @@ protected virtual bool IsAcceptable(TypeRegistration registration, Type type) private static IList FindTypes(Assembly assembly, Type baseType, TypeFilter filter) { - ArgumentNullException.ThrowIfNull(assembly, "assembly"); - ArgumentNullException.ThrowIfNull(baseType, "baseType"); + ArgumentNullException.ThrowIfNull(assembly); + ArgumentNullException.ThrowIfNull(baseType); Type[] allTypes; try { diff --git a/Orm/Xtensive.Orm/Collections/TypeRegistry.cs b/Orm/Xtensive.Orm/Collections/TypeRegistry.cs index 18e0c8218..e11087156 100644 --- a/Orm/Xtensive.Orm/Collections/TypeRegistry.cs +++ b/Orm/Xtensive.Orm/Collections/TypeRegistry.cs @@ -58,7 +58,7 @@ public bool Contains(Type type) public void Register(Type type) { EnsureNotLocked(); - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); if (!isProcessingPendingActions) Register(new TypeRegistration(type)); else if (typeSet.Add(type)) { @@ -79,7 +79,7 @@ public void Register(Type type) public void Register(Assembly assembly) { EnsureNotLocked(); - ArgumentNullException.ThrowIfNull(assembly, "assembly"); + ArgumentNullException.ThrowIfNull(assembly); Register(new TypeRegistration(assembly)); } @@ -96,8 +96,8 @@ public void Register(Assembly assembly) public void Register(Assembly assembly, string @namespace) { EnsureNotLocked(); - ArgumentNullException.ThrowIfNull(assembly, "assembly"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(@namespace, "@namespace"); + ArgumentNullException.ThrowIfNull(assembly); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(@namespace, nameof(@namespace)); Register(new TypeRegistration(assembly, @namespace)); } @@ -110,7 +110,7 @@ public void Register(Assembly assembly, string @namespace) public bool Register(TypeRegistration action) { EnsureNotLocked(); - ArgumentNullException.ThrowIfNull(action, "action"); + ArgumentNullException.ThrowIfNull(action); if (actionSet.Contains(action)) return false; actionSet.Add(action); diff --git a/Orm/Xtensive.Orm/Comparison/AdvancedComparer.cs b/Orm/Xtensive.Orm/Comparison/AdvancedComparer.cs index 829176e32..b3e599e61 100644 --- a/Orm/Xtensive.Orm/Comparison/AdvancedComparer.cs +++ b/Orm/Xtensive.Orm/Comparison/AdvancedComparer.cs @@ -132,7 +132,7 @@ public AdvancedComparer Cast() public AdvancedComparer(IAdvancedComparer implementation) : this(implementation, implementation, implementation) { - ArgumentNullException.ThrowIfNull(implementation, "implementation"); + ArgumentNullException.ThrowIfNull(implementation); } /// diff --git a/Orm/Xtensive.Orm/Comparison/ComparisonRules.cs b/Orm/Xtensive.Orm/Comparison/ComparisonRules.cs index 6f4cb4793..eb31a4343 100644 --- a/Orm/Xtensive.Orm/Comparison/ComparisonRules.cs +++ b/Orm/Xtensive.Orm/Comparison/ComparisonRules.cs @@ -289,7 +289,7 @@ public ComparisonRules(ComparisonRule value, ComparisonRules[] composite, Compar { if (value.Direction==Direction.None) throw Exceptions.InvalidArgument(value.Direction, "value.Direction"); - ArgumentNullException.ThrowIfNull(tail, "tail"); + ArgumentNullException.ThrowIfNull(tail); this.value = value; if (composite!=null) { int tailIndex = composite.Length-1; diff --git a/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase1,TBase2}.cs b/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase1,TBase2}.cs index 1ee86594b..f910b161e 100644 --- a/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase1,TBase2}.cs +++ b/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase1,TBase2}.cs @@ -41,7 +41,7 @@ public abstract class WrappingComparer: AdvancedComparerBase< public WrappingComparer(IComparerProvider provider, ComparisonRules comparisonRules) : base(provider, comparisonRules) { - ArgumentNullException.ThrowIfNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(provider); BaseComparer1 = provider.GetComparer().ApplyRules(comparisonRules[0]); BaseComparer2 = provider.GetComparer().ApplyRules(comparisonRules[1]); } diff --git a/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase}.cs b/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase}.cs index d436c2fd3..b34af0256 100644 --- a/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase}.cs +++ b/Orm/Xtensive.Orm/Comparison/WrappingComparer{T,TBase}.cs @@ -37,7 +37,7 @@ public abstract class WrappingComparer : AdvancedComparerBase public WrappingComparer(IComparerProvider provider, ComparisonRules comparisonRules) : base(provider, comparisonRules) { - ArgumentNullException.ThrowIfNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(provider); BaseComparer = provider.GetComparer().ApplyRules(comparisonRules); } diff --git a/Orm/Xtensive.Orm/Core/AsyncFutureResult.cs b/Orm/Xtensive.Orm/Core/AsyncFutureResult.cs index c1fd18000..a9cf7f5a3 100644 --- a/Orm/Xtensive.Orm/Core/AsyncFutureResult.cs +++ b/Orm/Xtensive.Orm/Core/AsyncFutureResult.cs @@ -75,7 +75,7 @@ public override async ValueTask DisposeAsync() public AsyncFutureResult(Func worker, BaseLog logger) { - ArgumentNullException.ThrowIfNull(worker, nameof(worker)); + ArgumentNullException.ThrowIfNull(worker); this.logger = logger; @@ -84,7 +84,7 @@ public AsyncFutureResult(Func worker, BaseLog logger) public AsyncFutureResult(Func> worker, BaseLog logger, bool startWorker) { - ArgumentNullException.ThrowIfNull(worker, nameof(worker)); + ArgumentNullException.ThrowIfNull(worker); this.logger = logger; diff --git a/Orm/Xtensive.Orm/Core/DisposableSet.cs b/Orm/Xtensive.Orm/Core/DisposableSet.cs index 919c9ed1e..62d30dd32 100644 --- a/Orm/Xtensive.Orm/Core/DisposableSet.cs +++ b/Orm/Xtensive.Orm/Core/DisposableSet.cs @@ -85,7 +85,7 @@ private void EnsureInitialized() public DisposableSet(IEnumerable initialContent) : this() { - ArgumentNullException.ThrowIfNull(initialContent, "initialContent"); + ArgumentNullException.ThrowIfNull(initialContent); foreach (object o in initialContent) Add(o as IDisposable); } diff --git a/Orm/Xtensive.Orm/Core/Exceptions.cs b/Orm/Xtensive.Orm/Core/Exceptions.cs index b13be2234..b407212e3 100644 --- a/Orm/Xtensive.Orm/Core/Exceptions.cs +++ b/Orm/Xtensive.Orm/Core/Exceptions.cs @@ -163,8 +163,8 @@ public static Exception CollectionHasBeenChanged([InvokerParameterName] string p /// Newly created exception. public static InvalidOperationException ContextRequired(Type contextType, Type scopeType) { - ArgumentNullException.ThrowIfNull(contextType, "contextType"); - ArgumentNullException.ThrowIfNull(scopeType, "scopeType"); + ArgumentNullException.ThrowIfNull(contextType); + ArgumentNullException.ThrowIfNull(scopeType); return new InvalidOperationException( string.Format(Strings.ExContextRequired, contextType.GetShortName(), scopeType.GetShortName())); } @@ -189,7 +189,7 @@ public static InvalidOperationException ContextRequired() /// Newly created exception. public static InvalidOperationException ScopeRequired(Type scopeType) { - ArgumentNullException.ThrowIfNull(scopeType, "scopeType"); + ArgumentNullException.ThrowIfNull(scopeType); return new InvalidOperationException( string.Format(Strings.ExScopeRequired, scopeType.GetShortName())); } @@ -212,7 +212,7 @@ public static InvalidOperationException ScopeRequired() /// Newly created exception. public static InvalidOperationException LambdaParameterIsOutOfScope(ParameterExpression parameter) { - ArgumentNullException.ThrowIfNull(parameter, "parameter"); + ArgumentNullException.ThrowIfNull(parameter); return new InvalidOperationException(string.Format(Strings.ExLambdaParameterXIsOutOfScope, parameter.Name)); } } diff --git a/Orm/Xtensive.Orm/Core/Extensions/ArrayExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/ArrayExtensions.cs index a51859794..76adfed17 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/ArrayExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/ArrayExtensions.cs @@ -46,7 +46,7 @@ public static TNewItem[] Cast(this TItem[] source) /// An array of converted elements. public static TNewItem[] Convert(this TItem[] source, Converter converter) { - ArgumentNullException.ThrowIfNull(converter, "converter"); + ArgumentNullException.ThrowIfNull(converter); var items = new TNewItem[source.Length]; int i = 0; foreach (TItem item in source) @@ -69,7 +69,7 @@ public static TNewItem[] Convert(this TItem[] source, Converter /// public static int IndexOf(this TItem[] items, TItem item) { - ArgumentNullException.ThrowIfNull(items, "items"); + ArgumentNullException.ThrowIfNull(items); for (int i = 0; i < items.Length; i++) if (AdvancedComparerStruct.System.Equals(item, items[i])) return i; @@ -86,7 +86,7 @@ public static int IndexOf(this TItem[] items, TItem item) /// An enumerable iterating through the segment. public static IEnumerable Segment(this TItem[] items, int offset, int length) { - ArgumentNullException.ThrowIfNull(items, "items"); + ArgumentNullException.ThrowIfNull(items); int lastIndex = offset + length; if (offset<0) offset = 0; @@ -114,7 +114,7 @@ public static IEnumerable Segment(this TItem[] items, int offset, /// Value type is passed instead of class. public static int IndexOf(this TItem[] items, TItem item, bool byReference) { - ArgumentNullException.ThrowIfNull(items, "items"); + ArgumentNullException.ThrowIfNull(items); if (!byReference) return IndexOf(items, item); if (typeof(TItem).IsValueType) diff --git a/Orm/Xtensive.Orm/Core/Extensions/CollectionExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/CollectionExtensions.cs index b2c57db0e..834899dd9 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/CollectionExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/CollectionExtensions.cs @@ -43,12 +43,12 @@ public static TItem[] ToArray(this ICollection source) /// Destination array is too small. public static void Copy(this ICollection source, TItem[] target, int targetIndex) { - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(target); if (targetIndex < 0 || targetIndex > target.Length) - throw new ArgumentOutOfRangeException("targetIndex"); + throw new ArgumentOutOfRangeException(nameof(targetIndex)); if ((target.Length - targetIndex) < source.Count) - throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, "target"); + throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, nameof(target)); foreach (TItem item in source) target[targetIndex++] = item; @@ -67,14 +67,14 @@ public static void Copy(this ICollection source, TItem[] target, i /// Destination array is too small or multidimensional. public static void Copy(this ICollection source, Array target, int targetIndex) { - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(target); if (targetIndex < 0 || targetIndex > target.Length) - throw new ArgumentOutOfRangeException("targetIndex"); + throw new ArgumentOutOfRangeException(nameof(targetIndex)); if ((target.Length - targetIndex) < source.Count) - throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, "target"); + throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, nameof(target)); if (target.Rank != 1) - throw new ArgumentException(Strings.ExArrayIsMultidimensional, "target"); + throw new ArgumentException(Strings.ExArrayIsMultidimensional, nameof(target)); // if (target.GetType().GetElementType().IsAssignableFrom(typeof(T))) // throw new ArgumentException(Strings.ExIncompatibleArrayType, "target"); @@ -208,9 +208,9 @@ public static List SelectToList( internal static Pair SelectToArrays( this ICollection source, Func firstArraySelector, Func secondArraySelector) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(firstArraySelector, nameof(firstArraySelector)); - ArgumentNullException.ThrowIfNull(secondArraySelector, nameof(secondArraySelector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(firstArraySelector); + ArgumentNullException.ThrowIfNull(secondArraySelector); var first = new TFirst[source.Count]; var second = new TSecond[source.Count]; diff --git a/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs index ac3d433a3..614d585bf 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs @@ -131,7 +131,7 @@ public static void ForEach(this IEnumerable items, Action action) /// all the items from the sequence. public static ChainedBuffer ToChainedBuffer(this IEnumerable source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); return new ChainedBuffer(source); } @@ -146,8 +146,8 @@ public static ChainedBuffer ToChainedBuffer(this IEnumerable source) /// A sequence of converted elements. public static IEnumerable Convert(this IEnumerable source, Converter converter) { - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(converter, "converter"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(converter); foreach (TItem item in source) yield return converter(item); } @@ -377,9 +377,9 @@ public static Dictionary ToDictionary( IEqualityComparer comparer, int capacity) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(keySelector, nameof(keySelector)); - ArgumentNullException.ThrowIfNull(elementSelector, nameof(elementSelector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(keySelector); + ArgumentNullException.ThrowIfNull(elementSelector); ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(capacity, 0, nameof(capacity)); var dictionary = comparer != null @@ -574,8 +574,8 @@ public static bool AtMost(this IEnumerable sequence, int numberOfE /// Topologically sorted if no cycles exist, otherwise null. public static List SortTopologically(this IEnumerable values, Func edgeTester) { - ArgumentNullException.ThrowIfNull(values, "values"); - ArgumentNullException.ThrowIfNull(edgeTester, "edgeTester"); + ArgumentNullException.ThrowIfNull(values); + ArgumentNullException.ThrowIfNull(edgeTester); var graph = new Graph, Edge>(); graph.Nodes.AddRange(values.Select(p => new Node(p))); diff --git a/Orm/Xtensive.Orm/Core/Extensions/ExpressionExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/ExpressionExtensions.cs index c1492d155..3b80bb924 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/ExpressionExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/ExpressionExtensions.cs @@ -55,7 +55,7 @@ public static string ToString(this Expression expression, bool inCSharpNotation) /// public static bool IsNull(this Expression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); if (expression.NodeType==ExpressionType.Constant) { var constantExpression = (ConstantExpression) expression; return constantExpression.Value==null; @@ -166,12 +166,12 @@ public static Type GetReturnType(this LambdaExpression lambda) /// The root node of expression isn't of type. public static MemberInfo GetMember(this Expression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); expression = expression.StripLambda().StripCasts(); var me = expression as MemberExpression; if (me==null) throw new ArgumentException( - string.Format(Strings.ExInvalidArgumentType, typeof (MemberExpression)), "expression"); + string.Format(Strings.ExInvalidArgumentType, typeof (MemberExpression)), nameof(expression)); return me.Member; } @@ -215,12 +215,12 @@ public static PropertyInfo GetProperty(this Expression expression) /// Expression must reference event. public static MethodInfo GetMethod(this Expression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); expression = expression.StripLambda().StripCasts(); var mce = expression as MethodCallExpression; if (mce==null) throw new ArgumentException( - string.Format(Strings.ExInvalidArgumentType, typeof (MethodCallExpression)), "expression"); + string.Format(Strings.ExInvalidArgumentType, typeof (MethodCallExpression)), nameof(expression)); return mce.Method; } @@ -232,12 +232,12 @@ public static MethodInfo GetMethod(this Expression expression) /// Expression must reference event. public static PropertyInfo GetIndexer(this Expression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); expression = expression.StripLambda().StripCasts(); var ie = expression as IndexExpression; if (ie==null) throw new ArgumentException( - string.Format(Strings.ExInvalidArgumentType, typeof (IndexExpression)), "expression"); + string.Format(Strings.ExInvalidArgumentType, typeof (IndexExpression)), nameof(expression)); return ie.Indexer; } @@ -249,12 +249,12 @@ public static PropertyInfo GetIndexer(this Expression expression) /// Expression must reference event. public static ConstructorInfo GetConstructor(this Expression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); expression = expression.StripLambda().StripCasts(); var ne = expression as NewExpression; if (ne==null) throw new ArgumentException( - string.Format(Strings.ExInvalidArgumentType, typeof (NewExpression)), "expression"); + string.Format(Strings.ExInvalidArgumentType, typeof (NewExpression)), nameof(expression)); return ne.Constructor; } diff --git a/Orm/Xtensive.Orm/Core/Extensions/HasServicesExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/HasServicesExtensions.cs index ae8fc3967..921b893b3 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/HasServicesExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/HasServicesExtensions.cs @@ -32,7 +32,7 @@ public static class HasServicesExtensions public static T GetService(this IHasServices serviceProvider, bool failIfNone) where T: class { - ArgumentNullException.ThrowIfNull(serviceProvider, "serviceProvider"); + ArgumentNullException.ThrowIfNull(serviceProvider); var service = serviceProvider.GetService(); if (failIfNone && service == null) throw new InvalidOperationException( diff --git a/Orm/Xtensive.Orm/Core/Extensions/ListExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/ListExtensions.cs index 3a31a6f2b..ec0301ff8 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/ListExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/ListExtensions.cs @@ -52,13 +52,12 @@ public static int IndexOf(this IReadOnlyList list, T item) /// Destination array is too small. public static void Copy(this IList source, TItem[] target, int targetIndex) { - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(target); if (targetIndex < 0 || targetIndex > target.Length) - throw new ArgumentOutOfRangeException("targetIndex"); + throw new ArgumentOutOfRangeException(nameof(targetIndex)); if ((target.Length - targetIndex) < source.Count) - throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, "target"); + throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, nameof(target)); int count = source.Count; for (int i = 0; i < count; i++) @@ -78,14 +77,14 @@ public static void Copy(this IList source, TItem[] target, int tar /// Destination array is too small or multidimensional. public static void Copy(this IList source, Array target, int targetIndex) { - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(target); if (targetIndex < 0 || targetIndex > target.Length) - throw new ArgumentOutOfRangeException("targetIndex"); + throw new ArgumentOutOfRangeException(nameof(targetIndex)); if ((target.Length - targetIndex) < source.Count) - throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, "target"); + throw new ArgumentException(Strings.ExDestionationArrayIsTooSmall, nameof(target)); if (target.Rank != 1) - throw new ArgumentException(Strings.ExArrayIsMultidimensional, "target"); + throw new ArgumentException(Strings.ExArrayIsMultidimensional, nameof(target)); // if (target.GetType().GetElementType().IsAssignableFrom(typeof(T))) // throw new ArgumentException(Strings.ExIncompatibleArrayType, "target"); diff --git a/Orm/Xtensive.Orm/Core/Extensions/StringBuilderExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/StringBuilderExtensions.cs index 9d137e0d3..723c46a80 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/StringBuilderExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/StringBuilderExtensions.cs @@ -16,6 +16,7 @@ namespace Xtensive.Core public static class StringBuilderExtensions { private const char IndentChar = ' '; + private const string LowerHexChars = "0123456789abcdef"; /// /// Appends the specified indented by specified count of spaces. @@ -76,13 +77,12 @@ public static StringBuilder AppendIndented(this StringBuilder builder, int inden /// Original . public static StringBuilder AppendHexArray(this StringBuilder builder, byte[] values) { - ArgumentNullException.ThrowIfNull(builder, "builder"); - ArgumentNullException.ThrowIfNull(values, "values"); + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(values); - const string lowerHexChars = "0123456789abcdef"; foreach (var item in values) { - _ = builder.Append(lowerHexChars[item >> 4]) - .Append(lowerHexChars[item & 0xF]); + _ = builder.Append(LowerHexChars[item >> 4]) + .Append(LowerHexChars[item & 0xF]); } return builder; } @@ -97,12 +97,11 @@ public static StringBuilder AppendHexArray(this StringBuilder builder, byte[] va /// Original . public static StringBuilder AppendHexArray(this StringBuilder builder, in ReadOnlySpan values) { - ArgumentNullException.ThrowIfNull(builder, "builder"); + ArgumentNullException.ThrowIfNull(builder); - const string lowerHexChars = "0123456789abcdef"; foreach (var item in values) { - _ = builder.Append(lowerHexChars[item >> 4]) - .Append(lowerHexChars[item & 0xF]); + _ = builder.Append(LowerHexChars[item >> 4]) + .Append(LowerHexChars[item & 0xF]); } return builder; } diff --git a/Orm/Xtensive.Orm/Core/Extensions/StringExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/StringExtensions.cs index 7467a8bb5..611b64edf 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/StringExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/StringExtensions.cs @@ -94,7 +94,7 @@ public static string Indent(this string value, int indentSize) /// Indented . public static string Indent(this string value, int indentSize, bool indentFirstLine) { - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); var indent = new string(' ', indentSize); var sb = new ValueStringBuilder(stackalloc char[4096]); if (indentFirstLine) @@ -202,7 +202,7 @@ public static bool GreaterThanOrEqual(this string x, string y) /// ==. public static string RevertibleJoin(this IEnumerable source, char escape, char delimiter) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); if (escape==delimiter) throw new ArgumentException( Strings.ExEscapeCharacterMustDifferFromDelimiterCharacter); @@ -239,7 +239,7 @@ public static string RevertibleJoin(this IEnumerable source, char escape /// ==. public static IEnumerable RevertibleSplit(this string source, char escape, char delimiter) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); if (escape==delimiter) throw new ArgumentException( Strings.ExEscapeCharacterMustDifferFromDelimiterCharacter); @@ -278,7 +278,7 @@ public static IEnumerable RevertibleSplit(this string source, char escap /// ==. public static Pair RevertibleSplitFirstAndTail(this string source, char escape, char delimiter) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); if (escape==delimiter) throw new ArgumentException( Strings.ExEscapeCharacterMustDifferFromDelimiterCharacter); @@ -360,8 +360,8 @@ public static string Unescape(this string source, char escape) /// public static bool Like(this string value, string sqlLikePattern) { - ArgumentNullException.ThrowIfNull(value, "value"); - ArgumentNullException.ThrowIfNull(sqlLikePattern, "sqlLikePattern"); + ArgumentNullException.ThrowIfNull(value); + ArgumentNullException.ThrowIfNull(sqlLikePattern); var regexPattern = Regex.Replace(sqlLikePattern, @"[%_]|[^%_]+", match => { @@ -387,14 +387,14 @@ public static bool Like(this string value, string sqlLikePattern) /// public static bool Like(this string value, string sqlLikePattern, char escapeCharacter) { - ArgumentNullException.ThrowIfNull(value, "value"); - ArgumentNullException.ThrowIfNull(sqlLikePattern, "sqlLikePattern"); + ArgumentNullException.ThrowIfNull(value); + ArgumentNullException.ThrowIfNull(sqlLikePattern); const string regExSpecialChars = @"[]\/^$.|?*+(){}"; if(char.IsControl(escapeCharacter)) - throw new ArgumentException(Strings.ExControlCharacterUsedAsEscapeCharacter, "escapeCharacter"); + throw new ArgumentException(Strings.ExControlCharacterUsedAsEscapeCharacter, nameof(escapeCharacter)); if(escapeCharacter=='%' || escapeCharacter== '_') - throw new ArgumentException(string.Format(Strings.ExSpecialCharacterXUsedAsEscapeCharacter, escapeCharacter), "escapeCharacter"); + throw new ArgumentException(string.Format(Strings.ExSpecialCharacterXUsedAsEscapeCharacter, escapeCharacter), nameof(escapeCharacter)); var escChar = new string(escapeCharacter, 1); if (regExSpecialChars.Contains(escapeCharacter)) @@ -437,8 +437,8 @@ public static string StripRoundBrackets(this string value) internal static bool Contains(this string str, string value, StringComparison comparison) { - ArgumentNullException.ThrowIfNull(str, nameof(str)); - ArgumentNullException.ThrowIfNull(value, nameof(value)); + ArgumentNullException.ThrowIfNull(str); + ArgumentNullException.ThrowIfNull(value); return str.IndexOf(value, comparison) >= 0; } diff --git a/Orm/Xtensive.Orm/Core/SimpleXmlSerializer.cs b/Orm/Xtensive.Orm/Core/SimpleXmlSerializer.cs index 2b24b6928..3f635010a 100644 --- a/Orm/Xtensive.Orm/Core/SimpleXmlSerializer.cs +++ b/Orm/Xtensive.Orm/Core/SimpleXmlSerializer.cs @@ -25,7 +25,7 @@ public sealed class SimpleXmlSerializer /// Deserialized instance. public T Deserialize(string value) { - ArgumentNullException.ThrowIfNull(value, "serialized"); + ArgumentNullException.ThrowIfNull(value); using (var reader = new StringReader(value)) return (T) serializer.Deserialize(reader); @@ -38,7 +38,7 @@ public T Deserialize(string value) /// Serialized instance. public string Serialize(T value) { - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); using (var writer = new StringWriter()) { serializer.Serialize(writer, value); diff --git a/Orm/Xtensive.Orm/IoC/ServiceContainer.cs b/Orm/Xtensive.Orm/IoC/ServiceContainer.cs index 6a86dff9e..7fb6aff02 100644 --- a/Orm/Xtensive.Orm/IoC/ServiceContainer.cs +++ b/Orm/Xtensive.Orm/IoC/ServiceContainer.cs @@ -202,10 +202,10 @@ public static IServiceContainer Create(Type containerType, object configuration) /// Wrong container type. public static IServiceContainer Create(Type containerType, object configuration, IServiceContainer parent) { - ArgumentNullException.ThrowIfNull(containerType, "containerType"); + ArgumentNullException.ThrowIfNull(containerType); if (!iServiceContainerType.IsAssignableFrom(containerType)) throw new ArgumentException(string.Format( - Strings.ExContainerTypeMustImplementX, iServiceContainerType.Name), "containerType"); + Strings.ExContainerTypeMustImplementX, iServiceContainerType.Name)); Type configurationType = configuration?.GetType(), parentType = parent?.GetType(); @@ -219,7 +219,7 @@ public static IServiceContainer Create(Type containerType, object configuration, ?? FindConstructor(containerType, configurationType)?.Invoke(new[] { configuration }) ?? FindConstructor(containerType, parentType)?.Invoke(new[] { parent }) #endif - ?? throw new ArgumentException(Strings.ExContainerTypeDoesNotProvideASuitableConstructor, "containerType") + ?? throw new ArgumentException(Strings.ExContainerTypeDoesNotProvideASuitableConstructor, nameof(containerType)) ); } diff --git a/Orm/Xtensive.Orm/IoC/ServiceRegistration.cs b/Orm/Xtensive.Orm/IoC/ServiceRegistration.cs index d2e02530e..6ca671deb 100644 --- a/Orm/Xtensive.Orm/IoC/ServiceRegistration.cs +++ b/Orm/Xtensive.Orm/IoC/ServiceRegistration.cs @@ -81,7 +81,7 @@ public static ServiceRegistration[] CreateAll(Type type, bool defaultOnly) => private static Lazy ServiceRegistrationsExtractorImpl(ServiceRegistrationKey key) => new Lazy(() => { (var type, var defaultOnly) = key; - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); if (type.IsAbstract) { return Array.Empty(); } diff --git a/Orm/Xtensive.Orm/Linq/Internals/ExpressionHashCodeCalculator.cs b/Orm/Xtensive.Orm/Linq/Internals/ExpressionHashCodeCalculator.cs index 585946a67..6bd13deca 100644 --- a/Orm/Xtensive.Orm/Linq/Internals/ExpressionHashCodeCalculator.cs +++ b/Orm/Xtensive.Orm/Linq/Internals/ExpressionHashCodeCalculator.cs @@ -20,7 +20,7 @@ internal sealed class ExpressionHashCodeCalculator : ExpressionVisitor public int CalculateHashCode(Expression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); try { return Visit(expression); } diff --git a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ReflectionExtensions.cs b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ReflectionExtensions.cs index 433eea61d..dab1957e9 100644 --- a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ReflectionExtensions.cs +++ b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ReflectionExtensions.cs @@ -87,8 +87,8 @@ public static ConstructorInfo GetConstructorFromSerializableForm(this string ser public static void AddArray(this SerializationInfo info, string key, T[] array) { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(key, "key"); - ArgumentNullException.ThrowIfNull(array, "array"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(key, nameof(key)); + ArgumentNullException.ThrowIfNull(array); info.AddValue($"{key}Count", array.Length); for (int i = 0; i < array.Length; i++) @@ -97,7 +97,7 @@ public static void AddArray(this SerializationInfo info, string key, T[] arra public static T[] GetArrayFromSerializableForm(this SerializationInfo info, string key) { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(key, "key"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(key, nameof(key)); var count = info.GetInt32($"{key}Count"); var array = new T[count]; diff --git a/Orm/Xtensive.Orm/Modelling/Actions/ActionSequence.cs b/Orm/Xtensive.Orm/Modelling/Actions/ActionSequence.cs index 234258f6b..b03a8b0d5 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/ActionSequence.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/ActionSequence.cs @@ -41,7 +41,7 @@ public ActionScope LogAction() /// public void Add(NodeAction action) { - ArgumentNullException.ThrowIfNull(action, "action"); + ArgumentNullException.ThrowIfNull(action); EnsureNotLocked(); // Only locked actions can be added var ca = action as PropertyChangeAction; @@ -63,7 +63,7 @@ public void Add(NodeAction action) /// public void Add(IEnumerable actions) { - ArgumentNullException.ThrowIfNull(actions, "actions"); + ArgumentNullException.ThrowIfNull(actions); foreach (NodeAction action in actions) Add(action); } diff --git a/Orm/Xtensive.Orm/Modelling/Actions/CreateNodeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/CreateNodeAction.cs index 305591c68..69a6a56a5 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/CreateNodeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/CreateNodeAction.cs @@ -31,7 +31,7 @@ public class CreateNodeAction : NodeAction public Type Type { get { return type; } set { - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); EnsureNotLocked(); type = value; } @@ -43,7 +43,7 @@ public Type Type { public string Name { get { return name; } set { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(value, "value"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(value, nameof(value)); EnsureNotLocked(); name = value; } @@ -80,7 +80,7 @@ public object[] Parameters { /// Required constructor isn't found. protected override void PerformExecute(IModel model, IPathNode item) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var parent = (Node) item; var node = TryConstructor(model, parent, name); // Regular node if (node==null) diff --git a/Orm/Xtensive.Orm/Modelling/Actions/GroupingNodeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/GroupingNodeAction.cs index 9d6588e16..6af85d2c3 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/GroupingNodeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/GroupingNodeAction.cs @@ -45,7 +45,7 @@ public IList Actions { /// The action to add. public void Add(NodeAction action) { - ArgumentNullException.ThrowIfNull(action, "action"); + ArgumentNullException.ThrowIfNull(action); EnsureNotLocked(); // Only locked actions can be added var ca = action as PropertyChangeAction; diff --git a/Orm/Xtensive.Orm/Modelling/Actions/MoveNodeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/MoveNodeAction.cs index db89f42a2..45bf2e547 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/MoveNodeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/MoveNodeAction.cs @@ -74,7 +74,7 @@ public string NewPath { /// Required constructor isn't found. protected override void PerformExecute(IModel model, IPathNode item) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var node = (Node) item; var newParent = parent==null ? node.Parent : (Node) model.Resolve(parent, true); if ((node is IModel) && (newParent is IModel)) diff --git a/Orm/Xtensive.Orm/Modelling/Actions/NodeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/NodeAction.cs index b3ffca0c3..c2e3c676d 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/NodeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/NodeAction.cs @@ -49,7 +49,7 @@ public Difference Difference { /// public virtual void Execute(IModel model) { - ArgumentNullException.ThrowIfNull(model, "model"); + ArgumentNullException.ThrowIfNull(model); var item = model.Resolve(path, true); ActionHandler.Current.Execute(this); PerformExecute(model, item); diff --git a/Orm/Xtensive.Orm/Modelling/Actions/PropertyChangeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/PropertyChangeAction.cs index 5ae5b00f2..038c30116 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/PropertyChangeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/PropertyChangeAction.cs @@ -29,7 +29,7 @@ public IDictionary Properties { /// protected override void PerformExecute(IModel model, IPathNode item) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var node = (Node) item; foreach (var pair in properties) node.SetProperty(pair.Key, PathNodeReference.Resolve(model, pair.Value)); diff --git a/Orm/Xtensive.Orm/Modelling/Actions/RemoveNodeAction.cs b/Orm/Xtensive.Orm/Modelling/Actions/RemoveNodeAction.cs index 0acf2fb69..bf26aa685 100644 --- a/Orm/Xtensive.Orm/Modelling/Actions/RemoveNodeAction.cs +++ b/Orm/Xtensive.Orm/Modelling/Actions/RemoveNodeAction.cs @@ -19,7 +19,7 @@ public class RemoveNodeAction : NodeAction /// protected override void PerformExecute(IModel model, IPathNode item) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var node = (Node) item; node.Remove(); } diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs index af4920501..90b3c84c0 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Comparer.cs @@ -126,7 +126,7 @@ protected Difference Visit(object source, object target) /// , if they're equal. protected virtual Difference Visit(Type type, object source, object target) { - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); if (typeof (Node).IsAssignableFrom(type)) return VisitNode((Node) source, (Node) target); if (typeof(NodeCollection).IsAssignableFrom(type)) @@ -697,7 +697,7 @@ protected virtual ComparisonContext CreateContext() /// The path of the target node. protected virtual string GetTargetPath(Node source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); if (source.Model==Source) { var renameHint = Hints.GetHint(source); if (renameHint!=null) @@ -720,7 +720,7 @@ protected virtual string GetTargetPath(Node source) /// The name of the target node. protected virtual string GetTargetName(Node source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); if (source.Model==Source) { var renameHint = Hints.GetHint(source); if (renameHint!=null) diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/CopyDataHint.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/CopyDataHint.cs index d1bdb04ac..d3dfd718f 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/CopyDataHint.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/CopyDataHint.cs @@ -65,7 +65,7 @@ public CopyDataHint(string sourceTablePath, IList identities, IList> copiedColumns) : base(sourceTablePath, identities) { - ArgumentNullException.ThrowIfNull(copiedColumns, "copiedColumns"); + ArgumentNullException.ThrowIfNull(copiedColumns); CopiedColumns = new ReadOnlyCollection>(copiedColumns); } diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/DataHint.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/DataHint.cs index 14e0125ec..071301eb5 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/DataHint.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/DataHint.cs @@ -49,8 +49,8 @@ public override IEnumerable GetTargets() /// protected DataHint(string sourceTablePath, IList identities) { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceTablePath, "sourceTablePath"); - ArgumentNullException.ThrowIfNull(identities, "pairs"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceTablePath, nameof(sourceTablePath)); + ArgumentNullException.ThrowIfNull(identities); SourceTablePath = sourceTablePath; Identities = new ReadOnlyCollection(identities); diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/HintSet.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/HintSet.cs index b6364670f..41ff6c14b 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/HintSet.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/HintSet.cs @@ -66,7 +66,7 @@ public int Count { /// method isn't found. public void Add(Hint hint) { - ArgumentNullException.ThrowIfNull(hint, "hint"); + ArgumentNullException.ThrowIfNull(hint); if (set.Contains(hint)) throw new InvalidOperationException(Strings.ExItemAlreadyExists); @@ -165,7 +165,7 @@ IEnumerator IEnumerable.GetEnumerator() private Dictionary GetNodeHints(Node node) { - ArgumentNullException.ThrowIfNull(node, "node"); + ArgumentNullException.ThrowIfNull(node); if (!hintMap.TryGetValue(node, out var nodeHintMap)) { hintMap.Add(node, nodeHintMap = new Dictionary()); diff --git a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/UpdateDataHint.cs b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/UpdateDataHint.cs index 08c6c3c91..9dbcd33b7 100644 --- a/Orm/Xtensive.Orm/Modelling/Comparison/Hints/UpdateDataHint.cs +++ b/Orm/Xtensive.Orm/Modelling/Comparison/Hints/UpdateDataHint.cs @@ -60,7 +60,7 @@ public UpdateDataHint( IList> updateParameters) : base(sourceTablePath, identities) { - ArgumentNullException.ThrowIfNull(updateParameters, "updateParameters"); + ArgumentNullException.ThrowIfNull(updateParameters); UpdateParameter = new ReadOnlyCollection>(updateParameters); } diff --git a/Orm/Xtensive.Orm/Modelling/Node.cs b/Orm/Xtensive.Orm/Modelling/Node.cs index 4609f6469..b19e46bbe 100644 --- a/Orm/Xtensive.Orm/Modelling/Node.cs +++ b/Orm/Xtensive.Orm/Modelling/Node.cs @@ -66,7 +66,7 @@ public Node Parent { get { return parent; } [DebuggerStepThrough] set { - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); if (value==Parent) return; NodeCollection collection = null; @@ -338,10 +338,10 @@ public virtual Node Clone(Node newParent, string newName) using (CloningScope.Open()) { var isModel = this is IModel; if (!isModel) { - ArgumentNullException.ThrowIfNull(newParent, nameof(newParent)); + ArgumentNullException.ThrowIfNull(newParent); } - ArgumentNullException.ThrowIfNull(newName, nameof(newName)); + ArgumentNullException.ThrowIfNull(newName); // Cloning the instance var model = isModel ? null : (IModel) newParent.Model; @@ -850,7 +850,7 @@ private void UpdateModel() private static PropertyAccessorDictionary GetPropertyAccessors(Type type) { - ArgumentNullException.ThrowIfNull(type, nameof(type)); + ArgumentNullException.ThrowIfNull(type); static Lazy PropertyAccessorExtractor(Type entityType) { @@ -1006,7 +1006,7 @@ public override string ToString() protected Node(Node parent, string name) { if (!(this is IModel)) { - ArgumentNullException.ThrowIfNull(parent, nameof(parent)); + ArgumentNullException.ThrowIfNull(parent); } if (!(this is IUnnamedNode)) { diff --git a/Orm/Xtensive.Orm/Orm/Attributes/IndexAttribute.cs b/Orm/Xtensive.Orm/Orm/Attributes/IndexAttribute.cs index 07ded1246..c5fe78df5 100644 --- a/Orm/Xtensive.Orm/Orm/Attributes/IndexAttribute.cs +++ b/Orm/Xtensive.Orm/Orm/Attributes/IndexAttribute.cs @@ -89,7 +89,7 @@ public bool Unique /// The other (optional) key fields. public IndexAttribute(string keyField, params string[] keyFields) { - ArgumentNullException.ThrowIfNull(keyField, "keyField"); + ArgumentNullException.ThrowIfNull(keyField); if (keyFields==null || keyFields.Length==0) { KeyFields = new[] {keyField}; diff --git a/Orm/Xtensive.Orm/Orm/Building/Builders/DomainBuilder.cs b/Orm/Xtensive.Orm/Orm/Building/Builders/DomainBuilder.cs index f731632e9..c7f8a80fb 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Builders/DomainBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Builders/DomainBuilder.cs @@ -31,7 +31,7 @@ internal sealed class DomainBuilder /// Built domain. public static Domain Run(DomainBuilderConfiguration builderConfiguration) { - ArgumentNullException.ThrowIfNull(builderConfiguration, nameof(builderConfiguration)); + ArgumentNullException.ThrowIfNull(builderConfiguration); var context = new BuildingContext(builderConfiguration); using (BuildLog.InfoRegion(nameof(Strings.LogBuildingX), typeof(Domain).Name)) { diff --git a/Orm/Xtensive.Orm/Orm/Building/Builders/MemberCompilerProviderBuilder.cs b/Orm/Xtensive.Orm/Orm/Building/Builders/MemberCompilerProviderBuilder.cs index 425fab413..26d9ad64b 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Builders/MemberCompilerProviderBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Builders/MemberCompilerProviderBuilder.cs @@ -24,8 +24,8 @@ internal sealed class MemberCompilerProviderBuilder public static Dictionary Build(DomainConfiguration configuration, IEnumerable systemCompilerContainers) { - ArgumentNullException.ThrowIfNull(configuration, "configuration"); - ArgumentNullException.ThrowIfNull(systemCompilerContainers, "systemCompilerContainers"); + ArgumentNullException.ThrowIfNull(configuration); + ArgumentNullException.ThrowIfNull(systemCompilerContainers); var builder = new MemberCompilerProviderBuilder(configuration, systemCompilerContainers); builder.Build(); return builder.memberCompilerProviders; diff --git a/Orm/Xtensive.Orm/Orm/Building/Builders/PartialIndexFilterBuilder.cs b/Orm/Xtensive.Orm/Orm/Building/Builders/PartialIndexFilterBuilder.cs index c890d49fc..80774708c 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Builders/PartialIndexFilterBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Builders/PartialIndexFilterBuilder.cs @@ -36,7 +36,7 @@ internal class PartialIndexFilterBuilder : ExpressionVisitor public static void BuildFilter(IndexInfo index) { - ArgumentNullException.ThrowIfNull(index, "index"); + ArgumentNullException.ThrowIfNull(index); var builder = new PartialIndexFilterBuilder(index); var body = builder.Visit(index.FilterExpression.Body); var filter = new PartialIndexFilterInfo { diff --git a/Orm/Xtensive.Orm/Orm/Building/Definitions/HierarchyDefCollection.cs b/Orm/Xtensive.Orm/Orm/Building/Definitions/HierarchyDefCollection.cs index 7c817b1b2..04fe27904 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Definitions/HierarchyDefCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Definitions/HierarchyDefCollection.cs @@ -36,7 +36,7 @@ public class HierarchyDefCollection : CollectionBaseSlim /// public override bool Contains(HierarchyDef item) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); return TryGetValue(item.Root) != null; } @@ -115,7 +115,7 @@ public override void Clear() /// instance or if hierarchy is not found. public HierarchyDef Find(TypeDef item) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); var itemUnderlyingType = item.UnderlyingType; HierarchyDef hierarchyDef; diff --git a/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDef.cs b/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDef.cs index c9e20524b..ddac1f565 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDef.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDef.cs @@ -151,7 +151,7 @@ public IndexDef DefineIndex(string name) /// public FieldDef DefineField(PropertyInfo property) { - ArgumentNullException.ThrowIfNull(property, nameof(property)); + ArgumentNullException.ThrowIfNull(property); if (property.ReflectedType != UnderlyingType) { throw new DomainBuilderException( @@ -172,7 +172,7 @@ public FieldDef DefineField(PropertyInfo property) public FieldDef DefineField(string name, Type valueType) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, nameof(name)); - ArgumentNullException.ThrowIfNull(valueType, nameof(valueType)); + ArgumentNullException.ThrowIfNull(valueType); var field = builder.DefineField(UnderlyingType, name, valueType); fields.Add(field); diff --git a/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDefCollection.cs b/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDefCollection.cs index e422daa53..03fdc681d 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDefCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Definitions/TypeDefCollection.cs @@ -47,7 +47,7 @@ public sealed class TypeDefCollection : NodeCollection /// When is . public TypeDef FindAncestor(TypeDef item) { - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); if (item.IsInterface) return null; @@ -75,7 +75,7 @@ private TypeDef FindAncestor(Type type) => /// When is . public IEnumerable FindInterfaces(Type type) { - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); var interfaces = TypeHelper.GetInterfacesUnordered(type); return interfaces.Select(TryGetValue).Where(result => result != null); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs index e264c0c60..f2c414e3f 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs @@ -170,7 +170,7 @@ public static string SectionName { get => sectionName; set { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(value, "value"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(value, nameof(value)); if (sectionNameIsDefined) { throw Exceptions.AlreadyInitialized(nameof(SectionName)); } @@ -187,7 +187,7 @@ public string Name get => name; set { EnsureNotLocked(); - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); name = value; } } @@ -376,7 +376,7 @@ public SessionConfigurationCollection Sessions { get => sessions; set { - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); EnsureNotLocked(); sessions = value; } @@ -389,7 +389,7 @@ public MappingRuleCollection MappingRules { get => mappingRules; set { - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); EnsureNotLocked(); mappingRules = value; } @@ -402,7 +402,7 @@ public DatabaseConfigurationCollection Databases { get => databases; set { - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); EnsureNotLocked(); databases = value; } @@ -415,7 +415,7 @@ public KeyGeneratorConfigurationCollection KeyGenerators { get => keyGenerators; set { - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); EnsureNotLocked(); keyGenerators = value; } @@ -918,7 +918,7 @@ private static DomainConfiguration LoadConfigurationFromSection(ConfigurationSec /// The "domains" section is not found or domain with requested name is not found. public static DomainConfiguration Load(IConfigurationSection configurationSection, string name) { - ArgumentNullException.ThrowIfNull(configurationSection, nameof(configurationSection)); + ArgumentNullException.ThrowIfNull(configurationSection); var jsonParser = new JsonToDomainConfigurationReader(); var xmlParser = new XmlToDomainConfigurationReader(); @@ -936,7 +936,7 @@ public static DomainConfiguration Load(IConfigurationSection configurationSectio public static DomainConfiguration Load(IConfigurationRoot configurationRoot, string name) { - ArgumentNullException.ThrowIfNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot); var jsonParser = new JsonToDomainConfigurationReader(); var xmlParser = new XmlToDomainConfigurationReader(); @@ -954,7 +954,7 @@ public static DomainConfiguration Load(IConfigurationRoot configurationRoot, str public static DomainConfiguration Load(IConfigurationRoot configurationRoot, string sectionName, string name) { - ArgumentNullException.ThrowIfNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot); var jsonParser = new JsonToDomainConfigurationReader(); var xmlParser = new XmlToDomainConfigurationReader(); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs index 54f867337..d14b3af2e 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/ExtensionConfigurationCollection.cs @@ -53,7 +53,7 @@ public void Set(T value) where T : ConfigurationBase { EnsureNotLocked(); - ArgumentNullException.ThrowIfNull(value, nameof(value)); + ArgumentNullException.ThrowIfNull(value); var extensionConfigurationType = typeof(T); @@ -126,7 +126,7 @@ public ExtensionConfigurationCollection() public ExtensionConfigurationCollection(ExtensionConfigurationCollection source) : this() { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); if (source.Count == 0) return; extensionConfigurations = new Dictionary(source.extensionConfigurations); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/Internals/LoggingConfigurationReader.cs b/Orm/Xtensive.Orm/Orm/Configuration/Internals/LoggingConfigurationReader.cs index e4332542d..5bce1f9bd 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/Internals/LoggingConfigurationReader.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/Internals/LoggingConfigurationReader.cs @@ -23,7 +23,7 @@ internal sealed class LoggingConfigurationReader : IConfigurationSectionReader public LoggingConfiguration Read(IConfigurationRoot configurationRoot, string sectionName) { - ArgumentNullException.ThrowIfNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sectionName, nameof(sectionName)); return Read(configurationRoot.GetSection(sectionName)); @@ -32,7 +32,7 @@ public LoggingConfiguration Read(IConfigurationRoot configurationRoot, string se /// public LoggingConfiguration Read(IConfigurationRoot configurationRoot) { - ArgumentNullException.ThrowIfNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot); return Read(configurationRoot.GetSection(WellKnown.DefaultConfigurationSection)); } @@ -40,7 +40,7 @@ public LoggingConfiguration Read(IConfigurationRoot configurationRoot) /// public LoggingConfiguration Read(IConfigurationRoot configurationRoot, string sectionName, string nameOfConfiguration) { - ArgumentNullException.ThrowIfNull(configurationRoot, nameof(configurationRoot)); + ArgumentNullException.ThrowIfNull(configurationRoot); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sectionName, nameof(sectionName)); return Read(configurationRoot.GetSection(sectionName)); @@ -49,7 +49,7 @@ public LoggingConfiguration Read(IConfigurationRoot configurationRoot, string se /// public LoggingConfiguration Read(IConfigurationSection configurationSection) { - ArgumentNullException.ThrowIfNull(configurationSection, nameof(configurationSection)); + ArgumentNullException.ThrowIfNull(configurationSection); var ormConfigurationSection = configurationSection; diff --git a/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs index 92aca9c87..92abc6d0a 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/LoggingConfiguration.cs @@ -116,7 +116,7 @@ public static LoggingConfiguration Load(System.Configuration.Configuration confi /// Loaded configuration. public static LoggingConfiguration Load(System.Configuration.Configuration configuration, string sectionName) { - ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sectionName, nameof(sectionName)); var section = (ConfigurationSection) configuration.GetSection(sectionName); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs index 701ef207f..2b96cb030 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/NameMappingCollection.cs @@ -120,7 +120,7 @@ public NameMappingCollection() /// Mappings to add to this instance. public NameMappingCollection([NotNull] IEnumerable> items) { - ArgumentNullException.ThrowIfNull(items, "items"); + ArgumentNullException.ThrowIfNull(items); foreach (var item in items) Add(item.Key, item.Value); diff --git a/Orm/Xtensive.Orm/Orm/Configuration/Options/OptionsCollection{T}.cs b/Orm/Xtensive.Orm/Orm/Configuration/Options/OptionsCollection{T}.cs index ff8299d87..370bbd15b 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/Options/OptionsCollection{T}.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/Options/OptionsCollection{T}.cs @@ -81,7 +81,7 @@ public bool Remove(T item) public void CopyTo(T[] array, int arrayIndex) { - ArgumentNullException.ThrowIfNull(array, nameof(array)); + ArgumentNullException.ThrowIfNull(array); ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(arrayIndex, 0, nameof(arrayIndex)); if (array.Length - arrayIndex < map.Count) { diff --git a/Orm/Xtensive.Orm/Orm/DelayedQuery.cs b/Orm/Xtensive.Orm/Orm/DelayedQuery.cs index d63f1d043..ffcd65f8d 100644 --- a/Orm/Xtensive.Orm/Orm/DelayedQuery.cs +++ b/Orm/Xtensive.Orm/Orm/DelayedQuery.cs @@ -89,9 +89,9 @@ protected async ValueTask> MaterializeAsync(CancellationToken /// The parameter context. internal DelayedQuery(Session session, TranslatedQuery translatedQuery, ParameterContext outerParameterContext) { - ArgumentNullException.ThrowIfNull(session, nameof(session)); - ArgumentNullException.ThrowIfNull(translatedQuery, nameof(translatedQuery)); - ArgumentNullException.ThrowIfNull(outerParameterContext, nameof(outerParameterContext)); + ArgumentNullException.ThrowIfNull(session); + ArgumentNullException.ThrowIfNull(translatedQuery); + ArgumentNullException.ThrowIfNull(outerParameterContext); Session = session; LifetimeToken = session.GetLifetimeToken(); diff --git a/Orm/Xtensive.Orm/Orm/Domain.cs b/Orm/Xtensive.Orm/Orm/Domain.cs index ad16b9844..cd307e1d7 100644 --- a/Orm/Xtensive.Orm/Orm/Domain.cs +++ b/Orm/Xtensive.Orm/Orm/Domain.cs @@ -226,7 +226,7 @@ public Session OpenSession(SessionConfiguration configuration) => internal Session OpenSessionInternal(SessionConfiguration configuration, StorageNode storageNode, bool activate) { - ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration); configuration.Lock(true); if (isDebugEventLoggingEnabled) { @@ -300,7 +300,7 @@ public Task OpenSessionAsync(SessionType type, CancellationToken cancel /// public Task OpenSessionAsync(SessionConfiguration configuration, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(configuration); SessionScope sessionScope = null; try { diff --git a/Orm/Xtensive.Orm/Orm/Entity.cs b/Orm/Xtensive.Orm/Orm/Entity.cs index fe4c7ea34..c8c6cc54d 100644 --- a/Orm/Xtensive.Orm/Orm/Entity.cs +++ b/Orm/Xtensive.Orm/Orm/Entity.cs @@ -89,9 +89,9 @@ internal EntityState State { return state; } set { - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); if (state!=null) - throw Exceptions.AlreadyInitialized("State"); + throw Exceptions.AlreadyInitialized(nameof(State)); state = value; state.Entity = this; } @@ -858,7 +858,7 @@ internal Entity(Session session, Tuple keyTuple) : base(session) { try { - ArgumentNullException.ThrowIfNull(keyTuple, "keyTuple"); + ArgumentNullException.ThrowIfNull(keyTuple); var key = Key.Create(Session.Domain, Session.StorageNodeId, GetTypeInfo(), TypeReferenceAccuracy.ExactType, keyTuple); State = Session.CreateEntityState(key, true); changeVersionOnSetAttempt = ShouldChangeOnSetAttempt(); @@ -891,7 +891,7 @@ internal Entity(Session session, Tuple keyTuple) protected Entity(params object[] values) { try { - ArgumentNullException.ThrowIfNull(values, "values"); + ArgumentNullException.ThrowIfNull(values); var key = Key.Create(Session.Domain, Session.StorageNodeId, GetTypeInfo(), TypeReferenceAccuracy.ExactType, values); State = Session.CreateEntityState(key, true); changeVersionOnSetAttempt = ShouldChangeOnSetAttempt(); @@ -943,7 +943,7 @@ protected Entity(Session session, params object[] values) : base(session) { try { - ArgumentNullException.ThrowIfNull(values, "values"); + ArgumentNullException.ThrowIfNull(values); var key = Key.Create(Session.Domain, Session.StorageNodeId, GetTypeInfo(), TypeReferenceAccuracy.ExactType, values); State = Session.CreateEntityState(key, true); changeVersionOnSetAttempt = ShouldChangeOnSetAttempt(); diff --git a/Orm/Xtensive.Orm/Orm/EntityEventBroker.cs b/Orm/Xtensive.Orm/Orm/EntityEventBroker.cs index 76fe905ba..29a5929e5 100644 --- a/Orm/Xtensive.Orm/Orm/EntityEventBroker.cs +++ b/Orm/Xtensive.Orm/Orm/EntityEventBroker.cs @@ -132,9 +132,9 @@ public sealed class EntityEventBroker /// The delegate. public void AddSubscriber(Key key, FieldInfo fieldInfo, object eventKey, Delegate subscriber) { - ArgumentNullException.ThrowIfNull(key, "key"); - ArgumentNullException.ThrowIfNull(eventKey, "eventKey"); - ArgumentNullException.ThrowIfNull(subscriber, "subscriber"); + ArgumentNullException.ThrowIfNull(key); + ArgumentNullException.ThrowIfNull(eventKey); + ArgumentNullException.ThrowIfNull(subscriber); if (subscribers == null) subscribers = new Dictionary<(Key, FieldInfo, object), Delegate>(); var subscriberKey = (key, fieldInfo, eventKey); @@ -166,9 +166,9 @@ public void AddSubscriber(Key key, object eventKey, Delegate subscriber) /// The delegate. public void RemoveSubscriber(Key key, FieldInfo fieldInfo, object eventKey, Delegate subscriber) { - ArgumentNullException.ThrowIfNull(key, "key"); - ArgumentNullException.ThrowIfNull(eventKey, "eventKey"); - ArgumentNullException.ThrowIfNull(subscriber, "subscriber"); + ArgumentNullException.ThrowIfNull(key); + ArgumentNullException.ThrowIfNull(eventKey); + ArgumentNullException.ThrowIfNull(subscriber); if (subscribers == null) return; var subscriberKey = (key, fieldInfo, eventKey); diff --git a/Orm/Xtensive.Orm/Orm/EntitySet{T}.cs b/Orm/Xtensive.Orm/Orm/EntitySet{T}.cs index 3cc69f709..561a15fb5 100644 --- a/Orm/Xtensive.Orm/Orm/EntitySet{T}.cs +++ b/Orm/Xtensive.Orm/Orm/EntitySet{T}.cs @@ -114,7 +114,7 @@ public bool Remove(TItem item) public new void AddRange(IEnumerable items) where TElement: TItem { - ArgumentNullException.ThrowIfNull(items, "items"); + ArgumentNullException.ThrowIfNull(items); base.AddRange(items); } @@ -127,7 +127,7 @@ public bool Remove(TItem item) public new void IntersectWith(IEnumerable other) where TElement : TItem { - ArgumentNullException.ThrowIfNull(other, "other"); + ArgumentNullException.ThrowIfNull(other); base.IntersectWith(other); } @@ -140,7 +140,7 @@ public bool Remove(TItem item) public new void UnionWith(IEnumerable other) where TElement : TItem { - ArgumentNullException.ThrowIfNull(other, "other"); + ArgumentNullException.ThrowIfNull(other); base.UnionWith(other); } @@ -152,7 +152,7 @@ public bool Remove(TItem item) public new void ExceptWith(IEnumerable other) where TElement : TItem { - ArgumentNullException.ThrowIfNull(other, "other"); + ArgumentNullException.ThrowIfNull(other); base.ExceptWith(other); } diff --git a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/CustomProximityTerm.cs b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/CustomProximityTerm.cs index afbb11a8b..a1d346d1e 100644 --- a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/CustomProximityTerm.cs +++ b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/CustomProximityTerm.cs @@ -47,8 +47,8 @@ internal CustomProximityTerm(IOperator source, ICollection pr { if (proximityTerms.Count < 2) throw new ArgumentException(string.Format(Strings.ExCollectionShouldContainAtLeastXElements, 2)); - ArgumentNullException.ThrowIfNull(proximityTerms, "proximityTerms"); - ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(maxDistance, 0, "maxDistance"); + ArgumentNullException.ThrowIfNull(proximityTerms); + ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(maxDistance, 0, nameof(maxDistance)); Terms = proximityTerms.ToList().AsReadOnly(); MaxDistance = maxDistance; diff --git a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/GenerationTerm.cs b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/GenerationTerm.cs index a5b5f2ffa..274bb4a64 100644 --- a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/GenerationTerm.cs +++ b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/GenerationTerm.cs @@ -32,12 +32,12 @@ protected override void AcceptVisitorInternal(ISearchConditionNodeVisitor visito internal GenerationTerm(IOperator source, GenerationType generationType, ICollection terms) : base(SearchConditionNodeType.GenerationTerm, source) { - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(terms, "terms"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(terms); if (terms.Count==0) - throw new ArgumentException(Strings.ExCollectionIsEmpty, "terms"); + throw new ArgumentException(Strings.ExCollectionIsEmpty, nameof(terms)); if (terms.Any(c=>c.IsNullOrEmpty() || c.Trim().IsNullOrEmpty())) - throw new ArgumentException(Strings.ExCollectionCannotContainAnyNeitherNullOrEmptyStringValues, "terms"); + throw new ArgumentException(Strings.ExCollectionCannotContainAnyNeitherNullOrEmptyStringValues, nameof(terms)); GenerationType = generationType; Terms = terms.ToList().AsReadOnly(); } diff --git a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/Operator.cs b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/Operator.cs index e4227444a..a27353ff7 100644 --- a/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/Operator.cs +++ b/Orm/Xtensive.Orm/Orm/FullTextSearchCondition/Nodes/Operator.cs @@ -44,7 +44,7 @@ public IGenerationTerm GenerationTerm(GenerationType generationType, ICollection /// public IProximityTerm GenericProximityTerm(Func proximityTermsConstructor) { - ArgumentNullException.ThrowIfNull(proximityTermsConstructor, "proximityTermsConstructor"); + ArgumentNullException.ThrowIfNull(proximityTermsConstructor); var proximityOperandRoot = new ProximityOperandEndpoint(); var constructionFlow = proximityTermsConstructor.Invoke(proximityOperandRoot); @@ -54,7 +54,7 @@ public IProximityTerm GenericProximityTerm(Func public ICustomProximityTerm CustomProximityTerm(Func proximityTermsConstructor) { - ArgumentNullException.ThrowIfNull(proximityTermsConstructor, "proximityTermsConstructor"); + ArgumentNullException.ThrowIfNull(proximityTermsConstructor); var proximityOperandRoot = new ProximityOperandEndpoint(); var constructionFlow = proximityTermsConstructor.Invoke(proximityOperandRoot); @@ -64,7 +64,7 @@ public ICustomProximityTerm CustomProximityTerm(Func public ICustomProximityTerm CustomProximityTerm(Func proximityTermsConstructor, long maximumDistance) { - ArgumentNullException.ThrowIfNull(proximityTermsConstructor, "proximityTermsConstructor"); + ArgumentNullException.ThrowIfNull(proximityTermsConstructor); var proximityOperandRoot = new ProximityOperandEndpoint(); var constructionFlow = proximityTermsConstructor.Invoke(proximityOperandRoot); @@ -74,7 +74,7 @@ public ICustomProximityTerm CustomProximityTerm(Func public ICustomProximityTerm CustomProximityTerm(Func proximityTermsConstructor, long maximumDistance, bool matchOrder) { - ArgumentNullException.ThrowIfNull(proximityTermsConstructor, "proximityTermsConstructor"); + ArgumentNullException.ThrowIfNull(proximityTermsConstructor); var proximityOperandRoot = new ProximityOperandEndpoint(); var constructionFlow = proximityTermsConstructor.Invoke(proximityOperandRoot); @@ -84,7 +84,7 @@ public ICustomProximityTerm CustomProximityTerm(Func public IWeightedTerm WeightedTerm(Func weightedTermsConstructor) { - ArgumentNullException.ThrowIfNull(weightedTermsConstructor, "weightedTermsConstructor"); + ArgumentNullException.ThrowIfNull(weightedTermsConstructor); var endpoint = new WeightedTermEndpoint(); var constructionFlow = weightedTermsConstructor.Invoke(endpoint); @@ -94,7 +94,7 @@ public IWeightedTerm WeightedTerm(Func public IComplexTerm ComplexTerm(Func complexTermConstructor) { - ArgumentNullException.ThrowIfNull(complexTermConstructor, "complexTermConstructor"); + ArgumentNullException.ThrowIfNull(complexTermConstructor); var endpoint = SearchConditionNodeFactory.CreateConditonRoot(); return SearchConditionNodeFactory.CreateComplexTerm(this, complexTermConstructor.Invoke(endpoint)); diff --git a/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/NonPairedReferenceChangesRegistry.cs b/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/NonPairedReferenceChangesRegistry.cs index fcb6e1fdb..c287f8efd 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/NonPairedReferenceChangesRegistry.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/NonPairedReferenceChangesRegistry.cs @@ -53,8 +53,8 @@ public Identifier(EntityState entityState, AssociationInfo association) public IEnumerable GetRemovedReferencesTo(EntityState target, AssociationInfo association) { - ArgumentNullException.ThrowIfNull(target, "target"); - ArgumentNullException.ThrowIfNull(association, "association"); + ArgumentNullException.ThrowIfNull(target); + ArgumentNullException.ThrowIfNull(association); return association.IsPaired || !removedReferences.TryGetValue(Identifier.Make(target, association), out var removedMap) ? Array.Empty() @@ -63,8 +63,8 @@ public IEnumerable GetRemovedReferencesTo(EntityState target, Assoc public IEnumerable GetAddedReferenceTo(EntityState target, AssociationInfo association) { - ArgumentNullException.ThrowIfNull(target, "target"); - ArgumentNullException.ThrowIfNull(association, "association"); + ArgumentNullException.ThrowIfNull(target); + ArgumentNullException.ThrowIfNull(association); return association.IsPaired || !addedReferences.TryGetValue(Identifier.Make(target, association), out var removedMap) ? Array.Empty() @@ -83,8 +83,8 @@ public void Clear() private void RegisterChange(EntityState referencedState, EntityState referencingState, EntityState noLongerReferencedState, AssociationInfo association) { - ArgumentNullException.ThrowIfNull(association, "association"); - ArgumentNullException.ThrowIfNull(referencingState, "referencingState"); + ArgumentNullException.ThrowIfNull(association); + ArgumentNullException.ThrowIfNull(referencingState); if (!Session.DisableAutoSaveChanges || association.IsPaired || (referencedState == null && noLongerReferencedState == null)) { diff --git a/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/ReferenceFieldsChangesRegistry.cs b/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/ReferenceFieldsChangesRegistry.cs index eae27605b..8bcf1550f 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/ReferenceFieldsChangesRegistry.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/ReferenceFieldsChangesRegistry.cs @@ -26,9 +26,9 @@ internal sealed class ReferenceFieldsChangesRegistry : SessionBoundRegistry /// Field which value was set./ public void Register(Key fieldOwner, Key fieldValue, FieldInfo field) { - ArgumentNullException.ThrowIfNull(fieldOwner, "fieldOwner"); - ArgumentNullException.ThrowIfNull(fieldValue, "fieldValue"); - ArgumentNullException.ThrowIfNull(field, "field"); + ArgumentNullException.ThrowIfNull(fieldOwner); + ArgumentNullException.ThrowIfNull(fieldValue); + ArgumentNullException.ThrowIfNull(field); Register(new ReferenceFieldChangeInfo(fieldOwner, fieldValue, field)); } @@ -41,10 +41,10 @@ public void Register(Key fieldOwner, Key fieldValue, FieldInfo field) /// Field which value was set. public void Register(Key fieldOwner, Key fieldValue, Key auxiliaryEntity, FieldInfo field) { - ArgumentNullException.ThrowIfNull(fieldOwner, "fieldOwner"); - ArgumentNullException.ThrowIfNull(fieldValue, "fieldValue"); - ArgumentNullException.ThrowIfNull(auxiliaryEntity, "auxiliaryEntity"); - ArgumentNullException.ThrowIfNull(field, "field"); + ArgumentNullException.ThrowIfNull(fieldOwner); + ArgumentNullException.ThrowIfNull(fieldValue); + ArgumentNullException.ThrowIfNull(auxiliaryEntity); + ArgumentNullException.ThrowIfNull(field); Register(new ReferenceFieldChangeInfo(fieldOwner, fieldValue, auxiliaryEntity, field)); } diff --git a/Orm/Xtensive.Orm/Orm/Internals/FieldAccessors/StructureFieldAccessor.cs b/Orm/Xtensive.Orm/Orm/Internals/FieldAccessors/StructureFieldAccessor.cs index 7fd31f123..bfaf13fae 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/FieldAccessors/StructureFieldAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/FieldAccessors/StructureFieldAccessor.cs @@ -22,7 +22,7 @@ public override bool AreSameValues(object oldValue, object newValue) public override void SetValue(Persistent obj, T value) { var field = Field; - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(value); var valueType = value.GetType(); if (field.ValueType != valueType) throw new InvalidOperationException(String.Format( diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityGroupTask.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityGroupTask.cs index bafdf54e2..3d5466c9d 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityGroupTask.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntityGroupTask.cs @@ -203,7 +203,7 @@ private void MarkMissedEntityState(Key key, bool exactType) public EntityGroupTask(TypeInfo type, int[] columnIndexes, PrefetchManager manager) { - ArgumentNullException.ThrowIfNull(columnIndexes, nameof(columnIndexes)); + ArgumentNullException.ThrowIfNull(columnIndexes); ArgumentValidator.EnsureArgumentIsGreaterThan(columnIndexes.Length, 0, "columnIndexes.Length"); this.type = type ?? throw new ArgumentNullException(nameof(type)); diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchManager.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchManager.cs index 3a81cd6cc..b66eb233b 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchManager.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchManager.cs @@ -110,8 +110,8 @@ public async Task PrefetchAsync(Key key, TypeInfo type private async ValueTask Prefetch( Key key, TypeInfo type, IReadOnlyList descriptors, bool isAsync, CancellationToken token) { - ArgumentNullException.ThrowIfNull(key, nameof(key)); - ArgumentNullException.ThrowIfNull(descriptors, nameof(descriptors)); + ArgumentNullException.ThrowIfNull(key); + ArgumentNullException.ThrowIfNull(descriptors); if (descriptors.Count == 0) { return null; diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/RootEntityContainer.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/RootEntityContainer.cs index 61b9c5ce0..e9a59c641 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/RootEntityContainer.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/RootEntityContainer.cs @@ -44,7 +44,7 @@ public void NotifyOwnerAboutKeyWithUnknownType() public RootEntityContainer(Key key, TypeInfo type, bool exactType, PrefetchManager manager) : base(key, type, exactType, manager) { - ArgumentNullException.ThrowIfNull(key, "key"); + ArgumentNullException.ThrowIfNull(key); } } } \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Orm/Internals/ReferentialIntegrity/RemovalProcessor.cs b/Orm/Xtensive.Orm/Orm/Internals/ReferentialIntegrity/RemovalProcessor.cs index b78912cf8..685024968 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/ReferentialIntegrity/RemovalProcessor.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/ReferentialIntegrity/RemovalProcessor.cs @@ -49,7 +49,7 @@ public void EnqueueForRemoval(IEnumerable entities, EntityRemoveReason r public void Remove(IEnumerable entities, EntityRemoveReason reason) { - ArgumentNullException.ThrowIfNull(entities, "entities"); + ArgumentNullException.ThrowIfNull(entities); var isEmpty = true; foreach (var entity in entities) { isEmpty = false; @@ -58,7 +58,7 @@ public void Remove(IEnumerable entities, EntityRemoveReason reason) if (isEmpty) { return; } - var processedEntities = new List(); + IReadOnlyList processedEntities = Array.Empty(); var notifiedEntities = new HashSet(); try { var operations = Session.Operations; diff --git a/Orm/Xtensive.Orm/Orm/Internals/RemapContext.cs b/Orm/Xtensive.Orm/Orm/Internals/RemapContext.cs index b7e9a6bd3..a318d9124 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/RemapContext.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/RemapContext.cs @@ -38,8 +38,8 @@ public IEnumerable EntitiesToRemap /// Actual key public void RegisterKeyMap(Key localKey, Key realKey) { - ArgumentNullException.ThrowIfNull(localKey, "localKey"); - ArgumentNullException.ThrowIfNull(realKey, "realKey"); + ArgumentNullException.ThrowIfNull(localKey); + ArgumentNullException.ThrowIfNull(realKey); if(localKey!=realKey) keyMap.Add(localKey, realKey); } diff --git a/Orm/Xtensive.Orm/Orm/Internals/StorageNodeRegistry.cs b/Orm/Xtensive.Orm/Orm/Internals/StorageNodeRegistry.cs index 0c9e7bbe8..05fce9b81 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/StorageNodeRegistry.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/StorageNodeRegistry.cs @@ -17,13 +17,13 @@ internal sealed class StorageNodeRegistry public bool Add(StorageNode node) { - ArgumentNullException.ThrowIfNull(node, "node"); + ArgumentNullException.ThrowIfNull(node); return nodes.TryAdd(node.Id, node); } public bool Remove(string nodeId) { - ArgumentNullException.ThrowIfNull(nodeId, "nodeId"); + ArgumentNullException.ThrowIfNull(nodeId); if (nodeId==WellKnown.DefaultNodeId) throw new InvalidOperationException(Strings.ExDefaultStorageNodeCanNotBeRemoved); StorageNode dummy; @@ -32,7 +32,7 @@ public bool Remove(string nodeId) public StorageNode TryGet(string nodeId) { - ArgumentNullException.ThrowIfNull(nodeId, "nodeId"); + ArgumentNullException.ThrowIfNull(nodeId); StorageNode result; nodes.TryGetValue(nodeId, out result); return result; @@ -40,7 +40,7 @@ public StorageNode TryGet(string nodeId) public StorageNode Get(string nodeId) { - ArgumentNullException.ThrowIfNull(nodeId, "nodeId"); + ArgumentNullException.ThrowIfNull(nodeId); StorageNode result; if (!nodes.TryGetValue(nodeId, out result)) throw new KeyNotFoundException(string.Format(Strings.ExStorageNodeWithIdXIsNotFound, nodeId)); diff --git a/Orm/Xtensive.Orm/Orm/Internals/VersionGenerator.cs b/Orm/Xtensive.Orm/Orm/Internals/VersionGenerator.cs index 7ffe41cca..efc18f10b 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/VersionGenerator.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/VersionGenerator.cs @@ -24,7 +24,7 @@ public static class VersionGenerator /// Unsupported type. public static object GenerateNextVersion(object currentVersion) { - ArgumentNullException.ThrowIfNull(currentVersion, "currentValue"); + ArgumentNullException.ThrowIfNull(currentVersion); TypeCode code = Type.GetTypeCode(currentVersion.GetType()); switch (code) { diff --git a/Orm/Xtensive.Orm/Orm/Key.cs b/Orm/Xtensive.Orm/Orm/Key.cs index 778d2742d..069d5f30c 100644 --- a/Orm/Xtensive.Orm/Orm/Key.cs +++ b/Orm/Xtensive.Orm/Orm/Key.cs @@ -94,7 +94,7 @@ public bool IsTemporary(Domain domain) [NotNull] public TypeInfo ResolveTypeInfo([NotNull, InstantHandle] Session session) { - ArgumentNullException.ThrowIfNull(session, "session"); + ArgumentNullException.ThrowIfNull(session); if (TypeReference.Accuracy==TypeReferenceAccuracy.ExactType) return TypeReference.Type; @@ -280,7 +280,7 @@ public static Key Parse([NotNull] Domain domain, string source) if (source==null) return null; - ArgumentNullException.ThrowIfNull(domain, "domain"); + ArgumentNullException.ThrowIfNull(domain); var parts = source.RevertibleSplit(KeyFormatEscape, KeyFormatDelimiter).ToList(); if (parts.Count!=2 && parts.Count!=3 || parts.Contains(null)) @@ -350,8 +350,8 @@ public static Key Generate([NotNull] Session session) /// public static Key Generate([NotNull] Session session, [NotNull] Type type) { - ArgumentNullException.ThrowIfNull(session, "session"); - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(session); + ArgumentNullException.ThrowIfNull(type); return Generate(session, session.Domain.Model.Types[type]); } @@ -424,9 +424,9 @@ public static Key Create([NotNull] Domain domain, [NotNull] Type type, TypeRefer /// A newly created or existing instance. public static Key Create([NotNull] Domain domain, [NotNull] string nodeId, [NotNull] Type type, TypeReferenceAccuracy accuracy, [NotNull] Tuple value) { - ArgumentNullException.ThrowIfNull(domain, "domain"); - ArgumentNullException.ThrowIfNull(type, "type"); - ArgumentNullException.ThrowIfNull(value, "value"); + ArgumentNullException.ThrowIfNull(domain); + ArgumentNullException.ThrowIfNull(type); + ArgumentNullException.ThrowIfNull(value); return Create(domain, nodeId, domain.Model.Types[type], accuracy, value); } @@ -497,10 +497,10 @@ public static Key Create([NotNull] Domain domain, [NotNull] Type type, TypeRefer /// A newly created or existing instance. public static Key Create([NotNull] Domain domain, [NotNull] string nodeId, [NotNull] Type type, TypeReferenceAccuracy accuracy, [NotNull] params object[] values) { - ArgumentNullException.ThrowIfNull(domain, "domain"); - ArgumentNullException.ThrowIfNull(nodeId, "nodeId"); - ArgumentNullException.ThrowIfNull(type, "type"); - ArgumentNullException.ThrowIfNull(values, "values"); + ArgumentNullException.ThrowIfNull(domain); + ArgumentNullException.ThrowIfNull(nodeId); + ArgumentNullException.ThrowIfNull(type); + ArgumentNullException.ThrowIfNull(values); return Create(domain, nodeId, domain.Model.Types[type], accuracy, values); } diff --git a/Orm/Xtensive.Orm/Orm/Linq/LocalCollectionKeyTypeExtractor.cs b/Orm/Xtensive.Orm/Orm/Linq/LocalCollectionKeyTypeExtractor.cs index 6494a9991..33af30835 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/LocalCollectionKeyTypeExtractor.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/LocalCollectionKeyTypeExtractor.cs @@ -19,7 +19,7 @@ internal static class LocalCollectionKeyTypeExtractor { public static Type Extract(BinaryExpression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); if (expression.Right.StripMarkers() is KeyExpression key) { return key.EntityType.UnderlyingType; } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Materialization/MaterializationContext.cs b/Orm/Xtensive.Orm/Orm/Linq/Materialization/MaterializationContext.cs index d40234869..22ef60d79 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Materialization/MaterializationContext.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Materialization/MaterializationContext.cs @@ -108,7 +108,7 @@ public TypeMapping GetTypeMapping(int entityIndex, TypeInfo approximateType, int private int ResolveTypeToNodeSpecificTypeIdentifier(TypeInfo typeInfo) { - ArgumentNullException.ThrowIfNull(typeInfo, "typeInfo"); + ArgumentNullException.ThrowIfNull(typeInfo); return TypeIdRegistry[typeInfo]; } diff --git a/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs b/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs index 81e6b186b..73d475353 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProvider.cs @@ -48,7 +48,7 @@ private readonly Dictionary compilers public Delegate GetUntypedCompiler(MemberInfo target) { - ArgumentNullException.ThrowIfNull(target, nameof(target)); + ArgumentNullException.ThrowIfNull(target); return compilers.GetValueOrDefault(GetCompilerKey(target)); } @@ -66,7 +66,7 @@ public void RegisterCompilers(Type compilerContainer) public void RegisterCompilers(Type compilerContainer, ConflictHandlingMethod conflictHandlingMethod) { - ArgumentNullException.ThrowIfNull(compilerContainer, "compilerContainer"); + ArgumentNullException.ThrowIfNull(compilerContainer); EnsureNotLocked(); if (compilerContainer.IsGenericType) @@ -87,7 +87,7 @@ public void RegisterCompilers(IEnumerable>> compilerDefinitions, ConflictHandlingMethod conflictHandlingMethod) { - ArgumentNullException.ThrowIfNull(compilerDefinitions, "compilerDefinitions"); + ArgumentNullException.ThrowIfNull(compilerDefinitions); EnsureNotLocked(); var newItems = compilerDefinitions.Select(item => (item.Key, (Delegate) item.Value)); diff --git a/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProviderFactory.cs b/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProviderFactory.cs index 71e86f319..e8776d156 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProviderFactory.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/MemberCompilation/MemberCompilerProviderFactory.cs @@ -22,7 +22,7 @@ public static class MemberCompilerProviderFactory /// The type. public static IMemberCompilerProvider Create(Type type) { - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); var concreteType = typeof (MemberCompilerProvider<>).CachedMakeGenericType(type); return (IMemberCompilerProvider) Activator.CreateInstance(concreteType); } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Queryable.cs b/Orm/Xtensive.Orm/Orm/Linq/Queryable.cs index f8200fd05..068020758 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Queryable.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Queryable.cs @@ -61,7 +61,7 @@ public async IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati /// is out of range. public Queryable(QueryProvider provider, Expression expression) { - ArgumentNullException.ThrowIfNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression); if (!typeof (IQueryable).IsAssignableFrom(expression.Type)) { throw new ArgumentOutOfRangeException(nameof(expression)); } diff --git a/Orm/Xtensive.Orm/Orm/Linq/TranslatorContext.cs b/Orm/Xtensive.Orm/Orm/Linq/TranslatorContext.cs index c465aad1d..d116c20e0 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/TranslatorContext.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/TranslatorContext.cs @@ -140,9 +140,9 @@ private Expression ApplyPreprocessor(IQueryPreprocessor preprocessor, Session se public TranslatorContext(Session session, CompilerConfiguration rseCompilerConfiguration, Expression query, CompiledQueryProcessingScope compiledQueryScope) { - ArgumentNullException.ThrowIfNull(session, nameof(session)); - ArgumentNullException.ThrowIfNull(rseCompilerConfiguration, nameof(rseCompilerConfiguration)); - ArgumentNullException.ThrowIfNull(query, nameof(query)); + ArgumentNullException.ThrowIfNull(session); + ArgumentNullException.ThrowIfNull(rseCompilerConfiguration); + ArgumentNullException.ThrowIfNull(query); Domain = session.Domain; RseCompilerConfiguration = rseCompilerConfiguration; diff --git a/Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs b/Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs index 357943d87..90332ea63 100644 --- a/Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs +++ b/Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs @@ -37,7 +37,7 @@ public abstract class BaseLog /// object. Region will closed by disposing of this object. public IndentManager.IndentScope DebugRegion(string messageId, params object[] parameters) { - ArgumentNullException.ThrowIfNull(messageId, "message"); + ArgumentNullException.ThrowIfNull(messageId); if (!IsLogged(LogLevel.Debug)) return IndentManager.IncreaseIndent(); var message = Strings.ResourceManager.GetString(messageId, Strings.Culture) ?? messageId; @@ -60,7 +60,7 @@ public IndentManager.IndentScope DebugRegion(string messageId, params object[] p /// object. Region will closed by disposing of this object. public IndentManager.IndentScope InfoRegion(string messageId, params object[] parameters) { - ArgumentNullException.ThrowIfNull(messageId, "message"); + ArgumentNullException.ThrowIfNull(messageId); if (!IsLogged(LogLevel.Info)) return IndentManager.IncreaseIndent(); var message = Strings.ResourceManager.GetString(messageId, Strings.Culture) ?? messageId; diff --git a/Orm/Xtensive.Orm/Orm/Logging/LogManager.cs b/Orm/Xtensive.Orm/Orm/Logging/LogManager.cs index e49d4a392..cdbccf0ee 100644 --- a/Orm/Xtensive.Orm/Orm/Logging/LogManager.cs +++ b/Orm/Xtensive.Orm/Orm/Logging/LogManager.cs @@ -41,7 +41,7 @@ public void Initialize(System.Configuration.Configuration configuration) /// Instance of class, which implements . public void Initialize(LogProvider logProvider) { - ArgumentNullException.ThrowIfNull(logProvider, "logProvider"); + ArgumentNullException.ThrowIfNull(logProvider); lock (syncObj) { EnsureIsNotInitialized(); provider = logProvider; @@ -54,7 +54,7 @@ public void Initialize(LogProvider logProvider) /// Configuration of logging. public void Initialize(LoggingConfiguration configuration) { - ArgumentNullException.ThrowIfNull(configuration, "configuration"); + ArgumentNullException.ThrowIfNull(configuration); lock (syncObj) { EnsureIsNotInitialized(); if (!string.IsNullOrEmpty(configuration.Provider)) { diff --git a/Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs b/Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs index 966e87d21..b3500f781 100644 --- a/Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs +++ b/Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs @@ -100,7 +100,7 @@ public override string ToString() => /// The instance. public ColumnInfoRef(ColumnInfo columnInfo) { - ArgumentNullException.ThrowIfNull(columnInfo, "columnInfo"); + ArgumentNullException.ThrowIfNull(columnInfo); TypeName = columnInfo.Field.DeclaringType.Name; FieldName = columnInfo.Field.Name; ColumnName = columnInfo.Name; diff --git a/Orm/Xtensive.Orm/Orm/Model/Stored/Internals/TypeMappingUpdater.cs b/Orm/Xtensive.Orm/Orm/Model/Stored/Internals/TypeMappingUpdater.cs index 759740bf4..feca16377 100644 --- a/Orm/Xtensive.Orm/Orm/Model/Stored/Internals/TypeMappingUpdater.cs +++ b/Orm/Xtensive.Orm/Orm/Model/Stored/Internals/TypeMappingUpdater.cs @@ -12,8 +12,8 @@ internal sealed class TypeMappingUpdater { public void UpdateMappings(StoredDomainModel model, NodeConfiguration nodeConfiguration) { - ArgumentNullException.ThrowIfNull(model, "model"); - ArgumentNullException.ThrowIfNull(nodeConfiguration, "nodeConfiguration"); + ArgumentNullException.ThrowIfNull(model); + ArgumentNullException.ThrowIfNull(nodeConfiguration); foreach (var storedType in model.Types) { if (!storedType.MappingDatabase.IsNullOrEmpty()) diff --git a/Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs b/Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs index 67791809b..e1eab161d 100644 --- a/Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs +++ b/Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs @@ -37,7 +37,7 @@ public sealed class TypeIdRegistry : LockableBase public int this[TypeInfo type] { get { - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); return !mapping.TryGetValue(type, out var result) ? throw new KeyNotFoundException(string.Format(Strings.ExTypeXIsNotRegistered, type.Name)) : result; @@ -62,7 +62,7 @@ public int this[TypeInfo type] /// otherwise false. public bool Contains(TypeInfo type) { - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); return mapping.ContainsKey(type); } @@ -77,7 +77,7 @@ public bool Contains(TypeInfo type) /// otherwise . public int GetTypeId(TypeInfo type) { - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); return !mapping.TryGetValue(type, out var result) ? TypeInfo.NoTypeId : result; } @@ -100,7 +100,7 @@ public void Clear() /// Type. public void Register(int typeId, TypeInfo type) { - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(type); EnsureNotLocked(); mapping[type] = typeId; diff --git a/Orm/Xtensive.Orm/Orm/Model/TypeInfoCollection.cs b/Orm/Xtensive.Orm/Orm/Model/TypeInfoCollection.cs index d30c00e45..bf2f163a3 100644 --- a/Orm/Xtensive.Orm/Orm/Model/TypeInfoCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Model/TypeInfoCollection.cs @@ -146,8 +146,7 @@ public override bool Contains(TypeInfo item) { if (item==null) return false; - TypeInfo result; - if (!TryGetValue(item.UnderlyingType, out result)) + if (!TryGetValue(item.UnderlyingType, out var result)) return false; return result==item; } @@ -162,9 +161,8 @@ public override bool Contains(TypeInfo item) /// , if there is no type with specified full name. public TypeInfo Find(string fullName) { - ArgumentNullException.ThrowIfNull(fullName, "fullName"); - TypeInfo result; - return fullNameTable.TryGetValue(fullName, out result) ? result : null; + ArgumentNullException.ThrowIfNull(fullName); + return fullNameTable.TryGetValue(fullName, out var result) ? result : null; } /// diff --git a/Orm/Xtensive.Orm/Orm/Operations/EntityOperation.cs b/Orm/Xtensive.Orm/Orm/Operations/EntityOperation.cs index 1149fc140..bbcb6251a 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/EntityOperation.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/EntityOperation.cs @@ -27,7 +27,7 @@ public abstract class EntityOperation : KeyOperation protected EntityOperation(Key key) : base(key) { - ArgumentNullException.ThrowIfNull(key, "key"); + ArgumentNullException.ThrowIfNull(key); } /// diff --git a/Orm/Xtensive.Orm/Orm/Operations/Internals/OperationRegistrationScope.cs b/Orm/Xtensive.Orm/Orm/Operations/Internals/OperationRegistrationScope.cs index 6c1b40c65..d9ee028c2 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/Internals/OperationRegistrationScope.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/Internals/OperationRegistrationScope.cs @@ -39,7 +39,7 @@ public void Complete() /// public void RegisterEntityIdentifier(Key key, string identifier) { - ArgumentNullException.ThrowIfNull(key, "key"); + ArgumentNullException.ThrowIfNull(key); // Initializing dictionaries, if necessary if (IdentifierByKey == null) { diff --git a/Orm/Xtensive.Orm/Orm/Operations/KeyGenerateOperation.cs b/Orm/Xtensive.Orm/Orm/Operations/KeyGenerateOperation.cs index 724022075..1c68689ba 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/KeyGenerateOperation.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/KeyGenerateOperation.cs @@ -109,7 +109,7 @@ protected override Operation CloneSelf(Operation clone) public KeyGenerateOperation(Key key) : base(key) { - ArgumentNullException.ThrowIfNull(key, "key"); + ArgumentNullException.ThrowIfNull(key); } /// diff --git a/Orm/Xtensive.Orm/Orm/Operations/ValidateVersionOperation.cs b/Orm/Xtensive.Orm/Orm/Operations/ValidateVersionOperation.cs index 3f893d499..f7ff94ede 100644 --- a/Orm/Xtensive.Orm/Orm/Operations/ValidateVersionOperation.cs +++ b/Orm/Xtensive.Orm/Orm/Operations/ValidateVersionOperation.cs @@ -90,7 +90,7 @@ protected override Operation CloneSelf(Operation clone) public ValidateVersionOperation(Key key, VersionInfo version) : base(key) { - ArgumentNullException.ThrowIfNull(version, "version"); + ArgumentValidator.EnsureArgumentIsNotDefault(version, nameof(version)); Version = version; } diff --git a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandFactory.cs b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandFactory.cs index b75c3caca..8d5f2f842 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandFactory.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandFactory.cs @@ -44,8 +44,8 @@ public IEnumerable CreatePersistParts(SqlPersistTask task) public virtual IEnumerable CreatePersistParts(SqlPersistTask task, in string parameterNamePrefix) { - ArgumentNullException.ThrowIfNull(task, "task"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(parameterNamePrefix, "parameterNamePrefix"); + ArgumentNullException.ThrowIfNull(task); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(parameterNamePrefix, nameof(parameterNamePrefix)); var upgradeContext = Upgrade.UpgradeContext.GetCurrent(Session.Domain.UpgradeContextCookie); var nodeConfiguration = upgradeContext != null ? upgradeContext.NodeConfiguration : Session.StorageNode.Configuration; @@ -95,8 +95,8 @@ public CommandPart CreateQueryPart(IQueryRequest request, ParameterContext param public virtual CommandPart CreateQueryPart(IQueryRequest request, in string parameterNamePrefix, ParameterContext parameterContext) { - ArgumentNullException.ThrowIfNull(request, "request"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(parameterNamePrefix, "parameterNamePrefix"); + ArgumentNullException.ThrowIfNull(request); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(parameterNamePrefix, nameof(parameterNamePrefix)); int parameterIndex = 0; var compilationResult = request.GetCompiledStatement(); diff --git a/Orm/Xtensive.Orm/Orm/Providers/CompilationService.cs b/Orm/Xtensive.Orm/Orm/Providers/CompilationService.cs index 9e9fefab1..410388078 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/CompilationService.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/CompilationService.cs @@ -30,8 +30,8 @@ public CompilerConfiguration CreateConfiguration(Session session) => public ExecutableProvider Compile(CompilableProvider provider, CompilerConfiguration configuration) { - ArgumentNullException.ThrowIfNull(provider, "provider"); - ArgumentNullException.ThrowIfNull(configuration, "configuration"); + ArgumentNullException.ThrowIfNull(provider); + ArgumentNullException.ThrowIfNull(configuration); var preCompiler = preCompilerProvider.Invoke(configuration); var compiler = compilerProvider.Invoke(configuration); diff --git a/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs b/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs index a43f63ded..97ad4c715 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs @@ -501,9 +501,9 @@ public ExpressionProcessor(LambdaExpression lambda, in bool preferCaseOverVariant, params IReadOnlyList[] sourceColumns) { - ArgumentNullException.ThrowIfNull(lambda, "lambda"); - ArgumentNullException.ThrowIfNull(handlers, "handlers"); - ArgumentNullException.ThrowIfNull(sourceColumns, "sourceColumns"); + ArgumentNullException.ThrowIfNull(lambda); + ArgumentNullException.ThrowIfNull(handlers); + ArgumentNullException.ThrowIfNull(sourceColumns); if (lambda.Parameters.Count != sourceColumns.Length) throw Exceptions.InternalError(Strings.ExParametersCountIsNotSameAsSourceColumnListsCount, OrmLog.Instance); diff --git a/Orm/Xtensive.Orm/Orm/Providers/MappingResolver.cs b/Orm/Xtensive.Orm/Orm/Providers/MappingResolver.cs index a214a2970..f02c5ce6b 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/MappingResolver.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/MappingResolver.cs @@ -43,9 +43,9 @@ public Schema ResolveSchema(SchemaExtractionResult model, string mappingDatabase public static MappingResolver Create(DomainConfiguration configuration, NodeConfiguration nodeConfiguration, DefaultSchemaInfo defaultSchemaInfo) { - ArgumentNullException.ThrowIfNull(configuration, "configuration"); - ArgumentNullException.ThrowIfNull(nodeConfiguration, "nodeConfiguration"); - ArgumentNullException.ThrowIfNull(defaultSchemaInfo, "defaultSchemaInfo"); + ArgumentNullException.ThrowIfNull(configuration); + ArgumentNullException.ThrowIfNull(nodeConfiguration); + ArgumentNullException.ThrowIfNull(defaultSchemaInfo); if (configuration.IsMultidatabase) return new MultidatabaseMappingResolver(configuration, nodeConfiguration); diff --git a/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs b/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs index 034c65a01..fdb54aa24 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs @@ -62,8 +62,8 @@ public sealed class NameBuilder /// Type name. public string BuildTypeName(BuildingContext context, TypeDef type) { - ArgumentNullException.ThrowIfNull(context, "context"); - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(context); + ArgumentNullException.ThrowIfNull(type); if (type.UnderlyingType.IsGenericType) return ApplyNamingRules(BuildGenericTypeName(context, type.UnderlyingType, type.MappingName)); @@ -152,7 +152,7 @@ public string BuildTableName(IndexInfo indexInfo) /// Column name. public string BuildTableColumnName(ColumnInfo columnInfo) { - ArgumentNullException.ThrowIfNull(columnInfo, "columnInfo"); + ArgumentNullException.ThrowIfNull(columnInfo); return ApplyNamingRules(columnInfo.Name); } @@ -162,9 +162,9 @@ public string BuildTableColumnName(ColumnInfo columnInfo) /// Foreign key name. public string BuildReferenceForeignKeyName(TypeInfo ownerType, FieldInfo ownerField, TypeInfo targetType) { - ArgumentNullException.ThrowIfNull(ownerType, "ownerType"); - ArgumentNullException.ThrowIfNull(ownerField, "ownerField"); - ArgumentNullException.ThrowIfNull(targetType, "targetType"); + ArgumentNullException.ThrowIfNull(ownerType); + ArgumentNullException.ThrowIfNull(ownerField); + ArgumentNullException.ThrowIfNull(targetType); return ApplyNamingRules(string.Format(ReferenceForeignKeyFormat, ownerType.Name, ownerField.Name, targetType.Name)); } @@ -174,8 +174,8 @@ public string BuildReferenceForeignKeyName(TypeInfo ownerType, FieldInfo ownerFi /// Foreign key name. public string BuildHierarchyForeignKeyName(TypeInfo baseType, TypeInfo descendantType) { - ArgumentNullException.ThrowIfNull(baseType, "baseType"); - ArgumentNullException.ThrowIfNull(descendantType, "descendantType"); + ArgumentNullException.ThrowIfNull(baseType); + ArgumentNullException.ThrowIfNull(descendantType); return ApplyNamingRules(string.Format(HierarchyForeignKeyFormat, baseType.Name, descendantType.Name)); } @@ -186,7 +186,7 @@ public string BuildHierarchyForeignKeyName(TypeInfo baseType, TypeInfo descendan /// Field name. public string BuildFieldName(FieldDef field) { - ArgumentNullException.ThrowIfNull(field, "field"); + ArgumentNullException.ThrowIfNull(field); string result = field.Name; if (field.UnderlyingProperty != null) return BuildFieldNameInternal(field.UnderlyingProperty); @@ -203,7 +203,7 @@ private string BuildFieldNameInternal(PropertyInfo propertyInfo) /// The property info. public string BuildFieldName(PropertyInfo propertyInfo) { - ArgumentNullException.ThrowIfNull(propertyInfo, "propertyInfo"); + ArgumentNullException.ThrowIfNull(propertyInfo); return BuildFieldNameInternal(propertyInfo); } @@ -226,8 +226,8 @@ public string BuildExplicitFieldName(TypeInfo type, string name) /// Nested field name. public string BuildNestedFieldName(FieldInfo complexField, FieldInfo childField) { - ArgumentNullException.ThrowIfNull(complexField, "complexField"); - ArgumentNullException.ThrowIfNull(childField, "childField"); + ArgumentNullException.ThrowIfNull(complexField); + ArgumentNullException.ThrowIfNull(childField); var nameSource = complexField; while (nameSource.Parent != null) nameSource = nameSource.Parent; @@ -257,8 +257,8 @@ public string BuildMappingName(FieldInfo complexField, FieldInfo childField) /// Column name. public string BuildColumnName(FieldInfo field, ColumnInfo baseColumn) { - ArgumentNullException.ThrowIfNull(field, "field"); - ArgumentNullException.ThrowIfNull(baseColumn, "baseColumn"); + ArgumentNullException.ThrowIfNull(field); + ArgumentNullException.ThrowIfNull(baseColumn); var result = field.MappingName ?? field.Name; return ApplyNamingRules(result); @@ -272,7 +272,7 @@ public string BuildColumnName(FieldInfo field, ColumnInfo baseColumn) /// Column name. public string BuildColumnName(ColumnInfo column) { - ArgumentNullException.ThrowIfNull(column, "column"); + ArgumentNullException.ThrowIfNull(column); if (column.Name.StartsWith(column.Field.DeclaringType.Name + ".", StringComparison.Ordinal)) throw new InvalidOperationException(); string result = string.Concat(column.Field.DeclaringType.Name, ".", column.Name); @@ -287,7 +287,7 @@ public string BuildColumnName(ColumnInfo column) /// Index name. public string BuildIndexName(TypeDef type, IndexDef index) { - ArgumentNullException.ThrowIfNull(index, "index"); + ArgumentNullException.ThrowIfNull(index); string result = string.Empty; if (!index.Name.IsNullOrEmpty()) @@ -319,7 +319,7 @@ public string BuildIndexName(TypeDef type, IndexDef index) /// Index name. public string BuildIndexName(TypeInfo type, IndexInfo index) { - ArgumentNullException.ThrowIfNull(index, "index"); + ArgumentNullException.ThrowIfNull(index); if (!index.Name.IsNullOrEmpty()) return index.Name; @@ -597,9 +597,9 @@ private static string FormatKeyGeneratorName(string database, string name) internal NameBuilder(DomainConfiguration configuration, ProviderInfo providerInfo) { - ArgumentNullException.ThrowIfNull(configuration, "configuration"); + ArgumentNullException.ThrowIfNull(configuration); ArgumentNullException.ThrowIfNull(configuration.NamingConvention, "configuration.NamingConvention"); - ArgumentNullException.ThrowIfNull(providerInfo, "providerInfo"); + ArgumentNullException.ThrowIfNull(providerInfo); namingConvention = configuration.NamingConvention; isMultidatabase = configuration.IsMultidatabase; diff --git a/Orm/Xtensive.Orm/Orm/Providers/Requests/QueryParameterBinding.cs b/Orm/Xtensive.Orm/Orm/Providers/Requests/QueryParameterBinding.cs index 0b0238b62..b193bb448 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/Requests/QueryParameterBinding.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/Requests/QueryParameterBinding.cs @@ -28,7 +28,7 @@ private QueryParameterBinding(TypeMapping typeMapping, Func void IDirectSqlService.RegisterInitializationSql(string sql) { - ArgumentNullException.ThrowIfNull(sql, "sql"); + ArgumentNullException.ThrowIfNull(sql); initializationSqlScripts.Add(sql); } diff --git a/Orm/Xtensive.Orm/Orm/Providers/StorageDriver.cs b/Orm/Xtensive.Orm/Orm/Providers/StorageDriver.cs index 43327a6ec..7f4e475fc 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/StorageDriver.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/StorageDriver.cs @@ -95,7 +95,7 @@ public DbDataReaderAccessor GetDataReaderAccessor(in TupleDescriptor descriptor) public StorageDriver CreateNew(Domain domain) { - ArgumentNullException.ThrowIfNull(domain, "domain"); + ArgumentNullException.ThrowIfNull(domain); return new StorageDriver(underlyingDriver, ProviderInfo, domain.Configuration, GetModelProvider(domain), connectionAccessorFactories); } @@ -213,8 +213,8 @@ private static Func CreateNewAccessor() where T : IDbC public static StorageDriver Create(SqlDriverFactory driverFactory, DomainConfiguration configuration) { - ArgumentNullException.ThrowIfNull(driverFactory, nameof(driverFactory)); - ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(driverFactory); + ArgumentNullException.ThrowIfNull(configuration); var accessors = CreateConnectionAccessors(configuration.Types.DbConnectionAccessors, out var factories); var driverConfiguration = new SqlDriverConfiguration(accessors) { @@ -232,8 +232,8 @@ public static StorageDriver Create(SqlDriverFactory driverFactory, DomainConfigu public static async Task CreateAsync( SqlDriverFactory driverFactory, DomainConfiguration configuration, CancellationToken token) { - ArgumentNullException.ThrowIfNull(driverFactory, nameof(driverFactory)); - ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); + ArgumentNullException.ThrowIfNull(driverFactory); + ArgumentNullException.ThrowIfNull(configuration); var accessors = CreateConnectionAccessors(configuration.Types.DbConnectionAccessors, out var factories); var driverConfiguration = new SqlDriverConfiguration(accessors) { diff --git a/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs b/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs index b3c14775e..514a79644 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/StorageSequenceAccessor.cs @@ -113,7 +113,7 @@ private SequenceQuery GetSequenceQuery(SequenceInfo sequenceInfo, Session sessio [ServiceConstructor] public StorageSequenceAccessor(HandlerAccessor handlers) { - ArgumentNullException.ThrowIfNull(handlers, "handlers"); + ArgumentNullException.ThrowIfNull(handlers); queryBuilder = handlers.SequenceQueryBuilder; domain = handlers.Domain; diff --git a/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs b/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs index be4b13cd2..8eab1195f 100644 --- a/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs +++ b/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs @@ -95,7 +95,7 @@ public IQueryable All(Type elementType) public IQueryable> FreeText(string searchCriteria) where T : Entity { - ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(searchCriteria); var method = WellKnownMembers.Query.FreeTextString.CachedMakeGenericMethod(typeof(T)); var expression = Expression.Call(method, Expression.Constant(searchCriteria)); return Provider.CreateQuery>(expression); @@ -115,8 +115,8 @@ public IQueryable> FreeText(string searchCriteria) public IQueryable> FreeText(string searchCriteria, int topNByRank) where T : Entity { - ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); - ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, "topNByRank"); + ArgumentNullException.ThrowIfNull(searchCriteria); + ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, nameof(topNByRank)); var method = WellKnownMembers.Query.FreeTextStringTopNByRank.CachedMakeGenericMethod(typeof (T)); var expression = Expression.Call(method, Expression.Constant(searchCriteria), Expression.Constant(topNByRank)); return Provider.CreateQuery>(expression); @@ -134,7 +134,7 @@ public IQueryable> FreeText(string searchCriteria, int topNB public IQueryable> FreeText(Expression> searchCriteria) where T : Entity { - ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(searchCriteria); var method = WellKnownMembers.Query.FreeTextExpression.CachedMakeGenericMethod(typeof(T)); var expression = Expression.Call(null, method, new[] { searchCriteria }); return Provider.CreateQuery>(expression); @@ -154,8 +154,8 @@ public IQueryable> FreeText(Expression> searchC public IQueryable> FreeText(Expression> searchCriteria, int topNByRank) where T : Entity { - ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); - ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, "topNByRank"); + ArgumentNullException.ThrowIfNull(searchCriteria); + ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, nameof(topNByRank)); var method = WellKnownMembers.Query.FreeTextExpressionTopNByRank.CachedMakeGenericMethod(typeof (T)); var expression = Expression.Call(null, method, searchCriteria, Expression.Constant(topNByRank)); return Provider.CreateQuery>(expression); @@ -173,7 +173,7 @@ public IQueryable> FreeText(Expression> searchC public IQueryable> ContainsTable([NotNull] Expression> searchCriteria) where T: Entity { - ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); + ArgumentNullException.ThrowIfNull(searchCriteria); var method = WellKnownMembers.Query.ContainsTableExpr.CachedMakeGenericMethod(typeof (T)); var expression = Expression.Call(null, method, searchCriteria); return Provider.CreateQuery>(expression); @@ -194,8 +194,8 @@ public IQueryable> ContainsTable( [NotNull] Expression>[] targetFields) where T : Entity { - ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); - ArgumentNullException.ThrowIfNull(targetFields, "targetFields"); + ArgumentNullException.ThrowIfNull(searchCriteria); + ArgumentNullException.ThrowIfNull(targetFields); var method = WellKnownMembers.Query.ContainsTableExprWithColumns.CachedMakeGenericMethod(typeof(T)); var expression = Expression.Call(null, method, searchCriteria, Expression.Constant(targetFields)); return Provider.CreateQuery>(expression); @@ -217,8 +217,8 @@ public IQueryable> ContainsTable( public IQueryable> ContainsTable([NotNull] Expression> searchCriteria, int topNByRank) where T : Entity { - ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); - ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, "topNByRank"); + ArgumentNullException.ThrowIfNull(searchCriteria); + ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, nameof(topNByRank)); var method = WellKnownMembers.Query.ContainsTableExprTopNByRank.CachedMakeGenericMethod(typeof(T)); var expression = Expression.Call(null, method, searchCriteria, Expression.Constant(topNByRank)); return Provider.CreateQuery>(expression); @@ -244,9 +244,9 @@ public IQueryable> ContainsTable( int topNByRank) where T : Entity { - ArgumentNullException.ThrowIfNull(searchCriteria, "searchCriteria"); - ArgumentNullException.ThrowIfNull(targetFields, "targetFields"); - ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, "topNByRank"); + ArgumentNullException.ThrowIfNull(searchCriteria); + ArgumentNullException.ThrowIfNull(targetFields); + ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, nameof(topNByRank)); var method = WellKnownMembers.Query.ContainsTableExprTopNByRank.CachedMakeGenericMethod(typeof(T)); var expression = Expression.Call(null, method, searchCriteria, Expression.Constant(targetFields), Expression.Constant(topNByRank)); return Provider.CreateQuery>(expression); @@ -839,9 +839,9 @@ public IQueryable Items(Expression> private Key GetKeyByValues(object[] keyValues) where T : class, IEntity { - ArgumentNullException.ThrowIfNull(keyValues, "keyValues"); + ArgumentNullException.ThrowIfNull(keyValues); if (keyValues.Length == 0) - throw new ArgumentException(Strings.ExKeyValuesArrayIsEmpty, "keyValues"); + throw new ArgumentException(Strings.ExKeyValuesArrayIsEmpty, nameof(keyValues)); if (keyValues.Length == 1) { switch (keyValues[0]) { case Key key: @@ -867,15 +867,15 @@ private Expression BuildRootExpression(Type elementType) internal QueryEndpoint(QueryProvider provider) { - ArgumentNullException.ThrowIfNull(provider, "provider"); + ArgumentNullException.ThrowIfNull(provider); Provider = provider; session = provider.Session; } internal QueryEndpoint(QueryEndpoint outerEndpoint, IQueryRootBuilder queryRootBuilder) { - ArgumentNullException.ThrowIfNull(outerEndpoint, "outerEndpoint"); - ArgumentNullException.ThrowIfNull(queryRootBuilder, "queryRootBuilder"); + ArgumentNullException.ThrowIfNull(outerEndpoint); + ArgumentNullException.ThrowIfNull(queryRootBuilder); Provider = outerEndpoint.Provider; session = outerEndpoint.session; RootBuilder = queryRootBuilder; diff --git a/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs b/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs index 4817387e9..08291b9ae 100644 --- a/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs +++ b/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs @@ -67,8 +67,8 @@ public QueryAsAsyncEnumerable(QueryProvider queryProvider, Expression expression public static Task AllAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(predicate); return ExecuteScalarAsync(WellKnownMembers.Queryable.All, source, predicate, cancellationToken); } @@ -91,7 +91,7 @@ public static Task AllAsync(this IQueryable source, public static Task AnyAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.Any, source, cancellationToken); } @@ -116,8 +116,8 @@ public static Task AnyAsync(this IQueryable source, public static Task AnyAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(predicate); return ExecuteScalarAsync( WellKnownMembers.Queryable.AnyWithPredicate, source, predicate, cancellationToken); @@ -144,7 +144,7 @@ public static Task AnyAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.Int32], source, cancellationToken); @@ -167,7 +167,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.NullableInt32], source, cancellationToken); @@ -193,8 +193,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.Int32], @@ -221,8 +221,8 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.NullableInt32], @@ -248,7 +248,7 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.Int64], source, cancellationToken); @@ -271,7 +271,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.NullableInt64], source, cancellationToken); @@ -297,8 +297,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.Int64], @@ -325,8 +325,8 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.NullableInt64], @@ -352,7 +352,7 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.Double], source, cancellationToken); @@ -375,7 +375,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.NullableDouble], source, cancellationToken); @@ -401,8 +401,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.Double], @@ -429,8 +429,8 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.NullableDouble], @@ -456,7 +456,7 @@ public static Task AverageAsync(this IQueryable source public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.Single], source, cancellationToken); @@ -479,7 +479,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.NullableSingle], source, cancellationToken); @@ -505,8 +505,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.Single], @@ -533,8 +533,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.NullableSingle], @@ -560,7 +560,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.Decimal], source, cancellationToken); @@ -583,7 +583,7 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageMethodInfos[WellKnownTypes.NullableDecimal], source, cancellationToken); @@ -609,8 +609,8 @@ public static Task AverageAsync(this IQueryable source, public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.Decimal], @@ -637,8 +637,8 @@ public static Task AverageAsync(this IQueryable sourc public static Task AverageAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.AverageWithSelectorMethodInfos[WellKnownTypes.NullableDecimal], @@ -668,7 +668,7 @@ public static Task AverageAsync(this IQueryable sourc public static Task ContainsAsync(this IQueryable source, TSource item, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.Contains, source, Expression.Constant(item, typeof(TSource)), cancellationToken); @@ -694,7 +694,7 @@ public static Task ContainsAsync(this IQueryable source, public static Task CountAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.Count, source, cancellationToken); } @@ -718,8 +718,8 @@ public static Task CountAsync(this IQueryable source, public static Task CountAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(predicate); return ExecuteScalarAsync(WellKnownMembers.Queryable.CountWithPredicate, source, predicate, cancellationToken); @@ -749,7 +749,7 @@ public static Task CountAsync(this IQueryable source, public static Task FirstAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.First, source, cancellationToken); } @@ -773,8 +773,8 @@ public static Task FirstAsync(this IQueryable source, public static Task FirstAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(predicate); return ExecuteScalarAsync(WellKnownMembers.Queryable.FirstWithPredicate, source, predicate, cancellationToken); @@ -801,7 +801,7 @@ public static Task FirstAsync(this IQueryable source, public static Task FirstOrDefaultAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.FirstOrDefault, source, cancellationToken); } @@ -827,8 +827,8 @@ public static Task FirstOrDefaultAsync(this IQueryable FirstOrDefaultAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(predicate); return ExecuteScalarAsync(WellKnownMembers.Queryable.FirstOrDefaultWithPredicate, source, predicate, cancellationToken); @@ -857,7 +857,7 @@ public static Task FirstOrDefaultAsync(this IQueryable LastAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.Last, source, cancellationToken); } @@ -881,8 +881,8 @@ public static Task LastAsync(this IQueryable source, public static Task LastAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(predicate); return ExecuteScalarAsync(WellKnownMembers.Queryable.LastWithPredicate, source, predicate, cancellationToken); @@ -909,7 +909,7 @@ public static Task LastAsync(this IQueryable source, public static Task LastOrDefaultAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.LastOrDefault, source, cancellationToken); } @@ -935,8 +935,8 @@ public static Task LastOrDefaultAsync(this IQueryable public static Task LastOrDefaultAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(predicate); return ExecuteScalarAsync(WellKnownMembers.Queryable.LastOrDefaultWithPredicate, source, predicate, cancellationToken); @@ -965,7 +965,7 @@ public static Task LastOrDefaultAsync(this IQueryable public static Task LongCountAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.LongCount, source, cancellationToken); } @@ -991,8 +991,8 @@ public static Task LongCountAsync(this IQueryable source public static Task LongCountAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(predicate); return ExecuteScalarAsync(WellKnownMembers.Queryable.LongCountWithPredicate, source, predicate, cancellationToken); @@ -1022,7 +1022,7 @@ public static Task LongCountAsync(this IQueryable source public static Task MaxAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.Max, source, cancellationToken); } @@ -1048,8 +1048,8 @@ public static Task MaxAsync(this IQueryable source, public static Task MaxAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync(WellKnownMembers.Queryable.MaxWithSelector, source, selector, cancellationToken); @@ -1074,7 +1074,7 @@ public static Task MaxAsync(this IQueryable public static Task MinAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.Min, source, cancellationToken); } @@ -1099,8 +1099,8 @@ public static Task MinAsync(this IQueryable source, public static Task MinAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync(WellKnownMembers.Queryable.MinWithSelector, source, selector, cancellationToken); @@ -1131,7 +1131,7 @@ public static Task MinAsync(this IQueryable public static Task SingleAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.Single, source, cancellationToken); } @@ -1156,8 +1156,8 @@ public static Task SingleAsync(this IQueryable source public static Task SingleAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(predicate); return ExecuteScalarAsync(WellKnownMembers.Queryable.SingleWithPredicate, source, predicate, cancellationToken); @@ -1186,7 +1186,7 @@ public static Task SingleAsync(this IQueryable source public static Task SingleOrDefaultAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync(WellKnownMembers.Queryable.SingleOrDefault, source, cancellationToken); @@ -1214,8 +1214,8 @@ public static Task SingleOrDefaultAsync(this IQueryable SingleOrDefaultAsync(this IQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(predicate, nameof(predicate)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(predicate); return ExecuteScalarAsync(WellKnownMembers.Queryable.SingleOrDefaultWithPredicate, source, predicate, cancellationToken); @@ -1244,7 +1244,7 @@ public static Task SingleOrDefaultAsync(this IQueryable SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.Int32], source, cancellationToken); @@ -1267,7 +1267,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.NullableInt32], source, cancellationToken); @@ -1293,8 +1293,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.Int32], @@ -1321,8 +1321,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.NullableInt32], @@ -1348,7 +1348,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.Int64], source, cancellationToken); @@ -1371,7 +1371,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.NullableInt64], source, cancellationToken); @@ -1397,8 +1397,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.Int64], @@ -1425,8 +1425,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.NullableInt64], @@ -1452,7 +1452,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.Double], source, cancellationToken); @@ -1475,7 +1475,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.NullableDouble], source, cancellationToken); @@ -1501,8 +1501,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.Double], @@ -1529,8 +1529,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.NullableDouble], @@ -1556,7 +1556,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.Single], source, cancellationToken); @@ -1579,7 +1579,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.NullableSingle], source, cancellationToken); @@ -1605,8 +1605,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.Single], @@ -1633,8 +1633,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.NullableSingle], @@ -1660,7 +1660,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.Decimal], source, cancellationToken); @@ -1683,7 +1683,7 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumMethodInfos[WellKnownTypes.NullableDecimal], source, cancellationToken); @@ -1709,8 +1709,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.Decimal], @@ -1737,8 +1737,8 @@ public static Task SumAsync(this IQueryable source, public static Task SumAsync(this IQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(selector, nameof(selector)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(selector); return ExecuteScalarAsync( WellKnownMembers.Queryable.SumWithSelectorMethodInfos[WellKnownTypes.NullableDecimal], @@ -1991,7 +1991,7 @@ public static async Task> ToLookupAsyncThe query results. public static IAsyncEnumerable AsAsyncEnumerable(this IQueryable source) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); if (source is IAsyncEnumerable nativeAsyncEnumerable) { return nativeAsyncEnumerable; diff --git a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs index 507528dad..197cbcd3f 100644 --- a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs @@ -37,8 +37,8 @@ public static partial class QueryableExtensions /// The same sequence, but with "comment" applied to query. public static IQueryable Tag(this IQueryable source, string tag) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(tag, nameof(tag)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(tag); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -61,8 +61,8 @@ public static IQueryable Tag(this IQueryable source, /// The same sequence, but with "comment" applied to query. public static IQueryable Tag(this IQueryable source, string tag) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(tag, nameof(tag)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(tag); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -81,7 +81,7 @@ public static IQueryable Tag(this IQueryable source, string tag) /// The source sequence. public static int Count([InstantHandle] this IQueryable source) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return (int) source.Provider.Execute( Expression.Call( WellKnownTypes.Queryable, nameof(Queryable.Count), @@ -98,8 +98,8 @@ public static int Count([InstantHandle] this IQueryable source) /// The same result as its original version. public static IQueryable Take(this IQueryable source, Expression> count) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(count, nameof(count)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(count); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -122,8 +122,8 @@ public static IQueryable Take(this IQueryable source, /// The same result as its original version. public static IQueryable Skip(this IQueryable source, Expression> count) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(count, nameof(count)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(count); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -146,8 +146,8 @@ public static IQueryable Skip(this IQueryable source, /// The same result as its original version. public static TSource ElementAt(this IQueryable source, Expression> index) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(index, nameof(index)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(index); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -170,8 +170,8 @@ public static TSource ElementAt(this IQueryable source, Expres /// The same result as its original version. public static TSource ElementAtOrDefault(this IQueryable source, Expression> index) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(index, nameof(index)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(index); var providerType = source.Provider.GetType(); if (providerType != WellKnownOrmTypes.QueryProvider) { @@ -194,9 +194,7 @@ public static TSource ElementAtOrDefault(this IQueryable sourc /// The same sequence, but with "apply lock" hint. public static IQueryable Lock(this IQueryable source, LockMode lockMode, LockBehavior lockBehavior) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(lockMode, nameof(lockMode)); - ArgumentNullException.ThrowIfNull(lockBehavior, nameof(lockBehavior)); + ArgumentNullException.ThrowIfNull(source); var providerType = source.Provider.GetType(); if (providerType!=WellKnownOrmTypes.QueryProvider) { @@ -275,11 +273,11 @@ public static bool In(this T source, IncludeAlgorithm algorithm, IEnumerable< [Obsolete(".NET 10 has its own LeftJoin method declared, which will conflict with this. Use LeftJoinEx to prepare your code for future .NET change")] public static IQueryable LeftJoin(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { - ArgumentNullException.ThrowIfNull(outer, nameof(outer)); - ArgumentNullException.ThrowIfNull(inner, nameof(inner)); - ArgumentNullException.ThrowIfNull(outerKeySelector, nameof(outerKeySelector)); - ArgumentNullException.ThrowIfNull(innerKeySelector, nameof(innerKeySelector)); - ArgumentNullException.ThrowIfNull(resultSelector, nameof(resultSelector)); + ArgumentNullException.ThrowIfNull(outer); + ArgumentNullException.ThrowIfNull(inner); + ArgumentNullException.ThrowIfNull(outerKeySelector); + ArgumentNullException.ThrowIfNull(innerKeySelector); + ArgumentNullException.ThrowIfNull(resultSelector); var outerProviderType = outer.Provider.GetType(); if (outerProviderType!=WellKnownOrmTypes.QueryProvider) { @@ -309,11 +307,11 @@ public static IQueryable LeftJoin(this I /// Queryable is not a query. public static IQueryable LeftJoinEx(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { - ArgumentNullException.ThrowIfNull(outer, nameof(outer)); - ArgumentNullException.ThrowIfNull(inner, nameof(inner)); - ArgumentNullException.ThrowIfNull(outerKeySelector, nameof(outerKeySelector)); - ArgumentNullException.ThrowIfNull(innerKeySelector, nameof(innerKeySelector)); - ArgumentNullException.ThrowIfNull(resultSelector, nameof(resultSelector)); + ArgumentNullException.ThrowIfNull(outer); + ArgumentNullException.ThrowIfNull(inner); + ArgumentNullException.ThrowIfNull(outerKeySelector); + ArgumentNullException.ThrowIfNull(innerKeySelector); + ArgumentNullException.ThrowIfNull(resultSelector); var outerProviderType = outer.Provider.GetType(); if (outerProviderType != WellKnownOrmTypes.QueryProvider) { diff --git a/Orm/Xtensive.Orm/Orm/Rse/ProviderExtensions.cs b/Orm/Xtensive.Orm/Orm/Rse/ProviderExtensions.cs index 0d14f42e2..c6a81996e 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/ProviderExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/ProviderExtensions.cs @@ -27,8 +27,8 @@ public static class ProviderExtensions public static RecordSetReader GetRecordSetReader( this CompilableProvider provider, Session session, ParameterContext parameterContext) { - ArgumentNullException.ThrowIfNull(provider, nameof(provider)); - ArgumentNullException.ThrowIfNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(provider); + ArgumentNullException.ThrowIfNull(session); var executableProvider = session.Compile(provider); return executableProvider.GetRecordSetReader(session, parameterContext); } @@ -40,8 +40,8 @@ public static RecordSetReader GetRecordSetReader( /// The session. public static long Count(this CompilableProvider provider, Session session) { - ArgumentNullException.ThrowIfNull(provider, nameof(provider)); - ArgumentNullException.ThrowIfNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(provider); + ArgumentNullException.ThrowIfNull(session); using var recordSetReader = provider .Aggregate(null, new AggregateColumnDescriptor("$Count", 0, AggregateType.Count)) .GetRecordSetReader(session, new ParameterContext()); diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AggregateProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AggregateProvider.cs index 1847a2bc3..297e7e052 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AggregateProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AggregateProvider.cs @@ -199,7 +199,7 @@ private static NotSupportedException AggregateNotSupported(Type sourceColumnType public AggregateProvider(CompilableProvider source, int[] groupIndexes, IReadOnlyList columnDescriptors) : base(ProviderType.Aggregate, source) { - ArgumentNullException.ThrowIfNull(columnDescriptors, nameof(columnDescriptors)); + ArgumentNullException.ThrowIfNull(columnDescriptors); groupIndexes = groupIndexes ?? Array.Empty(); var columns = new AggregateColumn[columnDescriptors.Count]; for (int i = 0, count = columnDescriptors.Count; i < count; i++) { diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/CalculateProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/CalculateProvider.cs index 127f7c782..b5a23d747 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/CalculateProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/CalculateProvider.cs @@ -70,7 +70,7 @@ protected override void Initialize() public CalculateProvider(CompilableProvider source, IReadOnlyList columnDescriptors, bool isInlined = false) : base(ProviderType.Calculate, source) { - ArgumentNullException.ThrowIfNull(columnDescriptors, nameof(columnDescriptors)); + ArgumentNullException.ThrowIfNull(columnDescriptors); IsInlined = isInlined; var columns = new CalculatedColumn[columnDescriptors.Count]; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/IncludeProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/IncludeProvider.cs index d08e74c11..6c0dd4789 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/IncludeProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/IncludeProvider.cs @@ -90,7 +90,7 @@ public IncludeProvider(CompilableProvider source, IncludeAlgorithm algorithm, bo : base(ProviderType.Include, source) { ArgumentValidator.EnsureArgumentNotNullOrEmpty(resultColumnName, nameof (resultColumnName)); - ArgumentNullException.ThrowIfNull(filteredColumns, nameof(filteredColumns)); + ArgumentNullException.ThrowIfNull(filteredColumns); Algorithm = algorithm; IsInlined = isInlined; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/SelectProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/SelectProvider.cs index e00684ee8..5b094fa50 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/SelectProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/SelectProvider.cs @@ -44,7 +44,7 @@ protected override string ParametersToString() public SelectProvider(CompilableProvider provider, IReadOnlyList columnIndexes) : base(ProviderType.Select, provider) { - ArgumentNullException.ThrowIfNull(columnIndexes, nameof(columnIndexes)); + ArgumentNullException.ThrowIfNull(columnIndexes); switch (columnIndexes) { case int[] indexArray: diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/StoreProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/StoreProvider.cs index c5a8d742f..819ad69d1 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/StoreProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/StoreProvider.cs @@ -67,7 +67,7 @@ public StoreProvider(RecordSetHeader header, string name) public StoreProvider(CompilableProvider source, string name) : base(ProviderType.Store, source) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, nameof(name)); Name = name; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/ExecutableProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/ExecutableProvider.cs index 5152cc3f9..ceef589d5 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/ExecutableProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/ExecutableProvider.cs @@ -142,7 +142,7 @@ public IEnumerable ToEnumerable(EnumerationContext context) /// New bound to specified . public RecordSetReader GetRecordSetReader(Session session, ParameterContext parameterContext) { - ArgumentNullException.ThrowIfNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(session); var enumerationContext = session.CreateEnumerationContext(parameterContext); return RecordSetReader.Create(enumerationContext, this); } @@ -160,7 +160,7 @@ public RecordSetReader GetRecordSetReader(Session session, ParameterContext para public async Task GetRecordSetReaderAsync( Session session, ParameterContext parameterContext, CancellationToken token) { - ArgumentNullException.ThrowIfNull(session, nameof(session)); + ArgumentNullException.ThrowIfNull(session); var enumerationContext = await session.CreateEnumerationContextAsync(parameterContext, token).ConfigureAwait(false); return await RecordSetReader.CreateAsync(enumerationContext, this, token).ConfigureAwait(false); diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/TagScope.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/TagScope.cs index 0c69bb27e..cadfb329d 100755 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/TagScope.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/TagScope.cs @@ -17,8 +17,8 @@ public void Dispose() => internal TagScope(List tags, string tag) { - ArgumentNullException.ThrowIfNull(tags, nameof(tags)); - ArgumentNullException.ThrowIfNull(tag, nameof(tag)); + ArgumentNullException.ThrowIfNull(tags); + ArgumentNullException.ThrowIfNull(tag); (this.tags = tags).Add(tag); } } diff --git a/Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs b/Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs index a9db9b389..6299961ab 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs @@ -377,8 +377,8 @@ public RecordSetHeader( TupleDescriptor? orderKeyDescriptor, DirectionCollection order) { - ArgumentValidator.EnsureArgumentIsNotDefault(tupleDescriptor, "tupleDescriptor"); - ArgumentNullException.ThrowIfNull(columns, "columns"); + ArgumentValidator.EnsureArgumentIsNotDefault(tupleDescriptor, nameof(tupleDescriptor)); + ArgumentNullException.ThrowIfNull(columns); TupleDescriptor = tupleDescriptor; // Unsafe perf. optimization: if you pass a list, it should be immutable! diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyFilterRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyFilterRewriter.cs index 3ac5f583a..148bb803a 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyFilterRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyFilterRewriter.cs @@ -46,13 +46,13 @@ protected override Expression VisitMethodCall(MethodCallExpression mc) private void Initialize(Expression> predicate, ColumnCollection predicateColumns, ColumnCollection currentColumns) { - ArgumentNullException.ThrowIfNull(predicate, "predicate"); - ArgumentNullException.ThrowIfNull(predicateColumns, "predicateColumns"); - ArgumentNullException.ThrowIfNull(currentColumns, "currentColumns"); + ArgumentNullException.ThrowIfNull(predicate); + ArgumentNullException.ThrowIfNull(predicateColumns); + ArgumentNullException.ThrowIfNull(currentColumns); if (predicateColumns.Count == 0) - throw Exceptions.CollectionIsEmpty("predicateColumns"); + throw Exceptions.CollectionIsEmpty(nameof(predicateColumns)); if (currentColumns.Count == 0) - throw Exceptions.CollectionIsEmpty("currentColumns"); + throw Exceptions.CollectionIsEmpty(nameof(currentColumns)); sourceColumns = predicateColumns; targetColumns = currentColumns; } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyParameterSearcher.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyParameterSearcher.cs index 5d5e4d7e2..737dc22a5 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyParameterSearcher.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyParameterSearcher.cs @@ -17,7 +17,7 @@ internal sealed class ApplyParameterSearcher : ExpressionVisitor public ApplyParameter Find(LambdaExpression predicate) { - ArgumentNullException.ThrowIfNull(predicate, "predicate"); + ArgumentNullException.ThrowIfNull(predicate); result = null; Visit(predicate); return result; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateRelatedExpressionRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateRelatedExpressionRewriter.cs index a7f85e5b0..b5f284119 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateRelatedExpressionRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/CalculateRelatedExpressionRewriter.cs @@ -24,7 +24,7 @@ public LambdaExpression Rewrite(LambdaExpression expression, ParameterExpression substituteParameter, ColumnCollection sourceColumns, ColumnCollection targetColumns) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); substitute = substituteParameter ?? throw new ArgumentNullException(nameof(substituteParameter)); this.sourceColumns = sourceColumns ?? throw new ArgumentNullException(nameof(sourceColumns)); diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs index b294e6023..e313be7f6 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs @@ -24,7 +24,7 @@ public static CompilableProvider Rewrite( CompilableProvider originProvider, Func orderingDescriptorResolver) { - ArgumentNullException.ThrowIfNull(originProvider, nameof(originProvider)); + ArgumentNullException.ThrowIfNull(originProvider); var rewriter = new OrderingRewriter(orderingDescriptorResolver); if (originProvider.Type == ProviderType.Select) { var selectProvider = (SelectProvider) originProvider; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ParameterRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ParameterRewriter.cs index 724bd3551..7ef7da9c9 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ParameterRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ParameterRewriter.cs @@ -20,7 +20,7 @@ internal sealed class ParameterRewriter : ExpressionVisitor public LambdaExpression Replace(LambdaExpression sourceExpression, ParameterExpression oldParameter, ParameterExpression newParameter) { - ArgumentNullException.ThrowIfNull(sourceExpression, nameof(sourceExpression)); + ArgumentNullException.ThrowIfNull(sourceExpression); this.oldParameter = oldParameter ?? throw new ArgumentNullException(nameof(oldParameter)); this.newParameter = newParameter ?? throw new ArgumentNullException(nameof(newParameter)); diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessGatherer.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessGatherer.cs index 38b45c4c4..43d2b5aab 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessGatherer.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessGatherer.cs @@ -64,8 +64,8 @@ public virtual List Gather(Expression expression) /// List containing all used columns (order and uniqueness are not guaranteed). public List Gather(Expression expression, ParameterExpression parameter) { - ArgumentNullException.ThrowIfNull(expression, "expression"); - ArgumentNullException.ThrowIfNull(parameter, "parameter"); + ArgumentNullException.ThrowIfNull(expression); + ArgumentNullException.ThrowIfNull(parameter); tupleParameter = parameter; var result = Gather(expression); tupleParameter = null; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessRewriter.cs index 31cb200ec..3f8f8dfe5 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/TupleAccessRewriter.cs @@ -68,8 +68,8 @@ public virtual Expression Rewrite(Expression expression) /// public virtual Expression Rewrite(Expression expression, ParameterExpression parameter) { - ArgumentNullException.ThrowIfNull(expression, "expression"); - ArgumentNullException.ThrowIfNull(parameter, "parameter"); + ArgumentNullException.ThrowIfNull(expression); + ArgumentNullException.ThrowIfNull(parameter); tupleParameter = parameter; return Visit(expression); } diff --git a/Orm/Xtensive.Orm/Orm/Services/DirectEntityAccessor.cs b/Orm/Xtensive.Orm/Orm/Services/DirectEntityAccessor.cs index dd1030be2..242e2becf 100644 --- a/Orm/Xtensive.Orm/Orm/Services/DirectEntityAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Services/DirectEntityAccessor.cs @@ -39,7 +39,7 @@ public bool UpdateVersionInfo(Entity targetEntity, FieldInfo changedField) /// The target entity. public EntityState GetEntityState(Entity target) { - ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(target); return target.State; } diff --git a/Orm/Xtensive.Orm/Orm/Services/DirectEntitySetAccessor.cs b/Orm/Xtensive.Orm/Orm/Services/DirectEntitySetAccessor.cs index 3534dfbb9..8993a155b 100644 --- a/Orm/Xtensive.Orm/Orm/Services/DirectEntitySetAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Services/DirectEntitySetAccessor.cs @@ -139,13 +139,13 @@ public void Clear(Entity target, FieldInfo field) private static void ValidateArguments(object target) { - ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(target); } private static void ValidateArguments(Persistent target, FieldInfo field) { ValidateArguments(target); - ArgumentNullException.ThrowIfNull(field, "field"); + ArgumentNullException.ThrowIfNull(field); if (!target.TypeInfo.Fields.Contains(field)) throw new InvalidOperationException(string.Format( Strings.ExTypeXDoesNotContainYField, target.TypeInfo.Name, field.Name)); @@ -157,13 +157,13 @@ private static void ValidateArguments(Persistent target, FieldInfo field) private static void ValidateArguments(EntitySetBase target, Entity item) { ValidateArguments(target); - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); } private static void ValidateArguments(Persistent target, FieldInfo field, Entity item) { ValidateArguments(target, field); - ArgumentNullException.ThrowIfNull(item, "item"); + ArgumentNullException.ThrowIfNull(item); } #endregion diff --git a/Orm/Xtensive.Orm/Orm/Services/DirectPersistentAccessor.cs b/Orm/Xtensive.Orm/Orm/Services/DirectPersistentAccessor.cs index 80a364de4..b696ec714 100644 --- a/Orm/Xtensive.Orm/Orm/Services/DirectPersistentAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Services/DirectPersistentAccessor.cs @@ -33,7 +33,7 @@ public class DirectPersistentAccessor : SessionBound, public Entity CreateEntity(Type entityType) { using (Session.OpenSystemLogicOnlyRegion()) { - ArgumentNullException.ThrowIfNull(entityType, "entityType"); + ArgumentNullException.ThrowIfNull(entityType); if (!WellKnownOrmTypes.Entity.IsAssignableFrom(entityType)) throw new InvalidOperationException( string.Format(Strings.TypeXIsNotAnYDescendant, entityType, WellKnownOrmTypes.Entity)); @@ -52,8 +52,8 @@ public Entity CreateEntity(Type entityType) public Entity CreateEntity(Type entityType, Tuple tuple) { using (Session.OpenSystemLogicOnlyRegion()) { - ArgumentNullException.ThrowIfNull(entityType, "entityType"); - ArgumentNullException.ThrowIfNull(tuple, "tuple"); + ArgumentNullException.ThrowIfNull(entityType); + ArgumentNullException.ThrowIfNull(tuple); if (!WellKnownOrmTypes.Entity.IsAssignableFrom(entityType)) throw new InvalidOperationException( string.Format(Strings.TypeXIsNotAnYDescendant, entityType, WellKnownOrmTypes.Entity)); @@ -73,7 +73,7 @@ public Entity CreateEntity(Key key) { using (Session.OpenSystemLogicOnlyRegion()) { - ArgumentNullException.ThrowIfNull(key, "key"); + ArgumentNullException.ThrowIfNull(key); if (key.TypeReference.Accuracy != TypeReferenceAccuracy.ExactType) throw new InvalidOperationException(string.Format(Strings.ExKeyXShouldHaveExactType, key)); var entityType = key.TypeReference.Type; @@ -102,7 +102,7 @@ public Structure CreateStructure(Type structureType) public Structure CreateStructure(Type structureType, Tuple structureData) { using (Session.OpenSystemLogicOnlyRegion()) { - ArgumentNullException.ThrowIfNull(structureType, "structureType"); + ArgumentNullException.ThrowIfNull(structureType); if (!WellKnownOrmTypes.Structure.IsAssignableFrom(structureType)) { throw new InvalidOperationException( string.Format(Strings.TypeXIsNotAnYDescendant, structureType, WellKnownOrmTypes.Structure)); @@ -233,7 +233,7 @@ public void SetFieldValue(Persistent target, FieldInfo field, T value) public void Remove(Entity target) { using (Session.OpenSystemLogicOnlyRegion()) { - ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(target); target.RemoveInternal(EntityRemoveReason.User); } } @@ -249,8 +249,8 @@ public void Remove(Entity target) /// The field of persistent type. protected static void ValidateArguments(Persistent target, FieldInfo field) { - ArgumentNullException.ThrowIfNull(target, "target"); - ArgumentNullException.ThrowIfNull(field, "field"); + ArgumentNullException.ThrowIfNull(target); + ArgumentNullException.ThrowIfNull(field); if (!target.TypeInfo.Fields.Contains(field)) throw new InvalidOperationException(string.Format( Strings.ExTypeXDoesNotContainYField, target.TypeInfo.Name, field.Name)); diff --git a/Orm/Xtensive.Orm/Orm/Services/Old/DirectStateAccessor.cs b/Orm/Xtensive.Orm/Orm/Services/Old/DirectStateAccessor.cs index 8fdacc0fa..ff41c82a1 100644 --- a/Orm/Xtensive.Orm/Orm/Services/Old/DirectStateAccessor.cs +++ b/Orm/Xtensive.Orm/Orm/Services/Old/DirectStateAccessor.cs @@ -19,7 +19,7 @@ public static class DirectStateAccessor /// public static SessionStateAccessor Get(Session source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); return new SessionStateAccessor(source); } @@ -28,7 +28,7 @@ public static SessionStateAccessor Get(Session source) /// public static PersistentStateAccessor Get(Persistent source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); return new PersistentStateAccessor(source); } @@ -37,7 +37,7 @@ public static PersistentStateAccessor Get(Persistent source) /// public static EntitySetStateAccessor Get(EntitySetBase source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); return new EntitySetStateAccessor(source); } } diff --git a/Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryBuilder.cs b/Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryBuilder.cs index 34b67e1b1..e07d65c9b 100644 --- a/Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryBuilder.cs @@ -35,7 +35,7 @@ public sealed class QueryBuilder : SessionBound, ISessionService /// Translated query. public QueryTranslationResult TranslateQuery(IQueryable query) { - ArgumentNullException.ThrowIfNull(query, "query"); + ArgumentNullException.ThrowIfNull(query); var configuration = Session.CompilationService.CreateConfiguration(Session); configuration.PrepareRequest = false; @@ -64,7 +64,7 @@ public QueryTranslationResult TranslateQuery(IQueryable query) /// Compiled query. public SqlCompilationResult CompileQuery(ISqlCompileUnit query) { - ArgumentNullException.ThrowIfNull(query, "query"); + ArgumentNullException.ThrowIfNull(query); return driver.Compile(query); } @@ -77,8 +77,8 @@ public SqlCompilationResult CompileQuery(ISqlCompileUnit query) /// Created binding. public QueryParameterBinding CreateParameterBinding(Type valueType, Func valueAccessor) { - ArgumentNullException.ThrowIfNull(valueType, "valueType"); - ArgumentNullException.ThrowIfNull(valueAccessor, "valueAccessor"); + ArgumentNullException.ThrowIfNull(valueType); + ArgumentNullException.ThrowIfNull(valueAccessor); var mapping = driver.GetTypeMapping(valueType); return new QueryParameterBinding( @@ -91,8 +91,8 @@ public QueryParameterBinding CreateParameterBinding(Type valueType, FuncBuilt request. public QueryRequest CreateRequest(SqlCompilationResult compiledQuery, IEnumerable bindings) { - ArgumentNullException.ThrowIfNull(compiledQuery, "compiledQuery"); - ArgumentNullException.ThrowIfNull(bindings, "bindings"); + ArgumentNullException.ThrowIfNull(compiledQuery); + ArgumentNullException.ThrowIfNull(bindings); return new QueryRequest(new UserQueryRequest( compiledQuery, @@ -107,7 +107,7 @@ public QueryRequest CreateRequest(SqlCompilationResult compiledQuery, IEnumerabl /// Created command. public QueryCommand CreateCommand(QueryRequest request) { - ArgumentNullException.ThrowIfNull(request, "request"); + ArgumentValidator.EnsureArgumentIsNotDefault(request, nameof(request)); var command = commandFactory.CreateCommand(); command.AddPart(commandFactory.CreateQueryPart(request.RealRequest, new ParameterContext())); diff --git a/Orm/Xtensive.Orm/Orm/Services/QueryFormatter.cs b/Orm/Xtensive.Orm/Orm/Services/QueryFormatter.cs index 373ebb83a..81103c72a 100644 --- a/Orm/Xtensive.Orm/Orm/Services/QueryFormatter.cs +++ b/Orm/Xtensive.Orm/Orm/Services/QueryFormatter.cs @@ -30,7 +30,7 @@ public sealed class QueryFormatter : SessionBound, ISessionService /// A string containing formatted query. public string ToSqlString(IQueryable query) { - ArgumentNullException.ThrowIfNull(query, "query"); + ArgumentNullException.ThrowIfNull(query); var part = GetCommandPart(query); return part!=null ? part.Statement : string.Empty; @@ -44,7 +44,7 @@ public string ToSqlString(IQueryable query) /// A string containing formatted query. public string ToString(IQueryable query) { - ArgumentNullException.ThrowIfNull(query, "query"); + ArgumentNullException.ThrowIfNull(query); return query.Expression.ToString(true); } @@ -57,7 +57,7 @@ public string ToString(IQueryable query) /// A . public DbCommand ToDbCommand(IQueryable query) { - ArgumentNullException.ThrowIfNull(query, "query"); + ArgumentNullException.ThrowIfNull(query); var part = GetCommandPart(query); if (part==null) diff --git a/Orm/Xtensive.Orm/Orm/Session.Persist.cs b/Orm/Xtensive.Orm/Orm/Session.Persist.cs index 2efec3e05..fd2fdb646 100644 --- a/Orm/Xtensive.Orm/Orm/Session.Persist.cs +++ b/Orm/Xtensive.Orm/Orm/Session.Persist.cs @@ -246,7 +246,7 @@ private async ValueTask Persist(PersistReason reason, bool isAsync, Cancellation public IDisposable DisableSaveChanges(IEntity target) { EnsureNotDisposed(); - ArgumentNullException.ThrowIfNull(target, "target"); + ArgumentNullException.ThrowIfNull(target); if (!Configuration.Supports(SessionOptions.AutoSaveChanges)) return null; // No need to pin in this case diff --git a/Orm/Xtensive.Orm/Orm/Session.Query.cs b/Orm/Xtensive.Orm/Orm/Session.Query.cs index 0c0002902..23565e798 100644 --- a/Orm/Xtensive.Orm/Orm/Session.Query.cs +++ b/Orm/Xtensive.Orm/Orm/Session.Query.cs @@ -35,7 +35,7 @@ partial class Session /// once is called. public IDisposable OverrideQueryRoot(IQueryRootBuilder queryRootBuilder) { - ArgumentNullException.ThrowIfNull(queryRootBuilder, "queryRootBuilder"); + ArgumentNullException.ThrowIfNull(queryRootBuilder); var oldQuery = Query; var newQuery = new QueryEndpoint(oldQuery, queryRootBuilder); Query = newQuery; diff --git a/Orm/Xtensive.Orm/Orm/StorageNode.cs b/Orm/Xtensive.Orm/Orm/StorageNode.cs index 8b775007b..604d7ae41 100644 --- a/Orm/Xtensive.Orm/Orm/StorageNode.cs +++ b/Orm/Xtensive.Orm/Orm/StorageNode.cs @@ -116,10 +116,10 @@ public Task OpenSessionAsync(SessionConfiguration configuration, Cancel internal StorageNode(Domain domain, NodeConfiguration configuration, ModelMapping mapping, TypeIdRegistry typeIdRegistry) { - ArgumentNullException.ThrowIfNull(domain, nameof(domain)); - ArgumentNullException.ThrowIfNull(configuration, nameof(configuration)); - ArgumentNullException.ThrowIfNull(mapping, nameof(mapping)); - ArgumentNullException.ThrowIfNull(typeIdRegistry, nameof(typeIdRegistry)); + ArgumentNullException.ThrowIfNull(domain); + ArgumentNullException.ThrowIfNull(configuration); + ArgumentNullException.ThrowIfNull(mapping); + ArgumentNullException.ThrowIfNull(typeIdRegistry); EntityLockProviderCache = new ConcurrentDictionary<(TypeInfo, LockMode, LockBehavior), ExecutableProvider>(); EntityFetchQueryCache = new ConcurrentDictionary(); diff --git a/Orm/Xtensive.Orm/Orm/Transaction.cs b/Orm/Xtensive.Orm/Orm/Transaction.cs index 2d29600ff..ccaa48f9a 100644 --- a/Orm/Xtensive.Orm/Orm/Transaction.cs +++ b/Orm/Xtensive.Orm/Orm/Transaction.cs @@ -63,8 +63,8 @@ public static Transaction Demand() /// is . public static void Require(Session session) { - ArgumentNullException.ThrowIfNull(session, nameof(session)); - session.DemandTransaction(); + ArgumentNullException.ThrowIfNull(session); + _ = session.DemandTransaction(); } #endregion @@ -155,7 +155,7 @@ public static void Require(Session session) /// public bool AreChangesVisibleTo(Transaction otherTransaction) { - ArgumentNullException.ThrowIfNull(otherTransaction, "otherTransaction"); + ArgumentNullException.ThrowIfNull(otherTransaction); if (Outermost != otherTransaction.Outermost) { return false; } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/ChangeFieldTypeHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/ChangeFieldTypeHint.cs index 6628ef562..70be9dbcc 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/ChangeFieldTypeHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/ChangeFieldTypeHint.cs @@ -74,7 +74,7 @@ public override int GetHashCode() /// Name of field that changes type. public ChangeFieldTypeHint(Type type, string fieldName) { - ArgumentNullException.ThrowIfNull(type, nameof(type)); + ArgumentNullException.ThrowIfNull(type); ArgumentValidator.EnsureArgumentNotNullOrEmpty(fieldName, nameof(fieldName)); Type = type; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/CopyFieldHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/CopyFieldHint.cs index 10d72cf82..9c0a71dfb 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/CopyFieldHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/CopyFieldHint.cs @@ -87,7 +87,7 @@ public CopyFieldHint(string sourceTypeName, string sourceFieldName, Type targetT { ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceTypeName, nameof(sourceTypeName)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceFieldName, nameof(sourceFieldName)); - ArgumentNullException.ThrowIfNull(targetType, nameof(targetType)); + ArgumentNullException.ThrowIfNull(targetType); ArgumentValidator.EnsureArgumentNotNullOrEmpty(targetFieldName, nameof(targetFieldName)); SourceType = sourceTypeName; SourceField = sourceFieldName; @@ -115,9 +115,9 @@ public CopyFieldHint(Type sourceType, string fieldName, Type targetType) /// The target field name. public CopyFieldHint(Type sourceType, string sourceFieldName, Type targetType, string targetFieldName) { - ArgumentNullException.ThrowIfNull(sourceType, nameof(sourceType)); + ArgumentNullException.ThrowIfNull(sourceType); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceFieldName, nameof(sourceFieldName)); - ArgumentNullException.ThrowIfNull(targetType, nameof(targetType)); + ArgumentNullException.ThrowIfNull(targetType); ArgumentValidator.EnsureArgumentNotNullOrEmpty(targetFieldName, nameof(targetFieldName)); SourceType = sourceType.FullName; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MoveFieldHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MoveFieldHint.cs index 2b10cb85b..96d975efc 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MoveFieldHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/MoveFieldHint.cs @@ -88,7 +88,7 @@ public MoveFieldHint(string sourceTypeName, string sourceFieldName, Type targetT { ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceTypeName, nameof(sourceTypeName)); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceFieldName, nameof(sourceFieldName)); - ArgumentNullException.ThrowIfNull(targetType, nameof(targetType)); + ArgumentNullException.ThrowIfNull(targetType); ArgumentValidator.EnsureArgumentNotNullOrEmpty(targetFieldName, nameof(targetFieldName)); SourceType = sourceTypeName; SourceField = sourceFieldName; @@ -116,9 +116,9 @@ public MoveFieldHint(Type sourceType, string fieldName, Type targetType) /// The target field name. public MoveFieldHint(Type sourceType, string sourceFieldName, Type targetType, string targetFieldName) { - ArgumentNullException.ThrowIfNull(sourceType, nameof(sourceType)); + ArgumentNullException.ThrowIfNull(sourceType); ArgumentValidator.EnsureArgumentNotNullOrEmpty(sourceFieldName, nameof(sourceFieldName)); - ArgumentNullException.ThrowIfNull(targetType, nameof(targetType)); + ArgumentNullException.ThrowIfNull(targetType); ArgumentValidator.EnsureArgumentNotNullOrEmpty(targetFieldName, nameof(targetFieldName)); SourceType = sourceType.FullName; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameFieldHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameFieldHint.cs index cb782a83d..4fc163b84 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameFieldHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameFieldHint.cs @@ -76,9 +76,9 @@ public override string ToString() => /// New name of the field. public RenameFieldHint(Type targetType, string oldFieldName, string newFieldName) { - ArgumentNullException.ThrowIfNull(targetType, "targetType"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(oldFieldName, "oldFieldName"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(newFieldName, "newFieldName"); + ArgumentNullException.ThrowIfNull(targetType); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(oldFieldName, nameof(oldFieldName)); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(newFieldName, nameof(newFieldName)); TargetType = targetType; OldFieldName = oldFieldName; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameTypeHint.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameTypeHint.cs index 3b40064a2..0f0ee9ab0 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameTypeHint.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Hints/RenameTypeHint.cs @@ -70,7 +70,7 @@ public override string ToString() => /// The new type. public RenameTypeHint(string oldType, Type newType) { - ArgumentNullException.ThrowIfNull(newType, nameof(newType)); + ArgumentNullException.ThrowIfNull(newType); ArgumentValidator.EnsureArgumentNotNullOrEmpty(oldType, nameof(oldType)); if (!oldType.Contains(".", StringComparison.Ordinal)) diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainExtractedModelBuilder.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainExtractedModelBuilder.cs index 626cf3631..0c2480715 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainExtractedModelBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainExtractedModelBuilder.cs @@ -274,8 +274,8 @@ private static ReferentialAction ConvertReferentialAction(Model.ReferentialActio internal DomainExtractedModelBuilder(UpgradeServiceAccessor services, StorageModel model, bool makeSharedFinally) { - ArgumentNullException.ThrowIfNull(services, "services"); - ArgumentNullException.ThrowIfNull(model, "model"); + ArgumentNullException.ThrowIfNull(services); + ArgumentNullException.ThrowIfNull(model); this.model = model; this.makeSharedFinally = makeSharedFinally; diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/ExtractedModelBuilderFactory.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/ExtractedModelBuilderFactory.cs index 70acbc138..2ead36f6c 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/ExtractedModelBuilderFactory.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/ExtractedModelBuilderFactory.cs @@ -13,7 +13,7 @@ internal static class ExtractedModelBuilderFactory { public static ISchemaExtractionResultBuilder GetBuilder(UpgradeContext context) { - ArgumentNullException.ThrowIfNull(context, "context"); + ArgumentNullException.ThrowIfNull(context); if (context.ParentDomain==null) { var makeShared = context.Configuration.ShareStorageSchemaOverNodes; return new DomainExtractedModelBuilder(context.Services, context.TargetStorageModel, makeShared); diff --git a/Orm/Xtensive.Orm/Orm/Validation/EntityErrorInfo.cs b/Orm/Xtensive.Orm/Orm/Validation/EntityErrorInfo.cs index bc4057ff0..16542fe6f 100644 --- a/Orm/Xtensive.Orm/Orm/Validation/EntityErrorInfo.cs +++ b/Orm/Xtensive.Orm/Orm/Validation/EntityErrorInfo.cs @@ -32,8 +32,8 @@ public sealed class EntityErrorInfo /// A collection of s for an errors discovered. public EntityErrorInfo(Entity target, IList errors) { - ArgumentNullException.ThrowIfNull(target, "target"); - ArgumentNullException.ThrowIfNull(errors, "errors"); + ArgumentNullException.ThrowIfNull(target); + ArgumentNullException.ThrowIfNull(errors); Target = target; Errors = errors; diff --git a/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlInsertValuesCollection.cs b/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlInsertValuesCollection.cs index d9f631dee..5881db742 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlInsertValuesCollection.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Collections/SqlInsertValuesCollection.cs @@ -45,7 +45,7 @@ public sealed class SqlInsertValuesCollection : IReadOnlyList /// -or- is empty. public void Add(Dictionary row) { - ArgumentNullException.ThrowIfNull(row, nameof(row)); + ArgumentNullException.ThrowIfNull(row); if (row.Count == 0) { throw new ArgumentException("Empty row is not allowed."); } diff --git a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCursor.cs b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCursor.cs index 876510823..d40f8da4b 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCursor.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlCursor.cs @@ -126,14 +126,14 @@ public SqlFetch Fetch(SqlFetchOption option, SqlExpression rowCount, params ISql { if (rowCount is not null) { if (option != SqlFetchOption.Absolute && option != SqlFetchOption.Relative) - throw new ArgumentException(Strings.ExInvalidUsageOfTheRowCountArgument, "rowCount"); + throw new ArgumentException(Strings.ExInvalidUsageOfTheRowCountArgument, nameof(rowCount)); SqlValidator.EnsureIsArithmeticExpression(rowCount); } else if (option == SqlFetchOption.Absolute || option == SqlFetchOption.Relative) - throw new ArgumentException(Strings.ExInvalidUsageOfTheOrientationArgument, "option"); + throw new ArgumentException(Strings.ExInvalidUsageOfTheOrientationArgument, nameof(option)); if (target != null) for (int i = 0, l = target.Length; i < l; i++) - ArgumentNullException.ThrowIfNull(target[i], "target"); + ArgumentNullException.ThrowIfNull(target[i], $"target[{i}]"); return new SqlFetch(option, rowCount, this, target); } diff --git a/Orm/Xtensive.Orm/Sql/SqlDml.cs b/Orm/Xtensive.Orm/Sql/SqlDml.cs index b029674cf..143afba85 100644 --- a/Orm/Xtensive.Orm/Sql/SqlDml.cs +++ b/Orm/Xtensive.Orm/Sql/SqlDml.cs @@ -107,7 +107,7 @@ public static SqlBinary Add(SqlExpression left, SqlExpression right) public static SqlBinary Subtract(SqlExpression left, SqlExpression right) { ArgumentNullException.ThrowIfNull(left); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.Subtract, left, right); @@ -115,8 +115,8 @@ public static SqlBinary Subtract(SqlExpression left, SqlExpression right) public static SqlBinary Multiply(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.Multiply, left, right); @@ -124,8 +124,8 @@ public static SqlBinary Multiply(SqlExpression left, SqlExpression right) public static SqlBinary Divide(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.Divide, left, right); @@ -133,8 +133,8 @@ public static SqlBinary Divide(SqlExpression left, SqlExpression right) public static SqlBinary Modulo(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.Modulo, left, right); @@ -266,8 +266,8 @@ public static SqlArray Array(params TimeSpan[] value) public static SqlBinary BitAnd(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.BitAnd, left, right); @@ -275,8 +275,8 @@ public static SqlBinary BitAnd(SqlExpression left, SqlExpression right) public static SqlBinary BitOr(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.BitOr, left, right); @@ -284,8 +284,8 @@ public static SqlBinary BitOr(SqlExpression left, SqlExpression right) public static SqlBinary BitXor(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); return Binary(SqlNodeType.BitXor, left, right); @@ -293,8 +293,8 @@ public static SqlBinary BitXor(SqlExpression left, SqlExpression right) public static SqlBinary And(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsBooleanExpression(left); SqlValidator.EnsureIsBooleanExpression(right); return Binary(SqlNodeType.And, left, right); @@ -302,8 +302,8 @@ public static SqlBinary And(SqlExpression left, SqlExpression right) public static SqlBinary Or(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsBooleanExpression(left); SqlValidator.EnsureIsBooleanExpression(right); return Binary(SqlNodeType.Or, left, right); @@ -321,8 +321,8 @@ public static SqlQueryExpression ExceptAll(ISqlQueryExpression left, ISqlQueryEx private static SqlQueryExpression Except(ISqlQueryExpression left, ISqlQueryExpression right, bool all) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlQueryExpression(SqlNodeType.Except, left, right, all); } @@ -338,8 +338,8 @@ public static SqlQueryExpression IntersectAll(ISqlQueryExpression left, ISqlQuer private static SqlQueryExpression Intersect(ISqlQueryExpression left, ISqlQueryExpression right, bool all) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlQueryExpression(SqlNodeType.Intersect, left, right, all); } @@ -355,50 +355,50 @@ public static SqlQueryExpression UnionAll(ISqlQueryExpression left, ISqlQueryExp private static SqlQueryExpression Union(ISqlQueryExpression left, ISqlQueryExpression right, bool all) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlQueryExpression(SqlNodeType.Union, left, right, all); } public static SqlBinary In(SqlExpression left, ISqlQueryExpression right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.In, left, SubQuery(right)); } public static SqlBinary In(SqlExpression left, SqlRow right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.In, left, right); } public static SqlBinary In(SqlExpression left, SqlArray right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.In, left, right); } public static SqlBinary NotIn(SqlExpression left, ISqlQueryExpression right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.NotIn, left, SubQuery(right)); } public static SqlBinary NotIn(SqlExpression left, SqlRow right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.NotIn, left, right); } public static SqlBinary NotIn(SqlExpression left, SqlArray right) { SqlValidator.EnsureIsRowValueConstructor(left); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.NotIn, left, right); } @@ -435,32 +435,32 @@ internal static SqlBinary Binary(SqlNodeType nodeType, SqlExpression left, SqlEx public static SqlCast Cast(SqlExpression operand, SqlValueType type) { - ArgumentNullException.ThrowIfNull(operand, "operand"); - ArgumentNullException.ThrowIfNull(type, "type"); + ArgumentNullException.ThrowIfNull(operand); + ArgumentNullException.ThrowIfNull(type); return new SqlCast(operand, type); } public static SqlCast Cast(SqlExpression operand, SqlType type) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCast(operand, new SqlValueType(type)); } public static SqlCast Cast(SqlExpression operand, SqlType type, int size) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCast(operand, new SqlValueType(type, size)); } public static SqlCast Cast(SqlExpression operand, SqlType type, short precision, short scale) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCast(operand, new SqlValueType(type, precision, scale)); } public static SqlCast Cast(SqlExpression operand, SqlType type, short precision) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlCast(operand, new SqlValueType(type, precision, 0)); } @@ -470,43 +470,43 @@ public static SqlCast Cast(SqlExpression operand, SqlType type, short precision) public static SqlBinary Equals(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.Equals, left, right); } public static SqlBinary NotEquals(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.NotEquals, left, right); } public static SqlBinary GreaterThan(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.GreaterThan, left, right); } public static SqlBinary LessThan(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.LessThan, left, right); } public static SqlBinary GreaterThanOrEquals(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.GreaterThanOrEquals, left, right); } public static SqlBinary LessThanOrEquals(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return Binary(SqlNodeType.LessThanOrEquals, left, right); } @@ -555,7 +555,7 @@ public static SqlFunctionCall CurrentTimeStamp(SqlExpression precision) public static SqlExtract Extract(SqlDateTimePart part, SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsArithmeticExpression(operand); if (part == SqlDateTimePart.Nothing) { throw new ArgumentException(string.Format("Unable to extract {0} part", SqlDateTimePart.Nothing.ToString())); @@ -565,7 +565,7 @@ public static SqlExtract Extract(SqlDateTimePart part, SqlExpression operand) public static SqlExtract Extract(SqlDatePart part, SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, nameof(operand)); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsArithmeticExpression(operand); if (part == SqlDatePart.Nothing) { throw new ArgumentException(string.Format("Unable to extract {0} part", SqlDatePart.Nothing.ToString())); @@ -575,7 +575,7 @@ public static SqlExtract Extract(SqlDatePart part, SqlExpression operand) public static SqlExtract Extract(SqlTimePart part, SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, nameof(operand)); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsArithmeticExpression(operand); if (part == SqlTimePart.Nothing) { throw new ArgumentException(string.Format("Unable to extract {0} part", SqlTimePart.Nothing.ToString())); @@ -585,7 +585,7 @@ public static SqlExtract Extract(SqlTimePart part, SqlExpression operand) public static SqlExtract Extract(SqlIntervalPart part, SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsArithmeticExpression(operand); if (part == SqlIntervalPart.Nothing) { throw new ArgumentException(string.Format("Unable to extract {0} part", SqlIntervalPart.Nothing.ToString())); @@ -595,9 +595,9 @@ public static SqlExtract Extract(SqlIntervalPart part, SqlExpression operand) public static SqlFunctionCall DateTimeConstruct(SqlExpression year, SqlExpression month, SqlExpression day) { - ArgumentNullException.ThrowIfNull(year, "year"); - ArgumentNullException.ThrowIfNull(month, "month"); - ArgumentNullException.ThrowIfNull(day, "day"); + ArgumentNullException.ThrowIfNull(year); + ArgumentNullException.ThrowIfNull(month); + ArgumentNullException.ThrowIfNull(day); SqlValidator.EnsureIsArithmeticExpression(year); SqlValidator.EnsureIsArithmeticExpression(month); SqlValidator.EnsureIsArithmeticExpression(day); @@ -642,70 +642,70 @@ public static SqlFunctionCall TimeConstruct(SqlExpression ticks) public static SqlBinary DateTimePlusInterval(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.DateTimePlusInterval, left, right); } public static SqlBinary TimePlusInterval(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, nameof(left)); - ArgumentNullException.ThrowIfNull(right, nameof(right)); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.TimePlusInterval, left, right); } public static SqlBinary TimeMinusTime(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, nameof(left)); - ArgumentNullException.ThrowIfNull(right, nameof(right)); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.TimeMinusTime, left, right); } public static SqlBinary DateTimeMinusInterval(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.DateTimeMinusInterval, left, right); } public static SqlBinary DateTimeMinusDateTime(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.DateTimeMinusDateTime, left, right); } public static SqlFunctionCall DateTimeAddYears(SqlExpression source, SqlExpression years) { - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(years, "years"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(years); return new SqlFunctionCall(SqlFunctionType.DateTimeAddYears, source, years); } public static SqlFunctionCall DateTimeAddMonths(SqlExpression source, SqlExpression months) { - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(months, "months"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(months); return new SqlFunctionCall(SqlFunctionType.DateTimeAddMonths, source, months); } public static SqlFunctionCall DateTimeToTime(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression); return new SqlFunctionCall(SqlFunctionType.DateTimeToTime, expression); } public static SqlFunctionCall DateAddYears(SqlExpression source, SqlExpression years) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(years, nameof(years)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(years); return new SqlFunctionCall(SqlFunctionType.DateAddYears, source, years); } public static SqlFunctionCall DateAddMonths(SqlExpression source, SqlExpression months) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(months, nameof(months)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(months); return new SqlFunctionCall(SqlFunctionType.DateAddMonths, source, months); } @@ -718,105 +718,105 @@ public static SqlFunctionCall DateAddDays(SqlExpression source, SqlExpression da public static SqlFunctionCall DateToString(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression); return new SqlFunctionCall(SqlFunctionType.DateToString, expression); } public static SqlFunctionCall DateToDateTime(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression); return new SqlFunctionCall(SqlFunctionType.DateToDateTime, expression); } public static SqlFunctionCall DateTimeToDate(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression); return new SqlFunctionCall(SqlFunctionType.DateTimeToDate, expression); } public static SqlFunctionCall DateToDateTimeOffset(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression); return new SqlFunctionCall(SqlFunctionType.DateToDateTimeOffset, expression); } public static SqlFunctionCall TimeAddHours(SqlExpression source, SqlExpression hours) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(hours, nameof(hours)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(hours); return new SqlFunctionCall(SqlFunctionType.TimeAddHours, source, hours); } public static SqlFunctionCall TimeAddMinutes(SqlExpression source, SqlExpression minutes) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); - ArgumentNullException.ThrowIfNull(minutes, nameof(minutes)); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(minutes); return new SqlFunctionCall(SqlFunctionType.TimeAddMinutes, source, minutes); } public static SqlFunctionCall TimeToString(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression); return new SqlFunctionCall(SqlFunctionType.TimeToString, expression); } public static SqlFunctionCall TimeToDateTime(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression); return new SqlFunctionCall(SqlFunctionType.TimeToDateTime, expression); } public static SqlExpression TimeToNanoseconds(SqlExpression source) { - ArgumentNullException.ThrowIfNull(source, nameof(source)); + ArgumentNullException.ThrowIfNull(source); return new SqlFunctionCall(SqlFunctionType.TimeToNanoseconds, source); } public static SqlFunctionCall TimeToDateTimeOffset(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression); return new SqlFunctionCall(SqlFunctionType.TimeToDateTimeOffset, expression); } public static SqlFunctionCall DateTimeToStringIso(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); return new SqlFunctionCall(SqlFunctionType.DateTimeToStringIso, expression); } public static SqlFunctionCall DateTimeTruncate(SqlExpression source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); return new SqlFunctionCall(SqlFunctionType.DateTimeTruncate, source); } public static SqlFunctionCall IntervalConstruct(SqlExpression nanoseconds) { - ArgumentNullException.ThrowIfNull(nanoseconds, "nanoseconds"); + ArgumentNullException.ThrowIfNull(nanoseconds); return new SqlFunctionCall(SqlFunctionType.IntervalConstruct, nanoseconds); } public static SqlFunctionCall IntervalToMilliseconds(SqlExpression source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); return new SqlFunctionCall(SqlFunctionType.IntervalToMilliseconds, source); } public static SqlFunctionCall IntervalToNanoseconds(SqlExpression source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); return new SqlFunctionCall(SqlFunctionType.IntervalToNanoseconds, source); } public static SqlFunctionCall IntervalAbs(SqlExpression source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); return new SqlFunctionCall(SqlFunctionType.IntervalAbs, source); } public static SqlFunctionCall IntervalNegate(SqlExpression source) { - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(source); return new SqlFunctionCall(SqlFunctionType.IntervalNegate, source); } @@ -831,7 +831,7 @@ public static SqlFunctionCall CurrentDateTimeOffset() public static SqlExtract Extract(SqlDateTimeOffsetPart part, SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsArithmeticExpression(operand); if (part==SqlDateTimeOffsetPart.Nothing) throw new ArgumentException(); @@ -840,87 +840,87 @@ public static SqlExtract Extract(SqlDateTimeOffsetPart part, SqlExpression opera public static SqlFunctionCall DateTimeOffsetConstruct(SqlExpression dateTime, SqlExpression offset) { - ArgumentNullException.ThrowIfNull(dateTime, "dateTime"); - ArgumentNullException.ThrowIfNull(offset, "offset"); + ArgumentNullException.ThrowIfNull(dateTime); + ArgumentNullException.ThrowIfNull(offset); SqlValidator.EnsureIsArithmeticExpression(offset); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetConstruct, dateTime, offset); } public static SqlBinary DateTimeOffsetPlusInterval(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.DateTimeOffsetPlusInterval, left, right); } public static SqlBinary DateTimeOffsetMinusInterval(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.DateTimeOffsetMinusInterval, left, right); } public static SqlBinary DateTimeOffsetMinusDateTimeOffset(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.DateTimeOffsetMinusDateTimeOffset, left, right); } public static SqlFunctionCall DateTimeOffsetAddYears(SqlExpression source, SqlExpression years) { - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(years, "years"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(years); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetAddYears, source, years); } public static SqlFunctionCall DateTimeOffsetAddMonths(SqlExpression source, SqlExpression months) { - ArgumentNullException.ThrowIfNull(source, "source"); - ArgumentNullException.ThrowIfNull(months, "months"); + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(months); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetAddMonths, source, months); } public static SqlFunctionCall DateTimeOffsetTimeOfDay(SqlExpression dateTimeOffset) { - ArgumentNullException.ThrowIfNull(dateTimeOffset, "dateTimeOffset"); + ArgumentNullException.ThrowIfNull(dateTimeOffset); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetTimeOfDay, dateTimeOffset); } public static SqlFunctionCall DateTimeOffsetToLocalTime(SqlExpression dateTimeOffset) { - ArgumentNullException.ThrowIfNull(dateTimeOffset, "dateTimeOffset"); + ArgumentNullException.ThrowIfNull(dateTimeOffset); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToLocalTime, dateTimeOffset); } public static SqlFunctionCall DateTimeOffsetToUtcTime(SqlExpression dateTimeOffset) { - ArgumentNullException.ThrowIfNull(dateTimeOffset, "dateTimeOffset"); + ArgumentNullException.ThrowIfNull(dateTimeOffset); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToUtcTime, dateTimeOffset); } public static SqlFunctionCall DateTimeToDateTimeOffset(SqlExpression dateTime) { - ArgumentNullException.ThrowIfNull(dateTime, "dateTime"); + ArgumentNullException.ThrowIfNull(dateTime); return new SqlFunctionCall(SqlFunctionType.DateTimeToDateTimeOffset, dateTime); } public static SqlFunctionCall DateTimeOffsetToDateTime(SqlExpression dateTimeOffset) { - ArgumentNullException.ThrowIfNull(dateTimeOffset, nameof(dateTimeOffset)); + ArgumentNullException.ThrowIfNull(dateTimeOffset); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToDateTime, dateTimeOffset); } public static SqlFunctionCall DateTimeOffsetToTime(SqlExpression dateTimeOffset) { - ArgumentNullException.ThrowIfNull(dateTimeOffset, nameof(dateTimeOffset)); + ArgumentNullException.ThrowIfNull(dateTimeOffset); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToTime, dateTimeOffset); } public static SqlFunctionCall DateTimeOffsetToDate(SqlExpression dateTimeOffset) { - ArgumentNullException.ThrowIfNull(dateTimeOffset, nameof(dateTimeOffset)); - ArgumentNullException.ThrowIfNull(dateTimeOffset, nameof(dateTimeOffset)); + ArgumentNullException.ThrowIfNull(dateTimeOffset); + ArgumentNullException.ThrowIfNull(dateTimeOffset); return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToDate, dateTimeOffset); } @@ -965,8 +965,8 @@ public static SqlFunctionCall User() public static SqlFunctionCall NullIf(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); //SqlCase c = new SqlCase(null); @@ -978,8 +978,8 @@ public static SqlFunctionCall NullIf(SqlExpression left, SqlExpression right) public static SqlFunctionCall Coalesce(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(left); SqlValidator.EnsureIsArithmeticExpression(right); //SqlCase c = new SqlCase(null); @@ -992,25 +992,8 @@ public static SqlFunctionCall Coalesce(SqlExpression left, SqlExpression right) public static SqlFunctionCall Coalesce( SqlExpression left, SqlExpression right, params SqlExpression[] values) { - //if (values!=null && values.Length>0) { - // SqlExpression[] v = null; - // if (values.Length>1) { - // v = new SqlExpression[values.Length-1]; - // for (int i = 1, l = values.Length; i leftColumns, IReadOnlyList rightColumns, SqlExpression expression) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); if (expression is not null && (joinType == SqlJoinType.CrossApply || joinType == SqlJoinType.LeftOuterApply)) - throw new ArgumentException(Strings.ExJoinExpressionShouldBeNullForCrossApplyAndOuterApply, "expression"); + throw new ArgumentException(Strings.ExJoinExpressionShouldBeNullForCrossApplyAndOuterApply, nameof(expression)); return new SqlJoinedTable(new SqlJoinExpression(joinType, left, right, expression), leftColumns, rightColumns); } public static SqlJoinedTable Join(SqlTable left, SqlTable right, params SqlColumn[] columns) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlJoinedTable(new SqlJoinExpression(SqlJoinType.UsingJoin, left, right, Row(columns))); } @@ -1200,8 +1183,8 @@ public static SqlExpression LiteralOrContainer(object value) public static SqlMatch Match(SqlRow value, ISqlQueryExpression query, bool unique, SqlMatchType matchType) { - ArgumentNullException.ThrowIfNull(value, "value"); - ArgumentNullException.ThrowIfNull(query, "query"); + ArgumentNullException.ThrowIfNull(value); + ArgumentNullException.ThrowIfNull(query); return new SqlMatch(value, SubQuery(query), unique, matchType); } @@ -1222,8 +1205,8 @@ public static SqlMatch Match(SqlRow value, ISqlQueryExpression query) public static SqlMatch Match(ISqlQueryExpression value, ISqlQueryExpression query, bool unique, SqlMatchType matchType) { - ArgumentNullException.ThrowIfNull(value, "value"); - ArgumentNullException.ThrowIfNull(query, "query"); + ArgumentNullException.ThrowIfNull(value); + ArgumentNullException.ThrowIfNull(query); return new SqlMatch(SubQuery(value), SubQuery(query), unique, matchType); } @@ -1248,36 +1231,36 @@ public static SqlMatch Match(ISqlQueryExpression value, ISqlQueryExpression quer public static SqlFunctionCall Abs(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Abs, argument); } public static SqlFunctionCall Acos(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Acos, argument); } public static SqlFunctionCall Asin(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Asin, argument); } public static SqlFunctionCall Atan(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Atan, argument); } public static SqlFunctionCall Atan2(SqlExpression argument1, SqlExpression argument2) { - ArgumentNullException.ThrowIfNull(argument1, "argument1"); - ArgumentNullException.ThrowIfNull(argument2, "argument2"); + ArgumentNullException.ThrowIfNull(argument1); + ArgumentNullException.ThrowIfNull(argument2); SqlValidator.EnsureIsArithmeticExpression(argument1); SqlValidator.EnsureIsArithmeticExpression(argument2); return new SqlFunctionCall(SqlFunctionType.Atan2, argument1, argument2); @@ -1285,56 +1268,56 @@ public static SqlFunctionCall Atan2(SqlExpression argument1, SqlExpression argum public static SqlFunctionCall Ceiling(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Ceiling, argument); } public static SqlFunctionCall Cos(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Cos, argument); } public static SqlFunctionCall Cot(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Cot, argument); } public static SqlFunctionCall Degrees(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Degrees, argument); } public static SqlFunctionCall Exp(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Exp, argument); } public static SqlFunctionCall Floor(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Floor, argument); } public static SqlFunctionCall Log(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Log, argument); } public static SqlFunctionCall Log10(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Log10, argument); } @@ -1346,16 +1329,16 @@ public static SqlFunctionCall Pi() public static SqlFunctionCall Power(SqlExpression argument, SqlExpression power) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); - ArgumentNullException.ThrowIfNull(power, "power"); + ArgumentNullException.ThrowIfNull(power); SqlValidator.EnsureIsArithmeticExpression(power); return new SqlFunctionCall(SqlFunctionType.Power, argument, power); } public static SqlFunctionCall Radians(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Radians, argument); } @@ -1377,66 +1360,66 @@ public static SqlFunctionCall Rand() public static SqlFunctionCall Round(SqlExpression argument, SqlExpression length) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); - ArgumentNullException.ThrowIfNull(length, "length"); + ArgumentNullException.ThrowIfNull(length); SqlValidator.EnsureIsArithmeticExpression(length); return new SqlFunctionCall(SqlFunctionType.Round, argument, length); } public static SqlFunctionCall Round(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Round, argument); } public static SqlRound Round(SqlExpression argument, SqlExpression length, TypeCode type, MidpointRounding mode) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); if (type!=TypeCode.Decimal && type!=TypeCode.Double) - throw new ArgumentOutOfRangeException("type"); + throw new ArgumentOutOfRangeException(nameof(type)); return new SqlRound(argument, length, type, mode); } public static SqlFunctionCall Truncate(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Truncate, argument); } public static SqlFunctionCall Sign(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Sign, argument); } public static SqlFunctionCall Sin(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Sin, argument); } public static SqlFunctionCall Sqrt(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Sqrt, argument); } public static SqlFunctionCall Square(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Square, argument); } public static SqlFunctionCall Tan(SqlExpression argument) { - ArgumentNullException.ThrowIfNull(argument, "argument"); + ArgumentNullException.ThrowIfNull(argument); SqlValidator.EnsureIsArithmeticExpression(argument); return new SqlFunctionCall(SqlFunctionType.Tan, argument); } @@ -1447,19 +1430,19 @@ public static SqlFunctionCall Tan(SqlExpression argument) public static SqlNative Native(string value) { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(value, "value"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(value, nameof(value)); return new SqlNative(value); } public static SqlMetadata Metadata(SqlExpression expression, object value) { - ArgumentNullException.ThrowIfNull(expression, nameof(expression)); + ArgumentNullException.ThrowIfNull(expression); return new SqlMetadata(expression, value); } public static SqlSubQuery SubQuery(ISqlQueryExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlSubQuery(operand); } @@ -1470,19 +1453,19 @@ public static SqlCursor Cursor(string name) public static SqlCursor Cursor(string name, ISqlQueryExpression query) { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, nameof(name)); return new SqlCursor(name, query); } public static SqlParameterRef ParameterRef(object parameter) { - ArgumentNullException.ThrowIfNull(parameter, "parameter"); + ArgumentNullException.ThrowIfNull(parameter); return new SqlParameterRef(parameter); } public static SqlParameterRef ParameterRef(string name) { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, nameof(name)); return new SqlParameterRef(name); } @@ -1498,13 +1481,13 @@ public static SqlCase Case() public static SqlNextValue NextValue(Sequence sequence) { - ArgumentNullException.ThrowIfNull(sequence, "sequence"); + ArgumentNullException.ThrowIfNull(sequence); return new SqlNextValue(sequence); } public static SqlNextValue NextValue(Sequence sequence, int increment) { - ArgumentNullException.ThrowIfNull(sequence, "sequence"); + ArgumentNullException.ThrowIfNull(sequence); return new SqlNextValue(sequence, increment); } @@ -1515,21 +1498,21 @@ public static SqlStatementBlock StatementBlock() public static SqlVariant Variant(object id, SqlExpression main, SqlExpression alternative) { - ArgumentNullException.ThrowIfNull(id, "id"); - ArgumentNullException.ThrowIfNull(main, "main"); - ArgumentNullException.ThrowIfNull(alternative, "alternative"); + ArgumentNullException.ThrowIfNull(id); + ArgumentNullException.ThrowIfNull(main); + ArgumentNullException.ThrowIfNull(alternative); return new SqlVariant(id, main, alternative); } public static SqlPlaceholder Placeholder(object id) { - ArgumentNullException.ThrowIfNull(id, "id"); + ArgumentNullException.ThrowIfNull(id); return new SqlPlaceholder(id); } public static SqlDynamicFilter DynamicFilter(object id) { - ArgumentNullException.ThrowIfNull(id, "id"); + ArgumentNullException.ThrowIfNull(id); return new SqlDynamicFilter(id); } @@ -1559,7 +1542,7 @@ public static SqlOrder Order(SqlExpression expression) public static SqlOrder Order(SqlExpression expression, bool ascending) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); return new SqlOrder(expression, ascending); } @@ -1604,13 +1587,13 @@ public static SqlRow Row() public static SqlFragment Fragment(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); return new SqlFragment(expression); } public static SqlWhile While(SqlExpression condition) { - ArgumentNullException.ThrowIfNull(condition, "condition"); + ArgumentNullException.ThrowIfNull(condition); SqlValidator.EnsureIsBooleanExpression(condition); return new SqlWhile(condition); } @@ -1622,25 +1605,25 @@ public static SqlBatch Batch() public static SqlAssignment Assign(SqlVariable left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(right); return new SqlAssignment(left, right); } public static SqlAssignment Assign(SqlParameterRef left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsArithmeticExpression(right); return new SqlAssignment(left, right); } public static SqlIf If(SqlExpression condition, SqlStatement ifTrue, SqlStatement ifFalse) { - ArgumentNullException.ThrowIfNull(condition, "condition"); + ArgumentNullException.ThrowIfNull(condition); SqlValidator.EnsureIsBooleanExpression(condition); - ArgumentNullException.ThrowIfNull(ifTrue, "ifTrue"); + ArgumentNullException.ThrowIfNull(ifTrue); return new SqlIf(condition, ifTrue, ifFalse); } @@ -1656,7 +1639,7 @@ public static SqlDelete Delete() public static SqlDelete Delete(SqlTableRef table) { - ArgumentNullException.ThrowIfNull(table, "table"); + ArgumentNullException.ThrowIfNull(table); return new SqlDelete(table); } @@ -1667,7 +1650,7 @@ public static SqlUpdate Update() public static SqlUpdate Update(SqlTableRef tableRef) { - ArgumentNullException.ThrowIfNull(tableRef, "table"); + ArgumentNullException.ThrowIfNull(tableRef); return new SqlUpdate(tableRef); } @@ -1678,7 +1661,7 @@ public static SqlInsert Insert() public static SqlInsert Insert(SqlTableRef tableRef) { - ArgumentNullException.ThrowIfNull(tableRef, "table"); + ArgumentNullException.ThrowIfNull(tableRef); return new SqlInsert(tableRef); } @@ -1689,7 +1672,7 @@ public static SqlSelect Select() public static SqlSelect Select(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); var result = new SqlSelect(); result.Columns.Add(expression); return result; @@ -1697,7 +1680,7 @@ public static SqlSelect Select(SqlExpression expression) public static SqlSelect Select(SqlTable table) { - ArgumentNullException.ThrowIfNull(table, "table"); + ArgumentNullException.ThrowIfNull(table); return new SqlSelect(table); } @@ -1712,7 +1695,7 @@ public static SqlConcat Concat(SqlExpression left, SqlExpression right) public static SqlConcat Concat(params SqlExpression[] items) { - ArgumentNullException.ThrowIfNull(items, "items"); + ArgumentNullException.ThrowIfNull(items); foreach (var item in items) SqlValidator.EnsureIsCharacterExpression(item); return new SqlConcat(items); @@ -1726,8 +1709,8 @@ public static SqlConcat Concat(params SqlExpression[] items) /// New expression. public static SqlBinary RawConcat(SqlExpression left, SqlExpression right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); SqlValidator.EnsureIsCharacterExpression(left); SqlValidator.EnsureIsCharacterExpression(right); return new SqlBinary(SqlNodeType.RawConcat, left, right); @@ -1740,10 +1723,10 @@ public static SqlFunctionCall Substring(SqlExpression operand, int start) public static SqlFunctionCall Substring(SqlExpression operand, int start, int? length) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsCharacterExpression(operand); if (length<0) - throw new ArgumentException(Strings.ExLengthShouldBeNotNegativeValue, "length"); + throw new ArgumentException(Strings.ExLengthShouldBeNotNegativeValue, nameof(length)); var arguments = new List(3); arguments.Add(operand); arguments.Add(new SqlLiteral(start)); @@ -1755,8 +1738,8 @@ public static SqlFunctionCall Substring(SqlExpression operand, int start, int? l public static SqlFunctionCall Substring( SqlExpression operand, SqlExpression start, SqlExpression length = null) { - ArgumentNullException.ThrowIfNull(operand, "operand"); - ArgumentNullException.ThrowIfNull(start, "start"); + ArgumentNullException.ThrowIfNull(operand); + ArgumentNullException.ThrowIfNull(start); SqlValidator.EnsureIsCharacterExpression(operand); SqlValidator.EnsureIsArithmeticExpression(start); if (length != null) { @@ -1768,29 +1751,29 @@ public static SqlFunctionCall Substring( public static SqlFunctionCall Upper(SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsCharacterExpression(operand); return new SqlFunctionCall(SqlFunctionType.Upper, operand); } public static SqlFunctionCall Lower(SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsCharacterExpression(operand); return new SqlFunctionCall(SqlFunctionType.Lower, operand); } public static SqlTrim Trim(SqlExpression operand, SqlTrimType trimType, string trimCharacters) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsCharacterExpression(operand); - ArgumentNullException.ThrowIfNull(trimCharacters, "trimCharacters"); + ArgumentNullException.ThrowIfNull(trimCharacters); return new SqlTrim(operand, trimCharacters, trimType); } public static SqlTrim Trim(SqlExpression operand, SqlTrimType trimType) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsCharacterExpression(operand); return new SqlTrim(operand, null, trimType); } @@ -1803,8 +1786,8 @@ public static SqlTrim Trim(SqlExpression operand) public static SqlLike Like( SqlExpression expression, SqlExpression pattern, SqlExpression escape) { - ArgumentNullException.ThrowIfNull(expression, "expression"); - ArgumentNullException.ThrowIfNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(expression); + ArgumentNullException.ThrowIfNull(pattern); SqlValidator.EnsureIsCharacterExpression(expression); SqlValidator.EnsureIsCharacterExpression(pattern); SqlValidator.EnsureIsCharacterExpression(escape); @@ -1818,22 +1801,22 @@ public static SqlLike Like(SqlExpression expression, SqlExpression pattern) public static SqlLike Like(SqlExpression expression, string pattern) { - ArgumentNullException.ThrowIfNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(pattern); return Like(expression, new SqlLiteral(pattern), null); } public static SqlLike Like(SqlExpression expression, string pattern, char escape) { SqlValidator.EnsureIsCharacterExpression(expression); - ArgumentNullException.ThrowIfNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(pattern); return Like(expression, new SqlLiteral(pattern), new SqlLiteral(escape)); } public static SqlLike NotLike( SqlExpression expression, SqlExpression pattern, SqlExpression escape) { - ArgumentNullException.ThrowIfNull(expression, "expression"); - ArgumentNullException.ThrowIfNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(expression); + ArgumentNullException.ThrowIfNull(pattern); SqlValidator.EnsureIsCharacterExpression(expression); SqlValidator.EnsureIsCharacterExpression(pattern); SqlValidator.EnsureIsCharacterExpression(escape); @@ -1847,14 +1830,14 @@ public static SqlLike NotLike(SqlExpression expression, SqlExpression pattern) public static SqlLike NotLike(SqlExpression expression, string pattern) { - ArgumentNullException.ThrowIfNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(pattern); return NotLike(expression, new SqlLiteral(pattern), null); } public static SqlLike NotLike(SqlExpression expression, string pattern, char escape) { SqlValidator.EnsureIsCharacterExpression(expression); - ArgumentNullException.ThrowIfNull(pattern, "pattern"); + ArgumentNullException.ThrowIfNull(pattern); return NotLike(expression, new SqlLiteral(pattern), new SqlLiteral(escape)); } @@ -1870,59 +1853,59 @@ public static SqlBinary Overlaps(DateTime from1, DateTime to1, DateTime from2, D public static SqlBinary Overlaps(SqlExpression from1, SqlExpression toOrSpan1, SqlExpression from2, SqlExpression toOrSpan2) { - ArgumentNullException.ThrowIfNull(from1, "from1"); - ArgumentNullException.ThrowIfNull(toOrSpan1, "toOrSpan1"); - ArgumentNullException.ThrowIfNull(from2, "from2"); - ArgumentNullException.ThrowIfNull(toOrSpan2, "toOrSpan2"); + ArgumentNullException.ThrowIfNull(from1); + ArgumentNullException.ThrowIfNull(toOrSpan1); + ArgumentNullException.ThrowIfNull(from2); + ArgumentNullException.ThrowIfNull(toOrSpan2); return new SqlBinary(SqlNodeType.Overlaps, Row(from1, toOrSpan1), Row(from2, toOrSpan2)); } public static SqlBinary Overlaps(SqlRow left, SqlRow right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.Overlaps, left, right); } public static SqlBinary Overlaps(SqlSelect left, SqlRow right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.Overlaps, SubQuery(left), right); } public static SqlBinary Overlaps(SqlRow left, SqlSelect right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.Overlaps, left, SubQuery(right)); } public static SqlBinary Overlaps(SqlSelect left, SqlSelect right) { - ArgumentNullException.ThrowIfNull(left, "left"); - ArgumentNullException.ThrowIfNull(right, "right"); + ArgumentNullException.ThrowIfNull(left); + ArgumentNullException.ThrowIfNull(right); return new SqlBinary(SqlNodeType.Overlaps, left, right); } public static SqlFunctionCall BinaryLength(SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsCharacterExpression(operand); return new SqlFunctionCall(SqlFunctionType.BinaryLength, operand); } public static SqlFunctionCall CharLength(SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsCharacterExpression(operand); return new SqlFunctionCall(SqlFunctionType.CharLength, operand); } public static SqlFunctionCall Position(SqlExpression pattern, SqlExpression source) { - ArgumentNullException.ThrowIfNull(pattern, "pattern"); - ArgumentNullException.ThrowIfNull(source, "source"); + ArgumentNullException.ThrowIfNull(pattern); + ArgumentNullException.ThrowIfNull(source); SqlValidator.EnsureIsCharacterExpression(pattern); SqlValidator.EnsureIsCharacterExpression(source); return new SqlFunctionCall(SqlFunctionType.Position, pattern, source); @@ -1930,9 +1913,9 @@ public static SqlFunctionCall Position(SqlExpression pattern, SqlExpression sour public static SqlFunctionCall Replace(SqlExpression text, SqlExpression from, SqlExpression to) { - ArgumentNullException.ThrowIfNull(text, "text"); - ArgumentNullException.ThrowIfNull(from, "from"); - ArgumentNullException.ThrowIfNull(to, "to"); + ArgumentNullException.ThrowIfNull(text); + ArgumentNullException.ThrowIfNull(from); + ArgumentNullException.ThrowIfNull(to); SqlValidator.EnsureIsCharacterExpression(text); SqlValidator.EnsureIsCharacterExpression(from); SqlValidator.EnsureIsCharacterExpression(to); @@ -1941,40 +1924,40 @@ public static SqlFunctionCall Replace(SqlExpression text, SqlExpression from, Sq public static SqlCollate Collate(SqlExpression operand, Collation collation) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsCharacterExpression(operand); - ArgumentNullException.ThrowIfNull(collation, "collation"); + ArgumentNullException.ThrowIfNull(collation); return new SqlCollate(operand, collation); } public static SqlFunctionCall PadLeft(SqlExpression operand, SqlExpression length) { - ArgumentNullException.ThrowIfNull(operand, "operand"); - ArgumentNullException.ThrowIfNull(length, "length"); + ArgumentNullException.ThrowIfNull(operand); + ArgumentNullException.ThrowIfNull(length); return new SqlFunctionCall(SqlFunctionType.PadLeft, operand, length); } public static SqlFunctionCall PadLeft(SqlExpression operand, SqlExpression length, SqlExpression padChar) { - ArgumentNullException.ThrowIfNull(operand, "operand"); - ArgumentNullException.ThrowIfNull(length, "length"); - ArgumentNullException.ThrowIfNull(padChar, "padChar"); + ArgumentNullException.ThrowIfNull(operand); + ArgumentNullException.ThrowIfNull(length); + ArgumentNullException.ThrowIfNull(padChar); return new SqlFunctionCall(SqlFunctionType.PadLeft, operand, length, padChar); } public static SqlFunctionCall PadRight(SqlExpression operand, SqlExpression length) { - ArgumentNullException.ThrowIfNull(operand, "operand"); - ArgumentNullException.ThrowIfNull(length, "length"); + ArgumentNullException.ThrowIfNull(operand); + ArgumentNullException.ThrowIfNull(length); return new SqlFunctionCall(SqlFunctionType.PadRight, operand, length); } public static SqlFunctionCall PadRight(SqlExpression operand, SqlExpression length, SqlExpression padChar) { - ArgumentNullException.ThrowIfNull(operand, "operand"); - ArgumentNullException.ThrowIfNull(length, "length"); - ArgumentNullException.ThrowIfNull(padChar, "padChar"); + ArgumentNullException.ThrowIfNull(operand); + ArgumentNullException.ThrowIfNull(length); + ArgumentNullException.ThrowIfNull(padChar); return new SqlFunctionCall(SqlFunctionType.PadRight, operand, length, padChar); } @@ -1984,142 +1967,142 @@ public static SqlFunctionCall PadRight(SqlExpression operand, SqlExpression leng public static SqlTableColumn TableColumn(SqlTable sqlTable) { - ArgumentNullException.ThrowIfNull(sqlTable, "table"); + ArgumentNullException.ThrowIfNull(sqlTable); return new SqlTableColumn(sqlTable, string.Empty); } public static SqlTableColumn TableColumn(SqlTable sqlTable, string name) { - ArgumentNullException.ThrowIfNull(sqlTable, "table"); + ArgumentNullException.ThrowIfNull(sqlTable); ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); return new SqlTableColumn(sqlTable, name); } public static SqlUserColumn Column(SqlExpression expression) { - ArgumentNullException.ThrowIfNull(expression, "expression"); + ArgumentNullException.ThrowIfNull(expression); return new SqlUserColumn(expression); } public static SqlColumnRef ColumnRef(SqlColumn column) { - ArgumentNullException.ThrowIfNull(column, "column"); + ArgumentNullException.ThrowIfNull(column); return new SqlColumnRef(column); } public static SqlColumnRef ColumnRef(SqlColumn column, string alias) { - ArgumentNullException.ThrowIfNull(column, "column"); + ArgumentNullException.ThrowIfNull(column); ArgumentValidator.EnsureArgumentNotNullOrEmpty(alias, "alias"); return new SqlColumnRef(column, alias); } public static SqlColumnStub ColumnStub(SqlColumn column) { - ArgumentNullException.ThrowIfNull(column, "column"); + ArgumentNullException.ThrowIfNull(column); return new SqlColumnStub(column); } public static SqlFreeTextTable FreeTextTable(DataTable dataTable, SqlExpression freeText, IList columnNames) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentNullException.ThrowIfNull(freeText, "freeText"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentNullException.ThrowIfNull(freeText); return new SqlFreeTextTable(dataTable, freeText, columnNames); } public static SqlFreeTextTable FreeTextTable(DataTable dataTable, SqlExpression freeText, IList columnNames, IList targetColumnNames) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentNullException.ThrowIfNull(freeText, "freeText"); - ArgumentNullException.ThrowIfNull(columnNames, "columnNames"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentNullException.ThrowIfNull(freeText); + ArgumentNullException.ThrowIfNull(columnNames); return new SqlFreeTextTable(dataTable, freeText, columnNames, targetColumnNames); } public static SqlFreeTextTable FreeTextTable(DataTable dataTable, SqlExpression freeText, IList columnNames, SqlExpression topN) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentNullException.ThrowIfNull(freeText, "freeText"); - ArgumentNullException.ThrowIfNull(topN, "topN"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentNullException.ThrowIfNull(freeText); + ArgumentNullException.ThrowIfNull(topN); return new SqlFreeTextTable(dataTable, freeText, columnNames, topN); } public static SqlFreeTextTable FreeTextTable(DataTable dataTable, SqlExpression freeText, IList columnNames, IList targetColumNames, SqlExpression topN) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentNullException.ThrowIfNull(freeText, "freeText"); - ArgumentNullException.ThrowIfNull(targetColumNames, "targetColumNames"); - ArgumentNullException.ThrowIfNull(topN, "topN"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentNullException.ThrowIfNull(freeText); + ArgumentNullException.ThrowIfNull(targetColumNames); + ArgumentNullException.ThrowIfNull(topN); return new SqlFreeTextTable(dataTable, freeText, columnNames, targetColumNames, topN); } public static SqlContainsTable ContainsTable(DataTable dataTable, SqlExpression searchText, IList columnNames) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentNullException.ThrowIfNull(searchText, "searchText"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentNullException.ThrowIfNull(searchText); return new SqlContainsTable(dataTable, searchText, columnNames); } public static SqlContainsTable ContainsTable(DataTable dataTable, SqlExpression searchText, IList columnNames, IList targetColumnNames) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentNullException.ThrowIfNull(searchText, "searchText"); - ArgumentNullException.ThrowIfNull(columnNames, "columnNames"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentNullException.ThrowIfNull(searchText); + ArgumentNullException.ThrowIfNull(columnNames); return new SqlContainsTable(dataTable, searchText, columnNames, targetColumnNames); } public static SqlContainsTable ContainsTable(DataTable dataTable, SqlExpression searchText, IList columnNames, SqlExpression topN) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentNullException.ThrowIfNull(searchText, "searchText"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentNullException.ThrowIfNull(searchText); return new SqlContainsTable(dataTable, searchText, columnNames, topN); } public static SqlContainsTable ContainsTable(DataTable dataTable, SqlExpression searchText, IList columnNames, IList targetColumnNames, SqlExpression topN) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentNullException.ThrowIfNull(searchText, "searchText"); - ArgumentNullException.ThrowIfNull(columnNames, "columnNames"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentNullException.ThrowIfNull(searchText); + ArgumentNullException.ThrowIfNull(columnNames); return new SqlContainsTable(dataTable, searchText, columnNames, targetColumnNames, topN); } public static SqlTableRef TableRef(DataTable dataTable) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); + ArgumentNullException.ThrowIfNull(dataTable); return new SqlTableRef(dataTable); } public static SqlTableRef TableRef(DataTable dataTable, IEnumerable columnNames) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentNullException.ThrowIfNull(columnNames, "columnNames"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentNullException.ThrowIfNull(columnNames); return new SqlTableRef(dataTable, string.Empty, columnNames.ToArray()); } public static SqlTableRef TableRef(DataTable dataTable, string name) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, nameof(name)); return new SqlTableRef(dataTable, name); } public static SqlTableRef TableRef(DataTable dataTable, string name, IEnumerable columnNames) { - ArgumentNullException.ThrowIfNull(dataTable, "dataTable"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, "name"); - ArgumentNullException.ThrowIfNull(columnNames, "columnNames"); + ArgumentNullException.ThrowIfNull(dataTable); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(name, nameof(name)); + ArgumentNullException.ThrowIfNull(columnNames); return new SqlTableRef(dataTable, name, columnNames.ToArray()); } public static SqlQueryRef QueryRef(ISqlQueryExpression query) { - ArgumentNullException.ThrowIfNull(query, "query"); + ArgumentNullException.ThrowIfNull(query); return new SqlQueryRef(query); } public static SqlQueryRef QueryRef(ISqlQueryExpression query, string alias) { - ArgumentNullException.ThrowIfNull(query, "query"); - ArgumentValidator.EnsureArgumentNotNullOrEmpty(alias, "alias"); + ArgumentNullException.ThrowIfNull(query); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(alias, nameof(alias)); return new SqlQueryRef(query, alias); } @@ -2129,64 +2112,64 @@ public static SqlQueryRef QueryRef(ISqlQueryExpression query, string alias) public static SqlUnary BitNot(SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsArithmeticExpression(operand); return Unary(SqlNodeType.BitNot, operand); } public static SqlUnary Negate(SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsArithmeticExpression(operand); return Unary(SqlNodeType.Negate, operand); } public static SqlUnary Not(SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); SqlValidator.EnsureIsBooleanExpression(operand); return Unary(SqlNodeType.Not, operand); } public static SqlUnary IsNull(SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return Unary(SqlNodeType.IsNull, operand); } public static SqlUnary IsNotNull(SqlExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return Unary(SqlNodeType.IsNotNull, operand); } public static SqlUnary Unique(ISqlQueryExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return Unary(SqlNodeType.Unique, SubQuery(operand)); } public static SqlUnary Exists(ISqlQueryExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return new SqlUnary(SqlNodeType.Exists, SubQuery(operand)); } public static SqlUnary All(ISqlQueryExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return Unary(SqlNodeType.All, SubQuery(operand)); } public static SqlUnary Any(ISqlQueryExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return Unary(SqlNodeType.Any, SubQuery(operand)); } public static SqlUnary Some(ISqlQueryExpression operand) { - ArgumentNullException.ThrowIfNull(operand, "operand"); + ArgumentNullException.ThrowIfNull(operand); return Unary(SqlNodeType.Some, SubQuery(operand)); } @@ -2234,7 +2217,7 @@ public static SqlVariable Variable(string name, SqlType type, short precision) public static SqlJoinHint JoinHint(SqlJoinMethod method, SqlTable table) { - ArgumentNullException.ThrowIfNull(table, "table"); + ArgumentNullException.ThrowIfNull(table); return new SqlJoinHint(method, table); } @@ -2251,13 +2234,13 @@ public static SqlForceJoinOrderHint ForceJoinOrderHint(params SqlTable[] sqlTabl public static SqlFastFirstRowsHint FastFirstRowsHint(int amount) { - ArgumentValidator.EnsureArgumentIsGreaterThan(amount, 0, "amount"); + ArgumentValidator.EnsureArgumentIsGreaterThan(amount, 0, nameof(amount)); return new SqlFastFirstRowsHint(amount); } public static SqlNativeHint NativeHint(string hintText) { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(hintText, "hintText"); + ArgumentValidator.EnsureArgumentNotNullOrEmpty(hintText, nameof(hintText)); return new SqlNativeHint(hintText); } From cd556f100bd759f77e4d7f009f3af1f2d0fd64fc Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 11 Mar 2026 11:18:59 +0500 Subject: [PATCH 30/55] Improve mappings merge Buffer collection on stack that acts like usage map of indexes also serves as orderer. More memory efficient solution and faster approach for at least portion of queries --- .../Transformation/ColumnMappingInspector.cs | 56 +++++++++++++++---- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs index b2e8827a2..514efe9f3 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs @@ -436,6 +436,10 @@ protected override void OnRecursionEntrance(Provider provider) private static List Merge(IEnumerable left, IEnumerable right) { + if (TryMergeFast(left, right, out var result)) + return result; + + // slow var hs = new HashSet(left); foreach (var r in right) { _ = hs.Add(r); @@ -445,18 +449,50 @@ private static List Merge(IEnumerable left, IEnumerable right) return resultList; } - private static List Merge(List leftMap, IEnumerable rightMap) + private static bool TryMergeFast(IEnumerable leftMap, IEnumerable rightMap, out List result) { - var preReturn = leftMap.Union(rightMap).ToList(leftMap.Count * 2); - preReturn.Sort(); - return preReturn; - } + Span usageMap = stackalloc bool[512]; + usageMap.Fill(false); + var uniqueCount = 0; + var biggestIndex = 0; - private static List Merge(List leftMap, IList rightMap) - { - var preReturn = leftMap.Union(rightMap).ToList(leftMap.Count + rightMap.Count); - preReturn.Sort(); - return preReturn; + // leftMap.Concat(rightMap) is slower! + foreach (var idx in leftMap) { + if (idx >= usageMap.Length) { + result = null; + return false; + } + if (!usageMap[idx]) { + uniqueCount++; + usageMap[idx] = true; + } + if (biggestIndex < idx) + biggestIndex = idx; + } + foreach (var idx in rightMap) { + if (idx >= usageMap.Length) { + result = null; + return false; + } + if (!usageMap[idx]) { + uniqueCount++; + usageMap[idx] = true; + } + if (biggestIndex < idx) + biggestIndex = idx; + } + var resultList = new List(uniqueCount); + for (int i = 0; i < biggestIndex + 1; i++) { + if (usageMap[i]) + resultList.Add(i); + } + if (resultList.Count != uniqueCount) { + // + result = null; + return false; + } + result = resultList; + return true; } private static List MergeMappings(Provider originalLeft, List leftMap, List rightMap) From ab47f077f3a5ed68cd32e50fa0d20deaf281fd2b Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 11 Mar 2026 11:45:56 +0500 Subject: [PATCH 31/55] Improve changelog --- ChangeLog/7.2.1-dev.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog/7.2.1-dev.txt b/ChangeLog/7.2.1-dev.txt index cf3f48a14..c49004e10 100644 --- a/ChangeLog/7.2.1-dev.txt +++ b/ChangeLog/7.2.1-dev.txt @@ -1,2 +1,4 @@ [main] LeftJoin extension marked as Obsolete to prepare movement to .NET 10, LeftJoinEx provided as substitution [main] IPriorityQueue interface became Obsolete +[main] EnumerableUtils.One() marked as Obsolete +[main] Performance and memory usage improvements \ No newline at end of file From 13382e135ed7131fda609c115948b8289f49180d Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 11 Mar 2026 15:30:00 +0500 Subject: [PATCH 32/55] Update Mono.Cecil package to 0.11.6 it fixes certain issues of pdb files being unsynced with code --- Weaver/Xtensive.Orm.Weaver/Xtensive.Orm.Weaver.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Weaver/Xtensive.Orm.Weaver/Xtensive.Orm.Weaver.csproj b/Weaver/Xtensive.Orm.Weaver/Xtensive.Orm.Weaver.csproj index 897076fbb..183872c42 100644 --- a/Weaver/Xtensive.Orm.Weaver/Xtensive.Orm.Weaver.csproj +++ b/Weaver/Xtensive.Orm.Weaver/Xtensive.Orm.Weaver.csproj @@ -11,7 +11,7 @@ Debug;Release;Debug-NET6;Release-NET6;Debug-NET7;Release-NET7;Debug-NET8;Release-NET8 - + From f57dbcf341ed021b56aec5d3cb53f416a7025e9e Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Wed, 11 Mar 2026 15:31:52 +0500 Subject: [PATCH 33/55] Improve changlog --- ChangeLog/7.2.1-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog/7.2.1-dev.txt b/ChangeLog/7.2.1-dev.txt index 436cde815..b70e7ce68 100644 --- a/ChangeLog/7.2.1-dev.txt +++ b/ChangeLog/7.2.1-dev.txt @@ -2,3 +2,4 @@ [main] Addressed issue of not disposing IAsyncEnumerator which caused query being open [main] Addressed issue of overwriting exception on attempt to rollback the transaction of Domain upgrade if commit operation failed [postgresql] Update Npgsql to 9.0.4 +[weaver] Updated Mono.Cecil package to v0.11.6, which resolves certain issues of unsynced pdb files From ef1e52b9cda1eecc3f72cae4c51689ede8bc7b59 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Thu, 12 Mar 2026 15:02:28 +0500 Subject: [PATCH 34/55] No CollectionUtils.RangeToList/RangeToArray usage --- .../Collections/CollectionUtilsTest.cs | 2 ++ Orm/Xtensive.Orm/Collections/CollectionUtils.cs | 2 ++ Orm/Xtensive.Orm/Orm/Building/Builders/IndexBuilder.cs | 4 ++-- Orm/Xtensive.Orm/Orm/EntitySetBase.cs | 2 +- .../Orm/Rse/Transformation/ColumnMappingInspector.cs | 10 +++++----- .../Rse/Transformation/Internals/SkipTakeRewriter.cs | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Orm/Xtensive.Orm.Tests.Core/Collections/CollectionUtilsTest.cs b/Orm/Xtensive.Orm.Tests.Core/Collections/CollectionUtilsTest.cs index 9171f9639..82af59342 100644 --- a/Orm/Xtensive.Orm.Tests.Core/Collections/CollectionUtilsTest.cs +++ b/Orm/Xtensive.Orm.Tests.Core/Collections/CollectionUtilsTest.cs @@ -16,6 +16,7 @@ namespace Xtensive.Orm.Tests.Core.Collections public class CollectionUtilsTest { [Test] + [Obsolete] public void RangeToArrayTest() { Assert.That(CollectionUtils.RangeToArray(1, 10).SequenceEqual(Enumerable.Range(1, 10))); @@ -24,6 +25,7 @@ public void RangeToArrayTest() } [Test] + [Obsolete] public void RangeToListTest() { Assert.That(CollectionUtils.RangeToList(1, 10).SequenceEqual(Enumerable.Range(1, 10))); diff --git a/Orm/Xtensive.Orm/Collections/CollectionUtils.cs b/Orm/Xtensive.Orm/Collections/CollectionUtils.cs index aa47715dc..f84a44e6f 100644 --- a/Orm/Xtensive.Orm/Collections/CollectionUtils.cs +++ b/Orm/Xtensive.Orm/Collections/CollectionUtils.cs @@ -24,6 +24,7 @@ public static class CollectionUtils /// /// is less than 0.-or- /// + -1 is larger than . + [Obsolete("Enumerable.Range().ToArray() is several times faster")] public static int[] RangeToArray(int start, int count) { ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(count, 0, "count"); @@ -41,6 +42,7 @@ public static int[] RangeToArray(int start, int count) /// /// is less than 0.-or- /// + -1 is larger than . + [Obsolete("Enumerable.Range().ToList() is several times faster")] public static List RangeToList(int start, int count) { ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(count, 0, "count"); diff --git a/Orm/Xtensive.Orm/Orm/Building/Builders/IndexBuilder.cs b/Orm/Xtensive.Orm/Orm/Building/Builders/IndexBuilder.cs index a602d74d5..c8f6637ac 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Builders/IndexBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Builders/IndexBuilder.cs @@ -805,7 +805,7 @@ private ColumnGroup BuildColumnGroup(IndexInfo index) var reflectedType = index.ReflectedType; var indexKeyColumns = index.KeyColumns; var keyColumns = index.IsPrimary - ? (IReadOnlyList) CollectionUtils.RangeToArray(0, indexKeyColumns.Count) + ? (IReadOnlyList) Enumerable.Range(0, indexKeyColumns.Count).ToArray() : indexKeyColumns .Select(static pair => pair.Key) .Concat(index.ValueColumns) @@ -813,7 +813,7 @@ private ColumnGroup BuildColumnGroup(IndexInfo index) .Where(static arg => arg.c.IsPrimaryKey) .Select(static arg => arg.i) .ToList(); - var columns = CollectionUtils.RangeToArray(0, indexKeyColumns.Count + index.ValueColumns.Count); + var columns = Enumerable.Range(0, indexKeyColumns.Count + index.ValueColumns.Count).ToArray(); return new ColumnGroup(reflectedType, keyColumns, columns); } diff --git a/Orm/Xtensive.Orm/Orm/EntitySetBase.cs b/Orm/Xtensive.Orm/Orm/EntitySetBase.cs index 1be20e8b6..72bd04e79 100644 --- a/Orm/Xtensive.Orm/Orm/EntitySetBase.cs +++ b/Orm/Xtensive.Orm/Orm/EntitySetBase.cs @@ -940,7 +940,7 @@ private static EntitySetTypeState BuildEntitySetTypeState(FieldInfo field, Entit .Where(ci => ci.IsPrimaryKey) .Select(ci => ci.Field.MappingInfo.Offset) .ToList() - : CollectionUtils.RangeToList(0, targetDescriptor.Count); + : Enumerable.Range(0, targetDescriptor.Count).ToList(); var keyFieldCount = ownerDescriptor.Count + itemColumnOffsets.Count; var keyFieldTypes = ownerDescriptor diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs index 514efe9f3..fdd69572d 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs @@ -28,7 +28,7 @@ internal abstract class ColumnMappingInspector : CompilableProviderVisitor public virtual CompilableProvider RemoveRedundantColumns() { - mappings.Add(rootProvider, CollectionUtils.RangeToList(0, rootProvider.Header.Length)); + mappings.Add(rootProvider, Enumerable.Range(0, rootProvider.Header.Length).ToList()); var visitedProvider = VisitCompilable(rootProvider); return visitedProvider != rootProvider ? visitedProvider @@ -89,25 +89,25 @@ protected override SelectProvider VisitSelect(SelectProvider provider) /// protected override FreeTextProvider VisitFreeText(FreeTextProvider provider) { - mappings[provider] = CollectionUtils.RangeToList(0, provider.Header.Length); + mappings[provider] = Enumerable.Range(0, provider.Header.Length).ToList(); return provider; } protected override CompilableProvider VisitContainsTable(ContainsTableProvider provider) { - mappings[provider] = CollectionUtils.RangeToList(0, provider.Header.Length); + mappings[provider] = Enumerable.Range(0, provider.Header.Length).ToList(); return provider; } protected override IndexProvider VisitIndex(IndexProvider provider) { - mappings[provider] = CollectionUtils.RangeToList(0, provider.Header.Length); + mappings[provider] = Enumerable.Range(0, provider.Header.Length).ToList(); return provider; } protected override SeekProvider VisitSeek(SeekProvider provider) { - mappings[provider] = CollectionUtils.RangeToList(0, provider.Header.Length); + mappings[provider] = Enumerable.Range(0, provider.Header.Length).ToList(); return provider; } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/SkipTakeRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/SkipTakeRewriter.cs index cb534df97..326758e3a 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/SkipTakeRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/SkipTakeRewriter.cs @@ -57,7 +57,7 @@ protected override CompilableProvider Visit(CompilableProvider cp) var headerCount = visitedProvider.Header.Length - 1; visitedProvider = new SelectProvider( visitedProvider, - CollectionUtils.RangeToArray(0, headerCount)); + Enumerable.Range(0, headerCount).ToArray()); } return visitedProvider; From eb2b8b6c6dbefb2f254af6d79ae889b92d378a4d Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Thu, 12 Mar 2026 15:04:55 +0500 Subject: [PATCH 35/55] Remove unnecessary check --- .../Orm/Rse/Transformation/ColumnMappingInspector.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs index fdd69572d..cb6f58bf5 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs @@ -486,11 +486,6 @@ private static bool TryMergeFast(IEnumerable leftMap, IEnumerable righ if (usageMap[i]) resultList.Add(i); } - if (resultList.Count != uniqueCount) { - // - result = null; - return false; - } result = resultList; return true; } From b4e4e5c6c3094fbbb2a1fdaa33667bc8c8c63fb6 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 13 Mar 2026 12:18:35 +0500 Subject: [PATCH 36/55] Improve changelog --- ChangeLog/7.2.1-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog/7.2.1-dev.txt b/ChangeLog/7.2.1-dev.txt index 389cba7a0..bfa4e69ad 100644 --- a/ChangeLog/7.2.1-dev.txt +++ b/ChangeLog/7.2.1-dev.txt @@ -5,5 +5,6 @@ [main] IPriorityQueue interface became Obsolete [main] EnumerableUtils.One() marked as Obsolete [main] Performance and memory usage improvements +[main] Fixed certain issues connected with SerializableExpressions deserialization [postgresql] Update Npgsql to 9.0.4 [weaver] Updated Mono.Cecil package to v0.11.6, which resolves certain issues of unsynced pdb files From c283d4ad73f9d181942cce0636aeb77c295809ac Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 13 Mar 2026 14:01:42 +0500 Subject: [PATCH 37/55] Remove some obsolete types usage --- .../Xtensive.Orm.Security/Cryptography/MD5HashingService.cs | 5 +---- .../Xtensive.Orm.Security/Cryptography/SHA1HashingService.cs | 5 +---- .../Cryptography/SHA256HashingService.cs | 5 +---- .../Cryptography/SHA384HashingService.cs | 5 +---- .../Cryptography/SHA512HashingService.cs | 5 +---- .../Sql.Drivers.Sqlite/ProviderInitializer.cs | 5 +---- Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs | 4 +--- 7 files changed, 7 insertions(+), 27 deletions(-) diff --git a/Extensions/Xtensive.Orm.Security/Cryptography/MD5HashingService.cs b/Extensions/Xtensive.Orm.Security/Cryptography/MD5HashingService.cs index 12ff7ba42..aa6f986ca 100644 --- a/Extensions/Xtensive.Orm.Security/Cryptography/MD5HashingService.cs +++ b/Extensions/Xtensive.Orm.Security/Cryptography/MD5HashingService.cs @@ -17,10 +17,7 @@ namespace Xtensive.Orm.Security.Cryptography public class MD5HashingService : GenericHashingService { /// -#pragma warning disable SYSLIB0021 // Type or member is obsolete - // direct creation is more efficient than MD5.Create() - protected override HashAlgorithm GetHashAlgorithm() => new MD5CryptoServiceProvider(); -#pragma warning restore SYSLIB0021 // Type or member is obsolete + protected override HashAlgorithm GetHashAlgorithm() => MD5.Create(); /// /// Initializes a new instance of the class. diff --git a/Extensions/Xtensive.Orm.Security/Cryptography/SHA1HashingService.cs b/Extensions/Xtensive.Orm.Security/Cryptography/SHA1HashingService.cs index 10e36f3c1..b3a3e9f58 100644 --- a/Extensions/Xtensive.Orm.Security/Cryptography/SHA1HashingService.cs +++ b/Extensions/Xtensive.Orm.Security/Cryptography/SHA1HashingService.cs @@ -16,10 +16,7 @@ namespace Xtensive.Orm.Security.Cryptography public class SHA1HashingService : GenericHashingService { /// -#pragma warning disable SYSLIB0021 // Type or member is obsolete - // direct creation is more efficient than SHA1.Create() - protected override HashAlgorithm GetHashAlgorithm() => new SHA1Managed(); -#pragma warning restore SYSLIB0021 // Type or member is obsolete + protected override HashAlgorithm GetHashAlgorithm() => SHA1.Create(); /// /// Initializes a new instance of the class. diff --git a/Extensions/Xtensive.Orm.Security/Cryptography/SHA256HashingService.cs b/Extensions/Xtensive.Orm.Security/Cryptography/SHA256HashingService.cs index fae88b439..18227039e 100644 --- a/Extensions/Xtensive.Orm.Security/Cryptography/SHA256HashingService.cs +++ b/Extensions/Xtensive.Orm.Security/Cryptography/SHA256HashingService.cs @@ -16,10 +16,7 @@ namespace Xtensive.Orm.Security.Cryptography public class SHA256HashingService : GenericHashingService { /// -#pragma warning disable SYSLIB0021 // Type or member is obsolete - // direct creation is more efficient than SHA256.Create() - protected override HashAlgorithm GetHashAlgorithm() => new SHA256Managed(); -#pragma warning restore SYSLIB0021 // Type or member is obsolete + protected override HashAlgorithm GetHashAlgorithm() => SHA256.Create(); /// /// Initializes a new instance of the class. diff --git a/Extensions/Xtensive.Orm.Security/Cryptography/SHA384HashingService.cs b/Extensions/Xtensive.Orm.Security/Cryptography/SHA384HashingService.cs index 7753ca1af..0aee4d045 100644 --- a/Extensions/Xtensive.Orm.Security/Cryptography/SHA384HashingService.cs +++ b/Extensions/Xtensive.Orm.Security/Cryptography/SHA384HashingService.cs @@ -16,10 +16,7 @@ namespace Xtensive.Orm.Security.Cryptography public class SHA384HashingService : GenericHashingService { /// -#pragma warning disable SYSLIB0021 // Type or member is obsolete - // direct creation is more efficient than SHA384.Create() - protected override HashAlgorithm GetHashAlgorithm() => new SHA384Managed(); -#pragma warning restore SYSLIB0021 // Type or member is obsolete + protected override HashAlgorithm GetHashAlgorithm() => SHA384.Create(); /// /// Initializes a new instance of the class. diff --git a/Extensions/Xtensive.Orm.Security/Cryptography/SHA512HashingService.cs b/Extensions/Xtensive.Orm.Security/Cryptography/SHA512HashingService.cs index 3de5b3c88..ff011d0e0 100644 --- a/Extensions/Xtensive.Orm.Security/Cryptography/SHA512HashingService.cs +++ b/Extensions/Xtensive.Orm.Security/Cryptography/SHA512HashingService.cs @@ -16,10 +16,7 @@ namespace Xtensive.Orm.Security.Cryptography public class SHA512HashingService : GenericHashingService { /// -#pragma warning disable SYSLIB0021 // Type or member is obsolete - // direct creation is more efficient than SHA512.Create() - protected override HashAlgorithm GetHashAlgorithm() => new SHA512Managed(); -#pragma warning restore SYSLIB0021 // Type or member is obsolete + protected override HashAlgorithm GetHashAlgorithm() => SHA512.Create(); /// /// Initializes a new instance of the class. diff --git a/Orm/Xtensive.Orm.Sqlite/Sql.Drivers.Sqlite/ProviderInitializer.cs b/Orm/Xtensive.Orm.Sqlite/Sql.Drivers.Sqlite/ProviderInitializer.cs index 7f528311f..d31063756 100644 --- a/Orm/Xtensive.Orm.Sqlite/Sql.Drivers.Sqlite/ProviderInitializer.cs +++ b/Orm/Xtensive.Orm.Sqlite/Sql.Drivers.Sqlite/ProviderInitializer.cs @@ -53,9 +53,7 @@ private static Stream GetLibraryStream() private static string GetLibraryHash() { -#pragma warning disable SYSLIB0021 // Type or member is obsolete - // direct creation is more efficient than SHA1.Create() - using (var hashProvider = new System.Security.Cryptography.SHA1Managed()) { + using (var hashProvider = SHA1.Create()) { //hashProvider.Initialize(); ReadOnlySpan hashRaw; using (var stream = GetLibraryStream()) { @@ -63,7 +61,6 @@ private static string GetLibraryHash() } return new StringBuilder().AppendHexArray(hashRaw[..8]).ToString(); } -#pragma warning restore SYSLIB0021 // Type or member is obsolete } private static string GetLibraryFileName(string nativeLibraryCacheFolder, string moduleHash) diff --git a/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs b/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs index fdb54aa24..44cc72670 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs @@ -579,12 +579,10 @@ public string ApplyNamingRules(string name) /// Computed hash. private static string GetHash(string name) { -#pragma warning disable SYSLIB0021 // Type or member is obsolete - using (var hashAlgorithm = new MD5CryptoServiceProvider()) { + using (var hashAlgorithm = MD5.Create()) { var hash = hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(name)); return $"H{hash[0]:x2}{hash[1]:x2}{hash[2]:x2}{hash[3]:x2}"; } -#pragma warning restore SYSLIB0021 // Type or member is obsolete } private static string FormatKeyGeneratorName(string database, string name) From a4149760b0ac7faf295985c5e91ba0d98a1ef80d Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 13 Mar 2026 15:16:44 +0500 Subject: [PATCH 38/55] Bump version to 7.2.1 --- ChangeLog/{7.2.1-dev.txt => 7.2.1-Z_Final.txt} | 0 Version.props | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename ChangeLog/{7.2.1-dev.txt => 7.2.1-Z_Final.txt} (100%) diff --git a/ChangeLog/7.2.1-dev.txt b/ChangeLog/7.2.1-Z_Final.txt similarity index 100% rename from ChangeLog/7.2.1-dev.txt rename to ChangeLog/7.2.1-Z_Final.txt diff --git a/Version.props b/Version.props index f8d908824..a9df093cf 100644 --- a/Version.props +++ b/Version.props @@ -3,7 +3,7 @@ 7.2.1 - dev + From 5a323f47cca7a9a3395e4c25ac7abaae9356e5b9 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 13 Mar 2026 16:56:45 +0500 Subject: [PATCH 39/55] Updated workflows - no net6/net7 mentioned - added net10 - removed unsupported storages --- .github/actions/setup-dotnets/action.yml | 6 + .github/workflows/auto-databaseless-tests.yml | 2 +- .github/workflows/auto-mssql2019-tests.yml | 2 +- .github/workflows/auto-mysql57-tests.yml | 2 +- .github/workflows/auto-mysql80-tests.yml | 2 +- .github/workflows/auto-mysql90-tests.yml | 2 +- .github/workflows/auto-pgsql140-tests.yml | 2 +- .github/workflows/auto-pgsql170-tests.yml | 2 +- .github/workflows/auto-sqlite3-tests.yml | 2 +- .../workflows/dispatched-firebird-tests.yml | 6 +- .github/workflows/dispatched-mssql-tests.yml | 6 +- .github/workflows/dispatched-mysql5-tests.yml | 52 +------- .github/workflows/dispatched-mysql8-tests.yml | 10 +- .github/workflows/dispatched-mysql9-tests.yml | 8 +- .../workflows/dispatched-pgsql10-tests.yml | 44 ++----- .github/workflows/dispatched-pgsql9-tests.yml | 118 ------------------ 16 files changed, 39 insertions(+), 227 deletions(-) delete mode 100644 .github/workflows/dispatched-pgsql9-tests.yml diff --git a/.github/actions/setup-dotnets/action.yml b/.github/actions/setup-dotnets/action.yml index 442005972..b936b5f22 100644 --- a/.github/actions/setup-dotnets/action.yml +++ b/.github/actions/setup-dotnets/action.yml @@ -11,6 +11,12 @@ runs: using: "composite" steps: + - name: Setup .NET 10 (if needed) + if: ${{ contains(inputs.target_framework, '10.0') }} + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '10.0.x' + - name: Setup .NET 9 (if needed) if: ${{ contains(inputs.target_framework, '9.0') }} uses: actions/setup-dotnet@v4 diff --git a/.github/workflows/auto-databaseless-tests.yml b/.github/workflows/auto-databaseless-tests.yml index c1d87a02d..af3302dc8 100644 --- a/.github/workflows/auto-databaseless-tests.yml +++ b/.github/workflows/auto-databaseless-tests.yml @@ -99,7 +99,7 @@ jobs: name: Core Tests strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] # For security reasons we allow test runs either for pushes from the team or for pull-requests after their changes were seen and approved by someone # # push filter - to cover pushes from the team to main branch of major version diff --git a/.github/workflows/auto-mssql2019-tests.yml b/.github/workflows/auto-mssql2019-tests.yml index abb965b8b..c7770ba84 100644 --- a/.github/workflows/auto-mssql2019-tests.yml +++ b/.github/workflows/auto-mssql2019-tests.yml @@ -144,7 +144,7 @@ jobs: name: Tests on MS SQL Server 2019 strategy: matrix: - net: [ 'net6.0', 'net8.0' ] # only LTS + net: [ 'net8.0', 'net10.0' ] # only LTS # For security reasons we allow test runs either for pushes from the team or for pull-requests after their changes were seen and approved by someone # # push filter - to cover pushes from the team to main branch of major version diff --git a/.github/workflows/auto-mysql57-tests.yml b/.github/workflows/auto-mysql57-tests.yml index 842f3d21e..68a4106d5 100644 --- a/.github/workflows/auto-mysql57-tests.yml +++ b/.github/workflows/auto-mysql57-tests.yml @@ -150,7 +150,7 @@ jobs: name: Tests on MySQL 5.7 strategy: matrix: - net: [ 'net6.0', 'net8.0' ] # only LTS + net: [ 'net8.0', 'net10.0' ] # only LTS # For security reasons we allow test runs either for pushes from the team or for pull-requests after their changes were seen and approved by someone # # push filter - to cover pushes from the team to main branch of major version diff --git a/.github/workflows/auto-mysql80-tests.yml b/.github/workflows/auto-mysql80-tests.yml index 5d7265ca6..8a1df4ded 100644 --- a/.github/workflows/auto-mysql80-tests.yml +++ b/.github/workflows/auto-mysql80-tests.yml @@ -153,7 +153,7 @@ jobs: name: Tests on MySQL 8.0 strategy: matrix: - net: [ 'net6.0', 'net8.0' ] # only LTS + net: [ 'net8.0', 'net10.0' ] # only LTS # For security reasons we allow test runs either for pushes from the team or for pull-requests after their changes were seen and approved by someone # # push filter - to cover pushes from the team to main branch of major version diff --git a/.github/workflows/auto-mysql90-tests.yml b/.github/workflows/auto-mysql90-tests.yml index 5b59923d3..d3c19079f 100644 --- a/.github/workflows/auto-mysql90-tests.yml +++ b/.github/workflows/auto-mysql90-tests.yml @@ -153,7 +153,7 @@ jobs: name: Tests on MySQL 9.0 strategy: matrix: - net: [ 'net6.0', 'net8.0' ] # only LTS + net: [ 'net8.0', 'net10.0' ] # only LTS # For security reasons we allow test runs either for pushes from the team or for pull-requests after their changes were seen and approved by someone # # push filter - to cover pushes from the team to main branch of major version diff --git a/.github/workflows/auto-pgsql140-tests.yml b/.github/workflows/auto-pgsql140-tests.yml index 949ed4f76..2caeadc9b 100644 --- a/.github/workflows/auto-pgsql140-tests.yml +++ b/.github/workflows/auto-pgsql140-tests.yml @@ -144,7 +144,7 @@ jobs: name: Tests on PostgreSQL 14.0 strategy: matrix: - net: [ 'net6.0', 'net8.0' ] # only LTS + net: [ 'net8.0', 'net10.0' ] # only LTS # For security reasons we allow test runs either for pushes from the team or for pull-requests after their changes were seen and approved by someone # # push filter - to cover pushes from the team to main branch of major version diff --git a/.github/workflows/auto-pgsql170-tests.yml b/.github/workflows/auto-pgsql170-tests.yml index 4386c1269..df7f75466 100644 --- a/.github/workflows/auto-pgsql170-tests.yml +++ b/.github/workflows/auto-pgsql170-tests.yml @@ -153,7 +153,7 @@ jobs: name: Tests on PostgreSQL 17.0 strategy: matrix: - net: [ 'net6.0', 'net8.0' ] # only LTS + net: [ 'net8.0', 'net10.0' ] # only LTS # For security reasons we allow test runs either for pushes from the team or for pull-requests after their changes were seen and approved by someone # # push filter - to cover pushes from the team to main branch of major version diff --git a/.github/workflows/auto-sqlite3-tests.yml b/.github/workflows/auto-sqlite3-tests.yml index 56156808b..eae392e04 100644 --- a/.github/workflows/auto-sqlite3-tests.yml +++ b/.github/workflows/auto-sqlite3-tests.yml @@ -142,7 +142,7 @@ jobs: name: Tests on SQLite 3 strategy: matrix: - net: [ 'net6.0', 'net8.0' ] # only LTS + net: [ 'net8.0', 'net10.0' ] # only LTS # For security reasons we allow test runs either for pushes from the team or for pull-requests after their changes were seen and approved by someone # # push filter - to cover pushes from the team to main branch of major version diff --git a/.github/workflows/dispatched-firebird-tests.yml b/.github/workflows/dispatched-firebird-tests.yml index 78e794656..b5df78699 100644 --- a/.github/workflows/dispatched-firebird-tests.yml +++ b/.github/workflows/dispatched-firebird-tests.yml @@ -45,7 +45,7 @@ jobs: if: ${{ inputs.firebird30 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: firebird30 @@ -65,7 +65,7 @@ jobs: if: ${{ inputs.firebird40 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: firebird40 @@ -85,7 +85,7 @@ jobs: if: ${{ inputs.firebird50 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: firebird50 diff --git a/.github/workflows/dispatched-mssql-tests.yml b/.github/workflows/dispatched-mssql-tests.yml index f59347d1c..e6dfe586d 100644 --- a/.github/workflows/dispatched-mssql-tests.yml +++ b/.github/workflows/dispatched-mssql-tests.yml @@ -45,7 +45,7 @@ jobs: if: ${{ inputs.mssql2017 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mssql2017 @@ -65,7 +65,7 @@ jobs: if: ${{ inputs.mssql2019 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mssql2019 @@ -85,7 +85,7 @@ jobs: if: ${{ inputs.mssql2022 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mssql2022 diff --git a/.github/workflows/dispatched-mysql5-tests.yml b/.github/workflows/dispatched-mysql5-tests.yml index dae1a0d57..7671204ed 100644 --- a/.github/workflows/dispatched-mysql5-tests.yml +++ b/.github/workflows/dispatched-mysql5-tests.yml @@ -13,16 +13,6 @@ on: type: boolean default: false required: true - mysql55: - description: 'MySQL 5.5' - type: boolean - default: false - required: true - mysql56: - description: 'MySQL 5.6' - type: boolean - default: true - required: true mysql57: description: 'MySQL 5.7' type: boolean @@ -40,52 +30,12 @@ permissions: checks: write jobs: - test_on_mysql55: - name: Tests on MySQL 5.5 - if: ${{ inputs.mysql55 }} - strategy: - matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] - uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master - with: - storage: mysql55 - build_config: Release - target_framework: ${{ matrix.net }} - specific_sha: ${{ inputs.specific_sha }} - show_all_fails: ${{ fromJSON(inputs.show_all_fails) }} - test_output_verbosity: minimal - test_run_timeout: 20 - run_main: true - run_sql: true - run_extensions: true - publish_raw_results: true - - test_on_mysql56: - name: Tests on MySQL 5.6 - if: ${{ inputs.mysql56 }} - strategy: - matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] - uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master - with: - storage: mysql56 - build_config: Release - target_framework: ${{ matrix.net }} - specific_sha: ${{ inputs.specific_sha }} - show_all_fails: ${{ fromJSON(inputs.show_all_fails) }} - test_output_verbosity: minimal - test_run_timeout: 30 - run_main: true - run_sql: true - run_extensions: true - publish_raw_results: true - test_on_mysql57: name: Tests on MySQL 5.7 if: ${{ inputs.mysql57 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mysql57 diff --git a/.github/workflows/dispatched-mysql8-tests.yml b/.github/workflows/dispatched-mysql8-tests.yml index ab901e282..7d91d434d 100644 --- a/.github/workflows/dispatched-mysql8-tests.yml +++ b/.github/workflows/dispatched-mysql8-tests.yml @@ -55,7 +55,7 @@ jobs: if: ${{ inputs.mysql80 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mysql80 @@ -75,7 +75,7 @@ jobs: if: ${{ inputs.mysql81 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mysql81 @@ -95,7 +95,7 @@ jobs: if: ${{ inputs.mysql82 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mysql82 @@ -115,7 +115,7 @@ jobs: if: ${{ inputs.mysql83 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mysql83 @@ -135,7 +135,7 @@ jobs: if: ${{ inputs.mysql84 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mysql84 diff --git a/.github/workflows/dispatched-mysql9-tests.yml b/.github/workflows/dispatched-mysql9-tests.yml index 8a1f792a4..608cf2f9a 100644 --- a/.github/workflows/dispatched-mysql9-tests.yml +++ b/.github/workflows/dispatched-mysql9-tests.yml @@ -50,7 +50,7 @@ jobs: if: ${{ inputs.mysql90 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mysql90 @@ -70,7 +70,7 @@ jobs: if: ${{ inputs.mysql91 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mysql91 @@ -90,7 +90,7 @@ jobs: if: ${{ inputs.mysql92 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mysql92 @@ -110,7 +110,7 @@ jobs: if: ${{ inputs.mysql93 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: mysql93 diff --git a/.github/workflows/dispatched-pgsql10-tests.yml b/.github/workflows/dispatched-pgsql10-tests.yml index a579501a5..eb970dc91 100644 --- a/.github/workflows/dispatched-pgsql10-tests.yml +++ b/.github/workflows/dispatched-pgsql10-tests.yml @@ -14,12 +14,6 @@ on: default: false required: true # EOL - moved to addtional versions - #pgsql100: - # description: 'PostgreSQL 10' - # type: boolean - # default: false - # required: true - # EOL - moved to addtional versions #pgsql110: # description: 'PostgreSQL 11' # type: boolean @@ -84,32 +78,12 @@ permissions: checks: write jobs: - test_on_pgsql100: - name: Tests on PostgreSQL 10 - if: ${{ contains(inputs.additional_versions, 'pgsql100') }} - strategy: - matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] - uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master - with: - storage: pgsql100 - build_config: Release - target_framework: ${{ matrix.net }} - specific_sha: ${{ inputs.specific_sha }} - show_all_fails: ${{ fromJSON(inputs.show_all_fails) }} - test_output_verbosity: minimal - test_run_timeout: 30 - run_main: true - run_sql: true - run_extensions: true - publish_raw_results: true - test_on_pgsql110: name: Tests on PostgreSQL 11 if: ${{ contains(inputs.additional_versions, 'pgsql110') }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: pgsql110 @@ -129,7 +103,7 @@ jobs: if: ${{ contains(inputs.additional_versions, 'pgsql120') }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: pgsql120 @@ -150,7 +124,7 @@ jobs: strategy: fail-fast: false matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: pgsql130 @@ -170,7 +144,7 @@ jobs: if: ${{ inputs.pgsql140 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: pgsql140 @@ -190,7 +164,7 @@ jobs: if: ${{ inputs.pgsql150 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: pgsql150 @@ -210,7 +184,7 @@ jobs: if: ${{ inputs.pgsql160 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: pgsql160 @@ -230,7 +204,7 @@ jobs: if: ${{ inputs.pgsql170 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: pgsql170 @@ -250,7 +224,7 @@ jobs: if: ${{ inputs.pgsql180 }} strategy: matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] + net: [ 'net8.0', 'net10.0' ] uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master with: storage: pgsql180 @@ -270,7 +244,7 @@ jobs: # if: ${{ inputs.pgsql190 }} # strategy: # matrix: - # net: [ 'net6.0', 'net7.0', 'net8.0' ] + # net: [ 'net8.0', 'net10.0' ] # uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master # with: # storage: pgsql190 diff --git a/.github/workflows/dispatched-pgsql9-tests.yml b/.github/workflows/dispatched-pgsql9-tests.yml deleted file mode 100644 index f21c6ad6d..000000000 --- a/.github/workflows/dispatched-pgsql9-tests.yml +++ /dev/null @@ -1,118 +0,0 @@ -name: 🛠🐘 PostgreSQL 9.x tests -run-name: Run database tests on PostgreSQL on dispatch. Run No ${{ github.run_number }}. -on: - workflow_dispatch: - inputs: - specific_sha: - description: 'Commit SHA to checkout' - required: false - default: '' - type: string - show_all_fails: - description: 'No mute tests' - type: boolean - default: false - required: true - pgsql91: - description: 'PostgreSQL 9.1' - type: boolean - default: false - required: true - pgsql92: - description: 'PostgreSQL 9.2' - type: boolean - default: false - required: true - pgsql96: - description: 'PostgreSQL 9.6' - type: boolean - default: true - required: true - -# new commits with the same key will cancel previously run workflows -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - contents: read - actions: read - checks: write - -jobs: - # requires special docker registry because the image is based on schema 1, which is depricated - #test_on_pgsql90: - # name: Tests on PostgreSQL 9.0 - # if: ${{ inputs.pgsql90 }} - # uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master - # with: - # storage: pgsql90 - # build_config: Release - # target_frameworks: net6.0 - # specific_sha: ${{ inputs.specific_sha }} - # test_output_verbosity: minimal - # test_run_timeout: 70 - # run_main: true - # run_sql: true - # run_extensions: true - # publish_raw_results: false - - test_on_pgsql91: - name: Tests on PostgreSQL 9.1 - if: ${{ inputs.pgsql91 }} - strategy: - matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] - uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master - with: - storage: pgsql91 - build_config: Release - target_framework: ${{ matrix.net }} - specific_sha: ${{ inputs.specific_sha }} - show_all_fails: ${{ fromJSON(inputs.show_all_fails) }} - test_output_verbosity: minimal - test_run_timeout: 30 - run_main: true - run_sql: true - run_extensions: true - publish_raw_results: true - - test_on_pgsql92: - name: Tests on PostgreSQL 9.2 - if: ${{ inputs.pgsql92 }} - strategy: - matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] - uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master - with: - storage: pgsql92 - build_config: Release - target_framework: ${{ matrix.net }} - specific_sha: ${{ inputs.specific_sha }} - show_all_fails: ${{ fromJSON(inputs.show_all_fails) }} - test_output_verbosity: minimal - test_run_timeout: 30 - run_main: true - run_sql: true - run_extensions: true - publish_raw_results: true - - test_on_pgsql96: - name: Tests on PostgreSQL 9.6 - if: ${{ inputs.pgsql96 }} - strategy: - matrix: - net: [ 'net6.0', 'net7.0', 'net8.0' ] - uses: DataObjects-NET/dataobjects-net/.github/workflows/reusable-storage-dependant-tests.yml@master - with: - storage: pgsql96 - build_config: Release - target_framework: ${{ matrix.net }} - specific_sha: ${{ inputs.specific_sha }} - show_all_fails: ${{ fromJSON(inputs.show_all_fails) }} - test_output_verbosity: minimal - test_run_timeout: 30 - run_main: true - run_sql: true - run_extensions: true - publish_raw_results: true From 864d5f0730816bf9659e4f1c804536fedfcb7d9e Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 19 Mar 2026 11:56:31 -0700 Subject: [PATCH 40/55] LeftOuterJoin --- .../Sql.Drivers.PostgreSql/v11_0/Extractor.cs | 6 ++--- .../Sql.Drivers.PostgreSql/v12_0/Extractor.cs | 4 ++-- .../SqlServer/MSSQLTests.cs | 2 +- ...Github0114_QueryRootReuseCauseNoRefJoin.cs | 6 ++--- ...b0171_ReadDateTimeOffsetFromPackedTuple.cs | 4 ++-- ...3_IncorrectLeftJoinOnNotNullEntityField.cs | 8 +++---- ...ira0584_IncorrectMappingOfColumnInQuery.cs | 22 +++++++++---------- ...ssueJira0586_AnonymousTypeComparisonBug.cs | 2 +- ...a0617_IncorrectRemoveOfRedundantColumns.cs | 22 +++++++++---------- ...JoiningExpressionCausesWrongTranslation.cs | 6 ++--- .../Linq/DynamicallyDefinedFields.cs | 2 +- Orm/Xtensive.Orm.Tests/Linq/InTest.cs | 2 +- Orm/Xtensive.Orm.Tests/Linq/JoinTest.cs | 6 ++--- Orm/Xtensive.Orm.Tests/Linq/TagTest.cs | 4 ++-- Orm/Xtensive.Orm/Orm/QueryableExtensions.cs | 11 +++++++--- Orm/Xtensive.Orm/Sql/Dml/SqlTable.cs | 6 ++--- 16 files changed, 59 insertions(+), 54 deletions(-) diff --git a/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v11_0/Extractor.cs b/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v11_0/Extractor.cs index 0169acf70..cce8cbbeb 100644 --- a/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v11_0/Extractor.cs +++ b/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v11_0/Extractor.cs @@ -624,7 +624,7 @@ protected virtual ISqlCompileUnit BuildExtractSchemaContentsQuery(ExtractionCont var relationsTable = PgClass; var tablespacesTable = PgTablespace; - var join = relationsTable.LeftOuterJoin(tablespacesTable, + var join = relationsTable.LeftJoinEx(tablespacesTable, tablespacesTable["oid"] == relationsTable["reltablespace"]); var select = SqlDml.Select(join); select.Where = relationsTable["relowner"] == context.CurrentUserIdentifier @@ -735,7 +735,7 @@ protected virtual ISqlCompileUnit BuildExtractTableAndViewColumnsQuery(Extractio var typesTable = PgType; var select = SqlDml.Select(columnsTable - .LeftOuterJoin(defaultValuesTable, + .LeftJoinEx(defaultValuesTable, columnsTable["attrelid"] == defaultValuesTable["adrelid"] && columnsTable["attnum"] == defaultValuesTable["adnum"]) .InnerJoin(typesTable, typesTable["oid"] == columnsTable["atttypid"])); @@ -889,7 +889,7 @@ protected virtual ISqlCompileUnit BuildExtractTableIndexesQuery(ExtractionContex //not automatically created indexes of our tables var select = SqlDml.Select(indexTable .InnerJoin(relationsTable, relationsTable["oid"] == indexTable["indexrelid"]) - .LeftOuterJoin(tableSpacesTable, tableSpacesTable["oid"] == relationsTable["reltablespace"])); + .LeftJoinEx(tableSpacesTable, tableSpacesTable["oid"] == relationsTable["reltablespace"])); select.Where = SqlDml.In(indexTable["indrelid"], CreateOidRow(tableMap.Keys)) && !SqlDml.Exists(subSelect); select.Columns.Add(indexTable["indrelid"]); select.Columns.Add(indexTable["indexrelid"]); diff --git a/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v12_0/Extractor.cs b/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v12_0/Extractor.cs index a22674cb0..c02cbb256 100644 --- a/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v12_0/Extractor.cs +++ b/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v12_0/Extractor.cs @@ -33,7 +33,7 @@ protected override ISqlCompileUnit BuildExtractTableAndViewColumnsQuery(Extracti var typesTable = PgType; var select = SqlDml.Select(columnsTable - .LeftOuterJoin(defaultValuesTable, + .LeftJoinEx(defaultValuesTable, columnsTable["attrelid"] == defaultValuesTable["adrelid"] && columnsTable["attnum"] == defaultValuesTable["adnum"]) .InnerJoin(typesTable, typesTable["oid"] == columnsTable["atttypid"])); @@ -103,7 +103,7 @@ protected override ISqlCompileUnit BuildExtractTableIndexesQuery(ExtractionConte //not automatically created indexes of our tables var select = SqlDml.Select(indexTable .InnerJoin(relationsTable, relationsTable["oid"] == indexTable["indexrelid"]) - .LeftOuterJoin(tableSpacesTable, tableSpacesTable["oid"] == relationsTable["reltablespace"])); + .LeftJoinEx(tableSpacesTable, tableSpacesTable["oid"] == relationsTable["reltablespace"])); select.Where = SqlDml.In(indexTable["indrelid"], CreateOidRow(tableMap.Keys)) && !SqlDml.Exists(subSelect); select.Columns.Add(indexTable["indrelid"]); select.Columns.Add(indexTable["indexrelid"]); diff --git a/Orm/Xtensive.Orm.Tests.Sql/SqlServer/MSSQLTests.cs b/Orm/Xtensive.Orm.Tests.Sql/SqlServer/MSSQLTests.cs index 66c4c36ec..b21ffdd1e 100644 --- a/Orm/Xtensive.Orm.Tests.Sql/SqlServer/MSSQLTests.cs +++ b/Orm/Xtensive.Orm.Tests.Sql/SqlServer/MSSQLTests.cs @@ -2562,7 +2562,7 @@ public void Test115() var p = SqlDml.TableRef(Catalog.Schemas["Production"].Tables["Product"], "p"); var pr = SqlDml.TableRef(Catalog.Schemas["Production"].Tables["ProductReview"], "pr"); - var select = SqlDml.Select(p.LeftOuterJoin(pr, p["ProductID"]==pr["ProductID"])); + var select = SqlDml.Select(p.LeftJoinEx(pr, p["ProductID"]==pr["ProductID"])); select.Columns.AddRange(p["Name"], pr["ProductReviewID"]); Assert.That(CompareExecuteDataReader(nativeSql, select), Is.True); diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0114_QueryRootReuseCauseNoRefJoin.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0114_QueryRootReuseCauseNoRefJoin.cs index 7a2509434..fcb47e498 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0114_QueryRootReuseCauseNoRefJoin.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0114_QueryRootReuseCauseNoRefJoin.cs @@ -2389,7 +2389,7 @@ public void LeftJoinQueryReuse() .Select(promo => new { promo, notifications = session.Query.All() - .LeftOuterJoin(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }) + .LeftJoinEx(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }) }) .Select(anon => new { contacted = anon.notifications.Select(c => c.n.Recipient.User.Id) @@ -2401,9 +2401,9 @@ public void LeftJoinQueryReuse() .Select(promo => new { promo }) .Select(anon => new { contacted = session.Query.All() - .LeftOuterJoin(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }).Select(c => c.n.Recipient.User.Id) + .LeftJoinEx(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }).Select(c => c.n.Recipient.User.Id) .Concat(session.Query.All() - .LeftOuterJoin(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }).Select(c => c.n.Recipient.User.Id)), + .LeftJoinEx(session.Query.All(), n => n.TriggeredBy.Id, u => u.Id, (n, u) => new { n, u }).Select(c => c.n.Recipient.User.Id)), promo = anon.promo }).ToArray(); diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0171_ReadDateTimeOffsetFromPackedTuple.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0171_ReadDateTimeOffsetFromPackedTuple.cs index ca963bba5..67f97769e 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0171_ReadDateTimeOffsetFromPackedTuple.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueGithub0171_ReadDateTimeOffsetFromPackedTuple.cs @@ -78,7 +78,7 @@ public void DateTimeOffsetCase() var loadWithCargo = new CargoLoad(session, cargo); var query = session.Query.All() - .LeftOuterJoin(session.Query.All(), + .LeftJoinEx(session.Query.All(), cl => cl.Cargo, c => c, (cl, c) => new { CargoLoad = cl, Cargo = c }) @@ -102,7 +102,7 @@ public void DateTimeCase() var loadWithCargo = new CargoLoad(session, cargo); var query = session.Query.All() - .LeftOuterJoin(session.Query.All(), + .LeftJoinEx(session.Query.All(), cl => cl.Cargo, c => c, (cl, c) => new { CargoLoad = cl, Cargo = c }) diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0553_IncorrectLeftJoinOnNotNullEntityField.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0553_IncorrectLeftJoinOnNotNullEntityField.cs index 10e05e255..c01a8114f 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0553_IncorrectLeftJoinOnNotNullEntityField.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0553_IncorrectLeftJoinOnNotNullEntityField.cs @@ -136,7 +136,7 @@ public void BadWorkTest() using (var session = Domain.OpenSession()) using (var t = session.OpenTransaction()) { var badResult = session.Query.All() - .LeftOuterJoin( + .LeftJoinEx( session.Query.All(), e => e.Id, ewc => ewc.Id, @@ -155,7 +155,7 @@ public void GoodWorkTest() using (var session = Domain.OpenSession()) using (var transaction = session.OpenTransaction()) { var goodResult = session.Query.All() - .LeftOuterJoin( + .LeftJoinEx( session.Query.All(), e => e.Id, ewc => ewc.Id, @@ -173,7 +173,7 @@ public void WorkaroundTest() using (var session = Domain.OpenSession()) using (var transaction = session.OpenTransaction()) { var wordaround = session.Query.All() - .LeftOuterJoin( + .LeftJoinEx( session.Query.All(), e => e.Id, ewc => ewc.Id, @@ -181,7 +181,7 @@ public void WorkaroundTest() e.Id, CarId = ewc.Car.Id }) - .LeftOuterJoin( + .LeftJoinEx( session.Query.All(), e => e.CarId, c => c.Id, diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0584_IncorrectMappingOfColumnInQuery.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0584_IncorrectMappingOfColumnInQuery.cs index 409077418..272fdf6f0 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0584_IncorrectMappingOfColumnInQuery.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0584_IncorrectMappingOfColumnInQuery.cs @@ -526,8 +526,8 @@ public void IncludeProviderOptimizationTest01() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftOuterJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftOuterJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting() { Id = item.Id, @@ -609,8 +609,8 @@ public void IncludeProviderOptimizationTest02() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftOuterJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftOuterJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -692,8 +692,8 @@ public void IncludeProviderOptimizationTest03() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftOuterJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftOuterJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -776,8 +776,8 @@ public void IncludeProviderOptimizationTest04() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftOuterJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftOuterJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -859,8 +859,8 @@ public void IncludeProviderOptimizationTest05() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftOuterJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftOuterJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -1029,7 +1029,7 @@ public void JoinAsSourceOfSetOperation() var result = from r in preResult.Join(tp.Distinct(), a => a.MasterAccount, a => a.Account, (a, pm) => new {pp = a, pm}) - .LeftOuterJoin(Query.All(), a => a.pm.FinToolKind, a => a.Id, (a, b) => new {pp = a.pp, pm = a.pm, fk = b}) + .LeftJoinEx(Query.All(), a => a.pm.FinToolKind, a => a.Id, (a, b) => new {pp = a.pp, pm = a.pm, fk = b}) let q = r.pp select new { diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0586_AnonymousTypeComparisonBug.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0586_AnonymousTypeComparisonBug.cs index 2ea6b5a0e..8080bfd0a 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0586_AnonymousTypeComparisonBug.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0586_AnonymousTypeComparisonBug.cs @@ -108,7 +108,7 @@ public void MainTest() var masterCredit = Query.All(); - var join = from r in masterCredit.LeftOuterJoin( + var join = from r in masterCredit.LeftJoinEx( tableParts, a => a.CreditAccount.Id, a => a.Account.Id, diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0617_IncorrectRemoveOfRedundantColumns.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0617_IncorrectRemoveOfRedundantColumns.cs index 2c2eaf62a..a2b9c6687 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0617_IncorrectRemoveOfRedundantColumns.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0617_IncorrectRemoveOfRedundantColumns.cs @@ -68,8 +68,8 @@ public void Test01() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftOuterJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftOuterJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting() { Id = item.Id, @@ -149,8 +149,8 @@ public void Test02() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftOuterJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftOuterJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -230,8 +230,8 @@ public void Test03() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftOuterJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftOuterJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -312,8 +312,8 @@ public void Test04() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftOuterJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftOuterJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -393,8 +393,8 @@ public void Test05() var usefulColumns = masterCredit.Union(masterDebit); var readyForFilterQuery = from joinResult in usefulColumns - .LeftOuterJoin(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) - .LeftOuterJoin(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) + .LeftJoinEx(priceCalculation, a => a.SlaveAccount, a => a.Account, (pp, ps) => new {pp, ps}) + .LeftJoinEx(priceCalculation, a => a.pp.MasterAccount, a => a.Account, (a, pm) => new {a.pp, a.ps, pm}) let item = joinResult.pp select new CustomPosting { Id = item.Id, @@ -562,7 +562,7 @@ public void Test08() var result = from r in preResult.Join(tp.Distinct(), a => a.MasterAccount, a => a.Account, (a, pm) => new {pp = a, pm}) - .LeftOuterJoin(Query.All(), a => a.pm.FinToolKind, a => a.Id, (a, b) => new {pp = a.pp, pm = a.pm, fk = b}) + .LeftJoinEx(Query.All(), a => a.pm.FinToolKind, a => a.Id, (a, b) => new {pp = a.pp, pm = a.pm, fk = b}) let q = r.pp select new { diff --git a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0803_ReuseOfJoiningExpressionCausesWrongTranslation.cs b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0803_ReuseOfJoiningExpressionCausesWrongTranslation.cs index 8e4e1bebe..57d5c648a 100644 --- a/Orm/Xtensive.Orm.Tests/Issues/IssueJira0803_ReuseOfJoiningExpressionCausesWrongTranslation.cs +++ b/Orm/Xtensive.Orm.Tests/Issues/IssueJira0803_ReuseOfJoiningExpressionCausesWrongTranslation.cs @@ -66,7 +66,7 @@ public void LeftJoinOneVariableUsage() using (var tx = session.OpenTransaction()) { var leftJoinWithExpression = session.Query.All() - .LeftOuterJoin(session.Query.All().Where(it => it.Description == null), + .LeftJoinEx(session.Query.All().Where(it => it.Description == null), o => o.Id, key, (o, i) => o) @@ -78,7 +78,7 @@ public void LeftJoinOneVariableUsage() Assert.That(leftJoinWithExpression.Count, Is.EqualTo(3)); leftJoinWithExpression = session.Query.All() - .LeftOuterJoin(session.Query.All().Where(it => it.Description == null), + .LeftJoinEx(session.Query.All().Where(it => it.Description == null), key, i => i.Id, (o, i) => o) @@ -101,7 +101,7 @@ public void LeftJoinTwoVariableUsage() var ex = Assert.Throws(() => _ = session.Query.All() - .LeftOuterJoin(session.Query.All().Where(it => it.Description == null), + .LeftJoinEx(session.Query.All().Where(it => it.Description == null), key, key, (o, i) => o) diff --git a/Orm/Xtensive.Orm.Tests/Linq/DynamicallyDefinedFields.cs b/Orm/Xtensive.Orm.Tests/Linq/DynamicallyDefinedFields.cs index 24ea3bd9b..8e7ae24d2 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/DynamicallyDefinedFields.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/DynamicallyDefinedFields.cs @@ -1260,7 +1260,7 @@ public void LeftJoinTest() using (session.Activate()) using (var transction = session.OpenTransaction()) { Assert.DoesNotThrow(() => { - session.Query.All().LeftOuterJoin(session.Query.All(), area => (Group)area[testData.GroupFieldName], + session.Query.All().LeftJoinEx(session.Query.All(), area => (Group)area[testData.GroupFieldName], group => group, (area, @group) => new { Area = area, Group = group }); }); } diff --git a/Orm/Xtensive.Orm.Tests/Linq/InTest.cs b/Orm/Xtensive.Orm.Tests/Linq/InTest.cs index 4f0069848..ac66f1462 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/InTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/InTest.cs @@ -76,7 +76,7 @@ public async Task StringContainsAsyncTest() public void MartinTest() { _ = Session.Query.All() - .LeftOuterJoin(Session.Query.All(), c => c, i => i.Customer, (c, i) => new { Customer = c, Invoice = i }) + .LeftJoinEx(Session.Query.All(), c => c, i => i.Customer, (c, i) => new { Customer = c, Invoice = i }) .GroupBy(i => new { i.Customer.FirstName, i.Customer.LastName }) .Select(g => new { Key = g.Key, Count = g.Count(j => j.Invoice != null) }) .ToList(); diff --git a/Orm/Xtensive.Orm.Tests/Linq/JoinTest.cs b/Orm/Xtensive.Orm.Tests/Linq/JoinTest.cs index efff17fc2..292e3d993 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/JoinTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/JoinTest.cs @@ -143,7 +143,7 @@ public void SimpleLeftTest() { var traclCount = Session.Query.All().Count(); var result = Session.Query.All() - .LeftOuterJoin(Session.Query.All(), + .LeftJoinEx(Session.Query.All(), track => track.Album.AlbumId, album => album.AlbumId, (track, album) => new {track.Name, album.Title, album.AlbumId}); @@ -159,7 +159,7 @@ public void LeftJoin1Test() Session.Current.SaveChanges(); var tracks = Session.Query.All(); var albums = Session.Query.All(); - var result = tracks.LeftOuterJoin( + var result = tracks.LeftJoinEx( albums, track => track.Album, album => album, @@ -179,7 +179,7 @@ public void LeftJoin2Test() Session.Current.SaveChanges(); var tracks = Session.Query.All(); var albums = Session.Query.All(); - var result = tracks.LeftOuterJoin( + var result = tracks.LeftJoinEx( albums, track => track.Album.AlbumId, album => album.AlbumId, diff --git a/Orm/Xtensive.Orm.Tests/Linq/TagTest.cs b/Orm/Xtensive.Orm.Tests/Linq/TagTest.cs index 234317500..07f6c0714 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/TagTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/TagTest.cs @@ -331,7 +331,7 @@ public void TagInJoin() var inner = session.Query.All().Tag("inner"); var outer = session.Query.All().Tag("outer"); - var query = outer.LeftOuterJoin(inner, o => o.Owner.Id, i => i.Id, (i, o) => new { i, o }); + var query = outer.LeftJoinEx(inner, o => o.Owner.Id, i => i.Id, (i, o) => new { i, o }); var queryFormatter = session.Services.Demand(); var queryString = queryFormatter.ToSqlString(query); @@ -589,7 +589,7 @@ public void TagInGrouping() .Tag("AfterSelect") .Where(g => g.Items.Count() >= 0) .Tag("AfterWhere") - .LeftOuterJoin(session.Query.All().Tag("WithinJoin"), g => g.Key, bu => bu.Id, (g, bu) => new { Key = bu, Items = g.Items }); + .LeftJoinEx(session.Query.All().Tag("WithinJoin"), g => g.Key, bu => bu.Id, (g, bu) => new { Key = bu, Items = g.Items }); using (var tagScope = session.Tag("sessionTag6")) { session.Events.DbCommandExecuting += SqlCapturer; diff --git a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs index 72cd28db8..05549329e 100644 --- a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs @@ -328,7 +328,7 @@ public static bool In(this T source, IncludeAlgorithm algorithm, IEnumerable< /// /// One of provided arguments is . /// Queryable is not a query. - public static IQueryable LeftOuterJoin(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) + public static IQueryable LeftJoinEx(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { ArgumentNullException.ThrowIfNull(outer); ArgumentNullException.ThrowIfNull(inner); @@ -337,15 +337,20 @@ public static IQueryable LeftOuterJoin(t ArgumentNullException.ThrowIfNull(resultSelector); var outerProviderType = outer.Provider.GetType(); - if (outerProviderType!=WellKnownOrmTypes.QueryProvider) { + if (outerProviderType != WellKnownOrmTypes.QueryProvider) { var errorMessage = Strings.ExLeftJoinDoesNotSupportQueryProviderOfTypeX; throw new NotSupportedException(string.Format(errorMessage, outerProviderType)); } - var expression = Expression.Call(null, Traits.ExtensionLeftJoinMethodInfo, new[] {outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector}); + var genericMethod = WellKnownMembers.Queryable.ExtensionLeftJoin.MakeGenericMethod(new[] { typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult) }); + var expression = Expression.Call(null, genericMethod, new[] { outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector }); return outer.Provider.CreateQuery(expression); } + + public static IQueryable LeftOuterJoin(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) => + LeftJoinEx(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + /// /// Runs query to database asynchronously and returns completed task for other . /// diff --git a/Orm/Xtensive.Orm/Sql/Dml/SqlTable.cs b/Orm/Xtensive.Orm/Sql/Dml/SqlTable.cs index ad33aa675..bcdbe2b54 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/SqlTable.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/SqlTable.cs @@ -83,9 +83,9 @@ public virtual SqlJoinedTable InnerJoin(SqlTable right) return InnerJoin(right, null); } - public virtual SqlJoinedTable LeftOuterJoin(SqlTable right) + public virtual SqlJoinedTable LeftJoinEx(SqlTable right) { - return LeftOuterJoin(right, null); + return LeftJoinEx(right, null); } public virtual SqlJoinedTable RightOuterJoin(SqlTable right) @@ -103,7 +103,7 @@ public virtual SqlJoinedTable InnerJoin(SqlTable right, SqlExpression expression return SqlDml.Join(SqlJoinType.InnerJoin, this, right, expression); } - public virtual SqlJoinedTable LeftOuterJoin(SqlTable right, SqlExpression expression) + public virtual SqlJoinedTable LeftJoinEx(SqlTable right, SqlExpression expression) { return SqlDml.Join(SqlJoinType.LeftOuterJoin, this, right, expression); } From 948c9049e5e21cb6f6088d2208bda6fc3daa0260 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 19 Mar 2026 12:22:44 -0700 Subject: [PATCH 41/55] Fix build --- Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs | 11 ++++++- .../DatabaseConfigurationCollection.cs | 4 +-- .../Orm/Configuration/DomainConfiguration.cs | 1 - .../Orm/Configuration/IgnoreRuleCollection.cs | 2 -- .../KeyGeneratorConfigurationCollection.cs | 3 +- .../Configuration/MappingRuleCollection.cs | 4 +-- .../Orm/Configuration/NamingConvention.cs | 4 +-- .../Orm/Configuration/NodeConfiguration.cs | 2 -- .../SessionConfigurationCollection.cs | 2 -- .../Orm/Configuration/VersioningConvention.cs | 3 -- .../Expressions/Visitors/ColumnGatherer.cs | 28 ++++++++-------- .../Visitors/EntityExpressionJoiner.cs | 4 +-- .../Visitors/ExtendedExpressionReplacer.cs | 26 +++++++-------- .../Visitors/ExtendedExpressionVisitor.cs | 32 +++++++++---------- .../Linq/Expressions/Visitors/OwnerRemover.cs | 20 ++++++------ .../Visitors/PersistentExpressionVisitor.cs | 6 ++-- .../Materialization/ExpressionMaterializer.cs | 28 ++++++++-------- .../Linq/Rewriters/ApplyParameterRewriter.cs | 6 ++-- .../ApplyParameterToTupleParameterRewriter.cs | 6 ++-- .../Linq/Rewriters/SubqueryFilterRemover.cs | 2 +- .../Orm/Providers/SqlCompiler.Include.cs | 2 +- .../Orm/Providers/SqlCompiler.NotSupported.cs | 6 ++-- .../Orm/Providers/SqlCompiler.Paging.cs | 2 +- Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.cs | 2 +- Orm/Xtensive.Orm/Orm/Rse/AggregateColumn.cs | 2 +- Orm/Xtensive.Orm/Orm/Rse/CalculatedColumn.cs | 2 +- .../Orm/Rse/Providers/ProviderVisitor.cs | 2 +- Orm/Xtensive.Orm/Orm/Rse/SystemColumn.cs | 2 +- .../ApplyProviderCorrectorRewriter.cs | 6 ++-- .../Internals/OrderingRewriter.cs | 12 +++---- 30 files changed, 112 insertions(+), 120 deletions(-) diff --git a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs index 29c4b3190..cbe224487 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs @@ -105,6 +105,15 @@ protected override Expression VisitDefault(DefaultExpression d) protected override Expression VisitMember(MemberExpression m) => Visit(m, m.Expression, static (m, expression) => Expression.MakeMemberAccess(expression, m.Member)); + + protected virtual MemberExpression VisitMemberAccess(MemberExpression m) + { + Expression expression = Visit(m.Expression); + if (expression!=m.Expression) + return Expression.MakeMemberAccess(expression, m.Member); + return m; + } + /// protected override Expression VisitMethodCall(MethodCallExpression mc) { @@ -129,7 +138,7 @@ protected override MemberAssignment VisitMemberAssignment(MemberAssignment ma) = protected override Expression VisitLambda(Expression l) => Visit((LambdaExpression)l, l.Body, static (l, body) => FastExpression.Lambda(l.Type, body, l.Parameters)); - protected Expression VisitLambda(LambdaExpression lambda) => base.Visit(lambda); + protected virtual Expression VisitLambda(LambdaExpression lambda) => base.Visit(lambda); private TOriginal Visit(TOriginal original, TSubExpression subExpression, Func func) where TSubExpression : Expression { diff --git a/Orm/Xtensive.Orm/Orm/Configuration/DatabaseConfigurationCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/DatabaseConfigurationCollection.cs index 6b2710e29..1536ab043 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/DatabaseConfigurationCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/DatabaseConfigurationCollection.cs @@ -41,8 +41,6 @@ public DatabaseConfigurationCollection Clone() return result; } - object ICloneable.Clone() => Clone(); - /// public override void Lock(bool recursive) { @@ -53,4 +51,4 @@ public override void Lock(bool recursive) base.Lock(recursive); } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs index bcbaf809d..d99d0d2d8 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs @@ -788,7 +788,6 @@ protected override void CopyFrom(ConfigurationBase source) types = configuration.Types.Clone(); linqExtensions = configuration.LinqExtensions.Clone(); namingConvention = configuration.NamingConvention.Clone(); - keyCacheSize = configuration.KeyCacheSize; keyGeneratorCacheSize = configuration.KeyGeneratorCacheSize; queryCacheSize = configuration.QueryCacheSize; recordSetMappingCacheSize = configuration.RecordSetMappingCacheSize; diff --git a/Orm/Xtensive.Orm/Orm/Configuration/IgnoreRuleCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/IgnoreRuleCollection.cs index 713e1aad1..9fb739731 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/IgnoreRuleCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/IgnoreRuleCollection.cs @@ -65,8 +65,6 @@ public IgnoreRuleCollection Clone() return result; } - object ICloneable.Clone() => Clone(); - /// public override void Lock(bool recursive) { diff --git a/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfigurationCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfigurationCollection.cs index 70c9c49d9..0acbca03a 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfigurationCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/KeyGeneratorConfigurationCollection.cs @@ -56,7 +56,6 @@ public KeyGeneratorConfigurationCollection Clone() return result; } - object ICloneable.Clone() => Clone(); /// public override void Lock(bool recursive) { @@ -67,4 +66,4 @@ public override void Lock(bool recursive) base.Lock(recursive); } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Configuration/MappingRuleCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/MappingRuleCollection.cs index 91f0b49e7..6db36a184 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/MappingRuleCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/MappingRuleCollection.cs @@ -65,8 +65,6 @@ public MappingRuleCollection Clone() return result; } - object ICloneable.Clone() => Clone(); - /// public override void Lock(bool recursive) { @@ -77,4 +75,4 @@ public override void Lock(bool recursive) base.Lock(recursive); } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Configuration/NamingConvention.cs b/Orm/Xtensive.Orm/Orm/Configuration/NamingConvention.cs index 4e0189d46..50d465141 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/NamingConvention.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/NamingConvention.cs @@ -113,8 +113,6 @@ public NamingConvention Clone() return result; } - object ICloneable.Clone() => Clone(); - #endregion } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Configuration/NodeConfiguration.cs b/Orm/Xtensive.Orm/Orm/Configuration/NodeConfiguration.cs index 1056659ba..17876db57 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/NodeConfiguration.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/NodeConfiguration.cs @@ -108,8 +108,6 @@ public NodeConfiguration Clone() => TypeIdRegistry = TypeIdRegistry, }; - object ICloneable.Clone() => Clone(); - internal void Validate(DomainConfiguration configuration) { if (string.IsNullOrEmpty(nodeId)) diff --git a/Orm/Xtensive.Orm/Orm/Configuration/SessionConfigurationCollection.cs b/Orm/Xtensive.Orm/Orm/Configuration/SessionConfigurationCollection.cs index dd85c2045..831f60ece 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/SessionConfigurationCollection.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/SessionConfigurationCollection.cs @@ -155,8 +155,6 @@ public SessionConfigurationCollection Clone() return result; } - object ICloneable.Clone() => Clone(); - private SessionConfiguration GetConfiguration(string name, SessionConfiguration fallback) { return !IsLocked ? this[name] : fallback; diff --git a/Orm/Xtensive.Orm/Orm/Configuration/VersioningConvention.cs b/Orm/Xtensive.Orm/Orm/Configuration/VersioningConvention.cs index 34d1dc0c5..e5f1a9fb2 100644 --- a/Orm/Xtensive.Orm/Orm/Configuration/VersioningConvention.cs +++ b/Orm/Xtensive.Orm/Orm/Configuration/VersioningConvention.cs @@ -60,8 +60,6 @@ public VersioningConvention Clone() return result; } - object ICloneable.Clone() => Clone(); - /// public VersioningConvention() { @@ -70,4 +68,3 @@ public VersioningConvention() } } } - diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ColumnGatherer.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ColumnGatherer.cs index a5132e2bf..d029f5aa8 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ColumnGatherer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ColumnGatherer.cs @@ -70,20 +70,20 @@ public static ColNum[] GetColumns(Expression expression, ColumnExtractionModes c return ordered.ToArray(); } - protected override MarkerExpression VisitMarker(MarkerExpression expression) + internal protected override MarkerExpression VisitMarker(MarkerExpression expression) { Visit(expression.Target); return expression; } - protected override FieldExpression VisitFieldExpression(FieldExpression f) + internal protected override FieldExpression VisitFieldExpression(FieldExpression f) { ProcessFieldOwner(f); AddColumns(f, f.Mapping.GetItems()); return f; } - protected override StructureFieldExpression VisitStructureFieldExpression(StructureFieldExpression s) + internal protected override StructureFieldExpression VisitStructureFieldExpression(StructureFieldExpression s) { ProcessFieldOwner(s); AddColumns(s, @@ -93,13 +93,13 @@ protected override StructureFieldExpression VisitStructureFieldExpression(Struct return s; } - protected override KeyExpression VisitKeyExpression(KeyExpression k) + internal protected override KeyExpression VisitKeyExpression(KeyExpression k) { AddColumns(k, k.Mapping.GetItems()); return k; } - protected override EntityExpression VisitEntityExpression(EntityExpression e) + internal protected override EntityExpression VisitEntityExpression(EntityExpression e) { if (TreatEntityAsKey) { var keyExpression = (KeyExpression) e.Fields.First(f => f.ExtendedType==ExtendedExpressionType.Key); @@ -119,7 +119,7 @@ protected override EntityExpression VisitEntityExpression(EntityExpression e) return e; } - protected override EntityFieldExpression VisitEntityFieldExpression(EntityFieldExpression ef) + internal protected override EntityFieldExpression VisitEntityFieldExpression(EntityFieldExpression ef) { var keyExpression = (KeyExpression) ef.Fields.First(f => f.ExtendedType==ExtendedExpressionType.Key); AddColumns(ef, keyExpression.Mapping.GetItems()); @@ -128,19 +128,19 @@ protected override EntityFieldExpression VisitEntityFieldExpression(EntityFieldE return ef; } - protected override EntitySetExpression VisitEntitySetExpression(EntitySetExpression es) + internal protected override EntitySetExpression VisitEntitySetExpression(EntitySetExpression es) { VisitEntityExpression((EntityExpression) es.Owner); return es; } - protected override ColumnExpression VisitColumnExpression(ColumnExpression c) + internal protected override ColumnExpression VisitColumnExpression(ColumnExpression c) { AddColumns(c, c.Mapping.GetItems()); return c; } - protected override StructureExpression VisitStructureExpression(StructureExpression expression) + internal protected override StructureExpression VisitStructureExpression(StructureExpression expression) { AddColumns(expression, expression.Fields @@ -149,14 +149,14 @@ protected override StructureExpression VisitStructureExpression(StructureExpress return expression; } - protected override GroupingExpression VisitGroupingExpression(GroupingExpression expression) + internal protected override GroupingExpression VisitGroupingExpression(GroupingExpression expression) { Visit(expression.KeyExpression); VisitSubQueryExpression(expression); return expression; } - protected override SubQueryExpression VisitSubQueryExpression(SubQueryExpression subQueryExpression) + internal protected override SubQueryExpression VisitSubQueryExpression(SubQueryExpression subQueryExpression) { bool isTopSubquery = false; @@ -179,14 +179,14 @@ protected override SubQueryExpression VisitSubQueryExpression(SubQueryExpression return subQueryExpression; } - protected override LocalCollectionExpression VisitLocalCollectionExpression(LocalCollectionExpression expression) + internal protected override LocalCollectionExpression VisitLocalCollectionExpression(LocalCollectionExpression expression) { foreach (var field in expression.Fields) Visit((Expression) field.Value); return expression; } - internal override Expression VisitConstructorExpression(ConstructorExpression expression) + internal protected override Expression VisitConstructorExpression(ConstructorExpression expression) { foreach (var binding in expression.Bindings) Visit(binding.Value); @@ -229,7 +229,7 @@ private void AddColumns(ParameterizedExpression parameterizedExpression, IEnumer columns.AddRange(expressionColumns.Select(i => (i, (Expression)parameterizedExpression))); } - protected override FullTextExpression VisitFullTextExpression(FullTextExpression expression) + internal protected override FullTextExpression VisitFullTextExpression(FullTextExpression expression) { VisitEntityExpression(expression.EntityExpression); VisitColumnExpression(expression.RankExpression); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/EntityExpressionJoiner.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/EntityExpressionJoiner.cs index f5b74e941..2a19af0d2 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/EntityExpressionJoiner.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/EntityExpressionJoiner.cs @@ -14,7 +14,7 @@ internal sealed class EntityExpressionJoiner : ExtendedExpressionVisitor private readonly Translator translator; private readonly ItemProjectorExpression itemProjectorExpression; - internal override System.Linq.Expressions.Expression VisitEntityExpression(EntityExpression expression) + internal protected override System.Linq.Expressions.Expression VisitEntityExpression(EntityExpression expression) { translator.EnsureEntityFieldsAreJoined(expression, itemProjectorExpression); return base.VisitEntityExpression(expression); @@ -32,4 +32,4 @@ private EntityExpressionJoiner(Translator translator, ItemProjectorExpression it this.itemProjectorExpression = itemProjectorExpression; } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs index 82aaec525..7814be89a 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs @@ -28,7 +28,7 @@ public override Expression Visit(Expression e) return result ?? base.Visit(e); } - protected override ProjectionExpression VisitProjectionExpression(ProjectionExpression projectionExpression) + internal protected override ProjectionExpression VisitProjectionExpression(ProjectionExpression projectionExpression) { var item = Visit(projectionExpression.ItemProjector.Item); var provider = providerVisitor.VisitCompilable(projectionExpression.ItemProjector.DataSource); @@ -41,7 +41,7 @@ protected override ProjectionExpression VisitProjectionExpression(ProjectionExpr return projectionExpression; } - protected override GroupingExpression VisitGroupingExpression(GroupingExpression expression) + internal protected override GroupingExpression VisitGroupingExpression(GroupingExpression expression) { var keyExpression = Visit(expression.KeyExpression); if (keyExpression!=expression.KeyExpression) @@ -56,7 +56,7 @@ protected override GroupingExpression VisitGroupingExpression(GroupingExpression return expression; } - protected override FullTextExpression VisitFullTextExpression(FullTextExpression expression) + internal protected override FullTextExpression VisitFullTextExpression(FullTextExpression expression) { var rankExpression = (ColumnExpression) Visit(expression.RankExpression); var entityExpression = (EntityExpression) Visit(expression.EntityExpression); @@ -65,7 +65,7 @@ protected override FullTextExpression VisitFullTextExpression(FullTextExpression return expression; } - protected override SubQueryExpression VisitSubQueryExpression(SubQueryExpression expression) + internal protected override SubQueryExpression VisitSubQueryExpression(SubQueryExpression expression) { return expression; } @@ -76,42 +76,42 @@ private Expression TranslateExpression(CompilableProvider provider, Expression o return result ?? original; } - protected override FieldExpression VisitFieldExpression(FieldExpression expression) + internal protected override FieldExpression VisitFieldExpression(FieldExpression expression) { return expression; } - protected override StructureFieldExpression VisitStructureFieldExpression(StructureFieldExpression expression) + internal protected override StructureFieldExpression VisitStructureFieldExpression(StructureFieldExpression expression) { return expression; } - protected override KeyExpression VisitKeyExpression(KeyExpression expression) + internal protected override KeyExpression VisitKeyExpression(KeyExpression expression) { return expression; } - protected override EntityExpression VisitEntityExpression(EntityExpression expression) + internal protected override EntityExpression VisitEntityExpression(EntityExpression expression) { return expression; } - protected override EntityFieldExpression VisitEntityFieldExpression(EntityFieldExpression expression) + internal protected override EntityFieldExpression VisitEntityFieldExpression(EntityFieldExpression expression) { return expression; } - protected override EntitySetExpression VisitEntitySetExpression(EntitySetExpression expression) + internal protected override EntitySetExpression VisitEntitySetExpression(EntitySetExpression expression) { return expression; } - protected override ColumnExpression VisitColumnExpression(ColumnExpression expression) + internal protected override ColumnExpression VisitColumnExpression(ColumnExpression expression) { return expression; } - protected override ConstructorExpression VisitConstructorExpression(ConstructorExpression expression) + internal protected override ConstructorExpression VisitConstructorExpression(ConstructorExpression expression) { var bindings = new Dictionary(expression.Bindings.Count); var nativeBindings = new Dictionary(expression.NativeBindings.Count); @@ -143,7 +143,7 @@ protected override ConstructorExpression VisitConstructorExpression(ConstructorE arguments); } - protected override MarkerExpression VisitMarker(MarkerExpression expression) + internal protected override MarkerExpression VisitMarker(MarkerExpression expression) { var target = Visit(expression.Target); return target == expression.Target diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionVisitor.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionVisitor.cs index f4b1c3956..68da62bb2 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionVisitor.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionVisitor.cs @@ -17,23 +17,23 @@ protected override Expression VisitExtension(Expression node) => (node as ExtendedExpression ?? throw new NotSupportedException(string.Format(Strings.ExpressionXIsUnknown, node))) .Accept(this); - internal virtual Expression VisitFullTextExpression(FullTextExpression expression) => expression; - internal virtual Expression VisitConstructorExpression(ConstructorExpression expression) => expression; - internal virtual Expression VisitStructureExpression(StructureExpression expression) => expression; - internal virtual Expression VisitLocalCollectionExpression(LocalCollectionExpression expression) => expression; - internal virtual Expression VisitGroupingExpression(GroupingExpression expression) => expression; - internal virtual Expression VisitSubQueryExpression(SubQueryExpression expression) => expression; - internal virtual Expression VisitProjectionExpression(ProjectionExpression projectionExpression) => projectionExpression; - internal virtual Expression VisitFieldExpression(FieldExpression expression) => expression; - internal virtual Expression VisitStructureFieldExpression(StructureFieldExpression expression) => expression; - internal virtual Expression VisitKeyExpression(KeyExpression expression) => expression; - internal virtual Expression VisitEntityExpression(EntityExpression expression) => expression; - internal virtual Expression VisitEntityFieldExpression(EntityFieldExpression expression) => expression; - internal virtual Expression VisitEntitySetExpression(EntitySetExpression expression) => expression; - internal virtual Expression VisitItemProjectorExpression(ItemProjectorExpression itemProjectorExpression) => itemProjectorExpression; - internal virtual Expression VisitColumnExpression(ColumnExpression expression) => expression; + internal protected virtual Expression VisitFullTextExpression(FullTextExpression expression) => expression; + internal protected virtual Expression VisitConstructorExpression(ConstructorExpression expression) => expression; + internal protected virtual Expression VisitStructureExpression(StructureExpression expression) => expression; + internal protected virtual Expression VisitLocalCollectionExpression(LocalCollectionExpression expression) => expression; + internal protected virtual Expression VisitGroupingExpression(GroupingExpression expression) => expression; + internal protected virtual Expression VisitSubQueryExpression(SubQueryExpression expression) => expression; + internal protected virtual Expression VisitProjectionExpression(ProjectionExpression projectionExpression) => projectionExpression; + internal protected virtual Expression VisitFieldExpression(FieldExpression expression) => expression; + internal protected virtual Expression VisitStructureFieldExpression(StructureFieldExpression expression) => expression; + internal protected virtual Expression VisitKeyExpression(KeyExpression expression) => expression; + internal protected virtual Expression VisitEntityExpression(EntityExpression expression) => expression; + internal protected virtual Expression VisitEntityFieldExpression(EntityFieldExpression expression) => expression; + internal protected virtual Expression VisitEntitySetExpression(EntitySetExpression expression) => expression; + internal protected virtual Expression VisitItemProjectorExpression(ItemProjectorExpression itemProjectorExpression) => itemProjectorExpression; + internal protected virtual Expression VisitColumnExpression(ColumnExpression expression) => expression; - internal virtual Expression VisitMarker(MarkerExpression expression) + internal protected virtual Expression VisitMarker(MarkerExpression expression) { var processedTarget = Visit(expression.Target); return processedTarget == expression.Target ? expression : new MarkerExpression(processedTarget, expression.MarkerType); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs index 38524a0b6..d96bc5062 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/OwnerRemover.cs @@ -17,32 +17,32 @@ internal sealed class OwnerRemover : PersistentExpressionVisitor public static Expression RemoveOwner(Expression target) => Instance.Visit(target); - protected override GroupingExpression VisitGroupingExpression(GroupingExpression expression) + internal protected override GroupingExpression VisitGroupingExpression(GroupingExpression expression) { return expression; } - protected override SubQueryExpression VisitSubQueryExpression(SubQueryExpression expression) + internal protected override SubQueryExpression VisitSubQueryExpression(SubQueryExpression expression) { return expression; } - protected override FieldExpression VisitFieldExpression(FieldExpression expression) + internal protected override FieldExpression VisitFieldExpression(FieldExpression expression) { return expression.RemoveOwner(); } - protected override FieldExpression VisitStructureFieldExpression(StructureFieldExpression expression) + internal protected override FieldExpression VisitStructureFieldExpression(StructureFieldExpression expression) { return expression.RemoveOwner(); } - protected override KeyExpression VisitKeyExpression(KeyExpression expression) + internal protected override KeyExpression VisitKeyExpression(KeyExpression expression) { return expression; } - protected override ConstructorExpression VisitConstructorExpression(ConstructorExpression expression) + internal protected override ConstructorExpression VisitConstructorExpression(ConstructorExpression expression) { var oldConstructorArguments = expression.ConstructorArguments; var newConstructorArguments = VisitExpressionList(oldConstructorArguments); @@ -70,22 +70,22 @@ protected override ConstructorExpression VisitConstructorExpression(ConstructorE return new ConstructorExpression(expression.Type, bindings, nativeBingings, expression.Constructor, newConstructorArguments.ToReadOnlyList()); } - protected override EntityExpression VisitEntityExpression(EntityExpression expression) + internal protected override EntityExpression VisitEntityExpression(EntityExpression expression) { return expression; } - protected override FieldExpression VisitEntityFieldExpression(EntityFieldExpression expression) + internal protected override FieldExpression VisitEntityFieldExpression(EntityFieldExpression expression) { return expression.RemoveOwner(); } - protected override EntitySetExpression VisitEntitySetExpression(EntitySetExpression expression) + internal protected override EntitySetExpression VisitEntitySetExpression(EntitySetExpression expression) { return expression; } - protected override ColumnExpression VisitColumnExpression(ColumnExpression expression) + internal protected override ColumnExpression VisitColumnExpression(ColumnExpression expression) { return expression; } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/PersistentExpressionVisitor.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/PersistentExpressionVisitor.cs index d9ffaeb91..56b248e62 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/PersistentExpressionVisitor.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/PersistentExpressionVisitor.cs @@ -13,13 +13,13 @@ namespace Xtensive.Orm.Linq.Expressions.Visitors { internal abstract class PersistentExpressionVisitor : ExtendedExpressionVisitor { - internal override Expression VisitProjectionExpression(ProjectionExpression projectionExpression) => + internal protected override Expression VisitProjectionExpression(ProjectionExpression projectionExpression) => throw Exceptions.InternalError(string.Format(Strings.ExXDoesNotSupportX, typeof(PersistentExpressionVisitor), WellKnownOrmTypes.ProjectionExpression), OrmLog.Instance); - internal override Expression VisitItemProjectorExpression(ItemProjectorExpression itemProjectorExpression) + internal protected override Expression VisitItemProjectorExpression(ItemProjectorExpression itemProjectorExpression) { throw Exceptions.InternalError(String.Format(Strings.ExXDoesNotSupportX, typeof (PersistentExpressionVisitor), typeof (ItemProjectorExpression)), OrmLog.Instance); } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs b/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs index b88ac170c..aaf6d612a 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs @@ -85,7 +85,7 @@ public static MaterializationInfo MakeMaterialization(ItemProjectorExpression pr #region Visitor methods overrsides - internal override Expression VisitFullTextExpression(FullTextExpression expression) + internal protected override Expression VisitFullTextExpression(FullTextExpression expression) { var rankMaterializer = Visit(expression.RankExpression); var entityMaterializer = Visit(expression.EntityExpression); @@ -99,7 +99,7 @@ internal override Expression VisitFullTextExpression(FullTextExpression expressi entityMaterializer); } - internal override Expression VisitMarker(MarkerExpression expression) + internal protected override Expression VisitMarker(MarkerExpression expression) { var target = expression.Target; var processedTarget = Visit(target); @@ -114,7 +114,7 @@ internal override Expression VisitMarker(MarkerExpression expression) return processedTarget; } - internal override Expression VisitGroupingExpression(GroupingExpression groupingExpression) + internal protected override Expression VisitGroupingExpression(GroupingExpression groupingExpression) { // 1. Prepare subquery parameters. var translatedQuery = PrepareSubqueryParameters(groupingExpression, @@ -146,7 +146,7 @@ internal override Expression VisitGroupingExpression(GroupingExpression grouping return Expression.Convert(resultExpression, groupingExpression.Type); } - internal override Expression VisitSubQueryExpression(SubQueryExpression subQueryExpression) + internal protected override Expression VisitSubQueryExpression(SubQueryExpression subQueryExpression) { // 1. Prepare subquery parameters. var translatedQuery = PrepareSubqueryParameters( @@ -209,7 +209,7 @@ private TranslatedQuery PrepareSubqueryParameters(SubQueryExpression subQueryExp } } - internal override Expression VisitFieldExpression(FieldExpression expression) + internal protected override Expression VisitFieldExpression(FieldExpression expression) { var tupleExpression = GetTupleExpression(expression); @@ -240,11 +240,11 @@ internal override Expression VisitFieldExpression(FieldExpression expression) return MaterializeThroughOwner(expression, tupleExpression); } - internal override Expression VisitLocalCollectionExpression(LocalCollectionExpression expression) => + internal protected override Expression VisitLocalCollectionExpression(LocalCollectionExpression expression) => throw new NotSupportedException( string.Format(Strings.ExUnableToMaterializeBackLocalCollectionItem, expression.ToString())); - internal override Expression VisitStructureFieldExpression(StructureFieldExpression expression) + internal protected override Expression VisitStructureFieldExpression(StructureFieldExpression expression) { var tupleExpression = GetTupleExpression(expression); @@ -276,7 +276,7 @@ internal override Expression VisitStructureFieldExpression(StructureFieldExpress return MaterializeThroughOwner(expression, tupleExpression); } - internal override Expression VisitConstructorExpression(ConstructorExpression expression) + internal protected override Expression VisitConstructorExpression(ConstructorExpression expression) { var newExpression = expression.Constructor==null ? Expression.New(expression.Type) // Value type with default ctor (expression.Constructor is null in that case) @@ -292,7 +292,7 @@ internal override Expression VisitConstructorExpression(ConstructorExpression ex .Select(item => Expression.Bind(item.Key, Visit(item.Value))).Cast()); } - internal override Expression VisitStructureExpression(StructureExpression expression) + internal protected override Expression VisitStructureExpression(StructureExpression expression) { var tupleExpression = GetTupleExpression(expression); @@ -319,7 +319,7 @@ internal override Expression VisitStructureExpression(StructureExpression expres expression.Type); } - internal override Expression VisitKeyExpression(KeyExpression expression) + internal protected override Expression VisitKeyExpression(KeyExpression expression) { // TODO: http://code.google.com/p/dataobjectsdotnet/issues/detail?id=336 Expression tupleExpression = Expression.Call( @@ -337,7 +337,7 @@ internal override Expression VisitKeyExpression(KeyExpression expression) tupleExpression); } - internal override Expression VisitEntityExpression(EntityExpression expression) + internal protected override Expression VisitEntityExpression(EntityExpression expression) { var tupleExpression = GetTupleExpression(expression); return CreateEntity(expression, tupleExpression); @@ -392,7 +392,7 @@ private Expression CreateEntity(IEntityExpression expression, Expression tupleEx } /// InvalidOperationException. - internal override Expression VisitEntityFieldExpression(EntityFieldExpression expression) + internal protected override Expression VisitEntityFieldExpression(EntityFieldExpression expression) { if (expression.Entity!=null) return Visit(expression.Entity); @@ -403,7 +403,7 @@ internal override Expression VisitEntityFieldExpression(EntityFieldExpression ex : CreateEntity(expression, tupleExpression); } - internal override Expression VisitEntitySetExpression(EntitySetExpression expression) + internal protected override Expression VisitEntitySetExpression(EntitySetExpression expression) { var tupleExpression = GetTupleExpression(expression); var materializedEntitySetExpression = MaterializeThroughOwner(expression, tupleExpression); @@ -416,7 +416,7 @@ internal override Expression VisitEntitySetExpression(EntitySetExpression expres return prefetchEntitySetExpression; } - internal override Expression VisitColumnExpression(ColumnExpression expression) + internal protected override Expression VisitColumnExpression(ColumnExpression expression) { var tupleExpression = GetTupleExpression(expression); return tupleExpression.MakeTupleAccess(expression.Type, expression.Mapping.Offset); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Rewriters/ApplyParameterRewriter.cs b/Orm/Xtensive.Orm/Orm/Linq/Rewriters/ApplyParameterRewriter.cs index 56b8bc22f..5d887c307 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Rewriters/ApplyParameterRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Rewriters/ApplyParameterRewriter.cs @@ -38,7 +38,7 @@ protected override Expression VisitMember(MemberExpression m) } - internal override Expression VisitGroupingExpression(GroupingExpression expression) + internal protected override Expression VisitGroupingExpression(GroupingExpression expression) { var projectionExpression = expression.ProjectionExpression; var newProvider = Rewrite(projectionExpression.ItemProjector.DataSource, oldApplyParameter, newApplyParameter); @@ -56,7 +56,7 @@ internal override Expression VisitGroupingExpression(GroupingExpression expressi return expression; } - internal override Expression VisitSubQueryExpression(SubQueryExpression expression) + internal protected override Expression VisitSubQueryExpression(SubQueryExpression expression) { var projectionExpression = expression.ProjectionExpression; var newProvider = Rewrite(projectionExpression.ItemProjector.DataSource, oldApplyParameter, newApplyParameter); @@ -94,4 +94,4 @@ private ApplyParameterRewriter(ApplyParameter oldParameter, ApplyParameter newPa newApplyParameter = newParameter; } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Linq/Rewriters/ApplyParameterToTupleParameterRewriter.cs b/Orm/Xtensive.Orm/Orm/Linq/Rewriters/ApplyParameterToTupleParameterRewriter.cs index 95b61fefa..a1d7da9b3 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Rewriters/ApplyParameterToTupleParameterRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Rewriters/ApplyParameterToTupleParameterRewriter.cs @@ -39,7 +39,7 @@ protected override Expression VisitMember(MemberExpression m) return parameterOfTupleExpression; } - internal override Expression VisitGroupingExpression(GroupingExpression expression) + internal protected override Expression VisitGroupingExpression(GroupingExpression expression) { var projectionExpression = expression.ProjectionExpression; var newProvider = Rewrite(projectionExpression.ItemProjector.DataSource, parameterOfTuple, applyParameter); @@ -58,7 +58,7 @@ internal override Expression VisitGroupingExpression(GroupingExpression expressi return expression; } - internal override Expression VisitSubQueryExpression(SubQueryExpression expression) + internal protected override Expression VisitSubQueryExpression(SubQueryExpression expression) { var projectionExpression = expression.ProjectionExpression; var newProvider = Rewrite(projectionExpression.ItemProjector.DataSource, parameterOfTuple, applyParameter); @@ -95,4 +95,4 @@ private ApplyParameterToTupleParameterRewriter(Parameter parameterOfTuple this.applyParameter = applyParameter; } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Linq/Rewriters/SubqueryFilterRemover.cs b/Orm/Xtensive.Orm/Orm/Linq/Rewriters/SubqueryFilterRemover.cs index 5207a21a9..6a7243a4b 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Rewriters/SubqueryFilterRemover.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Rewriters/SubqueryFilterRemover.cs @@ -115,4 +115,4 @@ private SubqueryFilterRemover(ApplyParameter filterParameter) checker = new SubqueryFilterChecker(filterParameter); } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Include.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Include.cs index e705d0451..af2fc5f58 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Include.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Include.cs @@ -19,7 +19,7 @@ namespace Xtensive.Orm.Providers public partial class SqlCompiler { /// - protected override SqlIncludeProvider VisitInclude(IncludeProvider provider) + internal protected override SqlIncludeProvider VisitInclude(IncludeProvider provider) { var source = Compile(provider.Source); var resultQuery = ExtractSqlSelect(provider, source); diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.NotSupported.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.NotSupported.cs index 7d7c8f552..4c83940b7 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.NotSupported.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.NotSupported.cs @@ -12,19 +12,19 @@ namespace Xtensive.Orm.Providers public partial class SqlCompiler { /// - protected internal override SqlProvider VisitRaw(RawProvider provider) + internal protected override SqlProvider VisitRaw(RawProvider provider) { throw new NotSupportedException(); } /// - protected internal override SqlProvider VisitFreeText(FreeTextProvider provider) + internal protected override SqlProvider VisitFreeText(FreeTextProvider provider) { throw new NotSupportedException(); } /// - protected internal override SqlProvider VisitContainsTable(ContainsTableProvider provider) + internal protected override SqlProvider VisitContainsTable(ContainsTableProvider provider) { throw new NotSupportedException(); } diff --git a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Paging.cs b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Paging.cs index 12c9604a2..1331c63ae 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Paging.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Paging.cs @@ -160,4 +160,4 @@ private static Func BuildLimitOffsetAccessor(Func - protected override SqlStoreProvider VisitStore(StoreProvider provider) + internal protected override SqlStoreProvider VisitStore(StoreProvider provider) { var source = provider.Source is RawProvider rawProvider ? (ExecutableProvider) (new Rse.Providers.ExecutableRawProvider(rawProvider)) diff --git a/Orm/Xtensive.Orm/Orm/Rse/AggregateColumn.cs b/Orm/Xtensive.Orm/Orm/Rse/AggregateColumn.cs index 192ca9892..32823cdd1 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/AggregateColumn.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/AggregateColumn.cs @@ -39,7 +39,7 @@ public override string ToString() } /// - public override AggregateColumn Clone(int newIndex) + public override AggregateColumn Clone(ColNum newIndex) { return new AggregateColumn(this, newIndex); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/CalculatedColumn.cs b/Orm/Xtensive.Orm/Orm/Rse/CalculatedColumn.cs index d35c803d1..121a0cec8 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/CalculatedColumn.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/CalculatedColumn.cs @@ -35,7 +35,7 @@ public override string ToString() } /// - public override CalculatedColumn Clone(int newIndex) + public override CalculatedColumn Clone(ColNum newIndex) { return new CalculatedColumn(this, newIndex); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/ProviderVisitor.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/ProviderVisitor.cs index e5d851044..45d0c35e1 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/ProviderVisitor.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/ProviderVisitor.cs @@ -205,4 +205,4 @@ public abstract class ProviderVisitor /// internal protected abstract Provider VisitContainsTable(ContainsTableProvider provider); } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Rse/SystemColumn.cs b/Orm/Xtensive.Orm/Orm/Rse/SystemColumn.cs index add58dd39..9995e0796 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/SystemColumn.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/SystemColumn.cs @@ -16,7 +16,7 @@ namespace Xtensive.Orm.Rse public class SystemColumn : DerivedColumn { /// - public override SystemColumn Clone(int newIndex) + public override SystemColumn Clone(ColNum newIndex) { return new SystemColumn(this, newIndex); } diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyProviderCorrectorRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyProviderCorrectorRewriter.cs index d16ed6a45..596e00a06 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyProviderCorrectorRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/ApplyProviderCorrectorRewriter.cs @@ -196,7 +196,7 @@ internal protected override CompilableProvider VisitFilter(FilterProvider provid return predicateCollector.TryAdd(newProvider) ? source : newProvider; } - protected override AliasProvider VisitAlias(AliasProvider provider) + internal protected override AliasProvider VisitAlias(AliasProvider provider) { var source = VisitCompilable(provider.Source); var newProvider = source!=provider.Source ? new AliasProvider(source, provider.Alias) : provider; @@ -259,7 +259,7 @@ internal protected override ExceptProvider VisitExcept(ExceptProvider provider) : provider; } - protected override ConcatProvider VisitConcat(ConcatProvider provider) + internal protected override ConcatProvider VisitConcat(ConcatProvider provider) { VisitBinaryProvider(provider, out var left, out var right); return left != provider.Left || right != provider.Right @@ -275,7 +275,7 @@ internal protected override UnionProvider VisitUnion(UnionProvider provider) : provider; } - protected override AggregateProvider VisitAggregate(AggregateProvider provider) + internal protected override AggregateProvider VisitAggregate(AggregateProvider provider) { var source = VisitCompilable(provider.Source); var newProvider = provider; diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs index 1c53b05a1..b2dd2d5b4 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/Internals/OrderingRewriter.cs @@ -62,7 +62,7 @@ internal protected override CompilableProvider VisitSort(SortProvider provider) return source; } - protected override SelectProvider VisitSelect(SelectProvider provider) + internal protected override SelectProvider VisitSelect(SelectProvider provider) { var result = provider; var source = VisitCompilable(provider.Source); @@ -93,7 +93,7 @@ protected override SelectProvider VisitSelect(SelectProvider provider) return result; } - protected override AggregateProvider VisitAggregate(AggregateProvider provider) + internal protected override AggregateProvider VisitAggregate(AggregateProvider provider) { var result = provider; var source = VisitCompilable(provider.Source); @@ -118,19 +118,19 @@ protected override AggregateProvider VisitAggregate(AggregateProvider provider) return result; } - protected override IndexProvider VisitIndex(IndexProvider provider) + internal protected override IndexProvider VisitIndex(IndexProvider provider) { sortOrder = new(); return provider; } - protected override FreeTextProvider VisitFreeText(FreeTextProvider provider) + internal protected override FreeTextProvider VisitFreeText(FreeTextProvider provider) { sortOrder = new(); return provider; } - protected override ContainsTableProvider VisitContainsTable(ContainsTableProvider provider) + internal protected override ContainsTableProvider VisitContainsTable(ContainsTableProvider provider) { sortOrder = new(); return provider; @@ -142,7 +142,7 @@ internal protected override RawProvider VisitRaw(RawProvider provider) return provider; } - protected override StoreProvider VisitStore(StoreProvider provider) + internal protected override StoreProvider VisitStore(StoreProvider provider) { sortOrder = new(); return provider; From 7cf5836b6d85a83efd4b2be62d7619a3e20f7d2b Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 19 Mar 2026 14:31:32 -0700 Subject: [PATCH 42/55] Fix LeftJoinEx() --- Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs | 1 + Orm/Xtensive.Orm/Orm/Linq/WellknownMembers.Queryable.cs | 1 + Orm/Xtensive.Orm/Reflection/WellKnown.QueryableExtensions.cs | 1 + 3 files changed, 3 insertions(+) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs index ead3b3545..26f540260 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs @@ -516,6 +516,7 @@ protected override Expression VisitMethodCall(MethodCallExpression mc) // Visit Queryable extensions. if (methodDeclaringType == typeof(QueryableExtensions)) { return methodName switch { + Reflection.WellKnown.QueryableExtensions.LeftJoinEx => VisitLeftJoin(mc), Reflection.WellKnown.QueryableExtensions.LeftOuterJoin => VisitLeftJoin(mc), Reflection.WellKnown.QueryableExtensions.In => VisitIn(mc), Reflection.WellKnown.QueryableExtensions.Lock => VisitLock(mc), diff --git a/Orm/Xtensive.Orm/Orm/Linq/WellknownMembers.Queryable.cs b/Orm/Xtensive.Orm/Orm/Linq/WellknownMembers.Queryable.cs index 64454f41e..4cc5e2b8d 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/WellknownMembers.Queryable.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/WellknownMembers.Queryable.cs @@ -123,6 +123,7 @@ public static class Queryable // Queryable extensions public static readonly MethodInfo ExtensionCount = GetQueryableExtensionsMethod(nameof(QueryableExtensions.Count), 0, 1); public static readonly MethodInfo ExtensionLeftJoin = GetQueryableExtensionsMethod(nameof(QueryableExtensions.LeftOuterJoin), 4, 5); + public static readonly MethodInfo ExtensionLeftJoinEx = GetQueryableExtensionsMethod(nameof(QueryableExtensions.LeftJoinEx), 4, 5); public static readonly MethodInfo ExtensionLock = GetQueryableExtensionsMethod(nameof(QueryableExtensions.Lock), 1, 3); public static readonly MethodInfo ExtensionTake = GetQueryableExtensionsMethod(nameof(QueryableExtensions.Take), 1, 2); public static readonly MethodInfo ExtensionSkip = GetQueryableExtensionsMethod(nameof(QueryableExtensions.Skip), 1, 2); diff --git a/Orm/Xtensive.Orm/Reflection/WellKnown.QueryableExtensions.cs b/Orm/Xtensive.Orm/Reflection/WellKnown.QueryableExtensions.cs index 23dc01dd3..4345b3196 100644 --- a/Orm/Xtensive.Orm/Reflection/WellKnown.QueryableExtensions.cs +++ b/Orm/Xtensive.Orm/Reflection/WellKnown.QueryableExtensions.cs @@ -13,6 +13,7 @@ public static class QueryableExtensions { public const string Count = nameof(Orm.QueryableExtensions.Count); public const string LeftOuterJoin = nameof(Orm.QueryableExtensions.LeftOuterJoin); + public const string LeftJoinEx = nameof(Orm.QueryableExtensions.LeftJoinEx); public const string Lock = nameof(Orm.QueryableExtensions.Lock); public const string Take = nameof(Orm.QueryableExtensions.Take); public const string Skip = nameof(Orm.QueryableExtensions.Skip); From 1420121a6770117a7ae0ad66b7ba0865a1057047 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 19 Mar 2026 14:50:30 -0700 Subject: [PATCH 43/55] Fix VisitLambda --- Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs | 2 +- .../Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs index cbe224487..54ab091d3 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs @@ -136,7 +136,7 @@ protected override MemberAssignment VisitMemberAssignment(MemberAssignment ma) = /// protected override Expression VisitLambda(Expression l) => - Visit((LambdaExpression)l, l.Body, static (l, body) => FastExpression.Lambda(l.Type, body, l.Parameters)); + VisitLambda(l); protected virtual Expression VisitLambda(LambdaExpression lambda) => base.Visit(lambda); diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs index 65a145c4f..5875c58fd 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs @@ -106,6 +106,7 @@ private static void ValidateExpressionType(Expression e) private void ValidateParameter(ParameterExpression p) { if (currentParameter!=p) + throw new NotSupportedException("Outer parameter should not be accessed from nested Prefetch() call"); } @@ -135,4 +136,4 @@ private ExpressionMapBuilder() { } } -} \ No newline at end of file +} From de4d71949737c89bb25e7403b76a0e7269708ffd Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 19 Mar 2026 14:58:23 -0700 Subject: [PATCH 44/55] Fix VisitLambda --- .../Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs index 5875c58fd..b6eec38d7 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs @@ -40,7 +40,7 @@ protected override ParameterExpression VisitParameter(ParameterExpression p) return p; } - protected override LambdaExpression VisitLambda(LambdaExpression l) + protected override Expression VisitLambda(Expression l) { var oldParameter = currentParameter; currentParameter = l.Parameters.First(); From d5e438556ecb28dee84462f8d83113d0b9e60ad2 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 19 Mar 2026 15:09:27 -0700 Subject: [PATCH 45/55] Revert "Fix VisitLambda" This reverts commit de4d71949737c89bb25e7403b76a0e7269708ffd. --- .../Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs index b6eec38d7..5875c58fd 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs @@ -40,7 +40,7 @@ protected override ParameterExpression VisitParameter(ParameterExpression p) return p; } - protected override Expression VisitLambda(Expression l) + protected override LambdaExpression VisitLambda(LambdaExpression l) { var oldParameter = currentParameter; currentParameter = l.Parameters.First(); From c7991a7483b295c70b0e04abc34600b7744eba66 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 19 Mar 2026 15:17:43 -0700 Subject: [PATCH 46/55] VisitMember --- Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs | 11 +---------- .../Internals/Prefetch/Nodes/ExpressionMapBuilder.cs | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs index 54ab091d3..ae55cca38 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs @@ -105,15 +105,6 @@ protected override Expression VisitDefault(DefaultExpression d) protected override Expression VisitMember(MemberExpression m) => Visit(m, m.Expression, static (m, expression) => Expression.MakeMemberAccess(expression, m.Member)); - - protected virtual MemberExpression VisitMemberAccess(MemberExpression m) - { - Expression expression = Visit(m.Expression); - if (expression!=m.Expression) - return Expression.MakeMemberAccess(expression, m.Member); - return m; - } - /// protected override Expression VisitMethodCall(MethodCallExpression mc) { @@ -136,7 +127,7 @@ protected override MemberAssignment VisitMemberAssignment(MemberAssignment ma) = /// protected override Expression VisitLambda(Expression l) => - VisitLambda(l); + Visit((LambdaExpression)l, l.Body, static (l, body) => FastExpression.Lambda(l.Type, body, l.Parameters)); protected virtual Expression VisitLambda(LambdaExpression lambda) => base.Visit(lambda); diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs index 5875c58fd..1b068395c 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs @@ -80,7 +80,7 @@ protected override MethodCallExpression VisitMethodCall(MethodCallExpression cal return call; } - protected override MemberExpression VisitMemberAccess(MemberExpression m) + protected override MemberExpression VisitMember(MemberExpression m) { ValidateMemberAccess(m); result.RegisterChild(m.Expression, m); From 66127d5097dabbb5082cfe0154bc0f996eeb5ba6 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 19 Mar 2026 15:28:58 -0700 Subject: [PATCH 47/55] Fix build --- ...essionToSerializableExpressionConverter.cs | 8 ++--- ...alizableExpressionToExpressionConverter.cs | 4 +-- .../Orm/Building/Builders/ModelBuilder.cs | 3 +- .../Orm/Building/PrefetchActionContainer.cs | 36 +++++++++---------- Orm/Xtensive.Orm/Orm/QueryableExtensions.cs | 10 +++--- .../Orm/Upgrade/Internals/CatalogCloner.cs | 4 +-- .../Upgrade/Internals/DomainModelConverter.cs | 2 +- .../Orm/Upgrade/Model/PrimaryIndexInfo.cs | 2 +- Orm/Xtensive.Orm/Reflection/MethodHelper.cs | 2 +- .../Sql/Dml/Hints/SqlForceJoinOrderHint.cs | 2 +- 10 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ExpressionToSerializableExpressionConverter.cs b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ExpressionToSerializableExpressionConverter.cs index fa2bf0b2e..62175aba9 100644 --- a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ExpressionToSerializableExpressionConverter.cs +++ b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/ExpressionToSerializableExpressionConverter.cs @@ -223,17 +223,17 @@ private SerializableMemberBinding[] VisitMemberBindingSequence(IReadOnlyList initializers) { return initializers - .SelectToArray(initializer => new SerializableElementInit + .Select(initializer => new SerializableElementInit { AddMethod = initializer.AddMethod, Arguments = VisitExpressionSequence(initializer.Arguments) - }); + }).ToArray(); } private SerializableExpression[] VisitExpressionSequence(IList expressions) where T : Expression { - return expressions.SelectToArray(e => Visit(e)); + return expressions.Select(e => Visit(e)).ToArray(); } #endregion @@ -244,4 +244,4 @@ public ExpressionToSerializableExpressionConverter(Expression source) this.source = source; } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/SerializableExpressionToExpressionConverter.cs b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/SerializableExpressionToExpressionConverter.cs index 6330fc629..97c83e02a 100644 --- a/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/SerializableExpressionToExpressionConverter.cs +++ b/Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/SerializableExpressionToExpressionConverter.cs @@ -201,7 +201,7 @@ private Expression VisitMethodCall(SerializableMethodCallExpression mc) private Expression VisitLambda(SerializableLambdaExpression l) { - var parameters = l.Parameters.SelectToArray(p => (ParameterExpression) Visit(p)); + var parameters = l.Parameters.Select(p => (ParameterExpression) Visit(p)).ToArray(); using (CreateParameterScope(parameters)) { return FastExpression.Lambda(l.Type, Visit(l.Body), parameters); } @@ -320,4 +320,4 @@ public SerializableExpressionToExpressionConverter(SerializableExpression source parameterScopes = new Stack>(); } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Building/Builders/ModelBuilder.cs b/Orm/Xtensive.Orm/Orm/Building/Builders/ModelBuilder.cs index 12504c0de..ff8089a34 100644 --- a/Orm/Xtensive.Orm/Orm/Building/Builders/ModelBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Building/Builders/ModelBuilder.cs @@ -172,7 +172,8 @@ private void BuildPrefetchActions() foreach (var type in context.Model.Types.Entities) { var associations = type.GetOwnerAssociations() .Where(static a => a.OnOwnerRemove is OnRemoveAction.Cascade or OnRemoveAction.Clear); - if (PrefetchActionContainer.BuildPrefetchAction(type, associations) is { } action) { + var action = new PrefetchActionContainer(type).BuildPrefetchAction(associations); + if (action != null) { domain.PrefetchActionMap.Add(type, action); } } diff --git a/Orm/Xtensive.Orm/Orm/Building/PrefetchActionContainer.cs b/Orm/Xtensive.Orm/Orm/Building/PrefetchActionContainer.cs index f5b7a7a64..e8ed4e832 100644 --- a/Orm/Xtensive.Orm/Orm/Building/PrefetchActionContainer.cs +++ b/Orm/Xtensive.Orm/Orm/Building/PrefetchActionContainer.cs @@ -11,28 +11,28 @@ namespace Xtensive.Orm.Building; [Serializable] -internal static class PrefetchActionContainer +internal class PrefetchActionContainer { + private readonly TypeInfo type; + private IReadOnlyList fields; + // Returns null if associations is empty - public static Action> BuildPrefetchAction(TypeInfo type, IEnumerable associations) + public Action> BuildPrefetchAction(IEnumerable associations) { - var fields = associations.Select(static association => new PrefetchFieldDescriptor(association.OwnerField, true, false)).ToArray(); - return fields.Length > 0 - ? Prefetch - : null; + fields = associations.Select(static association => new PrefetchFieldDescriptor(association.OwnerField, true, false)) + .ToArray(); + return fields.Count > 0 ? Prefetch : null; + } - // Returns null if associations is empty - public Action> BuildPrefetchAction(IEnumerable associations) - { - fields = associations.Select(static association => new PrefetchFieldDescriptor(association.OwnerField, true, false)) - .ToArray(); - return fields.Count > 0 ? Prefetch : null; - } + private void Prefetch(SessionHandler sh, IEnumerable keys) + { + foreach (var key in keys) + sh.Prefetch(key, type, fields); + } - private void Prefetch(SessionHandler sh, IEnumerable keys) - { - foreach (var key in keys) - sh.Prefetch(key, type, fields); - } + public PrefetchActionContainer(TypeInfo type) + { + this.type = type; + fields = Array.Empty(); } } diff --git a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs index c11647e26..53600466f 100644 --- a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs @@ -369,11 +369,11 @@ public static IQueryable LeftOuterJoin(t /// Queryable is not a query. public static IQueryable LeftJoinEx(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { - ArgumentValidator.EnsureArgumentNotNull(outer, nameof(outer)); - ArgumentValidator.EnsureArgumentNotNull(inner, nameof(inner)); - ArgumentValidator.EnsureArgumentNotNull(outerKeySelector, nameof(outerKeySelector)); - ArgumentValidator.EnsureArgumentNotNull(innerKeySelector, nameof(innerKeySelector)); - ArgumentValidator.EnsureArgumentNotNull(resultSelector, nameof(resultSelector)); + ArgumentNullException.ThrowIfNull(outer); + ArgumentNullException.ThrowIfNull(inner); + ArgumentNullException.ThrowIfNull(outerKeySelector); + ArgumentNullException.ThrowIfNull(innerKeySelector); + ArgumentNullException.ThrowIfNull(resultSelector); var outerProviderType = outer.Provider.GetType(); if (outerProviderType != WellKnownOrmTypes.QueryProvider) { diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs index b310598bf..ddd06c47e 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs @@ -339,12 +339,12 @@ private void CloneTableConstraint(Table newTable, TableConstraint sourceConstrai if (sourceConstraint is UniqueConstraint uniqueConstraint) { if (sourceConstraint is PrimaryKey primaryKey) { - var columns = primaryKey.Columns.SelectToArray(c => newTable.TableColumns[c.Name]); + var columns = primaryKey.Columns.Select(c => newTable.TableColumns[c.Name]).ToArray(); var pk = newTable.CreatePrimaryKey(primaryKey.Name, columns); CopyDbName(pk, primaryKey); } else { - var columns = uniqueConstraint.Columns.SelectToArray(c => newTable.TableColumns[c.Name]); + var columns = uniqueConstraint.Columns.Select(c => newTable.TableColumns[c.Name]).ToArray(); var uc = newTable.CreateUniqueConstraint(uniqueConstraint.Name, columns); CopyDbName(uc, uniqueConstraint); } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs index c80ccfa48..e8f708193 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/DomainModelConverter.cs @@ -440,7 +440,7 @@ private static string GetPrimaryIndexColumnName(IndexInfo primaryIndex, ColumnIn private static void CreateReferenceForeignKey(TableInfo referencingTable, TableInfo referencedTable, FieldInfo referencingField, string foreignKeyName) { - var foreignColumns = referencingField.Columns.SelectToArray(column => referencingTable.Columns[column.Name]); + var foreignColumns = referencingField.Columns.Select(column => referencingTable.Columns[column.Name]).ToArray(); var foreignKey = new ForeignKeyInfo(referencingTable, foreignKeyName) { PrimaryKey = referencedTable.PrimaryIndex, OnRemoveAction = ReferentialAction.None, diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs index d8ffda7ea..49ba2aa83 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Model/PrimaryIndexInfo.cs @@ -62,7 +62,7 @@ protected override void ValidateState() ea.Execute(() => { throw new ValidationException(Strings.ExInvalidPrimaryKeyStructure, Path); }); - if (all.Zip(tableColumns, (column, tableColumn) => (column, tableColumn)).Any(p => p.Item1 != p.Item2)) + if (keys.Concat(values).Zip(tableColumns, (column, tableColumn) => (column, tableColumn)).Any(p => p.Item1 != p.Item2)) ea.Execute(() => { throw new ValidationException(Strings.ExInvalidPrimaryKeyStructure, Path); }); diff --git a/Orm/Xtensive.Orm/Reflection/MethodHelper.cs b/Orm/Xtensive.Orm/Reflection/MethodHelper.cs index 68185b18b..f1d5b0e32 100644 --- a/Orm/Xtensive.Orm/Reflection/MethodHelper.cs +++ b/Orm/Xtensive.Orm/Reflection/MethodHelper.cs @@ -108,7 +108,7 @@ public static ConstructorInfo GetConstructorEx(this Type type, BindingFlags bind } else if (parameterTypes.All(o => o is Type)) { return type.GetConstructor(bindingFlags, null, - parameterTypes.SelectToArray(o => (Type) o), null); + parameterTypes.ToArray(), null); } ConstructorInfo lastMatch = null; diff --git a/Orm/Xtensive.Orm/Sql/Dml/Hints/SqlForceJoinOrderHint.cs b/Orm/Xtensive.Orm/Sql/Dml/Hints/SqlForceJoinOrderHint.cs index 39bf90c40..6c7b89b39 100644 --- a/Orm/Xtensive.Orm/Sql/Dml/Hints/SqlForceJoinOrderHint.cs +++ b/Orm/Xtensive.Orm/Sql/Dml/Hints/SqlForceJoinOrderHint.cs @@ -19,7 +19,7 @@ public class SqlForceJoinOrderHint : SqlHint internal override SqlForceJoinOrderHint Clone(SqlNodeCloneContext context) => context.GetOrAdd(this, static (t, c) => - new SqlForceJoinOrderHint(t.tables?.SelectToArray(table => (SqlTable) table.Clone()))); + new SqlForceJoinOrderHint(t.Tables?.Select(table => (SqlTable) table.Clone()).ToArray())); public override void AcceptVisitor(ISqlVisitor visitor) { From ebd8ac958f63165d3a87369af79fa43af99af4a8 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 19 Mar 2026 17:12:59 -0700 Subject: [PATCH 48/55] Fix build --- .../Cryptography/SHA1HashingService.cs | 3 + .../Sql.Drivers.SqlServer/v13/Extractor.cs | 66 ++++++++-------- .../Upgrade/DomainUpgradeTest.cs | 2 +- .../Collections/CollectionUtils.cs | 5 +- Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs | 41 ++++------ Orm/Xtensive.Orm/Linq/ExpressionWriter.cs | 17 ---- .../Linq/Expressions/ConstructorExpression.cs | 10 +-- .../Orm/Linq/Expressions/KeyExpression.cs | 23 +----- .../ParameterizedExpressionExtensions.cs | 4 +- .../Linq/Expressions/StructureExpression.cs | 3 - .../Expressions/StructureFieldExpression.cs | 9 +-- .../Visitors/ExtendedExpressionReplacer.cs | 3 +- .../Visitors/IncludeFilterMappingGatherer.cs | 5 +- .../Materialization/ExpressionMaterializer.cs | 34 ++++---- .../Orm/Linq/Translator.Expressions.cs | 2 +- .../Orm/Linq/Translator.Materialization.cs | 27 +++---- .../Orm/Linq/Translator.Queryable.cs | 2 - .../Providers/CommandProcessing/DataReader.cs | 77 +++++++------------ .../Orm/Rse/CompilableProviderExtensions.cs | 16 +--- .../Rse/Providers/Compilable/AliasProvider.cs | 4 +- .../Providers/Compilable/ExistenceProvider.cs | 7 +- .../Transformation/ColumnMappingInspector.cs | 10 +-- .../Orm/Upgrade/Internals/CatalogCloner.cs | 8 +- .../Orm/Upgrade/UpgradingDomainBuilder.cs | 2 +- .../Sql/Compiler/Internals/JoinSequence.cs | 17 +--- 25 files changed, 138 insertions(+), 259 deletions(-) diff --git a/Extensions/Xtensive.Orm.Security/Cryptography/SHA1HashingService.cs b/Extensions/Xtensive.Orm.Security/Cryptography/SHA1HashingService.cs index f309c4884..70bedcb2a 100644 --- a/Extensions/Xtensive.Orm.Security/Cryptography/SHA1HashingService.cs +++ b/Extensions/Xtensive.Orm.Security/Cryptography/SHA1HashingService.cs @@ -15,6 +15,9 @@ namespace Xtensive.Orm.Security.Cryptography [Service(typeof (IHashingService), Singleton = true, Name = "sha1")] public class SHA1HashingService : GenericHashingService { + /// + protected override int HashSizeInBytes => 20; + /// protected override HashAlgorithm GetHashAlgorithm() => SHA1.Create(); diff --git a/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v13/Extractor.cs b/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v13/Extractor.cs index 9f5b4e5f3..8479d39fb 100644 --- a/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v13/Extractor.cs +++ b/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v13/Extractor.cs @@ -96,7 +96,7 @@ public override async Task ExtractSchemesAsync( string catalogName, string[] schemaNames, CancellationToken token = default) { var context = CreateContext(catalogName, schemaNames); - await ExtractCatalogContentsAsync(context, token).ConfigureAwait(false); + await ExtractCatalogContentsAsync(context, token).ConfigureAwaitFalse(); return context.Catalog; } @@ -117,13 +117,13 @@ protected virtual async Task ExtractCatalogContentsAsync(ExtractionContext conte { await ExtractSchemasAsync(context, token).ConfigureAwait(false); RegisterReplacements(context); - await ExtractTypesAsync(context, token).ConfigureAwait(false); - await ExtractTablesAndViewsAsync(context, token).ConfigureAwait(false); - await ExtractColumnsAsync(context, token).ConfigureAwait(false); - await ExtractIndexesAsync(context, token).ConfigureAwait(false); - await ExtractForeignKeysAsync(context, token).ConfigureAwait(false); - await ExtractFulltextIndexesAsync(context, token).ConfigureAwait(false); - await ExtractSequencesAsync(context, token).ConfigureAwait(false); + await ExtractTypesAsync(context, token).ConfigureAwaitFalse(); + await ExtractTablesAndViewsAsync(context, token).ConfigureAwaitFalse(); + await ExtractColumnsAsync(context, token).ConfigureAwaitFalse(); + await ExtractIndexesAsync(context, token).ConfigureAwaitFalse(); + await ExtractForeignKeysAsync(context, token).ConfigureAwaitFalse(); + await ExtractFulltextIndexesAsync(context, token).ConfigureAwaitFalse(); + await ExtractSequencesAsync(context, token).ConfigureAwaitFalse(); } protected virtual void RegisterReplacements(ExtractionContext context) @@ -163,9 +163,9 @@ private async Task ExtractSchemasAsync(ExtractionContext context, CancellationTo var cmd = Connection.CreateCommand(query); await using (cmd.ConfigureAwait(false)) { - var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwait(false); + var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse(); await using (reader.ConfigureAwait(false)) { - while (await reader.ReadAsync(token).ConfigureAwait(false)) { + while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { ReadSchemaData(reader, context); } } @@ -215,10 +215,10 @@ private async Task ExtractTypesAsync(ExtractionContext context, CancellationToke var query = BuildExtractTypesQuery(context); var command = Connection.CreateCommand(query); - await using (command.ConfigureAwait(false)) { - var reader = await command.ExecuteReaderAsync(token).ConfigureAwait(false); - await using (reader.ConfigureAwait(false)) { - while (await reader.ReadAsync(token).ConfigureAwait(false)) { + await using (command.ConfigureAwaitFalse()) { + var reader = await command.ExecuteReaderAsync(token).ConfigureAwaitFalse(); + await using (reader.ConfigureAwaitFalse()) { + while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { ReadTypeData(reader, context); } } @@ -285,10 +285,10 @@ private async Task ExtractTablesAndViewsAsync(ExtractionContext context, Cancell var query = BuildExtractTablesAndViewsQuery(context); var cmd = Connection.CreateCommand(query); - await using (cmd.ConfigureAwait(false)) { - var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwait(false); - await using (reader.ConfigureAwait(false)) { - while (await reader.ReadAsync(token).ConfigureAwait(false)) { + await using (cmd.ConfigureAwaitFalse()) { + var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse(); + await using (reader.ConfigureAwaitFalse()) { + while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { ReadTableOrViewData(reader, context); } } @@ -371,10 +371,10 @@ private async Task ExtractColumnsAsync(ExtractionContext context, CancellationTo var currentTableId = 0; var cmd = Connection.CreateCommand(query); ColumnResolver columnResolver = null; - await using (cmd.ConfigureAwait(false)) { - var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwait(false); - await using (reader.ConfigureAwait(false)) { - while (await reader.ReadAsync(token).ConfigureAwait(false)) { + await using (cmd.ConfigureAwaitFalse()) { + var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse(); + await using (reader.ConfigureAwaitFalse()) { + while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { ReadColumnData(context, reader, ref currentTableId, ref columnResolver); } } @@ -383,10 +383,10 @@ private async Task ExtractColumnsAsync(ExtractionContext context, CancellationTo query = BuildExtractIdentityColumnsQuery(context); cmd = Connection.CreateCommand(query); - await using (cmd.ConfigureAwait(false)) { - var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwait(false); - await using (reader.ConfigureAwait(false)) { - while (await reader.ReadAsync(token).ConfigureAwait(false)) { + await using (cmd.ConfigureAwaitFalse()) { + var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse(); + await using (reader.ConfigureAwaitFalse()) { + while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { ReadIdentityColumnData(reader, context); } } @@ -626,9 +626,9 @@ private async Task ExtractIndexesAsync(ExtractionContext context, CancellationTo UniqueConstraint uniqueConstraint = null; var cmd = Connection.CreateCommand(query); await using (cmd.ConfigureAwait(false)) { - var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwait(false); - await using (reader.ConfigureAwait(false)) { - while (await reader.ReadAsync(token).ConfigureAwait(false)) { + var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse(); + await using (reader.ConfigureAwaitFalse()) { + while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { ReadIndexColumnData(reader, context, ref tableId, spatialIndexType, ref primaryKey, ref uniqueConstraint, ref index, ref table); } @@ -736,10 +736,10 @@ private async Task ExtractForeignKeysAsync(ExtractionContext context, Cancellati ColumnResolver referencedTable = null; ForeignKey foreignKey = null; var cmd = Connection.CreateCommand(query); - await using (cmd.ConfigureAwait(false)) { - var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwait(false); - await using (reader.ConfigureAwait(false)) { - while (await reader.ReadAsync(token).ConfigureAwait(false)) { + await using (cmd.ConfigureAwaitFalse()) { + var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse(); + await using (reader.ConfigureAwaitFalse()) { + while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { ReadForeignKeyColumnData(reader, context, ref tableId, ref foreignKey, ref referencingTable, ref referencedTable); } } diff --git a/Orm/Xtensive.Orm.Tests/Upgrade/DomainUpgradeTest.cs b/Orm/Xtensive.Orm.Tests/Upgrade/DomainUpgradeTest.cs index f3c0abce5..843f0de64 100644 --- a/Orm/Xtensive.Orm.Tests/Upgrade/DomainUpgradeTest.cs +++ b/Orm/Xtensive.Orm.Tests/Upgrade/DomainUpgradeTest.cs @@ -775,7 +775,7 @@ private async Task BuildDomainAsync(int version, DomainUpgradeMode upgra var configuration = CreateConfiguration(upgradeMode, types, keyCacheSize); using (Upgrader.EnableForVersion(version, modelParts)) { - return await BuildDomainFromConfig(configuration, true).ConfigureAwait(false); + return await BuildDomainFromConfig(configuration, true).ConfigureAwaitFalse(); } } diff --git a/Orm/Xtensive.Orm/Collections/CollectionUtils.cs b/Orm/Xtensive.Orm/Collections/CollectionUtils.cs index 258e9b76c..c262a6479 100644 --- a/Orm/Xtensive.Orm/Collections/CollectionUtils.cs +++ b/Orm/Xtensive.Orm/Collections/CollectionUtils.cs @@ -41,12 +41,13 @@ public static int[] RangeToArray(int start, int count) /// /// is less than 0.-or- /// + -1 is larger than . - [Obsolete("Enumerable.Range().ToList() is several times faster")] public static List RangeToList(int start, int count) { ArgumentOutOfRangeException.ThrowIfNegative(count); var result = new List(count); - result.AddRange(Enumerable.Range(start, count).Select(i => (ColNum) i)); + for (int i = 0; i < count; ++i) { + result[i] = (ColNum)(start + i); + } return result; } diff --git a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs index 38dc4db0e..9d4614c80 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs @@ -21,7 +21,7 @@ public abstract class ExpressionVisitor(bool isCaching = false) : System.Linq.Ex { private readonly Dictionary cache = isCaching ? new() : null; - protected virtual IEnumerable VisitExpressionList(IReadOnlyList expressions) => + protected virtual IReadOnlyList VisitExpressionList(IReadOnlyList expressions) => VisitList(expressions, Visit); public override Expression Visit(Expression e) @@ -37,19 +37,6 @@ public override Expression Visit(Expression e) return result; } - protected override IReadOnlyList VisitExpressionList(IReadOnlyList expressions) - { - bool isChanged = false; - var results = new Expression[expressions.Count]; - for (int i = 0, n = expressions.Count; i < n; i++) { - var expression = expressions[i]; - var p = Visit(expression); - results[i] = p; - isChanged |= !ReferenceEquals(expression, p); - } - return isChanged ? results : expressions; - } - /// /// Visits the unknown expression. /// @@ -267,31 +254,31 @@ protected override MemberMemberBinding VisitMemberMemberBinding(MemberMemberBind /// /// The original binding list. /// Visit result. - protected virtual IEnumerable VisitBindingList(ReadOnlyCollection original) => + protected virtual IReadOnlyList VisitBindingList(ReadOnlyCollection original) => VisitList(original, VisitBinding); - public static IEnumerable VisitList(IReadOnlyList original, Func func) where T : class + public static IReadOnlyList VisitList(IReadOnlyList original, Func func) where T : class { - var results = new List(original.Count); - bool isChanged = false; for (int i = 0, n = original.Count; i < n; i++) { - var originalBinding = original[i]; - MemberBinding p = VisitBinding(originalBinding); - results.Add(p); - isChanged |= !ReferenceEquals(originalBinding, p); + var originalValue = original[i]; + if (func(originalValue) is var p && !ReferenceEquals(p, originalValue)) { + return VisitListIterator(original, func, p, i); + } } return original; } - private static IEnumerable VisitListIterator(IReadOnlyList original, Func func, T p, int pIdx) where T : class + private static IReadOnlyList VisitListIterator(IReadOnlyList original, Func func, T p, int pIdx) where T : class { + T[] result = new T[original.Count]; for (var i = 0; i < pIdx; ++i) { - yield return original[i]; + result[i] = original[i]; } - yield return p; + result[pIdx] = p; for (int i = pIdx + 1, n = original.Count; i < n; ++i) { - yield return func(original[i]); + result[i] = func(original[i]); } + return result; } /// @@ -312,7 +299,7 @@ protected virtual IReadOnlyList VisitBindingList(IReadOnlyList initializers = VisitElementInitializerList((IReadOnlyList) binding.Initializers); if (initializers!=binding.Initializers) diff --git a/Orm/Xtensive.Orm/Linq/ExpressionWriter.cs b/Orm/Xtensive.Orm/Linq/ExpressionWriter.cs index 1e0508c43..babbc4523 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionWriter.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionWriter.cs @@ -4,12 +4,9 @@ // Created by: Alexey Kochetov // Created: 2008.11.25 -using System; using System.Collections; -using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; using System.Linq.Expressions; using System.Runtime.CompilerServices; using Xtensive.Core; @@ -457,20 +454,6 @@ protected override IReadOnlyList VisitElementInitializerList(IReadO return original; } - protected override IReadOnlyList VisitExpressionList( - IReadOnlyList expressions) - { - for (int i = 0, n = expressions.Count; i < n; i++) { - Visit(expressions[i]); - if (i < n - 1) { - Write(","); - WriteLine(IndentType.Same); - } - } - - return expressions; - } - /// protected override IReadOnlyList VisitExpressionList(IReadOnlyList expressions) { diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs index 7276ff0b7..87d8c0a1f 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs @@ -67,9 +67,9 @@ public override Expression Remap(ColNum offset, Dictionary kvp.Key, kvp => GenericExpressionVisitor.Process(kvp.Value, remapper)); - var newConstructorArguments = ReferenceEquals(ConstructorArguments, Array.Empty()) + var newConstructorArguments = ConstructorArguments.Count == 0 ? ConstructorArguments - : ConstructorArguments.Select(arg => GenericExpressionVisitor.Process(arg, remapper)); + : ConstructorArguments.Select(arg => GenericExpressionVisitor.Process(arg, remapper)).ToArray(); var newNativeBindings = NativeBindings.ToDictionary(kvp => kvp.Key, kvp => GenericExpressionVisitor.Process(kvp.Value, remapper)); var result = new ConstructorExpression( Type, @@ -90,9 +90,9 @@ public override Expression Remap(ColumnMap map, Dictionary kvp.Key, kvp => GenericExpressionVisitor.Process(kvp.Value, remapper)); - var newConstructorArguments = ReferenceEquals(ConstructorArguments, Array.Empty()) + var newConstructorArguments = ConstructorArguments.Count == 0 ? ConstructorArguments - : ConstructorArguments.Select(arg => GenericExpressionVisitor.Process(arg, remapper)); + : ConstructorArguments.Select(arg => GenericExpressionVisitor.Process(arg, remapper)).ToArray(); var newNativeBindings = NativeBindings.ToDictionary(kvp => kvp.Key, kvp => GenericExpressionVisitor.Process(kvp.Value, remapper)); return new ConstructorExpression(Type, newBindings, newNativeBindings, Constructor, newConstructorArguments); } @@ -101,7 +101,7 @@ public ConstructorExpression(Type type, Dictionary bindings, Dictionary nativeBindings, ConstructorInfo constructor, - IEnumerable constructorArguments) + IReadOnlyList constructorArguments) : base(ExtendedExpressionType.Constructor, type, null, false) { Bindings = bindings ?? new Dictionary(); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/KeyExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/KeyExpression.cs index 7b21cbcf8..f7cd939a3 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/KeyExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/KeyExpression.cs @@ -32,29 +32,10 @@ public override KeyExpression Remap(ColNum offset, Dictionary processedExpressions) - { - var newMapping = new Segment(Mapping.Offset + offset, Mapping.Length); - - var fields = KeyFields.Select(Remap).ToArray(KeyFields.Count); var result = new KeyExpression(EntityType, fields, newMapping, UnderlyingProperty, OuterParameter, DefaultIfEmpty); processedExpressions.Add(this, result); return result; - - - FieldExpression Remap(FieldExpression f) - { - return (FieldExpression) f.Remap(offset, processedExpressions); - } } public override KeyExpression Remap(ColumnMap map, Dictionary processedExpressions) @@ -101,7 +82,7 @@ public override KeyExpression BindParameter( // Having this code as a separate method helps to avoid closure allocation during BindParameter call // in case processedExpressions dictionary already contains a result. - private Expression BindParameterWithNoCheck( + private KeyExpression BindParameterWithNoCheck( ParameterExpression parameter, Dictionary processedExpressions) { var fields = KeyFields.Select(BindParameter).ToArray(KeyFields.Count); @@ -133,7 +114,7 @@ public override KeyExpression RemoveOuterParameter(Dictionary processedExpressions) + private KeyExpression RemoveOuterParameterWithNoCheck(Dictionary processedExpressions) { var fields = KeyFields.Select(RemoveOuterParameter).ToArray(KeyFields.Count); var result = new KeyExpression(EntityType, fields, Mapping, UnderlyingProperty, null, DefaultIfEmpty); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ParameterizedExpressionExtensions.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ParameterizedExpressionExtensions.cs index c24082639..77297ac4b 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ParameterizedExpressionExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ParameterizedExpressionExtensions.cs @@ -18,7 +18,7 @@ internal static class ParameterizedExpressionExtensions /// Filtered results. public static IEnumerable OfAnyFieldExpression(this IEnumerable fields) { - // Faster that .OfType() + // Faster than .OfType() return fields .Where(static f => f.ExtendedType is ExtendedExpressionType.Field or ExtendedExpressionType.EntityField @@ -41,4 +41,4 @@ public static IEnumerable OfExactlyFieldExpression(this IEnumer .Cast(); } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs index eafcd489d..92eb966b0 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs @@ -28,13 +28,10 @@ internal sealed class StructureExpression : ParameterizedExpression, IPersistent private void SetFields(IReadOnlyList value) { - get => fields; - private set { fields = value; foreach (var fieldExpression in fields.OfAnyFieldExpression()) { fieldExpression.Owner = this; } - } } public override Expression Remap(ColNum offset, Dictionary processedExpressions) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureFieldExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureFieldExpression.cs index c781c3bfd..c161bbca8 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureFieldExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureFieldExpression.cs @@ -23,12 +23,9 @@ internal sealed class StructureFieldExpression : FieldExpression, private void SetFields(IReadOnlyList value) { - get => fields; - private set { - fields = value; - foreach (var fieldExpression in fields.OfAnyFieldExpression()) { - fieldExpression.Owner = this; - } + fields = value; + foreach (var fieldExpression in fields.OfAnyFieldExpression()) { + fieldExpression.Owner = this; } } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs index bc8135360..ca9df34a8 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/ExtendedExpressionReplacer.cs @@ -113,7 +113,6 @@ internal protected override ColumnExpression VisitColumnExpression(ColumnExpress internal protected override ConstructorExpression VisitConstructorExpression(ConstructorExpression expression) { - IList arguments = new List(); var bindings = new Dictionary(expression.Bindings.Count); var nativeBindings = new Dictionary(expression.NativeBindings.Count); bool recreate = false; @@ -141,7 +140,7 @@ internal protected override ConstructorExpression VisitConstructorExpression(Con bindings, nativeBindings, expression.Constructor, - arguments.Count > 0 ? arguments : Array.Empty()); + arguments); } internal protected override MarkerExpression VisitMarker(MarkerExpression expression) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs index e471cee13..7b1f8ffb9 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs @@ -37,10 +37,7 @@ public MappingEntry(LambdaExpression calculatedColumn) private static readonly IReadOnlyList CalculatedColumnParameters = [CalculatedColumnParameter]; public static void Gather(Expression filterExpression, Expression filterDataTuple, ApplyParameter filteredTuple, ArraySegment mapping) - { - var mapping = new MappingEntry[columnCount]; - System.Array.Fill(mapping, null); - + { var visitor = new IncludeFilterMappingGatherer(filterDataTuple, filteredTuple, mapping); _ = visitor.Visit(filterExpression); if (mapping.Contains(null)) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs b/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs index 3450e2592..591c0e075 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Materialization/ExpressionMaterializer.cs @@ -4,12 +4,8 @@ // Created by: Alexey Gamzov // Created: 2009.05.21 -using System; -using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; using System.Reflection; -using Xtensive.Collections; using Xtensive.Core; using Xtensive.Linq; using Xtensive.Orm.Internals; @@ -257,17 +253,17 @@ internal protected override Expression VisitStructureFieldExpression(StructureFi var mappingSequence = expression.Fields .OfExactlyFieldExpression() .OrderBy(static f => f.Field.MappingInfo.Offset) - .Select(static f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) + .Select(f => (f.Field.MappingInfo.Offset, f.Mapping.Offset)) .Distinct(); - Pair[] mappingInfo; + (ColNum, ColNum)[] mappingInfo; if (expression.Fields.Count > NumberOfItemsOnStack * 2) { mappingInfo = mappingSequence.ToArray(); } else { - Span> mappingInfoSpan = (expression.Fields.Count < NumberOfItemsOnStack) - ? stackalloc Pair[expression.Fields.Count] - : new Pair[expression.Fields.Count]; + Span<(ColNum, ColNum)> mappingInfoSpan = (expression.Fields.Count < NumberOfItemsOnStack) + ? stackalloc (ColNum, ColNum)[expression.Fields.Count] + : new (ColNum, ColNum)[expression.Fields.Count]; int actualCount = 0; foreach (var map in mappingSequence) { @@ -322,17 +318,17 @@ internal protected override Expression VisitStructureExpression(StructureExpress var mappingSequence = expression.Fields .OfExactlyFieldExpression() .OrderBy(static f => f.Field.MappingInfo.Offset) - .Select(static f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) + .Select(static f => (f.Field.MappingInfo.Offset, f.Mapping.Offset)) .Distinct(); - Pair[] mappingInfo; + (ColNum, ColNum)[] mappingInfo; if (expression.Fields.Count > NumberOfItemsOnStack * 2) { mappingInfo = mappingSequence.ToArray(); } else { - Span> mappingInfoSpan = (expression.Fields.Count < NumberOfItemsOnStack) - ? stackalloc Pair[expression.Fields.Count] - : new Pair[expression.Fields.Count]; + Span<(ColNum, ColNum)> mappingInfoSpan = (expression.Fields.Count < NumberOfItemsOnStack) + ? stackalloc (ColNum, ColNum)[expression.Fields.Count] + : new (ColNum, ColNum)[expression.Fields.Count]; int actualCount = 0; foreach (var map in mappingSequence) { @@ -402,17 +398,17 @@ private Expression CreateEntity(IEntityExpression expression, Expression tupleEx var mappingSequence = expression.Fields .OfExactlyFieldExpression() .OrderBy(static f => f.Field.MappingInfo.Offset) - .Select(static f => new Pair(f.Field.MappingInfo.Offset, f.Mapping.Offset)) + .Select(static f => (f.Field.MappingInfo.Offset, f.Mapping.Offset)) .Distinct(); - Pair[] mappingInfo; + (ColNum, ColNum)[] mappingInfo; if (expression.Fields.Count > NumberOfItemsOnStack * 4) { mappingInfo = mappingSequence.ToArray(); } else { - Span> mappingInfoSpan = (expression.Fields.Count < NumberOfItemsOnStack) - ? stackalloc Pair[expression.Fields.Count] - : new Pair[expression.Fields.Count]; + Span<(ColNum, ColNum)> mappingInfoSpan = (expression.Fields.Count < NumberOfItemsOnStack) + ? stackalloc (ColNum, ColNum)[expression.Fields.Count] + : new (ColNum, ColNum)[expression.Fields.Count]; int actualCount = 0; foreach (var map in mappingSequence) { diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs index 2491d9ffd..87b27141d 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs @@ -716,7 +716,7 @@ protected override Expression VisitNew(NewExpression newExpression) : Expression.New(newExpression.Constructor, arguments, newExpressionMembers); } - if (constructorParameters.Length != arguments.Length) + if (constructorParameters.Length != arguments.Count) throw Exceptions.InternalError(Strings.ExInvalidNumberOfParametersInNewExpression, OrmLog.Instance); var bindings = GetBindingsForConstructor(constructorParameters, arguments, newExpression); diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs index 773c820bd..5ae5186cf 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs @@ -149,22 +149,17 @@ private Materializer BuildMaterializer(ProjectionExpression projection, IReadOnl return new Materializer(projectorExpression.CachingCompile()); } - private IReadOnlyList VisitNewExpressionArguments(NewExpression n) - { private IReadOnlyList VisitNewExpressionArguments(NewExpression n, out ParameterInfo[] constructorParameters) { + constructorParameters = n.GetConstructorParameters(); var origArguments = n.Arguments; int count = origArguments.Count; - var arguments = new Expression[count]; - for (int i = 0; i < count; i++) { - constructorParameters = n.GetConstructorParameters(); - if (n.Arguments.Count == 0) { - return Array.Empty(); + if (count == 0) { + return []; } - var arguments = new Expression[n.Arguments.Count]; - var origArguments = n.Arguments; - for (int i = 0, count = origArguments.Count; i < count; i++) { + var arguments = new Expression[count]; + for (int i = 0; i < count; i++) { var argument = origArguments[i]; Expression body; @@ -174,17 +169,13 @@ private IReadOnlyList VisitNewExpressionArguments(NewExpression n, o context.RegisterPossibleQueryReuse(n.Members[i]); } } - arguments[i] = body.StripMarkers().IsProjection() + body = body.IsProjection() ? BuildSubqueryResult((ProjectionExpression) body, argument.Type) : ProcessProjectionElement(body); - } - var constructorParameters = n.GetConstructorParameters(); - for (int i = 0; i < count; i++) { var parameterType = constructorParameters[i].ParameterType; - ref var argument = ref arguments[i]; - if (argument.Type != parameterType) { - argument = Expression.Convert(argument, parameterType); - } + arguments[i] = body.Type != parameterType + ? Expression.Convert(body, parameterType) + : body; } return arguments; } diff --git a/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs b/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs index 2183996e1..d4e0ac113 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs @@ -418,8 +418,6 @@ private ProjectionExpression VisitCast(Expression source, Type targetType, Type var sourceTypeInfo = context.Model.Types[sourceType]; var map = Enumerable.Repeat((ColNum)(-1), recordSet.Header.Columns.Count).ToArray(); ColNum targetFieldIndex = 0; - - var targetFieldIndex = 0; var targetFields = targetTypeInfo.Fields.Where(f => f.IsPrimitive); foreach (var targetField in targetFields) { var sourceFieldInfo = targetType.IsInterface && sourceType.IsClass diff --git a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/DataReader.cs b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/DataReader.cs index 6bd767f9e..fe4bef7d3 100644 --- a/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/DataReader.cs +++ b/Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/DataReader.cs @@ -2,11 +2,7 @@ // This code is distributed under MIT license terms. // See the License.txt file in the project root for more information. -using System; using System.Collections; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; using Xtensive.Core; using Tuple = Xtensive.Tuples.Tuple; @@ -45,11 +41,32 @@ internal sealed class InMemoryDataReader(IEnumerable tuples) : DataReader public override void Dispose() => source.Dispose(); - public override async ValueTask DisposeAsync() => await ((IAsyncEnumerator) source).DisposeAsync().ConfigureAwaitFalse(); + /// + public async override ValueTask DisposeAsync() + { + if (source is IAsyncEnumerator asyncSource) { + // true async enumerable source + await asyncSource.DisposeAsync().ConfigureAwaitFalse(); + } + else { + // preloaded collection of elements, + // like in case of delayed query which has already been read from database + // or greedy enumeration + ((IEnumerator) source).Dispose(); + } + } public override ValueTask MoveNextAsync() => ValueTask.FromResult(MoveNext()); + } + /// + /// Creates wrapping active instance. + /// + /// instance to read data from. + /// instance + /// transforming raw database records to s. + /// to terminate operation if necessary. internal sealed class CommandDataReader(Command command, DbDataReaderAccessor accessor, CancellationToken token) : DataReader { /// @@ -61,6 +78,9 @@ internal sealed class CommandDataReader(Command command, DbDataReaderAccessor ac /// public override Tuple Current => command.ReadTupleWith(accessor); + public override ValueTask DisposeAsync() => command.DisposeAsync(); + + /// public override bool MoveNext() { @@ -90,50 +110,5 @@ public override async ValueTask MoveNextAsync() /// public override void Dispose() => command.Dispose(); - - /// - public async ValueTask DisposeAsync() - { - if (source is Command command) { - await command.DisposeAsync().ConfigureAwait(false); - } - else { - if (source is IAsyncEnumerator asyncSource) { - // true async enumerable source - await asyncSource.DisposeAsync().ConfigureAwait(false); - } - else { - // preloaded collection of elements, - // like in case of delayed query which has already been read from database - // or greedy enumeration - ((IEnumerator) source).Dispose(); - } - } - } - - /// - /// Creates wrapping enumerable collection of s. - /// - /// Collection of s to read from. - public DataReader(IEnumerable tuples) - { - source = tuples.GetEnumerator(); - accessor = null; - token = CancellationToken.None; - } - - /// - /// Creates wrapping active instance. - /// - /// instance to read data from. - /// instance - /// transforming raw database records to s. - /// to terminate operation if necessary. - public DataReader(Command command, DbDataReaderAccessor accessor, CancellationToken token) - { - source = command; - this.accessor = accessor; - this.token = token; - } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Rse/CompilableProviderExtensions.cs b/Orm/Xtensive.Orm/Orm/Rse/CompilableProviderExtensions.cs index 86c475d7c..53fcdc721 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/CompilableProviderExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/CompilableProviderExtensions.cs @@ -99,12 +99,6 @@ public static CompilableProvider OrderBy(this CompilableProvider source, Directi return new SortProvider(source, columnIndexes); } - public static CompilableProvider Alias(this CompilableProvider source, string alias) - { - ArgumentException.ThrowIfNullOrEmpty(alias); - return new AliasProvider(source, alias); - } - /// /// Applies to the given source. /// @@ -113,12 +107,6 @@ public static CompilableProvider Alias(this CompilableProvider source, string al /// instance. public static CompilableProvider Alias(this CompilableProvider source, string alias) => new AliasProvider(source, alias); - public static CompilableProvider Select(this CompilableProvider source, IReadOnlyList columnIndexes) - { - ArgumentNullException.ThrowIfNull(columnIndexes); - return new SelectProvider(source, columnIndexes); - } - /// /// Applies to the given source. /// @@ -133,7 +121,7 @@ public static CompilableProvider Select(this CompilableProvider source, IReadOnl /// Compilable provider. /// Column indexes to select from the source. /// instance. - public static CompilableProvider Select(this CompilableProvider source, IReadOnlyList columnIndexes) => new SelectProvider(source, columnIndexes); + public static CompilableProvider Select(this CompilableProvider source, IReadOnlyList columnIndexes) => new SelectProvider(source, columnIndexes); /// /// Applies to the given source. @@ -172,7 +160,7 @@ public static CompilableProvider Aggregate(this CompilableProvider recordQuery, /// Descriptors of aggregate columns. /// instance. public static CompilableProvider Aggregate(this CompilableProvider recordQuery, - int[] groupIndexes, IReadOnlyList descriptors) + ColNum[] groupIndexes, IReadOnlyList descriptors) => new AggregateProvider(recordQuery, groupIndexes, descriptors); /// diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AliasProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AliasProvider.cs index a949d867d..6341969e4 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AliasProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/AliasProvider.cs @@ -46,9 +46,9 @@ protected override string ParametersToString() public AliasProvider(CompilableProvider source, string alias) : base(ProviderType.Alias, source) { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(alias, nameof(alias)); + ArgumentException.ThrowIfNullOrEmpty(alias); Alias = alias; Initialize(); } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ExistenceProvider.cs b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ExistenceProvider.cs index 8d0c374cb..e55705306 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ExistenceProvider.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/ExistenceProvider.cs @@ -4,9 +4,6 @@ // Created by: Alexis Kochetov // Created: 2009.03.20 -using System; -using System.Diagnostics; -using Xtensive.Collections; using Xtensive.Core; using Xtensive.Reflection; using Xtensive.Tuples; @@ -45,9 +42,9 @@ protected override RecordSetHeader BuildHeader() public ExistenceProvider(CompilableProvider source, string existenceColumnName) : base(ProviderType.Existence, source) { - ArgumentValidator.EnsureArgumentNotNullOrEmpty(existenceColumnName, nameof(existenceColumnName)); + ArgumentException.ThrowIfNullOrEmpty(existenceColumnName); ExistenceColumnName = existenceColumnName; Initialize(); } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs index 72cbcb490..dcbe27fa9 100644 --- a/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs +++ b/Orm/Xtensive.Orm/Orm/Rse/Transformation/ColumnMappingInspector.cs @@ -26,7 +26,7 @@ internal abstract class ColumnMappingInspector : CompilableProviderVisitor public virtual CompilableProvider RemoveRedundantColumns() { - mappings.Add(rootProvider, Enumerable.Range(0, rootProvider.Header.Length).ToList()); + mappings.Add(rootProvider, CollectionUtils.RangeToList(0, rootProvider.Header.Length)); var visitedProvider = VisitCompilable(rootProvider); return visitedProvider != rootProvider ? visitedProvider @@ -87,25 +87,25 @@ internal protected override SelectProvider VisitSelect(SelectProvider provider) /// internal protected override FreeTextProvider VisitFreeText(FreeTextProvider provider) { - mappings[provider] = Enumerable.Range(0, provider.Header.Length).ToList(); + mappings[provider] = CollectionUtils.RangeToList(0, provider.Header.Length); return provider; } internal protected override CompilableProvider VisitContainsTable(ContainsTableProvider provider) { - mappings[provider] = Enumerable.Range(0, provider.Header.Length).ToList(); + mappings[provider] = CollectionUtils.RangeToList(0, provider.Header.Length); return provider; } internal protected override IndexProvider VisitIndex(IndexProvider provider) { - mappings[provider] = Enumerable.Range(0, provider.Header.Length).ToList(); + mappings[provider] = CollectionUtils.RangeToList(0, provider.Header.Length); return provider; } internal protected override SeekProvider VisitSeek(SeekProvider provider) { - mappings[provider] = Enumerable.Range(0, provider.Header.Length).ToList(); + mappings[provider] = CollectionUtils.RangeToList(0, provider.Header.Length); return provider; } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs index 4b575c88e..b4b232f6c 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/Internals/CatalogCloner.cs @@ -291,10 +291,10 @@ private void CloneIndex(DataTable newTable, Index sourceIndex) private DataTableColumn[] GetKeyColumns(DataTable newTable, Index sourceIndex) { if (newTable is Table table) - return sourceIndex.Columns.SelectToArray(el => table.TableColumns[el.Column.Name] as DataTableColumn); + return sourceIndex.Columns.Select(el => table.TableColumns[el.Column.Name] as DataTableColumn).ToArray(); if (newTable is View view) - return sourceIndex.Columns.SelectToArray(el => view.ViewColumns[el.Column.Name] as DataTableColumn); + return sourceIndex.Columns.Select(el => view.ViewColumns[el.Column.Name] as DataTableColumn).ToArray(); throw new ArgumentOutOfRangeException("newTable", Strings.ExUnexpectedTypeOfParameter); } @@ -302,10 +302,10 @@ private DataTableColumn[] GetKeyColumns(DataTable newTable, Index sourceIndex) private DataTableColumn[] GetNonKeyColumns(DataTable newTable, Index sourceIndex) { if (newTable is Table table) - return sourceIndex.NonkeyColumns.SelectToArray(el => table.TableColumns[el.Name] as DataTableColumn); + return sourceIndex.NonkeyColumns.Select(el => table.TableColumns[el.Name] as DataTableColumn).ToArray(); if (newTable is View view) - return sourceIndex.NonkeyColumns.SelectToArray(el => view.ViewColumns[el.Name] as DataTableColumn); + return sourceIndex.NonkeyColumns.Select(el => view.ViewColumns[el.Name] as DataTableColumn).ToArray(); throw new ArgumentOutOfRangeException("newTable", Strings.ExUnexpectedTypeOfParameter); } diff --git a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs index 797bf3049..627b4711c 100644 --- a/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs @@ -199,7 +199,7 @@ private async ValueTask CompleteUpgradeTransactionAsync(CancellationToken token) } try { - await driver.CommitTransactionAsync(null, connection, token); + await driver.CommitTransactionAsync(null, connection, token: token); } catch { // If transaction has become broken during commit its rollback leads to new exception diff --git a/Orm/Xtensive.Orm/Sql/Compiler/Internals/JoinSequence.cs b/Orm/Xtensive.Orm/Sql/Compiler/Internals/JoinSequence.cs index b021f83ff..033a3ba53 100644 --- a/Orm/Xtensive.Orm/Sql/Compiler/Internals/JoinSequence.cs +++ b/Orm/Xtensive.Orm/Sql/Compiler/Internals/JoinSequence.cs @@ -4,7 +4,6 @@ // Created by: Denis Krjuchkov // Created: 2012.05.18 -using System.Collections.Generic; using Xtensive.Sql.Dml; namespace Xtensive.Sql.Compiler @@ -42,10 +41,10 @@ public static JoinSequence Build(SqlJoinedTable root) private static void Traverse(SqlJoinedTable root, List output) { - var left = root.JoinExpression.Left; + var joinExpression = root.JoinExpression; + var left = joinExpression.Left; if (left is SqlJoinedTable joinedLeft) Traverse(joinedLeft, output); - } output.Add(joinExpression); @@ -53,15 +52,5 @@ private static void Traverse(SqlJoinedTable root, List output if (right is SqlJoinedTable joinedRight) Traverse(joinedRight, output); } - - - // Constructors - private JoinSequence(SqlTable pivot, IReadOnlyList tables, IReadOnlyList joinTypes, IReadOnlyList conditions) - { - Pivot = pivot; - Tables = tables; - JoinTypes = joinTypes; - Conditions = conditions; - } } -} \ No newline at end of file +} From bb4da2424aafa002fa2ed7be49d2c5789eb976e1 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Fri, 20 Mar 2026 10:30:21 -0700 Subject: [PATCH 49/55] Fix RangeToList() --- Orm/Xtensive.Orm/Collections/CollectionUtils.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Orm/Xtensive.Orm/Collections/CollectionUtils.cs b/Orm/Xtensive.Orm/Collections/CollectionUtils.cs index c262a6479..a154bd494 100644 --- a/Orm/Xtensive.Orm/Collections/CollectionUtils.cs +++ b/Orm/Xtensive.Orm/Collections/CollectionUtils.cs @@ -46,12 +46,14 @@ public static List RangeToList(int start, int count) ArgumentOutOfRangeException.ThrowIfNegative(count); var result = new List(count); for (int i = 0; i < count; ++i) { - result[i] = (ColNum)(start + i); + result.Add((ColNum)(start + i)); } return result; } - private static readonly IReadOnlyList[] preallocatedRanges = Enumerable.Range(0, 100).Select(len => (IReadOnlyList)Enumerable.Range(0, len).Select(i => (ColNum)i).ToArray()).ToArray(); + private static readonly IReadOnlyList[] preallocatedRanges = Enumerable.Range(0, 100) + .Select(len => (IReadOnlyList)Enumerable.Range(0, len).Select(i => (ColNum)i).ToArray()) + .ToArray(); public static IReadOnlyList ColNumRange(int count) => count < preallocatedRanges.Length ? preallocatedRanges[count] : Enumerable.Range(0, count).Select(i => (ColNum)i).ToArray(); From 446e4d8eececc6503182fc70aae7f1210974ecb7 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Fri, 20 Mar 2026 11:31:55 -0700 Subject: [PATCH 50/55] ConstructorExpression.Accept() --- Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs index 87d8c0a1f..71443d828 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/ConstructorExpression.cs @@ -97,6 +97,8 @@ public override Expression Remap(ColumnMap map, Dictionary visitor.VisitConstructorExpression(this); + public ConstructorExpression(Type type, Dictionary bindings, Dictionary nativeBindings, From a4e61a38c3fe2fb88754ea699c883a2f437fcc3a Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Fri, 20 Mar 2026 12:06:18 -0700 Subject: [PATCH 51/55] Fix VisitLambda --- Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs index 9d4614c80..47ee79aed 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs @@ -145,7 +145,7 @@ protected override MemberAssignment VisitMemberAssignment(MemberAssignment ma) = /// protected override Expression VisitLambda(Expression l) => - Visit((LambdaExpression)l, l.Body, static (l, body) => FastExpression.Lambda(l.Type, body, l.Parameters)); + VisitLambda((LambdaExpression)l); protected virtual Expression VisitLambda(LambdaExpression lambda) => base.Visit(lambda); From 1ac77e8bece99cb8f008a3a344d8f42b6d832add Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Fri, 20 Mar 2026 12:08:11 -0700 Subject: [PATCH 52/55] Revert "Fix VisitLambda" This reverts commit a4e61a38c3fe2fb88754ea699c883a2f437fcc3a. --- Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs index 47ee79aed..9d4614c80 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs @@ -145,7 +145,7 @@ protected override MemberAssignment VisitMemberAssignment(MemberAssignment ma) = /// protected override Expression VisitLambda(Expression l) => - VisitLambda((LambdaExpression)l); + Visit((LambdaExpression)l, l.Body, static (l, body) => FastExpression.Lambda(l.Type, body, l.Parameters)); protected virtual Expression VisitLambda(LambdaExpression lambda) => base.Visit(lambda); From ecb2bea9a54167e7783bddae584f265e01250286 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Fri, 20 Mar 2026 12:09:34 -0700 Subject: [PATCH 53/55] Fix VisitLambda() --- Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs | 2 +- .../Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs index 9d4614c80..59f83d65e 100644 --- a/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs +++ b/Orm/Xtensive.Orm/Linq/ExpressionVisitor.cs @@ -147,7 +147,7 @@ protected override MemberAssignment VisitMemberAssignment(MemberAssignment ma) = protected override Expression VisitLambda(Expression l) => Visit((LambdaExpression)l, l.Body, static (l, body) => FastExpression.Lambda(l.Type, body, l.Parameters)); - protected virtual Expression VisitLambda(LambdaExpression lambda) => base.Visit(lambda); + protected Expression VisitLambda(LambdaExpression lambda) => base.Visit(lambda); private TOriginal Visit(TOriginal original, TSubExpression subExpression, Func func) where TSubExpression : Expression { diff --git a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs index 1b068395c..647aafebf 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs @@ -40,7 +40,7 @@ protected override ParameterExpression VisitParameter(ParameterExpression p) return p; } - protected override LambdaExpression VisitLambda(LambdaExpression l) + protected override Expression VisitLambda(Expression l) { var oldParameter = currentParameter; currentParameter = l.Parameters.First(); From 2ec9fb8d016b38582a5548a03c9ccb2904bec390 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Fri, 20 Mar 2026 13:13:42 -0700 Subject: [PATCH 54/55] StructSimpleContainsAsyncTest() --- Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs b/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs index 92eb966b0..514cff2f0 100644 --- a/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs +++ b/Orm/Xtensive.Orm/Orm/Linq/Expressions/StructureExpression.cs @@ -135,14 +135,13 @@ public static StructureExpression CreateLocalCollectionStructure(TypeInfo typeIn var sourceFields = typeInfo.Fields; var destinationFields = new PersistentFieldExpression[sourceFields.Count]; - var result = new StructureExpression(typeInfo, mapping); - result.SetFields(destinationFields); int i = 0; foreach (var field in sourceFields) { // Do not convert to LINQ. We intentionally avoiding closure creation here destinationFields[i++] = BuildNestedFieldExpression(field, mapping.Offset); } - + var result = new StructureExpression(typeInfo, mapping); + result.SetFields(destinationFields); return result; } From 68531c45c5c7c0e4c0c8f760edc2d4f16092dd58 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Fri, 20 Mar 2026 13:32:14 -0700 Subject: [PATCH 55/55] .ConfigureAwaitFalse() --- .../Sql.Drivers.SqlServer/v13/Extractor.cs | 24 +++++------ .../Core/Extensions/TaskExtensions.cs | 42 +++++++++---------- Orm/Xtensive.Orm/Orm/QueryEndpoint.cs | 10 ++--- 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v13/Extractor.cs b/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v13/Extractor.cs index 8479d39fb..e03c41382 100644 --- a/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v13/Extractor.cs +++ b/Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v13/Extractor.cs @@ -115,7 +115,7 @@ protected virtual void ExtractCatalogContents(ExtractionContext context) protected virtual async Task ExtractCatalogContentsAsync(ExtractionContext context, CancellationToken token) { - await ExtractSchemasAsync(context, token).ConfigureAwait(false); + await ExtractSchemasAsync(context, token).ConfigureAwaitFalse(); RegisterReplacements(context); await ExtractTypesAsync(context, token).ConfigureAwaitFalse(); await ExtractTablesAndViewsAsync(context, token).ConfigureAwaitFalse(); @@ -162,9 +162,9 @@ private async Task ExtractSchemasAsync(ExtractionContext context, CancellationTo var query = BuildExtractSchemasQuery(context); var cmd = Connection.CreateCommand(query); - await using (cmd.ConfigureAwait(false)) { + await using (cmd.ConfigureAwaitFalse()) { var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse(); - await using (reader.ConfigureAwait(false)) { + await using (reader.ConfigureAwaitFalse()) { while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { ReadSchemaData(reader, context); } @@ -625,7 +625,7 @@ private async Task ExtractIndexesAsync(ExtractionContext context, CancellationTo PrimaryKey primaryKey = null; UniqueConstraint uniqueConstraint = null; var cmd = Connection.CreateCommand(query); - await using (cmd.ConfigureAwait(false)) { + await using (cmd.ConfigureAwaitFalse()) { var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse(); await using (reader.ConfigureAwaitFalse()) { while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { @@ -812,10 +812,10 @@ protected virtual async Task ExtractFulltextIndexesAsync(ExtractionContext conte ColumnResolver table = null; FullTextIndex index = null; var cmd = Connection.CreateCommand(query); - await using (cmd.ConfigureAwait(false)) { - var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwait(false); - await using (reader.ConfigureAwait(false)) { - while (await reader.ReadAsync(token).ConfigureAwait(false)) { + await using (cmd.ConfigureAwaitFalse()) { + var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse(); + await using (reader.ConfigureAwaitFalse()) { + while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { ReadFullTextIndexColumnData(reader, context, ref currentTableId, ref table, ref index); } } @@ -999,10 +999,10 @@ private async Task ExtractSequencesAsync(ExtractionContext context, Cancellation var query = BuildExtractSequencesQuery(context); var cmd = Connection.CreateCommand(query); - await using (cmd.ConfigureAwait(false)) { - var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwait(false); - await using (reader.ConfigureAwait(false)) { - while (await reader.ReadAsync(token).ConfigureAwait(false)) { + await using (cmd.ConfigureAwaitFalse()) { + var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse(); + await using (reader.ConfigureAwaitFalse()) { + while (await reader.ReadAsync(token).ConfigureAwaitFalse()) { ReadSequenceData(reader, context); } } diff --git a/Orm/Xtensive.Orm/Core/Extensions/TaskExtensions.cs b/Orm/Xtensive.Orm/Core/Extensions/TaskExtensions.cs index 56f914768..d592011f0 100644 --- a/Orm/Xtensive.Orm/Core/Extensions/TaskExtensions.cs +++ b/Orm/Xtensive.Orm/Core/Extensions/TaskExtensions.cs @@ -1,30 +1,26 @@ -using System; -using System.Collections.Generic; using System.Runtime.CompilerServices; -using System.Threading.Tasks; -namespace Xtensive.Core +namespace Xtensive.Core; + +public static class TaskExtensions { - public static class TaskExtensions - { #if DO_CONFIGURE_AWAIT_FALSE - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredTaskAwaitable ConfigureAwaitFalse(this Task task) => task.ConfigureAwait(false); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredTaskAwaitable ConfigureAwaitFalse(this Task task) => task.ConfigureAwait(false); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredValueTaskAwaitable ConfigureAwaitFalse(this ValueTask task) => task.ConfigureAwait(false); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredValueTaskAwaitable ConfigureAwaitFalse(this ValueTask task) => task.ConfigureAwait(false); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredAsyncDisposable ConfigureAwaitFalse(this IAsyncDisposable source) => source.ConfigureAwait(false); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredCancelableAsyncEnumerable ConfigureAwaitFalse(this IAsyncEnumerable source) => source.ConfigureAwait(false); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredAsyncDisposable ConfigureAwaitFalse(this T source) where T: struct, IAsyncDisposable => source.ConfigureAwait(false);; - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredCancelableAsyncEnumerable ConfigureAwaitFalse(this ConfiguredCancelableAsyncEnumerable source) => source.ConfigureAwait(false); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredTaskAwaitable ConfigureAwaitFalse(this Task task) => task.ConfigureAwait(false); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredTaskAwaitable ConfigureAwaitFalse(this Task task) => task.ConfigureAwait(false); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredValueTaskAwaitable ConfigureAwaitFalse(this ValueTask task) => task.ConfigureAwait(false); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredValueTaskAwaitable ConfigureAwaitFalse(this ValueTask task) => task.ConfigureAwait(false); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredAsyncDisposable ConfigureAwaitFalse(this IAsyncDisposable source) => source.ConfigureAwait(false); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredCancelableAsyncEnumerable ConfigureAwaitFalse(this IAsyncEnumerable source) => source.ConfigureAwait(false); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredAsyncDisposable ConfigureAwaitFalse(this T source) where T: struct, IAsyncDisposable => source.ConfigureAwait(false);; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredCancelableAsyncEnumerable ConfigureAwaitFalse(this ConfiguredCancelableAsyncEnumerable source) => source.ConfigureAwait(false); #else - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Task ConfigureAwaitFalse(this Task task) => task; - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Task ConfigureAwaitFalse(this Task task) => task; - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ValueTask ConfigureAwaitFalse(this ValueTask task) => task; - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ValueTask ConfigureAwaitFalse(this ValueTask task) => task; - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IAsyncDisposable ConfigureAwaitFalse(this IAsyncDisposable source) => source; - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IAsyncEnumerable ConfigureAwaitFalse(this IAsyncEnumerable source) => source; - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T ConfigureAwaitFalse(this T source) where T: struct, IAsyncDisposable => source; - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredCancelableAsyncEnumerable ConfigureAwaitFalse(this ConfiguredCancelableAsyncEnumerable source) => source; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Task ConfigureAwaitFalse(this Task task) => task; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Task ConfigureAwaitFalse(this Task task) => task; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ValueTask ConfigureAwaitFalse(this ValueTask task) => task; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ValueTask ConfigureAwaitFalse(this ValueTask task) => task; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IAsyncDisposable ConfigureAwaitFalse(this IAsyncDisposable source) => source; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IAsyncEnumerable ConfigureAwaitFalse(this IAsyncEnumerable source) => source; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T ConfigureAwaitFalse(this T source) where T: struct, IAsyncDisposable => source; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredCancelableAsyncEnumerable ConfigureAwaitFalse(this ConfiguredCancelableAsyncEnumerable source) => source; #endif - } } diff --git a/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs b/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs index 134f67a75..aa1c13bc8 100644 --- a/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs +++ b/Orm/Xtensive.Orm/Orm/QueryEndpoint.cs @@ -290,7 +290,7 @@ public async ValueTask SingleAsync(Key key, CancellationToken token = de { if (key == null) return null; - var result = await SingleOrDefaultAsync(key, token).ConfigureAwait(false); + var result = await SingleOrDefaultAsync(key, token).ConfigureAwaitFalse(); if (result == null) throw new KeyNotFoundException(string.Format( Strings.EntityWithKeyXDoesNotExist, key)); @@ -338,7 +338,7 @@ private async ValueTask SingleOrDefaultInternal(Key key, bool isAsync, C } state = (isAsync) - ? await Session.Handler.FetchEntityStateAsync(key, token).ConfigureAwait(false) + ? await Session.Handler.FetchEntityStateAsync(key, token).ConfigureAwaitFalse() : Session.Handler.FetchEntityState(key); } else if (state.Tuple == null) { @@ -347,7 +347,7 @@ private async ValueTask SingleOrDefaultInternal(Key key, bool isAsync, C if (stateKeyType != keyType && !stateKeyType.IsAssignableFrom(keyType)) { Session.RemoveStateFromCache(state.Key, true); state = (isAsync) - ? await Session.Handler.FetchEntityStateAsync(key, token).ConfigureAwait(false) + ? await Session.Handler.FetchEntityStateAsync(key, token).ConfigureAwaitFalse() : Session.Handler.FetchEntityState(key); } } @@ -426,7 +426,7 @@ public T Single(params object[] keyValues) public async Task SingleAsync(object[] keyValues, CancellationToken token = default) where T : class, IEntity { - return (T) (object) (await SingleAsync(GetKeyByValues(keyValues), token).ConfigureAwait(false)); + return (T) (object) (await SingleAsync(GetKeyByValues(keyValues), token).ConfigureAwaitFalse()); } /// @@ -460,7 +460,7 @@ public T SingleOrDefault(Key key) public async Task SingleOrDefaultAsync(Key key, CancellationToken token = default) where T : class, IEntity { - return (T) (object) (await SingleOrDefaultAsync(key, token).ConfigureAwait(false)); + return (T) (object) (await SingleOrDefaultAsync(key, token).ConfigureAwaitFalse()); } ///