private static int computeMessageRootBlockLength(final List<Field> fields)
    {
        int blockLength = 0;

        for (final Field field : fields)
        {
            if (field.groupFields() != null)
            {
                return blockLength;
            }
            else if (field.type() != null)
            {
                final int fieldLength = field.type().encodedLength();

                if (Token.VARIABLE_LENGTH == fieldLength)
                {
                    return blockLength;
                }

                if (field.presence() == Presence.CONSTANT)
                {
                    blockLength = field.computedOffset();
                }
                else
                {
                    blockLength = field.computedOffset() + fieldLength;
                }
            }
        }

        return blockLength;
    }
Return the encodedLength of the {@link Message} in bytes including any padding.

@return the encodedLength of the {@link Message} in bytes including any padding.
sbe-tool/src/main/java/uk/co/real_logic/sbe/xml/Message.java