From ddde149792a9b4d6865205dfc1beb44abc0a47de Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 30 Jul 2018 15:06:43 -0700 Subject: [PATCH] Cleanup some IDE warnings --- .../LinkTagHelper.cs | 12 ++++-------- .../ScriptTagHelper.cs | 6 ++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.TagHelpers/LinkTagHelper.cs b/src/Microsoft.AspNetCore.Mvc.TagHelpers/LinkTagHelper.cs index 07054bed8a..2d3b8b9456 100644 --- a/src/Microsoft.AspNetCore.Mvc.TagHelpers/LinkTagHelper.cs +++ b/src/Microsoft.AspNetCore.Mvc.TagHelpers/LinkTagHelper.cs @@ -257,8 +257,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers // not function properly. Href = output.Attributes[HrefAttributeName]?.Value as string; - Mode mode; - if (!AttributeMatcher.TryDetermineMode(context, ModeDetails, Compare, out mode)) + if (!AttributeMatcher.TryDetermineMode(context, ModeDetails, Compare, out var mode)) { // No attributes matched so we have nothing to do return; @@ -295,8 +294,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers if (mode == Mode.Fallback && HasStyleSheetLinkType(output.Attributes)) { - string resolvedUrl; - if (TryResolveUrl(FallbackHref, resolvedUrl: out resolvedUrl)) + if (TryResolveUrl(FallbackHref, resolvedUrl: out string resolvedUrl)) { FallbackHref = resolvedUrl; } @@ -395,17 +393,15 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers private bool HasStyleSheetLinkType(TagHelperAttributeList attributes) { - TagHelperAttribute relAttribute; - if (!attributes.TryGetAttribute(RelAttributeName, out relAttribute) || + if (!attributes.TryGetAttribute(RelAttributeName, out var relAttribute) || relAttribute.Value == null) { return false; } var attributeValue = relAttribute.Value; - var contentValue = attributeValue as IHtmlContent; var stringValue = attributeValue as string; - if (contentValue != null) + if (attributeValue is IHtmlContent contentValue) { contentValue.WriteTo(StringWriter, HtmlEncoder); stringValue = StringWriter.ToString(); diff --git a/src/Microsoft.AspNetCore.Mvc.TagHelpers/ScriptTagHelper.cs b/src/Microsoft.AspNetCore.Mvc.TagHelpers/ScriptTagHelper.cs index 3d0ca2d33f..15f7323db3 100644 --- a/src/Microsoft.AspNetCore.Mvc.TagHelpers/ScriptTagHelper.cs +++ b/src/Microsoft.AspNetCore.Mvc.TagHelpers/ScriptTagHelper.cs @@ -221,8 +221,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers // not function properly. Src = output.Attributes[SrcAttributeName]?.Value as string; - Mode mode; - if (!AttributeMatcher.TryDetermineMode(context, ModeDetails, Compare, out mode)) + if (!AttributeMatcher.TryDetermineMode(context, ModeDetails, Compare, out var mode)) { // No attributes matched so we have nothing to do return; @@ -259,8 +258,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers if (mode == Mode.Fallback) { - string resolvedUrl; - if (TryResolveUrl(FallbackSrc, resolvedUrl: out resolvedUrl)) + if (TryResolveUrl(FallbackSrc, resolvedUrl: out string resolvedUrl)) { FallbackSrc = resolvedUrl; }