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


C# Analyzer.Analyze方法代码示例

本文整理汇总了C#中Analyzer.Analyze方法的典型用法代码示例。如果您正苦于以下问题:C# Analyzer.Analyze方法的具体用法?C# Analyzer.Analyze怎么用?C# Analyzer.Analyze使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Analyzer的用法示例。


在下文中一共展示了Analyzer.Analyze方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        public override void Initialize(AnalysisContext analysisContext)
        {
            // this is stateless analyzer, can run concurrently
            analysisContext.EnableConcurrentExecution();

            // this has no meaning on running on generated code which user can't control
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(c =>
            {
                INamedTypeSymbol @string = WellKnownTypes.String(c.Compilation);
                INamedTypeSymbol uri = WellKnownTypes.Uri(c.Compilation);
                if (@string == null || uri == null)
                {
                    // we don't have required types
                    return;
                }

                var analyzer = new Analyzer(c.Compilation, @string, uri, GetInvocationExpression);

                // REVIEW: I need to do this thing because OperationAnalysisContext doesn't give me OwningSymbol
                c.RegisterOperationBlockStartAction(sc =>
                {
                    sc.RegisterOperationAction(oc => analyzer.Analyze(oc, sc.OwningSymbol), OperationKind.InvocationExpression);
                });
            });
        }
开发者ID:vweijsters,项目名称:roslyn-analyzers,代码行数:27,代码来源:PassSystemUriObjectsInsteadOfStrings.cs

示例2: Main

    public static void Main(String[] args)
    {
        try
        {
            ITransformer transformer = new Transformer();
            IReader reader = new ConsoleReader();
            IAnalyzer analyzer = new Analyzer(reader, transformer);
            AnalysisResult analysisResult = analyzer.Analyze();
            IDumper fileDumper = new ConsoleDumper(analysisResult);

            // A better way to inform about the result would be an Enum with some codes (error dumping, error reading, error connecting to db, etc)
            bool operationFinished = fileDumper.Dump();
            string message = "";
            if (operationFinished) { message = ""; }
            else { message = "The application encountered an error. Please check the logs. Press Enter to exit."; }

            Console.WriteLine(message);
            Console.ReadLine();
        }
        catch (Exception ex)
        {
            ex.Log("");
            Console.WriteLine("The application encountered an error. Please check the logs. Press Enter to exit.");
            Console.ReadLine();
        }
    }
开发者ID:gophlb,项目名称:FraudPrevention,代码行数:26,代码来源:Solution.cs

示例3: Apply

        public BuildResult Apply(IDictionary<string, string> substitutions, bool debug)
        {
            var analyzer = new Analyzer(script.Compilation, substitutions);
            var analyzed = analyzer.Analyze();

            var rewriter = new Rewriter(script.Compilation, analyzed);
            var rewritten = rewriter.Rewrite();

            byte[] assembly;
            byte[] symbols = null;

            if (debug)
                EmitDebug(rewritten, out assembly, out symbols);
            else
                Emit(rewritten, out assembly);

            return new BuildResult(
                analyzed.Tasks.ToArray(),
                script.References.ToArray(),
                rewriter.Captured.ToArray(),
                assembly, symbols
            );
        }
开发者ID:jthelin,项目名称:Nake,代码行数:23,代码来源:Engine.cs

示例4: Compile

		/// <summary>
		/// Compiles the transient unit. 'PreCompile' should be called first!
		/// </summary>
		internal bool Compile(CompilationContext/*!*/ context, EvalKinds kind)
		{
			Analyzer analyzer = null;

			try
			{
				analyzer = new Analyzer(context);

				// perform pre-analysis on types and functions:
				if (types != null)
					analyzer.PreAnalyze(types.Values);

				if (functions != null)
					analyzer.PreAnalyze(functions.Values);

				// perform member analysis on types and functions:
				if (types != null)
					analyzer.AnalyzeMembers(types.Values);
				if (functions != null)
					analyzer.AnalyzeMembers(functions.Values);
				
				if (context.Errors.AnyFatalError) return false;

				// perform full analysis:
				analyzer.Analyze(sourceUnit);

				if (context.Errors.AnyFatalError) return false;

				// perform post analysis:
				analyzer.PostAnalyze();
			}
			catch (CompilerException)
			{
				return false;
			}
			finally
			{
				resolvingScriptContext = null;
				referringType = null;
			}

			// do not emit anything if there was parse/analysis error:
			if (context.Errors.AnyError) return false;

			DefineBuilders();

			// define constructed types:
			analyzer.DefineConstructedTypeBuilders();

			CodeGenerator cg = new CodeGenerator(context);
			sourceUnit.Emit(cg);
			return true;
		}
开发者ID:MpApQ,项目名称:Phalanger,代码行数:56,代码来源:CompilationUnits.cs


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