Add [Serializable] attribute to C# output code

I want to use the XmlSerializer or DataContract serializer in C#. These rely on reflection and attributes with which their targets are marked. How can I add custom attributes in C#, such as [Serializable] or, even more importantly, attributes that have arguments, such as:

[DataContract(Name = "SomeArgument", Namespace = "")]

There is @:strict which is used to declare a native C# attribute.


import cs.system.AttributeTargets;
import cs.system.AttributeUsageAttribute;
import cs.system.Attribute;

final class Main {
	@:strict(DataContract({Name:"SomeArgument", Namespace: ""}))
	static function main() {

class DataContract extends Attribute {
	public var Name:String;

	public var Namespace:String;

	public function new() {

Which will generate the following c# code:

	[DataContract(Name = "SomeArgument", Namespace = "")]
	public static void main() {

I hope it helps.