From e2e952a9be85c57eed8c70d7315281a6724b7049 Mon Sep 17 00:00:00 2001 From: Ed Harvey Date: Wed, 8 Jun 2016 22:42:38 +1000 Subject: [PATCH] Node text for cs/vb constructors use type name rather than .ctor/,cctor --- ILSpy/Images/OverlayStatic.png | Bin 315 -> 347 bytes ILSpy/Languages/CSharpLanguage.cs | 10 +++++++++- ILSpy/Languages/Language.cs | 9 ++++++++- ILSpy/TreeNodes/MethodTreeNode.cs | 4 ++-- ILSpy/VB/VBLanguage.cs | 10 +++++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ILSpy/Images/OverlayStatic.png b/ILSpy/Images/OverlayStatic.png index d079a1107c8e1bca81a2968c46f5ba1d4dcb74a6..1a0e5e9d44f576b710ac23ea83820b3b25972871 100644 GIT binary patch delta 299 zcmV+`0o4Ax0^0(RB#|)~f5HF&4#EKyC`y0;0004M{gIMfByHs{=)zNE<6AI zmn+?UfysYfI8+G%;5D<~ZNixkAkEG|%|0jp{}(CW_ngUXN-9(Z0pLEhNULPq1(;^> z8FxQ&r)@aI>@+C=s)7J;oT1DYxuA+ab_5&3Z0k4U_L<{s)7h$*Qv^2 x(;dNJ*`CH=(;2{EAzCj1l^F%2fB;}%0017|RN`QCqQ?LL002ovPDHLkV1h7Kg(Cm} delta 264 zcmcc3w3}&y3KwH>kh>GZx^prwCn`$UA7)_SJIr`Ie?gTe~DWM4f%yMzW diff --git a/ILSpy/Languages/CSharpLanguage.cs b/ILSpy/Languages/CSharpLanguage.cs index 9b4f187ab..15e0daaba 100644 --- a/ILSpy/Languages/CSharpLanguage.cs +++ b/ILSpy/Languages/CSharpLanguage.cs @@ -585,7 +585,15 @@ namespace ICSharpCode.ILSpy } else return property.Name; } - + + public override string FormatMethodName(MethodDefinition method) + { + if (method == null) + throw new ArgumentNullException("method"); + + return (method.IsConstructor) ? method.DeclaringType.Name : method.Name; + } + public override string FormatTypeName(TypeDefinition type) { if (type == null) diff --git a/ILSpy/Languages/Language.cs b/ILSpy/Languages/Language.cs index dc169f81e..467bc8bec 100644 --- a/ILSpy/Languages/Language.cs +++ b/ILSpy/Languages/Language.cs @@ -138,7 +138,14 @@ namespace ICSharpCode.ILSpy throw new ArgumentNullException("property"); return property.Name; } - + + public virtual string FormatMethodName(MethodDefinition method) + { + if (method == null) + throw new ArgumentNullException("method"); + return method.Name; + } + public virtual string FormatTypeName(TypeDefinition type) { if (type == null) diff --git a/ILSpy/TreeNodes/MethodTreeNode.cs b/ILSpy/TreeNodes/MethodTreeNode.cs index d6b33bcb5..19cdb6586 100644 --- a/ILSpy/TreeNodes/MethodTreeNode.cs +++ b/ILSpy/TreeNodes/MethodTreeNode.cs @@ -69,7 +69,7 @@ namespace ICSharpCode.ILSpy.TreeNodes b.Append(") : "); b.Append(language.TypeToString(method.ReturnType, false, method.MethodReturnType)); b.Append(method.MetadataToken.ToSuffixString()); - return HighlightSearchMatch(method.Name, b.ToString()); + return HighlightSearchMatch(language.FormatMethodName(method), b.ToString()); } public override object Icon @@ -93,7 +93,7 @@ namespace ICSharpCode.ILSpy.TreeNodes if (method.IsSpecialName && (method.Name == ".ctor" || method.Name == ".cctor")) { - return Images.GetIcon(MemberIcon.Constructor, GetOverlayIcon(method.Attributes), false); + return Images.GetIcon(MemberIcon.Constructor, GetOverlayIcon(method.Attributes), method.IsStatic); } if (method.HasPInvokeInfo) diff --git a/ILSpy/VB/VBLanguage.cs b/ILSpy/VB/VBLanguage.cs index 949b369cc..246dbd375 100644 --- a/ILSpy/VB/VBLanguage.cs +++ b/ILSpy/VB/VBLanguage.cs @@ -401,7 +401,15 @@ namespace ICSharpCode.ILSpy.VB Settings = settings }); } - + + public override string FormatMethodName(MethodDefinition method) + { + if (method == null) + throw new ArgumentNullException("method"); + + return (method.IsConstructor) ? method.DeclaringType.Name : method.Name; + } + public override string FormatTypeName(TypeDefinition type) { if (type == null)