Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public override void Visit(SqlFunctionCall node)

switch (node.FunctionType) {
case SqlFunctionType.Concat:
Visit(SqlDml.Concat(arguments.ToArray(node.Arguments.Count)));
Visit(SqlDml.Concat(arguments.ToArray()));
return;
case SqlFunctionType.DateTimeTruncate:
Visit(SqlDml.Cast(arguments[0], new SqlValueType("Date")));
Expand Down Expand Up @@ -458,4 +458,4 @@ protected internal Compiler(SqlDriver driver)
{
}
}
}
}
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm.MySql/Sql.Drivers.MySql/v5_0/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public override void Visit(SqlFunctionCall node)
SqlDml.FunctionCall("TRUNCATE", arguments[0], SqlDml.Literal(0)).AcceptVisitor(this);
return;
case SqlFunctionType.Concat:
Visit(SqlDml.Concat(arguments.ToArray(node.Arguments.Count)));
Visit(SqlDml.Concat(arguments.ToArray()));
return;
case SqlFunctionType.CharLength:
SqlDml.FunctionCall(translator.TranslateToString(SqlFunctionType.CharLength), node.Arguments[0]).AcceptVisitor(this);
Expand Down Expand Up @@ -448,4 +448,4 @@ protected internal Compiler(SqlDriver driver)
{
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override SqlProvider VisitFreeText(FreeTextProvider provider)
var query = queryAndBindings.Query;
var table = Mapping[realPrimaryIndex.ReflectedType];
var fromTable = SqlDml.FreeTextTable(table, searchCriteriaBinding.ParameterReference,
table.Columns.Select(column => column.Name).Append(rankColumnName).ToArray(table.Columns.Count + 1));
table.Columns.Select(column => column.Name).Append(rankColumnName).ToArray());
var fromTableRef = SqlDml.QueryRef(fromTable);
foreach (var column in query.Columns) {
select.Columns.Add(fromTableRef.Columns[column.Name] ?? column);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private static PreparedTemplate PrepareEnglishTemplate(string template)
}

CollectLastChunk(regexBuilder, template, offset);
return new PreparedTemplate(regexBuilder.ToString(), Enumerable.Range(1, count).ToArray(count));
return new PreparedTemplate(regexBuilder.ToString(), Enumerable.Range(1, count).ToArray());
}

private static PreparedTemplate PrepareNonEnglishTemplate(string template)
Expand Down Expand Up @@ -246,4 +246,4 @@ public ErrorMessageParser(IEnumerable<KeyValuePair<int,string>> messageTemplates
: messageTemplates.ToDictionary(item => item.Key, item => PrepareNonEnglishTemplate(item.Value));
}
}
}
}
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm/Core/AssociateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ protected AssociateProvider(SerializationInfo info, StreamingContext context)
typeSuffixes = (string[]) info.GetValue(nameof(typeSuffixes), typeof(string[]));

var highPriorityLocationsSerializable = (List<(string, string)>) info.GetValue(nameof(highPriorityLocations), typeof(List<(string, string)>));
highPriorityLocations = highPriorityLocationsSerializable.SelectToList(ls => (Assembly.Load(ls.Item1), ls.Item2));
highPriorityLocations = highPriorityLocationsSerializable.Select(ls => (Assembly.Load(ls.Item1), ls.Item2)).ToList();
}

/// <summary>
Expand Down Expand Up @@ -333,7 +333,7 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte
info.AddValue(nameof(constructorParams), constructorParamsExceptThis, constructorParams.GetType());
info.AddValue(nameof(typeSuffixes), typeSuffixes, typeSuffixes.GetType());

var highPriorityLocationsSerializable = HighPriorityLocations.SelectToList(l => (l.Item1.FullName, l.Item2));
var highPriorityLocationsSerializable = HighPriorityLocations.Select(l => (l.Item1.FullName, l.Item2)).ToList();
info.AddValue(nameof(highPriorityLocations), highPriorityLocationsSerializable, highPriorityLocationsSerializable.GetType());
}
}
Expand Down
68 changes: 0 additions & 68 deletions Orm/Xtensive.Orm/Core/Extensions/CollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ namespace Xtensive.Core
/// </summary>
public static class CollectionExtensionsEx
{
/// <summary>
/// Converts <paramref name="source"/> collection to an array.
/// </summary>
/// <typeparam name="TItem">The type of collection items.</typeparam>
/// <param name="source">Collection to convert.</param>
/// <returns>An array containing all the items from the <paramref name="source"/>.</returns>
public static TItem[] ToArray<TItem>(this ICollection<TItem> source)
{
var items = new TItem[source.Count];
source.Copy(items, 0);
return items;
}

/// <summary>
/// Copies the items from <paramref name="source"/> collection
Expand Down Expand Up @@ -139,62 +127,6 @@ public static bool ContainsAny<TItem>(this ICollection<TItem> collection, IEnume
return false;
}

/// <summary>Projects each element of a sequence into a new form.</summary>
/// <param name="source">A collection of values to invoke a transform function on.</param>
/// <param name="selector">A transform function to apply to each element.</param>
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
/// <typeparam name="TResult">The type of the value returned by <paramref name="selector" />.</typeparam>
/// <returns>An <see cref="T:System.Array`1" /> whose elements are the result of invoking the transform function on each element of <paramref name="source" />.</returns>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="source" /> or <paramref name="selector" /> is <see langword="null" />.</exception>
public static TResult[] SelectToArray<TSource, TResult>(
this ICollection<TSource> source, Func<TSource, TResult> selector)
{
return source.Select(selector).ToArray(source.Count);
}

/// <summary>Projects each element of a sequence into a new form by incorporating the element's index.</summary>
/// <param name="source">A collection of values to invoke a transform function on.</param>
/// <param name="selector">A transform function to apply to each source element; the second parameter of the function represents the index of the source element.</param>
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
/// <typeparam name="TResult">The type of the value returned by <paramref name="selector" />.</typeparam>
/// <returns>An <see cref="T:System.Array`1" /> whose elements are the result of invoking the transform function on each element of <paramref name="source" />.</returns>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="source" /> or <paramref name="selector" /> is <see langword="null" />.</exception>
public static TResult[] SelectToArray<TSource, TResult>(
this ICollection<TSource> source, Func<TSource, int, TResult> selector)
{
return source.Select(selector).ToArray(source.Count);
}

/// <summary>Projects each element of a sequence into a new form.</summary>
/// <param name="source">A collection of values to invoke a transform function on.</param>
/// <param name="selector">A transform function to apply to each element.</param>
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
/// <typeparam name="TResult">The type of the value returned by <paramref name="selector" />.</typeparam>
/// <returns>An <see cref="T:System.Collections.Generic.List`1" /> whose elements are the result of invoking the transform function on each element of <paramref name="source" />.</returns>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="source" /> or <paramref name="selector" /> is <see langword="null" />.</exception>
public static List<TResult> SelectToList<TSource, TResult>(
this ICollection<TSource> source, Func<TSource, TResult> selector)
{
return source.Select(selector).ToList(source.Count);
}

/// <summary>Projects each element of a sequence into a new form by incorporating the element's index.</summary>
/// <param name="source">A collection of values to invoke a transform function on.</param>
/// <param name="selector">A transform function to apply to each source element; the second parameter of the function represents the index of the source element.</param>
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
/// <typeparam name="TResult">The type of the value returned by <paramref name="selector" />.</typeparam>
/// <returns>An <see cref="T:System.Collections.Generic.List`1" /> whose elements are the result of invoking the transform function on each element of <paramref name="source" />.</returns>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="source" /> or <paramref name="selector" /> is <see langword="null" />.</exception>
public static List<TResult> SelectToList<TSource, TResult>(
this ICollection<TSource> source, Func<TSource, int, TResult> selector)
{
return source.Select(selector).ToList(source.Count);
}

/// <summary>
/// Projects each element of a sequence into two elements of new form and adds it to the first or the second array respectively.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public static T[] ToArraySafely<T>(this IEnumerable<T> sequence)
/// <typeparam name="T">The sequence element type.</typeparam>
/// <returns>The resulting array.</returns>
/// <exception cref="ArgumentException"><paramref name="length"/> is negative.</exception>
public static T[] ToArray<T>(this IEnumerable<T> sequence, int length)
internal static T[] ToArray<T>(this IEnumerable<T> sequence, int length)
{
ArgumentOutOfRangeException.ThrowIfNegative(length);

Expand All @@ -270,7 +270,7 @@ public static T[] ToArray<T>(this IEnumerable<T> sequence, int length)
/// <param name="capacity">The number of elements that the new list can initially store.</param>
/// <typeparam name="TItem">The type of the elements of <paramref name="source" />.</typeparam>
/// <returns>A <see cref="T:System.Collections.Generic.List`1" /> that contains elements from the input sequence.</returns>
public static List<TItem> ToList<TItem>(this IEnumerable<TItem> source, int capacity)
internal static List<TItem> ToList<TItem>(this IEnumerable<TItem> source, int capacity)
{
ArgumentOutOfRangeException.ThrowIfNegative(capacity);

Expand Down Expand Up @@ -580,7 +580,7 @@ public static List<TValue> SortTopologically<TValue>(this IEnumerable<TValue> va
if (edgeTester.Invoke(left.Value, right.Value))
new Edge(left, right);
var result = TopologicalSorter.Sort(graph);
return result.HasLoops ? null : result.SortedNodes.SelectToList(node => node.Value);
return result.HasLoops ? null : result.SortedNodes.Select(node => node.Value).ToList();
}

internal static IReadOnlyList<T> ToReadOnlyList<T>(this IEnumerable<T> seq) =>
Expand Down
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm/Modelling/Actions/CreateNodeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ protected override void PerformExecute(IModel model, IPathNode item)
protected Node TryConstructor(IModel model, params object[] arguments)
{
if (parameters!=null)
arguments = arguments.Concat(parameters.Select(p => PathNodeReference.Resolve(model, p))).ToArray(arguments.Length + parameters.Length);
var argTypes = arguments.SelectToArray(a => a.GetType());
arguments = arguments.Concat(parameters.Select(p => PathNodeReference.Resolve(model, p))).ToArray();
var argTypes = arguments.Select(a => a.GetType()).ToArray();
var ci = type.GetConstructor(argTypes);
if (ci==null)
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void BuildClassTableIndexes(TypeInfo type)
if (untypedIndexes.Contains(primaryIndex) && primaryIndex.ReflectedType == root) {
primaryIndex = type.Indexes.Single(i => i.DeclaringIndex == primaryIndex.DeclaringIndex && i.IsTyped);
}
var filterByTypes = type.AllDescendants.Append(type).ToList(type.AllDescendants.Count + 1);
var filterByTypes = type.AllDescendants.Append(type).ToList();

// Build virtual primary index
if (ancestors.Count > 0) {
Expand Down Expand Up @@ -156,4 +156,4 @@ private static bool IndexBuiltOverInheritedFields(IndexInfo index)
return false;
}
}
}
}
3 changes: 1 addition & 2 deletions Orm/Xtensive.Orm/Orm/Building/Builders/TypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ private KeyInfo BuildKeyInfo(TypeInfo root, HierarchyDef hierarchyDef)
.Select(static field => field.Column)
.ToArray();

var keyTupleDescriptor = TupleDescriptor.Create(
keyColumns.Select(static c => c.ValueType).ToArray(keyColumns.Length));
var keyTupleDescriptor = TupleDescriptor.Create(keyColumns.Select(static c => c.ValueType).ToArray());
var typeIdColumnIndex = -1;
if (hierarchyDef.IncludeTypeId) {
for (var i = 0; i < keyColumns.Length; i++) {
Expand Down
5 changes: 2 additions & 3 deletions Orm/Xtensive.Orm/Orm/EntitySetBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -941,16 +941,15 @@ private static EntitySetTypeState BuildEntitySetTypeState(FieldInfo field, Entit
.ToList()
: CollectionUtils.ColNumRange(targetDescriptor.Count);

var keyFieldCount = ownerDescriptor.Count + itemColumnOffsets.Count;
var keyFieldTypes = ownerDescriptor
.Concat(itemColumnOffsets.Select(i => targetDescriptor[i]))
.ToArray(keyFieldCount);
.ToArray();
var keyDescriptor = TupleDescriptor.Create(keyFieldTypes);

var map = Enumerable.Range(0, ownerDescriptor.Count)
.Select(i => ((ColNum)0, (ColNum) i))
.Concat(itemColumnOffsets.Select(i => ((ColNum)1, i)))
.ToArray(keyFieldCount);
.ToArray();
var seekTransform = new MapTransform(true, keyDescriptor, map);

Func<Tuple, Entity> itemCtor = null;
Expand Down
2 changes: 1 addition & 1 deletion Orm/Xtensive.Orm/Orm/Internals/KeyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private static GenericKeyFactory BuildGenericKeyFactory(TypeInfo typeInfo)
var descriptor = typeInfo.Key.TupleDescriptor;
var keyTypeName = string.Format(GenericKeyNameFormat, WellKnownOrmTypes.KeyOfT.Namespace, WellKnownOrmTypes.Key.Name, descriptor.Count);
var keyType = WellKnownOrmTypes.Key.Assembly.GetType(keyTypeName);
keyType = keyType.MakeGenericType(descriptor.ToArray(descriptor.Count));
keyType = keyType.MakeGenericType(descriptor.ToArray());
var defaultConstructor = DelegateHelper.CreateDelegate<Func<string, TypeInfo, Tuple, TypeReferenceAccuracy, Key>>(
null, keyType, "Create", Array.Empty<Type>());
var keyIndexBasedConstructor = DelegateHelper.CreateDelegate<Func<string, TypeInfo, Tuple, TypeReferenceAccuracy, IReadOnlyList<ColNum>, Key>>(
Expand Down
2 changes: 1 addition & 1 deletion Orm/Xtensive.Orm/Orm/Internals/Prefetch/EntitySetTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static CompilableProvider CreateQueryForDirectAssociation(in ItemsQueryC
AddResultColumnIndexes(resultColumns, primaryTargetIndex, 0);
var association = cachingKey.ReferencingField.Associations.Last();
var field = association.Reversed.OwnerField;
var keyColumnTypes = field.Columns.SelectToArray(column => column.ValueType);
var keyColumnTypes = field.Columns.Select(column => column.ValueType).ToArray();
return primaryTargetIndex
.GetQuery()
.Filter(QueryHelper.BuildFilterLambda(field.MappingInfo.Offset, keyColumnTypes, ownerParameter));
Expand Down
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/SetNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public IReadOnlyCollection<Key> ExtractKeys(object target)
var entity = (Entity) target;
var entitySet = (EntitySetBase) entity.GetFieldValue(Field);
var fetchedKeys = entitySet.State.FetchedKeys;
return fetchedKeys.ToArray(fetchedKeys.Count);
return fetchedKeys.ToArray();
}

public IHasNestedNodes ReplaceNestedNodes(IReadOnlyList<BaseFieldNode> nestedNodes) =>
Expand All @@ -45,4 +45,4 @@ public SetNode(string path, FieldInfo field, TypeInfo elementType, IReadOnlyList
NestedNodes = nestedNodes;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override ParameterizedExpression BindParameter(ParameterExpression parame
Bindings.ToDictionary(kvp => kvp.Key, kvp => genericBinder(kvp.Value)),
NativeBindings.ToDictionary(kvp=>kvp.Key, kvp => genericBinder(kvp.Value)),
Constructor,
ConstructorArguments.Select(genericBinder).ToArray(ConstructorArguments.Count));
ConstructorArguments.Select(genericBinder).ToArray());
}

public override Expression RemoveOuterParameter(Dictionary<Expression, Expression> processedExpressions)
Expand Down
2 changes: 1 addition & 1 deletion Orm/Xtensive.Orm/Orm/Linq/Expressions/KeyExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static KeyExpression Create(TypeInfo entityType, ColNum offset)
FieldExpression CreateField(ColumnInfo c) => FieldExpression.CreateField(c.Field, offset);

var fields = entityType.IsLocked
? entityType.Key.Columns.Select(CreateField).ToArray(entityType.Key.Columns.Count)
? entityType.Key.Columns.Select(CreateField).ToArray()
: entityType.Columns
.Where(c => c.IsPrimaryKey)
.OrderBy(c => c.Field.MappingInfo.Offset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal override Expression VisitConstructorExpression(ConstructorExpression ex
var oldConstructorArguments = expression.ConstructorArguments;
var newConstructorArguments = VisitExpressionList(oldConstructorArguments);

var oldBindings = expression.Bindings.Values.ToArray(expression.Bindings.Count);
var oldBindings = expression.Bindings.Values.ToArray();
var newBindings = VisitExpressionList(oldBindings);

var oldNativeBindings = expression.NativeBindings.Select(b => b.Value).ToArray().AsSafeWrapper();
Expand Down
2 changes: 1 addition & 1 deletion Orm/Xtensive.Orm/Orm/Linq/ItemToTupleConverter{TItem}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private Func<TItem, Tuple> BuildConverter(Expression sourceExpression)
Expression = IsPersistableType(itemType)
? BuildField(itemType, ref index, types)
: BuildLocalCollectionExpression(itemType, new HashSet<Type>(), ref index, null, types, sourceExpression);
TupleDescriptor = TupleDescriptor.Create(types.ToArray(types.Count));
TupleDescriptor = TupleDescriptor.Create(types.ToArray());

return delegate(TItem item) {
var tuple = Tuple.Create(TupleDescriptor);
Expand Down
Loading