In the parsing template, a null reference will occur when writing a type of "[ConsecutiveElements]" that has not been read in. Thus there should be a null check before reading. An alternative solution would be to instantiate the list in the constructor, but this might not be the best idea as it would cause unnecessary garbage collection if parsed and if there weren't elements, the writer would always write an empty. This may surprise the user. If a list didn't appear in the text, why should it be written out, even if empty.
In the parsing template, a null reference will occur when writing a type of "[ConsecutiveElements]" that has not been read in. Thus there should be a null check before reading. An alternative solution would be to instantiate the list in the constructor, but this might not be the best idea as it would cause unnecessary garbage collection if parsed and if there weren't elements, the writer would always write an empty. This may surprise the user. If a list didn't appear in the text, why should it be written out, even if empty.