in src/lib/Microsoft.Fx.Portability.MetadataReader/MemberMetadataInfo.cs [274:333]
private string GenerateMemberDocId()
{
var sb = new StringBuilder();
// Get the full name from the type
sb.Append(ParentType.ToString());
if (ParentType.IsArrayType)
{
sb.Append(ParentType.ArrayTypeInfo);
}
sb.Append(".");
// Make sure that the member name is safe by replacing the unwanted characters.
sb.Append(GetDocIdSafeMemberName(Name));
if (Kind == MemberKind.Method)
{
if (MethodSignature.GenericParameterCount > 0)
{
sb.Append(FormattableString.Invariant($"``{MethodSignature.GenericParameterCount}"));
}
}
// Add the method signature
if (Kind == MemberKind.Method && MethodSignature.ParameterTypes.Count() > 0)
{
sb.Append("(");
// Only required parameters should be listed explicitly
Debug.Assert(MethodSignature.ParameterTypes.Count() >= MethodSignature.RequiredParameterCount, LocalizedStrings.MoreParametersWereRequired);
sb.Append(string.Join(",", MethodSignature.ParameterTypes.Select(m => m.ToString()).ToArray(), 0, MethodSignature.RequiredParameterCount));
// If the method is a varargs method, it should add an '__arglist' parameter
if (MethodSignature.Header.CallingConvention.HasFlag(SignatureCallingConvention.VarArgs))
{
sb.Append(",__arglist");
}
sb.Append(")");
}
else if (Kind == MemberKind.Method && MethodSignature.Header.CallingConvention.HasFlag(SignatureCallingConvention.VarArgs))
{
// It's possible to have an __arglist without anything being passed to it
sb.Append("(__arglist)");
}
// Technically, we want to verify that these are marked as a special name along with the names op_Implicit or op_Explicit. However,
// since we are just using member references, we don't have enought information to know if it is. For now, we will assume that it is
// a special name if it only has one input parameter
if (Kind == MemberKind.Method && MethodSignature.ParameterTypes.Length == 1 &&
(string.Equals(Name, "op_Implicit", StringComparison.Ordinal) || string.Equals(Name, "op_Explicit", StringComparison.Ordinal)))
{
sb.Append("~");
sb.Append(MethodSignature.ReturnType);
}
return sb.ToString();
}