Skip to content

Commit

Permalink
Use extension method
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwengier committed Oct 28, 2021
1 parent e89e302 commit fb7a009
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Legacy;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.Language.Components;

namespace Microsoft.AspNetCore.Razor.LanguageServer.Formatting
{
Expand Down Expand Up @@ -216,7 +217,7 @@ public override void VisitMarkupTagHelperElement(MarkupTagHelperElementSyntax no

if (causesIndentation)
{
Debug.Assert(_currentComponentIndentationLevel > 0, "Component tracker should not be empty.");
Debug.Assert(_currentComponentIndentationLevel > 0, "Component indentation level should not be at 0.");
_currentComponentIndentationLevel -= componentIndentationLevels;
}
_currentHtmlIndentationLevel--;
Expand Down Expand Up @@ -283,19 +284,13 @@ static bool DoesComponentHaveCascadingTypeParameter(MarkupTagHelperElementSyntax
return false;
}

foreach (var descriptor in tagHelperInfo.BindingResult.Descriptors)
var descriptors = tagHelperInfo.BindingResult?.Descriptors;
if (descriptors is null)
{
foreach (var attribute in descriptor.BoundAttributes)
{
if (attribute.Metadata.TryGetValue("Components.TypeParameterIsCascading", out var value) &&
string.Equals(value, bool.TrueString))
{
return true;
}
}
return false;
}

return false;
return descriptors.Any(d => d.SuppliesCascadingGenericParameters());
}
}

Expand Down

0 comments on commit fb7a009

Please sign in to comment.