當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。