Increase the reach of Code Lens and Code Map


My code lens does not see references to properties in my MVC views .cshtml files.


Install the Razor Generator extension.


While watching a great deep dive of Code Map by Jean-Marc Prieur he mentioned the Razor Generator as a way to enable features in Code Map and Code Lens.

Install both the Razor Generator Extension and the Razor Generator MVC nuget package.  Once the nuget package is installed you can run the Enable-RazorGenerator command from the Package Manager Console. This will cause the Razor Generator to update all your cshtml files so they use a custom tool installed by the Razor Generator extension.


This extension allows processing Razor files at design time instead of runtime, allowing tools like Code Map and Code Lens to walk the code and find the references.


Code Lens showing only 2 references



Code Lens showing 3 references


Code Map showing the view

Comments are closed