Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit b7daeb4

Browse files
committed
Switch to GetFieldGetterFn() public API
1 parent a1acffc commit b7daeb4

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/ServiceStack.Text/Common/WriteType.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private static bool Init()
184184
propertyOrder,
185185
propertySuppressDefaultConfig,
186186
propertySuppressDefaultAttribute,
187-
propertyInfo.GetValueGetter<T>(),
187+
propertyInfo.GetPropertyGetterFn(),
188188
Serializer.GetWriteFn(propertyType),
189189
propertyType.GetDefaultValue(),
190190
shouldSerialize,
@@ -241,7 +241,7 @@ private static bool Init()
241241
propertyOrder,
242242
propertySuppressDefaultConfig,
243243
propertySuppressDefaultAttribute,
244-
fieldInfo.GetValueGetter<T>(),
244+
fieldInfo.GetFieldGetterFn(),
245245
Serializer.GetWriteFn(propertyType),
246246
defaultValue,
247247
shouldSerialize,
@@ -276,7 +276,7 @@ internal string PropertyName
276276
internal readonly string propertyReferenceName;
277277
internal readonly string propertyNameCLSFriendly;
278278
internal readonly string propertyNameLowercaseUnderscore;
279-
internal readonly Func<T, object> GetterFn;
279+
internal readonly GetMemberDelegate GetterFn;
280280
internal readonly WriteObjectDelegate WriteFn;
281281
internal readonly object DefaultValue;
282282
internal readonly Func<T, bool> shouldSerialize;
@@ -285,7 +285,7 @@ internal string PropertyName
285285

286286
public TypePropertyWriter(Type propertyType, string propertyName, string propertyDeclaredTypeName, string propertyNameCLSFriendly,
287287
string propertyNameLowercaseUnderscore, int propertyOrder, bool propertySuppressDefaultConfig, bool propertySuppressDefaultAttribute,
288-
Func<T, object> getterFn, WriteObjectDelegate writeFn, object defaultValue,
288+
GetMemberDelegate getterFn, WriteObjectDelegate writeFn, object defaultValue,
289289
Func<T, bool> shouldSerialize,
290290
Func<T, string, bool?> shouldSerializeDynamic,
291291
bool isEnum)

src/ServiceStack.Text/PlatformExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public static MethodInfo Method(this Delegate fn)
316316

317317
#if (NETFX_CORE || PCL || NETSTANDARD1_1)
318318
[MethodImpl(MethodImplOptions.AggressiveInlining)]
319-
public static MethodInfo GetGetMethod(this PropertyInfo pi) =>
319+
public static MethodInfo GetGetMethod(this PropertyInfo pi, bool nonPublic=true) =>
320320
pi.GetMethod;
321321

322322
[MethodImpl(MethodImplOptions.AggressiveInlining)]

src/ServiceStack.Text/TypeProperties.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public static class TypeReflector<T> { }
2020
public class TypePropertyInfo
2121
{
2222
public TypePropertyInfo(
23-
PropertyInfo propertyInfo,
24-
GetMemberDelegate publicGetter,
23+
PropertyInfo propertyInfo,
24+
GetMemberDelegate publicGetter,
2525
SetMemberDelegate publicSetter)
2626
{
2727
PropertyInfo = propertyInfo;
@@ -142,7 +142,6 @@ public static SetMemberDelegate GetPropertySetterFn(this PropertyInfo propertyIn
142142
PclExport.Instance.GetPropertySetterFn(propertyInfo);
143143

144144
#if !SL5
145-
146145
public static GetMemberDelegate GetReflection(PropertyInfo propertyInfo) => propertyInfo.GetValue;
147146
public static SetMemberDelegate SetReflection(PropertyInfo propertyInfo) => propertyInfo.SetValue;
148147

@@ -217,7 +216,8 @@ public static GetMemberDelegate GetEmit(PropertyInfo propertyInfo)
217216
gen.Emit(OpCodes.Castclass, propertyInfo.DeclaringType);
218217
}
219218

220-
gen.Emit(OpCodes.Callvirt, propertyInfo.GetGetMethod());
219+
var mi = propertyInfo.GetGetMethod(true);
220+
gen.Emit(OpCodes.Callvirt, mi);
221221

222222
if (propertyInfo.PropertyType.IsValueType())
223223
{

0 commit comments

Comments
 (0)