Add support for '//reference X.dll' alternative syntax to 'Reference X.dll' (Thanks SpiralP)

This commit is contained in:
UnknownShadow200 2020-06-02 19:51:38 +10:00
parent 43dc6c0c54
commit 3abe564c1c
2 changed files with 9 additions and 8 deletions

View File

@ -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 {

View File

@ -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<string> ReadSource(string path, CompilerParameters args, ref int offset) {
List<string> 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'