mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 12:31:30 -10:00
[mdoc-update] Add C#4 dynamic support for method declarations.
This commit is contained in:
1 parent
f0c2471465
commit
d80fadfb44
1 file changed
+24
-2
@@ -1899,6 +1899,8 @@ class MDocUpdater : MDocCommand
|
||||
"System.Runtime.CompilerServices.UnsafeValueTypeAttribute",
|
||||
// extension methods
|
||||
"System.Runtime.CompilerServices.ExtensionAttribute",
|
||||
// Used to differentiate 'object' from C#4 'dynamic'
|
||||
"System.Runtime.CompilerServices.DynamicAttribute",
|
||||
};
|
||||
|
||||
private void MakeAttributes (XmlElement root, IEnumerable<string> attributes)
|
||||
@@ -3518,7 +3520,7 @@ public abstract class MemberFormatter {
|
||||
|
||||
if (buf.Length != 0)
|
||||
buf.Append (" ");
|
||||
buf.Append (GetName (method.ReturnType.ReturnType)).Append (" ");
|
||||
buf.Append (GetTypeName (method.ReturnType)).Append (" ");
|
||||
|
||||
AppendMethodName (buf, method);
|
||||
AppendGenericMethod (buf, method).Append (" ");
|
||||
@@ -3527,6 +3529,11 @@ public abstract class MemberFormatter {
|
||||
return buf.ToString ();
|
||||
}
|
||||
|
||||
protected virtual string GetTypeName (MethodReturnType returnType)
|
||||
{
|
||||
return GetName (returnType.ReturnType);
|
||||
}
|
||||
|
||||
protected virtual StringBuilder AppendMethodName (StringBuilder buf, MethodDefinition method)
|
||||
{
|
||||
return buf.Append (method.Name);
|
||||
@@ -4336,6 +4343,21 @@ class CSharpFullMemberFormatter : MemberFormatter {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override string GetTypeName (MethodReturnType returnType)
|
||||
{
|
||||
return GetTypeName (returnType, () => returnType.ReturnType);
|
||||
}
|
||||
|
||||
string GetTypeName (ICustomAttributeProvider provider, Func<TypeReference> selector)
|
||||
{
|
||||
string type = GetName (selector ());
|
||||
if (type == "object" && provider.HasCustomAttributes &&
|
||||
provider.CustomAttributes.Cast<CustomAttribute>()
|
||||
.Any (ca => ca.Constructor.DeclaringType.FullName == "System.Runtime.CompilerServices.DynamicAttribute"))
|
||||
return "dynamic";
|
||||
return type;
|
||||
}
|
||||
|
||||
protected override StringBuilder AppendMethodName (StringBuilder buf, MethodDefinition method)
|
||||
{
|
||||
if (DocUtils.IsExplicitlyImplemented (method)) {
|
||||
@@ -4437,7 +4459,7 @@ class CSharpFullMemberFormatter : MemberFormatter {
|
||||
else
|
||||
buf.Append ("ref ");
|
||||
}
|
||||
buf.Append (GetName (parameter.ParameterType)).Append (" ");
|
||||
buf.Append (GetTypeName (parameter, () => parameter.ParameterType)).Append (" ");
|
||||
return buf.Append (parameter.Name);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user