Skip to content

Commit 49feb48

Browse files
committed
Fix issues
1 parent 6bcf939 commit 49feb48

File tree

8 files changed

+33
-31
lines changed

8 files changed

+33
-31
lines changed

Orm/Xtensive.Orm/Caching/WeakCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ public virtual bool TryGetItem(TKey key, bool markAsHit, out TItem item)
100100
/// <inheritdoc/>
101101
public void Add(TItem item) => Add(item, true);
102102

103-
private static Dictionary<TKey, GCHandle> CreateDictionary() => new Dictionary<TKey, GCHandle>();
104-
105103
/// <inheritdoc/>
106104
[SecuritySafeCritical]
107105
public virtual TItem Add(TItem item, bool replaceIfExists)
@@ -235,6 +233,8 @@ public virtual IEnumerator<TItem> GetEnumerator()
235233

236234
#region Private / internal methods
237235

236+
private static Dictionary<TKey, GCHandle> CreateDictionary() => new Dictionary<TKey, GCHandle>();
237+
238238
private void RegisterOperation(int weight)
239239
{
240240
time += weight;

Orm/Xtensive.Orm/IoC/ServiceContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Xtensive.IoC
2727
[Serializable]
2828
public class ServiceContainer : ServiceContainerBase
2929
{
30-
private static Type typeofIServiceContainer = typeof(IServiceContainer);
30+
private static readonly Type typeofIServiceContainer = typeof(IServiceContainer);
3131

3232
private readonly Dictionary<Key, List<ServiceRegistration>> types =
3333
new Dictionary<Key, List<ServiceRegistration>>();

Orm/Xtensive.Orm/IoC/ServiceRegistration.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
using System.Collections.Generic;
1010
using Xtensive.Core;
1111
using Xtensive.Reflection;
12+
using ServiceRegistrationKey = System.ValueTuple<System.Type, bool>;
1213

1314
namespace Xtensive.IoC
1415
{
15-
using ServiceRegistrationKey = ValueTuple<Type, bool>;
16-
1716
/// <summary>
1817
/// Describes single service mapping entry for <see cref="ServiceContainer"/>.
1918
/// </summary>

Orm/Xtensive.Orm/Orm/Internals/FieldAccessors/EntityFieldAccessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2008-2021 Xtensive LLC.
1+
// Copyright (C) 2008-2020 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Alexey Gamzov
@@ -54,4 +54,4 @@ public override T GetValue(Persistent obj)
5454
return (T) (object) obj.Session.Query.SingleOrDefault(key);
5555
}
5656
}
57-
}
57+
}

Orm/Xtensive.Orm/Orm/Model/TypeInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2007-2021 Xtensive LLC.
1+
// Copyright (C) 2007-2020 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Dmitri Maximov

Orm/Xtensive.Orm/Orm/Session.Cache.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ namespace Xtensive.Orm
2121
{
2222
public partial class Session
2323
{
24+
private static readonly Converter<EntityState, Key> keyExtractor = i => i.Key;
25+
2426
// EntitySets with cached items that filled their cache
2527
// within DisableSaveChanges() scope.
2628
private HashSet<EntitySetBase> entitySetsWithInvalidState;
27-
private static readonly Converter<EntityState, Key> keyExtractor = i => i.Key;
2829

2930
internal ICache<Key, EntityState> EntityStateCache { get; private set; }
3031
internal EntityChangeRegistry EntityChangeRegistry { get; private set; }

Orm/Xtensive.Orm/Reflection/AttributeHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
using System.Collections.Concurrent;
1010
using System.Linq;
1111
using System.Reflection;
12+
using AttributesKey = System.ValueTuple<System.Reflection.MemberInfo, System.Type, Xtensive.Reflection.AttributeSearchOptions>;
13+
using PerAttributeKey = System.ValueTuple<System.Reflection.MemberInfo, Xtensive.Reflection.AttributeSearchOptions>;
1214

1315
namespace Xtensive.Reflection
1416
{
15-
using AttributesKey = ValueTuple<MemberInfo, Type, AttributeSearchOptions>;
16-
using PerAttributeKey = ValueTuple<MemberInfo, AttributeSearchOptions>;
17-
1817
/// <summary>
1918
/// <see cref="Attribute"/> related helper \ extension methods.
2019
/// </summary>

Orm/Xtensive.Orm/Reflection/TypeHelper.cs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,6 @@ namespace Xtensive.Reflection
2727
/// </summary>
2828
public static class TypeHelper
2929
{
30-
private const string invokeMethodName = "Invoke";
31-
32-
private static readonly object emitLock = new object();
33-
private static readonly int NullableTypeMetadataToken = WellKnownTypes.NullableOfT.MetadataToken;
34-
private static readonly Module NullableTypeModule = WellKnownTypes.NullableOfT.Module;
35-
private static readonly Type CompilerGeneratedAttributeType = typeof(CompilerGeneratedAttribute);
36-
private static readonly string TypeHelperNamespace = typeof(TypeHelper).Namespace;
37-
38-
private static readonly ConcurrentDictionary<Type, Type[]> orderedInterfaces =
39-
new ConcurrentDictionary<Type, Type[]>();
40-
41-
private static readonly ConcurrentDictionary<Type, Type[]> orderedCompatibles =
42-
new ConcurrentDictionary<Type, Type[]>();
43-
44-
private static readonly ConcurrentDictionary<Pair<Type, Type>, InterfaceMapping> interfaceMaps =
45-
new ConcurrentDictionary<Pair<Type, Type>, InterfaceMapping>();
46-
4730
private class TypesEqualityComparer : IEqualityComparer<(Type, Type[])>
4831
{
4932
public bool Equals((Type, Type[]) x, (Type, Type[]) y) =>
@@ -59,9 +42,26 @@ public int GetHashCode((Type, Type[]) obj)
5942
}
6043
}
6144

45+
private const string invokeMethodName = "Invoke";
46+
6247
private static readonly ConcurrentDictionary<(Type, Type[]), ConstructorInfo> constructorInfoByTypes =
6348
new ConcurrentDictionary<(Type, Type[]), ConstructorInfo>(new TypesEqualityComparer());
6449

50+
private static readonly object emitLock = new object();
51+
private static readonly int NullableTypeMetadataToken = WellKnownTypes.NullableOfT.MetadataToken;
52+
private static readonly Module NullableTypeModule = WellKnownTypes.NullableOfT.Module;
53+
private static readonly Type CompilerGeneratedAttributeType = typeof(CompilerGeneratedAttribute);
54+
private static readonly string TypeHelperNamespace = typeof(TypeHelper).Namespace;
55+
56+
private static readonly ConcurrentDictionary<Type, Type[]> orderedInterfaces =
57+
new ConcurrentDictionary<Type, Type[]>();
58+
59+
private static readonly ConcurrentDictionary<Type, Type[]> orderedCompatibles =
60+
new ConcurrentDictionary<Type, Type[]>();
61+
62+
private static readonly ConcurrentDictionary<Pair<Type, Type>, InterfaceMapping> interfaceMaps =
63+
new ConcurrentDictionary<Pair<Type, Type>, InterfaceMapping>();
64+
6565
private static int createDummyTypeNumber = 0;
6666
private static AssemblyBuilder assemblyBuilder;
6767
private static ModuleBuilder moduleBuilder;
@@ -610,14 +610,17 @@ public static object Activate(this Type type, Type[] genericArguments, params ob
610610

611611
/// <summary>
612612
/// Gets the public constructor of type <paramref name="type"/>
613-
/// accepting specified <paramref name="argumentTypes"/>.
613+
/// accepting specified <paramref name="arguments"/>.
614614
/// </summary>
615615
/// <param name="type">The type to get the constructor for.</param>
616-
/// <param name="argumentTypes">The argument types.</param>
616+
/// <param name="arguments">The arguments.</param>
617617
/// <returns>
618618
/// Appropriate constructor, if a single match is found;
619619
/// otherwise, <see langword="null"/>.
620620
/// </returns>
621+
public static ConstructorInfo GetConstructor(this Type type, object[] arguments) =>
622+
GetSingleConstructor(type, arguments.Select(a => a?.GetType()).ToArray());
623+
621624
public static ConstructorInfo GetSingleConstructor(this Type type, Type[] argumentTypes) =>
622625
constructorInfoByTypes.GetOrAdd((type, argumentTypes), ConstructorExtractor);
623626

0 commit comments

Comments
 (0)