本文整理汇总了C#中Mono.CSharp.CompilerSettings.AddWarningAsError方法的典型用法代码示例。如果您正苦于以下问题:C# CompilerSettings.AddWarningAsError方法的具体用法?C# CompilerSettings.AddWarningAsError怎么用?C# CompilerSettings.AddWarningAsError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.CompilerSettings
的用法示例。
在下文中一共展示了CompilerSettings.AddWarningAsError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseOption
//.........这里部分代码省略.........
case "/checked":
case "/checked+":
settings.Checked = true;
return ParseResult.Success;
case "/checked-":
settings.Checked = false;
return ParseResult.Success;
case "/clscheck":
case "/clscheck+":
settings.VerifyClsCompliance = true;
return ParseResult.Success;
case "/clscheck-":
settings.VerifyClsCompliance = false;
return ParseResult.Success;
case "/unsafe":
case "/unsafe+":
settings.Unsafe = true;
return ParseResult.Success;
case "/unsafe-":
settings.Unsafe = false;
return ParseResult.Success;
case "/warnaserror":
case "/warnaserror+":
if (value.Length == 0) {
settings.WarningsAreErrors = true;
parser_settings.WarningsAreErrors = true;
} else {
if (!ProcessWarningsList (value, v => settings.AddWarningAsError (v)))
return ParseResult.Error;
}
return ParseResult.Success;
case "/warnaserror-":
if (value.Length == 0) {
settings.WarningsAreErrors = false;
} else {
if (!ProcessWarningsList (value, v => settings.AddWarningOnly (v)))
return ParseResult.Error;
}
return ParseResult.Success;
case "/warn":
case "/w":
if (value.Length == 0) {
Error_RequiresArgument (option);
return ParseResult.Error;
}
SetWarningLevel (value, settings);
return ParseResult.Success;
case "/nowarn":
if (value.Length == 0) {
Error_RequiresArgument (option);
return ParseResult.Error;
}
if (!ProcessWarningsList (value, v => settings.SetIgnoreWarning (v)))
return ParseResult.Error;
示例2: 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;
}
示例3: 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;
}
示例4: AddWarningAsError
void AddWarningAsError (string warningId, CompilerSettings settings)
{
int id;
try {
id = int.Parse (warningId);
} catch {
report.CheckWarningCode (warningId, Location.Null);
return;
}
if (!report.CheckWarningCode (id, Location.Null))
return;
settings.AddWarningAsError (id);
}