Skip to content

Commit

Permalink
Revert some uses of targeted new.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers committed Sep 9, 2022
1 parent 000ce7f commit 5508ac5
Show file tree
Hide file tree
Showing 364 changed files with 1,420 additions and 1,390 deletions.
4 changes: 2 additions & 2 deletions All.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeModifiersOrder/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeNamespaceBody/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeObjectCreationWhenTypeEvident/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeObjectCreationWhenTypeEvident/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeRedundantParentheses/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeTypeMemberModifiers/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeTypeModifiers/@EntryIndexedValue">WARNING</s:String>
Expand Down Expand Up @@ -111,7 +111,7 @@
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOREACH/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/OBJECT_CREATION_WHEN_TYPE_NOT_EVIDENT/@EntryValue">TargetTyped</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/OBJECT_CREATION_WHEN_TYPE_NOT_EVIDENT/@EntryValue">ExplicitlyTyped</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_LINQ_QUERY/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARGUMENT/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARRAY_AND_OBJECT_INITIALIZER/@EntryValue">False</s:Boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection
_sortDirection = direction;
_sortProperty = prop;
_isSorted = true;
OnListChanged(new(ListChangedType.Reset, -1));
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static DbContextOptionsBuilder UseCosmos(

((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);

cosmosOptionsAction?.Invoke(new(optionsBuilder));
cosmosOptionsAction?.Invoke(new CosmosDbContextOptionsBuilder(optionsBuilder));

return optionsBuilder;
}
Expand Down Expand Up @@ -147,7 +147,7 @@ public static DbContextOptionsBuilder UseCosmos(

((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);

cosmosOptionsAction?.Invoke(new(optionsBuilder));
cosmosOptionsAction?.Invoke(new CosmosDbContextOptionsBuilder(optionsBuilder));

return optionsBuilder;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ public static DbContextOptionsBuilder UseCosmos(

((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);

cosmosOptionsAction?.Invoke(new(optionsBuilder));
cosmosOptionsAction?.Invoke(new CosmosDbContextOptionsBuilder(optionsBuilder));

return optionsBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected virtual void ValidateSharedContainerCompatibility(

if (!containers.TryGetValue(container, out var mappedTypes))
{
mappedTypes = new();
mappedTypes = new List<IEntityType>();
containers[container] = mappedTypes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static ModelBuilder CreateModelBuilder()
{
using var serviceScope = CreateServiceScope();
using var context = serviceScope.ServiceProvider.GetRequiredService<DbContext>();
return new(ConventionSet.CreateConventionSet(context), context.GetService<ModelDependencies>());
return new ModelBuilder(ConventionSet.CreateConventionSet(context), context.GetService<ModelDependencies>());
}

private static IServiceScope CreateServiceScope()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public virtual CollectionShaperExpression Update(
Check.NotNull(innerShaper, nameof(innerShaper));

return projection != Projection || innerShaper != InnerShaper
? new(projection, innerShaper, Navigation, ElementType)
? new CollectionShaperExpression(projection, innerShaper, Navigation, ElementType)
: this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public virtual Expression Translate(SelectExpression selectExpression, Expressio
_selectExpression = selectExpression;
_clientEval = false;

_projectionMembers.Push(new());
_projectionMembers.Push(new ProjectionMember());

var result = Visit(expression);
if (result == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public CosmosQueryableMethodTranslatingExpressionVisitor(
_sqlExpressionFactory = sqlExpressionFactory;
_memberTranslatorProvider = memberTranslatorProvider;
_methodCallTranslatorProvider = methodCallTranslatorProvider;
_sqlTranslator = new(
_sqlTranslator = new CosmosSqlTranslatingExpressionVisitor(
queryCompilationContext,
_sqlExpressionFactory,
_memberTranslatorProvider,
_methodCallTranslatorProvider);
_projectionBindingExpressionVisitor =
new(_queryCompilationContext.Model, _sqlTranslator);
new CosmosProjectionBindingExpressionVisitor(_queryCompilationContext.Model, _sqlTranslator);
}

/// <summary>
Expand All @@ -61,13 +61,13 @@ protected CosmosQueryableMethodTranslatingExpressionVisitor(
{
_queryCompilationContext = parentVisitor._queryCompilationContext;
_sqlExpressionFactory = parentVisitor._sqlExpressionFactory;
_sqlTranslator = new(
_sqlTranslator = new CosmosSqlTranslatingExpressionVisitor(
QueryCompilationContext,
_sqlExpressionFactory,
_memberTranslatorProvider,
_methodCallTranslatorProvider);
_projectionBindingExpressionVisitor =
new(_queryCompilationContext.Model, _sqlTranslator);
new CosmosProjectionBindingExpressionVisitor(_queryCompilationContext.Model, _sqlTranslator);
}

/// <summary>
Expand Down Expand Up @@ -271,7 +271,7 @@ protected override ShapedQueryExpression TranslateAverage(ShapedQueryExpression
source = TranslateSelect(source, selector);
}

var projection = (SqlExpression)selectExpression.GetMappedProjection(new());
var projection = (SqlExpression)selectExpression.GetMappedProjection(new ProjectionMember());
projection = _sqlExpressionFactory.Function(
"AVG", new[] { projection }, projection.Type, projection.TypeMapping);

Expand Down Expand Up @@ -575,7 +575,7 @@ protected override ShapedQueryExpression TranslateMax(ShapedQueryExpression sour
source = TranslateSelect(source, selector);
}

var projection = (SqlExpression)selectExpression.GetMappedProjection(new());
var projection = (SqlExpression)selectExpression.GetMappedProjection(new ProjectionMember());

projection = _sqlExpressionFactory.Function("MAX", new[] { projection }, resultType, projection.TypeMapping);

Expand Down Expand Up @@ -603,7 +603,7 @@ protected override ShapedQueryExpression TranslateMin(ShapedQueryExpression sour
source = TranslateSelect(source, selector);
}

var projection = (SqlExpression)selectExpression.GetMappedProjection(new());
var projection = (SqlExpression)selectExpression.GetMappedProjection(new ProjectionMember());

projection = _sqlExpressionFactory.Function("MIN", new[] { projection }, resultType, projection.TypeMapping);

Expand Down Expand Up @@ -682,7 +682,7 @@ protected override ShapedQueryExpression TranslateOrderBy(
var translation = TranslateLambdaExpression(source, keySelector);
if (translation != null)
{
((SelectExpression)source.QueryExpression).ApplyOrdering(new(translation, ascending));
((SelectExpression)source.QueryExpression).ApplyOrdering(new OrderingExpression(translation, ascending));

return source;
}
Expand Down Expand Up @@ -841,7 +841,7 @@ protected override ShapedQueryExpression TranslateSum(ShapedQueryExpression sour
}

var serverOutputType = resultType.UnwrapNullableType();
var projection = (SqlExpression)selectExpression.GetMappedProjection(new());
var projection = (SqlExpression)selectExpression.GetMappedProjection(new ProjectionMember());

projection = _sqlExpressionFactory.Function(
"SUM", new[] { projection }, serverOutputType, projection.TypeMapping);
Expand Down Expand Up @@ -895,7 +895,7 @@ protected override ShapedQueryExpression TranslateThenBy(ShapedQueryExpression s
var translation = TranslateLambdaExpression(source, keySelector);
if (translation != null)
{
((SelectExpression)source.QueryExpression).AppendOrdering(new(translation, ascending));
((SelectExpression)source.QueryExpression).AppendOrdering(new OrderingExpression(translation, ascending));

return source;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private BlockExpression AddIncludes(BlockExpression shaperBlock)
shaperExpressions.RemoveAt(shaperExpressions.Count - 1);

var includesToProcess = _pendingIncludes;
_pendingIncludes = new();
_pendingIncludes = new List<IncludeExpression>();

foreach (var include in includesToProcess)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public CosmosSqlTranslatingExpressionVisitor(
_sqlExpressionFactory = sqlExpressionFactory;
_memberTranslatorProvider = memberTranslatorProvider;
_methodCallTranslatorProvider = methodCallTranslatorProvider;
_sqlVerifyingExpressionVisitor = new();
_sqlVerifyingExpressionVisitor = new SqlTypeMappingVerifyingExpressionVisitor();
}

/// <summary>
Expand Down Expand Up @@ -1064,7 +1064,7 @@ public Expression Convert(Type type)
=> type == typeof(object) // Ignore object conversion
|| type.IsAssignableFrom(Type) // Ignore conversion to base/interface
? this
: new(ParameterEntity, type);
: new EntityReferenceExpression(ParameterEntity, type);
}

private sealed class SqlTypeMappingVerifyingExpressionVisitor : ExpressionVisitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
public virtual Expression Update(Expression accessExpression)
=> accessExpression != AccessExpression
? new(EntityType, accessExpression)
? new EntityProjectionExpression(EntityType, accessExpression)
: this;

/// <summary>
Expand Down Expand Up @@ -236,7 +236,7 @@ public virtual EntityProjectionExpression UpdateEntityType(IEntityType derivedTy
derivedType.DisplayName(), EntityType.DisplayName()));
}

return new(derivedType, AccessExpression);
return new EntityProjectionExpression(derivedType, AccessExpression);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/FromSqlExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override string Alias
/// </summary>
public virtual FromSqlExpression Update(Expression arguments)
=> arguments != Arguments
? new(EntityType, Alias, Sql, arguments)
? new FromSqlExpression(EntityType, Alias, Sql, arguments)
: this;

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
var argument = visitor.Visit(Argument);

return argument != Argument
? new(EntityType, Sql, argument)
? new FromSqlQueryRootExpression(EntityType, Sql, argument)
: this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/InExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public virtual InExpression Negate()
/// </summary>
public virtual InExpression Update(SqlExpression item, SqlExpression values)
=> item != Item || values != Values
? new(item, IsNegated, values, TypeMapping!)
? new InExpression(item, IsNegated, values, TypeMapping!)
: this;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
public virtual KeyAccessExpression Update(Expression outerExpression)
=> outerExpression != AccessExpression
? new(Property, outerExpression)
? new KeyAccessExpression(Property, outerExpression)
: this;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
public virtual ObjectAccessExpression Update(Expression outerExpression)
=> outerExpression != AccessExpression
? new(Navigation, outerExpression)
? new ObjectAccessExpression(Navigation, outerExpression)
: this;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public virtual ObjectArrayProjectionExpression Update(
Expression accessExpression,
EntityProjectionExpression innerProjection)
=> accessExpression != AccessExpression || innerProjection != InnerProjection
? new(Navigation, accessExpression, innerProjection)
? new ObjectArrayProjectionExpression(Navigation, accessExpression, innerProjection)
: this;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/OrderingExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
public virtual OrderingExpression Update(SqlExpression expression)
=> expression != Expression
? new(expression, IsAscending)
? new OrderingExpression(expression, IsAscending)
: this;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
public virtual ProjectionExpression Update(Expression expression)
=> expression != Expression
? new(expression, Alias)
? new ProjectionExpression(expression, Alias)
: this;

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public virtual CosmosSqlQuery GetSqlQuery(
{
_sqlBuilder.Clear();
_parameterValues = parameterValues;
_sqlParameters = new();
_parameterNameGenerator = new();
_sqlParameters = new List<SqlParameter>();
_parameterNameGenerator = new ParameterNameGenerator();

Visit(selectExpression);

return new(_sqlBuilder.ToString(), _sqlParameters);
return new CosmosSqlQuery(_sqlBuilder.ToString(), _sqlParameters);
}

/// <summary>
Expand Down Expand Up @@ -282,7 +282,7 @@ when _parameterValues.TryGetValue(parameterExpression.Name, out var parameterVal
for (var i = 0; i < parameterValues.Length; i++)
{
var parameterName = _parameterNameGenerator.GenerateNext();
_sqlParameters.Add(new(parameterName, parameterValues[i]));
_sqlParameters.Add(new SqlParameter(parameterName, parameterValues[i]));
substitutions[i] = parameterName;
}

Expand Down Expand Up @@ -492,7 +492,7 @@ protected override Expression VisitSqlParameter(SqlParameterExpression sqlParame
if (_sqlParameters.All(sp => sp.Name != parameterName))
{
var jToken = GenerateJToken(_parameterValues[sqlParameterExpression.Name], sqlParameterExpression.TypeMapping);
_sqlParameters.Add(new(parameterName, jToken));
_sqlParameters.Add(new SqlParameter(parameterName, jToken));
}

_sqlBuilder.Append(parameterName);
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public ReadItemExpression(
{
Container = entityType.GetContainer();

ProjectionExpression = new(
ProjectionExpression = new ProjectionExpression(
new EntityProjectionExpression(
entityType,
new RootReferenceExpression(entityType, RootAlias)),
Expand Down
12 changes: 6 additions & 6 deletions src/EFCore.Cosmos/Query/Internal/SelectExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class SelectExpression : Expression
public SelectExpression(IEntityType entityType)
{
Container = entityType.GetContainer();
FromExpression = new(entityType, RootAlias);
_projectionMapping[new()] = new EntityProjectionExpression(entityType, FromExpression);
FromExpression = new RootReferenceExpression(entityType, RootAlias);
_projectionMapping[new ProjectionMember()] = new EntityProjectionExpression(entityType, FromExpression);
}

/// <summary>
Expand All @@ -47,7 +47,7 @@ public SelectExpression(IEntityType entityType, string sql, Expression argument)
{
Container = entityType.GetContainer();
FromExpression = new FromSqlExpression(entityType, RootAlias, sql, argument);
_projectionMapping[new()] = new EntityProjectionExpression(
_projectionMapping[new ProjectionMember()] = new EntityProjectionExpression(
entityType, new RootReferenceExpression(entityType, RootAlias));
}

Expand Down Expand Up @@ -273,7 +273,7 @@ private int AddToProjection(Expression expression, string alias)
currentAlias = $"{baseAlias}{counter++}";
}

_projection.Add(new(expression, currentAlias));
_projection.Add(new ProjectionExpression(expression, currentAlias));

return _projection.Count - 1;
}
Expand Down Expand Up @@ -408,7 +408,7 @@ public virtual void ReverseOrderings()
foreach (var existingOrdering in existingOrderings)
{
_orderings.Add(
new(
new OrderingExpression(
existingOrdering.Expression,
!existingOrdering.IsAscending));
}
Expand Down Expand Up @@ -524,7 +524,7 @@ public virtual SelectExpression Update(
projectionMapping[projectionMember] = expression;
}

return new(projections, fromExpression, orderings, Container)
return new SelectExpression(projections, fromExpression, orderings, Container)
{
_projectionMapping = projectionMapping,
Predicate = predicate,
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/SqlBinaryExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
public virtual SqlBinaryExpression Update(SqlExpression left, SqlExpression right)
=> left != Left || right != Right
? new(OperatorType, left, right, Type, TypeMapping)
? new SqlBinaryExpression(OperatorType, left, right, Type, TypeMapping)
: this;

/// <summary>
Expand Down
Loading

0 comments on commit 5508ac5

Please sign in to comment.