Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Tuple Decomposition Names Error in Razor #5996

Closed
RandyBuchholz opened this issue Mar 21, 2017 · 2 comments
Closed

Tuple Decomposition Names Error in Razor #5996

RandyBuchholz opened this issue Mar 21, 2017 · 2 comments

Comments

@RandyBuchholz
Copy link

RandyBuchholz commented Mar 21, 2017

This may be related to Declare List<Tuple> in View Error #5709

Issue

I am passing a collection of tuple to my view page, and using it in a foreach.

// In Controller
model.Processes= new List<(Enum process, string label)> { (Invoice.Present, "Find") }

// In View

foreach (var service in Model.Processes) {
    <button-route-process route=service.process>@service.label</button-route-process>
}
 // button-route-process is a TagHelper

Intellisense recognizes the element names for autocomplete, but at run time I get:
'ValueTuple<Enum, string>' does not contain a definition for 'label' and no extension method 'label' accepting...'

If I use Item,

<button-service-route route=service.Item1>@service.Item2</button-service-route>

it works fine.

If I try define the tuple signature I get a different error at runtime.

foreach ((Enum process, string label) service in Model.Processes) {
	<button-route-process route=service.process>@service.label</button-route-process>
}

The names are a little different in this image.
image

@Eilon
Copy link
Member

Eilon commented Mar 21, 2017

I think this is a dup of aspnet/Razor#1046 - Razor doesn't support C# 7 at all yet.

cc @NTaylorMullen to confirm.

@Eilon Eilon closed this as completed Mar 21, 2017
@NTaylorMullen
Copy link
Contributor

@Eilon yup, you're correct.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants