diff --git a/src/main/scala/io/septimalmind/baboon/translator/csharp/CSBaboonTranslator.scala b/src/main/scala/io/septimalmind/baboon/translator/csharp/CSBaboonTranslator.scala index 8cf05d6..17cd8d1 100644 --- a/src/main/scala/io/septimalmind/baboon/translator/csharp/CSBaboonTranslator.scala +++ b/src/main/scala/io/septimalmind/baboon/translator/csharp/CSBaboonTranslator.scala @@ -362,6 +362,7 @@ class CSBaboonTranslator(defnTranslator: CSDefnTranslator, | public $csString VersionFrom(); | public $csTpe TypeTo(); | public $csString VersionTo(); + | public $csString TypeId(); |} | |public interface IBaboonGeneratedConversion : IConversion @@ -396,9 +397,11 @@ class CSBaboonTranslator(defnTranslator: CSDefnTranslator, | return typeof(TTo); | } | - | public abstract String VersionFrom(); + | public abstract $csString VersionFrom(); | - | public abstract String VersionTo(); + | public abstract $csString VersionTo(); + | + | public abstract $csString TypeId(); |} | |public interface IBaboonCodecData { diff --git a/src/main/scala/io/septimalmind/baboon/translator/csharp/IndividualConversionHandler.scala b/src/main/scala/io/septimalmind/baboon/translator/csharp/IndividualConversionHandler.scala index cd7e515..ef5a95a 100644 --- a/src/main/scala/io/septimalmind/baboon/translator/csharp/IndividualConversionHandler.scala +++ b/src/main/scala/io/septimalmind/baboon/translator/csharp/IndividualConversionHandler.scala @@ -58,7 +58,7 @@ class IndividualConversionHandler(trans: CSTypeTranslator, | |public override $csString VersionTo() { | return "${domain.version.version}"; - |}""".stripMargin.shift(4).trim + |}""".stripMargin rules.conversions.map { conv => val convname = makeName("Convert", conv) @@ -80,6 +80,14 @@ class IndividualConversionHandler(trans: CSTypeTranslator, transfer(TypeRef.Scalar(tpe), ref) } + val fullMeta = + q"""|$versionsMeta + | + |public override $csString TypeId() + |{ + | return "${conv.sourceTpe.toString}"; + |}""".stripMargin.shift(4).trim + conv match { case _: Conversion.CustomConversionRequired => val cdefn = @@ -87,7 +95,7 @@ class IndividualConversionHandler(trans: CSTypeTranslator, |{ | public abstract override ${tout} Convert(C? context, $abstractBaboonConversions conversions, ${tin} from) where C: default; | - | $versionsMeta + | $fullMeta |}""".stripMargin val ctree = tools.inNs(pkg.parts.toSeq, cdefn) @@ -124,7 +132,7 @@ class IndividualConversionHandler(trans: CSTypeTranslator, | } | } | - | $versionsMeta + | $fullMeta |}""".stripMargin val ctree = tools.inNs(pkg.parts.toSeq, cdefn) val regtree = q"Register(new ${convname}());" @@ -153,7 +161,7 @@ class IndividualConversionHandler(trans: CSTypeTranslator, | ${branches.join("\nelse\n").shift(8).trim} | } | - | $versionsMeta + | $fullMeta |}""".stripMargin val ctree = tools.inNs(pkg.parts.toSeq, cdefn) val regtree = q"Register(new ${convname}());" @@ -328,7 +336,7 @@ class IndividualConversionHandler(trans: CSTypeTranslator, | ); | } | - | $versionsMeta + | $fullMeta |}""".stripMargin val ctree = tools.inNs(pkg.parts.toSeq, cdefn)