Question

I wrote a small web app using Nancy. I was originally using ASP.NET hosting, but I decided to try Nancy self hosting so I could deploy the app easily to any Windows machine. This involved replacing my ASP.NET Empty Web Application with a Console Application.

Pretty much everything is working well, but I've run into an issue where using certain window functions, such as alert() or escape(), in the JavaScript editor causes ReSharper warnings.

Here's how it looks in the editor:

"alert" underlined with a blue squiggle

I could always disable these warnings (or add window. before every call), but I'm wondering if there's anything I can do to have these functions recognized as if my project were an ASP.NET app.

Edit

If I return to my original project (the ASP.NET app) and type alert, here is what I see:

alert (in DHtml.js)

Could this mean that DHtml.js doesn't get loaded/included for console apps? Is there a way to make that happen?

Was it helpful?

Solution

When you create a web project, ReSharper adds some "hidden" js files to its cache that provide definitions for global objects, including the "Dhtml.js" file you mention. These files aren't added for console applications. There's no decent workaround here - ReSharper's web support is primarily based on the idea that you're in a web project of some kind, so there will be other features that are not enabled due to the fact that you're in a console app project.

However, it looks like it's possible to replicate what ReSharper does to add these files from a plugin - instead of looking to see if the project is a web project, it should look to see if it's a console app that also references Nancy. If so, tell ReSharper to internally reference these "hidden" files. I'd suggest posting a feature request to the Nancy ReSharper plugin project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top