mcs\class\referencesource\mscorlib\system\runtime\serialization\formatterservices.cs
private static MemberInfo[] GetSerializableMembers(RuntimeType type) {
// get the list of all fields
FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
int countProper = 0;
for (int i = 0; i < fields.Length; i++) {
if ((fields[i].Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized)
continue;
countProper++;
}
if (countProper != fields.Length) {
FieldInfo[] properFields = new FieldInfo[countProper];
countProper = 0;
for (int i = 0; i < fields.Length; i++) {
if ((fields[i].Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized)
continue;
properFields[countProper] = fields[i];
countProper++;
}
return properFields;
}
else
return fields;
}