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

C# CompilationOptions类代码示例

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

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



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

示例1: HandleCommandLineArgs

        private static bool HandleCommandLineArgs(string[] args)
        {
            bool status = true;
            options = new OptionSet
                          {
                              {"d", "Debug mode", v => option_compilationOptions |= CompilationOptions.DebugMode},
                              {"l|language=", "Custom language", v => option_customLanguage = v},
                              {"?|h|help", "Show help", v => { status = false; }},
                              {"<>", v => option_filename = v}
                          };
            try
            {
                options.Parse(args);
            }
            catch (OptionException)
            {
                status = false;
            }

            if (String.IsNullOrEmpty(option_filename))
            {
                status = false;
            }

            return status;
        }
开发者ID:dreasgrech,项目名称:yabfcompiler,代码行数:26,代码来源:Program.cs


示例2: CreateAsync

 public static async Task<ExtractInterfaceTestState> CreateAsync(string markup, string languageName, CompilationOptions compilationOptions)
 {
     var workspace = languageName == LanguageNames.CSharp
         ? await TestWorkspace.CreateCSharpAsync(markup, exportProvider: ExportProvider, compilationOptions: compilationOptions as CSharpCompilationOptions)
         : await TestWorkspace.CreateVisualBasicAsync(markup, exportProvider: ExportProvider, compilationOptions: compilationOptions);
     return new ExtractInterfaceTestState(workspace);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:ExtractInterfaceTestState.cs


示例3: CompileAndVerify

        internal CompilationVerifier CompileAndVerify(
            string[] sources,
            IEnumerable<MetadataReference> additionalRefs = null,
            IEnumerable<ModuleData> dependencies = null,
            Action<IModuleSymbol> sourceSymbolValidator = null,
            Action<PEAssembly> assemblyValidator = null,
            Action<IModuleSymbol> symbolValidator = null,
            SignatureDescription[] expectedSignatures = null,
            string expectedOutput = null,
            CompilationOptions options = null,
            ParseOptions parseOptions = null,
            bool verify = true)
        {
            if (options == null)
            {
                options = CompilationOptionsReleaseDll.WithOutputKind((expectedOutput != null) ? OutputKind.ConsoleApplication : OutputKind.DynamicallyLinkedLibrary);
            }

            var compilation = GetCompilationForEmit(sources, additionalRefs, options, parseOptions);

            return this.CompileAndVerify(
                compilation,
                null,
                dependencies,
                sourceSymbolValidator,
                assemblyValidator,
                symbolValidator,
                expectedSignatures,
                expectedOutput,
                verify);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:31,代码来源:CommonTestBase.cs


示例4: CodeCompilationIsCorrect

        public virtual void CodeCompilationIsCorrect()
        {
            // Arrange
            string inputFilePath = Path.Combine(_resourcesDirectoryPath,
                string.Format("variables/{0}/style{1}", _subfolderName, _fileExtension));
            string outputFilePath = Path.Combine(_resourcesDirectoryPath, "variables/style.css");

            string inputCode = File.ReadAllText(inputFilePath);
            string targetOutputCode = File.ReadAllText(outputFilePath);

            var options = new CompilationOptions
            {
                IndentedSyntax = _indentedSyntax
            };

            // Act
            CompilationResult result;

            using (var compiler = new SassCompiler())
            {
                result = compiler.Compile(inputCode, options: options);
            }

            // Assert
            Assert.Equal(targetOutputCode, result.CompiledContent);
            Assert.True(string.IsNullOrEmpty(result.SourceMap));
            Assert.Empty(result.IncludedFilePaths);
        }
开发者ID:Taritsyn,项目名称:LibSassHost,代码行数:28,代码来源:CompileTestsBase.cs


示例5: CreateWorkspaceFromFiles

 /// <param name="files">Can pass in multiple file contents: files will be named test1.cs, test2.cs, etc.</param>
 internal static TestWorkspace CreateWorkspaceFromFiles(
     string language,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     params string[] files)
 {
     return CreateWorkspaceFromFiles(language, compilationOptions, parseOptions, files, exportProvider: null);
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:9,代码来源:TestWorkspaceFactory.cs


示例6:

 Compilation ICompilationFactoryService.CreateSubmissionCompilation(string assemblyName, CompilationOptions options, Type hostObjectType)
 {
     return CSharpCompilation.CreateScriptCompilation(
         assemblyName,
         options: (CSharpCompilationOptions)options,
         previousScriptCompilation: null,
         globalsType: hostObjectType);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:CSharpCompilationFactoryService.cs


示例7: WriteTo

        public override void WriteTo(CompilationOptions options, ObjectWriter writer, CancellationToken cancellationToken)
        {
            WriteCompilationOptionsTo(options, writer, cancellationToken);

            var csharpOptions = (CSharpCompilationOptions)options;
            writer.WriteValue(csharpOptions.Usings.ToArray());
            writer.WriteBoolean(csharpOptions.AllowUnsafe);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:8,代码来源:CSharpOptionsSerializationService.cs


示例8: CreateAsync

 /// <param name="files">Can pass in multiple file contents: files will be named test1.cs, test2.cs, etc.</param>
 internal static Task<TestWorkspace> CreateAsync(
     string language,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     params string[] files)
 {
     return CreateAsync(language, compilationOptions, parseOptions, files, exportProvider: null);
 }
开发者ID:peter76111,项目名称:roslyn,代码行数:9,代码来源:TestWorkspace_Create.cs


示例9: CreateWorkspaceFromFileAsync

 /// <summary>
 /// Creates a single buffer in a workspace.
 /// </summary>
 /// <param name="content">Lines of text, the buffer contents</param>
 internal static Task<TestWorkspace> CreateWorkspaceFromFileAsync(
     string language,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     string content)
 {
     return CreateWorkspaceFromFilesAsync(language, compilationOptions, parseOptions, new[] { content });
 }
开发者ID:TerabyteX,项目名称:roslyn,代码行数:12,代码来源:TestWorkspaceFactory.cs


示例10: CreateWorkspaceFromFileAsync

 protected override async Task<TestWorkspace> CreateWorkspaceFromFileAsync(string definition, ParseOptions parseOptions, CompilationOptions compilationOptions)
 {
     var workspace = await base.CreateWorkspaceFromFileAsync(definition, parseOptions, compilationOptions);
     workspace.Options = workspace.Options
         .WithChangedOption(AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp, true)
         .WithChangedOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp, true);
     return workspace;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:8,代码来源:AddUsingTests_NuGet.cs


示例11: CreateWorkspaceFromFilesAsync

 /// <param name="files">Can pass in multiple file contents with individual source kind: files will be named test1.vb, test2.vbx, etc.</param>
 public static Task<TestWorkspace> CreateWorkspaceFromFilesAsync(
     string[] files,
     ParseOptions[] parseOptions = null,
     CompilationOptions compilationOptions = null,
     ExportProvider exportProvider = null)
 {
     return TestWorkspaceFactory.CreateWorkspaceFromFilesAsync(LanguageNames.VisualBasic, compilationOptions, parseOptions, files, exportProvider);
 }
开发者ID:TerabyteX,项目名称:roslyn,代码行数:9,代码来源:VisualBasicWorkspaceFactory.cs


示例12: CreateWorkspaceFromFileAsync

 public static Task<TestWorkspace> CreateWorkspaceFromFileAsync(
     string file,
     ParseOptions parseOptions = null,
     CompilationOptions compilationOptions = null,
     ExportProvider exportProvider = null,
     string[] metadataReferences = null)
 {
     return CreateWorkspaceFromFilesAsync(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences);
 }
开发者ID:TerabyteX,项目名称:roslyn,代码行数:9,代码来源:VisualBasicWorkspaceFactory.cs


示例13: CreateWorkspaceFromLines

 /// <summary>
 /// Creates a single buffer in a workspace.
 /// </summary>
 /// <param name="content">Lines of text, the buffer contents</param>
 internal static TestWorkspace CreateWorkspaceFromLines(
     string language,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     params string[] content)
 {
     var total = content.Join(Environment.NewLine);
     return CreateWorkspaceFromFiles(language, compilationOptions, parseOptions, total);
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:13,代码来源:TestWorkspaceFactory.cs


示例14: Compile_Synchronous

        /// <summary>
        ///     Performs a synchronous compilation
        /// </summary>
        /// <param name="rebuild"></param>
        /// <param name="silent"></param>
        public void Compile_Synchronous(bool rebuild, bool silent = false)
        {
            Options = new CompilationOptions (rebuild, silent);
            ModelElement.DontRaiseError(Options.SilentCompile, () =>
            {
                try
                {
                    // Clears all caches
                    FinderRepository.INSTANCE.ClearCache();

                    // Initialises the declared elements
                    // ReSharper disable once UnusedVariable
                    CleanBeforeCompilation clean_before_compilation = new CleanBeforeCompilation(Options, true);

                    // Create the update information
                    // ReSharper disable once UnusedVariable
                    FindUpdates find_updates = new FindUpdates();

                    // Unifies the state machines and structure according to the update information
                    // ReSharper disable once UnusedVariable
                    Unify unify = new Unify();

                    // Compiles each expression and each statement encountered in the nodes
                    foreach (Dictionary dictionary in EfsSystem.Instance.Dictionaries)
                    {
                        visit(dictionary, true);
                    }

                    if (Options.Rebuild)
                    {
                        CreateDependancy create_dependancy = new CreateDependancy();
                        if (create_dependancy.DependancyChange)
                        {
                            // ReSharper disable once UnusedVariable
                            FlattenDependancy flatten_dependancy = new FlattenDependancy();
                        }
                    }
                }
                catch (ThreadAbortException)
                {
                    EfsSystem.Instance.ShouldRebuild = true;
                }
                catch (Exception e)
                {
                    // TODO : I don't know what to do.
                    // Please, at least, don't remove this
                    Debugger.Break();
                    Console.WriteLine();
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine();
                    EfsSystem.Instance.ShouldRebuild = true;
                }
            });
        }
开发者ID:GautierBerck,项目名称:ERTMSFormalSpecs,代码行数:60,代码来源:Compiler.cs


示例15: SerializeCompilationOptions

        public void SerializeCompilationOptions(CompilationOptions options, ObjectWriter writer, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var language = options.Language;

            // TODO: once compiler team adds ability to serialize compilation options to ObjectWriter directly, we won't need this.
            writer.WriteString(language);

            var service = GetOptionsSerializationService(language);
            service.WriteTo(options, writer, cancellationToken);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:12,代码来源:Serializer_Asset.cs


示例16: CleanBeforeCompilation

        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="options"></param>
        /// <param name="clearCache"></param>
        public CleanBeforeCompilation(CompilationOptions options, bool clearCache)
        {
            ClearCaches = clearCache;
            Options = options;
            EfsSystem.Instance.InitDeclaredElements();

            foreach (Dictionary dictionary in EfsSystem.Instance.Dictionaries)
            {
                // ReSharper disable once DoNotCallOverridableMethodsInConstructor
                visit(dictionary, true);
            }
        }
开发者ID:ERTMSSolutions,项目名称:ERTMSFormalSpecs,代码行数:17,代码来源:ClearBeforeCompilation.cs


示例17: NotImplementedException

        Compilation ICompilationFactoryService.CreateSubmissionCompilation(string assemblyName, CompilationOptions options, Type hostObjectType)
        {
#if SCRIPTING
            return CSharpCompilation.CreateSubmission(
                assemblyName,
                options: (CSharpCompilationOptions)options,
                previousSubmission: null,
                hostObjectType: hostObjectType);
#else
            throw new NotImplementedException();
#endif
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:12,代码来源:CSharpCompilationFactoryService.cs


示例18: GetCompilationForEmit

 //TODO: 4.6 should be the default for most testcases
 //      for now I do not want to do such a large change at once
 //      when 4.6 is the default, this override and ExpressionAssemblyRef below will not be needed.
 protected override Compilation GetCompilationForEmit(
     IEnumerable<string> source,
     IEnumerable<MetadataReference> additionalRefs,
     CompilationOptions options,
     ParseOptions parseOptions)
 {
     return CreateCompilationWithMscorlib46(
         Parse(source, options: (CSharpParseOptions)parseOptions),
         references: additionalRefs,
         options: (CSharpCompilationOptions)options,
         assemblyName: GetUniqueName());
 }
开发者ID:GeneralRookie,项目名称:roslyn,代码行数:15,代码来源:CodeGenExprLambdaTests.cs


示例19: TestMissing

        protected void TestMissing(string initialMarkup, ParseOptions parseOptions, CompilationOptions compilationOptions, IDictionary<OptionKey, object> options = null, string fixAllActionEquivalenceKey = null)
        {
            using (var workspace = CreateWorkspaceFromFile(initialMarkup, parseOptions, compilationOptions))
            {
                if (options != null)
                {
                    ApplyOptionsToWorkspace(options, workspace);
                }

                var diagnostics = GetDiagnosticAndFix(workspace, fixAllActionEquivalenceKey);
                Assert.False(diagnostics?.Item2?.Fixes.IsEmpty == true);
            }
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:13,代码来源:AbstractUserDiagnosticTest.cs


示例20: WriteCompilationOptionsTo

        protected void WriteCompilationOptionsTo(CompilationOptions options, ObjectWriter writer, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            writer.WriteInt32((int)options.OutputKind);
            writer.WriteBoolean(options.ReportSuppressedDiagnostics);
            writer.WriteString(options.ModuleName);
            writer.WriteString(options.MainTypeName);
            writer.WriteString(options.ScriptClassName);
            writer.WriteInt32((int)options.OptimizationLevel);
            writer.WriteBoolean(options.CheckOverflow);

            // REVIEW: is it okay this being not part of snapshot?
            writer.WriteString(options.CryptoKeyContainer);
            writer.WriteString(options.CryptoKeyFile);

            writer.WriteValue(options.CryptoPublicKey.ToArray());
            writer.WriteBoolean(options.DelaySign.HasValue);
            if (options.DelaySign.HasValue)
            {
                writer.WriteBoolean(options.DelaySign.Value);
            }

            writer.WriteInt32((int)options.Platform);
            writer.WriteInt32((int)options.GeneralDiagnosticOption);

            writer.WriteInt32(options.WarningLevel);

            // REVIEW: I don't think there is a guarantee on ordering of elements in the immutable dictionary.
            //         unfortunately, we need to sort them to make it deterministic
            writer.WriteInt32(options.SpecificDiagnosticOptions.Count);
            foreach (var kv in options.SpecificDiagnosticOptions.OrderBy(o => o.Key))
            {
                writer.WriteString(kv.Key);
                writer.WriteInt32((int)kv.Value);
            }

            writer.WriteBoolean(options.ConcurrentBuild);
            writer.WriteBoolean(options.Deterministic);
            writer.WriteBoolean(options.PublicSign);

            // REVIEW: What should I do with these. we probably need to implement either out own one
            //         or somehow share these as service....
            //
            // XmlReferenceResolver xmlReferenceResolver
            // SourceReferenceResolver sourceReferenceResolver
            // MetadataReferenceResolver metadataReferenceResolver
            // AssemblyIdentityComparer assemblyIdentityComparer
            // StrongNameProvider strongNameProvider
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:50,代码来源:AbstractOptionsSerializationService.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# CompilationStartAnalysisContext类代码示例发布时间:2022-05-24
下一篇:
C# CompilationFlags类代码示例发布时间: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