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
{
[DebuggerDisplay("{DisplayName,nq}")]
public abstract class AllowedChildTagDescriptor : IEquatable<AllowedChildTagDescriptor>
{
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)
{
return AllowedChildTagDescriptorComparer.Default.Equals(this, other);

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Microsoft.AspNetCore.Razor.Language
@ -11,7 +10,6 @@ namespace Microsoft.AspNetCore.Razor.Language
/// <summary>
/// A metadata class describing a tag helper attribute.
/// </summary>
[DebuggerDisplay("{DisplayName,nq}")]
public abstract class BoundAttributeDescriptor : IEquatable<BoundAttributeDescriptor>
{
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)
{
return BoundAttributeDescriptorComparer.Default.Equals(this, other);

View File

@ -8,7 +8,7 @@ using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Razor.Language.Legacy
{
[DebuggerDisplay("({Location})\"{Value}\"")]
[DebuggerDisplay("{" + nameof(DebuggerToString) + "(),nq}")]
internal class LocationTagged<TValue> : IFormattable
{
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;
}
private string DebuggerToString()
{
return $@"({Location})""{Value}""";
}
}
}

View File

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

View File

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

View File

@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language
/// <summary>
/// An item in <see cref="RazorProject"/>.
/// </summary>
[DebuggerDisplay("{CombinedPath}")]
[DebuggerDisplay("{" + nameof(DebuggerToString) + "()}")]
public abstract class RazorProjectItem
{
/// <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.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Microsoft.AspNetCore.Razor.Language
{
[DebuggerDisplay("{DisplayName,nq}")]
public abstract class RequiredAttributeDescriptor : IEquatable<RequiredAttributeDescriptor>
{
public string Name { get; protected set; }
@ -32,7 +30,12 @@ namespace Microsoft.AspNetCore.Razor.Language
return errors;
}
}
public override string ToString()
{
return DisplayName ?? base.ToString();
}
public bool Equals(RequiredAttributeDescriptor other)
{
return RequiredAttributeDescriptorComparer.Default.Equals(this, other);

View File

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

View File

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