コード例 #1
0
        public BooScriptCompiler()
        {
            compiler = BooHelpers.CreateBooCompiler();
            var parameters = compiler.Parameters;

            //parameters.Environment =

            parameters.GenerateInMemory   = true;
            parameters.Ducky              = true;
            parameters.WhiteSpaceAgnostic = false;
            parameters.References.Clear();
            //parameters.LoadDefaultReferences();//do not use! This will cause failures on future calls, within the context of a TShockPlugin(unknown reason).
            //parameters.StdLib = false;

            parameters.DisabledWarnings.Add("BCW0016");            //dont warn about unused namespaces...
            parameters.OutputType          = CompilerOutputType.Library;
            parameters.OutputAssembly      = "scripts.dll";
            parameters.GenerateCollectible = true;           //dont leak assemblies...
            var pipeline = new CompileToMemory();            //...when we compile them to memory.

            //parameters.Pipeline = new CompileToFile();
            //parameters.Pipeline = new Parse();

            injectImportsStep = new InjectImportsStep();
            pipeline.Insert(1, injectImportsStep);

            ensureMethodSignaturesStep = new EnsureMethodSignaturesStep();

            pipeline.Insert(2, ensureMethodSignaturesStep);

            parameters.Pipeline = pipeline;
        }
コード例 #2
0
        public static IEnumerable <Assembly> GetReferences(bool addCallingAssembly = true)
        {
            var assemblies = new List <Assembly>();

            //var assemblies = Assembly.GetEntryAssembly().GetReferencedAssemblies();
            var mscorAss = Assembly.GetAssembly(typeof(object));

#pragma warning disable 612, 618
            var sysAss  = Assembly.LoadWithPartialName("System");
            var sysCore = Assembly.LoadWithPartialName("System.Core");
#pragma warning restore 612, 618

            var otapiAss      = Assembly.GetAssembly(typeof(Vector2));
            var tshockAss     = Assembly.GetAssembly(typeof(TSPlayer));
            var corruptionAss = Assembly.GetAssembly(typeof(AreaFunctions));
            //var pluginAss = Assembly.GetExecutingAssembly();

            assemblies.Add(mscorAss);
            assemblies.Add(sysAss);
            assemblies.Add(otapiAss);
            assemblies.Add(tshockAss);
            assemblies.Add(corruptionAss);

            if (addCallingAssembly)
            {
                var pluginAss = Assembly.GetCallingAssembly();
                assemblies.Add(pluginAss);
            }

            assemblies.AddRange(BooHelpers.GetBooLangAssemblies());

            return(assemblies);
        }