Skip to content

Commit 091d5cc

Browse files
committed
Releasing v5.2.4
1 parent 4680c82 commit 091d5cc

File tree

4 files changed

+212
-6
lines changed

4 files changed

+212
-6
lines changed

package.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22

33
<PropertyGroup>
4-
<Version>5.2.3</Version>
5-
<PackageReleaseNotes>This package is compatible with .NET 4.5, 4.6, and 4.7 frameworks.</PackageReleaseNotes>
4+
<Version>5.2.4</Version>
5+
<PackageReleaseNotes>This package is compatible with NET Standard 2.0, Net Core 2.0, .NET 4.0, 4.5, 4.6, and 4.7 frameworks.</PackageReleaseNotes>
66
</PropertyGroup>
77

88
<PropertyGroup>
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using Unity.Attributes;
4+
5+
#if NET40
6+
namespace System.Reflection
7+
{
8+
using Unity;
9+
10+
internal class TypeInfo
11+
{
12+
private const BindingFlags DeclaredOnlyLookup = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
13+
private readonly Type _type;
14+
15+
16+
internal TypeInfo(Type type)
17+
{
18+
_type = type ?? throw new ArgumentNullException(nameof(type));
19+
}
20+
21+
22+
public Assembly Assembly => _type.Assembly;
23+
24+
public bool IsGenericTypeDefinition => _type.IsGenericTypeDefinition;
25+
26+
public Type[] GenericTypeArguments => _type.GetGenericArguments();
27+
28+
public Type[] GenericTypeParameters => _type.IsGenericTypeDefinition ? _type.GetGenericArguments()
29+
: Type.EmptyTypes;
30+
public string Name => _type.Name;
31+
32+
public Type BaseType => _type.BaseType;
33+
34+
public bool IsGenericType => _type.IsGenericType;
35+
36+
public Type AsType() => _type;
37+
38+
public bool IsAssignableFrom(TypeInfo typeInfo) => _type.IsAssignableFrom(typeInfo.AsType());
39+
40+
public bool IsGenericParameter => _type.IsGenericParameter;
41+
42+
public bool IsInterface => _type.IsInterface;
43+
44+
public bool IsAbstract => _type.IsAbstract;
45+
46+
public bool IsSubclassOf(Type type) => _type.IsSubclassOf(type);
47+
48+
public bool IsValueType => _type.IsValueType;
49+
50+
public bool ContainsGenericParameters => _type.ContainsGenericParameters;
51+
52+
public bool IsConstructedGenericType => _type.IsGenericType && !_type.ContainsGenericParameters;
53+
54+
#region moved over from Type
55+
56+
//// Fields
57+
58+
public virtual EventInfo GetDeclaredEvent(String name)
59+
{
60+
return _type.GetEvent(name, DeclaredOnlyLookup);
61+
}
62+
public virtual FieldInfo GetDeclaredField(String name)
63+
{
64+
return _type.GetField(name, DeclaredOnlyLookup);
65+
}
66+
public virtual MethodInfo GetDeclaredMethod(String name)
67+
{
68+
return _type.GetMethod(name, DeclaredOnlyLookup);
69+
}
70+
71+
public virtual IEnumerable<MethodInfo> GetDeclaredMethods(String name)
72+
{
73+
foreach (MethodInfo method in _type.GetMethods(DeclaredOnlyLookup))
74+
{
75+
if (method.Name == name)
76+
yield return method;
77+
}
78+
}
79+
80+
public virtual TypeInfo GetDeclaredNestedType(String name)
81+
{
82+
var nt = _type.GetNestedType(name, DeclaredOnlyLookup);
83+
return nt == null ? null : nt.GetTypeInfo();
84+
}
85+
86+
public virtual PropertyInfo GetDeclaredProperty(String name)
87+
{
88+
return _type.GetProperty(name, DeclaredOnlyLookup);
89+
}
90+
91+
92+
//// Properties
93+
94+
public virtual IEnumerable<ConstructorInfo> DeclaredConstructors => _type.GetConstructors(DeclaredOnlyLookup);
95+
96+
public virtual IEnumerable<EventInfo> DeclaredEvents => _type.GetEvents(DeclaredOnlyLookup);
97+
98+
public virtual IEnumerable<FieldInfo> DeclaredFields => _type.GetFields(DeclaredOnlyLookup);
99+
100+
public virtual IEnumerable<MemberInfo> DeclaredMembers => _type.GetMembers(DeclaredOnlyLookup);
101+
102+
public virtual IEnumerable<MethodInfo> DeclaredMethods => _type.GetMethods(DeclaredOnlyLookup);
103+
104+
public virtual IEnumerable<TypeInfo> DeclaredNestedTypes
105+
{
106+
get
107+
{
108+
foreach (var t in _type.GetNestedTypes(DeclaredOnlyLookup))
109+
{
110+
yield return t.GetTypeInfo();
111+
}
112+
}
113+
}
114+
115+
public virtual IEnumerable<PropertyInfo> DeclaredProperties => _type.GetProperties(DeclaredOnlyLookup);
116+
117+
118+
public virtual IEnumerable<Type> ImplementedInterfaces => _type.GetInterfaces();
119+
120+
#endregion
121+
122+
public override int GetHashCode()
123+
{
124+
return _type.GetHashCode();
125+
}
126+
127+
public override bool Equals(object obj)
128+
{
129+
return _type.Equals(obj);
130+
}
131+
132+
public static bool operator ==(TypeInfo left, TypeInfo right)
133+
{
134+
return left?.GetHashCode() == right?.GetHashCode();
135+
}
136+
137+
public static bool operator !=(TypeInfo left, TypeInfo right)
138+
{
139+
return left?.GetHashCode() != right?.GetHashCode();
140+
}
141+
142+
public Type GetGenericTypeDefinition()
143+
{
144+
return _type.GetGenericTypeDefinition();
145+
}
146+
}
147+
}
148+
#endif
149+
150+
namespace Unity
151+
{
152+
using System;
153+
using System.Reflection;
154+
155+
156+
internal static class Compatibility
157+
{
158+
#if NETSTANDARD1_0
159+
public static System.Reflection.ConstructorInfo[] GetConstructors(this System.Type type)
160+
{
161+
var ctors = type.GetTypeInfo().DeclaredConstructors;
162+
return ctors is ConstructorInfo[] array ? array : ctors.ToArray();
163+
}
164+
#endif
165+
166+
#if NET40
167+
public static Attribute GetCustomAttribute(this ParameterInfo parameter, Type type)
168+
{
169+
return parameter.GetCustomAttributes(false)
170+
.OfType<DependencyResolutionAttribute>()
171+
.FirstOrDefault();
172+
}
173+
174+
public static TypeInfo GetTypeInfo(this Type type)
175+
{
176+
if (type == null)
177+
{
178+
throw new ArgumentNullException(nameof(type));
179+
}
180+
181+
return new TypeInfo(type);
182+
}
183+
184+
public static Delegate CreateDelegate(this MethodInfo method, Type delegateType)
185+
{
186+
return Delegate.CreateDelegate(delegateType, method);
187+
}
188+
189+
public static Delegate CreateDelegate(this MethodInfo method, Type delegateType, object target)
190+
{
191+
return Delegate.CreateDelegate(delegateType, target, method);
192+
}
193+
#else
194+
public static MethodInfo GetGetMethod(this PropertyInfo info, bool _)
195+
{
196+
return info.GetMethod;
197+
}
198+
199+
public static MethodInfo GetSetMethod(this PropertyInfo info, bool _)
200+
{
201+
return info.SetMethod;
202+
}
203+
#endif
204+
}
205+
}

src/Unity.Configuration.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<SignAssembly>true</SignAssembly>
2020
<AssemblyOriginatorKeyFile>package.snk</AssemblyOriginatorKeyFile>
2121
<DelaySign>false</DelaySign>
22-
<TargetFrameworks>netstandard2.0;net47;net46;net45;netcoreapp2.0</TargetFrameworks>
22+
<TargetFrameworks>netstandard2.0;net47;net46;net45;net40;netcoreapp2.0</TargetFrameworks>
2323
</PropertyGroup>
2424

2525
<ItemGroup>
@@ -41,6 +41,7 @@
4141
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
4242
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
4343
<OutputPath>$(SolutionDir)lib</OutputPath>
44+
<DebugType>Portable</DebugType>
4445
</PropertyGroup>
4546

4647
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

tests/Configuration.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
13-
<PackageReference Include="MSTest.TestAdapter" Version="1.3.0-beta2" />
14-
<PackageReference Include="MSTest.TestFramework" Version="1.3.0-beta2" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
13+
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
14+
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

0 commit comments

Comments
 (0)