Skip to content

Commit

Permalink
Improve tooltips for partially corrupted metadata members
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Oct 30, 2024
1 parent f955c38 commit cf10ad9
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions dnSpy/dnSpy.Decompiler/CSharp/CSharpFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cf10ad9

Please sign in to comment.