Browse Source

do not use primitive type names in TreeNodes; fixes #183

pull/143/merge
Siegfried Pammer 15 years ago
parent
commit
111a6ca292
  1. 6
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. 14
      ILSpy/CSharpLanguage.cs
  3. 7
      ILSpy/Language.cs
  4. 2
      ILSpy/TreeNodes/TypeTreeNode.cs

6
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -28,7 +28,8 @@ namespace ICSharpCode.Decompiler.Ast @@ -28,7 +28,8 @@ namespace ICSharpCode.Decompiler.Ast
{
None = 0,
IncludeNamespace = 1,
IncludeTypeParameterDefinitions = 2
IncludeTypeParameterDefinitions = 2,
DoNotUsePrimitiveTypeNames = 4
}
public class AstBuilder : ICodeMappings
@ -462,6 +463,8 @@ namespace ICSharpCode.Decompiler.Ast @@ -462,6 +463,8 @@ namespace ICSharpCode.Decompiler.Ast
return new PrimitiveType("dynamic");
} else {
if (ns == "System") {
if ((options & ConvertTypeOptions.DoNotUsePrimitiveTypeNames)
!= ConvertTypeOptions.DoNotUsePrimitiveTypeNames) {
switch (name) {
case "SByte":
return new PrimitiveType("sbyte");
@ -497,6 +500,7 @@ namespace ICSharpCode.Decompiler.Ast @@ -497,6 +500,7 @@ namespace ICSharpCode.Decompiler.Ast
return new PrimitiveType("object");
}
}
}
name = ICSharpCode.NRefactory.TypeSystem.ReflectionHelper.SplitTypeParameterCountFromReflectionName(name);

14
ILSpy/CSharpLanguage.cs

@ -508,6 +508,12 @@ namespace ICSharpCode.ILSpy @@ -508,6 +508,12 @@ namespace ICSharpCode.ILSpy
ConvertTypeOptions options = ConvertTypeOptions.IncludeTypeParameterDefinitions;
if (includeNamespace)
options |= ConvertTypeOptions.IncludeNamespace;
return TypeToString(options, type, typeAttributes);
}
string TypeToString(ConvertTypeOptions options, TypeReference type, ICustomAttributeProvider typeAttributes = null)
{
AstType astType = AstBuilder.ConvertType(type, typeAttributes, options);
StringWriter w = new StringWriter();
@ -557,6 +563,14 @@ namespace ICSharpCode.ILSpy @@ -557,6 +563,14 @@ namespace ICSharpCode.ILSpy
return property.Name;
}
public override string FormatTypeName(TypeDefinition type)
{
if (type == null)
throw new ArgumentNullException("type");
return TypeToString(ConvertTypeOptions.DoNotUsePrimitiveTypeNames | ConvertTypeOptions.IncludeTypeParameterDefinitions, type);
}
public override bool ShowMember(MemberReference member)
{
return showAllMembers || !AstBuilder.MemberIsHidden(member, new DecompilationOptions().DecompilerSettings);

7
ILSpy/Language.cs

@ -128,6 +128,13 @@ namespace ICSharpCode.ILSpy @@ -128,6 +128,13 @@ namespace ICSharpCode.ILSpy
return property.Name;
}
public virtual string FormatTypeName(TypeDefinition type)
{
if (type == null)
throw new ArgumentNullException("type");
return type.Name;
}
/// <summary>
/// Used for WPF keyboard navigation.
/// </summary>

2
ILSpy/TreeNodes/TypeTreeNode.cs

@ -59,7 +59,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -59,7 +59,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
public override object Text {
get { return HighlightSearchMatch(this.Language.TypeToString(type, includeNamespace: false)); }
get { return HighlightSearchMatch(this.Language.FormatTypeName(type)); }
}
public bool IsPublicAPI {

Loading…
Cancel
Save