Fixed NullReferenceException.
Added test for optional {V}Specified and ShouldSerialize{V}.
{V}Specified is a property or field and ShouldSerialize{V} is a method that can be set to false if we do not want to serialize an attribute with name {V}.
Added optional serialization based on ShouldSerialize{V}.
SerializationCodeGenerator and XmlSerializationWriterInterpreter will no longer serialize an attribute named {V} if its object has a method named ShouldSerialize{V}() that returns false.
{V}Specified now is also checked to be true before serializating the attribute even if it is a property that is not settable.
Fixes #1852.
Test serialization wen class has method bool ShouldSerialize<T>().
.NET throws an exception but it should have no effect on the serialization.
Ignore method ShouldSerialize if it is a generic.
Merge pull request #1257 from esdrubal/xmloptional

Added optional serialization based on ShouldSerialize{V}.