Skip running ModelDirective pass for component documents (dotnet/aspnetcore-tooling#372)
\n\nCommit migrated from 6824620cb0
This commit is contained in:
parent
730f3cdc6b
commit
8eee2d5bc4
|
|
@ -76,6 +76,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
|
||||
protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
|
||||
{
|
||||
if (documentNode.DocumentKind != RazorPageDocumentClassifierPass.RazorPageDocumentKind &&
|
||||
documentNode.DocumentKind != MvcViewDocumentClassifierPass.MvcViewDocumentKind)
|
||||
{
|
||||
// Not a MVC file. Skip.
|
||||
return;
|
||||
}
|
||||
|
||||
var visitor = new Visitor();
|
||||
var modelType = GetModelType(documentNode, visitor);
|
||||
|
||||
|
|
|
|||
|
|
@ -251,6 +251,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
// Notice we're not registering the ModelDirective.Pass here so we can run it on demand.
|
||||
b.AddDirective(ModelDirective.Directive);
|
||||
|
||||
b.Features.Add(new RazorPageDocumentClassifierPass());
|
||||
b.Features.Add(new MvcViewDocumentClassifierPass());
|
||||
b.Features.Add(new DesignTimeOptionsFeature(designTime));
|
||||
}).Engine;
|
||||
}
|
||||
|
|
@ -278,21 +280,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
return codeDocument.GetDocumentIntermediateNode();
|
||||
}
|
||||
|
||||
private string GetCSharpContent(IntermediateNode node)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
for (var i = 0; i < node.Children.Count; i++)
|
||||
{
|
||||
var child = node.Children[i] as IntermediateToken;
|
||||
if (child.Kind == TokenKind.CSharp)
|
||||
{
|
||||
builder.Append(child.Content);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private class ClassNodeVisitor : IntermediateNodeWalker
|
||||
{
|
||||
public ClassDeclarationIntermediateNode Node { get; set; }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace __GeneratedComponent
|
||||
{
|
||||
#line hidden
|
||||
using TModel = global::System.Object;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - __GeneratedComponent
|
||||
UsingDirective - - TModel = global::System.Object
|
||||
UsingDirective - (1:0,1 [12] ) - System
|
||||
UsingDirective - (16:1,1 [32] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [17] ) - System.Linq
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
Source Location: (12:0,12 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml)
|
||||
|IDisposable|
|
||||
Generated Location: (684:18,0 [11] )
|
||||
Generated Location: (641:17,0 [11] )
|
||||
|IDisposable|
|
||||
|
||||
Source Location: (38:1,13 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml)
|
||||
|this.ToString()|
|
||||
Generated Location: (1318:36,13 [15] )
|
||||
Generated Location: (1275:35,13 [15] )
|
||||
|this.ToString()|
|
||||
|
||||
Source Location: (79:3,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml)
|
||||
|string.Format("{0}", "Hello")|
|
||||
Generated Location: (1501:43,6 [29] )
|
||||
Generated Location: (1458:42,6 [29] )
|
||||
|string.Format("{0}", "Hello")|
|
||||
|
||||
Source Location: (132:6,12 [37] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml)
|
||||
|
|
||||
void IDisposable.Dispose(){ }
|
||||
|
|
||||
Generated Location: (1753:52,12 [37] )
|
||||
Generated Location: (1710:51,12 [37] )
|
||||
|
|
||||
void IDisposable.Dispose(){ }
|
||||
|
|
||||
|
|
|
|||
Loading…
Reference in New Issue