Jelajahi Sumber

Changed #ifdef exclusions in VsCode debugger

Xanathar 9 tahun lalu
induk
melakukan
1cb87bdada
65 mengubah file dengan 406 tambahan dan 109 penghapusan
  1. 5 0
      src/MoonSharp.Interpreter.Tests/EndToEnd/CollectionsBaseGenRegisteredTests.cs
  2. 3 3
      src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataMethodsTests.cs
  3. 6 6
      src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataMethodsTests.cs
  4. 22 5
      src/MoonSharp.Interpreter.Tests/TestRunner.cs
  5. 1 1
      src/MoonSharp.Interpreter/CoreLib/BasicModule.cs
  6. 1 1
      src/MoonSharp.Interpreter/CoreLib/LoadModule.cs
  7. 2 1
      src/MoonSharp.Interpreter/CoreLib/OsTimeModule.cs
  8. 1 1
      src/MoonSharp.Interpreter/Execution/VM/ByteCode.cs
  9. 1 1
      src/MoonSharp.Interpreter/IO/UndisposableStream.cs
  10. 1 1
      src/MoonSharp.Interpreter/Interop/LuaStateInterop/Tools.cs
  11. 1 1
      src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs
  12. 1 1
      src/MoonSharp.Interpreter/Loaders/FileSystemScriptLoader.cs
  13. 1 1
      src/MoonSharp.Interpreter/Loaders/UnityAssetsScriptLoader.cs
  14. 17 11
      src/MoonSharp.Interpreter/Platforms/PlatformAutoDetector.cs
  15. 1 1
      src/MoonSharp.Interpreter/Platforms/PortableWrappers/Attributes.cs
  16. 1 1
      src/MoonSharp.Interpreter/Platforms/PortableWrappers/ExtensionMethods.cs
  17. 1 1
      src/MoonSharp.Interpreter/Platforms/PortableWrappers/Stopwatch.cs
  18. 1 1
      src/MoonSharp.Interpreter/Platforms/PortableWrappers/Utils.cs
  19. 1 1
      src/MoonSharp.Interpreter/Platforms/StandardPlatformAccessor.cs
  20. 1 1
      src/MoonSharp.Interpreter/REPL/ReplInterpreterScriptLoader.cs
  21. 1 1
      src/MoonSharp.Interpreter/Tree/Lexer/LexerUtils.cs
  22. 5 2
      src/MoonSharp.VsCodeDebugger/DebuggerLogic/AsyncDebugger.cs
  23. 4 1
      src/MoonSharp.VsCodeDebugger/DebuggerLogic/EmptyDebugSession.cs
  24. 5 1
      src/MoonSharp.VsCodeDebugger/DebuggerLogic/IAsyncDebuggerClient.cs
  25. 4 1
      src/MoonSharp.VsCodeDebugger/DebuggerLogic/MoonSharpDebugSession.cs
  26. 77 1
      src/MoonSharp.VsCodeDebugger/MoonSharpVsCodeDebugServer.cs
  27. 4 1
      src/MoonSharp.VsCodeDebugger/SDK/DebugSession.cs
  28. 5 2
      src/MoonSharp.VsCodeDebugger/SDK/Protocol.cs
  29. 6 2
      src/MoonSharp.VsCodeDebugger/SDK/Utilities.cs
  30. 5 1
      src/MoonSharp.VsCodeDebugger/VariableInspector.cs
  31. 6 6
      src/MoonSharp.VsCodeDebugger/_Projects/MoonSharp.VsCodeDebugger.net40-client/MoonSharp.VsCodeDebugger.net40-client.csproj
  32. 2 1
      src/Unity/MoonSharp/Assembly-CSharp-firstpass.csproj
  33. 4 1
      src/Unity/MoonSharp/Assembly-CSharp.csproj
  34. TEMPAT SAMPAH
      src/Unity/MoonSharp/Assets/CustomTest1.unity
  35. 62 0
      src/Unity/MoonSharp/Assets/CustomTest1Behaviour.cs
  36. TEMPAT SAMPAH
      src/Unity/MoonSharp/Assets/MainMenu.unity
  37. 24 0
      src/Unity/MoonSharp/Assets/MainMenuBehaviour.cs
  38. 0 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Debugger/DebuggerLogic/AsyncDebugger.cs
  39. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/CoreLib/BasicModule.cs
  40. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/CoreLib/LoadModule.cs
  41. 2 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/CoreLib/OsTimeModule.cs
  42. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/ByteCode.cs
  43. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/IO/UndisposableStream.cs
  44. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Interop/LuaStateInterop/Tools.cs
  45. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs
  46. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Loaders/FileSystemScriptLoader.cs
  47. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Loaders/UnityAssetsScriptLoader.cs
  48. 17 11
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/PlatformAutoDetector.cs
  49. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/PortableWrappers/Attributes.cs
  50. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/PortableWrappers/ExtensionMethods.cs
  51. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/PortableWrappers/Stopwatch.cs
  52. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/PortableWrappers/Utils.cs
  53. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/StandardPlatformAccessor.cs
  54. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/REPL/ReplInterpreterScriptLoader.cs
  55. 1 1
      src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Tree/Lexer/LexerUtils.cs
  56. 44 2
      src/Unity/MoonSharp/Assets/TestRunnerBehaviour.cs
  57. 5 0
      src/Unity/MoonSharp/Assets/Tests/EndToEnd/CollectionsBaseGenRegisteredTests.cs
  58. 3 3
      src/Unity/MoonSharp/Assets/Tests/EndToEnd/UserDataMethodsTests.cs
  59. 6 6
      src/Unity/MoonSharp/Assets/Tests/EndToEnd/VtUserDataMethodsTests.cs
  60. 22 5
      src/Unity/MoonSharp/Assets/Tests/TestRunner.cs
  61. TEMPAT SAMPAH
      src/Unity/MoonSharp/Assets/UnitTestsRunner.unity
  62. 5 0
      src/Unity/MoonSharp/Assets/link.xml
  63. 4 4
      src/Unity/MoonSharp/MoonSharp.userprefs
  64. TEMPAT SAMPAH
      src/Unity/MoonSharp/ProjectSettings/EditorBuildSettings.asset
  65. TEMPAT SAMPAH
      src/Unity/MoonSharp/ProjectSettings/ProjectSettings.asset

+ 5 - 0
src/MoonSharp.Interpreter.Tests/EndToEnd/CollectionsBaseGenRegisteredTests.cs

@@ -56,6 +56,11 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 		void Do(string code, Action<DynValue> asserts)
 		{
+			// useless ops, to trick AOT to include the extension methods..
+			List<int> lst = new List<int>() { 1, 1, 1, 1 };
+			lst.Add(lst.Sum());
+			lst.Add(lst.Last());
+
 			Do(code, (d, o) => asserts(d));
 		}
 

+ 3 - 3
src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataMethodsTests.cs

@@ -175,7 +175,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 				sb.Append("|");
 
-				sb.Append(string.Join(",", map.Keys.OrderBy(x => x).Select(i => i.ToString()).ToArray()));
+				sb.Append(string.Join(",", map.Keys.OrderBy(x => x.ToUpperInvariant()).ToArray()));
 
 				sb.Append("|");
 
@@ -206,9 +206,9 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 				p7.Append("|");
 				foreach (var o in p6) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Keys.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Keys.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Values.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Values.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
 
 				p7.Append(p9);

+ 6 - 6
src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataMethodsTests.cs

@@ -55,7 +55,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 				sb.Append("|");
 
-				sb.Append(string.Join(",", map.Keys.OrderBy(x => x).Select(i => i.ToString()).ToArray()));
+				sb.Append(string.Join(",", map.Keys.OrderBy(x => x.ToUpperInvariant()).ToArray()));
 
 				sb.Append("|");
 
@@ -86,9 +86,9 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 				p7.Append("|");
 				foreach (var o in p6) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Keys.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Keys.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Values.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Values.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
 
 				p7.Append(p9);
@@ -174,7 +174,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 				sb.Append("|");
 
-				sb.Append(string.Join(",", map.Keys.OrderBy(x => x).Select(i => i.ToString()).ToArray()));
+				sb.Append(string.Join(",", map.Keys.OrderBy(x => x.ToUpperInvariant()).ToArray()));
 
 				sb.Append("|");
 
@@ -205,9 +205,9 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 				p7.Append("|");
 				foreach (var o in p6) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Keys.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Keys.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Values.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Values.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
 
 				p7.Append(p9);

+ 22 - 5
src/MoonSharp.Interpreter.Tests/TestRunner.cs

@@ -37,7 +37,7 @@ namespace MoonSharp.Interpreter.Tests
 
 		public TestRunner(Action<TestResult> loggerAction)
 		{
-			IsRunning = true; 
+			IsRunning = true;
 
 			this.loggerAction = loggerAction;
 
@@ -53,7 +53,7 @@ namespace MoonSharp.Interpreter.Tests
 		}
 
 
-		public IEnumerable<TestResult> IterateOnTests(string whichTest = null, string[] testsToSkip = null)
+		public IEnumerable<TestResult> IterateOnTests(string whichTest = null, string[] testsToSkip = null, Type[] types = null)
 		{
 			HashSet<string> skipList = new HashSet<string>();
 
@@ -62,14 +62,18 @@ namespace MoonSharp.Interpreter.Tests
 
 			Assembly asm = Assembly.GetExecutingAssembly();
 
-			Type[] types = asm.GetTypes().Where(t => t.GetCustomAttributes(typeof(TestFixtureAttribute), true).Any()).ToArray();
+			types = types ?? asm.GetTypes().Where(t => t.GetCustomAttributes(typeof(TestFixtureAttribute), true).Any()).ToArray();
+
+#if UNITY_EDITOR_OSX
+            System.IO.File.WriteAllLines("/temp/types.cs", types.Select(t => t.FullName).ToArray());
+#endif
 
 			Console_WriteLine("Found {0} test types.", types.Length);
 
 			foreach (Type t in types)
 			{
 				MethodInfo[] tests = t.GetMethods().Where(m => m.GetCustomAttributes(typeof(TestAttribute), true).Any()).ToArray();
-				Console_WriteLine("Testing {0} - {1} tests found.", t.Name, tests.Length);
+				//Console_WriteLine("Testing {0} - {1} tests found.", t.Name, tests.Length);
 
 				foreach (MethodInfo mi in tests)
 				{
@@ -189,7 +193,7 @@ namespace MoonSharp.Interpreter.Tests
 					return new TestResult()
 					{
 						TestName = mi.Name,
-						Message = ex.Message,
+						Message = BuildExceptionMessage(ex),
 						Type = TestResultType.Fail,
 						Exception = ex
 					};
@@ -197,6 +201,19 @@ namespace MoonSharp.Interpreter.Tests
 			}
 		}
 
+		private static string BuildExceptionMessage(Exception ex)
+		{
+			StringBuilder sb = new StringBuilder();
+
+			for (Exception e = ex; e != null; e = e.InnerException)
+			{
+				sb.Append(">>> ");
+				sb.Append(e.Message);
+			}
+
+			return sb.ToString();
+		}
+
 		internal static void Skip()
 		{
 			if (TestRunner.IsRunning)

+ 1 - 1
src/MoonSharp.Interpreter/CoreLib/BasicModule.cs

@@ -62,7 +62,7 @@ namespace MoonSharp.Interpreter.CoreLib
 
 			if (mode == null || mode == "collect" || mode == "restart")
 			{
-#if PCL
+#if PCL || ENABLE_DOTNET
 				GC.Collect();
 #else
 				GC.Collect(2, GCCollectionMode.Forced);

+ 1 - 1
src/MoonSharp.Interpreter/CoreLib/LoadModule.cs

@@ -24,7 +24,7 @@ namespace MoonSharp.Interpreter.CoreLib
 				throw new InternalErrorException("'package' global variable was found and it is not a table");
 			}
 
-#if PCL
+#if PCL || ENABLE_DOTNET
 			string cfg = "\\\n;\n?\n!\n-\n";
 #else
 			string cfg = System.IO.Path.DirectorySeparatorChar + "\n;\n?\n!\n-\n";

+ 2 - 1
src/MoonSharp.Interpreter/CoreLib/OsTimeModule.cs

@@ -119,7 +119,8 @@ namespace MoonSharp.Interpreter.CoreLib
 			}
 			else
 			{
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
+
 				try
 				{
 					reference = TimeZoneInfo.ConvertTimeFromUtc(reference, TimeZoneInfo.Local);

+ 1 - 1
src/MoonSharp.Interpreter/Execution/VM/ByteCode.cs

@@ -59,7 +59,7 @@ namespace MoonSharp.Interpreter.Execution.VM
 			m_CurrentSourceRef = (m_SourceRefStack.Count > 0) ? m_SourceRefStack[m_SourceRefStack.Count - 1] : null;
 		}
 
-#if !PCL
+	#if !(PCL || ENABLE_DOTNET)
 		public void Dump(string file)
 		{
 			StringBuilder sb = new StringBuilder();

+ 1 - 1
src/MoonSharp.Interpreter/IO/UndisposableStream.cs

@@ -21,7 +21,7 @@ namespace MoonSharp.Interpreter.IO
 		{
 		}
 
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 		public override void Close()
 		{
 		}

+ 1 - 1
src/MoonSharp.Interpreter/Interop/LuaStateInterop/Tools.cs

@@ -579,7 +579,7 @@ namespace MoonSharp.Interpreter.Interop.LuaStateInterop
 					#region p - pointer
 					case 'p':   // pointer
 						if (o is IntPtr)
-#if PCL
+#if PCL || ENABLE_DOTNET
 							w = ( (IntPtr)o ).ToString();
 #else
 							w = "0x" + ((IntPtr)o).ToString("x");

+ 1 - 1
src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs

@@ -178,7 +178,7 @@ namespace MoonSharp.Interpreter.Interop
 				// optimized setters fall here
 				throw ScriptRuntimeException.UserDataArgumentTypeMismatch(v.Type, FieldInfo.FieldType);
 			}
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 			catch (FieldAccessException ex)
 			{
 				throw new ScriptRuntimeException(ex);

+ 1 - 1
src/MoonSharp.Interpreter/Loaders/FileSystemScriptLoader.cs

@@ -1,4 +1,4 @@
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 using System.IO;
 
 namespace MoonSharp.Interpreter.Loaders

+ 1 - 1
src/MoonSharp.Interpreter/Loaders/UnityAssetsScriptLoader.cs

@@ -98,7 +98,7 @@ namespace MoonSharp.Interpreter.Loaders
 			}
 			catch (Exception ex)
 			{
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 				Console.WriteLine("Error initializing UnityScriptLoader : {0}", ex);
 #endif
 			}

+ 17 - 11
src/MoonSharp.Interpreter/Platforms/PlatformAutoDetector.cs

@@ -79,20 +79,24 @@ namespace MoonSharp.Interpreter.Platforms
 				return;
 #if PCL
 			IsPortableFramework = true;
+	#if ENABLE_DOTNET
+			IsRunningOnUnity = true;
+			IsUnityNative = true;
+	#endif
 #else
-#if UNITY_5
+	#if UNITY_5
 			IsRunningOnUnity = true;
 			IsUnityNative = true;
 
-			#if ENABLE_IL2CPP
+	#if ENABLE_IL2CPP
 				IsUnityIL2CPP = true;
-			#endif
-#else
+	#endif
+	#else
 			IsRunningOnUnity = AppDomain.CurrentDomain
 				.GetAssemblies()
 				.SelectMany(a => a.SafeGetTypes())
 				.Any(t => t.FullName.StartsWith("UnityEngine."));
-#endif
+	#endif
 #endif
 
 			IsRunningOnMono = (Type.GetType("Mono.Runtime") != null);
@@ -108,7 +112,7 @@ namespace MoonSharp.Interpreter.Platforms
 		{
 			AutoDetectPlatformFlags();
 
-#if PCL
+#if PCL || ENABLE_DOTNET
 			return new LimitedPlatformAccessor();
 #else
 			if (IsRunningOnUnity)
@@ -122,14 +126,16 @@ namespace MoonSharp.Interpreter.Platforms
 		{
 			AutoDetectPlatformFlags();
 
-#if PCL
-			return new InvalidScriptLoader("Portable Framework");
-#else
 			if (IsRunningOnUnity)
 				return new UnityAssetsScriptLoader();
-
-			return new FileSystemScriptLoader();
+			else
+			{
+#if PCL
+				return new InvalidScriptLoader("Portable Framework");
+#else
+				return new FileSystemScriptLoader();
 #endif
+			}
 		}
 	}
 }

+ 1 - 1
src/MoonSharp.Interpreter/Platforms/PortableWrappers/Attributes.cs

@@ -1,4 +1,4 @@
-#if PCL
+#if PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET))
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 1 - 1
src/MoonSharp.Interpreter/Platforms/PortableWrappers/ExtensionMethods.cs

@@ -1,4 +1,4 @@
-#if PCL
+#if PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET))
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 1 - 1
src/MoonSharp.Interpreter/Platforms/PortableWrappers/Stopwatch.cs

@@ -1,4 +1,4 @@
-#if PCL
+#if PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET))
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 1 - 1
src/MoonSharp.Interpreter/Platforms/PortableWrappers/Utils.cs

@@ -6,7 +6,7 @@ namespace MoonSharp.Interpreter
 	{
 		internal static bool IsDbNull(this object p)
 		{
-#if PCL
+#if PCL || ENABLE_DOTNET
 			return p != null && p.GetType().FullName.StartsWith("System.DBNull");
 #else
 			return p != null && Convert.IsDBNull(p);

+ 1 - 1
src/MoonSharp.Interpreter/Platforms/StandardPlatformAccessor.cs

@@ -1,4 +1,4 @@
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 using System;
 using System.Diagnostics;
 using System.IO;

+ 1 - 1
src/MoonSharp.Interpreter/REPL/ReplInterpreterScriptLoader.cs

@@ -1,4 +1,4 @@
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 using System;
 using MoonSharp.Interpreter.Loaders;
 

+ 1 - 1
src/MoonSharp.Interpreter/Tree/Lexer/LexerUtils.cs

@@ -283,7 +283,7 @@ namespace MoonSharp.Interpreter.Tree
 
 		private static string ConvertUtf32ToChar(int i)
 		{
-#if PCL
+#if PCL || ENABLE_DOTNET
 			return ((char)i).ToString();
 #else
 			return char.ConvertFromUtf32(i);

+ 5 - 2
src/MoonSharp.VsCodeDebugger/DebuggerLogic/AsyncDebugger.cs

@@ -1,4 +1,6 @@
-using System;
+#if (!UNITY_5) || UNITY_STANDALONE || UNITY_EDITOR
+
+using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
@@ -21,7 +23,6 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic
 		private IAsyncDebuggerClient m_Client__;
 		DebuggerAction m_PendingAction = null;
 
-		bool m_InGetActionLoop = false;
 		List<WatchItem>[] m_WatchItems;
 		Dictionary<int, SourceCode> m_SourcesMap = new Dictionary<int, SourceCode>();
 		Dictionary<int, string> m_SourcesOverride = new Dictionary<int, string>();
@@ -302,3 +303,5 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic
 		}
 	}
 }
+
+#endif

+ 4 - 1
src/MoonSharp.VsCodeDebugger/DebuggerLogic/EmptyDebugSession.cs

@@ -1,4 +1,6 @@
-using System;
+#if (!UNITY_5) || UNITY_STANDALONE || UNITY_EDITOR
+
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -198,3 +200,4 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic
 		}
 	}
 }
+#endif

+ 5 - 1
src/MoonSharp.VsCodeDebugger/DebuggerLogic/IAsyncDebuggerClient.cs

@@ -1,4 +1,6 @@
-using System;
+#if (!UNITY_5) || UNITY_STANDALONE || UNITY_EDITOR
+
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -17,3 +19,5 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic
 		void Unbind();
 	}
 }
+
+#endif

+ 4 - 1
src/MoonSharp.VsCodeDebugger/DebuggerLogic/MoonSharpDebugSession.cs

@@ -1,4 +1,6 @@
-using System;
+#if (!UNITY_5) || UNITY_STANDALONE || UNITY_EDITOR
+
+using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
@@ -449,3 +451,4 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic
 		}
 	}
 }
+#endif

+ 77 - 1
src/MoonSharp.VsCodeDebugger/MoonSharpVsCodeDebugServer.cs

@@ -1,4 +1,6 @@
-using System;
+#if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE || UNITY_EDITOR)
+
+using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
@@ -305,3 +307,77 @@ namespace MoonSharp.VsCodeDebugger
 		}
 	}
 }
+
+#else
+using System;
+using System.Collections.Generic;
+using MoonSharp.Interpreter;
+using MoonSharp.Interpreter.Debugging;
+
+namespace MoonSharp.VsCodeDebugger
+{
+	public class MoonSharpVsCodeDebugServer : IDisposable
+	{
+		public MoonSharpVsCodeDebugServer(int port = 41912)
+		{
+		}
+
+		[Obsolete("Use the constructor taking only a port, and the 'Attach' method instead.")]
+		public MoonSharpVsCodeDebugServer(Script script, int port, Func<SourceCode, string> sourceFinder = null)
+		{
+		}
+
+		public void AttachToScript(Script script, string name, Func<SourceCode, string> sourceFinder = null)
+		{
+		}
+
+		public IEnumerable<KeyValuePair<int, string>> GetAttachedDebuggersByIdAndName()
+		{
+			yield break;
+		}
+
+
+		public int? CurrentId
+		{
+			get { return null; }
+			set { }
+		}
+
+
+		public Script Current
+		{
+			get { return null; }
+			set { }
+		}
+
+		/// <summary>
+		/// Detaches the specified script. The debugger attached to that script will get disconnected.
+		/// </summary>
+		/// <param name="script">The script.</param>
+		/// <exception cref="ArgumentException">Thrown if the script cannot be found.</exception>
+		public void Detach(Script script)
+		{
+
+		}
+
+		public Action<string> Logger { get; set; }
+
+		
+		[Obsolete("Use the Attach method instead.")]
+		public IDebugger GetDebugger()
+		{
+			return null;
+		}
+
+		public void Dispose()
+		{
+		}
+
+		public MoonSharpVsCodeDebugServer Start()
+		{
+			return this;
+		}
+
+	}
+}
+#endif

+ 4 - 1
src/MoonSharp.VsCodeDebugger/SDK/DebugSession.cs

@@ -1,4 +1,6 @@
-/*---------------------------------------------------------------------------------------------
+#if (!UNITY_5) || UNITY_STANDALONE || UNITY_EDITOR
+
+/*---------------------------------------------------------------------------------------------
 Copyright (c) Microsoft Corporation
 
 All rights reserved. 
@@ -605,3 +607,4 @@ namespace MoonSharp.VsCodeDebugger.SDK
 		}
 	}
 }
+#endif

+ 5 - 2
src/MoonSharp.VsCodeDebugger/SDK/Protocol.cs

@@ -1,4 +1,6 @@
-/*---------------------------------------------------------------------------------------------
+#if (!UNITY_5) || UNITY_STANDALONE || UNITY_EDITOR
+
+/*---------------------------------------------------------------------------------------------
 Copyright (c) Microsoft Corporation
 
 All rights reserved. 
@@ -336,4 +338,5 @@ namespace MoonSharp.VsCodeDebugger.SDK
 
 
 	}
-}
+}
+#endif

+ 6 - 2
src/MoonSharp.VsCodeDebugger/SDK/Utilities.cs

@@ -1,4 +1,6 @@
-/*---------------------------------------------------------------------------------------------
+#if (!UNITY_5) || UNITY_STANDALONE || UNITY_EDITOR
+
+/*---------------------------------------------------------------------------------------------
 Copyright (c) Microsoft Corporation
 
 All rights reserved. 
@@ -87,4 +89,6 @@ namespace MoonSharp.VsCodeDebugger.SDK
 			*/
 		}
 	}
-}
+}
+
+#endif

+ 5 - 1
src/MoonSharp.VsCodeDebugger/VariableInspector.cs

@@ -1,4 +1,6 @@
-using System;
+#if (!UNITY_5) || UNITY_STANDALONE || UNITY_EDITOR
+
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -82,3 +84,5 @@ namespace MoonSharp.VsCodeDebugger
 		}
 	}
 }
+
+#endif

+ 6 - 6
src/MoonSharp.VsCodeDebugger/_Projects/MoonSharp.VsCodeDebugger.net40-client/MoonSharp.VsCodeDebugger.net40-client.csproj

@@ -46,13 +46,16 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="..\..\DebuggerKit\AsyncDebugger.cs">
+    <Compile Include="..\..\DebuggerLogic\AsyncDebugger.cs">
       <Link>AsyncDebugger.cs</Link>
     </Compile>
-    <Compile Include="..\..\DebuggerKit\IAsyncDebuggerClient.cs">
+    <Compile Include="..\..\DebuggerLogic\IAsyncDebuggerClient.cs">
       <Link>IAsyncDebuggerClient.cs</Link>
     </Compile>
-    <Compile Include="..\..\MoonSharpDebugSession.cs">
+    <Compile Include="..\..\DebuggerLogic\EmptyDebugSession.cs">
+      <Link>EmptyDebugSession.cs</Link>
+    </Compile>
+    <Compile Include="..\..\DebuggerLogic\MoonSharpDebugSession.cs">
       <Link>MoonSharpDebugSession.cs</Link>
     </Compile>
     <Compile Include="..\..\MoonSharpVsCodeDebugServer.cs">
@@ -61,9 +64,6 @@
     <Compile Include="..\..\Properties\AssemblyInfo.cs">
       <Link>AssemblyInfo.cs</Link>
     </Compile>
-    <Compile Include="..\..\DebuggerKit\BlockingQueue.cs">
-      <Link>BlockingQueue.cs</Link>
-    </Compile>
     <Compile Include="..\..\SDK\DebugSession.cs">
       <Link>DebugSession.cs</Link>
     </Compile>

+ 2 - 1
src/Unity/MoonSharp/Assembly-CSharp-firstpass.csproj

@@ -19,7 +19,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>Temp\bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_4;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE</DefineConstants>
+    <DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_4;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_WEBGL;UNITY_WEBGL_API;UNITY_DISABLE_WEB_VERIFICATION;ENABLE_TEXTUREID_MAP;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_IL2CPP;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <NoWarn>0169</NoWarn>
@@ -337,6 +337,7 @@
      <None Include="Assets\Resources\MoonSharp\Scripts\011-while.t.txt" />
      <None Include="Assets\Resources\MoonSharp\Scripts\200-examples.t.txt" />
      <None Include="Assets\Resources\MoonSharp\Scripts\214-coroutine.t.txt" />
+     <None Include="Assets\link.xml" />
      <None Include="Assets\Resources\MoonSharp\Scripts\103-nil.t.txt" />
  <Reference Include="UnityEngine.UI">
  <HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>

+ 4 - 1
src/Unity/MoonSharp/Assembly-CSharp.csproj

@@ -19,7 +19,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>Temp\bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_4;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE</DefineConstants>
+    <DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_4;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_WEBGL;UNITY_WEBGL_API;UNITY_DISABLE_WEB_VERIFICATION;ENABLE_TEXTUREID_MAP;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_IL2CPP;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <NoWarn>0169</NoWarn>
@@ -45,6 +45,8 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
+     <Compile Include="Assets\CustomTest1Behaviour.cs" />
+     <Compile Include="Assets\MainMenuBehaviour.cs" />
      <Compile Include="Assets\TestRunnerBehaviour.cs" />
      <Compile Include="Assets\Tests\EmbeddableNUnitWrapper.cs" />
      <Compile Include="Assets\Tests\EndToEnd\BinaryDumpTests.cs" />
@@ -131,6 +133,7 @@
      <None Include="Assets\Resources\MoonSharp\Scripts\011-while.t.txt" />
      <None Include="Assets\Resources\MoonSharp\Scripts\200-examples.t.txt" />
      <None Include="Assets\Resources\MoonSharp\Scripts\214-coroutine.t.txt" />
+     <None Include="Assets\link.xml" />
      <None Include="Assets\Resources\MoonSharp\Scripts\103-nil.t.txt" />
  <Reference Include="UnityEngine.UI">
  <HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>

TEMPAT SAMPAH
src/Unity/MoonSharp/Assets/CustomTest1.unity


+ 62 - 0
src/Unity/MoonSharp/Assets/CustomTest1Behaviour.cs

@@ -0,0 +1,62 @@
+using UnityEngine;
+using System.Collections;
+using MoonSharp.Interpreter;
+using System;
+using System.Reflection;
+using System.Linq;
+
+public class CustomTest1Behaviour : MonoBehaviour {
+
+    public class MyClass
+    {
+        public string MyMethod()
+        {
+            return DateTime.Now.ToString("u");
+        }
+    }
+
+    void RegisterNamespace(string ns)
+    {
+        string @namespace = "System";
+
+        var q = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.Namespace == @namespace).ToList();
+
+        q.ForEach(t => UserData.RegisterType(t));
+    }
+
+	// Use this for initialization
+	void Start () 
+    {
+       /* RegisterNamespace("System");
+
+
+        UserData.RegisterType<MyClass>();
+
+
+        Script S = new Script();
+        S.Options.DebugPrint = s => Debug.Log(s);
+
+        S.Globals["obj"] = new MyClass();
+
+        S.DoString("print (obj.myMethod());");
+
+        Debug.Log("CUSTOM TEST 1 - DONE"); */
+	}
+	
+	// Update is called once per frame
+	void Update () {
+        string[] arr = (new string[] { "abc", "XY", "CDE", "ijk" }).OrderBy(s => s).ToArray();
+	}
+
+    void OnGUI()
+    {
+        string[] arr = (new string[] { "abc", "XY", "CDE", "ijk" }).OrderBy(s => s).ToArray();
+        string text = string.Join(", ", arr);
+
+        string banner = string.Format("MoonSharp Test Runner {0} [{1}]", Script.VERSION, Script.GlobalOptions.Platform.GetPlatformName());
+
+        GUI.Box(new Rect(0, 0, Screen.width, Screen.height), banner);
+        GUI.TextArea(new Rect(0, 30, Screen.width, Screen.height - 30), text);
+    }
+
+}

TEMPAT SAMPAH
src/Unity/MoonSharp/Assets/Untitled.unity → src/Unity/MoonSharp/Assets/MainMenu.unity


+ 24 - 0
src/Unity/MoonSharp/Assets/MainMenuBehaviour.cs

@@ -0,0 +1,24 @@
+using UnityEngine;
+using System.Collections;
+using UnityEngine.SceneManagement;
+
+public class MainMenuBehaviour : MonoBehaviour {
+
+    void OnGUI()
+    {
+        string text = "";
+
+        string banner = "MoonSharp Test Runner Menu";
+
+        GUI.Box(new Rect(0, 0, Screen.width, Screen.height), banner);
+
+        int X = (Screen.width - 200) / 2;
+
+        if (GUI.Button(new Rect(X, 30, 200, 40), "Unit Tests"))
+            SceneManager.LoadScene("UnitTestsRunner");
+
+        if (GUI.Button(new Rect(X, 80, 200, 40), "Manual Test #1"))
+            SceneManager.LoadScene("CustomTest1");
+    }
+
+}

+ 0 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Debugger/DebuggerLogic/AsyncDebugger.cs

@@ -21,7 +21,6 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic
 		private IAsyncDebuggerClient m_Client__;
 		DebuggerAction m_PendingAction = null;
 
-		bool m_InGetActionLoop = false;
 		List<WatchItem>[] m_WatchItems;
 		Dictionary<int, SourceCode> m_SourcesMap = new Dictionary<int, SourceCode>();
 		Dictionary<int, string> m_SourcesOverride = new Dictionary<int, string>();

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/CoreLib/BasicModule.cs

@@ -62,7 +62,7 @@ namespace MoonSharp.Interpreter.CoreLib
 
 			if (mode == null || mode == "collect" || mode == "restart")
 			{
-#if PCL
+#if PCL || ENABLE_DOTNET
 				GC.Collect();
 #else
 				GC.Collect(2, GCCollectionMode.Forced);

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/CoreLib/LoadModule.cs

@@ -24,7 +24,7 @@ namespace MoonSharp.Interpreter.CoreLib
 				throw new InternalErrorException("'package' global variable was found and it is not a table");
 			}
 
-#if PCL
+#if PCL || ENABLE_DOTNET
 			string cfg = "\\\n;\n?\n!\n-\n";
 #else
 			string cfg = System.IO.Path.DirectorySeparatorChar + "\n;\n?\n!\n-\n";

+ 2 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/CoreLib/OsTimeModule.cs

@@ -119,7 +119,8 @@ namespace MoonSharp.Interpreter.CoreLib
 			}
 			else
 			{
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
+
 				try
 				{
 					reference = TimeZoneInfo.ConvertTimeFromUtc(reference, TimeZoneInfo.Local);

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/ByteCode.cs

@@ -59,7 +59,7 @@ namespace MoonSharp.Interpreter.Execution.VM
 			m_CurrentSourceRef = (m_SourceRefStack.Count > 0) ? m_SourceRefStack[m_SourceRefStack.Count - 1] : null;
 		}
 
-#if !PCL
+	#if !(PCL || ENABLE_DOTNET)
 		public void Dump(string file)
 		{
 			StringBuilder sb = new StringBuilder();

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/IO/UndisposableStream.cs

@@ -21,7 +21,7 @@ namespace MoonSharp.Interpreter.IO
 		{
 		}
 
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 		public override void Close()
 		{
 		}

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Interop/LuaStateInterop/Tools.cs

@@ -579,7 +579,7 @@ namespace MoonSharp.Interpreter.Interop.LuaStateInterop
 					#region p - pointer
 					case 'p':   // pointer
 						if (o is IntPtr)
-#if PCL
+#if PCL || ENABLE_DOTNET
 							w = ( (IntPtr)o ).ToString();
 #else
 							w = "0x" + ((IntPtr)o).ToString("x");

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs

@@ -178,7 +178,7 @@ namespace MoonSharp.Interpreter.Interop
 				// optimized setters fall here
 				throw ScriptRuntimeException.UserDataArgumentTypeMismatch(v.Type, FieldInfo.FieldType);
 			}
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 			catch (FieldAccessException ex)
 			{
 				throw new ScriptRuntimeException(ex);

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Loaders/FileSystemScriptLoader.cs

@@ -1,4 +1,4 @@
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 using System.IO;
 
 namespace MoonSharp.Interpreter.Loaders

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Loaders/UnityAssetsScriptLoader.cs

@@ -98,7 +98,7 @@ namespace MoonSharp.Interpreter.Loaders
 			}
 			catch (Exception ex)
 			{
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 				Console.WriteLine("Error initializing UnityScriptLoader : {0}", ex);
 #endif
 			}

+ 17 - 11
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/PlatformAutoDetector.cs

@@ -79,20 +79,24 @@ namespace MoonSharp.Interpreter.Platforms
 				return;
 #if PCL
 			IsPortableFramework = true;
+	#if ENABLE_DOTNET
+			IsRunningOnUnity = true;
+			IsUnityNative = true;
+	#endif
 #else
-#if UNITY_5
+	#if UNITY_5
 			IsRunningOnUnity = true;
 			IsUnityNative = true;
 
-			#if ENABLE_IL2CPP
+	#if ENABLE_IL2CPP
 				IsUnityIL2CPP = true;
-			#endif
-#else
+	#endif
+	#else
 			IsRunningOnUnity = AppDomain.CurrentDomain
 				.GetAssemblies()
 				.SelectMany(a => a.SafeGetTypes())
 				.Any(t => t.FullName.StartsWith("UnityEngine."));
-#endif
+	#endif
 #endif
 
 			IsRunningOnMono = (Type.GetType("Mono.Runtime") != null);
@@ -108,7 +112,7 @@ namespace MoonSharp.Interpreter.Platforms
 		{
 			AutoDetectPlatformFlags();
 
-#if PCL
+#if PCL || ENABLE_DOTNET
 			return new LimitedPlatformAccessor();
 #else
 			if (IsRunningOnUnity)
@@ -122,14 +126,16 @@ namespace MoonSharp.Interpreter.Platforms
 		{
 			AutoDetectPlatformFlags();
 
-#if PCL
-			return new InvalidScriptLoader("Portable Framework");
-#else
 			if (IsRunningOnUnity)
 				return new UnityAssetsScriptLoader();
-
-			return new FileSystemScriptLoader();
+			else
+			{
+#if PCL
+				return new InvalidScriptLoader("Portable Framework");
+#else
+				return new FileSystemScriptLoader();
 #endif
+			}
 		}
 	}
 }

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/PortableWrappers/Attributes.cs

@@ -1,4 +1,4 @@
-#if PCL
+#if PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET))
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/PortableWrappers/ExtensionMethods.cs

@@ -1,4 +1,4 @@
-#if PCL
+#if PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET))
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/PortableWrappers/Stopwatch.cs

@@ -1,4 +1,4 @@
-#if PCL
+#if PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET))
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/PortableWrappers/Utils.cs

@@ -6,7 +6,7 @@ namespace MoonSharp.Interpreter
 	{
 		internal static bool IsDbNull(this object p)
 		{
-#if PCL
+#if PCL || ENABLE_DOTNET
 			return p != null && p.GetType().FullName.StartsWith("System.DBNull");
 #else
 			return p != null && Convert.IsDBNull(p);

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Platforms/StandardPlatformAccessor.cs

@@ -1,4 +1,4 @@
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 using System;
 using System.Diagnostics;
 using System.IO;

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/REPL/ReplInterpreterScriptLoader.cs

@@ -1,4 +1,4 @@
-#if !PCL
+#if !(PCL || ENABLE_DOTNET)
 using System;
 using MoonSharp.Interpreter.Loaders;
 

+ 1 - 1
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/Tree/Lexer/LexerUtils.cs

@@ -283,7 +283,7 @@ namespace MoonSharp.Interpreter.Tree
 
 		private static string ConvertUtf32ToChar(int i)
 		{
-#if PCL
+#if PCL || ENABLE_DOTNET
 			return ((char)i).ToString();
 #else
 			return char.ConvertFromUtf32(i);

+ 44 - 2
src/Unity/MoonSharp/Assets/TestRunnerBehaviour.cs

@@ -151,11 +151,53 @@ public class TestRunnerBehaviour : MonoBehaviour
         SKIPLIST.AddRange(HARDWIRE_SKIPLIST);
         UserData.RegistrationPolicy = new HardwireAndLogPolicy();
 
+        Type[] testFixtures = new Type[] {
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.BinaryDumpTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.ClosureTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseInterfGenRegisteredTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.ConfigPropertyAssignerTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.CoroutineTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.DynamicTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.ErrorHandlingTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.GotoTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.JsonSerializationTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.LuaTestSuiteExtract),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.ProxyObjectsTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.SimpleTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.StringLibTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.TableTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.TailCallTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.VarargsTupleTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests),
+            typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests),
+            typeof(MoonSharp.Interpreter.Tests.TestMoreTests),
+            typeof(MoonSharp.Interpreter.Tests.Units.BinDumpStreamTests),
+            typeof(MoonSharp.Interpreter.Tests.Units.FastStackTests),
+            typeof(MoonSharp.Interpreter.Tests.Units.InteropTests),
+        };
+
 
 
         MoonSharp.Interpreter.Tests.TestRunner tr = new MoonSharp.Interpreter.Tests.TestRunner(Log);
 
-        foreach (var r in tr.IterateOnTests(null, SKIPLIST.ToArray()))
+        foreach (var r in tr.IterateOnTests(null, SKIPLIST.ToArray(), testFixtures))
         {
             Log(r);
             yield return null;
@@ -180,7 +222,7 @@ public class TestRunnerBehaviour : MonoBehaviour
         }
         else
         {
-            //Console_WriteLine("{0}", r.Message);
+            Console_WriteLine("{0}", r.Message);
         }
     }
 

+ 5 - 0
src/Unity/MoonSharp/Assets/Tests/EndToEnd/CollectionsBaseGenRegisteredTests.cs

@@ -56,6 +56,11 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 		void Do(string code, Action<DynValue> asserts)
 		{
+			// useless ops, to trick AOT to include the extension methods..
+			List<int> lst = new List<int>() { 1, 1, 1, 1 };
+			lst.Add(lst.Sum());
+			lst.Add(lst.Last());
+
 			Do(code, (d, o) => asserts(d));
 		}
 

+ 3 - 3
src/Unity/MoonSharp/Assets/Tests/EndToEnd/UserDataMethodsTests.cs

@@ -175,7 +175,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 				sb.Append("|");
 
-				sb.Append(string.Join(",", map.Keys.OrderBy(x => x).Select(i => i.ToString()).ToArray()));
+				sb.Append(string.Join(",", map.Keys.OrderBy(x => x.ToUpperInvariant()).ToArray()));
 
 				sb.Append("|");
 
@@ -206,9 +206,9 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 				p7.Append("|");
 				foreach (var o in p6) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Keys.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Keys.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Values.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Values.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
 
 				p7.Append(p9);

+ 6 - 6
src/Unity/MoonSharp/Assets/Tests/EndToEnd/VtUserDataMethodsTests.cs

@@ -55,7 +55,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 				sb.Append("|");
 
-				sb.Append(string.Join(",", map.Keys.OrderBy(x => x).Select(i => i.ToString()).ToArray()));
+				sb.Append(string.Join(",", map.Keys.OrderBy(x => x.ToUpperInvariant()).ToArray()));
 
 				sb.Append("|");
 
@@ -86,9 +86,9 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 				p7.Append("|");
 				foreach (var o in p6) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Keys.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Keys.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Values.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Values.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
 
 				p7.Append(p9);
@@ -174,7 +174,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 				sb.Append("|");
 
-				sb.Append(string.Join(",", map.Keys.OrderBy(x => x).Select(i => i.ToString()).ToArray()));
+				sb.Append(string.Join(",", map.Keys.OrderBy(x => x.ToUpperInvariant()).ToArray()));
 
 				sb.Append("|");
 
@@ -205,9 +205,9 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 				p7.Append("|");
 				foreach (var o in p6) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Keys.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Keys.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
-				foreach (var o in p8.Values.OrderBy(x => x.ToString())) p7.Append(o);
+				foreach (var o in p8.Values.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o);
 				p7.Append("|");
 
 				p7.Append(p9);

+ 22 - 5
src/Unity/MoonSharp/Assets/Tests/TestRunner.cs

@@ -37,7 +37,7 @@ namespace MoonSharp.Interpreter.Tests
 
 		public TestRunner(Action<TestResult> loggerAction)
 		{
-			IsRunning = true; 
+			IsRunning = true;
 
 			this.loggerAction = loggerAction;
 
@@ -53,7 +53,7 @@ namespace MoonSharp.Interpreter.Tests
 		}
 
 
-		public IEnumerable<TestResult> IterateOnTests(string whichTest = null, string[] testsToSkip = null)
+		public IEnumerable<TestResult> IterateOnTests(string whichTest = null, string[] testsToSkip = null, Type[] types = null)
 		{
 			HashSet<string> skipList = new HashSet<string>();
 
@@ -62,14 +62,18 @@ namespace MoonSharp.Interpreter.Tests
 
 			Assembly asm = Assembly.GetExecutingAssembly();
 
-			Type[] types = asm.GetTypes().Where(t => t.GetCustomAttributes(typeof(TestFixtureAttribute), true).Any()).ToArray();
+			types = types ?? asm.GetTypes().Where(t => t.GetCustomAttributes(typeof(TestFixtureAttribute), true).Any()).ToArray();
+
+#if UNITY_EDITOR_OSX
+            System.IO.File.WriteAllLines("/temp/types.cs", types.Select(t => t.FullName).ToArray());
+#endif
 
 			Console_WriteLine("Found {0} test types.", types.Length);
 
 			foreach (Type t in types)
 			{
 				MethodInfo[] tests = t.GetMethods().Where(m => m.GetCustomAttributes(typeof(TestAttribute), true).Any()).ToArray();
-				Console_WriteLine("Testing {0} - {1} tests found.", t.Name, tests.Length);
+				//Console_WriteLine("Testing {0} - {1} tests found.", t.Name, tests.Length);
 
 				foreach (MethodInfo mi in tests)
 				{
@@ -189,7 +193,7 @@ namespace MoonSharp.Interpreter.Tests
 					return new TestResult()
 					{
 						TestName = mi.Name,
-						Message = ex.Message,
+						Message = BuildExceptionMessage(ex),
 						Type = TestResultType.Fail,
 						Exception = ex
 					};
@@ -197,6 +201,19 @@ namespace MoonSharp.Interpreter.Tests
 			}
 		}
 
+		private static string BuildExceptionMessage(Exception ex)
+		{
+			StringBuilder sb = new StringBuilder();
+
+			for (Exception e = ex; e != null; e = e.InnerException)
+			{
+				sb.Append(">>> ");
+				sb.Append(e.Message);
+			}
+
+			return sb.ToString();
+		}
+
 		internal static void Skip()
 		{
 			if (TestRunner.IsRunning)

TEMPAT SAMPAH
src/Unity/MoonSharp/Assets/UnitTestsRunner.unity


+ 5 - 0
src/Unity/MoonSharp/Assets/link.xml

@@ -0,0 +1,5 @@
+<linker>
+       <assembly fullname="System.Core">
+               <type fullname="System.Linq.Enumerable" preserve="all"/>
+       </assembly>
+</linker>

+ 4 - 4
src/Unity/MoonSharp/MoonSharp.userprefs

@@ -1,10 +1,10 @@
 <Properties StartupItem="Assembly-CSharp.csproj">
   <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
-  <MonoDevelop.Ide.Workbench ActiveDocument="Assets/Tests/EndToEnd/VtUserDataPropertiesTests.cs">
+  <MonoDevelop.Ide.Workbench ActiveDocument="Assets/MainMenuBehaviour.cs">
     <Files>
-      <File FileName="Assets/Tests/EndToEnd/BinaryDumpTests.cs" Line="59" Column="1" />
-      <File FileName="Assets/TestRunnerBehaviour.cs" Line="53" Column="6" />
-      <File FileName="Assets/Tests/EndToEnd/VtUserDataPropertiesTests.cs" Line="468" Column="1" />
+      <File FileName="Assets/MainMenuBehaviour.cs" Line="1" Column="1" />
+      <File FileName="Assets/Tests/TestRunner.cs" Line="1" Column="1" />
+      <File FileName="Assets/Tests/EndToEnd/VtUserDataMethodsTests.cs" Line="126" Column="36" />
     </Files>
   </MonoDevelop.Ide.Workbench>
   <MonoDevelop.Ide.DebuggingService.Breakpoints>

TEMPAT SAMPAH
src/Unity/MoonSharp/ProjectSettings/EditorBuildSettings.asset


TEMPAT SAMPAH
src/Unity/MoonSharp/ProjectSettings/ProjectSettings.asset