• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CompilerOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CompilerOptions的典型用法代码示例。如果您正苦于以下问题:C# CompilerOptions类的具体用法?C# CompilerOptions怎么用?C# CompilerOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CompilerOptions类属于命名空间,在下文中一共展示了CompilerOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CombiningWithOtherOptionsOverwrites

        public void CombiningWithOtherOptionsOverwrites()
        {
            var options = new CompilerOptions
            {
                AllowUnsafe = false,
                Optimize = true,
                WarningsAsErrors = true,
                LanguageVersion = "x"
            };

            var options2 = new CompilerOptions
            {
                AllowUnsafe = true,
                Optimize = false,
                WarningsAsErrors = false,
                LanguageVersion = "y",
            };

            var result = CompilerOptions.Combine(options, options2);

            Assert.True(result.AllowUnsafe.Value);
            Assert.False(result.Optimize.Value);
            Assert.False(result.WarningsAsErrors.Value);
            Assert.Equal("y", result.LanguageVersion);
        }
开发者ID:leloulight,项目名称:dnx,代码行数:25,代码来源:CompilerOptionsFacts.cs


示例2: GetParser

        private Parser GetParser()
        {
            if (_parser == null)
                {
                    using (var options = new CompilerOptions())
                    {
                        var sourceItems = new SourceItem[]{
                            new TextItem()
                            {

                                Name = "GdlGrammer", ContentType = TextItemType.MGrammar, Reader = new StringReader(Language)
                            }
                        };

                        options.AddSourceItems(sourceItems);

                        CompilationResults results = Compiler.Compile(options);
                        if (results.HasErrors)
                        {
                            //TODO: show meaningful error message
                            throw new Exception("Failed to compile GDL ....");
                        }
                        else
                        {
                            foreach (var parserFactory in results.ParserFactories)
                            {
                                //TODO: Why inside foreach loop!!!
                                _parser = parserFactory.Value.Create();
                            }
                        }
                    }
                }
                return _parser;
        }
开发者ID:tuliosouza,项目名称:ASG,代码行数:34,代码来源:GestureDefinitionLanguage.cs


示例3: Compile

        public CodePart Compile(int startLineNum, ParseTree tree, Context context, CompilerOptions options)
        {
            InitCompileFlags();

            part = new CodePart();
            this.context = context;
            this.options = options;
            this.startLineNum = startLineNum;

            ++context.NumCompilesSoFar;

            try
            {
                if (tree.Nodes.Count > 0)
                {
                    PreProcess(tree);
                    CompileProgram(tree);
                }
            }
            catch (KOSException kosException)
            {
                if (lastNode != null)
                {
                    throw;  // TODO something more sophisticated will go here that will
                    // attach source/line information to the exception before throwing it upward.
                    // that's why this seemingly pointless "catch and then throw again" is here.
                }
                SafeHouse.Logger.Log("Exception in Compiler: " + kosException.Message);
                SafeHouse.Logger.Log(kosException.StackTrace);
                throw;  // throw it up in addition to logging the stack trace, so the kOS terminal will also give the user some message.
            }

            return part;
        }
开发者ID:gisikw,项目名称:KOS,代码行数:34,代码来源:Compiler.cs


示例4: Compile

        public CodePart Compile(ParseTree tree, Context context, CompilerOptions options)
        {
            _part = new CodePart();
            _context = context;
            _options = options;

            try
            {
                if (tree.Nodes.Count > 0)
                {
                    PreProcess(tree);
                    CompileProgram(tree);
                }
            }
            catch (Exception e)
            {
                if (_lastNode != null)
                {
                    throw new Exception(string.Format("Error parsing {0}: {1}", ConcatenateNodes(_lastNode), e.Message));
                }
                else
                {
                    throw;
                }
            }

            return _part;
        }
开发者ID:ElasticRaven,项目名称:KOS,代码行数:28,代码来源:Compiler.cs


示例5: Test_That_Compiler_Returns_Response_As_Expected

        public void Test_That_Compiler_Returns_Response_As_Expected()
        {
            // Arrange
            const string ExpectedCompiledJavaScript = "{\"compiledCode\":\"alert(2);var a\\u003d(void 0).a.value,b\\u003d\\\"\\\";if(\\\"\\\"\\u003d\\u003da||-1\\u003d\\u003da.indexOf(\\\"@\\\"))b\\u003d\\\"please do something\\\";alert(\\\"\\\"\\u003d\\u003db);\",\"warnings\":[{\"type\":\"JSC_POSSIBLE_INEXISTENT_PROPERTY\",\"file\":\"Input_0\",\"lineno\":8,\"charno\":22,\"warning\":\"Property something never defined on frm\",\"line\":\"    var somevar \\u003d frm.something.value;\"},{\"type\":\"JSC_WRONG_ARGUMENT_COUNT\",\"file\":\"Input_0\",\"lineno\":19,\"charno\":6,\"warning\":\"Function dosomething: called with 0 argument(s). Function requires at least 1 argument(s) and no more than 1 argument(s).\",\"line\":\"alert(dosomething());\"}],\"statistics\":{\"originalSize\":372,\"originalGzipSize\":219,\"compressedSize\":103,\"compressedGzipSize\":113,\"compileTime\":0},\"outputFilePath\":\"/code/jsc533f6c7203b8d05105e273ac53810976/default.js\"}";

            // request and response data that will be used by the mock webrequest
            var requestStreamMock = new Mock<Stream>();
            var webResponseMock = new Mock<WebResponse>();
            var responseStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(ExpectedCompiledJavaScript));
            webResponseMock.Setup(m => m.GetResponseStream()).Returns(responseStream);

            // Mock of the webrequest tht will make the call to GCC
            var webRequestMock = new Mock<WebRequest>();
            webRequestMock.Setup(m => m.GetRequestStream()).Returns(requestStreamMock.Object);
            webRequestMock.Setup(m => m.GetResponse()).Returns(webResponseMock.Object);

            // Mock of file that will be read by the compiler
            var textReaderMock = new Mock<TextReader>();
            textReaderMock.Setup(m => m.ReadToEnd()).Returns("var x = 0;");

            var compilerOptions = new CompilerOptions(textReaderMock.Object, webRequestMock.Object, "A");
            var compiler = new JavaScriptCompiler(compilerOptions, new CompilationLevelHelper());

            // Act
            var actualCompiledJavaScript = compiler.Compile();

            Assert.Equal(ExpectedCompiledJavaScript, actualCompiledJavaScript);
        }
开发者ID:jameswiseman76,项目名称:JsGoogleCompile,代码行数:28,代码来源:JavaScriptCompilerTests.cs


示例6: GetOption

        public void GetOption(CompilerOptions optionID, IntPtr variant)
        {
            if (optionID < 0 || optionID >= CompilerOptions.LARGEST_OPTION_ID)
            {
                throw new ArgumentOutOfRangeException(nameof(optionID));
            }

            Marshal.GetNativeVariantForObject(_options[(int)optionID], variant);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:CSharpProjectShim.ICSCompilerConfig.cs


示例7: Process

        /// <summary>
        /// Process a file
        /// </summary>
        /// <param name="file">File name</param>
        /// <param name="options">Compilation options</param>
        public void Process(string file, CompilerOptions options = CompilerOptions.None)
        {
            // clear compilation info if compilation
              if (options != CompilerOptions.ContinueCompilation)
            Init();

              ParseFile(file);
              Emitter.Prepare();
              Emitter.RootNode.Compile(Emitter);
        }
开发者ID:menozz,项目名称:mirelle,代码行数:15,代码来源:Compiler.cs


示例8: CombiningWithNullSkipsNulls

        public void CombiningWithNullSkipsNulls()
        {
            var options = new CompilerOptions
            {
                Optimize = true
            };

            var result = CompilerOptions.Combine(options, null);

            Assert.True(result.Optimize.Value);
        }
开发者ID:leloulight,项目名称:dnx,代码行数:11,代码来源:CompilerOptionsFacts.cs


示例9: CompilerContext

        public CompilerContext(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink, ParserSink parserSink) {
            ContractUtils.RequiresNotNull(sourceUnit, "sourceUnit");
            ContractUtils.RequiresNotNull(errorSink, "errorSink");
            ContractUtils.RequiresNotNull(parserSink, "parserSink");
            ContractUtils.RequiresNotNull(options, "options");

            _sourceUnit = sourceUnit;
            _options = options;
            _errors = errorSink;
            _parserSink = parserSink;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:11,代码来源:CompilerContext.cs


示例10: Compilation

        public Compilation(CompilationTest test)
        {
            _test = test;

            _references = new List<string>();
            _sources = new List<CompilationInput>();
            _resources = new List<CompilationInput>();

            _options = new CompilerOptions();
            _options.Minimize = false;
            _options.InternalTestMode = true;
            _options.Defines = new string[] { };
        }
开发者ID:jimmygilles,项目名称:scriptsharp,代码行数:13,代码来源:Compilation.cs


示例11: source_directory_is_mirrored_in_output

        public void source_directory_is_mirrored_in_output([ValueSource("OutputFolderParameters")] string outputFolder)
        {
            var sourceDir = ExampleScripts.Valid.Hierarchy;

            var compilerOptions = new CompilerOptions
                                      {
                                          Compile = true,
                                          OutputDir = outputFolder,
                                          Path = sourceDir.ToString()
                                      };

            new Compiler().Compile(compilerOptions);

            AssertOutputMirrorsSource(compilerOptions.Path.AsDirectory(), compilerOptions.OutputDir.AsDirectory());
        }
开发者ID:mlidbom,项目名称:coffeescript-dotnet,代码行数:15,代码来源:when_building_directory.cs


示例12: SetOptionWithMarshaledValue

        public int SetOptionWithMarshaledValue(CompilerOptions optionID, object value)
        {
            SetOption(ref _options[(int)optionID], value);

            if (optionID == CompilerOptions.OPTID_COMPATIBILITY)
            {
                // HACK: we want the project system to use the out-of-proc compiler rather than
                // us, because we really don't build much of anything yet. We can say we don't
                // support pretty much anything we want to do this. Let's just say we don't
                // support any version of C# yet

                return VSConstants.S_FALSE;
            }

            return VSConstants.S_OK;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:16,代码来源:CSharpProjectShim.ICSCompilerConfig.cs


示例13: CombiningConcatsDefines

        public void CombiningConcatsDefines()
        {
            var options = new CompilerOptions
            {
                Defines = new[] { "OPT1" }
            };

            var options2 = new CompilerOptions
            {
                Defines = new[] { "OPT2" }
            };

            var result = CompilerOptions.Combine(options, options2);

            Assert.Equal(new[] { "OPT1", "OPT2" }, result.Defines);
        }
开发者ID:leloulight,项目名称:dnx,代码行数:16,代码来源:CompilerOptionsFacts.cs


示例14: Compile

        public override List<CodePart> Compile(GlobalPath filePath, int startLineNum, string scriptText, string contextId, CompilerOptions options)
        {
            var parts = new List<CodePart>();
            ParseTree parseTree = parser.Parse(scriptText);
            if (parseTree.Errors.Count == 0)
            {
                var compiler = new Compiler();
                LoadContext(contextId);

                CodePart mainPart;
                try
                {
                    mainPart = compiler.Compile(startLineNum, parseTree, currentContext, options);
                }
                catch (KOSCompileException e)
                {
                    e.AddSourceText((short)startLineNum, scriptText);
                    throw;
                }

                // add locks and triggers
                parts.AddRange(currentContext.UserFunctions.GetNewParts());
                parts.AddRange(currentContext.Triggers.GetNewParts());
                parts.AddRange(currentContext.Subprograms.GetNewParts());

                parts.Add(mainPart);

                AssignSourceId(parts, filePath);

                //if (contextId != "interpreter") _cache.AddToCache(scriptText, parts);
            }
            else
            {
                // TODO: Come back here and check on the possibility of reporting more
                // errors than just the first one.  It appears that TinyPG builds a
                // whole array of error messages so people could see multiple syntax
                // errors in one go if we supported the reporting of it.  It may be that
                // it was deliberately not done because it might be too verbose that way
                // for the small text terminal.

                ParseError error = parseTree.Errors[0];
                throw new KOSParseException(error, scriptText);
            }

            return parts;
        }
开发者ID:KSP-KOS,项目名称:KOS,代码行数:46,代码来源:KSScript.cs


示例15: ParseOptions

        internal static CompilerOptions ParseOptions(string[] args, TextWriter infoWriter, TextWriter errorWriter)
        {
            if (args.Length == 0) {
                ShowHelp(infoWriter);
                return null;
            }

            try {
                bool showHelp = false;
                var result = new CompilerOptions() { MinimizeScript = true };
                var opts = new OptionSet {
                    { "outasm=",       v => result.OutputAssemblyPath = v },
                    { "outscript=",    v => result.OutputScriptPath = v },
                    { "doc=",          v => result.DocumentationFile = v },
                    { "d|define=",     v => result.DefineConstants.AddRange(v.Split(new[] { ';' }).Select(s => s.Trim()).Where(s => s != "" && !result.DefineConstants.Contains(s))) },
                    { "lib=",          v => result.AdditionalLibPaths.AddRange(v.Split(new[] { ',' }).Select(s => s.Trim()).Where(s => s != "" && !result.AdditionalLibPaths.Contains(s))) },
                    { "m|main=",       v => result.EntryPointClass = v },
                    { "r|reference=",  v => HandleReferences(result, v) },
                    { "debug",         f => result.MinimizeScript = f == null || f.EndsWith("-") },
                    { "w|warn=",       (int v) => { if (v < 0 || v > 4) throw new OptionException("Warning level must be between 0 and 4", "/warn"); result.WarningLevel = v; } },
                    { "nowarn=",       v => DisableWarnings(result, v) },
                    { "warnaserror:",  v => HandleWarningsAsErrors(result, v) },
                    { "warnaserror-:", v => HandleWarningsNotAsErrors(result, v) },
                    { "keyfile=",      v => result.KeyFile = v },
                    { "keycontainer=", v => result.KeyContainer = v },
                    { "t|target=",     v => result.HasEntryPoint = ParseTargetForHasEntryPoint(v) },
                    { "?|help",        v => showHelp = true },
                };

                var extra = opts.Parse(args);
                foreach (var file in extra)
                    result.SourceFiles.Add(file);

                if (showHelp) {
                    ShowHelp(infoWriter);
                    return null;
                }

                return result;
            }
            catch (OptionException ex) {
                errorWriter.WriteLine(ex.Message);
                return null;
            }
        }
开发者ID:JimmyJune,项目名称:SaltarelleCompiler,代码行数:45,代码来源:Program.cs


示例16: ScriptTextWriter

        public ScriptTextWriter(TextWriter writer, CompilerOptions options)
            : base(CultureInfo.InvariantCulture) {
            _writer = writer;
            _globalWriter = writer;

#if DEBUG
            _minimize = options.Minimize && (options.InternalTestMode == false);
#else
            _minimize = options.Minimize;
#endif
            if (_minimize) {
                NewLine = "\n";
            }

            _tabString = "    ";
            _indentLevel = 0;
            _tabsPending = false;
        }
开发者ID:fugaku,项目名称:scriptsharp,代码行数:18,代码来源:ScriptTextWriter.cs


示例17: Compile

        public CodePart Compile(int startLineNum, ParseTree tree, Context context, CompilerOptions options)
        {
            InitCompileFlags();

            part = new CodePart();
            this.context = context;
            this.options = options;
            this.startLineNum = startLineNum;

            ++context.NumCompilesSoFar;

            if (tree.Nodes.Count > 0)
            {
                PreProcess(tree);
                CompileProgram(tree);
            }
            return part;
        }
开发者ID:KSP-KOS,项目名称:KOS,代码行数:18,代码来源:Compiler.cs


示例18: InvokeMethodInternal

        private void InvokeMethodInternal(InvokeParams invokeParams)
        {
            var invokeOptions = new InvokeOptions()
            {
                ClassName = invokeParams.TypeName,
                MethodName = invokeParams.MethodName,
                Async = true
            };

            var compilerOptions = new CompilerOptions()
            {
                FilePath = invokeParams.FilePath,
                ReferencedAssemblyPaths = BuildManager.GetReferencedAssemblies().OfType<Assembly>().Select(x => x.Location).ToArray(),
                SignKeyPath = invokeParams.KeyPath,
                OutputAssemblyName = invokeParams.AsmName
            };

            MethodInvoker.Execute(invokeOptions, compilerOptions);
        }
开发者ID:Gebov,项目名称:no-compile,代码行数:19,代码来源:MethodInvokerService.cs


示例19: Compile

        public override List<CodePart> Compile(string scriptText, string contextId, CompilerOptions options)
        {
            List<CodePart> parts = null;

            // make the code lowercase
            scriptText = MakeLowerCase(scriptText);
            scriptText = ReplaceIdentifiers(scriptText);

            //if (contextId != "interpreter") parts = _cache.GetFromCache(scriptText);

            // if parts is null means the code doesn't exists in the cache
            if (parts == null)
            {
                parts = new List<CodePart>();
                ParseTree parseTree = parser.Parse(scriptText);
                if (parseTree.Errors.Count == 0)
                {
                    var compiler = new Compiler();
                    LoadContext(contextId);

                    // TODO: handle compile errors (e.g. wrong run parameter count)
                    CodePart mainPart = compiler.Compile(parseTree, currentContext, options);

                    // add locks and triggers
                    parts.AddRange(currentContext.Locks.GetNewParts());
                    parts.AddRange(currentContext.Triggers.GetNewParts());
                    parts.AddRange(currentContext.Subprograms.GetNewParts());

                    parts.Add(mainPart);

                    AssignInstructionId(parts);

                    //if (contextId != "interpreter") _cache.AddToCache(scriptText, parts);
                }
                else
                {
                    ParseError error = parseTree.Errors[0];
                    RaiseParseException(scriptText, error.Line, error.Position);
                }
            }

            return parts;
        }
开发者ID:kevin-ye,项目名称:KOS,代码行数:43,代码来源:KSScript.cs


示例20: Effect

        public Effect(GraphicsDevice graphicsDevice, byte[] effectCode, CompilerOptions options, EffectPool pool) 
        {
            int fragmentblocklength = BitConverter.ToInt32(effectCode, 0);

            int vertexblocklength = BitConverter.ToInt32(effectCode, fragmentblocklength + 4);

            if (fragmentblocklength != 0)
            {
                fragment_handle = Gl.glCreateShader(Gl.GL_FRAGMENT_SHADER);
                fragment = true;
            }

            if (vertexblocklength != 0)
            {
                vertex_handle = Gl.glCreateShader(Gl.GL_VERTEX_SHADER);
                vertex = true;
            }

            if (fragment)
            {
                string[] fragmentstring = new string[1] { Encoding.UTF8.GetString(effectCode, 4, fragmentblocklength) };
                int[] fragmentLength = new int[1] { fragmentstring[0].Length };
                Gl.glShaderSource(fragment_handle, 1, fragmentstring, fragmentLength);
            }

            if (vertex)
            {
                string[] vertexstring = new string[1] { Encoding.UTF8.GetString(effectCode, fragmentblocklength + 8, vertexblocklength) };
                int[] vertexLength = new int[1] { vertexstring[0].Length };
                Gl.glShaderSource(vertex_handle, 1, vertexstring, vertexLength);
            }

            if (fragment)
            {
                Gl.glCompileShader(fragment_handle);
            }

            if (vertex)
            {
                Gl.glCompileShader(fragment_handle);
            }
        }
开发者ID:sergios1234,项目名称:monoxna,代码行数:42,代码来源:Effect.cs



注:本文中的CompilerOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CompilerPipeline类代码示例发布时间:2022-05-24
下一篇:
C# CompilerContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap