internal static string GetMethodName(Method method, MemberNameOptions givenOptions, Scope scope, out bool isIndexer) { string methName = null; isIndexer = false; if ( method.Template != null) methName = MemberNameBuilder.GetAtPrefixedIfRequired(method.Template.GetUnmangledNameWithoutTypeParameters(true), givenOptions); else methName = MemberNameBuilder.GetAtPrefixedIfRequired(method.GetUnmangledNameWithoutTypeParameters(true), givenOptions); if (method is InstanceInitializer) { MemberNameOptions mask = MemberNameOptions.Keywords | MemberNameOptions.TemplateInfo | MemberNameOptions.TemplateArguments | MemberNameOptions.TemplateParameters | MemberNameOptions.Namespace | MemberNameOptions.EnclosingType; methName = MemberNameBuilder.GetMemberNameRaw(method.DeclaringType, givenOptions & ~mask, scope); } else if (method.IsSpecialName) { if (methName.StartsWith("get_") || methName.StartsWith("set_")) { if ((method.Parameters != null && method.Parameters.Count > 0)) { // In this case enclosing type is not really an option. its part of name. methName = MemberNameBuilder.GetMemberNameRaw(method.DeclaringType, givenOptions, scope); if (methName == null) methName = ""; isIndexer = true; } methName = methName.Substring(4); } else if (methName.StartsWith("add_") && method.Parameters != null && method.Parameters.Count == 1) methName = methName.Substring(4); else if (methName.StartsWith("remove_") && method.Parameters != null && method.Parameters.Count == 1) methName = methName.Substring(7); else { string opName = method.Name == null ? null : (string)Cci.Checker.OperatorName[method.Name.UniqueIdKey]; if (opName != null) { // In this case Enclosing type is not really an option. its part of name. string name = MemberNameBuilder.GetMemberNameRaw(method.DeclaringType, givenOptions, scope) + "." + opName; if (method.Name.UniqueIdKey == StandardIds.opExplicit.UniqueIdKey || method.Name.UniqueIdKey == StandardIds.opImplicit.UniqueIdKey) name = name + " " + MemberNameBuilder.GetMemberNameRaw(method.ReturnType, givenOptions, scope); return name; } } } else { if (method.HasCompilerGeneratedSignature) { if (method.Name.UniqueIdKey == StandardIds.Finalize.UniqueIdKey) methName = "~" + MemberNameBuilder.GetAtPrefixedIfRequired(method.DeclaringType.Name.Name, givenOptions); } } if (method.ImplementedTypes != null && method.ImplementedTypes.Count > 0 && method.ImplementedTypes[0] != null && IsOptionActive(givenOptions, MemberNameOptions.ImplementInterface)) methName = MemberNameBuilder.GetMemberNameRaw(method.ImplementedTypes[0], givenOptions, scope) + "." + methName; if (IsOptionActive(givenOptions, MemberNameOptions.EnclosingType) && !isIndexer) { string decTypeName = null; if (!IsOptionActive(givenOptions, MemberNameOptions.SmartClassName) || !MemberNameBuilder.IsAggregateVisibleIn(method.DeclaringType, scope)) decTypeName = MemberNameBuilder.GetMemberNameRaw(method.DeclaringType, givenOptions, scope); ; if (decTypeName != null) methName = decTypeName + "." + methName; } return methName; }
private Method VisitMethodInternal(Method method) { if (method == null) return null; this.writer.WriteStartElement("Method"); string nameWithParameters = method.GetUnmangledNameWithoutTypeParameters(false); this.writer.WriteAttributeString("name", method.ReturnType.GetFullUnmangledNameWithTypeParameters() + " " + nameWithParameters); this.WriteSourceContext(method); this.writer.WriteEndElement(); // Method return method; }