This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug #1354 - ViewComponent View() fails on CoreCLR with IEnumerable<> …
…passed in. Fix - When the model is passed in to a View, ViewDataDictionary sets it. During this process, we recurse through all the properties and create FastPropertyGetters for each of them. In this case, since it is an enumerable, the properties which we recurse through are not the elements of the collection but the properties of the Enumerable instead. i.e - Enumerable.Current. Creating getters for these properties are not necessary. The fix moves the property iteration step to a place where the properties are actually requested. - Splitting TypeInformation class into two and separating their caches appropriately.
- Loading branch information
sornaks
committed
Dec 16, 2014
1 parent
2df482a
commit 1570e19
Showing
12 changed files
with
303 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
test/WebSites/RazorWebSite/Views/Shared/_PartialWithModelFromEnumerable.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@model Person | ||
@Html.DisplayFor(m => m.Name) |
4 changes: 4 additions & 0 deletions
4
test/WebSites/RazorWebSite/Views/ViewEngine/ViewWithPartialTakingModelFromIEnumerable.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@using RazorWebSite | ||
@model IEnumerable<Person> | ||
@foreach (var item in Model) | ||
{@await Html.PartialAsync("_PartialWithModelFromEnumerable", item)} |
50 changes: 50 additions & 0 deletions
50
test/WebSites/ViewComponentWebSite/EnumerableViewComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.AspNet.Mvc; | ||
|
||
namespace ViewComponentWebSite | ||
{ | ||
public class EnumerableViewComponent : ViewComponent | ||
{ | ||
public IViewComponentResult Invoke(string linqQueryType) | ||
{ | ||
var modelList = new List<SampleModel>() | ||
{ | ||
new SampleModel { Prop1 = "Hello", Prop2 = "World" }, | ||
new SampleModel { Prop1 = linqQueryType, Prop2 = "Test" }, | ||
}; | ||
|
||
switch (linqQueryType) { | ||
case "Where": | ||
return View(modelList.Where(e => e != null)); | ||
|
||
case "Take": | ||
return View(modelList.Take(2)); | ||
|
||
case "TakeWhile": | ||
return View(modelList.TakeWhile(a => a != null)); | ||
|
||
case "Union": | ||
return View(modelList.Union(modelList)); | ||
|
||
case "SelectMany": | ||
var selectManySampleModelList = new List<SelectManySampleModel> | ||
{ | ||
new SelectManySampleModel { | ||
TestModel = | ||
new List<SampleModel> { new SampleModel { Prop1 = "Hello", Prop2 = "World" } } }, | ||
new SelectManySampleModel { | ||
TestModel = | ||
new List<SampleModel> { new SampleModel{ Prop1 = linqQueryType, Prop2 = "Test" } } } | ||
}; | ||
|
||
return View(selectManySampleModelList.SelectMany(a => a.TestModel)); | ||
}; | ||
|
||
return View(modelList.Select(e => e)); | ||
} | ||
} | ||
} |
Oops, something went wrong.