Use as cast instead of C-style cast for IVewContextAware helpers
Fixes #5254
This commit is contained in:
parent
eee1a9fef4
commit
4a5e1f4a72
|
|
@ -149,7 +149,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Host.Internal
|
|||
}))
|
||||
{
|
||||
Writer.WriteInstanceMethodInvocation(
|
||||
$"((global::{_context.IViewContextAwareTypeName}){ViewComponentTagHelperVariable})",
|
||||
$"({ViewComponentTagHelperVariable} as global::{_context.IViewContextAwareTypeName})?",
|
||||
_context.ContextualizeMethodName,
|
||||
new [] { ViewContextVariable });
|
||||
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Host.Test.Internal
|
|||
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
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class __Generated__FooViewComponentTagHelper : Microsoft.AspNetCore.Razor
|
|||
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);
|
||||
|
|
@ -30,7 +30,7 @@ public class __Generated__BarViewComponentTagHelper : Microsoft.AspNetCore.Razor
|
|||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue