Skip to content
Closed
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
18 changes: 16 additions & 2 deletions src/MsgPack/Serialization/SerializerBuilder`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,27 @@ private static IEnumerable<SerializingMember> GetTargetMembers()
typeof( TObject ).FindMembers(
MemberTypes.Field | MemberTypes.Property,
BindingFlags.Public | BindingFlags.Instance,
( member, criteria ) => true,
( member, criteria ) =>
{
var property = member as PropertyInfo;
if ( property != null )
{
return property.GetGetMethod() != null && property.GetSetMethod() != null;
}
var field = member as FieldInfo;
if ( field != null )
{
return !field.IsInitOnly;
}
return false;
},
null
);
var filtered = members.Where( item => Attribute.IsDefined( item, typeof( MessagePackMemberAttribute ) ) ).ToArray();
#else
var members =
typeof( TObject ).GetRuntimeFields().Where( f => f.IsPublic && !f.IsStatic ).OfType<MemberInfo>().Concat( typeof( TObject ).GetRuntimeProperties().Where( p => p.GetMethod != null && p.GetMethod.IsPublic && !p.GetMethod.IsStatic ) );
typeof( TObject ).GetRuntimeFields().Where( f => f.IsPublic && !f.IsStatic && !f.IsInitOnly ).OfType<MemberInfo>().Concat(
typeof( TObject ).GetRuntimeProperties().Where( p => p.GetMethod != null && p.SetMethod != null && p.GetMethod.IsPublic && !p.GetMethod.IsStatic ) );
var filtered = members.Where( item => item.IsDefined( typeof( MessagePackMemberAttribute ) ) ).ToArray();
#endif

Expand Down