Skip to content

Commit

Permalink
Cleanup #9
Browse files Browse the repository at this point in the history
  • Loading branch information
viceroypenguin committed May 20, 2024
1 parent 8ac4558 commit 1f59841
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Source/LinqToDB/DataProvider/AssemblyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace LinqToDB.DataProvider
{
using LinqToDB.Common;
using Common;

sealed class AssemblyResolver
{
Expand Down
5 changes: 2 additions & 3 deletions Source/LinqToDB/DataProvider/DataProviderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Data;
using System.Data.Common;
using System.Data.Linq;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq.Expressions;
Expand All @@ -19,11 +18,11 @@ namespace LinqToDB.DataProvider
using Common.Internal;
using Data;
using Expressions;
using Infrastructure;
using Linq.Translation;
using Mapping;
using SchemaProvider;
using SqlProvider;
using Linq.Translation;
using Infrastructure;

public abstract class DataProviderBase : IDataProvider, IInfrastructure<IServiceProvider>
{
Expand Down
3 changes: 1 addition & 2 deletions Source/LinqToDB/DataProvider/DynamicDataProviderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

namespace LinqToDB.DataProvider
{
using Common;
using Data.RetryPolicy;
using Extensions;
using Interceptors;
using Mapping;
using Tools;
using Interceptors;

public abstract class DynamicDataProviderBase<TProviderMappings> : DataProviderBase
where TProviderMappings : IDynamicProviderAdapter
Expand Down
2 changes: 1 addition & 1 deletion Source/LinqToDB/DataProvider/MultipleRowsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

namespace LinqToDB.DataProvider
{
using Common;
using Data;
using Extensions;
using Mapping;
using SqlProvider;
using SqlQuery;
using Common;

public class MultipleRowsHelper<T> : MultipleRowsHelper
where T : notnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

namespace LinqToDB.Expressions
{
using Common.Internal;
using Common;
using Common.Internal;
using Extensions;
using Interceptors;
using Linq;
Expand Down
4 changes: 3 additions & 1 deletion Source/LinqToDB/Expressions/DefaultValueExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public override int GetHashCode()
{
unchecked
{
return ((_mappingSchema != null ? _mappingSchema.GetHashCode() : 0) * 397) ^ _type.GetHashCode();
var hashCode = _mappingSchema?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ _type.GetHashCode();
return hashCode;
}
}

Expand Down
17 changes: 7 additions & 10 deletions Source/LinqToDB/Expressions/ExpressionEqualityComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
// ReSharper disable LoopCanBeConvertedToQuery
namespace LinqToDB.Expressions
{
using Common;

using Extensions;

using Linq;

using LinqToDB.Reflection;
using Reflection;

/// <summary>
/// This API supports the linq2db infrastructure and is not intended to be used
Expand Down Expand Up @@ -119,7 +115,8 @@ public int GetHashCode(Expression? obj)
var constantExpression = (ConstantExpression)obj;

if (constantExpression.Value != null
&& !(constantExpression.Value is IQueryable) && !(constantExpression.Value is not string && constantExpression.Value is IEnumerable))
&& constantExpression.Value is not IQueryable
&& (constantExpression.Value is string or not IEnumerable))
{
hashCode += (hashCode * 397) ^ constantExpression.Value.GetHashCode();
}
Expand Down Expand Up @@ -478,10 +475,10 @@ bool CompareIndex(IndexExpression a, IndexExpression b)

bool CompareSwitch(SwitchExpression a, SwitchExpression b)
{
if (! (Equals(a.SwitchValue, b.SwitchValue) &&
Equals(a.DefaultBody, b.DefaultBody) &&
Equals(a.Comparison, b.Comparison) &&
a.Cases.Count != b.Cases.Count))
if (! (Equals(a.SwitchValue, b.SwitchValue)
&& Equals(a.DefaultBody, b.DefaultBody)
&& Equals(a.Comparison, b.Comparison)
&& a.Cases.Count != b.Cases.Count))
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/LinqToDB/Expressions/ExpressionEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace LinqToDB.Expressions
{
using Extensions;
using Common;
using Extensions;

/// <summary>
/// Internal API.
Expand Down
2 changes: 0 additions & 2 deletions Source/LinqToDB/Expressions/ExpressionPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

namespace LinqToDB.Expressions
{
using System.Globalization;

using Common;
using Infrastructure;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

namespace LinqToDB.Expressions
{
using Mapping;
using Extensions;
using Mapping;

static class EqualsToVisitor
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace LinqToDB.Expressions
{
using LinqToDB.Linq;
using Linq;

// PathVisitor cannot be shared/reused due to _visited state field
internal sealed class PathVisitor<TContext>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,23 @@ private void VisitXE(Expression expr)
{
Visit(generic.Assignments.Select(a => a.Expression));
Visit(generic.Parameters.Select(p => p.Expression));
} else if (expr is SqlGenericParamAccessExpression paramAccess)
}
else if (expr is SqlGenericParamAccessExpression paramAccess)
{
Visit(paramAccess.Constructor);
} else if (expr is SqlReaderIsNullExpression isNullExpression)
}
else if (expr is SqlReaderIsNullExpression isNullExpression)
{
Visit(isNullExpression.Placeholder);
} else if (expr is SqlAdjustTypeExpression adjustType)
}
else if (expr is SqlAdjustTypeExpression adjustType)
{
Visit(adjustType.Expression);
}
else if (expr.CanReduce)
{
Visit(expr.Reduce());
}
}

}
}
14 changes: 10 additions & 4 deletions Source/LinqToDB/Expressions/ExpressionVisitors/VisitFuncVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,26 @@ private void VisitXE(Expression expr)
{
Visit(generic.Assignments.Select(a => a.Expression));
Visit(generic.Parameters.Select(p => p.Expression));
} else if (expr is SqlGenericParamAccessExpression paramAccess)
}
else if (expr is SqlGenericParamAccessExpression paramAccess)
{
Visit(paramAccess.Constructor);
} else if (expr is SqlReaderIsNullExpression isNullExpression)
}
else if (expr is SqlReaderIsNullExpression isNullExpression)
{
Visit(isNullExpression.Placeholder);
} else if (expr is SqlAdjustTypeExpression adjustType)
}
else if (expr is SqlAdjustTypeExpression adjustType)
{
Visit(adjustType.Expression);
} else if (expr is SqlPathExpression keyHolder)
}
else if (expr is SqlPathExpression keyHolder)
{
}
else if (expr.CanReduce)
{
Visit(expr.Reduce());
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion Source/LinqToDB/Expressions/TypeMapper/TypeWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace LinqToDB.Expressions
{
using LinqToDB.Common;
using Common;

/// <summary>
/// Implements base class for typed wrappers over provider-specific type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace LinqToDB.Expressions
{
using LinqToDB.Common;
using Common;

public class ValueTaskToTaskMapper : ICustomMapper
{
Expand Down

0 comments on commit 1f59841

Please sign in to comment.