diff --git a/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs index ba2c593313..14ea34c493 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs @@ -8,7 +8,6 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language { - [DebuggerDisplay("{DisplayName,nq}")] public abstract class AllowedChildTagDescriptor : IEquatable { 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); diff --git a/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeDescriptor.cs index 2014a1336f..787ded4336 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeDescriptor.cs @@ -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 /// /// A metadata class describing a tag helper attribute. /// - [DebuggerDisplay("{DisplayName,nq}")] public abstract class BoundAttributeDescriptor : IEquatable { 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); diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/LocationTagged.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/LocationTagged.cs index ad90f96f60..a1ffeaf00b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/LocationTagged.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/LocationTagged.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - [DebuggerDisplay("({Location})\"{Value}\"")] + [DebuggerDisplay("{" + nameof(DebuggerToString) + "(),nq}")] internal class LocationTagged : 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}"""; + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserContext.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserContext.cs index 189930e4d9..6035ccc81b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserContext.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserContext.cs @@ -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 } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticDescriptor.cs index 41563c9197..6d61173768 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticDescriptor.cs @@ -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 { private readonly Func _messageFormat; public RazorDiagnosticDescriptor( string id, - Func messageFormat, + Func 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()}"""; + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs index ccb61711bc..67b0e04dfd 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language /// /// An item in . /// - [DebuggerDisplay("{CombinedPath}")] + [DebuggerDisplay("{" + nameof(DebuggerToString) + "()}")] public abstract class RazorProjectItem { /// @@ -105,5 +105,10 @@ namespace Microsoft.AspNetCore.Razor.Language } } } + + private string DebuggerToString() + { + return CombinedPath; + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/RequiredAttributeDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/RequiredAttributeDescriptor.cs index 6d9e6fcf7b..ce8bdca365 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RequiredAttributeDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RequiredAttributeDescriptor.cs @@ -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 { 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); diff --git a/src/Microsoft.AspNetCore.Razor.Language/TagHelperDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/TagHelperDescriptor.cs index 4068305fa0..7c81d5e94f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/TagHelperDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/TagHelperDescriptor.cs @@ -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 { private IEnumerable _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); diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/DefaultTagHelperContent.cs b/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/DefaultTagHelperContent.cs index b8609a051a..c4cdc3750f 100644 --- a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/DefaultTagHelperContent.cs +++ b/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/DefaultTagHelperContent.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers /// /// Default concrete . /// - [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