diff options
author | Siegfried Pammer <siegfriedpammer@gmail.com> | 2016-06-18 01:15:15 +0300 |
---|---|---|
committer | Siegfried Pammer <siegfriedpammer@gmail.com> | 2016-06-18 01:15:15 +0300 |
commit | 2d6d964fcdd8854451779f994bf3271d2896d6be (patch) | |
tree | c8e2fd750288d739c6d03bfeec9cbb9eb295c314 | |
parent | 2a744ce793cb8c670f4d6340b74ab95e8dfedcc0 (diff) |
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.
-rw-r--r-- | ICSharpCode.NRefactory.Cecil/CecilLoader.cs | 38 |
1 files 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 /// <c>true</c> if this instance has references to the cecil objects; otherwise, <c>false</c>. /// </value> public bool HasCecilReferences { get { return typeSystemTranslationTable != null; } } + + bool shortenInterfaceImplNames = true; + + /// <summary> + /// Specifies whether method names of explicit interface-implementations should be shortened. + /// </summary> + /// <remarks>This is important when working with parser-initialized type-systems in order to be consistent.</remarks> + 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())); + } } } |