コード例 #1
0
        public override void Initialize(AnalysisContext context)
        {
#pragma warning disable CA1062 // Validate arguments of public methods
            context.RegisterCompilationStartAction(x =>
#pragma warning restore CA1062 // Validate arguments of public methods
            {
                var transaction = SyntaxTreeCache <SemanticModel> .Begin(x.Compilation);
                x.RegisterCompilationEndAction(_ => transaction.Dispose());
            });
        }
コード例 #2
0
        public override void Initialize(AnalysisContext context)
        {
#pragma warning disable CA1062 // Validate arguments of public methods
            context.EnableConcurrentExecution();
#pragma warning restore CA1062 // Validate arguments of public methods
            context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
            context.RegisterCompilationStartAction(x =>
            {
                var transaction = SyntaxTreeCache <SemanticModel> .Begin(x.Compilation);
                x.RegisterCompilationEndAction(_ => transaction.Dispose());
            });
        }
コード例 #3
0
 /// <summary>
 /// Get an item from cache or create and add and return.
 /// </summary>
 /// <typeparam name="TValue">The value type.</typeparam>
 /// <param name="key">The cache key.</param>
 /// <param name="valueFactory">The factory for new items.</param>
 /// <returns>The cached value.</returns>
 public static TValue GetOrAdd <TValue>(SyntaxTree key, Func <SyntaxTree, TValue> valueFactory) => SyntaxTreeCache <TValue> .GetOrAdd(key, valueFactory);