From d023ec21f3e72cc72527fa5b44099d7c615c53cb Mon Sep 17 00:00:00 2001 From: Benjamin Dobell Date: Thu, 14 Nov 2019 02:48:59 +1100 Subject: [PATCH] Handle execution in unknown scripts (probably in a bad state) --- src/MoonSharp.Interpreter/TtsDebugger.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/MoonSharp.Interpreter/TtsDebugger.cs b/src/MoonSharp.Interpreter/TtsDebugger.cs index fd52e2ad..1ec25382 100644 --- a/src/MoonSharp.Interpreter/TtsDebugger.cs +++ b/src/MoonSharp.Interpreter/TtsDebugger.cs @@ -215,7 +215,13 @@ public static void OnStringDone(Script script) private static string SourceCodeToTempPath(SourceCode sourceCode) { - var scriptName = scriptNames[sourceCode.OwnerScript]; + string scriptName; + + if (!scriptNames.TryGetValue(sourceCode.OwnerScript, out scriptName)) + { + scriptName = "unknown"; + } + var sourceName = (scriptName == sourceCode.Name ? scriptName : $"{scriptName}_{sourceCode.Name}").Replace(Path.DirectorySeparatorChar, '_'); var path = Path.Combine(tempPath, sourceName + ".ttslua");