diff --git a/src/main/resources/baboon-runtime/cs/BaboonRuntimeShared.cs b/src/main/resources/baboon-runtime/cs/BaboonRuntimeShared.cs index ad5dea4..872b7df 100644 --- a/src/main/resources/baboon-runtime/cs/BaboonRuntimeShared.cs +++ b/src/main/resources/baboon-runtime/cs/BaboonRuntimeShared.cs @@ -19,6 +19,31 @@ // ReSharper disable UnusedType.Global namespace Baboon.Runtime.Shared { + public static class BaboonEnumerable + { + public static List BbnToList(this IEnumerable source) + { + if (source is List l) + { + return l; + } + + return source.ToList(); + } + + public static Dictionary BbnToDictionary( + this IEnumerable> source) + where TKey : notnull + { + if (source is Dictionary d) + { + return d; + } + + return new Dictionary(source); + } + } + public interface IBaboonGenerated { public string BaboonDomainVersion(); public string BaboonDomainIdentifier(); diff --git a/src/main/scala/io/septimalmind/baboon/translator/csharp/CSTypes.scala b/src/main/scala/io/septimalmind/baboon/translator/csharp/CSTypes.scala index 398e10f..e0cc823 100644 --- a/src/main/scala/io/septimalmind/baboon/translator/csharp/CSTypes.scala +++ b/src/main/scala/io/septimalmind/baboon/translator/csharp/CSTypes.scala @@ -136,7 +136,7 @@ object CSTypes { val debug: CSType = CSType(csDiagnosticsPkg, "Debug", fq = false) - val mkDict = q"ToDictionary(v => v.Key, v => v.Value)" - val mkList = q"ToList()" + val mkDict = q"BbnToDictionary()" + val mkList = q"BbnToList()" val mkSet = q"ToImmutableHashSet()" }