Esempio n. 1
0
        private static DataFlowAnalysisResult <DisposeBlockAnalysisResult, DisposeAbstractValue> GetOrComputeResultCore(
            ControlFlowGraph cfg,
            INamedTypeSymbol iDisposable,
            INamedTypeSymbol taskType,
            ImmutableHashSet <INamedTypeSymbol> collectionTypes,
            ImmutableHashSet <INamedTypeSymbol> disposeOwnershipTransferLikelyTypes,
            ISymbol owningSymbol,
            DataFlowAnalysisResult <PointsToAnalysis.PointsToBlockAnalysisResult, PointsToAnalysis.PointsToAbstractValue> pointsToAnalysisResult,
            DataFlowAnalysisResult <NullAnalysis.NullBlockAnalysisResult, NullAnalysis.NullAbstractValue> nullAnalysisResultOpt,
            bool trackInstanceFields,
            out ImmutableDictionary <IFieldSymbol, PointsToAnalysis.PointsToAbstractValue> trackedInstanceFieldPointsToMap)
        {
            Debug.Assert(cfg != null);
            Debug.Assert(iDisposable != null);
            Debug.Assert(owningSymbol != null);
            Debug.Assert(pointsToAnalysisResult != null);

            var operationVisitor = new DisposeDataFlowOperationVisitor(iDisposable, taskType, collectionTypes,
                                                                       disposeOwnershipTransferLikelyTypes, DisposeAbstractValueDomain.Default, owningSymbol, trackInstanceFields, pointsToAnalysisResult, nullAnalysisResultOpt);
            var disposeAnalysis = new DisposeAnalysis(DisposeAnalysisDomainInstance, operationVisitor);
            var result          = disposeAnalysis.GetOrComputeResultCore(cfg);

            trackedInstanceFieldPointsToMap = trackInstanceFields ? operationVisitor.TrackedInstanceFieldPointsToMap : null;
            return(result);
        }
        public static DataFlowAnalysisResult <DisposeBlockAnalysisResult, DisposeAbstractValue> GetOrComputeResult(
            ControlFlowGraph cfg,
            INamedTypeSymbol iDisposable,
            INamedTypeSymbol iCollection,
            INamedTypeSymbol genericICollection,
            ImmutableHashSet <INamedTypeSymbol> disposeOwnershipTransferLikelyTypes,
            INamedTypeSymbol containingTypeSymbol,
            DataFlowAnalysisResult <PointsToAnalysis.PointsToBlockAnalysisResult, PointsToAnalysis.PointsToAbstractValue> pointsToAnalysisResult,
            DataFlowAnalysisResult <NullAnalysis.NullBlockAnalysisResult, NullAnalysis.NullAbstractValue> nullAnalysisResultOpt = null)
        {
            Debug.Assert(cfg != null);
            Debug.Assert(iDisposable != null);
            Debug.Assert(containingTypeSymbol != null);
            Debug.Assert(pointsToAnalysisResult != null);

            var operationVisitor = new DisposeDataFlowOperationVisitor(iDisposable, iCollection, genericICollection,
                                                                       disposeOwnershipTransferLikelyTypes, DisposeAbstractValueDomain.Default, containingTypeSymbol, pointsToAnalysisResult, nullAnalysisResultOpt);
            var disposeAnalysis = new DisposeAnalysis(DisposeAnalysisDomainInstance, operationVisitor);

            return(disposeAnalysis.GetOrComputeResultCore(cfg));
        }
        private static DataFlowAnalysisResult <DisposeBlockAnalysisResult, DisposeAbstractValue> GetOrComputeResultCore(
            ControlFlowGraph cfg,
            ISymbol owningSymbol,
            WellKnownTypeProvider wellKnownTypeProvider,
            ImmutableHashSet <INamedTypeSymbol> disposeOwnershipTransferLikelyTypes,
            DataFlowAnalysisResult <PointsToAnalysis.PointsToBlockAnalysisResult, PointsToAnalysis.PointsToAbstractValue> pointsToAnalysisResult,
            bool trackInstanceFields,
            out ImmutableDictionary <IFieldSymbol, PointsToAnalysis.PointsToAbstractValue> trackedInstanceFieldPointsToMap)
        {
            Debug.Assert(cfg != null);
            Debug.Assert(wellKnownTypeProvider.IDisposable != null);
            Debug.Assert(owningSymbol != null);
            Debug.Assert(pointsToAnalysisResult != null);

            var operationVisitor = new DisposeDataFlowOperationVisitor(DisposeAbstractValueDomain.Default, owningSymbol, wellKnownTypeProvider,
                                                                       disposeOwnershipTransferLikelyTypes, trackInstanceFields, pointsToAnalysisResult);
            var disposeAnalysis = new DisposeAnalysis(DisposeAnalysisDomainInstance, operationVisitor);
            var result          = disposeAnalysis.GetOrComputeResultCore(cfg, cacheResult: false);

            trackedInstanceFieldPointsToMap = trackInstanceFields ? operationVisitor.TrackedInstanceFieldPointsToMap : null;
            return(result);
        }