public IVSDebugPropertyProxy EvaluateExpression(string expression) { if (string.IsNullOrEmpty(expression)) { throw new ArgumentNullException("Expression is empty"); } _log.Info("Evaluating expression {0}.", expression); IVSDebugPropertyProxy resultDebugProperty = _cache.TryGetFromCache(expression); if (resultDebugProperty != null) { return(resultDebugProperty); } IDebugProperty2 debugProperty = GetVsDebugProperty(expression); _log.Info($"Done evaluating expression {expression} "); resultDebugProperty = VSDebugPropertyProxy.Create(debugProperty); _log.Info($"Property retreived { resultDebugProperty }"); _cache.Cache(expression, resultDebugProperty); return(resultDebugProperty); }
public void TraversPropertyTree( IVSDebugPropertyProxy debugProperty, string searchCriteria) { StringFilter stringFilter = new StringFilter(searchCriteria); _isCanceling = false; TraversPropertyTreeInternal(debugProperty, stringFilter, 0); _propertyVisitor.Dispose(); }
/// <summary> /// Traversal of Properties Tree (deep-fir, recursive) /// </summary> private void TraversPropertyTreeInternal( IVSDebugPropertyProxy debugProperty, StringFilter stringFilter, int depth) { depth++; if (depth > MaxDepth) { _searchStatus.StatusUpdated($"Skipping property: {debugProperty.PropertyInfo.FullName}. Max depth reached"); return; } if (SelfReferenceDetection.DoesItLookLikeSelfReference(debugProperty.PropertyInfo.Name)) { _searchStatus.StatusUpdated($"Skip traversing property {debugProperty.PropertyInfo.FullName}. Property looks like referece to self object"); return; } ThrowIfCancelRequested(); _logger.Info("Traversing property {0}", debugProperty.PropertyInfo.FullName); // visit root RiseAppropriateAction(debugProperty.PropertyInfo, stringFilter); // travers all children foreach (IPropertyInfo unevalProperty in debugProperty.Children) { ThrowIfCancelRequested(); IVSDebugPropertyProxy evaluated = EvaluateExpression(unevalProperty); // null in case we can skip that property if (evaluated == null) { continue; } var valueProperty = evaluated.PropertyInfo as IValuePropertyInfo; if (valueProperty != null) { RiseAppropriateAction(valueProperty, stringFilter); } else if (evaluated.PropertyInfo is IExpandablePropertyInfo) { TraversPropertyTreeInternal(evaluated, stringFilter, depth); } else { throw new NotSupportedException($"Property info type { evaluated.PropertyInfo.GetType().Name } is not supported. Contact developer."); } } }
private void Search() { var expressionEvaluatorProvider = _expressionEvaluatorProvider; if (expressionEvaluatorProvider.IsEvaluatorAvailable) { if (String.IsNullOrEmpty(FilterText)) // search all locals { _property = expressionEvaluatorProvider.ExpressionEvaluator.GetLocals(); IterateThrueProperty(expressionEvaluatorProvider); } else { _property = expressionEvaluatorProvider.ExpressionEvaluator.EvaluateExpression(FilterText); IterateThrueProperty(expressionEvaluatorProvider); } } }
private void RiseAppropriateAction(IPropertyInfo propertyInfo, StringFilter stringFilter) { if (propertyInfo == null) { return; } bool nameMatches = (stringFilter.IsMatching(propertyInfo.Name) || stringFilter.IsMatching(propertyInfo.FullName)); if (propertyInfo is IExpandablePropertyInfo) { if (nameMatches) { _propertyVisitor.ParentPropertyAttended((IExpandablePropertyInfo)propertyInfo); } } else if (propertyInfo is IValuePropertyInfo) { var valuePropertyInfo = (IValuePropertyInfo)propertyInfo; if (!valuePropertyInfo.IsEvaluated) { IVSDebugPropertyProxy eveluatedProperty = EvaluateExpression(valuePropertyInfo); if (eveluatedProperty != null && eveluatedProperty.PropertyInfo is IValuePropertyInfo) { valuePropertyInfo = (IValuePropertyInfo)eveluatedProperty.PropertyInfo; } } if (nameMatches || stringFilter.IsMatching(valuePropertyInfo.Value)) { _propertyVisitor.ValuePropertyAttended(valuePropertyInfo); } } else { throw new NotSupportedException("This property info type is not supported. Contact developer."); } }
public void Cache(string expression, IVSDebugPropertyProxy resultDebugProperty) { // do nothing }
public void Cache(string expression, IVSDebugPropertyProxy resultDebugProperty) { _cache.TryAdd(expression, resultDebugProperty); }