Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to look up documentation for methods with out or ref parameters. #4

Open
Shane88 opened this issue Jan 5, 2015 · 2 comments
Open

Comments

@Shane88
Copy link

Shane88 commented Jan 5, 2015

When trying to look up documentation for a method that has out or ref parameters DocsService.GetXmlFromMember fails. I originally tried using the code here http://jimblackler.net/blog/?p=49 and ran into this issue. I then tried using this nuget package which also has the same issue. I reverted back to the code on jim blacklers blog and changed a small piece of code in DocsByReflection.XMLFromMember(MethodInfo methodInfo)

Where the following line was

parametersString += parameterInfo.ParameterType.FullName;

I changed it too

if (parameterInfo.ParameterType.IsByRef)
{
    parametersString += parameterInfo.ParameterType.FullName.Replace('&', '@');
}
else
{
    parametersString += parameterInfo.ParameterType.FullName;
}

I have not identified where the appropriate fix would be in this projects code base. The problem was that the types name for ref and out parameters contains a trailing &, but the XML documentation contains a @ instead.

@msamusenka
Copy link

I'd rather suggest this fix:

        public static string GetTypeFullNameForXmlDoc(Type type, bool isMethodParameter = false)
        {
            if (type.MemberType == MemberTypes.TypeInfo && type.IsGenericType && (!type.IsClass || isMethodParameter))
            {
                return String.Format(CultureInfo.InvariantCulture,
                    "{0}.{1}{{{2}}}",
                    type.Namespace,
                    type.Name.Replace("`1", ""),
                    GetTypeFullNameForXmlDoc(type.GetGenericArguments().FirstOrDefault()));
            }
            else if (type.IsByRef)
            {
                return String.Format(CultureInfo.InvariantCulture, "{0}@", GetTypeFullNameForXmlDoc(type.GetElementType()));
            }
            else if (type.IsNested)
            {
                return String.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}", type.Namespace, type.DeclaringType.Name, type.Name);
            }
            else
            {
                return String.Format(CultureInfo.InvariantCulture, "{0}.{1}", type.Namespace, type.Name);
            }
        }

@giacomelli
Copy link
Owner

Please, make a pull-request with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants