Browse Source

Add includeNamespaceOfDeclaringTypeName to ToString methods in Language.

pull/1213/head
Siegfried Pammer 8 years ago
parent
commit
1ff5353907
  1. 2
      ILSpy/Analyzers/TreeNodes/AnalyzedEventTreeNode.cs
  2. 2
      ILSpy/Analyzers/TreeNodes/AnalyzedFieldTreeNode.cs
  3. 2
      ILSpy/Analyzers/TreeNodes/AnalyzedMethodTreeNode.cs
  4. 2
      ILSpy/Analyzers/TreeNodes/AnalyzedPropertyTreeNode.cs
  5. 26
      ILSpy/Languages/CSharpLanguage.cs
  6. 24
      ILSpy/Languages/Language.cs
  7. 8
      ILSpy/Search/AbstractSearchStrategy.cs
  8. 2
      ILSpy/TreeNodes/EventTreeNode.cs
  9. 2
      ILSpy/TreeNodes/FieldTreeNode.cs
  10. 2
      ILSpy/TreeNodes/MethodTreeNode.cs
  11. 2
      ILSpy/TreeNodes/PropertyTreeNode.cs

2
ILSpy/Analyzers/TreeNodes/AnalyzedEventTreeNode.cs

@ -40,7 +40,7 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes @@ -40,7 +40,7 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
public override object Icon => EventTreeNode.GetIcon(analyzedEvent);
// TODO: This way of formatting is not suitable for events which explicitly implement interfaces.
public override object Text => prefix + Language.EventToString(analyzedEvent, includeTypeName: true, includeNamespace: true);
public override object Text => prefix + Language.EventToString(analyzedEvent, includeDeclaringTypeName: true, includeNamespace: false, includeNamespaceOfDeclaringTypeName: true);
protected override void LoadChildren()
{

2
ILSpy/Analyzers/TreeNodes/AnalyzedFieldTreeNode.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes @@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
public override object Icon => FieldTreeNode.GetIcon(analyzedField);
public override object Text => Language.FieldToString(analyzedField, true, true);
public override object Text => Language.FieldToString(analyzedField, true, false, true);
protected override void LoadChildren()
{

2
ILSpy/Analyzers/TreeNodes/AnalyzedMethodTreeNode.cs

@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes @@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
public override object Icon => MethodTreeNode.GetIcon(analyzedMethod);
public override object Text => prefix + Language.MethodToString(analyzedMethod, true, true);
public override object Text => prefix + Language.MethodToString(analyzedMethod, true, false, true);
protected override void LoadChildren()
{

2
ILSpy/Analyzers/TreeNodes/AnalyzedPropertyTreeNode.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes @@ -37,7 +37,7 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
public override object Icon => PropertyTreeNode.GetIcon(analyzedProperty);
// TODO: This way of formatting is not suitable for properties which explicitly implement interfaces.
public override object Text => prefix + Language.PropertyToString(analyzedProperty, includeNamespace: true, includeTypeName: true);
public override object Text => prefix + Language.PropertyToString(analyzedProperty, includeNamespace: false, includeDeclaringTypeName: true, includeNamespaceOfDeclaringTypeName: true);
protected override void LoadChildren()
{

26
ILSpy/Languages/CSharpLanguage.cs

@ -450,18 +450,18 @@ namespace ICSharpCode.ILSpy @@ -450,18 +450,18 @@ namespace ICSharpCode.ILSpy
return output;
}
public override string FieldToString(IField field, bool includeTypeName, bool includeNamespace)
public override string FieldToString(IField field, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (field == null)
throw new ArgumentNullException(nameof(field));
string simple = field.Name + " : " + TypeToString(field.Type, includeNamespace);
if (!includeTypeName)
if (!includeDeclaringTypeName)
return simple;
return TypeToStringInternal(field.DeclaringTypeDefinition, includeNamespace) + "." + simple;
return TypeToStringInternal(field.DeclaringTypeDefinition, includeNamespaceOfDeclaringTypeName) + "." + simple;
}
public override string PropertyToString(IProperty property, bool includeTypeName, bool includeNamespace)
public override string PropertyToString(IProperty property, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (property == null)
throw new ArgumentNullException(nameof(property));
@ -492,21 +492,21 @@ namespace ICSharpCode.ILSpy @@ -492,21 +492,21 @@ namespace ICSharpCode.ILSpy
}
buffer.Append(" : ");
buffer.Append(TypeToStringInternal(property.ReturnType, includeNamespace));
if (!includeTypeName)
if (!includeDeclaringTypeName)
return buffer.ToString();
return TypeToString(property.DeclaringTypeDefinition, includeNamespace) + "." + buffer.ToString();
return TypeToString(property.DeclaringTypeDefinition, includeNamespaceOfDeclaringTypeName) + "." + buffer.ToString();
}
public override string MethodToString(IMethod method, bool includeTypeName, bool includeNamespace)
public override string MethodToString(IMethod method, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (method == null)
throw new ArgumentNullException(nameof(method));
string name;
if (method.IsConstructor) {
name = TypeToString(method.DeclaringTypeDefinition, includeNamespace: includeNamespace);
name = TypeToString(method.DeclaringTypeDefinition, includeNamespace: includeNamespaceOfDeclaringTypeName);
} else {
if (includeTypeName) {
name = TypeToString(method.DeclaringTypeDefinition, includeNamespace: includeNamespace) + ".";
if (includeDeclaringTypeName) {
name = TypeToString(method.DeclaringTypeDefinition, includeNamespace: includeNamespaceOfDeclaringTypeName) + ".";
} else {
name = "";
}
@ -542,13 +542,13 @@ namespace ICSharpCode.ILSpy @@ -542,13 +542,13 @@ namespace ICSharpCode.ILSpy
return buffer.ToString();
}
public override string EventToString(IEvent @event, bool includeTypeName, bool includeNamespace)
public override string EventToString(IEvent @event, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (@event == null)
throw new ArgumentNullException(nameof(@event));
var buffer = new System.Text.StringBuilder();
if (includeTypeName) {
buffer.Append(TypeToString(@event.DeclaringTypeDefinition, includeNamespace) + ".");
if (includeDeclaringTypeName) {
buffer.Append(TypeToString(@event.DeclaringTypeDefinition, includeNamespaceOfDeclaringTypeName) + ".");
}
buffer.Append(@event.Name);
buffer.Append(" : ");

24
ILSpy/Languages/Language.cs

@ -174,31 +174,31 @@ namespace ICSharpCode.ILSpy @@ -174,31 +174,31 @@ namespace ICSharpCode.ILSpy
/// </summary>
public virtual string GetTooltip(IEntity entity)
{
return GetDisplayName(entity, true, true);
return GetDisplayName(entity, true, true, true);
}
public virtual string FieldToString(IField field, bool includeTypeName, bool includeNamespace)
public virtual string FieldToString(IField field, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (field == null)
throw new ArgumentNullException(nameof(field));
return GetDisplayName(field, includeTypeName, includeNamespace) + " : " + TypeToString(field.ReturnType, includeNamespace);
return GetDisplayName(field, includeDeclaringTypeName, includeNamespace, includeNamespaceOfDeclaringTypeName) + " : " + TypeToString(field.ReturnType, includeNamespace);
}
public virtual string PropertyToString(IProperty property, bool includeTypeName, bool includeNamespace)
public virtual string PropertyToString(IProperty property, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (property == null)
throw new ArgumentNullException(nameof(property));
return GetDisplayName(property, includeTypeName, includeNamespace) + " : " + TypeToString(property.ReturnType, includeNamespace);
return GetDisplayName(property, includeDeclaringTypeName, includeNamespace, includeNamespaceOfDeclaringTypeName) + " : " + TypeToString(property.ReturnType, includeNamespace);
}
public virtual string MethodToString(IMethod method, bool includeTypeName, bool includeNamespace)
public virtual string MethodToString(IMethod method, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (method == null)
throw new ArgumentNullException(nameof(method));
int i = 0;
var buffer = new System.Text.StringBuilder();
buffer.Append(GetDisplayName(method, includeTypeName, includeNamespace));
buffer.Append(GetDisplayName(method, includeDeclaringTypeName, includeNamespace, includeNamespaceOfDeclaringTypeName));
var typeParameters = method.TypeParameters;
if (typeParameters.Count > 0) {
buffer.Append('<');
@ -226,22 +226,22 @@ namespace ICSharpCode.ILSpy @@ -226,22 +226,22 @@ namespace ICSharpCode.ILSpy
return buffer.ToString();
}
public virtual string EventToString(IEvent @event, bool includeTypeName, bool includeNamespace)
public virtual string EventToString(IEvent @event, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (@event == null)
throw new ArgumentNullException(nameof(@event));
var buffer = new System.Text.StringBuilder();
buffer.Append(GetDisplayName(@event, includeTypeName, includeNamespace));
buffer.Append(GetDisplayName(@event, includeDeclaringTypeName, includeNamespace, includeNamespaceOfDeclaringTypeName));
buffer.Append(" : ");
buffer.Append(TypeToString(@event.ReturnType, includeNamespace));
return buffer.ToString();
}
protected string GetDisplayName(IEntity entity, bool includeTypeName, bool includeNamespace)
protected string GetDisplayName(IEntity entity, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (includeTypeName && entity.DeclaringTypeDefinition != null) {
if (includeDeclaringTypeName && entity.DeclaringTypeDefinition != null) {
string name;
if (includeNamespace) {
if (includeNamespaceOfDeclaringTypeName) {
name = entity.DeclaringTypeDefinition.FullName;
} else {
name = entity.DeclaringTypeDefinition.Name;

8
ILSpy/Search/AbstractSearchStrategy.cs

@ -138,13 +138,13 @@ namespace ICSharpCode.ILSpy.Search @@ -138,13 +138,13 @@ namespace ICSharpCode.ILSpy.Search
case ITypeDefinition t:
return language.TypeToString(t, false);
case IField f:
return language.FieldToString(f, true, false);
return language.FieldToString(f, true, false, false);
case IProperty p:
return language.PropertyToString(p, true, false);
return language.PropertyToString(p, true, false, false);
case IMethod m:
return language.MethodToString(m, true, false);
return language.MethodToString(m, true, false, false);
case IEvent e:
return language.EventToString(e, true, false);
return language.EventToString(e, true, false, false);
default:
throw new NotSupportedException(member?.GetType() + " not supported!");
}

2
ILSpy/TreeNodes/EventTreeNode.cs

@ -47,7 +47,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -47,7 +47,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
public static object GetText(IEvent ev, Language language)
{
return language.EventToString(ev, false, false);
return language.EventToString(ev, false, false, false);
}
public override object Icon => GetIcon(EventDefinition);

2
ILSpy/TreeNodes/FieldTreeNode.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -39,7 +39,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
public static object GetText(IField field, Language language)
{
return language.FieldToString(field, includeTypeName: false, includeNamespace: false);
return language.FieldToString(field, includeDeclaringTypeName: false, includeNamespace: false, includeNamespaceOfDeclaringTypeName: false);
}
public override object Icon => GetIcon(FieldDefinition);

2
ILSpy/TreeNodes/MethodTreeNode.cs

@ -40,7 +40,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -40,7 +40,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
public static object GetText(IMethod method, Language language)
{
return language.MethodToString(method, false, false);
return language.MethodToString(method, false, false, false);
}
public override object Icon => GetIcon(MethodDefinition);

2
ILSpy/TreeNodes/PropertyTreeNode.cs

@ -53,7 +53,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -53,7 +53,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
public static object GetText(IProperty property, Language language)
{
return language.PropertyToString(property, false, false);
return language.PropertyToString(property, false, false, false);
}
public override object Icon => GetIcon(PropertyDefinition);

Loading…
Cancel
Save