From 2d6d964fcdd8854451779f994bf3271d2896d6be Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 18 Jun 2016 07:15:15 +0900 Subject: Add new mode for ILSpy to CecilLoader: explicit interface implementations use names with dots. These are normally shortened by CecilLoader to be consistent with parser-initialized type systems. The new mode allows to disable the shortening. --- ICSharpCode.NRefactory.Cecil/CecilLoader.cs | 38 +++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/ICSharpCode.NRefactory.Cecil/CecilLoader.cs b/ICSharpCode.NRefactory.Cecil/CecilLoader.cs index e3a04e7d..402c4c79 100644 --- a/ICSharpCode.NRefactory.Cecil/CecilLoader.cs +++ b/ICSharpCode.NRefactory.Cecil/CecilLoader.cs @@ -86,6 +86,21 @@ namespace ICSharpCode.NRefactory.TypeSystem /// true if this instance has references to the cecil objects; otherwise, false. /// public bool HasCecilReferences { get { return typeSystemTranslationTable != null; } } + + bool shortenInterfaceImplNames = true; + + /// + /// Specifies whether method names of explicit interface-implementations should be shortened. + /// + /// This is important when working with parser-initialized type-systems in order to be consistent. + public bool ShortenInterfaceImplNames { + get { + return shortenInterfaceImplNames; + } + set { + shortenInterfaceImplNames = value; + } + } #endregion ModuleDefinition currentModule; @@ -121,6 +136,7 @@ namespace ICSharpCode.NRefactory.TypeSystem this.IncludeInternalMembers = loader.IncludeInternalMembers; this.LazyLoad = loader.LazyLoad; this.OnEntityLoaded = loader.OnEntityLoaded; + this.ShortenInterfaceImplNames = loader.ShortenInterfaceImplNames; this.currentModule = loader.currentModule; this.currentAssembly = loader.currentAssembly; // don't use interning - the interning provider is most likely not thread-safe @@ -1367,16 +1383,18 @@ namespace ICSharpCode.NRefactory.TypeSystem m.IsExtensionMethod = true; } - int lastDot = method.Name.LastIndexOf('.'); - if (lastDot >= 0 && method.HasOverrides) { - // To be consistent with the parser-initialized type system, shorten the method name: - m.Name = method.Name.Substring(lastDot + 1); - m.IsExplicitInterfaceImplementation = true; - foreach (var or in method.Overrides) { - m.ExplicitInterfaceImplementations.Add(new DefaultMemberReference( - accessorOwner != null ? SymbolKind.Accessor : SymbolKind.Method, - ReadTypeReference(or.DeclaringType), - or.Name, or.GenericParameters.Count, m.Parameters.Select(p => p.Type).ToList())); + if (ShortenInterfaceImplNames) { + int lastDot = method.Name.LastIndexOf('.'); + if (lastDot >= 0 && method.HasOverrides) { + // To be consistent with the parser-initialized type system, shorten the method name: + m.Name = method.Name.Substring(lastDot + 1); + m.IsExplicitInterfaceImplementation = true; + foreach (var or in method.Overrides) { + m.ExplicitInterfaceImplementations.Add(new DefaultMemberReference( + accessorOwner != null ? SymbolKind.Accessor : SymbolKind.Method, + ReadTypeReference(or.DeclaringType), + or.Name, or.GenericParameters.Count, m.Parameters.Select(p => p.Type).ToList())); + } } } -- cgit v1.2.3