Esempio n. 1
0
        private static bool IsUnsetUnsafe(ScriptCompilerBase.CompilerOption compilerOption)
        {
            if (string.IsNullOrEmpty(compilerOption?.Arg))
            {
                return(false);
            }

            return(compilerOption.Arg.Equals("/unsafe", StringComparison.Ordinal) ||
                   compilerOption.Arg.Equals("/unsafe+", StringComparison.Ordinal));
        }
Esempio n. 2
0
 private static string[] GetOptionDefines(ScriptCompilerBase.CompilerOption compilerOption)
 {
     return(compilerOption.Value.Split(CompilerOptionArgumentSeperators));
 }
Esempio n. 3
0
        private static bool TryGetReference(ScriptCompilerBase.CompilerOption option, string fileName,
                                            string projectDirectory, string[] systemReferenceDirectories,
                                            ref List <string> errors, out string result)
        {
            result = null;
            var value = option.Value;

            if (value.Length == 0)
            {
                errors.Add("No value set for reference");
                return(false); // break;
            }

            string[] refs = value.Split(CompilerOptionArgumentSeperators);

            if (refs.Length != 1)
            {
                errors.Add("Cannot specify multiple aliases using single /reference option");
                return(false); // break;
            }

            var reference = refs[0];

            if (reference.Length == 0)
            {
                return(false); // continue;
            }

            int index             = reference.IndexOf('=');
            var responseReference = index > -1 ? reference.Substring(index + 1) : reference;

            var  fullPathReference = responseReference;
            bool isRooted          = Path.IsPathRooted(responseReference);

            if (!isRooted)
            {
                foreach (var directory in systemReferenceDirectories)
                {
                    var systemReferencePath = Paths.Combine(directory, responseReference);
                    if (File.Exists(systemReferencePath))
                    {
                        fullPathReference = systemReferencePath;
                        isRooted          = true;
                        break;
                    }
                }

                var userPath = Paths.Combine(projectDirectory, responseReference);
                if (File.Exists(userPath))
                {
                    fullPathReference = userPath;
                    isRooted          = true;
                }
            }

            if (!isRooted)
            {
                errors.Add(
                    $"{fileName}: not parsed correctly: {responseReference} could not be found as a system library.\n" +
                    "If this was meant as a user reference please provide the relative path from project root (parent of the Assets folder) in the response file.");
                return(false); // continue;
            }

            responseReference = fullPathReference.Replace('\\', '/');
            result            = responseReference;
            return(true);
        }