From 9c55cda3734f36c70824c754d059e27f3fa7f6bb Mon Sep 17 00:00:00 2001 From: Alex Liubymov Date: Wed, 25 Sep 2024 17:46:15 +0300 Subject: [PATCH] Remove dynamic artefacts, update C# RpDateTime. --- .../csharp/CSBaboonTranslator.scala | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) 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 3b1a9b4..7ee227e 100644 --- a/src/main/scala/io/septimalmind/baboon/translator/csharp/CSBaboonTranslator.scala +++ b/src/main/scala/io/septimalmind/baboon/translator/csharp/CSBaboonTranslator.scala @@ -206,11 +206,6 @@ class CSBaboonTranslator(defnTranslator: CSDefnTranslator, |{ | public abstract TTo Convert(TCtx? context, $abstractBaboonConversions conversions, TFrom from); | - | public TTo Convert(TCtx? context, $abstractBaboonConversions conversions, dynamic from) - | { - | return Convert(context, conversions, (TFrom)from); - | } - | | IBaboonGenerated IBaboonGeneratedConversion.Convert(TCtx? context, $abstractBaboonConversions conversions, $iBaboonGenerated from) where TCtx : default | { | if (from is not TFrom fr) @@ -477,6 +472,24 @@ class CSBaboonTranslator(defnTranslator: CSDefnTranslator, | public static RpDateTime MinValue => new RpDateTime($csDateTime.MinValue); | public static RpDateTime MaxValue => new RpDateTime($csDateTime.MaxValue); | + | public int Year => Underlying.Year; + | public int Month => Underlying.Month; + | public int Day => Underlying.Day; + | public int DayOfYear => Underlying.DayOfYear; + | + | public $csTimeSpan TimeOfDay => Underlying.TimeOfDay; + | public $csDayOfWeek DayOfWeek => Underlying.DayOfWeek; + | + | public static RpDateTime operator -(RpDateTime left, TimeSpan delta) + | { + | return new RpDateTime(left.Underlying - delta); + | } + | + | public static RpDateTime operator +(RpDateTime left, TimeSpan delta) + | { + | return new RpDateTime(left.Underlying + delta); + | } + | | public static bool operator ==(RpDateTime left, RpDateTime right) | { | return left.Equals(right); @@ -959,6 +972,10 @@ object CSBaboonTranslator { CSType(csSystemPkg, "Enum", fq = false) val csDateTime: CSType = CSType(csSystemPkg, "DateTime", fq = false) + val csTimeSpan: CSType = + CSType(csSystemPkg, "DateTime", fq = false) + val csDayOfWeek: CSType = + CSType(csSystemPkg, "DateTime", fq = false) val rpDateTime: CSType = CSType(baboonTimePkg, "RpDateTime", fq = false) val csArgumentException: CSType =