Adding property set support

CodeSmith Generator serializes custom metadata types automatically with the JSON.NET library, so in most cases you don't need to do anything to save their values in a CodeSmith Generator project.

If your type doesn't serialize correctly by default, or needs special formatting when it's saved to XML, add a property serializer. Without one, users can't save a property set that includes a value of your type. A property serializer is a class that implements the CodeSmith.IPropertySerializer interface.

Example

The CustomPropertiesSample project in your extracted samples folder (Documents\CodeSmith Generator\Samples\<version>\Projects\CSharp\CustomPropertiesSample) contains example serializers.

In that sample, DropDownEditorProperty is a class that combines a string and a Boolean value into a single piece of metadata. To serialize it, the sample provides DropDownEditorPropertySerializer, which implements IPropertySerializer. A PropertySerializer attribute on DropDownEditorProperty tells Generator to use that serializer:

[PropertySerializer(typeof(CodeSmith.Samples.DropDownEditorPropertySerializer))]
public class DropDownEditorProperty

You can also set the serializer in a template, with the Serializer attribute of the Property directive.