React to change in Razor
This commit is contained in:
parent
b520b0cb22
commit
a65a6a7cab
|
|
@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
// If there's more than 1 model chunk there will be a Razor error BUT we want intellisense to show up on
|
||||
// the current model chunk that the user is typing.
|
||||
return chunkTree
|
||||
.Chunks
|
||||
.Children
|
||||
.OfType<ModelChunk>()
|
||||
.LastOrDefault();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
var chunkMergers = GetChunkMergers(chunkTree, defaultModel);
|
||||
// We merge chunks into the ChunkTree in two passes. In the first pass, we traverse the ChunkTree visiting
|
||||
// a mapped IChunkMerger for types that are registered.
|
||||
foreach (var chunk in chunkTree.Chunks)
|
||||
foreach (var chunk in chunkTree.Children)
|
||||
{
|
||||
foreach (var merger in chunkMergers)
|
||||
{
|
||||
|
|
@ -136,7 +136,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
}
|
||||
|
||||
var inheritedChunks = _defaultInheritedChunks.Concat(
|
||||
inheritedChunkTrees.SelectMany(tree => tree.Chunks)).ToArray();
|
||||
inheritedChunkTrees.SelectMany(tree => tree.Children)).ToArray();
|
||||
|
||||
foreach (var merger in chunkMergers)
|
||||
{
|
||||
|
|
@ -175,8 +175,8 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
chunkGenerator.Visit(parseResults);
|
||||
|
||||
// Rewrite the location of inherited chunks so they point to the global import file.
|
||||
var chunkTree = chunkGenerator.Context.ChunkTreeBuilder.ChunkTree;
|
||||
foreach (var chunk in chunkTree.Chunks)
|
||||
var chunkTree = chunkGenerator.Context.ChunkTreeBuilder.Root;
|
||||
foreach (var chunk in chunkTree.Children)
|
||||
{
|
||||
chunk.Start = new SourceLocation(
|
||||
viewImportsPath,
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
if (injectChunk != null &&
|
||||
_addedMemberNames.Add(injectChunk.MemberName))
|
||||
{
|
||||
chunkTree.Chunks.Add(TransformChunk(injectChunk));
|
||||
chunkTree.Children.Add(TransformChunk(injectChunk));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
var baseTypeChunk = inheritedChunks[i] as SetBaseTypeChunk;
|
||||
if (baseTypeChunk != null)
|
||||
{
|
||||
chunkTree.Chunks.Add(TransformChunk(baseTypeChunk));
|
||||
chunkTree.Children.Add(TransformChunk(baseTypeChunk));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
{
|
||||
if (_currentUsings.Add(namespaceChunk.Namespace))
|
||||
{
|
||||
chunkTree.Chunks.Add(namespaceChunk);
|
||||
chunkTree.Children.Add(namespaceChunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
writer.WriteLineHiddenDirective();
|
||||
|
||||
var injectVisitor = new InjectChunkVisitor(writer, Context, _injectAttribute);
|
||||
injectVisitor.Accept(Context.ChunkTreeBuilder.ChunkTree.Chunks);
|
||||
injectVisitor.Accept(Context.ChunkTreeBuilder.Root.Children);
|
||||
|
||||
writer.WriteLine();
|
||||
writer.WriteLineHiddenDirective();
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
var inheritedChunkTrees = GetInheritedChunkTrees(context.SourceFile);
|
||||
|
||||
ChunkInheritanceUtility.MergeInheritedChunkTrees(
|
||||
context.ChunkTreeBuilder.ChunkTree,
|
||||
context.ChunkTreeBuilder.Root,
|
||||
inheritedChunkTrees,
|
||||
DefaultModel);
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
{
|
||||
var descriptors = new List<TagHelperDirectiveDescriptor>();
|
||||
|
||||
var inheritedChunks = defaultInheritedChunks.Concat(inheritedChunkTrees.SelectMany(tree => tree.Chunks));
|
||||
var inheritedChunks = defaultInheritedChunks.Concat(inheritedChunkTrees.SelectMany(tree => tree.Children));
|
||||
foreach (var chunk in inheritedChunks)
|
||||
{
|
||||
// All TagHelperDirectiveDescriptors created here have undefined source locations because the source
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
chunkTreeResult =>
|
||||
{
|
||||
var viewImportsPath = @"/Views/_ViewImports.cshtml";
|
||||
Assert.Collection(chunkTreeResult.ChunkTree.Chunks,
|
||||
Assert.Collection(chunkTreeResult.ChunkTree.Children,
|
||||
chunk =>
|
||||
{
|
||||
Assert.IsType<LiteralChunk>(chunk);
|
||||
|
|
@ -87,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
chunkTreeResult =>
|
||||
{
|
||||
var viewImportsPath = "/Views/home/_ViewImports.cshtml";
|
||||
Assert.Collection(chunkTreeResult.ChunkTree.Chunks,
|
||||
Assert.Collection(chunkTreeResult.ChunkTree.Children,
|
||||
chunk =>
|
||||
{
|
||||
Assert.IsType<LiteralChunk>(chunk);
|
||||
|
|
@ -150,7 +150,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
{
|
||||
new ChunkTree
|
||||
{
|
||||
Chunks = new Chunk[]
|
||||
Children = new Chunk[]
|
||||
{
|
||||
new UsingChunk { Namespace = "InheritedNamespace" },
|
||||
new LiteralChunk { Text = "some text" }
|
||||
|
|
@ -158,7 +158,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
},
|
||||
new ChunkTree
|
||||
{
|
||||
Chunks = new Chunk[]
|
||||
Children = new Chunk[]
|
||||
{
|
||||
new UsingChunk { Namespace = "AppNamespace.Model" },
|
||||
}
|
||||
|
|
@ -172,9 +172,9 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
utility.MergeInheritedChunkTrees(chunkTree, inheritedChunkTrees, "dynamic");
|
||||
|
||||
// Assert
|
||||
Assert.Collection(chunkTree.Chunks,
|
||||
Assert.Collection(chunkTree.Children,
|
||||
chunk => Assert.Same(defaultChunks[1], chunk),
|
||||
chunk => Assert.Same(inheritedChunkTrees[0].Chunks[0], chunk),
|
||||
chunk => Assert.Same(inheritedChunkTrees[0].Children[0], chunk),
|
||||
chunk => Assert.Same(defaultChunks[0], chunk));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
var chunk = Assert.Single(chunkTree.Chunks);
|
||||
var chunk = Assert.Single(chunkTree.Children);
|
||||
var injectChunk = Assert.IsType<InjectChunk>(chunk);
|
||||
Assert.Equal(expectedType, injectChunk.TypeName);
|
||||
Assert.Equal(expectedProperty, injectChunk.MemberName);
|
||||
|
|
@ -64,7 +64,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
Assert.Empty(chunkTree.Chunks);
|
||||
Assert.Empty(chunkTree.Children);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -84,12 +84,12 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, chunkTree.Chunks.Count);
|
||||
var injectChunk = Assert.IsType<InjectChunk>(chunkTree.Chunks[0]);
|
||||
Assert.Equal(2, chunkTree.Children.Count);
|
||||
var injectChunk = Assert.IsType<InjectChunk>(chunkTree.Children[0]);
|
||||
Assert.Equal("MyType", injectChunk.TypeName);
|
||||
Assert.Equal("myproperty", injectChunk.MemberName);
|
||||
|
||||
injectChunk = Assert.IsType<InjectChunk>(chunkTree.Chunks[1]);
|
||||
injectChunk = Assert.IsType<InjectChunk>(chunkTree.Children[1]);
|
||||
Assert.Equal("MyTypeB", injectChunk.TypeName);
|
||||
Assert.Equal("different-property", injectChunk.MemberName);
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
var chunk = Assert.Single(chunkTree.Chunks);
|
||||
var chunk = Assert.Single(chunkTree.Children);
|
||||
var injectChunk = Assert.IsType<InjectChunk>(chunk);
|
||||
Assert.Equal("MyHelper<dynamic>", injectChunk.TypeName);
|
||||
Assert.Equal("MyProperty", injectChunk.MemberName);
|
||||
|
|
@ -130,7 +130,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
var chunk = Assert.Single(chunkTree.Chunks);
|
||||
var chunk = Assert.Single(chunkTree.Children);
|
||||
var injectChunk = Assert.IsType<InjectChunk>(chunk);
|
||||
Assert.Equal("MyHelper<MyTestModel2>", injectChunk.TypeName);
|
||||
Assert.Equal("MyProperty", injectChunk.MemberName);
|
||||
|
|
@ -154,7 +154,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
Assert.Collection(chunkTree.Chunks,
|
||||
Assert.Collection(chunkTree.Children,
|
||||
chunk =>
|
||||
{
|
||||
var injectChunk = Assert.IsType<InjectChunk>(chunk);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
var chunk = Assert.Single(chunkTree.Chunks);
|
||||
var chunk = Assert.Single(chunkTree.Children);
|
||||
var setBaseTypeChunk = Assert.IsType<SetBaseTypeChunk>(chunk);
|
||||
Assert.Equal(expected, setBaseTypeChunk.TypeName);
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
Assert.Empty(chunkTree.Chunks);
|
||||
Assert.Empty(chunkTree.Children);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
var chunk = Assert.Single(chunkTree.Chunks);
|
||||
var chunk = Assert.Single(chunkTree.Children);
|
||||
var setBaseTypeChunk = Assert.IsType<SetBaseTypeChunk>(chunk);
|
||||
Assert.Equal("MyBase1", setBaseTypeChunk.TypeName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
var chunk = Assert.Single(chunkTree.Chunks);
|
||||
var chunk = Assert.Single(chunkTree.Children);
|
||||
var usingChunk = Assert.IsType<UsingChunk>(chunk);
|
||||
Assert.Equal(expected, usingChunk.Namespace);
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
Assert.Empty(chunkTree.Chunks);
|
||||
Assert.Empty(chunkTree.Children);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -69,10 +69,10 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, chunkTree.Chunks.Count);
|
||||
var chunk = Assert.IsType<UsingChunk>(chunkTree.Chunks[0]);
|
||||
Assert.Equal(2, chunkTree.Children.Count);
|
||||
var chunk = Assert.IsType<UsingChunk>(chunkTree.Children[0]);
|
||||
Assert.Equal("Microsoft.AspNet.Mvc", chunk.Namespace);
|
||||
chunk = Assert.IsType<UsingChunk>(chunkTree.Chunks[1]);
|
||||
chunk = Assert.IsType<UsingChunk>(chunkTree.Children[1]);
|
||||
Assert.Equal("Microsoft.AspNet.Mvc.Razor", chunk.Namespace);
|
||||
}
|
||||
|
||||
|
|
@ -92,10 +92,10 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
merger.MergeInheritedChunks(chunkTree, inheritedChunks);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, chunkTree.Chunks.Count);
|
||||
var chunk = Assert.IsType<UsingChunk>(chunkTree.Chunks[0]);
|
||||
Assert.Equal(2, chunkTree.Children.Count);
|
||||
var chunk = Assert.IsType<UsingChunk>(chunkTree.Children[0]);
|
||||
Assert.Equal("Microsoft.AspNet.Mvc", chunk.Namespace);
|
||||
chunk = Assert.IsType<UsingChunk>(chunkTree.Chunks[1]);
|
||||
chunk = Assert.IsType<UsingChunk>(chunkTree.Children[1]);
|
||||
Assert.Equal("Microsoft.AspNet.mvc", chunk.Namespace);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
{
|
||||
return new ChunkTree
|
||||
{
|
||||
Chunks = chunks
|
||||
Children = chunks
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue