diff options
author | katsiaryna_bialiatka <katsiaryna_bialiatka@epam.com> | 2018-06-08 15:58:17 +0300 |
---|---|---|
committer | katsiaryna_bialiatka <katsiaryna_bialiatka@epam.com> | 2018-06-08 15:58:17 +0300 |
commit | 59459f1de8394c8110c2fddbeb8d65f8741a8122 (patch) | |
tree | 7a7aadda3ab69cc983e6b4154753e8b47deeaaf7 /mdoc/Mono.Documentation/Updater/DocUtils.cs | |
parent | 111914edcbdf705aa44cfaeadabf343e3e3ea052 (diff) |
Fix Eii property names for VB
Apply fix to have interface name in signature
Fix ecma importers + slash doc importers
Add unit and integration tests
Addnew attribute for custom Eii name + fix xsd schema
Closes #92
Diffstat (limited to 'mdoc/Mono.Documentation/Updater/DocUtils.cs')
-rw-r--r-- | mdoc/Mono.Documentation/Updater/DocUtils.cs | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/mdoc/Mono.Documentation/Updater/DocUtils.cs b/mdoc/Mono.Documentation/Updater/DocUtils.cs index ed62e2de..2cf86f12 100644 --- a/mdoc/Mono.Documentation/Updater/DocUtils.cs +++ b/mdoc/Mono.Documentation/Updater/DocUtils.cs @@ -122,12 +122,28 @@ namespace Mono.Documentation.Updater return name.Substring (startType + 1);
}
- public static string GetMember (string name)
+ public static string GetMember(string name)
{
- int i = name.LastIndexOf ('.');
- if (i == -1)
- return name;
- return name.Substring (i + 1);
+ int i = name.LastIndexOf('.');
+ var memberName = i == -1 ? name : name.Substring(i + 1);
+
+ return memberName;
+ }
+
+ public static string GetMemberForProperty(string name)
+ {
+ int i = name.LastIndexOf('.');
+ var memberName = i == -1 ? name : name.Substring(i + 1);
+
+ if (memberName.StartsWith("get_") || memberName.StartsWith("set_"))
+ {
+ var index = memberName.IndexOf("_", StringComparison.InvariantCulture);
+ if (index > 0)
+ //remove get/set prefix from method name
+ memberName = memberName.Substring(index + 1);
+ }
+
+ return memberName;
}
public static void GetInfoForExplicitlyImplementedMethod (
@@ -156,24 +172,22 @@ namespace Mono.Documentation.Updater return true;
}
- public static string GetPropertyName (PropertyDefinition pi)
+ public static string GetPropertyName (PropertyDefinition pi, string delimeter = ".")
{
// Issue: (g)mcs-generated assemblies that explicitly implement
// properties don't specify the full namespace, just the
// TypeName.Property; .NET uses Full.Namespace.TypeName.Property.
- MethodDefinition method = pi.GetMethod;
- if (method == null)
- method = pi.SetMethod;
- if (!IsExplicitlyImplemented (method))
+ MethodDefinition method = pi.GetMethod ?? pi.SetMethod;
+ bool isExplicitlyImplemented = IsExplicitlyImplemented(method);
+ if (!isExplicitlyImplemented)
return pi.Name;
// Need to determine appropriate namespace for this member.
- TypeReference iface;
- MethodReference ifaceMethod;
- GetInfoForExplicitlyImplementedMethod (method, out iface, out ifaceMethod);
- return string.Join (".", new string[]{
- DocTypeFullMemberFormatter.Default.GetName (iface),
- GetMember (pi.Name)});
+ GetInfoForExplicitlyImplementedMethod (method, out var iface, out var ifaceMethod);
+ var stringifyIface = DocTypeFullMemberFormatter.Default.GetName(iface).Replace(".", delimeter);
+ return string.Join (delimeter, new string[]{
+ stringifyIface,
+ GetMemberForProperty (ifaceMethod.Name)});
}
public static string GetNamespace (TypeReference type, string delimeter = null)
@@ -372,7 +386,7 @@ namespace Mono.Documentation.Updater private static bool IsCompilerGenerated(MemberReference mi)
{
- IMemberDefinition memberDefinition = mi.Resolve();
+ IMemberDefinition memberDefinition = mi.Resolve();
return memberDefinition.IsSpecialName
|| memberDefinition.CustomAttributes.Any(i =>
i.AttributeType.FullName == Consts.CompilerGeneratedAttribute
@@ -380,7 +394,7 @@ namespace Mono.Documentation.Updater );
}
- public static bool IsAvailablePropertyMethod(MethodDefinition method)
+ public static bool IsAvailablePropertyMethod(MethodDefinition method)
{
return method != null
&& (IsExplicitlyImplemented(method)
|