本文整理汇总了C#中Mono.CSharp.CompilerSettings.AddConditionalSymbol方法的典型用法代码示例。如果您正苦于以下问题:C# CompilerSettings.AddConditionalSymbol方法的具体用法?C# CompilerSettings.AddConditionalSymbol怎么用?C# CompilerSettings.AddConditionalSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.CompilerSettings
的用法示例。
在下文中一共展示了CompilerSettings.AddConditionalSymbol方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitIfNeeded
void InitIfNeeded()
{
if (eval == null) {
Log ("INIT EVAL");
var settings = new CompilerSettings ();
settings.AddConditionalSymbol ("__Continuous__");
settings.AddConditionalSymbol ("DEBUG");
PlatformSettings (settings);
var context = new CompilerContext (settings, printer);
eval = new Evaluator (context);
//
// Add References to get UIKit, etc. Also add a hook to catch dynamically loaded assemblies.
//
AppDomain.CurrentDomain.AssemblyLoad += (_, e) => {
Log ("DYNAMIC REF {0}", e.LoadedAssembly);
AddReference (e.LoadedAssembly);
};
foreach (var a in AppDomain.CurrentDomain.GetAssemblies ()) {
Log ("STATIC REF {0}", a);
AddReference (a);
}
//
// Add default namespaces
//
object res;
bool hasRes;
eval.Evaluate ("using System;", out res, out hasRes);
eval.Evaluate ("using System.Collections.Generic;", out res, out hasRes);
eval.Evaluate ("using System.Linq;", out res, out hasRes);
PlatformInit ();
}
}
示例2: ParseOption
//
// This parses the -arg and /arg options to the compiler, even if the strings
// in the following text use "/arg" on the strings.
//
ParseResult ParseOption (string option, ref string[] args, CompilerSettings settings)
{
int idx = option.IndexOf (':');
string arg, value;
if (idx == -1) {
arg = option;
value = "";
} else {
arg = option.Substring (0, idx);
value = option.Substring (idx + 1);
}
switch (arg.ToLowerInvariant ()) {
case "/nologo":
return ParseResult.Success;
case "/t":
case "/target":
bool is_dotnet = true;
switch (value) {
case "exe":
settings.Target = Target.Exe;
break;
case "winexe":
settings.Target = Target.WinExe;
break;
case "library":
settings.Target = Target.Library;
settings.TargetExt = ".dll";
break;
case "module":
settings.Target = Target.Module;
settings.TargetExt = ".netmodule";
break;
case "javascript":
settings.Target = Target.JavaScript;
settings.TargetExt = ".js";
settings.AddConditionalSymbol ("TARGET_JS");
is_dotnet = false;
break;
case "cpp":
settings.Target = Target.Cpp;
settings.TargetExt = ".cpp";
settings.AddConditionalSymbol ("TARGET_CPP");
is_dotnet = false;
break;
default:
report.Error (2019, "Invalid target type for -target. Valid options are `exe', `winexe', `library', `module', `javascript' or `cpp'");
return ParseResult.Error;
}
if (is_dotnet) {
settings.AddConditionalSymbol ("TARGET_IL");
}
return ParseResult.Success;
case "/out":
if (value.Length == 0) {
Error_RequiresFileName (option);
return ParseResult.Error;
}
settings.OutputFile = value;
return ParseResult.Success;
case "/o":
case "/o+":
case "/optimize":
case "/optimize+":
settings.Optimize = true;
return ParseResult.Success;
case "/o-":
case "/optimize-":
settings.Optimize = false;
return ParseResult.Success;
// TODO: Not supported by csc 3.5+
case "/incremental":
case "/incremental+":
case "/incremental-":
// nothing.
return ParseResult.Success;
case "/d":
case "/define": {
if (value.Length == 0) {
Error_RequiresArgument (option);
return ParseResult.Error;
}
//.........这里部分代码省略.........
示例3: ParseOptionUnix
//
// Currently handles the Unix-like command line options, but will be
// deprecated in favor of the CSCParseOption, which will also handle the
// options that start with a dash in the future.
//
ParseResult ParseOptionUnix (string arg, ref string[] args, ref int i, CompilerSettings settings)
{
switch (arg){
case "-v":
settings.VerboseParserFlag++;
return ParseResult.Success;
case "--version":
Version ();
return ParseResult.Stop;
case "--parse":
settings.ParseOnly = true;
return ParseResult.Success;
case "--main": case "-m":
report.Warning (-29, 1, "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS");
if ((i + 1) >= args.Length){
Error_RequiresArgument (arg);
return ParseResult.Error;
}
settings.MainClass = args[++i];
return ParseResult.Success;
case "--unsafe":
report.Warning (-29, 1, "Compatibility: Use -unsafe instead of --unsafe");
settings.Unsafe = true;
return ParseResult.Success;
case "/?": case "/h": case "/help":
case "--help":
Usage ();
return ParseResult.Stop;
case "--define":
report.Warning (-29, 1, "Compatibility: Use -d:SYMBOL instead of --define SYMBOL");
if ((i + 1) >= args.Length){
Error_RequiresArgument (arg);
return ParseResult.Error;
}
settings.AddConditionalSymbol (args [++i]);
return ParseResult.Success;
case "--tokenize":
settings.TokenizeOnly = true;
return ParseResult.Success;
case "-o":
case "--output":
report.Warning (-29, 1, "Compatibility: Use -out:FILE instead of --output FILE or -o FILE");
if ((i + 1) >= args.Length){
Error_RequiresArgument (arg);
return ParseResult.Error;
}
settings.OutputFile = args[++i];
return ParseResult.Success;
case "--checked":
report.Warning (-29, 1, "Compatibility: Use -checked instead of --checked");
settings.Checked = true;
return ParseResult.Success;
case "--stacktrace":
settings.Stacktrace = true;
return ParseResult.Success;
case "--linkresource":
case "--linkres":
report.Warning (-29, 1, "Compatibility: Use -linkres:VALUE instead of --linkres VALUE");
if ((i + 1) >= args.Length){
Error_RequiresArgument (arg);
return ParseResult.Error;
}
AddResource (new AssemblyResource (args[++i], args[i]), settings);
return ParseResult.Success;
case "--resource":
case "--res":
report.Warning (-29, 1, "Compatibility: Use -res:VALUE instead of --res VALUE");
if ((i + 1) >= args.Length){
Error_RequiresArgument (arg);
return ParseResult.Error;
}
AddResource (new AssemblyResource (args[++i], args[i], true), settings);
return ParseResult.Success;
case "--target":
report.Warning (-29, 1, "Compatibility: Use -target:KIND instead of --target KIND");
if ((i + 1) >= args.Length){
Error_RequiresArgument (arg);
return ParseResult.Error;
}
//.........这里部分代码省略.........
示例4: MapSettings
private static CompilerSettings MapSettings(CompilerOptions options, string outputAssemblyPath, string outputDocFilePath, IErrorReporter er)
{
var allPaths = options.AdditionalLibPaths.Concat(new[] { Environment.CurrentDirectory }).ToList();
var result = new CompilerSettings();
result.Target = Target.Library;
result.Platform = Platform.AnyCPU;
result.TargetExt = ".dll";
result.VerifyClsCompliance = false;
result.Optimize = false;
result.Version = LanguageVersion.V_5;
result.EnhancedWarnings = false;
result.LoadDefaultReferences = false;
result.TabSize = 1;
result.WarningsAreErrors = options.TreatWarningsAsErrors;
result.FatalCounter = 100;
result.WarningLevel = options.WarningLevel;
result.AssemblyReferences = options.References.Where(r => r.Alias == null).Select(r => ResolveReference(r.Filename, allPaths, er)).ToList();
result.AssemblyReferencesAliases = options.References.Where(r => r.Alias != null).Select(r => Tuple.Create(r.Alias, ResolveReference(r.Filename, allPaths, er))).ToList();
result.Encoding = Encoding.UTF8;
result.DocumentationFile = !string.IsNullOrEmpty(options.DocumentationFile) ? outputDocFilePath : null;
result.OutputFile = outputAssemblyPath;
result.AssemblyName = GetAssemblyName(options);
result.StdLib = false;
result.StdLibRuntimeVersion = RuntimeVersion.v4;
result.StrongNameKeyContainer = options.KeyContainer;
result.StrongNameKeyFile = options.KeyFile;
result.SourceFiles.AddRange(options.SourceFiles.Select((f, i) => new SourceFile(f, f, i + 1)));
foreach (var c in options.DefineConstants)
result.AddConditionalSymbol(c);
foreach (var w in options.DisabledWarnings)
result.SetIgnoreWarning(w);
result.SetIgnoreWarning(660); // 660 and 661: class defines operator == or operator != but does not override Equals / GetHashCode. These warnings don't really apply, since we have no Equals / GetHashCode methods to override.
result.SetIgnoreWarning(661);
foreach (var w in options.WarningsAsErrors)
result.AddWarningAsError(w);
foreach (var w in options.WarningsNotAsErrors)
result.AddWarningOnly(w);
if (result.AssemblyReferencesAliases.Count > 0) { // NRefactory does currently not support reference aliases, this check will hopefully go away in the future.
er.Region = DomRegion.Empty;
er.Message(7998, "aliased reference");
}
return result;
}
示例5: PlatformSettings
partial void PlatformSettings(CompilerSettings settings)
{
settings.AddConditionalSymbol ("__ANDROID__");
}
示例6: MapSettings
private static CompilerSettings MapSettings(CompilerOptions options, string outputAssemblyPath, string outputDocFilePath, IErrorReporter er) {
var allPaths = options.AdditionalLibPaths.Concat(new[] { Environment.CurrentDirectory }).ToList();
var result = new CompilerSettings {
Target = (options.HasEntryPoint ? Target.Exe : Target.Library),
Platform = Platform.AnyCPU,
TargetExt = (options.HasEntryPoint ? ".exe" : ".dll"),
MainClass = options.EntryPointClass,
VerifyClsCompliance = false,
Optimize = false,
Version = LanguageVersion.V_5,
EnhancedWarnings = false,
LoadDefaultReferences = false,
TabSize = 1,
WarningsAreErrors = options.TreatWarningsAsErrors,
FatalCounter = 100,
WarningLevel = options.WarningLevel,
Encoding = Encoding.UTF8,
DocumentationFile = !string.IsNullOrEmpty(options.DocumentationFile) ? outputDocFilePath : null,
OutputFile = outputAssemblyPath,
AssemblyName = GetAssemblyName(options),
StdLib = false,
StdLibRuntimeVersion = RuntimeVersion.v4,
StrongNameKeyContainer = options.KeyContainer,
StrongNameKeyFile = options.KeyFile,
};
result.SourceFiles.AddRange(options.SourceFiles.Select((f, i) => new SourceFile(f, f, i + 1)));
foreach (var r in options.References) {
string resolvedPath = ResolveReference(r.Filename, allPaths, er);
if (r.Alias == null)
result.AssemblyReferences.Add(resolvedPath);
else
result.AssemblyReferencesAliases.Add(Tuple.Create(r.Alias, resolvedPath));
}
foreach (var c in options.DefineConstants)
result.AddConditionalSymbol(c);
foreach (var w in options.DisabledWarnings)
result.SetIgnoreWarning(w);
foreach (var w in options.WarningsAsErrors)
result.AddWarningAsError(w);
foreach (var w in options.WarningsNotAsErrors)
result.AddWarningOnly(w);
if (options.EmbeddedResources.Count > 0)
result.Resources = options.EmbeddedResources.Select(r => new AssemblyResource(r.Filename, r.ResourceName, isPrivate: !r.IsPublic) { IsEmbeded = true }).ToList();
if (result.AssemblyReferencesAliases.Count > 0) { // NRefactory does currently not support reference aliases, this check will hopefully go away in the future.
er.Region = DomRegion.Empty;
er.Message(Messages._7998, "aliased reference");
}
return result;
}