diff --git a/src/Engine/ProtoCore/Lang/Type.cs b/src/Engine/ProtoCore/Lang/Type.cs index fa2d72d88d3..50be014c287 100644 --- a/src/Engine/ProtoCore/Lang/Type.cs +++ b/src/Engine/ProtoCore/Lang/Type.cs @@ -121,6 +121,15 @@ public class TypeSystem public Dictionary addressTypeClassMap { get; set; } private static Dictionary primitiveTypeNames; + private static readonly Dictionary clrToDSTypeMap = new Dictionary + { + { typeof(string).FullName, "string" }, + { typeof(long).FullName, "int" }, + { typeof(double).FullName, "double" }, + { typeof(bool).FullName, "bool" }, + { typeof(char).FullName, "char" } + }; + public TypeSystem() { SetTypeSystem(); @@ -314,7 +323,13 @@ public string GetType(int UID) public int GetType(string ident) { Validity.Assert(null != classTable); - return classTable.IndexOf(ident); + var index = classTable.IndexOf(ident); + if (index != Constants.kInvalidIndex) return index; + + if(clrToDSTypeMap.TryGetValue(ident, out string dsType)) + return classTable.IndexOf(dsType); + + return Constants.kInvalidIndex; } public int GetType(StackValue sv) diff --git a/test/Engine/ProtoTest/Associative/BuiltinMethodsTest.cs b/test/Engine/ProtoTest/Associative/BuiltinMethodsTest.cs index 0ca49cf5a03..14de539b362 100644 --- a/test/Engine/ProtoTest/Associative/BuiltinMethodsTest.cs +++ b/test/Engine/ProtoTest/Associative/BuiltinMethodsTest.cs @@ -225,6 +225,27 @@ public void BIM10_RemoveIfNot() thisTest.Verify("t", 2); } + [Test] + //Test "RemoveIfNot()" + public void List_RemoveIfNot_CLRType() + { + String code = +@"import(""BuiltIn.ds""); +a = [""This is "",""a very complex "",""array"",1,2.0,3,false,4.0,5,6.0,true,[2,3.1415926],null,false,'c']; +b = List.RemoveIfNot(a, ""System.Int64""); +c = List.RemoveIfNot(a, ""System.Double""); +d = List.RemoveIfNot(a, ""System.Boolean""); +e = List.RemoveIfNot(a, ""System.Char""); +f = List.RemoveIfNot(a, ""System.String""); +"; + ExecutionMirror mirror = thisTest.RunScriptSource(code); + thisTest.Verify("b", new int[] { 1, 3, 5 }); + thisTest.Verify("c", new double[] { 2.0, 4.0, 6.0 }); + thisTest.Verify("d", new bool[] { false, true, false }); + thisTest.Verify("e", new char[] { 'c' }); + thisTest.Verify("f", new string[] { "This is ", "a very complex ", "array" }); + } + [Test] //Test "Reverse()" public void BIM11_Reverse()