Example #1
0
        public static DisposeAnalysisResult TryGetOrComputeResult(
            ControlFlowGraph cfg,
            ISymbol owningSymbol,
            WellKnownTypeProvider wellKnownTypeProvider,
            AnalyzerOptions analyzerOptions,
            DiagnosticDescriptor rule,
            ImmutableHashSet <INamedTypeSymbol> disposeOwnershipTransferLikelyTypes,
            bool trackInstanceFields,
            bool exceptionPathsAnalysis,
            CancellationToken cancellationToken,
            out PointsToAnalysisResult pointsToAnalysisResult,
            InterproceduralAnalysisKind interproceduralAnalysisKind = InterproceduralAnalysisKind.ContextSensitive,
            bool performCopyAnalysisIfNotUserConfigured             = false,
            InterproceduralAnalysisPredicate interproceduralAnalysisPredicateOpt = null,
            bool defaultDisposeOwnershipTransferAtConstructor = false,
            bool defaultDisposeOwnershipTransferAtMethodCall  = false)
        {
            Debug.Assert(!owningSymbol.IsConfiguredToSkipAnalysis(analyzerOptions, rule, wellKnownTypeProvider.Compilation, cancellationToken));

            var interproceduralAnalysisConfig = InterproceduralAnalysisConfiguration.Create(
                analyzerOptions, rule, interproceduralAnalysisKind, cancellationToken);
            var disposeOwnershipTransferAtConstructor = analyzerOptions.GetDisposeOwnershipTransferAtConstructorOption(
                rule, defaultValue: defaultDisposeOwnershipTransferAtConstructor, cancellationToken);
            var disposeOwnershipTransferAtMethodCall = analyzerOptions.GetDisposeOwnershipTransferAtMethodCall(
                rule, defaultValue: defaultDisposeOwnershipTransferAtMethodCall, cancellationToken);

            return(TryGetOrComputeResult(cfg, owningSymbol, analyzerOptions, wellKnownTypeProvider,
                                         interproceduralAnalysisConfig, interproceduralAnalysisPredicateOpt,
                                         disposeOwnershipTransferLikelyTypes, disposeOwnershipTransferAtConstructor,
                                         disposeOwnershipTransferAtMethodCall, trackInstanceFields, exceptionPathsAnalysis,
                                         performCopyAnalysis: analyzerOptions.GetCopyAnalysisOption(rule, defaultValue: performCopyAnalysisIfNotUserConfigured, cancellationToken),
                                         out pointsToAnalysisResult));
        }
Example #2
0
 public static bool GetDisposeOwnershipTransferAtMethodCall(
     this AnalyzerOptions options,
     DiagnosticDescriptor rule,
     ISymbol symbol,
     Compilation compilation,
     bool defaultValue,
     CancellationToken cancellationToken)
 => options.GetDisposeOwnershipTransferAtMethodCall(rule, symbol.Locations[0].SourceTree, compilation, defaultValue, cancellationToken);
Example #3
0
 public static bool GetDisposeOwnershipTransferAtMethodCall(
     this AnalyzerOptions options,
     DiagnosticDescriptor rule,
     ISymbol symbol,
     Compilation compilation,
     bool defaultValue)
 => TryGetSyntaxTreeForOption(symbol, out var tree)
     ? options.GetDisposeOwnershipTransferAtMethodCall(rule, tree, compilation, defaultValue)
     : defaultValue;