本文整理汇总了C#中CSharpParseOptions.WithLanguageVersion方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpParseOptions.WithLanguageVersion方法的具体用法?C# CSharpParseOptions.WithLanguageVersion怎么用?C# CSharpParseOptions.WithLanguageVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSharpParseOptions
的用法示例。
在下文中一共展示了CSharpParseOptions.WithLanguageVersion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LexicalTests
public LexicalTests()
{
_options = new CSharpParseOptions(languageVersion: LanguageVersion.CSharp3);
_options6 = new CSharpParseOptions(languageVersion: LanguageVersion.CSharp6);
_binaryOptions = _options.WithLanguageVersion(LanguageVersion.CSharp7);
_underscoreOptions = _options.WithLanguageVersion(LanguageVersion.CSharp7);
_binaryUnderscoreOptions = _binaryOptions;
}
示例2: GetCompilerArguments
public static CSharpParseOptions GetCompilerArguments (MonoDevelop.Projects.Project project)
{
var compilerArguments = new CSharpParseOptions ();
// compilerArguments.TabSize = 1;
if (project == null || MonoDevelop.Ide.IdeApp.Workspace == null) {
// compilerArguments.AllowUnsafeBlocks = true;
return compilerArguments;
}
var configuration = project.GetConfiguration (MonoDevelop.Ide.IdeApp.Workspace.ActiveConfiguration) as DotNetProjectConfiguration;
if (configuration == null)
return compilerArguments;
compilerArguments = compilerArguments.WithPreprocessorSymbols (configuration.GetDefineSymbols ());
var par = configuration.CompilationParameters as CSharpCompilerParameters;
if (par == null)
return compilerArguments;
// compilerArguments.AllowUnsafeBlocks = par.UnsafeCode;
compilerArguments = compilerArguments.WithLanguageVersion (ConvertLanguageVersion (par.LangVersion));
// compilerArguments.CheckForOverflow = par.GenerateOverflowChecks;
// compilerArguments.WarningLevel = par.WarningLevel;
// compilerArguments.TreatWarningsAsErrors = par.TreatWarningsAsErrors;
// if (!string.IsNullOrEmpty (par.NoWarnings)) {
// foreach (var warning in par.NoWarnings.Split (';', ',', ' ', '\t')) {
// int w;
// try {
// w = int.Parse (warning);
// } catch (Exception) {
// continue;
// }
// compilerArguments.DisabledWarnings.Add (w);
// }
// }
return compilerArguments;
}
示例3: Create
public HostBuildData Create(HostBuildOptions options)
{
var parseOptions = new CSharpParseOptions(languageVersion: LanguageVersion.CSharp6, documentationMode: DocumentationMode.Parse);
var compilationOptions = new CSharpCompilationOptions(
OutputKind.ConsoleApplication,
xmlReferenceResolver: new XmlFileResolver(options.ProjectDirectory),
sourceReferenceResolver: new SourceFileResolver(ImmutableArray<string>.Empty, options.ProjectDirectory),
metadataReferenceResolver: new AssemblyReferenceResolver(
new MetadataFileReferenceResolver(ImmutableArray<string>.Empty, options.ProjectDirectory),
MetadataFileReferenceProvider.Default),
strongNameProvider: new DesktopStrongNameProvider(ImmutableArray.Create(options.ProjectDirectory, options.OutputDirectory)),
assemblyIdentityComparer: DesktopAssemblyIdentityComparer.Default);
var warnings = new List<KeyValuePair<string, ReportDiagnostic>>(options.Warnings);
if (options.OutputKind.HasValue)
{
var kind = options.OutputKind.Value;
compilationOptions = compilationOptions.WithOutputKind(kind);
if (compilationOptions.Platform == Platform.AnyCpu32BitPreferred &&
(kind == OutputKind.DynamicallyLinkedLibrary || kind == OutputKind.NetModule || kind == OutputKind.WindowsRuntimeMetadata))
{
compilationOptions = compilationOptions.WithPlatform(Platform.AnyCpu);
}
}
if (!string.IsNullOrEmpty(options.DefineConstants))
{
IEnumerable<Diagnostic> diagnostics;
parseOptions = parseOptions.WithPreprocessorSymbols(CSharpCommandLineParser.ParseConditionalCompilationSymbols(options.DefineConstants, out diagnostics));
}
if (options.DocumentationFile != null)
{
parseOptions = parseOptions.WithDocumentationMode(!string.IsNullOrEmpty(options.DocumentationFile) ? DocumentationMode.Diagnose : DocumentationMode.Parse);
}
if (options.LanguageVersion != null)
{
var languageVersion = CompilationOptionsConversion.GetLanguageVersion(options.LanguageVersion);
if (languageVersion.HasValue)
{
parseOptions = parseOptions.WithLanguageVersion(languageVersion.Value);
}
}
if (!string.IsNullOrEmpty(options.PlatformWith32BitPreference))
{
Platform platform;
if (Enum.TryParse<Platform>(options.PlatformWith32BitPreference, true, out platform))
{
if (platform == Platform.AnyCpu &&
compilationOptions.OutputKind != OutputKind.DynamicallyLinkedLibrary &&
compilationOptions.OutputKind != OutputKind.NetModule &&
compilationOptions.OutputKind != OutputKind.WindowsRuntimeMetadata)
{
platform = Platform.AnyCpu32BitPreferred;
}
compilationOptions = compilationOptions.WithPlatform(platform);
}
}
if (options.AllowUnsafeBlocks.HasValue)
{
compilationOptions = compilationOptions.WithAllowUnsafe(options.AllowUnsafeBlocks.Value);
}
if (options.CheckForOverflowUnderflow.HasValue)
{
compilationOptions = compilationOptions.WithOverflowChecks(options.CheckForOverflowUnderflow.Value);
}
if (options.DelaySign != null)
{
bool delaySignExplicitlySet = options.DelaySign.Item1;
bool delaySign = options.DelaySign.Item2;
compilationOptions = compilationOptions.WithDelaySign(delaySignExplicitlySet ? delaySign : (bool?)null);
}
if (!string.IsNullOrEmpty(options.ApplicationConfiguration))
{
var appConfigPath = FileUtilities.ResolveRelativePath(options.ApplicationConfiguration, options.ProjectDirectory);
try
{
using (var appConfigStream = PortableShim.FileStream.Create(appConfigPath, PortableShim.FileMode.Open, PortableShim.FileAccess.Read))
{
compilationOptions = compilationOptions.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.LoadFromXml(appConfigStream));
}
}
catch (Exception)
{
}
}
if (!string.IsNullOrEmpty(options.KeyContainer))
{
compilationOptions = compilationOptions.WithCryptoKeyContainer(options.KeyContainer);
}
if (!string.IsNullOrEmpty(options.KeyFile))
//.........这里部分代码省略.........