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

Html.RenderPartialAsync("") shows an error in editor #1254

Closed
DamianEdwards opened this issue Apr 25, 2017 · 15 comments
Closed

Html.RenderPartialAsync("") shows an error in editor #1254

DamianEdwards opened this issue Apr 25, 2017 · 15 comments
Assignees

Comments

@DamianEdwards
Copy link
Member

Using VS2017 d15prerel (15.3 26423.1-Preview)

Add the following to a Razor file:

@section Scripts {
    @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

You get a squigglie indicating the overload doesn't exist:
image

You can however "Go to definition" on the method and it finds it OK. Also, runtime works fine.

@DamianEdwards
Copy link
Member Author

@NTaylorMullen @rynowak

@NTaylorMullen
Copy link
Contributor

Super odd.... That extension methods exists in the same namespace as the base RenderPartialAsync method. I'll have to try it out once my VS updates.

@rynowak
Copy link
Member

rynowak commented Apr 25, 2017

@NTaylorMullen - the error is on RenderAsyncDelegate in the generated code

@NTaylorMullen
Copy link
Contributor

@NTaylorMullen - the error is on RenderAsyncDelegate in the generated code

Ooo i see. Ya gotta fix this guy.

@rynowak
Copy link
Member

rynowak commented Apr 25, 2017

Can you figure out what the safe fix is for this for preview 1?

@NTaylorMullen
Copy link
Contributor

NTaylorMullen commented Apr 25, 2017

Issue here is that our code generation is compatible with 1.0.0 Mvc but not 2.0.0 Mvc.

We render:

DefineSection("Foo", async (__razor_section_writer) => {
});

Which works in 1.0.0. However, in 2.0.0 our define section method looks like this:

public virtual void DefineSection(string name, RenderAsyncDelegate section)

Where RenderAsyncDelegate is:

public delegate Task RenderAsyncDelegate();

The most minimal fix for this for preview1 would be to create an overload to DefineSection in RazorPage.cs that took in a Func<object, Task> as its second parameter instead of RenderAsyncDelegate. If not, we'll have to tackle code gen based on version.

What do you guys think?

@DamianEdwards
Copy link
Member Author

I'd vote for the minimal fix for preview1.

@rynowak
Copy link
Member

rynowak commented Apr 26, 2017

I'd vote for the minimal fix for preview1.

This guy right here.

Is this a pages-specific issue or do we need to fix this for pages and views?

@NTaylorMullen
Copy link
Contributor

Is this a pages-specific issue or do we need to fix this for pages and views?

Pages and Views

@rynowak
Copy link
Member

rynowak commented Apr 26, 2017

So if I understand correctly, the fix here is to add a dummy public virtual void DefineSection(string name, Func<TextWriter, Text> section) to RazorPageBase. (Probably with [EditorBrowsableNever])

This will be targeted by the design time codegen, but will have no purpose at runtime.

@NTaylorMullen
Copy link
Contributor

So if I understand correctly, the fix here is to add a dummy public virtual void DefineSection(string name, Func<TextWriter, Text> section) to RazorPageBase. (Probably with [EditorBrowsableNever])

This will be targeted by the design time codegen, but will have no purpose at runtime.

Exactly.

@NTaylorMullen
Copy link
Contributor

IF we really wanted we could have the runtime impl do other stuff:

  1. throw
  2. call through to the primary DefineSection impl
  3. Noop

NTaylorMullen added a commit to aspnet/Mvc that referenced this issue Apr 26, 2017
- This enables 2.0.0 code generation to not error.

aspnet/Razor#1254
@NTaylorMullen
Copy link
Contributor

Went with option 2

NTaylorMullen added a commit to aspnet/Mvc that referenced this issue Apr 26, 2017
- This enables 2.0.0 code generation to not error.

aspnet/Razor#1254
NTaylorMullen added a commit to aspnet/Mvc that referenced this issue Apr 26, 2017
- This enables 2.0.0 code generation to not error.

aspnet/Razor#1254
@NTaylorMullen
Copy link
Contributor

NTaylorMullen commented Apr 26, 2017

@rynowak
Copy link
Member

rynowak commented Apr 26, 2017

👍 🔥 🥈

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