Fixed DebuggerDisplay in DefaultTagHelperContent

- Also refactored it in few other places
This commit is contained in:
Ajay Bhargav Baaskaran 2017-07-31 16:31:45 -07:00
parent 31e9710186
commit ce689b0449
9 changed files with 52 additions and 14 deletions

View File

@ -8,7 +8,6 @@ using System.Linq;
namespace Microsoft.AspNetCore.Razor.Language namespace Microsoft.AspNetCore.Razor.Language
{ {
[DebuggerDisplay("{DisplayName,nq}")]
public abstract class AllowedChildTagDescriptor : IEquatable<AllowedChildTagDescriptor> public abstract class AllowedChildTagDescriptor : IEquatable<AllowedChildTagDescriptor>
{ {
public string Name { get; protected set; } public string Name { get; protected set; }
@ -27,6 +26,11 @@ namespace Microsoft.AspNetCore.Razor.Language
} }
} }
public override string ToString()
{
return DisplayName ?? base.ToString();
}
public bool Equals(AllowedChildTagDescriptor other) public bool Equals(AllowedChildTagDescriptor other)
{ {
return AllowedChildTagDescriptorComparer.Default.Equals(this, other); return AllowedChildTagDescriptorComparer.Default.Equals(this, other);

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
namespace Microsoft.AspNetCore.Razor.Language namespace Microsoft.AspNetCore.Razor.Language
@ -11,7 +10,6 @@ namespace Microsoft.AspNetCore.Razor.Language
/// <summary> /// <summary>
/// A metadata class describing a tag helper attribute. /// A metadata class describing a tag helper attribute.
/// </summary> /// </summary>
[DebuggerDisplay("{DisplayName,nq}")]
public abstract class BoundAttributeDescriptor : IEquatable<BoundAttributeDescriptor> public abstract class BoundAttributeDescriptor : IEquatable<BoundAttributeDescriptor>
{ {
protected BoundAttributeDescriptor(string kind) protected BoundAttributeDescriptor(string kind)
@ -55,6 +53,11 @@ namespace Microsoft.AspNetCore.Razor.Language
} }
} }
public override string ToString()
{
return DisplayName ?? base.ToString();
}
public bool Equals(BoundAttributeDescriptor other) public bool Equals(BoundAttributeDescriptor other)
{ {
return BoundAttributeDescriptorComparer.Default.Equals(this, other); return BoundAttributeDescriptorComparer.Default.Equals(this, other);

View File

@ -8,7 +8,7 @@ using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Razor.Language.Legacy namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
[DebuggerDisplay("({Location})\"{Value}\"")] [DebuggerDisplay("{" + nameof(DebuggerToString) + "(),nq}")]
internal class LocationTagged<TValue> : IFormattable internal class LocationTagged<TValue> : IFormattable
{ {
public LocationTagged(TValue value, int absoluteIndex, int lineIndex, int characterIndex) public LocationTagged(TValue value, int absoluteIndex, int lineIndex, int characterIndex)
@ -80,5 +80,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
return value == null ? default(TValue) : value.Value; return value == null ? default(TValue) : value.Value;
} }
private string DebuggerToString()
{
return $@"({Location})""{Value}""";
}
} }
} }

View File

@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
// Debug Helpers // Debug Helpers
#if DEBUG #if DEBUG
[DebuggerDisplay("{Unparsed}")] [DebuggerDisplay("{" + nameof(DebuggerToString) + "(),nq}")]
internal partial class ParserContext internal partial class ParserContext
{ {
private const int InfiniteLoopCountThreshold = 1000; private const int InfiniteLoopCountThreshold = 1000;
@ -98,6 +98,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
_infiniteLoopGuardLocation = Source.Location; _infiniteLoopGuardLocation = Source.Location;
return false; return false;
} }
private string DebuggerToString()
{
return Unparsed;
}
} }
#endif #endif
} }

View File

@ -6,14 +6,14 @@ using System.Diagnostics;
namespace Microsoft.AspNetCore.Razor.Language namespace Microsoft.AspNetCore.Razor.Language
{ {
[DebuggerDisplay("Error {Id}: {GetMessageFormat()}")] [DebuggerDisplay("{" + nameof(DebuggerToString) + "(),nq}")]
public sealed class RazorDiagnosticDescriptor : IEquatable<RazorDiagnosticDescriptor> public sealed class RazorDiagnosticDescriptor : IEquatable<RazorDiagnosticDescriptor>
{ {
private readonly Func<string> _messageFormat; private readonly Func<string> _messageFormat;
public RazorDiagnosticDescriptor( public RazorDiagnosticDescriptor(
string id, string id,
Func<string> messageFormat, Func<string> messageFormat,
RazorDiagnosticSeverity severity) RazorDiagnosticSeverity severity)
{ {
if (string.IsNullOrEmpty(id)) if (string.IsNullOrEmpty(id))
@ -56,5 +56,10 @@ namespace Microsoft.AspNetCore.Razor.Language
{ {
return StringComparer.Ordinal.GetHashCode(Id); return StringComparer.Ordinal.GetHashCode(Id);
} }
private string DebuggerToString()
{
return $@"Error ""{Id}"": ""{GetMessageFormat()}""";
}
} }
} }

View File

@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language
/// <summary> /// <summary>
/// An item in <see cref="RazorProject"/>. /// An item in <see cref="RazorProject"/>.
/// </summary> /// </summary>
[DebuggerDisplay("{CombinedPath}")] [DebuggerDisplay("{" + nameof(DebuggerToString) + "()}")]
public abstract class RazorProjectItem public abstract class RazorProjectItem
{ {
/// <summary> /// <summary>
@ -105,5 +105,10 @@ namespace Microsoft.AspNetCore.Razor.Language
} }
} }
} }
private string DebuggerToString()
{
return CombinedPath;
}
} }
} }

View File

@ -3,12 +3,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
namespace Microsoft.AspNetCore.Razor.Language namespace Microsoft.AspNetCore.Razor.Language
{ {
[DebuggerDisplay("{DisplayName,nq}")]
public abstract class RequiredAttributeDescriptor : IEquatable<RequiredAttributeDescriptor> public abstract class RequiredAttributeDescriptor : IEquatable<RequiredAttributeDescriptor>
{ {
public string Name { get; protected set; } public string Name { get; protected set; }
@ -32,7 +30,12 @@ namespace Microsoft.AspNetCore.Razor.Language
return errors; return errors;
} }
} }
public override string ToString()
{
return DisplayName ?? base.ToString();
}
public bool Equals(RequiredAttributeDescriptor other) public bool Equals(RequiredAttributeDescriptor other)
{ {
return RequiredAttributeDescriptorComparer.Default.Equals(this, other); return RequiredAttributeDescriptorComparer.Default.Equals(this, other);

View File

@ -3,12 +3,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
namespace Microsoft.AspNetCore.Razor.Language namespace Microsoft.AspNetCore.Razor.Language
{ {
[DebuggerDisplay("{DisplayName,nq}")]
public abstract class TagHelperDescriptor : IEquatable<TagHelperDescriptor> public abstract class TagHelperDescriptor : IEquatable<TagHelperDescriptor>
{ {
private IEnumerable<RazorDiagnostic> _allDiagnostics; private IEnumerable<RazorDiagnostic> _allDiagnostics;
@ -68,6 +66,11 @@ namespace Microsoft.AspNetCore.Razor.Language
return _allDiagnostics; return _allDiagnostics;
} }
public override string ToString()
{
return DisplayName ?? base.ToString();
}
public bool Equals(TagHelperDescriptor other) public bool Equals(TagHelperDescriptor other)
{ {
return TagHelperDescriptorComparer.Default.Equals(this, other); return TagHelperDescriptorComparer.Default.Equals(this, other);

View File

@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
/// <summary> /// <summary>
/// Default concrete <see cref="TagHelperContent"/>. /// Default concrete <see cref="TagHelperContent"/>.
/// </summary> /// </summary>
[DebuggerDisplay("{DebuggerToString(),nq}")] [DebuggerDisplay("{" + nameof(DebuggerToString) + "(),nq}")]
public class DefaultTagHelperContent : TagHelperContent public class DefaultTagHelperContent : TagHelperContent
{ {
private object _singleContent; private object _singleContent;
@ -324,6 +324,11 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
return this; return this;
} }
private string DebuggerToString()
{
return GetContent();
}
// Overrides Write(string) to find if the content written is empty/whitespace. // Overrides Write(string) to find if the content written is empty/whitespace.
private class EmptyOrWhiteSpaceWriter : TextWriter private class EmptyOrWhiteSpaceWriter : TextWriter