Lombiq / Lombiq-Orchard-Visual-Studio-Extension

Visual Studio extension to help our work at Lombiq (https://lombiq.com/), mainly with Orchard Core (and Orchard CMS) development.
13 stars 7 forks source link

Dependency Injector does not work with Razor Pages (VSIX-65) #39

Open DrewBrasher opened 5 months ago

DrewBrasher commented 5 months ago

If I try to use the Dependency Injector in the .cshtml.cs file of a Razor Page, it gets the error: "Could not inject dependency because the class was not found in his file"

image

Jira issue

DrewBrasher commented 5 months ago

I think this issue is because Razor Pages file names do not match the class names. So this method: https://github.com/Lombiq/Lombiq-Orchard-Visual-Studio-Extension/blob/2a82482674025f884de179247dde0d5d579f1c5b/Lombiq.Vsix.Orchard/Services/DependencyInjector/DependencyInjector.cs#L90-L96 for a file called Index.cshtml.cs would return Index.cshtml but the actual class name is IndexModel.

DrewBrasher commented 2 months ago

I created pull request https://github.com/Lombiq/Lombiq-Orchard-Visual-Studio-Extension/pull/40 to add support for this.