Don't render directive token from imports in design time

This commit is contained in:
Ajay Bhargav Baaskaran 2017-03-29 12:19:16 -07:00
parent 582ffe2e10
commit c1500da2a8
19 changed files with 33 additions and 452 deletions

View File

@ -110,8 +110,13 @@ namespace Microsoft.AspNetCore.Razor.Evolution.CodeGeneration
const string TypeHelper = "__typeHelper";
var tokenKind = node.Descriptor.Kind;
if (node.Source == null)
if (!node.Source.HasValue ||
!string.Equals(
Context.SourceDocument.FileName,
node.Source.Value.FilePath,
StringComparison.OrdinalIgnoreCase))
{
// We don't want to handle directives from imports.
return;
}

View File

@ -33,58 +33,6 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Html = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Json = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Component = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IUrlHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Url = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object ModelExpressionProvider = null;
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
}
#pragma warning restore 219
private static System.Object __o = null;

View File

@ -1,10 +1,10 @@
Source Location: (13:0,13 [4] /TestFiles/Input/Basic.cshtml)
|logo|
Generated Location: (2732:94,13 [4] )
Generated Location: (1024:42,13 [4] )
|logo|
Source Location: (43:2,5 [21] /TestFiles/Input/Basic.cshtml)
|Html.Input("SomeKey")|
Generated Location: (2817:99,6 [21] )
Generated Location: (1109:47,6 [21] )
|Html.Input("SomeKey")|

View File

@ -39,58 +39,6 @@ using MyNamespace;
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Html = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Json = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Component = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IUrlHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Url = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object ModelExpressionProvider = null;
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
MyApp __typeHelper = null;
}
))();

View File

@ -1,10 +1,10 @@
Source Location: (28:1,8 [5] /TestFiles/Input/Inject.cshtml)
|MyApp|
Generated Location: (2577:93,0 [5] )
Generated Location: (869:41,0 [5] )
|MyApp|
Source Location: (34:1,14 [14] /TestFiles/Input/Inject.cshtml)
|MyPropertyName|
Generated Location: (2679:97,14 [14] )
Generated Location: (971:45,14 [14] )
|MyPropertyName|

View File

@ -34,58 +34,6 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Html = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Json = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Component = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IUrlHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Url = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object ModelExpressionProvider = null;
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
MyModel __typeHelper = null;
}
))();

View File

@ -1,25 +1,25 @@
Source Location: (7:0,7 [7] /TestFiles/Input/InjectWithModel.cshtml)
|MyModel|
Generated Location: (2479:88,0 [7] )
Generated Location: (771:36,0 [7] )
|MyModel|
Source Location: (24:1,8 [5] /TestFiles/Input/InjectWithModel.cshtml)
|MyApp|
Generated Location: (2569:92,0 [5] )
Generated Location: (861:40,0 [5] )
|MyApp|
Source Location: (30:1,14 [14] /TestFiles/Input/InjectWithModel.cshtml)
|MyPropertyName|
Generated Location: (2671:96,14 [14] )
Generated Location: (963:44,14 [14] )
|MyPropertyName|
Source Location: (54:2,8 [17] /TestFiles/Input/InjectWithModel.cshtml)
|MyService<TModel>|
Generated Location: (2755:100,0 [17] )
Generated Location: (1047:48,0 [17] )
|MyService<TModel>|
Source Location: (72:2,26 [4] /TestFiles/Input/InjectWithModel.cshtml)
|Html|
Generated Location: (2869:104,14 [4] )
Generated Location: (1161:52,14 [4] )
|Html|

View File

@ -34,58 +34,6 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Html = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Json = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Component = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IUrlHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Url = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object ModelExpressionProvider = null;
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
MyModel __typeHelper = null;
}
))();

View File

@ -1,45 +1,45 @@
Source Location: (7:0,7 [7] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyModel|
Generated Location: (2483:88,0 [7] )
Generated Location: (775:36,0 [7] )
|MyModel|
Source Location: (24:1,8 [5] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyApp|
Generated Location: (2573:92,0 [5] )
Generated Location: (865:40,0 [5] )
|MyApp|
Source Location: (30:1,14 [14] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyPropertyName|
Generated Location: (2675:96,14 [14] )
Generated Location: (967:44,14 [14] )
|MyPropertyName|
Source Location: (58:2,8 [17] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyService<TModel>|
Generated Location: (2759:100,0 [17] )
Generated Location: (1051:48,0 [17] )
|MyService<TModel>|
Source Location: (76:2,26 [4] /TestFiles/Input/InjectWithSemicolon.cshtml)
|Html|
Generated Location: (2873:104,14 [4] )
Generated Location: (1165:52,14 [4] )
|Html|
Source Location: (93:3,8 [5] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyApp|
Generated Location: (2947:108,0 [5] )
Generated Location: (1239:56,0 [5] )
|MyApp|
Source Location: (99:3,14 [15] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyPropertyName2|
Generated Location: (3049:112,14 [15] )
Generated Location: (1341:60,14 [15] )
|MyPropertyName2|
Source Location: (129:4,8 [17] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyService<TModel>|
Generated Location: (3134:116,0 [17] )
Generated Location: (1426:64,0 [17] )
|MyService<TModel>|
Source Location: (147:4,26 [5] /TestFiles/Input/InjectWithSemicolon.cshtml)
|Html2|
Generated Location: (3248:120,14 [5] )
Generated Location: (1540:68,14 [5] )
|Html2|

View File

@ -34,58 +34,6 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Html = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Json = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Component = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IUrlHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Url = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object ModelExpressionProvider = null;
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Collections.IEnumerable __typeHelper = null;
}
))();

View File

@ -1,5 +1,5 @@
Source Location: (7:0,7 [30] /TestFiles/Input/Model.cshtml)
|System.Collections.IEnumerable|
Generated Location: (2515:88,0 [30] )
Generated Location: (807:36,0 [30] )
|System.Collections.IEnumerable|

View File

@ -34,58 +34,6 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Html = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Json = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Component = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IUrlHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Url = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object ModelExpressionProvider = null;
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
DateTime __typeHelper = null;
}
))();

View File

@ -1,20 +1,20 @@
Source Location: (7:0,7 [8] /TestFiles/Input/ModelExpressionTagHelper.cshtml)
|DateTime|
Generated Location: (2490:88,0 [8] )
Generated Location: (782:36,0 [8] )
|DateTime|
Source Location: (33:2,14 [108] /TestFiles/Input/ModelExpressionTagHelper.cshtml)
|Microsoft.AspNetCore.Mvc.Razor.Extensions.InputTestTagHelper, Microsoft.AspNetCore.Mvc.Razor.Extensions.Test|
Generated Location: (2611:92,30 [108] )
Generated Location: (903:40,30 [108] )
|Microsoft.AspNetCore.Mvc.Razor.Extensions.InputTestTagHelper, Microsoft.AspNetCore.Mvc.Razor.Extensions.Test|
Source Location: (162:4,17 [3] /TestFiles/Input/ModelExpressionTagHelper.cshtml)
|Now|
Generated Location: (3506:104,144 [3] )
Generated Location: (1798:52,144 [3] )
|Now|
Source Location: (189:5,18 [5] /TestFiles/Input/ModelExpressionTagHelper.cshtml)
|Model|
Generated Location: (3907:110,136 [5] )
Generated Location: (2199:58,136 [5] )
|Model|

View File

@ -34,58 +34,6 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Html = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Json = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Component = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IUrlHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Url = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object ModelExpressionProvider = null;
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
ThisShouldBeGenerated __typeHelper = null;
}
))();

View File

@ -1,10 +1,10 @@
Source Location: (7:0,7 [21] /TestFiles/Input/MultipleModels.cshtml)
|ThisShouldBeGenerated|
Generated Location: (2524:88,0 [21] )
Generated Location: (816:36,0 [21] )
|ThisShouldBeGenerated|
Source Location: (37:1,7 [30] /TestFiles/Input/MultipleModels.cshtml)
|System.Collections.IEnumerable|
Generated Location: (2628:92,0 [30] )
Generated Location: (920:40,0 [30] )
|System.Collections.IEnumerable|

View File

@ -34,58 +34,6 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Html = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Json = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Component = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.IUrlHelper __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object Url = null;
}
))();
((System.Action)(() => {
global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider __typeHelper = null;
}
))();
((System.Action)(() => {
System.Object ModelExpressionProvider = null;
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
System.Object __typeHelper = "Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor";
}
))();
((System.Action)(() => {
IHtmlHelper<TModel> __typeHelper = null;
}
))();

View File

@ -1,10 +1,10 @@
Source Location: (8:0,8 [19] /TestFiles/Input/_ViewImports.cshtml)
|IHtmlHelper<TModel>|
Generated Location: (2490:88,0 [19] )
Generated Location: (782:36,0 [19] )
|IHtmlHelper<TModel>|
Source Location: (28:0,28 [5] /TestFiles/Input/_ViewImports.cshtml)
|Model|
Generated Location: (2606:92,14 [5] )
Generated Location: (898:40,14 [5] )
|Model|

View File

@ -7,10 +7,6 @@
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
System.Object __typeHelper = "*, Test";
}
))();
}
#pragma warning restore 219
private static System.Object __o = null;

View File

@ -22,10 +22,6 @@ using System.Text;
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
Hello __typeHelper = null;
}
))();
}
#pragma warning restore 219
private static System.Object __o = null;