Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Use as cast instead of C-style cast for IVewContextAware helpers
Browse files Browse the repository at this point in the history
Fixes #5254
  • Loading branch information
pranavkm authored Sep 12, 2016
1 parent eee1a9f commit 4a5e1f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private void BuildProcessMethodString(TagHelperDescriptor descriptor)
}))
{
Writer.WriteInstanceMethodInvocation(
$"((global::{_context.IViewContextAwareTypeName}){ViewComponentTagHelperVariable})",
$"({ViewComponentTagHelperVariable} as global::{_context.IViewContextAwareTypeName})?",
_context.ContextualizeMethodName,
new [] { ViewContextVariable });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public void Accept_CorrectlyGeneratesCode(IList<Chunk> chunks)
if (!string.Equals(expectedOutput, resultOutput, StringComparison.Ordinal))
{
ResourceFile.UpdateFile(assembly, path, expectedOutput, resultOutput);
expectedOutput = ResourceFile.ReadResource(assembly, path, sourceFile: true);
}
#endif

#else
// Assert
Assert.Equal(expectedOutput, resultOutput, ignoreLineEndingDifferences: true);
#endif

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public __Generated__FooViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.I
public System.String Attribute { get; set; }
public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output)
{
((global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)_viewComponentHelper).Contextualize(ViewContext);
(_viewComponentHelper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext);
var viewContent = await _viewComponentHelper.InvokeAsync("Foo", new { Attribute });
output.TagName = null;
output.Content.SetHtmlContent(viewContent);
Expand All @@ -30,7 +30,7 @@ public __Generated__BarViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.I
public System.String Attribute { get; set; }
public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output)
{
((global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)_viewComponentHelper).Contextualize(ViewContext);
(_viewComponentHelper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext);
var viewContent = await _viewComponentHelper.InvokeAsync("Bar", new { Attribute });
output.TagName = null;
output.Content.SetHtmlContent(viewContent);
Expand Down

0 comments on commit 4a5e1f4

Please sign in to comment.