}
}
- string FormatNameAndSig (bool serialization)
+ string FormatNameAndSig ()
{
// Serialization uses ToString to resolve MethodInfo overloads.
StringBuilder sbName = new StringBuilder(Name);
- // serialization == true: use unambiguous (except for assembly name) type names to distinguish between overloads.
- // serialization == false: use basic format to maintain backward compatibility of MethodInfo.ToString().
- TypeNameFormatFlags format = serialization ? TypeNameFormatFlags.FormatSerialization : TypeNameFormatFlags.FormatBasic;
-
if (IsGenericMethod)
- sbName.Append(RuntimeMethodHandle.ConstructInstantiation(this, format));
+ sbName.Append(RuntimeMethodHandle.ConstructInstantiation(this, TypeNameFormatFlags.FormatBasic));
sbName.Append("(");
- RuntimeParameterInfo.FormatParameters (sbName, GetParametersNoCopy (), CallingConvention, serialization);
+ RuntimeParameterInfo.FormatParameters (sbName, GetParametersNoCopy (), CallingConvention);
sbName.Append(")");
return sbName.ToString();
public override String ToString()
{
- return ReturnType.FormatTypeName() + " " + FormatNameAndSig(false);
+ return ReturnType.FormatTypeName() + " " + FormatNameAndSig();
}
internal RuntimeModule GetRuntimeModule ()
sbName.Append ("Void ");
sbName.Append("(");
- RuntimeParameterInfo.FormatParameters (sbName, GetParametersNoCopy (), CallingConvention, false);
+ RuntimeParameterInfo.FormatParameters (sbName, GetParametersNoCopy (), CallingConvention);
sbName.Append(")");
return sbName.ToString();
this.marshalAs = marshalAs;
}
- internal static void FormatParameters (StringBuilder sb, ParameterInfo[] p, CallingConventions callingConvention, bool serialization)
+ internal static void FormatParameters (StringBuilder sb, ParameterInfo[] p, CallingConventions callingConvention)
{
for (int i = 0; i < p.Length; ++i) {
if (i > 0)
Type t = p[i].ParameterType;
- string typeName = t.FormatTypeName (serialization);
+ string typeName = t.FormatTypeName ();
// Legacy: Why use "ByRef" for by ref parameters? What language is this?
// VB uses "ByRef" but it should precede (not follow) the parameter name.
// Why don't we just use "&"?
- if (t.IsByRef && !serialization) {
+ if (t.IsByRef) {
sb.Append (typeName.TrimEnd (new char[] { '&' }));
sb.Append (" ByRef");
} else {
#region Object Overrides
public override String ToString()
{
- return FormatNameAndSig(false);
+ return FormatNameAndSig();
}
- private string FormatNameAndSig(bool serialization)
+ private string FormatNameAndSig()
{
- StringBuilder sbName = new StringBuilder(PropertyType.FormatTypeName(serialization));
+ StringBuilder sbName = new StringBuilder(PropertyType.FormatTypeName());
sbName.Append(" ");
sbName.Append(Name);
var pi = GetIndexParameters ();
if (pi.Length > 0) {
sbName.Append (" [");
- RuntimeParameterInfo.FormatParameters (sbName, pi, 0, serialization);
+ RuntimeParameterInfo.FormatParameters (sbName, pi, 0);
sbName.Append ("]");
}
return !object.ReferenceEquals(left, right);
}
- #region MemberInfo Overrides
-
- // This is used by the ToString() overrides of all reflection types. The legacy behavior has the following problems:
- // 1. Use only Name for nested types, which can be confused with global types and generic parameters of the same name.
- // 2. Use only Name for generic parameters, which can be confused with nested types and global types of the same name.
- // 3. Remove the namespace ("System") for all primitive types, which is not language neutral.
- // 4. MethodBase.ToString() use "ByRef" for byref parameters which is different than Type.ToString().
- // 5. ConstructorInfo.ToString() outputs "Void" as the return type. Why Void?
- // Since it could be a breaking changes to fix these legacy behaviors, we only use the better and more unambiguous format
- // in serialization (MemberInfoSerializationHolder).
- internal override string FormatTypeName(bool serialization)
- {
- if (serialization)
- {
- return GetCachedName(TypeNameKind.SerializationName);
- }
- else
- {
- Type elementType = GetRootElementType();
-
- // Legacy: this doesn't make sense, why use only Name for nested types but otherwise
- // ToString() which contains namespace.
- if (elementType.IsNested)
- return Name;
-
- string typeName = ToString();
-
- // Legacy: why removing "System"? Is it just because C# has keywords for these types?
- // If so why don't we change it to lower case to match the C# keyword casing?
- if (elementType.IsPrimitive ||
- elementType == typeof(void) ||
- elementType == typeof(TypedReference))
- {
- typeName = typeName.Substring(@"System.".Length);
- }
-
- return typeName;
- }
- }
-
- #endregion
-
#region Legacy Internal
private void CreateInstanceCheckThis()
{
public static Type GetTypeFromProgID (string progID, string? server, bool throwOnError) => throw new PlatformNotSupportedException ();
- internal string FormatTypeName ()
- {
- return FormatTypeName (false);
- }
-
- internal virtual string FormatTypeName (bool serialization)
- {
- throw new NotImplementedException ();
- }
-
internal virtual Type InternalResolve ()
{
return UnderlyingSystemType;