FieldSet.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Google.ProtocolBuffers.Descriptors;
  6. using Google.ProtocolBuffers.Collections;
  7. namespace Google.ProtocolBuffers {
  8. /// <summary>
  9. /// A class which represents an arbitrary set of fields of some message type.
  10. /// This is used to implement DynamicMessage, and also to represent extensions
  11. /// in GeneratedMessage. This class is internal, since outside users should probably
  12. /// be using DynamicMessage.
  13. ///
  14. /// As in the Java implementation, this class goes against the rest of the framework
  15. /// in terms of mutability. Instead of having a mutable Builder class and an immutable
  16. /// FieldSet class, FieldSet just has a MakeImmutable() method. This is safe so long as
  17. /// all callers are careful not to let a mutable FieldSet escape into the open. This would
  18. /// be impossible to guarantee if this were a public class, of course.
  19. ///
  20. /// All repeated fields are stored as IList[object] even
  21. /// </summary>
  22. internal class FieldSet {
  23. private static readonly FieldSet defaultInstance = new FieldSet(new Dictionary<FieldDescriptor, object>()).MakeImmutable();
  24. private IDictionary<FieldDescriptor, object> fields;
  25. private FieldSet(IDictionary<FieldDescriptor, object> fields) {
  26. this.fields = fields;
  27. }
  28. public static FieldSet CreateFieldSet() {
  29. return new FieldSet(new Dictionary<FieldDescriptor, object>());
  30. }
  31. /// <summary>
  32. /// Makes this FieldSet immutable, and returns it for convenience. Any
  33. /// mutable repeated fields are made immutable, as well as the map itself.
  34. /// </summary>
  35. internal FieldSet MakeImmutable() {
  36. // First check if we have any repeated values
  37. bool hasRepeats = false;
  38. foreach (object value in fields.Values) {
  39. IList<object> list = value as IList<object>;
  40. if (list != null && !list.IsReadOnly) {
  41. hasRepeats = true;
  42. break;
  43. }
  44. }
  45. if (hasRepeats) {
  46. var tmp = new SortedList<FieldDescriptor, object>();
  47. foreach (KeyValuePair<FieldDescriptor, object> entry in fields) {
  48. IList<object> list = entry.Value as IList<object>;
  49. tmp[entry.Key] = list == null ? entry.Value : Lists.AsReadOnly(list);
  50. }
  51. fields = tmp;
  52. }
  53. fields = Dictionaries.AsReadOnly(fields);
  54. return this;
  55. }
  56. /// <summary>
  57. /// Returns the default, immutable instance with no fields defined.
  58. /// </summary>
  59. internal static FieldSet DefaultInstance {
  60. get { return defaultInstance; }
  61. }
  62. /// <summary>
  63. /// Returns an immutable mapping of fields. Note that although the mapping itself
  64. /// is immutable, the entries may not be (i.e. any repeated values are represented by
  65. /// mutable lists). The behaviour is not specified if the contents are mutated.
  66. /// </summary>
  67. internal IDictionary<FieldDescriptor, object> AllFields {
  68. get { return Dictionaries.AsReadOnly(fields); }
  69. }
  70. /// <summary>
  71. /// See <see cref="IMessage.HasField"/>.
  72. /// </summary>
  73. public bool HasField(FieldDescriptor field) {
  74. if (field.IsRepeated) {
  75. throw new ArgumentException("HasField() can only be called on non-repeated fields.");
  76. }
  77. return fields.ContainsKey(field);
  78. }
  79. // TODO(jonskeet): Should this be in UnknownFieldSet.Builder really? Or CodedInputStream?
  80. internal static void MergeFrom(CodedInputStream input, UnknownFieldSet.Builder unknownFields,
  81. ExtensionRegistry extensionRegistry, IBuilder builder) {
  82. while (true) {
  83. uint tag = input.ReadTag();
  84. if (tag == 0) {
  85. break;
  86. }
  87. if (!MergeFieldFrom(input, unknownFields, extensionRegistry,
  88. builder, tag)) {
  89. // end group tag
  90. break;
  91. }
  92. }
  93. }
  94. // TODO(jonskeet): Should this be in UnknownFieldSet.Builder really? Or CodedInputStream?
  95. /// <summary>
  96. /// Like <see cref="MergeFrom(CodedInputStream, UnknownFieldSet.Builder, ExtensionRegistry, IBuilder)" />
  97. /// but parses a single field.
  98. /// </summary>
  99. /// <param name="input">The input to read the field from</param>
  100. /// <param name="unknownFields">The set of unknown fields to add the newly-read field to, if it's not a known field</param>
  101. /// <param name="extensionRegistry">Registry to use when an extension field is encountered</param>
  102. /// <param name="builder">Builder to merge field into, if it's a known field</param>
  103. /// <param name="tag">The tag, which should already have been read from the input</param>
  104. /// <returns>true unless the tag is an end-group tag</returns>
  105. internal static bool MergeFieldFrom(CodedInputStream input, UnknownFieldSet.Builder unknownFields,
  106. ExtensionRegistry extensionRegistry, IBuilder builder, uint tag) {
  107. MessageDescriptor type = builder.DescriptorForType;
  108. if (type.Options.MessageSetWireFormat && tag == WireFormat.MessageSetTag.ItemStart) {
  109. MergeMessageSetExtensionFromCodedStream(input, unknownFields, extensionRegistry, builder);
  110. return true;
  111. }
  112. WireFormat.WireType wireType = WireFormat.GetTagWireType(tag);
  113. int fieldNumber = WireFormat.GetTagFieldNumber(tag);
  114. FieldDescriptor field;
  115. IMessage defaultFieldInstance = null;
  116. if (type.IsExtensionNumber(fieldNumber)) {
  117. ExtensionInfo extension = extensionRegistry[type, fieldNumber];
  118. if (extension == null) {
  119. field = null;
  120. } else {
  121. field = extension.Descriptor;
  122. defaultFieldInstance = extension.DefaultInstance;
  123. }
  124. } else {
  125. field = type.FindFieldByNumber(fieldNumber);
  126. }
  127. // Unknown field or wrong wire type. Skip.
  128. if (field == null || wireType != WireFormat.FieldTypeToWireFormatMap[field.FieldType]) {
  129. return unknownFields.MergeFieldFrom(tag, input);
  130. }
  131. object value;
  132. switch (field.FieldType) {
  133. case FieldType.Group:
  134. case FieldType.Message: {
  135. IBuilder subBuilder;
  136. if (defaultFieldInstance != null) {
  137. subBuilder = defaultFieldInstance.CreateBuilderForType();
  138. } else {
  139. subBuilder = builder.CreateBuilderForField(field);
  140. }
  141. if (!field.IsRepeated) {
  142. subBuilder.MergeFrom((IMessage) builder[field]);
  143. }
  144. if (field.FieldType == FieldType.Group) {
  145. input.ReadGroup(field.FieldNumber, subBuilder, extensionRegistry);
  146. } else {
  147. input.ReadMessage(subBuilder, extensionRegistry);
  148. }
  149. value = subBuilder.Build();
  150. break;
  151. }
  152. case FieldType.Enum: {
  153. int rawValue = input.ReadEnum();
  154. value = field.EnumType.FindValueByNumber(rawValue);
  155. // If the number isn't recognized as a valid value for this enum,
  156. // drop it.
  157. if (value == null) {
  158. unknownFields.MergeVarintField(fieldNumber, (ulong) rawValue);
  159. return true;
  160. }
  161. break;
  162. }
  163. default:
  164. value = input.ReadPrimitiveField(field.FieldType);
  165. break;
  166. }
  167. if (field.IsRepeated) {
  168. builder.AddRepeatedField(field, value);
  169. } else {
  170. builder[field] = value;
  171. }
  172. return true;
  173. }
  174. // TODO(jonskeet): Should this be in UnknownFieldSet.Builder really? Or CodedInputStream?
  175. /// <summary>
  176. /// Called by MergeFieldFrom to parse a MessageSet extension.
  177. /// </summary>
  178. private static void MergeMessageSetExtensionFromCodedStream(CodedInputStream input,
  179. UnknownFieldSet.Builder unknownFields,
  180. ExtensionRegistry extensionRegistry,
  181. IBuilder builder) {
  182. MessageDescriptor type = builder.DescriptorForType;
  183. // The wire format for MessageSet is:
  184. // message MessageSet {
  185. // repeated group Item = 1 {
  186. // required int32 typeId = 2;
  187. // required bytes message = 3;
  188. // }
  189. // }
  190. // "typeId" is the extension's field number. The extension can only be
  191. // a message type, where "message" contains the encoded bytes of that
  192. // message.
  193. //
  194. // In practice, we will probably never see a MessageSet item in which
  195. // the message appears before the type ID, or where either field does not
  196. // appear exactly once. However, in theory such cases are valid, so we
  197. // should be prepared to accept them.
  198. int typeId = 0;
  199. ByteString rawBytes = null; // If we encounter "message" before "typeId"
  200. IBuilder subBuilder = null;
  201. FieldDescriptor field = null;
  202. while (true) {
  203. uint tag = input.ReadTag();
  204. if (tag == 0) {
  205. break;
  206. }
  207. if (tag == WireFormat.MessageSetTag.TypeID) {
  208. typeId = input.ReadInt32();
  209. // Zero is not a valid type ID.
  210. if (typeId != 0) {
  211. ExtensionInfo extension = extensionRegistry[type, typeId];
  212. if (extension != null) {
  213. field = extension.Descriptor;
  214. subBuilder = extension.DefaultInstance.CreateBuilderForType();
  215. IMessage originalMessage = (IMessage) builder[field];
  216. if (originalMessage != null) {
  217. subBuilder.MergeFrom(originalMessage);
  218. }
  219. if (rawBytes != null) {
  220. // We already encountered the message. Parse it now.
  221. // TODO(jonskeet): Check this is okay. It's subtly different from the Java, as it doesn't create an input stream from rawBytes.
  222. // In fact, why don't we just call MergeFrom(rawBytes)? And what about the extension registry?
  223. subBuilder.MergeFrom(rawBytes.CreateCodedInput());
  224. rawBytes = null;
  225. }
  226. } else {
  227. // Unknown extension number. If we already saw data, put it
  228. // in rawBytes.
  229. if (rawBytes != null) {
  230. unknownFields.MergeField(typeId,
  231. UnknownField.CreateBuilder()
  232. .AddLengthDelimited(rawBytes)
  233. .Build());
  234. rawBytes = null;
  235. }
  236. }
  237. }
  238. } else if (tag == WireFormat.MessageSetTag.Message) {
  239. if (typeId == 0) {
  240. // We haven't seen a type ID yet, so we have to store the raw bytes for now.
  241. rawBytes = input.ReadBytes();
  242. } else if (subBuilder == null) {
  243. // We don't know how to parse this. Ignore it.
  244. unknownFields.MergeField(typeId,
  245. UnknownField.CreateBuilder()
  246. .AddLengthDelimited(input.ReadBytes())
  247. .Build());
  248. } else {
  249. // We already know the type, so we can parse directly from the input
  250. // with no copying. Hooray!
  251. input.ReadMessage(subBuilder, extensionRegistry);
  252. }
  253. } else {
  254. // Unknown tag. Skip it.
  255. if (!input.SkipField(tag)) {
  256. break; // end of group
  257. }
  258. }
  259. }
  260. input.CheckLastTagWas(WireFormat.MessageSetTag.ItemEnd);
  261. if (subBuilder != null) {
  262. builder[field] = subBuilder.Build();
  263. }
  264. }
  265. /// <summary>
  266. /// Clears all fields.
  267. /// </summary>
  268. internal void Clear() {
  269. fields.Clear();
  270. }
  271. /// <summary>
  272. /// See <see cref="IMessage.Item(FieldDescriptor)"/>
  273. /// </summary>
  274. /// <remarks>
  275. /// If the field is not set, the behaviour when fetching this property varies by field type:
  276. /// <list>
  277. /// <item>For singular message values, null is returned.</item>
  278. /// <item>For singular non-message values, the default value of the field is returned.</item>
  279. /// <item>For repeated values, an empty immutable list is returned. This will be compatible
  280. /// with IList[object], regardless of the type of the repeated item.</item>
  281. /// </list>
  282. /// This method returns null if the field is a singular message type
  283. /// and is not set; in this case it is up to the caller to fetch the
  284. /// message's default instance. For repeated fields of message types,
  285. /// an empty collection is returned. For repeated fields of non-message
  286. /// types, null is returned.
  287. /// <para />
  288. /// When setting this property, any list values are copied, and each element is checked
  289. /// to ensure it is of an appropriate type.
  290. /// </remarks>
  291. ///
  292. internal object this[FieldDescriptor field] {
  293. get {
  294. object result;
  295. if (fields.TryGetValue(field, out result)) {
  296. return result;
  297. }
  298. if (field.MappedType == MappedType.Message) {
  299. if (field.IsRepeated) {
  300. return new List<object>();
  301. } else {
  302. return null;
  303. }
  304. }
  305. return field.DefaultValue;
  306. }
  307. set {
  308. if (field.IsRepeated) {
  309. List<object> list = value as List<object>;
  310. if (list == null) {
  311. throw new ArgumentException("Wrong object type used with protocol message reflection.");
  312. }
  313. // Wrap the contents in a new list so that the caller cannot change
  314. // the list's contents after setting it.
  315. List<object> newList = new List<object>(list);
  316. foreach (object element in newList) {
  317. VerifyType(field, element);
  318. }
  319. value = newList;
  320. }
  321. else {
  322. VerifyType(field, value);
  323. }
  324. fields[field] = value;
  325. }
  326. }
  327. /// <summary>
  328. /// See <see cref="IMessage.Item(FieldDescriptor,int)" />
  329. /// </summary>
  330. internal object this[FieldDescriptor field, int index] {
  331. get {
  332. if (!field.IsRepeated) {
  333. throw new ArgumentException("Indexer specifying field and index can only be called on repeated fields.");
  334. }
  335. return ((IList<object>) this[field])[index];
  336. }
  337. set {
  338. if (!field.IsRepeated) {
  339. throw new ArgumentException("Indexer specifying field and index can only be called on repeated fields.");
  340. }
  341. VerifyType(field, value);
  342. object list;
  343. if (!fields.TryGetValue(field, out list)) {
  344. throw new ArgumentOutOfRangeException();
  345. }
  346. ((IList<object>) list)[index] = value;
  347. }
  348. }
  349. /// <summary>
  350. /// See <see cref="IBuilder.AddRepeatedField" />
  351. /// </summary>
  352. internal void AddRepeatedField(FieldDescriptor field, object value) {
  353. if (!field.IsRepeated) {
  354. throw new ArgumentException("AddRepeatedField can only be called on repeated fields.");
  355. }
  356. VerifyType(field, value);
  357. object list;
  358. if (!fields.TryGetValue(field, out list)) {
  359. list = new List<object>();
  360. fields[field] = list;
  361. }
  362. ((IList<object>) list).Add(value);
  363. }
  364. /// <summary>
  365. /// Returns an enumerator for the field map. Used to write the fields out.
  366. /// </summary>
  367. internal IEnumerator<KeyValuePair<FieldDescriptor, object>> GetEnumerator() {
  368. return fields.GetEnumerator();
  369. }
  370. /// <summary>
  371. /// See <see cref="IMessage.IsInitialized" />
  372. /// </summary>
  373. /// <remarks>
  374. /// Since FieldSet itself does not have any way of knowing about
  375. /// required fields that aren't actually present in the set, it is up
  376. /// to the caller to check for genuinely required fields. This property
  377. /// merely checks that any messages present are themselves initialized.
  378. /// </remarks>
  379. internal bool IsInitialized {
  380. get {
  381. foreach (KeyValuePair<FieldDescriptor, object> entry in fields) {
  382. FieldDescriptor field = entry.Key;
  383. if (field.MappedType == MappedType.Message) {
  384. if (field.IsRepeated) {
  385. foreach(IMessage message in (IEnumerable) entry.Value) {
  386. if (!message.IsInitialized) {
  387. return false;
  388. }
  389. }
  390. } else {
  391. if (!((IMessage) entry.Value).IsInitialized) {
  392. return false;
  393. }
  394. }
  395. }
  396. }
  397. return true;
  398. }
  399. }
  400. /// <summary>
  401. /// Verifies whether all the required fields in the specified message
  402. /// descriptor are present in this field set, as well as whether
  403. /// all the embedded messages are themselves initialized.
  404. /// </summary>
  405. internal bool IsInitializedWithRespectTo(MessageDescriptor type) {
  406. foreach (FieldDescriptor field in type.Fields) {
  407. if (field.IsRequired && !HasField(field)) {
  408. return false;
  409. }
  410. }
  411. return IsInitialized;
  412. }
  413. /// <summary>
  414. /// See <see cref="IBuilder.ClearField" />
  415. /// </summary>
  416. public void ClearField(FieldDescriptor field) {
  417. fields.Remove(field);
  418. }
  419. /// <summary>
  420. /// See <see cref="IMessage.GetRepeatedFieldCount" />
  421. /// </summary>
  422. public int GetRepeatedFieldCount(FieldDescriptor field) {
  423. if (!field.IsRepeated) {
  424. throw new ArgumentException("GetRepeatedFieldCount() can only be called on repeated fields.");
  425. }
  426. return ((IList<object>) this[field]).Count;
  427. }
  428. /// <summary>
  429. /// Implementation of both <c>MergeFrom</c> methods.
  430. /// </summary>
  431. /// <param name="otherFields"></param>
  432. private void MergeFields(IEnumerable<KeyValuePair<FieldDescriptor, object>> otherFields) {
  433. // Note: We don't attempt to verify that other's fields have valid
  434. // types. Doing so would be a losing battle. We'd have to verify
  435. // all sub-messages as well, and we'd have to make copies of all of
  436. // them to insure that they don't change after verification (since
  437. // the IMessage interface itself cannot enforce immutability of
  438. // implementations).
  439. // TODO(jonskeet): Provide a function somewhere called MakeDeepCopy()
  440. // which allows people to make secure deep copies of messages.
  441. foreach (KeyValuePair<FieldDescriptor, object> entry in otherFields) {
  442. FieldDescriptor field = entry.Key;
  443. object existingValue;
  444. fields.TryGetValue(field, out existingValue);
  445. if (field.IsRepeated) {
  446. if (existingValue == null) {
  447. existingValue = new List<object>();
  448. fields[field] = existingValue;
  449. }
  450. IList<object> list = (IList<object>) existingValue;
  451. foreach (object otherValue in (IEnumerable) entry.Value) {
  452. list.Add(otherValue);
  453. }
  454. } else if (field.MappedType == MappedType.Message && existingValue != null) {
  455. IMessage existingMessage = (IMessage)existingValue;
  456. IMessage merged = existingMessage.CreateBuilderForType()
  457. .MergeFrom(existingMessage)
  458. .MergeFrom((IMessage)entry.Value)
  459. .Build();
  460. this[field] = merged;
  461. } else {
  462. this[field] = entry.Value;
  463. }
  464. }
  465. }
  466. /// <summary>
  467. /// See <see cref="IBuilder.MergeFrom(IMessage)" />
  468. /// </summary>
  469. public void MergeFrom(IMessage other) {
  470. MergeFields(other.AllFields);
  471. }
  472. /// <summary>
  473. /// Like <see cref="MergeFrom(IMessage)"/>, but merges from another <c>FieldSet</c>.
  474. /// </summary>
  475. public void MergeFrom(FieldSet other) {
  476. MergeFields(other.fields);
  477. }
  478. /// <summary>
  479. /// See <see cref="IMessage.WriteTo(CodedOutputStream)" />.
  480. /// </summary>
  481. public void WriteTo(CodedOutputStream output) {
  482. foreach (KeyValuePair<FieldDescriptor, object> entry in fields) {
  483. WriteField(entry.Key, entry.Value, output);
  484. }
  485. }
  486. /// <summary>
  487. /// Writes a single field to a CodedOutputStream.
  488. /// </summary>
  489. public void WriteField(FieldDescriptor field, Object value, CodedOutputStream output) {
  490. if (field.IsExtension && field.ContainingType.Options.MessageSetWireFormat) {
  491. output.WriteMessageSetExtension(field.FieldNumber, (IMessage) value);
  492. } else {
  493. if (field.IsRepeated) {
  494. foreach (object element in (IEnumerable) value) {
  495. output.WriteField(field.FieldType, field.FieldNumber, element);
  496. }
  497. } else {
  498. output.WriteField(field.FieldType, field.FieldNumber, value);
  499. }
  500. }
  501. }
  502. /// <summary>
  503. /// See <see cref="IMessage.SerializedSize" />. It's up to the caller to
  504. /// cache the resulting size if desired.
  505. /// </summary>
  506. public int SerializedSize {
  507. get {
  508. int size = 0;
  509. foreach (KeyValuePair<FieldDescriptor, object> entry in fields) {
  510. FieldDescriptor field = entry.Key;
  511. object value = entry.Value;
  512. if (field.IsExtension && field.ContainingType.Options.MessageSetWireFormat) {
  513. size += CodedOutputStream.ComputeMessageSetExtensionSize(field.FieldNumber, (IMessage) value);
  514. } else {
  515. if (field.IsRepeated) {
  516. foreach (object element in (IEnumerable) value) {
  517. size += CodedOutputStream.ComputeFieldSize(field.FieldType, field.FieldNumber, element);
  518. }
  519. } else {
  520. size += CodedOutputStream.ComputeFieldSize(field.FieldType, field.FieldNumber, value);
  521. }
  522. }
  523. }
  524. return size;
  525. }
  526. }
  527. /// <summary>
  528. /// Verifies that the given object is of the correct type to be a valid
  529. /// value for the given field.
  530. /// </summary>
  531. /// <remarks>
  532. /// For repeated fields, this checks if the object is of the right
  533. /// element type, not whether it's a list.
  534. /// </remarks>
  535. /// <exception cref="ArgumentException">The value is not of the right type.</exception>
  536. private static void VerifyType(FieldDescriptor field, object value) {
  537. bool isValid = false;
  538. switch (field.MappedType) {
  539. case MappedType.Int32: isValid = value is int; break;
  540. case MappedType.Int64: isValid = value is long; break;
  541. case MappedType.UInt32: isValid = value is uint; break;
  542. case MappedType.UInt64: isValid = value is ulong; break;
  543. case MappedType.Single: isValid = value is float; break;
  544. case MappedType.Double: isValid = value is double; break;
  545. case MappedType.Boolean: isValid = value is bool; break;
  546. case MappedType.String: isValid = value is string; break;
  547. case MappedType.ByteString: isValid = value is ByteString; break;
  548. case MappedType.Enum:
  549. EnumValueDescriptor enumValue = value as EnumValueDescriptor;
  550. isValid = enumValue != null && enumValue.EnumDescriptor == field.EnumType;
  551. break;
  552. case MappedType.Message:
  553. IMessage messageValue = value as IMessage;
  554. isValid = messageValue != null && messageValue.DescriptorForType == field.MessageType;
  555. break;
  556. }
  557. if (!isValid) {
  558. // When chaining calls to SetField(), it can be hard to tell from
  559. // the stack trace which exact call failed, since the whole chain is
  560. // considered one line of code. So, let's make sure to include the
  561. // field name and other useful info in the exception.
  562. throw new ArgumentException("Wrong object type used with protocol message reflection. "
  563. + "Message type \"" + field.ContainingType.FullName
  564. + "\", field \"" + (field.IsExtension ? field.FullName : field.Name)
  565. + "\", value was type \"" + value.GetType().Name + "\".");
  566. }
  567. }
  568. }
  569. }