Skip to content

make sure types that implement DebuggerDisplay override ToString sinc… #4002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Nest/CommonAbstractions/Infer/Field/Field.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public Field(PropertyInfo property, double? boost = null, string format = null)
+ $"{(!string.IsNullOrEmpty(Format) ? " format: " + Format : string.Empty)}"
+ $"{(_type == null ? string.Empty : " typeof: " + _type.Name)}";

public override string ToString() => DebugDisplay;

private string PropertyDebug => Property == null ? null : $"PropertyInfo: {Property.Name}";

public bool Equals(Field other) => _type != null
Expand Down
2 changes: 2 additions & 0 deletions src/Nest/CommonAbstractions/Infer/Fields/Fields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class Fields : IUrlParameter, IEnumerable<Field>, IEquatable<Fields>

private string DebugDisplay =>
$"Count: {ListOfFields.Count} [" + string.Join(",", ListOfFields.Select((t, i) => $"({i + 1}: {t?.DebugDisplay ?? "NULL"})")) + "]";

public override string ToString() => DebugDisplay;

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

Expand Down
2 changes: 1 addition & 1 deletion src/Nest/CommonAbstractions/Infer/Id/Id.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ string IUrlParameter.GetString(IConnectionConfigurationValues settings)

public static Id From<T>(T document) where T : class => new Id(document);

public override string ToString() => StringOrLongValue;
public override string ToString() => DebugDisplay;

public override bool Equals(object obj)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Nest/CommonAbstractions/Infer/Id/Ids.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public Ids(string value)

private string DebugDisplay => ((IUrlParameter)this).GetString(null);

public override string ToString() => DebugDisplay;

public bool Equals(Ids other)
{
if (other == null) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Nest/CommonAbstractions/Infer/IndexName/IndexName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private IndexName(string index, Type type, string cluster = null)
public Type Type { get; }

internal string DebugDisplay => Type == null ? Name : $"{nameof(IndexName)} for typeof: {Type?.Name}";

private static int TypeHashCode { get; } = typeof(IndexName).GetHashCode();

bool IEquatable<IndexName>.Equals(IndexName other) => EqualsMarker(other);
Expand Down
2 changes: 2 additions & 0 deletions src/Nest/CommonAbstractions/Infer/Indices/Indices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ internal Indices(IEnumerable<IndexName> indices) : base(new ManyIndices(indices)
types => $"Count: {types.Indices.Count} [" + string.Join(",", types.Indices.Select((t, i) => $"({i + 1}: {t.DebugDisplay})")) + "]"
);

public override string ToString() => DebugDisplay;

string IUrlParameter.GetString(IConnectionConfigurationValues settings) => Match(
all => "_all",
many =>
Expand Down
2 changes: 2 additions & 0 deletions src/Nest/CommonAbstractions/Infer/JoinFieldRouting/Routing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public Routing(object document)

private string DebugDisplay => StringOrLongValue ?? "Routing from instance typeof: " + Document?.GetType().Name;

public override string ToString() => DebugDisplay;

private static int TypeHashCode { get; } = typeof(Routing).GetHashCode();

public bool Equals(Routing other)
Expand Down
2 changes: 2 additions & 0 deletions src/Nest/CommonAbstractions/Infer/Name/Name.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class Name : IEquatable<Name>, IUrlParameter

private string DebugDisplay => Value;

public override string ToString() => DebugDisplay;

private static int TypeHashCode { get; } = typeof(Name).GetHashCode();

public bool Equals(Name other) => EqualsString(other?.Value);
Expand Down
2 changes: 2 additions & 0 deletions src/Nest/CommonAbstractions/Infer/Name/Names.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public Names(IEnumerable<Name> names)

private string DebugDisplay => ((IUrlParameter)this).GetString(null);

public override string ToString() => DebugDisplay;

public bool Equals(Names other) => EqualsAllIds(Value, other.Value);

string IUrlParameter.GetString(IConnectionConfigurationValues settings) =>
Expand Down
2 changes: 2 additions & 0 deletions src/Nest/CommonAbstractions/Infer/NodeId/NodeIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public NodeIds(IEnumerable<string> nodeIds)

private string DebugDisplay => ((IUrlParameter)this).GetString(null);

public override string ToString() => DebugDisplay;

public bool Equals(NodeIds other) => EqualsAllIds(Value, other.Value);

string IUrlParameter.GetString(IConnectionConfigurationValues settings) => string.Join(",", Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public PropertyName(PropertyInfo property)
internal string DebugDisplay =>
$"{Expression?.ToString() ?? PropertyDebug ?? Name}{(_type == null ? "" : " typeof: " + _type.Name)}";

public override string ToString() => DebugDisplay;

private string PropertyDebug => Property == null ? null : $"PropertyInfo: {Property.Name}";
private static int TypeHashCode { get; } = typeof(PropertyName).GetHashCode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ public bool EqualsMarker(RelationName other)

private bool EqualsString(string other) => !other.IsNullOrEmpty() && other == Name;

public override string ToString()
{
if (!Name.IsNullOrEmpty()) return Name;
public override string ToString() => DebugDisplay;

return Type != null ? Type.Name : string.Empty;
}
}
}
2 changes: 2 additions & 0 deletions src/Nest/Mapping/Types/PropertyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public abstract class PropertyBase : IProperty, IPropertyWithClrOrigin
public PropertyName Name { get; set; }

protected string DebugDisplay => $"Type: {((IProperty)this).Type ?? "<empty>"}, Name: {Name.DebugDisplay} ";

public override string ToString() => DebugDisplay;

/// <summary>
/// Override for the property type, used for custom mappings
Expand Down