theron-wang/VS2022-Editor-Support-for-Tailwind-CSS

Object reference not set to an instance of an object in .NET 7 Blazor WASM + IntelliSense doesn't work

Closed this issue · 10 comments

Visual Studio Community 17.7.1

Tailwind CSS VS2022 Editor Support 1.1.7.6

Tailwind 3.3.3

Node v18.16.0

Npm 9.8.1

  • No Tailwind classes are being shown in IntelliSense
  • However, what's being shown in IS are classes that I already have in my output css file. If trying to use one of them, I'm getting Object reference (...) in .razor files, my index.html in wwwroot doesn't have that problem. After a quick test, I've noticed .cshtml files also work

tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
    content: [ "./Components/**/*.{razor, html, cshtml}",
               "./Shared/**/*.{razor, html, cshtml}",
               "./Pages/**/*.{razor, html, cshtml}",
               "./wwwroot/index.html" ],
  theme: {
    extend: {},
  },
  plugins: [],
}

Build proccess started in Build tab in VS. Output from Build doesn't show any errors

Regarding 2 issue - from what I see NRE is happening in RazorCompletionController.cs, line 245

if (!_currentSession.SelectedCompletionSet.SelectionStatus.IsSelected && !force)

_currentSession is not null, SelectedCompletionSet is null, CompletionSets throws exception
twvsexception

Thank you for providing the information, it was very helpful for me to fix the bug. Unfortunately, I don't have much time to test right now, but since I will be unavailable for much of the day, I added null checks for the code that you mentioned. I tested it briefly and it worked, so if you have time, please let me know if it works.

Thanks!

Looks like 2nd issue is resolved, 1st still occurs, no TW classes in IS

I've also noticed weird behaviour. I've correctly set up my input/output files, ran Tailwind build process, everything works. However, after restarting VS for some reason build process doesn't seem to pick up my output correctly and will generate *nameofmyinputclass*.output.css in the same directory as my input class. tailwind.extensions.json doesn't change after VS restart

Found a quick fix tho - right click on your output class, remove it as an output file and add it again as an output file

If your issue with IntelliSense was that the menu showed up, but the classes did not update as you typed (only options were things like hover: or active:), then I have found a fix for that (update not published yet).

As for your issue regarding the output file, can I have some more information? For example, when your build process is building to *nameofmyinputclass*.output.css instead of your specified file, is the OutputCssFile property in the tailwind.extension.json null, or is the path correct? Also, I am having trouble reproducing this issue - if you could provide some steps for me to follow, I would really appreciate that.

As for your issue regarding the output file, can I have some more information? For example, when your build process is building to *nameofmyinputclass*.output.css instead of your specified file, is the OutputCssFile property in the tailwind.extension.json null, or is the path correct? Also, I am having trouble reproducing this issue - if you could provide some steps for me to follow, I would really appreciate that.

  1. Set up Tailwind in your project, select config file, input file, output file
  2. Start build process with Build -> Start TailwindCSS build process. Everything should work correctly
  3. Restart VS
  4. Start build process once again with Build -> Start TailwindCSS build process. Now, a new .css file will be generated in the same directory as input file that will be named *nameofmyinputclass*.output.css. Correct output file will NOT change at all
  5. To fix, simply remove output file from acting as an output file and add it again as an output file

From point 1 to 4 OutputCssFile in tailwind.extension.json is never edited - it has the correct path throughout the whole process

I still can't seem to repro this issue. I'm thinking that the extension may not be able to find the extension file; do you have multiple projects in your solution? If so, are there tailwind.extension.json files in more than 1 of them?

I found a typo in my code, which I fixed in 1.1.7.8. It may be related to this issue, so you can update the extension and see if it fixes that behavior.

Looks like intellisense is working

I still can't seem to repro this issue. I'm thinking that the extension may not be able to find the extension file; do you have multiple projects in your solution? If so, are there tailwind.extension.json files in more than 1 of them?

Just one project

I've reproduced similar behavior when adding a new project to a solution. I'm unsure if the fix I just published fixes your issue as well - if you encounter this again, feel free to create a new issue (since this issue is about IntelliSense rather than build behavior).