code: public int getSerializedSizeAsMessageSet() {
      int result = 0;
      for (final Map.Entry<Integer, Field> entry : fields.entrySet()) {
        result += entry.getValue().getSerializedSizeAsMessageSetExtension(
          entry.getKey());
      }
      return result;
    }
docs: Get the number of bytes required to encode this set using
  {@code MessageSet} wire format.