public override object TrackedVisitMethodDeclaration(MethodDeclaration methodDeclaration, object data) { TypeDeclaration typeDeclaration = (TypeDeclaration)methodDeclaration.Parent; if (typeDeclaration.BaseTypes.Count > 0) { if (IsMethodInExternalTypes(typeDeclaration, methodDeclaration)) { return(null); } } string methodName = methodDeclaration.Name; methodDeclaration.Name = Renamer.GetNewName(methodName); if (methodDeclaration.Name == typeDeclaration.Name) { methodDeclaration.Name += "_"; } return(base.TrackedVisitMethodDeclaration(methodDeclaration, data)); }
public override object TrackedVisitInvocationExpression(InvocationExpression invocationExpression, object data) { if (invocationExpression.TargetObject is IdentifierExpression) { IdentifierExpression identifierExpression = (IdentifierExpression)invocationExpression.TargetObject; TypeDeclaration typeDeclaration = (TypeDeclaration)AstUtil.GetParentOfType(invocationExpression, typeof(TypeDeclaration)); if (ExistMethodIn(typeDeclaration, invocationExpression)) { identifierExpression.Identifier = Renamer.GetNewName(identifierExpression.Identifier); } } else if (invocationExpression.TargetObject is FieldReferenceExpression) { FieldReferenceExpression fieldReferenceExpression = (FieldReferenceExpression)invocationExpression.TargetObject; Expression invoker = fieldReferenceExpression.TargetObject; if (fieldReferenceExpression.FieldName == "CallInternalMethod") { PrimitiveExpression methodName = (PrimitiveExpression)invocationExpression.Arguments[0]; if (methodName.Value.ToString().StartsWith("set") || methodName.Value.ToString().StartsWith("get")) { Expression obj = (Expression)invocationExpression.Arguments[1]; TypeReference objType = GetExpressionType(obj); if (objType != null) { string fullName = GetFullName(objType); if (CodeBase.Types.Contains(fullName)) { TypeDeclaration typeDeclaration = (TypeDeclaration)CodeBase.Types[fullName]; string propertyName = methodName.Value.ToString().Substring(3); if (ContainsProperty(typeDeclaration, propertyName)) { methodName.Value = methodName.Value.ToString().Insert(3, "_"); } else { methodName.Value = Renamer.GetNewName(methodName.Value.ToString()); } } } } else { methodName.Value = Renamer.GetNewName(methodName.Value.ToString()); } } TypeReference invokerType = GetExpressionType(invoker); if (invokerType != null) { string fullName = GetFullName(invokerType); if (CodeBase.Types.Contains(fullName) && !IsInExternalLibraries(fullName)) { TypeDeclaration typeDeclaration = (TypeDeclaration)CodeBase.Types[fullName]; if (ExistMethodIn(typeDeclaration, invocationExpression)) { fieldReferenceExpression.FieldName = Renamer.GetNewName(fieldReferenceExpression.FieldName); } } else { TypeMapping mapping = CodeBase.Mappings.GetCounterpart(fullName); string mapkey; if (ContainsMapping(mapping, invocationExpression, out mapkey)) { fieldReferenceExpression.FieldName = Renamer.GetNewName(fieldReferenceExpression.FieldName); } } } } return(base.TrackedVisitInvocationExpression(invocationExpression, data)); }