当前位置: 首页>>代码示例>>C#>>正文


C# CompilerSettings.AddWarningAsError方法代码示例

本文整理汇总了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;
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:66,代码来源:settings.cs

示例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;
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:52,代码来源:CompilerDriver.cs

示例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;
        }
开发者ID:unintelligible,项目名称:SaltarelleCompiler,代码行数:46,代码来源:CompilerDriver.cs

示例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);
		}
开发者ID:shaias,项目名称:mono,代码行数:15,代码来源:settings.cs


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