11

So far I can't find a question or fix for this. I'm sure it's something simple I'm missing.

I have a style bundle with a bunch of minified CSS, and I am decorating HTML elements with the classes inside. Everything is working great.

Intellisense and ReSharper however are both bugging me about the CSS the classes being unknown. I'm guessing this is because they cannot peek inside the bundles.

Question: Is there a way to fix this?

<!-- Style Bundles in HEAD tag-->
@Styles.Render("~/bundle/style/css")
@RenderSection("styles", false);

<!-- HTML elements in BODY tag: "row" is an unknown css class -->
<div class="row">
    <p>Lorem ipsum</p>
</div>

Update: Visual Studio 2012. LESS conversion and intellisense works for single directly referenced files. My situation is that intellisense breaks when referencing a LESS bundle.

Update 2: Here's the code showing the BundleConfig.cs since it isnt clear

var customStyles = new Bundle("~/bundle/style/css")
                      .Include("~/Content/normalize.css","~/Content/*.less");
bootstrapStyles.Transforms.Add(new LessTransform());
bootstrapStyles.Transforms.Add(new CssMinify());
bundles.Add(customStyles);

Notice we are using Bundle not StyleBundle which is necessary because we want to specify the LessTransform() class and skip the built in CSS transformer. The LessTransform object is a custom object that simply reads in all the LESS content and concatenates it on a StringBuilder and then calls dotless's converter... out comes a huge CSS string that is minified and returned. The question is why cant VS or ReSharper peek at the returned CSS and help check class styles?

SteveC
  • 15,808
  • 23
  • 102
  • 173
one.beat.consumer
  • 9,414
  • 11
  • 55
  • 98
  • Where have you got your stylesheets, in a content folder? Is the above code all in a layout? – dove Oct 11 '12 at 21:41
  • @dove: neither matters. the point is, the class "row" exists inside the bundle referenced, yet Visual Studio and ReSharper are both complaining that it cannot see "row" inside the bundled style. when rendered in a browser though it works fine. – one.beat.consumer Oct 11 '12 at 23:55
  • http://stackoverflow.com/questions/4973604/how-to-turn-on-visual-studio-2010-css-intellisense-on-less-file – VJAI Oct 16 '12 at 12:37
  • @Mark thank you for the link, but it's not the answer. I am using Visual Studio 2012 and Intellisense works fine for single `.less` files, it is only when referencing a style/less bundle. Bounty has 2 days left; don't let it go wasted :) – one.beat.consumer Oct 16 '12 at 16:55

2 Answers2

4

Here's a post on jetbrains blog. It's a bit out of date, but Jura went on record stating that there were no plans on supporting LESS (yet).

User:

Are there any plans to support LESS? I don’t care a whole lot about full support, but it would sure be nice if it could at least bring highlighting and code completion support into .less files and have it handle nested rules.

Jura Gorohovsky :

No, no such plans yet. Can you point me to a publicly available project that uses LESS extensively so that we can take a look at it to determine the scope of work?

Link

Late edit: Web WorkBench from Mindscape may provide what some people coming to this thread are looking for. They are very response to bug fixes, and have been making some solid improvements to intellisense in the LESS world.

samuelesque
  • 1,165
  • 13
  • 30
  • 1
    I appreciate the answer, and gave you a bump for it, but I'm nearly positive the issue lies with the bundling... after using the LESS transformer object, the bundle is just one massive swarm of CSS, in which case Intellisense (not ReSharper) should pick up on classes/etc. – one.beat.consumer Oct 16 '12 at 22:05
  • I appreciate the bump. Is wildcard loading an option? Generally speaking, bundles seem to be the preference, but if you -need- Intellisense, you might consider giving it a shot? – samuelesque Oct 17 '12 at 17:03
  • can you explain what you mean with wildcard loading? – one.beat.consumer Oct 17 '12 at 17:10
  • Depending on how your css files are "bundled" you might be able to get away with doing something like "Include("~/Styles/Common/*.css")". You lose the efficiency that you were gaining from using the bundles, but you gain intellisense. Towards the bottom of this page: http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification there is a section titled Using the "*" Wildcard Character to Select Files. It may not be an option, depending on how your files are stored. If you're using something like dotless, you're out of luck. If it's just bundled css, it might be an option. – samuelesque Oct 17 '12 at 17:23
  • See the update... i added the code going on behind the scenes of the bundling – one.beat.consumer Oct 17 '12 at 20:02
  • 1
    I gave you the bounty because you're the only one who gave it a fair shot, and provided something related to the question. Thanks. – one.beat.consumer Oct 18 '12 at 19:44
  • Appreciate it. Sorry we couldn't pinpoint it down any further for you. – samuelesque Oct 19 '12 at 13:23
-3

Have you installed the js extension to Visual Studio 2012? Go to Tools | Extensions and Updates and then SDKs if you have many installed.

enter image description here

Don't think the bundling has any affect on your intellisense, I've tried with and without and my intellisense is still there. Ensure you css stylesheet is included in your solution and maybe test with a more specific class, e.g. "onebeatconsumer" instead of "row" (there could be a clash somewhere with this)

If you are using LESS, this could most definitely be your issue as it visual might well not be able to parse LESS syntax as it only generates the full styles at runtime. Does styles in a standard css stylesheet work okay for you?

dove
  • 20,469
  • 14
  • 82
  • 108
  • VS patch in Nuget? Would it not be a full blown Extension instead of a project package? post more info please and I'll investigate – one.beat.consumer Oct 11 '12 at 23:51
  • correct it is not a package but now can't remember exactly what they called it and there is no history of it in about or package manager. it definitely had to do with js and css – dove Oct 12 '12 at 07:36
  • are you stylesheets in your solution? – dove Oct 12 '12 at 07:36
  • 1
    if you are talking about the "Extensions for Windows Library for JavaScript" it is installed and up to date. How in the world does this affect the Intellisense capability of Visual Studio to extract classes from an unconverted LESS file? – one.beat.consumer Oct 12 '12 at 22:28
  • not sure how but it does hint it might affect css style resources given it's descriptions. of more interesting note is that you are using LESS?! This could most definitely be your issue as it visual might well not be able to parse LESS syntax as it only generates the full styles at runtime. I'll update answer with this note. – dove Oct 13 '12 at 13:01