aspnet / Razor

[Archived] Parser and code generator for CSHTML files used in view pages for MVC web apps. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
883 stars 225 forks source link

Custom TagHelper not being discovered by razor on VisualStudio 15.8.5 #2608

Closed cjlapao closed 6 years ago

cjlapao commented 6 years ago

All my custom TagHelpers stop being rendered by razor on VisualStudio and also not being rendered when the application started. This was working previously before the update.

capture

mkArtakMSFT commented 6 years ago

Thanks for contacting us, @cjlapao. Can you please share with us a sample repro project, which we can use to investigate the problem?

@NTaylorMullen, can you please look into this? Thanks!

cjlapao commented 6 years ago

Hi Artak,

But of course.

As you can see by the captured screens the taghelper is not recognised by the razor page. this was working recently. when compiling the custom tags are not processed and therefore the html is not rendered correctly or as expected.

To notice that the Microsoft.AspNetCore.Mvc.TagHelpers works correctly as expected, just not the ones i have created.

I have looked into the docs and downloaded the samples and have the same issue. that ones are not rendered.

I also already repaired the VisualStudio installation with no avail

this is a different project from the one i have showed earlier and running on a different machine that has the same problem

taghelpers1 taghelpers2

taghelpers3

NTaylorMullen commented 6 years ago

@cjlapao when typing C# in your Razor files do you get C# completion? Looking at your screenshots it looks like the C# experience is busted. I tried this out locally and didn't have an issue:

image

@vank-ms What other steps can @cjlapao take to repair his dev environment? He said he already repaired his VS.

cjlapao commented 6 years ago

On one of my projects changing the @addTagHelper just to contain the first part of the namespace fixed the issue

so I have changed the _ViewImports.cs to the following @using SysAdmin @using SysAdmin.Models @using SysAdmin.Models.ViewModels @using SysAdmin.Infrastructure @using SysAdmin.Infrastructure.Mail @addTagHelper *, SysAdmin @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

but the taghelper is in the namespace SysAdmin.Infrastructure and this was working previously

on the more complex project with a lot of taghelpers and a very complex structure of namespaces this change did not work.

i do have c# competion and also have the Microsoft.AspNetCore.Mvc.TagHelpers working when typing in my Razor files it just does not show the custom taghelpers i have created. This also does not get processed when compiling and therefore the page is renderend with the tag instead of the processed one

NTaylorMullen commented 6 years ago

Ah @cjlapao the @addTagHelper directive does not take a namespace it takes an assembly name. That would be your issue.

cjlapao commented 6 years ago

@NTaylorMullen

It now works fine on both projects as one of them had a assembly name change and I did not notice that the last part of the directive was the assembly name and not main namespace.

Thank you for your help.

NTaylorMullen commented 6 years ago

Glad everything is working!