diff --git a/dnSpy/dnSpy.Decompiler/CSharp/CSharpFormatter.cs b/dnSpy/dnSpy.Decompiler/CSharp/CSharpFormatter.cs index 1b9f5c7f0b..f91e3530b4 100644 --- a/dnSpy/dnSpy.Decompiler/CSharp/CSharpFormatter.cs +++ b/dnSpy/dnSpy.Decompiler/CSharp/CSharpFormatter.cs @@ -222,22 +222,22 @@ public void WriteToolTip(IMemberRef? member) { return; } - if (member is IMethod method && method.MethodSig is not null) { + if (member.IsMethod && member is IMethod method) { WriteToolTip(method); return; } - if (member is IField field && field.FieldSig is not null) { + if (member.IsField && member is IField field) { WriteToolTip(field); return; } - if (member is PropertyDef prop && prop.PropertySig is not null) { + if (member is PropertyDef prop) { WriteToolTip(prop); return; } - if (member is EventDef evt && evt.EventType is not null) { + if (member is EventDef evt) { WriteToolTip(evt); return; } @@ -261,22 +261,22 @@ public void Write(IMemberRef? member) { return; } - if (member is IMethod method && method.MethodSig is not null) { + if (member.IsMethod && member is IMethod method) { Write(method); return; } - if (member is IField field && field.FieldSig is not null) { + if (member.IsField && member is IField field) { Write(field); return; } - if (member is PropertyDef prop && prop.PropertySig is not null) { + if (member is PropertyDef prop) { Write(prop); return; } - if (member is EventDef evt && evt.EventType is not null) { + if (member is EventDef evt) { Write(evt); return; } @@ -476,18 +476,17 @@ void Write(IMethod? method) { if (info.MethodDef is not null && info.MethodDef.IsConstructor && method.DeclaringType is not null) WriteIdentifier(TypeFormatterUtils.RemoveGenericTick(method.DeclaringType.Name), CSharpMetadataTextColorProvider.Instance.GetColor(method)); else if (info.MethodDef is not null && info.MethodDef.Overrides.Count > 0) { - var ovrMeth = (IMemberRef)info.MethodDef.Overrides[0].MethodDeclaration; + var ovrMeth = info.MethodDef.Overrides[0].MethodDeclaration; WriteMethodName(method, ovrMeth.Name, operatorInfo); } else WriteMethodName(method, method.Name, operatorInfo); + + WriteToken(method); if (isExplicitOrImplicit) { - WriteToken(method); WriteSpace(); ForceWriteReturnType(info, writeSpace: false, isReadOnly: TypeFormatterUtils.IsReadOnlyMethod(info.MethodDef)); } - else - WriteToken(method); WriteGenericArguments(info); WriteMethodParameterList(info, MethodParenOpen, MethodParenClose); @@ -541,7 +540,7 @@ void Write(IField? field, bool isToolTip) { WriteSpace(); } WriteModuleName(fd?.Module); - Write(sig.Type, null, null, null, attributeProvider: fd); + Write(sig?.Type, null, null, null, attributeProvider: fd); WriteSpace(); } else