Skip to content

Commit eef7aaa

Browse files
committed
Use TypeInfo reflection API
Switch to using the new TypeInfo based reflection API rather than the legacy properties on Type so that we can take advantage of newer platforms. Add a FEATURE_LEGACY_REFLECTION_API conditional symbol which provides a shim to the old reflection API.
1 parent 81c8722 commit eef7aaa

File tree

56 files changed

+249
-187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+249
-187
lines changed

README.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ xbuild /p:Configuration=NET45-Release /t:RunAllTests buildscripts/Build.proj
4040

4141
The following conditional compilation symbols (vertical) are currently defined for each of the build configurations (horizontal):
4242

43-
Symbol | NET35 | NET40 | NET45 | SL40 | SL50
44-
----------------------- | ------------------ | ------------------ | ------------------ | ------------------ | ------------------
45-
`FEATURE_SERIALIZATION` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
46-
`DOTNET35` | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign:
47-
`DOTNET40` | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
48-
`DOTNET45` | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
49-
`SILVERLIGHT` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark:
50-
`SL4` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign:
51-
`SL5` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark:
43+
Symbol | NET35 | NET40 | NET45 | SL40 | SL50
44+
------------------------------- | ------------------ | ------------------ | ------------------ | ------------------ | ------------------
45+
`FEATURE_LEGACY_REFLECTION_API` | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :white_check_mark: | :white_check_mark:
46+
`FEATURE_SERIALIZATION` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
47+
`DOTNET35` | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign:
48+
`DOTNET40` | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
49+
`DOTNET45` | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
50+
`SILVERLIGHT` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark:
51+
`SL4` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign:
52+
`SL5` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark:
5253

5354
The `__MonoCS__` symbol is used only in unit tests when compiled on Mono to work around Mono defects and non-Windows differences, however we are trying to move away from platform specific symbols as much as possible.

src/Castle.Core.Tests/Castle.Core.Tests.csproj

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<DebugSymbols>true</DebugSymbols>
2828
<DebugType>full</DebugType>
2929
<Optimize>false</Optimize>
30-
<DefineConstants>TRACE;DEBUG;DOTNET40 FEATURE_SERIALIZATION</DefineConstants>
30+
<DefineConstants>TRACE;DEBUG;DOTNET40 FEATURE_LEGACY_REFLECTION_API FEATURE_SERIALIZATION</DefineConstants>
3131
<ErrorReport>prompt</ErrorReport>
3232
<WarningLevel>4</WarningLevel>
3333
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -41,7 +41,7 @@
4141
<OutputPath>bin\NET40-Release\</OutputPath>
4242
<DebugType>pdbonly</DebugType>
4343
<Optimize>true</Optimize>
44-
<DefineConstants>TRACE;DOTNET40 FEATURE_SERIALIZATION</DefineConstants>
44+
<DefineConstants>TRACE;DOTNET40 FEATURE_LEGACY_REFLECTION_API FEATURE_SERIALIZATION</DefineConstants>
4545
<ErrorReport>prompt</ErrorReport>
4646
<WarningLevel>4</WarningLevel>
4747
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
@@ -53,7 +53,7 @@
5353
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NET35-Debug|AnyCPU'">
5454
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
5555
<OutputPath>bin\NET35-Debug\</OutputPath>
56-
<DefineConstants>TRACE;DEBUG;DOTNET35 FEATURE_SERIALIZATION</DefineConstants>
56+
<DefineConstants>TRACE;DEBUG;DOTNET35 FEATURE_LEGACY_REFLECTION_API FEATURE_SERIALIZATION</DefineConstants>
5757
<Optimize>false</Optimize>
5858
<DebugType>full</DebugType>
5959
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -65,7 +65,7 @@
6565
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NET35-Release|AnyCPU'">
6666
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
6767
<OutputPath>bin\NET35-Release\</OutputPath>
68-
<DefineConstants>TRACE;DOTNET35 FEATURE_SERIALIZATION</DefineConstants>
68+
<DefineConstants>TRACE;DOTNET35 FEATURE_LEGACY_REFLECTION_API FEATURE_SERIALIZATION</DefineConstants>
6969
<Optimize>true</Optimize>
7070
<DebugType>pdbonly</DebugType>
7171
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -78,7 +78,7 @@
7878
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'SL40-Release|AnyCPU'">
7979
<OutputPath>bin\SL40-Release\</OutputPath>
8080
<MSBuildTargets>Silverlight 4.0</MSBuildTargets>
81-
<DefineConstants>TRACE;SILVERLIGHT SL4</DefineConstants>
81+
<DefineConstants>TRACE;SILVERLIGHT SL4 FEATURE_LEGACY_REFLECTION_API</DefineConstants>
8282
<Optimize>true</Optimize>
8383
<DebugType>pdbonly</DebugType>
8484
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -93,7 +93,7 @@
9393
<DebugSymbols>true</DebugSymbols>
9494
<MSBuildTargets>Silverlight 4.0</MSBuildTargets>
9595
<OutputPath>bin\SL40-Debug\</OutputPath>
96-
<DefineConstants>DEBUG;TRACE;SILVERLIGHT SL4</DefineConstants>
96+
<DefineConstants>DEBUG;TRACE;SILVERLIGHT SL4 FEATURE_LEGACY_REFLECTION_API</DefineConstants>
9797
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
9898
<DebugType>full</DebugType>
9999
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -104,7 +104,7 @@
104104
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'SL50-Release|AnyCPU'">
105105
<OutputPath>bin\SL50-Release\</OutputPath>
106106
<MSBuildTargets>Silverlight 5.0</MSBuildTargets>
107-
<DefineConstants>TRACE;SILVERLIGHT SL5</DefineConstants>
107+
<DefineConstants>TRACE;SILVERLIGHT SL5 FEATURE_LEGACY_REFLECTION_API</DefineConstants>
108108
<Optimize>true</Optimize>
109109
<DebugType>pdbonly</DebugType>
110110
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -119,7 +119,7 @@
119119
<DebugSymbols>true</DebugSymbols>
120120
<MSBuildTargets>Silverlight 5.0</MSBuildTargets>
121121
<OutputPath>bin\SL50-Debug\</OutputPath>
122-
<DefineConstants>DEBUG;TRACE;SILVERLIGHT SL5</DefineConstants>
122+
<DefineConstants>DEBUG;TRACE;SILVERLIGHT SL5 FEATURE_LEGACY_REFLECTION_API</DefineConstants>
123123
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
124124
<DebugType>full</DebugType>
125125
<PlatformTarget>AnyCPU</PlatformTarget>

src/Castle.Core.Tests/ClassEmitterTestCase.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void UsingClassEmitterForInterfaces()
117117
emitter.CreateMethod("MyMethod", MethodAttributes.Public | MethodAttributes.Abstract | MethodAttributes.Virtual,
118118
typeof(void), Type.EmptyTypes);
119119
Type t = emitter.BuildType();
120-
Assert.IsTrue(t.IsInterface);
120+
Assert.IsTrue(t.GetTypeInfo().IsInterface);
121121
MethodInfo method = t.GetMethod("MyMethod");
122122
Assert.IsNotNull(method);
123123
}
@@ -166,7 +166,7 @@ public void NestedInterface()
166166
typeof(void), Type.EmptyTypes);
167167
Type inner = innerEmitter.BuildType();
168168
Type outer = outerEmitter.BuildType();
169-
Assert.IsTrue(inner.IsInterface);
169+
Assert.IsTrue(inner.GetTypeInfo().IsInterface);
170170
MethodInfo method = inner.GetMethod("MyMethod");
171171
Assert.IsNotNull(method);
172172
Assert.AreSame(inner, outer.GetNestedType("IInner", BindingFlags.Public));

src/Castle.Core.Tests/Interceptors/KeepDataInterceptor.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Castle.DynamicProxy.Tests.Interceptors
1616
{
1717
using System;
18+
using System.Reflection;
1819

1920
public class KeepDataInterceptor : IInterceptor
2021
{
@@ -34,7 +35,7 @@ public void Intercept(IInvocation invocation)
3435
{
3536
invocation.Proceed();
3637
}
37-
else if (concreteMethod.ReturnType.IsValueType && !concreteMethod.ReturnType.Equals(typeof(void)))
38+
else if (concreteMethod.ReturnType.GetTypeInfo().IsValueType && !concreteMethod.ReturnType.Equals(typeof(void)))
3839
// ensure valid return value
3940
{
4041
invocation.ReturnValue = Activator.CreateInstance(concreteMethod.ReturnType);

src/Castle.Core.Tests/Interceptors/LogInvocationInterceptor.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Castle.DynamicProxy.Tests.Interceptors
1616
{
1717
using System;
1818
using System.Collections;
19+
using System.Reflection;
1920
using System.Text;
2021
using System.Collections.Generic;
2122

@@ -39,7 +40,7 @@ protected override void PerformProceed (IInvocation invocation)
3940
{
4041
base.PerformProceed (invocation);
4142
}
42-
else if (invocation.Method.ReturnType.IsValueType && invocation.Method.ReturnType != typeof (void))
43+
else if (invocation.Method.ReturnType.GetTypeInfo().IsValueType && invocation.Method.ReturnType != typeof (void))
4344
{
4445
invocation.ReturnValue = Activator.CreateInstance (invocation.Method.ReturnType); // set default return value
4546
}

src/Castle.Core.Tests/ReflectionBasedDictionaryAdapterTestCase.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Castle.Core.Tests
1616
{
1717
using System;
1818
using System.Collections;
19+
using System.Reflection;
1920

2021
using Castle.Core;
2122

@@ -109,7 +110,7 @@ public void EnumeratorIteration()
109110
public void Using_anonymous_types_works_without_exception()
110111
{
111112
var target = new { foo = 1, name = "john", age = 25 };
112-
Assert.IsFalse(target.GetType().IsPublic);
113+
Assert.IsFalse(target.GetType().GetTypeInfo().IsPublic);
113114
var dict = new ReflectionBasedDictionaryAdapter(target);
114115

115116
Assert.AreEqual(3, dict.Count);

src/Castle.Core/Castle.Core.csproj

+9-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<DebugSymbols>true</DebugSymbols>
2727
<DebugType>full</DebugType>
2828
<Optimize>false</Optimize>
29-
<DefineConstants>TRACE;DEBUG;DOTNET40 FEATURE_SERIALIZATION</DefineConstants>
29+
<DefineConstants>TRACE;DEBUG;DOTNET40 FEATURE_LEGACY_REFLECTION_API FEATURE_SERIALIZATION</DefineConstants>
3030
<ErrorReport>prompt</ErrorReport>
3131
<WarningLevel>4</WarningLevel>
3232
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -42,7 +42,7 @@
4242
<OutputPath>bin\NET40-Release\</OutputPath>
4343
<DebugType>pdbonly</DebugType>
4444
<Optimize>true</Optimize>
45-
<DefineConstants>TRACE;DOTNET40 FEATURE_SERIALIZATION</DefineConstants>
45+
<DefineConstants>TRACE;DOTNET40 FEATURE_LEGACY_REFLECTION_API FEATURE_SERIALIZATION</DefineConstants>
4646
<ErrorReport>prompt</ErrorReport>
4747
<WarningLevel>4</WarningLevel>
4848
<DocumentationFile>bin\NET40-Release\Castle.Core.xml</DocumentationFile>
@@ -55,7 +55,7 @@
5555
<TargetFrameworkProfile>
5656
</TargetFrameworkProfile>
5757
<OutputPath>bin\NET35-Debug\</OutputPath>
58-
<DefineConstants>TRACE;DEBUG;DOTNET35 FEATURE_SERIALIZATION</DefineConstants>
58+
<DefineConstants>TRACE;DEBUG;DOTNET35 FEATURE_LEGACY_REFLECTION_API FEATURE_SERIALIZATION</DefineConstants>
5959
<DocumentationFile>
6060
</DocumentationFile>
6161
<Optimize>true</Optimize>
@@ -72,7 +72,7 @@
7272
<TargetFrameworkProfile>
7373
</TargetFrameworkProfile>
7474
<OutputPath>bin\NET35-Release\</OutputPath>
75-
<DefineConstants>TRACE;DOTNET35 FEATURE_SERIALIZATION</DefineConstants>
75+
<DefineConstants>TRACE;DOTNET35 FEATURE_LEGACY_REFLECTION_API FEATURE_SERIALIZATION</DefineConstants>
7676
<DocumentationFile>bin\NET35-Release\Castle.Core.xml</DocumentationFile>
7777
<Optimize>true</Optimize>
7878
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -88,7 +88,7 @@
8888
</TargetFrameworkProfile>
8989
<MSBuildTargets>Silverlight 4.0</MSBuildTargets>
9090
<OutputPath>bin\SL40-Release\</OutputPath>
91-
<DefineConstants>TRACE;SILVERLIGHT SL4</DefineConstants>
91+
<DefineConstants>TRACE;SILVERLIGHT SL4 FEATURE_LEGACY_REFLECTION_API</DefineConstants>
9292
<DocumentationFile>bin\SL40-Release\Castle.Core.xml</DocumentationFile>
9393
<Optimize>true</Optimize>
9494
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -105,7 +105,7 @@
105105
<MSBuildTargets>Silverlight 4.0</MSBuildTargets>
106106
<DebugSymbols>true</DebugSymbols>
107107
<OutputPath>bin\SL40-Debug\</OutputPath>
108-
<DefineConstants>TRACE;DEBUG;SILVERLIGHT SL4</DefineConstants>
108+
<DefineConstants>TRACE;DEBUG;SILVERLIGHT SL4 FEATURE_LEGACY_REFLECTION_API</DefineConstants>
109109
<DocumentationFile>
110110
</DocumentationFile>
111111
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -121,7 +121,7 @@
121121
</TargetFrameworkProfile>
122122
<MSBuildTargets>Silverlight 5.0</MSBuildTargets>
123123
<OutputPath>bin\SL50-Release\</OutputPath>
124-
<DefineConstants>TRACE;SILVERLIGHT SL5</DefineConstants>
124+
<DefineConstants>TRACE;SILVERLIGHT SL5 FEATURE_LEGACY_REFLECTION_API</DefineConstants>
125125
<DocumentationFile>bin\SL50-Release\Castle.Core.xml</DocumentationFile>
126126
<Optimize>true</Optimize>
127127
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -138,7 +138,7 @@
138138
<MSBuildTargets>Silverlight 5.0</MSBuildTargets>
139139
<DebugSymbols>true</DebugSymbols>
140140
<OutputPath>bin\SL40-Debug\</OutputPath>
141-
<DefineConstants>TRACE;DEBUG;SILVERLIGHT SL5</DefineConstants>
141+
<DefineConstants>TRACE;DEBUG;SILVERLIGHT SL5 FEATURE_LEGACY_REFLECTION_API</DefineConstants>
142142
<DocumentationFile>
143143
</DocumentationFile>
144144
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -183,6 +183,7 @@
183183
<Compile Include="..\..\buildscripts\CommonAssemblyInfo.cs">
184184
<Link>CommonAssemblyInfo.cs</Link>
185185
</Compile>
186+
<Compile Include="Compatibility\IntrospectionExtensions.cs" />
186187
<Compile Include="Components.DictionaryAdapter\Util\ListProjectionDebugView.cs" />
187188
<Compile Include="Components.DictionaryAdapter\Util\ICollectionAdapter.cs" />
188189
<Compile Include="Components.DictionaryAdapter\Attributes\ReferenceAttribute.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2004-2015 Castle Project - http://www.castleproject.org/
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#if FEATURE_LEGACY_REFLECTION_API
16+
17+
namespace System.Reflection
18+
{
19+
internal static class IntrospectionExtensions
20+
{
21+
// This allows us to use the new reflection API which seperates Type and TypeInfo
22+
// while still supporting .NET 3.5 and 4.0.
23+
//
24+
// Return the System.Type for now, we will probably need to create a TypeInfo class
25+
// which inherits from Type like .NET 4.5 and implement the additional methods and
26+
// properties.
27+
public static Type GetTypeInfo(this Type type)
28+
{
29+
return type;
30+
}
31+
}
32+
}
33+
34+
#endif

src/Castle.Core/Components.DictionaryAdapter/AbstractDictionaryAdapterVisitor.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Castle.Components.DictionaryAdapter
1818
using System.Linq;
1919
using System.Collections;
2020
using System.Collections.Generic;
21+
using System.Reflection;
2122

2223
using Castle.Core;
2324

@@ -68,7 +69,7 @@ public virtual bool VisitDictionaryAdapter(IDictionaryAdapter dictionaryAdapter,
6869
{
6970
VisitCollection(dictionaryAdapter, property, collectionItemType, state);
7071
}
71-
else if (property.PropertyType.IsInterface)
72+
else if (property.PropertyType.GetTypeInfo().IsInterface)
7273
{
7374
VisitInterface(dictionaryAdapter, property, state);
7475
}
@@ -137,11 +138,11 @@ private static bool IsCollection(PropertyDescriptor property, out Type collectio
137138
var propertyType = property.PropertyType;
138139
if (propertyType != typeof(string) && typeof(IEnumerable).IsAssignableFrom(propertyType))
139140
{
140-
if (propertyType.IsArray)
141+
if (propertyType.GetTypeInfo().IsArray)
141142
{
142143
collectionItemType = propertyType.GetElementType();
143144
}
144-
else if (propertyType.IsGenericType)
145+
else if (propertyType.GetTypeInfo().IsGenericType)
145146
{
146147
var arguments = propertyType.GetGenericArguments();
147148
collectionItemType = arguments[0];

src/Castle.Core/Components.DictionaryAdapter/Attributes/OnDemandAttribute.cs

+8-9
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key,
6767

6868
if (IsAcceptedType(type))
6969
{
70-
if (type.IsInterface)
70+
if (type.GetTypeInfo().IsInterface)
7171
{
7272
if (property.IsDynamicProperty == false)
7373
{
@@ -77,7 +77,7 @@ public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key,
7777
}
7878
}
7979
}
80-
else if (type.IsArray)
80+
else if (type.GetTypeInfo().IsArray)
8181
{
8282
storedValue = Array.CreateInstance(type.GetElementType(), 0);
8383
}
@@ -139,7 +139,7 @@ public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key,
139139

140140
private static bool IsAcceptedType(Type type)
141141
{
142-
return type != null && type != typeof(String) && !type.IsPrimitive && !type.IsEnum;
142+
return type != null && type != typeof(string) && !type.GetTypeInfo().IsPrimitive && !type.GetTypeInfo().IsEnum;
143143
}
144144

145145
private static Type GetInferredType(IDictionaryAdapter dictionaryAdapter, PropertyDescriptor property, out IValueInitializer initializer)
@@ -155,11 +155,11 @@ private static Type GetInferredType(IDictionaryAdapter dictionaryAdapter, Proper
155155

156156
Type collectionType = null;
157157

158-
if (type.IsGenericType)
158+
if (type.GetTypeInfo().IsGenericType)
159159
{
160160
var genericDef = type.GetGenericTypeDefinition();
161161
var genericArg = type.GetGenericArguments()[0];
162-
bool isBindingList =
162+
bool isBindingList =
163163
#if SILVERLIGHT
164164
false;
165165
#else
@@ -176,10 +176,9 @@ private static Type GetInferredType(IDictionaryAdapter dictionaryAdapter, Proper
176176
collectionType = isBindingList ? typeof(EditableBindingList<>) : typeof(EditableList<>);
177177
#endif
178178
}
179-
180-
#if SILVERLIGHT //never true
181-
#else
182-
if (isBindingList && genericArg.IsInterface)
179+
180+
#if !SILVERLIGHT
181+
if (isBindingList && genericArg.GetTypeInfo().IsInterface)
183182
{
184183
Func<object> addNew = () => dictionaryAdapter.Create(genericArg);
185184
initializer = (IValueInitializer)Activator.CreateInstance(

src/Castle.Core/Components.DictionaryAdapter/Attributes/RemoveIfAttribute.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace Castle.Components.DictionaryAdapter
1717
using System;
1818
using System.Linq;
1919
using System.Collections;
20+
using System.Reflection;
2021

2122
/// <summary>
2223
/// Removes a property if matches value.
@@ -77,15 +78,15 @@ private static TBase Construct<TBase>(Type type, string paramName)
7778
throw new ArgumentNullException(paramName);
7879
}
7980

80-
if (type.IsAbstract == false && typeof(TBase).IsAssignableFrom(type))
81+
if (type.GetTypeInfo().IsAbstract == false && typeof(TBase).IsAssignableFrom(type))
8182
{
8283
var constructor = type.GetConstructor(Type.EmptyTypes);
8384
if (constructor != null)
8485
{
8586
return (TBase)constructor.Invoke(new object[0]);
8687
}
8788
}
88-
89+
8990
throw new ArgumentException(string.Format(
9091
"{0} is not a concrete type implementing {1} with a default constructor",
9192
type.FullName, typeof(TBase).FullName));

0 commit comments

Comments
 (0)