public override object VisitMethodCallExpression(IMethodCallExpression expression) { // check if analysis of this property isn't terminated if (this.context.Current.PropertyAnalysisTerminated) { return(expression); } string invocationPath; // if expression is property invocation chain add explicate dependency and don't analyze this branch. if (this.context.Current.IsInCurrentProperty() && this.TryGetPropertyInvocationChain(expression, out invocationPath)) { this.context.Current.ExplicitDependencyMap.AddDependency(this.context.Current.CurrentProperty.Name, invocationPath); return(base.VisitMethodCallExpression(expression)); } List <string> ivocationPaths; // if expression is Depends.On call add explicit dependency and terminate analysis of this property if (this.TryGetDependsOn(expression, out ivocationPaths)) { // Depends.On is valid only in property if (this.context.Current.Parent == null || !this.context.Current.Parent.IsInCurrentProperty()) { DomainMessageSource.Instance.Write( this.context.Current.CurrentProperty, SeverityType.Error, "DOM012", this.context.Current.CurrentMethod); } this.context.Current.TerminateCurrentPropertyAnalysis(); this.context.Current.ExplicitDependencyMap.AddDependencies(this.context.Current.CurrentProperty.Name, ivocationPaths); return(expression); } ExpressionValidationResult validationResult = this.context.Current.Validate(expression); if (validationResult.HasFlag(ExpressionValidationResult.ImmediateReturn)) { return(base.VisitMethodCallExpression(expression)); } this.AnalyzeMethodRecursive(expression.Method); IList <FieldInfo> calledMethodFields; this.methodFieldDependencies.TryGetValue(expression.Method, out calledMethodFields); if (calledMethodFields != null) { IList <FieldInfo> fieldList = this.methodFieldDependencies.GetOrCreate(this.context.Current.CurrentMethod, () => new List <FieldInfo>()); foreach (FieldInfo calledMethodField in calledMethodFields) { fieldList.AddIfNew(calledMethodField); } } return(base.VisitMethodCallExpression(expression)); }
public override object VisitFieldExpression(IFieldExpression expression) { if (this.context.Current.PropertyAnalysisTerminated) { return(expression); } ExpressionValidationResult validationResult = this.context.Current.Validate(expression); if (validationResult.HasFlag(ExpressionValidationResult.ImmediateReturn)) { return(base.VisitFieldExpression(expression)); } this.methodFieldDependencies.GetOrCreate(this.context.Current.CurrentMethod, () => new List <FieldInfo>()).AddIfNew(expression.Field); return(base.VisitFieldExpression(expression)); }