コード例 #1
0
ファイル: BooCompiler.cs プロジェクト: wensincai/Unity5.4
        protected override Program StartCompiler()
        {
            List <string> list = new List <string>
            {
                "-debug",
                "-target:library",
                "-out:" + this._island._output,
                "-x-type-inference-rule-attribute:" + typeof(TypeInferenceRuleAttribute)
            };

            string[] references = this._island._references;
            for (int i = 0; i < references.Length; i++)
            {
                string fileName = references[i];
                list.Add("-r:" + ScriptCompilerBase.PrepareFileName(fileName));
            }
            foreach (string current in this._island._defines.Distinct <string>())
            {
                list.Add("-define:" + current);
            }
            string[] files = this._island._files;
            for (int j = 0; j < files.Length; j++)
            {
                string fileName2 = files[j];
                list.Add(ScriptCompilerBase.PrepareFileName(fileName2));
            }
            string compiler = Path.Combine(base.GetProfileDirectory(), "booc.exe");

            return(base.StartCompiler(this._island._target, compiler, list));
        }
コード例 #2
0
        public override string GetNamespace(string filePath, string definedSymbols)
        {
            var targetAssemblyFromPath = EditorCompilationInterface.Instance.GetTargetAssemblyFromPath(filePath);
            var definedSymbolsSplit    = definedSymbols.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            string[] fullListOfDefines = new string[definedSymbolsSplit.Length + (targetAssemblyFromPath?.Defines?.Length ?? 0)];
            Array.Copy(definedSymbolsSplit, fullListOfDefines, definedSymbolsSplit.Length);

            if (targetAssemblyFromPath?.Defines != null)
            {
                Array.Copy(targetAssemblyFromPath.Defines, 0, fullListOfDefines, definedSymbolsSplit.Length, targetAssemblyFromPath.Defines.Length);
            }

            var rspFile = targetAssemblyFromPath?.GetResponseFiles()?.FirstOrDefault();
            ApiCompatibilityLevel compatibilityLevel = ApiCompatibilityLevel.NET_4_6;

            string[] rspDefines = null;
            if (!string.IsNullOrEmpty(rspFile))
            {
                rspDefines = ScriptCompilerBase.ParseResponseFileFromFile(
                    rspFile,
                    Application.dataPath,
                    GetSystemReferenceDirectories(compatibilityLevel)).Defines;
            }

            return(GetNamespaceNewRuntime(filePath, fullListOfDefines, rspDefines));
        }
コード例 #3
0
        protected override Program StartCompiler()
        {
            string        str  = ScriptCompilerBase.PrepareFileName(this._island._output);
            List <string> list = new List <string>
            {
                "/target:library",
                "/nowarn:0169",
                "/unsafe",
                "/out:" + str
            };

            if (!this._island._development_player)
            {
                list.Add("/debug:pdbonly");
                list.Add("/optimize+");
            }
            else
            {
                list.Add("/debug:full");
                list.Add("/optimize-");
            }
            string argsPrefix;

            this.FillCompilerOptions(list, out argsPrefix);
            return(this.StartCompilerImpl(list, argsPrefix));
        }
コード例 #4
0
        protected override Program StartCompiler()
        {
            List <string> arguments = new List <string> {
                "-debug",
                "-target:library",
                "-out:" + this._island._output,
                "-x-type-inference-rule-attribute:" + typeof(TypeInferenceRuleAttribute)
            };

            foreach (string str in this._island._references)
            {
                arguments.Add("-r:" + ScriptCompilerBase.PrepareFileName(str));
            }
            foreach (string str2 in this._island._defines.Distinct <string>())
            {
                arguments.Add("-define:" + str2);
            }
            foreach (string str3 in this._island._files)
            {
                arguments.Add(ScriptCompilerBase.PrepareFileName(str3));
            }
            string compiler = Path.Combine(base.GetProfileDirectory(), "booc.exe");

            return(base.StartCompiler(this._island._target, compiler, arguments));
        }
コード例 #5
0
        protected override Program StartCompiler()
        {
            List <string> arguments = new List <string>()
            {
                "-debug", "-target:library", "-nowarn:0169", "-out:" + ScriptCompilerBase.PrepareFileName(this._island._output)
            };

            foreach (string reference in this._island._references)
            {
                arguments.Add("-r:" + ScriptCompilerBase.PrepareFileName(reference));
            }
            foreach (string str in ((IEnumerable <string>) this._island._defines).Distinct <string>())
            {
                arguments.Add("-define:" + str);
            }
            foreach (string file in this._island._files)
            {
                arguments.Add(ScriptCompilerBase.PrepareFileName(file));
            }
            foreach (string additionalReference in this.GetAdditionalReferences())
            {
                string str = Path.Combine(this.GetProfileDirectory(), additionalReference);
                if (File.Exists(str))
                {
                    arguments.Add("-r:" + ScriptCompilerBase.PrepareFileName(str));
                }
            }
            return((Program)this.StartCompiler(this._island._target, this.GetCompilerPath(arguments), arguments));
        }
コード例 #6
0
        protected override Program StartCompiler()
        {
            List <string> arguments = new List <string>()
            {
                "-debug", "-target:library", "-i:UnityEngine", "-i:System.Collections", "-base:UnityEngine.MonoBehaviour", "-nowarn:BCW0016", "-nowarn:BCW0003", "-method:Main", "-out:" + this._island._output, "-x-type-inference-rule-attribute:" + (object)typeof(TypeInferenceRuleAttribute)
            };

            if (this.StrictBuildTarget())
            {
                arguments.Add("-pragmas:strict,downcast");
            }
            foreach (string str in ((IEnumerable <string>) this._island._defines).Distinct <string>())
            {
                arguments.Add("-define:" + str);
            }
            foreach (string reference in this._island._references)
            {
                arguments.Add("-r:" + ScriptCompilerBase.PrepareFileName(reference));
            }
            if (Array.Exists <string>(this._island._references, new Predicate <string>(UnityScriptCompiler.UnityEditorPattern.IsMatch)))
            {
                arguments.Add("-i:UnityEditor");
            }
            else if (!BuildPipeline.IsUnityScriptEvalSupported(this._island._target))
            {
                arguments.Add(string.Format("-disable-eval:eval is not supported on the current build target ({0}).", (object)this._island._target));
            }
            foreach (string file in this._island._files)
            {
                arguments.Add(ScriptCompilerBase.PrepareFileName(file));
            }
            return((Program)this.StartCompiler(this._island._target, Path.Combine(this.GetProfileDirectory(), "us.exe"), arguments));
        }
コード例 #7
0
        private Program StartCompilerImpl(List <string> arguments, string argsPrefix, bool msBuildCompiler)
        {
            foreach (string reference in this._island._references)
            {
                arguments.Add("/reference:" + ScriptCompilerBase.PrepareFileName(reference));
            }
            foreach (string str in ((IEnumerable <string>) this._island._defines).Distinct <string>())
            {
                arguments.Add("/define:" + str);
            }
            foreach (string file in this._island._files)
            {
                arguments.Add(ScriptCompilerBase.PrepareFileName(file).Replace('/', '\\'));
            }
            string path = !msBuildCompiler?Path.Combine(MicrosoftCSharpCompiler.WindowsDirectory, "Microsoft.NET\\Framework\\v4.0.30319\\Csc.exe") : Path.Combine(MicrosoftCSharpCompiler.ProgramFilesDirectory, "MSBuild\\14.0\\Bin\\csc.exe");

            if (!File.Exists(path))
            {
                throw new Exception("'" + path + "' not found, either .NET 4.5 is not installed or your OS is not Windows 8/8.1.");
            }
            this.AddCustomResponseFileIfPresent(arguments, "csc.rsp");
            string  responseFile = CommandLineFormatter.GenerateResponseFile((IEnumerable <string>)arguments);
            Program program      = new Program(new ProcessStartInfo()
            {
                Arguments = argsPrefix + "@" + responseFile, FileName = path, CreateNoWindow = true
            });

            program.Start();
            return(program);
        }
コード例 #8
0
        protected override Program StartCompiler()
        {
            List <string> list = new List <string>
            {
                "-debug",
                "-target:library",
                "-nowarn:0169",
                "-langversion:4",
                "-out:" + ScriptCompilerBase.PrepareFileName(this._island._output),
                "-unsafe"
            };

            if (!this._island._development_player && !this._island._editor)
            {
                list.Add("-optimize");
            }
            string[] references = this._island._references;
            for (int i = 0; i < references.Length; i++)
            {
                string fileName = references[i];
                list.Add("-r:" + ScriptCompilerBase.PrepareFileName(fileName));
            }
            foreach (string current in this._island._defines.Distinct <string>())
            {
                list.Add("-define:" + current);
            }
            string[] files = this._island._files;
            for (int j = 0; j < files.Length; j++)
            {
                string fileName2 = files[j];
                list.Add(ScriptCompilerBase.PrepareFileName(fileName2));
            }
            string profile          = (this._island._api_compatibility_level != ApiCompatibilityLevel.NET_2_0) ? base.GetMonoProfileLibDirectory() : "2.0-api";
            string profileDirectory = MonoInstallationFinder.GetProfileDirectory(profile, "MonoBleedingEdge");

            string[] additionalReferences = this.GetAdditionalReferences();
            for (int k = 0; k < additionalReferences.Length; k++)
            {
                string path = additionalReferences[k];
                string text = Path.Combine(profileDirectory, path);
                if (File.Exists(text))
                {
                    list.Add("-r:" + ScriptCompilerBase.PrepareFileName(text));
                }
            }
            if (!base.AddCustomResponseFileIfPresent(list, "mcs.rsp"))
            {
                if (this._island._api_compatibility_level == ApiCompatibilityLevel.NET_2_0_Subset && base.AddCustomResponseFileIfPresent(list, "smcs.rsp"))
                {
                    Debug.LogWarning("Using obsolete custom response file 'smcs.rsp'. Please use 'mcs.rsp' instead.");
                }
                else if (this._island._api_compatibility_level == ApiCompatibilityLevel.NET_2_0 && base.AddCustomResponseFileIfPresent(list, "gmcs.rsp"))
                {
                    Debug.LogWarning("Using obsolete custom response file 'gmcs.rsp'. Please use 'mcs.rsp' instead.");
                }
            }
            return(base.StartCompiler(this._island._target, this.GetCompilerPath(list), list, false, MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge")));
        }
コード例 #9
0
        public override string GetNamespace(string filePath, string definedSymbols)
        {
            var responseFilePath = Path.Combine("Assets", MicrosoftCSharpCompiler.ResponseFilename);
            var responseFileData = ScriptCompilerBase.ParseResponseFileFromFile(
                responseFilePath,
                Directory.GetParent(Application.dataPath).FullName,
                GetSystemReferenceDirectories(ApiCompatibilityLevel.NET_4_6));

            return(GetNamespaceNewRuntime(filePath, definedSymbols, responseFileData.Defines));
        }
コード例 #10
0
        protected override Program StartCompiler()
        {
            List <string> arguments = new List <string> {
                "-debug",
                "-target:library",
                "-i:UnityEngine",
                "-i:System.Collections",
                "-base:UnityEngine.MonoBehaviour",
                "-nowarn:BCW0016",
                "-nowarn:BCW0003",
                "-method:Main",
                "-out:" + this._island._output,
                "-x-type-inference-rule-attribute:" + typeof(TypeInferenceRuleAttribute)
            };

            if (this.StrictBuildTarget())
            {
                arguments.Add("-pragmas:strict,downcast");
            }
            IEnumerator <string> enumerator = this._island._defines.Distinct <string>().GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    arguments.Add("-define:" + enumerator.Current);
                }
            }
            finally
            {
                if (enumerator == null)
                {
                }
                enumerator.Dispose();
            }
            foreach (string str2 in this._island._references)
            {
                arguments.Add("-r:" + ScriptCompilerBase.PrepareFileName(str2));
            }
            if (Array.Exists <string>(this._island._references, new Predicate <string>(UnityEditorPattern.IsMatch)))
            {
                arguments.Add("-i:UnityEditor");
            }
            else if (!BuildPipeline.IsUnityScriptEvalSupported(this._island._target))
            {
                arguments.Add(string.Format("-disable-eval:eval is not supported on the current build target ({0}).", this._island._target));
            }
            foreach (string str3 in this._island._files)
            {
                arguments.Add(ScriptCompilerBase.PrepareFileName(str3));
            }
            string compiler = Path.Combine(base.GetProfileDirectory(), "us.exe");

            return(base.StartCompiler(this._island._target, compiler, arguments));
        }
コード例 #11
0
        protected override Program StartCompiler()
        {
            List <string> list = new List <string>
            {
                "-debug",
                "-target:library",
                "-i:UnityEngine",
                "-i:System.Collections",
                "-base:UnityEngine.MonoBehaviour",
                "-nowarn:BCW0016",
                "-nowarn:BCW0003",
                "-method:Main",
                "-out:" + this._island._output,
                "-x-type-inference-rule-attribute:" + typeof(TypeInferenceRuleAttribute)
            };

            if (this.StrictBuildTarget())
            {
                list.Add("-pragmas:strict,downcast");
            }
            foreach (string current in this._island._defines.Distinct <string>())
            {
                list.Add("-define:" + current);
            }
            string[] references = this._island._references;
            for (int i = 0; i < references.Length; i++)
            {
                string fileName = references[i];
                list.Add("-r:" + ScriptCompilerBase.PrepareFileName(fileName));
            }
            bool flag = Array.Exists <string>(this._island._references, new Predicate <string>(UnityScriptCompiler.UnityEditorPattern.IsMatch));

            if (flag)
            {
                list.Add("-i:UnityEditor");
            }
            else
            {
                if (!BuildPipeline.IsUnityScriptEvalSupported(this._island._target))
                {
                    list.Add(string.Format("-disable-eval:eval is not supported on the current build target ({0}).", this._island._target));
                }
            }
            string[] files = this._island._files;
            for (int j = 0; j < files.Length; j++)
            {
                string fileName2 = files[j];
                list.Add(ScriptCompilerBase.PrepareFileName(fileName2));
            }
            string compiler = Path.Combine(base.GetProfileDirectory(), "us.exe");

            return(base.StartCompiler(this._island._target, compiler, list));
        }
コード例 #12
0
        private Program StartCompilerImpl(List <string> arguments, string argsPrefix, bool msBuildCompiler)
        {
            string str4;

            foreach (string str in this._island._references)
            {
                arguments.Add("/reference:" + ScriptCompilerBase.PrepareFileName(str));
            }
            IEnumerator <string> enumerator = this._island._defines.Distinct <string>().GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    arguments.Add("/define:" + enumerator.Current);
                }
            }
            finally
            {
                if (enumerator == null)
                {
                }
                enumerator.Dispose();
            }
            foreach (string str3 in this._island._files)
            {
                arguments.Add(ScriptCompilerBase.PrepareFileName(str3).Replace('/', '\\'));
            }
            if (msBuildCompiler)
            {
                str4 = Path.Combine(ProgramFilesDirectory, @"MSBuild\14.0\Bin\csc.exe");
            }
            else
            {
                str4 = Path.Combine(WindowsDirectory, @"Microsoft.NET\Framework\v4.0.30319\Csc.exe");
            }
            if (!File.Exists(str4))
            {
                throw new Exception("'" + str4 + "' not found, either .NET 4.5 is not installed or your OS is not Windows 8/8.1.");
            }
            base.AddCustomResponseFileIfPresent(arguments, "csc.rsp");
            string           str5 = CommandLineFormatter.GenerateResponseFile(arguments);
            ProcessStartInfo si   = new ProcessStartInfo {
                Arguments      = argsPrefix + "@" + str5,
                FileName       = str4,
                CreateNoWindow = true
            };
            Program program = new Program(si);

            program.Start();
            return(program);
        }
コード例 #13
0
        public override void GetClassAndNamespace(string filePath, string definedSymbols,
                                                  out string outClassName, out string outNamespace)
        {
            var responseFilePath = Path.Combine("Assets", MicrosoftCSharpCompiler.ResponseFilename);
            var responseFileData = ScriptCompilerBase.ParseResponseFileFromFile(
                responseFilePath,
                Directory.GetParent(Application.dataPath).FullName,
                GetSystemReferenceDirectories(ApiCompatibilityLevel.NET_4_6));

            var definedSymbolSplit = definedSymbols.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var uniqueSymbols      = responseFileData.Defines.Union(definedSymbolSplit).Distinct().ToArray();

            CSharpNamespaceParser.GetClassAndNamespace(ReadAndConverteNewLines(filePath).ReadToEnd(),
                                                       Path.GetFileNameWithoutExtension(filePath), out outClassName, out outNamespace, uniqueSymbols);
        }
コード例 #14
0
        private string GetCompilerPath(List <string> arguments)
        {
            string profileDirectory = MonoInstallationFinder.GetProfileDirectory("4.5", "MonoBleedingEdge");
            string text             = Path.Combine(profileDirectory, "mcs.exe");

            if (File.Exists(text))
            {
                string profile = (this._island._api_compatibility_level != ApiCompatibilityLevel.NET_2_0) ? BuildPipeline.CompatibilityProfileToClassLibFolder(this._island._api_compatibility_level) : "2.0-api";
                if (this._island._api_compatibility_level != ApiCompatibilityLevel.NET_Standard_2_0)
                {
                    arguments.Add("-lib:" + ScriptCompilerBase.PrepareFileName(MonoInstallationFinder.GetProfileDirectory(profile, "MonoBleedingEdge")));
                }
                return(text);
            }
            throw new ApplicationException("Unable to find csharp compiler in " + profileDirectory);
        }
コード例 #15
0
        public static string[] GetResponseFileDefinesFromFile(string responseFileName)
        {
            string path = Path.Combine("Assets", responseFileName);

            string[] result;
            if (!File.Exists(path))
            {
                result = new string[0];
            }
            else
            {
                string responseFileText = File.ReadAllText(path);
                result = ScriptCompilerBase.GetResponseFileDefinesFromText(responseFileText);
            }
            return(result);
        }
コード例 #16
0
        protected override Program StartCompiler()
        {
            List <string> list = new List <string>
            {
                "-debug",
                "-target:library",
                "-nowarn:0169",
                "-langversion:" + ((EditorApplication.scriptingRuntimeVersion != ScriptingRuntimeVersion.Latest) ? "4" : "6"),
                "-out:" + ScriptCompilerBase.PrepareFileName(this._island._output),
                "-nostdlib",
                "-unsafe"
            };

            if (!this._island._development_player && !this._island._editor)
            {
                list.Add("-optimize");
            }
            string[] references = this._island._references;
            for (int i = 0; i < references.Length; i++)
            {
                string fileName = references[i];
                list.Add("-r:" + ScriptCompilerBase.PrepareFileName(fileName));
            }
            foreach (string current in this._island._defines.Distinct <string>())
            {
                list.Add("-define:" + current);
            }
            string[] files = this._island._files;
            for (int j = 0; j < files.Length; j++)
            {
                string fileName2 = files[j];
                list.Add(ScriptCompilerBase.PrepareFileName(fileName2));
            }
            if (!base.AddCustomResponseFileIfPresent(list, MonoCSharpCompiler.ReponseFilename))
            {
                if (this._island._api_compatibility_level == ApiCompatibilityLevel.NET_2_0_Subset && base.AddCustomResponseFileIfPresent(list, "smcs.rsp"))
                {
                    Debug.LogWarning(string.Format("Using obsolete custom response file 'smcs.rsp'. Please use '{0}' instead.", MonoCSharpCompiler.ReponseFilename));
                }
                else if (this._island._api_compatibility_level == ApiCompatibilityLevel.NET_2_0 && base.AddCustomResponseFileIfPresent(list, "gmcs.rsp"))
                {
                    Debug.LogWarning(string.Format("Using obsolete custom response file 'gmcs.rsp'. Please use '{0}' instead.", MonoCSharpCompiler.ReponseFilename));
                }
            }
            return(base.StartCompiler(this._island._target, this.GetCompilerPath(list), list, false, MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge")));
        }
コード例 #17
0
        protected override Program StartCompiler()
        {
            string        str       = ScriptCompilerBase.PrepareFileName(this._island._output);
            List <string> arguments = new List <string>
            {
                "/debug:pdbonly",
                "/optimize+",
                "/target:library",
                "/nowarn:0169",
                "/unsafe",
                "/out:" + str
            };
            string argsPrefix;

            this.FillCompilerOptions(arguments, out argsPrefix);
            return(this.StartCompilerImpl(arguments, argsPrefix));
        }
コード例 #18
0
        public string GetNamespaceOldRuntime(string filePath, string definedSymbols)
        {
            var definedSymbolSplit = definedSymbols.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            string[] defines          = null;
            var      responseFilePath = Path.Combine("Assets", MonoCSharpCompiler.ReponseFilename);

            try
            {
                var responseFileData = ScriptCompilerBase.ParseResponseFileFromFile(responseFilePath);
                defines = new string[responseFileData.Defines.Length + definedSymbolSplit.Length];
                Array.Copy(definedSymbolSplit, defines, definedSymbolSplit.Length);
                Array.Copy(responseFileData.Defines, 0, defines, definedSymbolSplit.Length, responseFileData.Defines.Length);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            var uniqueSymbols = new HashSet <string>(defines ?? definedSymbolSplit);

            using (var parser = ParserFactory.CreateParser(ICSharpCode.NRefactory.SupportedLanguage.CSharp, ReadAndConverteNewLines(filePath)))
            {
                foreach (var symbol in uniqueSymbols)
                {
                    parser.Lexer.ConditionalCompilationSymbols.Add(symbol, string.Empty);
                }

                parser.Lexer.EvaluateConditionalCompilation = true;
                parser.Parse();
                try
                {
                    var visitor = new NamespaceVisitor();
                    var data    = new VisitorData {
                        TargetClassName = Path.GetFileNameWithoutExtension(filePath)
                    };
                    parser.CompilationUnit.AcceptVisitor(visitor, data);
                    return(string.IsNullOrEmpty(data.DiscoveredNamespace) ? string.Empty : data.DiscoveredNamespace);
                }
                catch
                {
                    // Don't care; all we want is the namespace
                }
            }
            return(string.Empty);
        }
コード例 #19
0
        private Program StartCompilerImpl(List <string> arguments, string argsPrefix, bool msBuildCompiler)
        {
            string[] references = this._island._references;
            for (int i = 0; i < references.Length; i++)
            {
                string fileName = references[i];
                arguments.Add("/reference:" + ScriptCompilerBase.PrepareFileName(fileName));
            }
            foreach (string current in this._island._defines.Distinct <string>())
            {
                arguments.Add("/define:" + current);
            }
            string[] files = this._island._files;
            for (int j = 0; j < files.Length; j++)
            {
                string fileName2 = files[j];
                arguments.Add(ScriptCompilerBase.PrepareFileName(fileName2).Replace('/', '\\'));
            }
            string text;

            if (msBuildCompiler)
            {
                text = Path.Combine(MicrosoftCSharpCompiler.ProgramFilesDirectory, "MSBuild\\14.0\\Bin\\csc.exe");
            }
            else
            {
                text = Path.Combine(MicrosoftCSharpCompiler.WindowsDirectory, "Microsoft.NET\\Framework\\v4.0.30319\\Csc.exe");
            }
            if (!File.Exists(text))
            {
                throw new Exception("'" + text + "' not found, either .NET 4.5 is not installed or your OS is not Windows 8/8.1.");
            }
            base.AddCustomResponseFileIfPresent(arguments, "csc.rsp");
            string           str = CommandLineFormatter.GenerateResponseFile(arguments);
            ProcessStartInfo si  = new ProcessStartInfo
            {
                Arguments      = argsPrefix + "@" + str,
                FileName       = text,
                CreateNoWindow = true
            };
            Program program = new Program(si);

            program.Start();
            return(program);
        }
コード例 #20
0
        protected override Program StartCompiler()
        {
            string        str       = ScriptCompilerBase.PrepareFileName(this._island._output);
            List <string> arguments = new List <string> {
                "/target:library",
                "/nowarn:0169",
                "/out:" + str
            };

            string[] collection = new string[] { "/debug:pdbonly", "/optimize+" };
            arguments.InsertRange(0, collection);
            string argsPrefix = string.Empty;

            if (base.CompilingForWSA() && ((PlayerSettings.WSA.compilationOverrides == PlayerSettings.WSACompilationOverrides.UseNetCore) || (PlayerSettings.WSA.compilationOverrides == PlayerSettings.WSACompilationOverrides.UseNetCorePartially)))
            {
                this.FillNETCoreCompilerOptions(EditorUserBuildSettings.wsaSDK, arguments, ref argsPrefix);
            }
            return(this.StartCompilerImpl(arguments, argsPrefix, EditorUserBuildSettings.wsaSDK == WSASDK.UWP));
        }
コード例 #21
0
        protected override Program StartCompiler()
        {
            List <string> arguments = new List <string>()
            {
                "/target:library", "/nowarn:0169", "/out:" + ScriptCompilerBase.PrepareFileName(this._island._output)
            };

            arguments.InsertRange(0, (IEnumerable <string>) new string[2]
            {
                "/debug:pdbonly",
                "/optimize+"
            });
            string empty = string.Empty;

            if (this.CompilingForWSA() && (PlayerSettings.WSA.compilationOverrides == PlayerSettings.WSACompilationOverrides.UseNetCore || PlayerSettings.WSA.compilationOverrides == PlayerSettings.WSACompilationOverrides.UseNetCorePartially))
            {
                this.FillNETCoreCompilerOptions(EditorUserBuildSettings.wsaSDK, arguments, ref empty);
            }
            return(this.StartCompilerImpl(arguments, empty, EditorUserBuildSettings.wsaSDK == WSASDK.UWP));
        }
コード例 #22
0
        public override string GetNamespace(string filePath, string definedSymbols)
        {
            var responseFilePath = Path.Combine("Assets", MonoCSharpCompiler.ResponseFilename);

            if (EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest)
            {
                var responseFileData = ScriptCompilerBase.ParseResponseFileFromFile(
                    responseFilePath,
                    Application.dataPath,
                    GetSystemReferenceDirectories(ApiCompatibilityLevel.NET_4_6));
                return(GetNamespaceNewRuntime(filePath, definedSymbols, responseFileData.Defines));
            }
            else
            {
                var responseFileData = ScriptCompilerBase.ParseResponseFileFromFile(
                    responseFilePath,
                    Application.dataPath,
                    GetSystemReferenceDirectories(ApiCompatibilityLevel.NET_2_0));
                return(GetNamespaceOldRuntime(filePath, definedSymbols, responseFileData.Defines));
            }
        }
コード例 #23
0
        protected override Program StartCompiler()
        {
            List <string> arguments = new List <string>()
            {
                "-debug", "-target:library", "-out:" + this._island._output, "-x-type-inference-rule-attribute:" + (object)typeof(TypeInferenceRuleAttribute)
            };

            foreach (string reference in this._island._references)
            {
                arguments.Add("-r:" + ScriptCompilerBase.PrepareFileName(reference));
            }
            foreach (string str in ((IEnumerable <string>) this._island._defines).Distinct <string>())
            {
                arguments.Add("-define:" + str);
            }
            foreach (string file in this._island._files)
            {
                arguments.Add(ScriptCompilerBase.PrepareFileName(file));
            }
            return((Program)this.StartCompiler(this._island._target, Path.Combine(this.GetProfileDirectory(), "booc.exe"), arguments));
        }
コード例 #24
0
        protected override Program StartCompiler()
        {
            List <string> list = new List <string>
            {
                "-debug",
                "-target:library",
                "-nowarn:0169",
                "-out:" + ScriptCompilerBase.PrepareFileName(this._island._output)
            };

            string[] references = this._island._references;
            for (int i = 0; i < references.Length; i++)
            {
                string fileName = references[i];
                list.Add("-r:" + ScriptCompilerBase.PrepareFileName(fileName));
            }
            foreach (string current in this._island._defines.Distinct <string>())
            {
                list.Add("-define:" + current);
            }
            string[] files = this._island._files;
            for (int j = 0; j < files.Length; j++)
            {
                string fileName2 = files[j];
                list.Add(ScriptCompilerBase.PrepareFileName(fileName2));
            }
            string[] additionalReferences = this.GetAdditionalReferences();
            for (int k = 0; k < additionalReferences.Length; k++)
            {
                string path = additionalReferences[k];
                string text = Path.Combine(base.GetProfileDirectory(), path);
                if (File.Exists(text))
                {
                    list.Add("-r:" + ScriptCompilerBase.PrepareFileName(text));
                }
            }
            return(base.StartCompiler(this._island._target, this.GetCompilerPath(list), list));
        }
コード例 #25
0
        protected override Program StartCompiler()
        {
            string        str  = ScriptCompilerBase.PrepareFileName(this._island._output);
            List <string> list = new List <string>
            {
                "/target:library",
                "/nowarn:0169",
                "/out:" + str
            };

            list.InsertRange(0, new string[]
            {
                "/debug:pdbonly",
                "/optimize+"
            });
            string empty = string.Empty;

            if (base.CompilingForWSA() && (PlayerSettings.WSA.compilationOverrides == PlayerSettings.WSACompilationOverrides.UseNetCore || PlayerSettings.WSA.compilationOverrides == PlayerSettings.WSACompilationOverrides.UseNetCorePartially))
            {
                this.FillNETCoreCompilerOptions(EditorUserBuildSettings.wsaSDK, list, ref empty);
            }
            return(this.StartCompilerImpl(list, empty, EditorUserBuildSettings.wsaSDK == WSASDK.UWP));
        }
コード例 #26
0
        public string GetNamespaceNewRuntime(string filePath, string definedSymbols)
        {
            var definedSymbolSplit = definedSymbols.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            string[] defines          = null;
            var      responseFilePath = Path.Combine("Assets", MonoCSharpCompiler.ReponseFilename);

            try
            {
                var responseFileData = ScriptCompilerBase.ParseResponseFileFromFile(responseFilePath);
                defines = new string[responseFileData.Defines.Length + definedSymbolSplit.Length];
                Array.Copy(definedSymbolSplit, defines, definedSymbolSplit.Length);
                Array.Copy(responseFileData.Defines, 0, defines, definedSymbolSplit.Length, responseFileData.Defines.Length);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            var uniqueSymbols = new HashSet <string>(defines ?? definedSymbolSplit);

            return(CSharpNamespaceParser.GetNamespace(ReadAndConverteNewLines(filePath).ReadToEnd(), Path.GetFileNameWithoutExtension(filePath), uniqueSymbols.ToArray()));
        }
コード例 #27
0
        protected override Program StartCompiler()
        {
            List <string> arguments = new List <string> {
                "-debug",
                "-target:library",
                "-out:" + this._island._output,
                "-x-type-inference-rule-attribute:" + typeof(TypeInferenceRuleAttribute)
            };

            foreach (string str in this._island._references)
            {
                arguments.Add("-r:" + ScriptCompilerBase.PrepareFileName(str));
            }
            IEnumerator <string> enumerator = this._island._defines.Distinct <string>().GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    arguments.Add("-define:" + enumerator.Current);
                }
            }
            finally
            {
                if (enumerator == null)
                {
                }
                enumerator.Dispose();
            }
            foreach (string str3 in this._island._files)
            {
                arguments.Add(ScriptCompilerBase.PrepareFileName(str3));
            }
            string compiler = Path.Combine(base.GetProfileDirectory(), "booc.exe");

            return(base.StartCompiler(this._island._target, compiler, arguments));
        }
コード例 #28
0
        private Program StartCompilerImpl(List <string> arguments, string argsPrefix)
        {
            string[] references = this._island._references;
            for (int i = 0; i < references.Length; i++)
            {
                string fileName = references[i];
                arguments.Add("/reference:" + ScriptCompilerBase.PrepareFileName(fileName));
            }
            foreach (string current in this._island._defines.Distinct <string>())
            {
                arguments.Add("/define:" + current);
            }
            string[] files = this._island._files;
            for (int j = 0; j < files.Length; j++)
            {
                string fileName2 = files[j];
                arguments.Add(ScriptCompilerBase.PrepareFileName(fileName2).Replace('/', '\\'));
            }
            string text = Paths.Combine(new string[]
            {
                EditorApplication.applicationContentsPath,
                "Tools",
                "Roslyn",
                "CoreRun.exe"
            }).Replace('/', '\\');
            string text2 = Paths.Combine(new string[]
            {
                EditorApplication.applicationContentsPath,
                "Tools",
                "Roslyn",
                "csc.exe"
            }).Replace('/', '\\');

            if (!File.Exists(text))
            {
                MicrosoftCSharpCompiler.ThrowCompilerNotFoundException(text);
            }
            if (!File.Exists(text2))
            {
                MicrosoftCSharpCompiler.ThrowCompilerNotFoundException(text2);
            }
            base.AddCustomResponseFileIfPresent(arguments, "csc.rsp");
            string           text3 = CommandLineFormatter.GenerateResponseFile(arguments);
            ProcessStartInfo si    = new ProcessStartInfo
            {
                Arguments = string.Concat(new string[]
                {
                    "\"",
                    text2,
                    "\" ",
                    argsPrefix,
                    "@",
                    text3
                }),
                FileName       = text,
                CreateNoWindow = true
            };
            Program program = new Program(si);

            program.Start();
            return(program);
        }