From 3abe564c1c41fdfe6b215f118be6b9fd5f3019d3 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 2 Jun 2020 19:51:38 +1000 Subject: [PATCH] Add support for '//reference X.dll' alternative syntax to 'Reference X.dll' (Thanks SpiralP) --- MCGalaxy/Games/LavaSurvival/LSConfig.cs | 9 ++------- MCGalaxy/Scripting/Scripting.cs | 8 +++++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/MCGalaxy/Games/LavaSurvival/LSConfig.cs b/MCGalaxy/Games/LavaSurvival/LSConfig.cs index ff7a64246..6642217b3 100644 --- a/MCGalaxy/Games/LavaSurvival/LSConfig.cs +++ b/MCGalaxy/Games/LavaSurvival/LSConfig.cs @@ -16,13 +16,8 @@ permissions and limitations under the Licenses. */ using System; -using System.IO; -using System.Timers; -using MCGalaxy.Commands; -using MCGalaxy.Maths; -using BlockID = System.UInt16; -using MCGalaxy.Config; -using System.Collections.Generic; +using MCGalaxy.Config; +using MCGalaxy.Maths; namespace MCGalaxy.Games { diff --git a/MCGalaxy/Scripting/Scripting.cs b/MCGalaxy/Scripting/Scripting.cs index e2e5c4ffe..75b17133b 100644 --- a/MCGalaxy/Scripting/Scripting.cs +++ b/MCGalaxy/Scripting/Scripting.cs @@ -128,11 +128,17 @@ namespace MCGalaxy.Scripting { return results; } + static bool IsReferenceLine(string line) { + // Originally only 'Reference X.dll' syntax was supported + // Later '//Reference X.dll' was added, and is preferred + return line.CaselessStarts("reference ") || line.CaselessStarts("//reference "); + } + static List ReadSource(string path, CompilerParameters args, ref int offset) { List lines = Utils.ReadAllLinesList(path); // Allow referencing other assemblies using 'Reference [assembly name]' at top of the file for (int i = 0; i < lines.Count; i++) { - if (!lines[i].CaselessStarts("reference ")) break; + if (!IsReferenceLine(lines[i])) break; int index = lines[i].IndexOf(' ') + 1; // For consistency with C#, treat 'Reference X.dll;' as 'Reference X.dll'