You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the following code in .net core 3 mvc web project the scaffolding of views fails.
public class HomeController : Controller
{
public IActionResult About()
{
ViewData["Message"] = $"Built from commit: {ThisAssembly.Git.Sha}";
return View();
}
}
When trying to scaffold a view via add->View I get this:
Finding the generator 'view'...
Running the generator 'view'...
Could not get the reflection type for Model : SubscriptionViewModel
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
If I remove the {ThisAssembly.Git.Sha} I have no problem scaffolding a view.
Steps to reproduce in VS 2019:
File -> New project ASP .net Core Web Application
Give a name, Create
use .net core, ASP .net core 3.0, Web application (Model-Veiw-Controller)
Add this class to Models
namespace ScaffoldFail.Models
{
public class CustomerViewModel
{
public int MyProperty { get; set; }
}
}
Add nuget gitinfo version 2.0.21, latest at time of writing.
Add this to Home Controller:
public IActionResult About()
{
ViewData["Message"] = $"Built from commit: {ThisAssembly.Git.Sha}";
return View();
}
Right click Views (in solution explorer) -> Add -> view
View name: Details, Template: Details Model class: CustomerViewModel -> Click Add
After a while a dialog shows up saying 'Could not get the reflrction type for Model : CustomerViewModel'.
The Output window gives the following information:
Finding the generator 'view'...
Running the generator 'view'...
Could not get the reflection type for Model : CustomerViewModel
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
Modifying the line in HomeController to this:
public IActionResult About()
{
ViewData["Message"] = $"Built from commit: ";// {ThisAssembly.Git.Sha}";
return View();
}
and try to scaffold again (redo point 7 and 8 above) and the scaffolding does produce what it is supposed to. This means that using ThisAssembly.Git.Sha breaks the scaffolding of views.
The text was updated successfully, but these errors were encountered:
Doesn't look like there's anything actionable here. I tried with nothing but some other source generator based packages (any from ThisAssembly.* for example) and they also fail the same way. Looks like the way the scaffolding is using roslyn to build the project during scaffold doesn't properly support packages or analyzers or both. I've scanned many such issues all over. Seems to be a very brittle feature on the ASP.NET MVC side :(
When using the following code in .net core 3 mvc web project the scaffolding of views fails.
When trying to scaffold a view via add->View I get this:
If I remove the {ThisAssembly.Git.Sha} I have no problem scaffolding a view.
Steps to reproduce in VS 2019:
Details
, Template:Details
Model class:CustomerViewModel
-> Click AddAfter a while a dialog shows up saying 'Could not get the reflrction type for Model : CustomerViewModel'.
The Output window gives the following information:
Modifying the line in HomeController to this:
and try to scaffold again (redo point 7 and 8 above) and the scaffolding does produce what it is supposed to. This means that using ThisAssembly.Git.Sha breaks the scaffolding of views.
The text was updated successfully, but these errors were encountered: