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

Commit 553b2d1

Browse files
committed
Use nameof when initializing GeneratedTagHelperContext
nits: - missing blank line before a comment - cleanup line breaks in `RazorPage.CreateTagHelper`
1 parent 873cb56 commit 553b2d1

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class MvcRazorHost : RazorEngineHost, IMvcRazorHost
3636
};
3737

3838
private readonly IFileSystem _fileSystem;
39+
3940
// CodeGenerationContext.DefaultBaseClass is set to MyBaseType<dynamic>.
4041
// This field holds the type name without the generic decoration (MyBaseType)
4142
private readonly string _baseType;
@@ -85,11 +86,28 @@ protected internal MvcRazorHost([NotNull] IFileSystem fileSystem)
8586
defineSectionMethodName: "DefineSection",
8687
generatedTagHelperContext: new GeneratedTagHelperContext
8788
{
89+
ExecutionContextTypeName = typeof(TagHelperExecutionContext).FullName,
90+
ExecutionContextAddMethodName = nameof(TagHelperExecutionContext.Add),
91+
ExecutionContextAddTagHelperAttributeMethodName =
92+
nameof(TagHelperExecutionContext.AddTagHelperAttribute),
93+
ExecutionContextAddHtmlAttributeMethodName = nameof(TagHelperExecutionContext.AddHtmlAttribute),
94+
ExecutionContextOutputPropertyName = nameof(TagHelperExecutionContext.Output),
95+
8896
RunnerTypeName = typeof(TagHelperRunner).FullName,
97+
RunnerRunAsyncMethodName = nameof(TagHelperRunner.RunAsync),
98+
8999
ScopeManagerTypeName = typeof(TagHelperScopeManager).FullName,
90-
ExecutionContextTypeName = typeof(TagHelperExecutionContext).FullName,
100+
ScopeManagerBeginMethodName = nameof(TagHelperScopeManager.Begin),
101+
ScopeManagerEndMethodName = nameof(TagHelperScopeManager.End),
102+
103+
OutputGenerateStartTagMethodName = nameof(TagHelperOutput.GenerateStartTag),
104+
OutputGenerateContentMethodName = nameof(TagHelperOutput.GenerateContent),
105+
OutputGenerateEndTagMethodName = nameof(TagHelperOutput.GenerateEndTag),
106+
107+
// Can't use nameof because RazorPage is not accessible here.
108+
CreateTagHelperMethodName = "CreateTagHelper",
91109
StartWritingScopeMethodName = "StartWritingScope",
92-
EndWritingScopeMethodName = "EndWritingScope"
110+
EndWritingScopeMethodName = "EndWritingScope",
93111
})
94112
{
95113
ResolveUrlMethodName = "Href",

src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ private ITypeActivator TypeActivator
138138
public TTagHelper CreateTagHelper<TTagHelper>() where TTagHelper : ITagHelper
139139
{
140140
var tagHelper = TypeActivator.CreateInstance<TTagHelper>(ViewContext.HttpContext.RequestServices);
141-
var hasViewContext = tagHelper as ICanHasViewContext;
142141

142+
var hasViewContext = tagHelper as ICanHasViewContext;
143143
hasViewContext?.Contextualize(ViewContext);
144144

145145
return tagHelper;

0 commit comments

Comments
 (0)