本文整理汇总了C#中CompilationOptions类的典型用法代码示例。如果您正苦于以下问题:C# CompilationOptions类的具体用法?C# CompilationOptions怎么用?C# CompilationOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompilationOptions类属于命名空间,在下文中一共展示了CompilationOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例6:
Compilation ICompilationFactoryService.CreateSubmissionCompilation(string assemblyName, CompilationOptions options, Type hostObjectType)
{
return CSharpCompilation.CreateScriptCompilation(
assemblyName,
options: (CSharpCompilationOptions)options,
previousScriptCompilation: null,
globalsType: hostObjectType);
}
示例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);
}
示例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);
}
示例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 });
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
});
}
示例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);
}