• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Compiler.CompilerErrorCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.CodeDom.Compiler.CompilerErrorCollection的典型用法代码示例。如果您正苦于以下问题:C# CompilerErrorCollection类的具体用法?C# CompilerErrorCollection怎么用?C# CompilerErrorCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CompilerErrorCollection类属于System.CodeDom.Compiler命名空间,在下文中一共展示了CompilerErrorCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CompileAssemblyFromFile

        public override CompilerResults CompileAssemblyFromFile(CompilerParameters options, params string[] fileNames)
        {
            var units = new CodeCompileUnit[fileNames.Length];
            var errors = new CompilerErrorCollection();
            var syntax = new Parser(options);

            for (int i = 0; i < fileNames.Length; i++)
            {
                try
                {
                    units[i] = syntax.Parse(new StreamReader(fileNames[i]), fileNames[i]);
                }
#if !DEBUG
                catch (ParseException e)
                {
                    errors.Add(new CompilerError(e.Source, e.Line, 0, e.Message.GetHashCode().ToString(), e.Message));
                }
                catch (Exception e)
                {
                    errors.Add(new CompilerError { ErrorText = e.Message });
                }
#endif
                finally { }
            }

            var results = CompileAssemblyFromDom(options, units);
            results.Errors.AddRange(errors);

            return results;
        }
开发者ID:lnsoso,项目名称:IronAHK,代码行数:30,代码来源:IACodeProvider.cs


示例2: HandleException

		private void HandleException(Exception ex, ProjectFile file, SingleFileCustomToolResult result)
		{
			if (ex is SpecFlowParserException)
			{
				SpecFlowParserException sfpex = (SpecFlowParserException) ex;
			                
				if (sfpex.ErrorDetails == null || sfpex.ErrorDetails.Count == 0)
				{
					result.UnhandledException = ex;
				}
				else
				{
					var compilerErrors = new CompilerErrorCollection();
					
					foreach (var errorDetail in sfpex.ErrorDetails)
					{
						var compilerError = new CompilerError(file.Name, errorDetail.ForcedLine, errorDetail.ForcedColumn, "0", errorDetail.Message);
						compilerErrors.Add(compilerError);
					}
							
					result.Errors.AddRange(compilerErrors);
				}
			}
			else
			{
				result.UnhandledException = ex;
			}
		}
开发者ID:roffster,项目名称:SpecFlow,代码行数:28,代码来源:SingleFeatureFileGenerator.cs


示例3: Emit

        public void Emit(CompilerErrorCollection errors, MethodBuilder m)
        {
            //Set the parameters
            //ParameterBuilder[] parms = new ParameterInfo[args.Length];
            for(int i = 0; i < args.Length; i++)
                m.DefineParameter(i + 1, ParameterAttributes.None, args[i].Name);

            ILGenerator gen = m.GetILGenerator();

            //Define the IT variable
            LocalRef it = locals["IT"] as LocalRef;
            DefineLocal(gen, it);

            statements.Process(this, errors, gen);

            statements.Emit(this, gen);

            //Cast the IT variable to our return type and return it
            if (m.ReturnType != typeof(void))
            {
                gen.Emit(OpCodes.Ldloc, it.Local);
                Expression.EmitCast(gen, it.Type, m.ReturnType);
            }
            gen.Emit(OpCodes.Ret);
        }
开发者ID:unycorn,项目名称:lolcode-dot-net,代码行数:25,代码来源:Program.cs


示例4: TemplateCompilationException

 /// <summary>
 /// Creates a new instance with serialized data.
 /// </summary>
 /// <param name="info">The object that holds the serialized
 /// object data.</param>
 /// <param name="context">The contextual information about
 /// the source or destination.</param>
 protected TemplateCompilationException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this.errors = (CompilerErrorCollection) info.GetValue(
         ErrorCollection,
         typeof(CompilerErrorCollection));
 }
开发者ID:sethyuan,项目名称:dcg,代码行数:14,代码来源:TemplateCompilationException.cs


示例5: Execute

        public override bool Execute()
        {
            Errors = new CompilerErrorCollection();
            try
            {
                AddAssemblyLoadEvent();
                DoExecute();
            }
            catch (Exception ex)
            {
                RecordException(ex);
            }

            // handle errors
            if (Errors.Count > 0)
            {
                bool hasErrors = false;
                foreach (CompilerError error in Errors)
                {
                    if (error.IsWarning)
                        OutputWarning(error.ToString(), error.ErrorText, error.FileName, error.Line, error.Column);
                    else
                    {
                        OutputError(error.ToString(), error.ErrorText, error.FileName, error.Line, error.Column);
                        hasErrors = true;
                    }
                }

                return !hasErrors;
            }

            return true;
        }
开发者ID:tmulkern,项目名称:SpecFlow,代码行数:33,代码来源:TaskBase.cs


示例6: AssemblyGenerator

 /// <summary>
 /// Creates a new instance of the Brainfuck assembly generator.
 /// </summary>
 public AssemblyGenerator()
 {
     Debug = false;
     Name = DefaultName;
     Errors = new CompilerErrorCollection();
     Cells = 1024;
 }
开发者ID:johnnonolan,项目名称:BrainfuckNet,代码行数:10,代码来源:AssemblyGenerator.cs


示例7: CompileCSharpScript

        /// <summary>
        /// Compiles a C# script as if it were a file in your project.
        /// </summary>
        /// <param name="scriptText">The text of the script.</param>
        /// <param name="errors">The compiler errors and warnings from compilation.</param>
        /// <param name="assemblyIfSucceeded">The compiled assembly if compilation succeeded.</param>
        /// <returns>True if compilation was a success, false otherwise.</returns>
        public static bool CompileCSharpScript(string scriptText, out CompilerErrorCollection errors, out Assembly assemblyIfSucceeded)
        {
            var codeProvider = new CSharpCodeProvider();
            var compilerOptions = new CompilerParameters();

            // We want a DLL and we want it in memory
            compilerOptions.GenerateExecutable = false;
            compilerOptions.GenerateInMemory = true;

            // Add references for UnityEngine and UnityEditor DLLs
            compilerOptions.ReferencedAssemblies.Add(typeof(Vector2).Assembly.Location);
            compilerOptions.ReferencedAssemblies.Add(typeof(EditorApplication).Assembly.Location);

            // Default to null output parameters
            errors = null;
            assemblyIfSucceeded = null;

            // Compile the assembly from the source script text
            CompilerResults result = codeProvider.CompileAssemblyFromSource(compilerOptions, scriptText);

            // Store the errors for the caller. even on successful compilation, we may have warnings.
            errors = result.Errors;

            // See if any errors are actually errors. if so return false
            foreach (CompilerError e in errors) {
                if (!e.IsWarning) {
                    return false;
                }
            }

            // Otherwise we pass back the compiled assembly and return true
            assemblyIfSucceeded = result.CompiledAssembly;
            return true;
        }
开发者ID:rubeninmark,项目名称:UnityToolbag,代码行数:41,代码来源:CodeCompiler.cs


示例8: FillErrorList

        public void FillErrorList( CompilerErrorCollection errors )
        {
            _listErrors.Items.Clear( );
            _listWarnings.Items.Clear( );

            if( errors != null && errors.Count > 0 )
            {
                int errorNum = 0;
                foreach( CompilerError error in errors )
                {
                    ListViewItem item = new ListViewItem( );

                    //Error Number
                    errorNum++;
                    item.SubItems.Add( new ListViewItem.ListViewSubItem( item, errorNum.ToString( ) ) );
                    //Error Message
                    item.SubItems.Add( new ListViewItem.ListViewSubItem( item, error.ErrorText ) );
                    //Filename
                    item.SubItems.Add( new ListViewItem.ListViewSubItem( item, System.IO.Path.GetFileName( error.FileName ) ) );
                    //Line
                    item.SubItems.Add( new ListViewItem.ListViewSubItem( item, error.Line.ToString( ) ) );
                    //Column
                    item.SubItems.Add( new ListViewItem.ListViewSubItem( item, error.Column.ToString( ) ) );

                    if( error.IsWarning )
                        _listWarnings.Items.Add( item );
                    else
                        _listErrors.Items.Add( item );
                }
            }
        }
开发者ID:HaKDMoDz,项目名称:Lunar-Development-Kit,代码行数:31,代码来源:ScriptErrorsDock.cs


示例9: CompileCSharpImmediateSnippet

        /// <summary>
        /// Compiles a method body of C# script, wrapped in a basic void-returning method.
        /// </summary>
        /// <param name="methodText">The text of the script to place inside a method.</param>
        /// <param name="errors">The compiler errors and warnings from compilation.</param>
        /// <param name="methodIfSucceeded">The compiled method if compilation succeeded.</param>
        /// <returns>True if compilation was a success, false otherwise.</returns>
        public static bool CompileCSharpImmediateSnippet(string methodText, out CompilerErrorCollection errors, out MethodInfo methodIfSucceeded)
        {
            // Wrapper text so we can compile a full type when given just the body of a method
            string methodScriptWrapper = @"
            using UnityEngine;
            using UnityEditor;
            using System.Collections;
            using System.Collections.Generic;
            using System.Text;
            using System.Xml;
            using System.Linq;
            public static class CodeSnippetWrapper
            {{
            public static void PerformAction()
            {{
            {0};
            }}
            }}";

            // Default method to null
            methodIfSucceeded = null;

            // Compile the full script
            Assembly assembly;
            if (CompileCSharpScript(string.Format(methodScriptWrapper, methodText), out errors, out assembly))
            {
                // If compilation succeeded, we can use reflection to get the method and pass that back to the user
                methodIfSucceeded = assembly.GetType("CodeSnippetWrapper").GetMethod("PerformAction", BindingFlags.Static | BindingFlags.Public);
                return true;
            }

            // Compilation failed, caller has the errors, return false
            return false;
        }
开发者ID:reydanro,项目名称:UnityToolbag,代码行数:41,代码来源:CodeCompiler.cs


示例10: TraceErrors

 private static void TraceErrors(CompilerErrorCollection errors)
 {
     foreach (var error in errors)
     {
         Trace.WriteLine(error);
     }
 }
开发者ID:gmaguire,项目名称:RuntimeTools,代码行数:7,代码来源:CodeDomCompiler.cs


示例11: StartProcessingRun

		public override void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
		{
			base.StartProcessingRun (languageProvider, templateContents, errors);
			provider = languageProvider;
			postStatements.Clear ();
			members.Clear ();
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:ParameterDirectiveProcessor.cs


示例12: HandleErrors

        static void HandleErrors(CompilerErrorCollection cr)
        {
            for(var i = 0; i < cr.Count; i++)
                Tracer.Line(cr[i].ToString());

            throw new CSharpCompilerErrorException(cr);
        }
开发者ID:hahoyer,项目名称:HWsqlass.cs,代码行数:7,代码来源:GeneratorExtension.cs


示例13: Main

		public static void Main()
		{
			var engine = new ScriptEngine();
			CompilerErrorCollection err = new CompilerErrorCollection();
			engine.Run("Console.WriteLine(\"Hello, Script!\");", out err);

		}
开发者ID:heber,项目名称:FreeOQ,代码行数:7,代码来源:ScriptEngine.cs


示例14: TemplateCompilationException

 /// <summary>
 /// Initialises a new instance of <see cref="TemplateCompilationException"/>.
 /// </summary>
 /// <param name="errors">The set of compiler errors.</param>
 /// <param name="sourceCode">The source code that wasn't compiled.</param>
 /// <param name="template">The source template that wasn't compiled.</param>
 internal TemplateCompilationException(CompilerErrorCollection errors, string sourceCode, string template)
     : base("Unable to compile template. " + errors[0].ErrorText + "\n\nOther compilation errors may have occurred. Check the Errors property for more information.")
 {
     var list = errors.Cast<CompilerError>().ToList();
     Errors = new ReadOnlyCollection<CompilerError>(list);
     SourceCode = sourceCode;
     Template = template;
 }
开发者ID:JodenSoft,项目名称:JodenSoft,代码行数:14,代码来源:TemplateCompilationException.cs


示例15: ShowErrors

		public void ShowErrors(CompilerErrorCollection errors)
		{
			TaskService.ClearExceptCommentTasks();
			foreach (CompilerError error in errors) {
				TaskService.Add(new CompilerErrorTask(error));
			}
			SD.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront();
		}
开发者ID:hefnerliu,项目名称:SharpDevelop,代码行数:8,代码来源:MvcFileGenerationErrorReporter.cs


示例16: HandleErrors_is_noop_when_no_errors

        public void HandleErrors_is_noop_when_no_errors()
        {
            var errors = new CompilerErrorCollection
                {
                    new CompilerError { IsWarning = true }
                };

            errors.HandleErrors("Not used");
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:CompilerErrorCollectionExtensionsTests.cs


示例17: CompilationException

		CompilationException (SerializationInfo info, StreamingContext context)
			: base (info, context)
                {
			filename = info.GetString ("filename");
			errors = info.GetValue ("errors", typeof (CompilerErrorCollection)) as CompilerErrorCollection;
			results = info.GetValue ("results", typeof (CompilerResults)) as CompilerResults;
			fileText = info.GetString ("fileText");
			errmsg = info.GetString ("errmsg");
			errorLines = info.GetValue ("errorLines", typeof (int[])) as int[];
                }
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:CompilationException.cs


示例18: ErrorCollectionToStringArray

        /// <summary>
        /// Errors the collection to string array.
        /// </summary>
        /// <param name="errorCollection">The error collection.</param>
        /// <returns>List&lt;System.String&gt;.</returns>
        private static List<string> ErrorCollectionToStringArray(CompilerErrorCollection errorCollection)
        {
            List<string> errors = new List<string>();
            foreach (CompilerError one in errorCollection)
            {
                errors.Add(one.ErrorText);
            }

            return errors;
        }
开发者ID:rynnwang,项目名称:CommonSolution,代码行数:15,代码来源:DynamicCompileException.cs


示例19: TemplateException

 /// <summary>
 /// Initialises a new instance of <see cref="TemplateException"/>
 /// </summary>
 /// <param name="errors">The collection of compilation errors.</param>
 internal TemplateException(CompilerErrorCollection errors)
     : base("Unable to compile template.")
 {
     var list = new List<CompilerError>();
     foreach (CompilerError error in errors)
     {
         list.Add(error);
     }
     Errors = new ReadOnlyCollection<CompilerError>(list);
 }
开发者ID:CarlosOnline,项目名称:RazorEngine,代码行数:14,代码来源:TemplateException.cs


示例20: CodeCompilerException

 public CodeCompilerException(
     string message,
     CodeCompileUnit[] codeCompileUnits,
     CompilerErrorCollection errors,
     CodeDomProvider codeDomProvider
     )
     : base(message)
 {
     CodeCompileUnit = codeCompileUnits;
     CompilerErros = errors;
 }
开发者ID:laymain,项目名称:CodeDomUtils,代码行数:11,代码来源:CodeCompilerException.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Compiler.CompilerParameters类代码示例发布时间:2022-05-26
下一篇:
C# Compiler.CompilerError类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap