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.
- Loading branch information
sornaks
committed
Dec 13, 2014
1 parent
1631ca1
commit b961aa6
Showing
6 changed files
with
78 additions
and
14 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
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
// 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() | ||
{ | ||
var modelList = new List<SampleModel>() | ||
{ | ||
new SampleModel { Prop1 = "Hello", Prop2 = "World" }, | ||
new SampleModel { Prop1 = "Sample", Prop2 = "Test" }, | ||
}; | ||
|
||
return View(modelList.Select(e => e)); | ||
} | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
test/WebSites/ViewComponentWebSite/Views/Shared/Components/Enumerable/Default.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,3 @@ | ||
@model IEnumerable<SampleModel> | ||
@foreach (var m in Model) | ||
{<p>@m.Prop1</p><p>@m.Prop2</p>} |
1 change: 1 addition & 0 deletions
1
test/WebSites/ViewComponentWebSite/Views/Shared/ViewComponentWithEnumerableModel.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 @@ | ||
@Component.Invoke("Enumerable") |