Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error, cannot continue: The method 'ToStringJS' is not generic

For the last couple of days, each time I compile my solution (MVC 3 Web Application + several other projects) I get this error in the Error List:

Fatal error, cannot continue: The method 'ToStringJS' is not generic (Site.css, line 1, column 1).

Since the error is related to a css file obviously I can run the project.

I don't see errors in the css file.

Even if I delete all css file content, I keep getting this error.

However, the code highlighting disappeared, whilst intellisense and ReSharper keeps working.

I'm not sure where to look for this issue (Googling didn't bring any result, neither Stack Exchange or other specific sites). It might be a ReSharper issue, but I have actual means to blame R#, so I'd like to start from here, before contacting them.

like image 574
Andrea Sciamanna Avatar asked Oct 07 '11 18:10

Andrea Sciamanna


2 Answers

The error you guys are getting comes from Jurassic library which is used by Chirpy Add-In.

I did a short lookup in the Chirpy and Jurassic sources and I found the exact place where the exception is thrown and causes the issue you described.

In the Jurassic sources go to Jurassic\Compiler\Binders directory and open JSBinder.cs file. The problems occurs in the protected override void GenerateStub(ILGenerator generator, int argumentCount) method which itself is used to generate another method... yadayadayada. It's quite complex.

Anyway. Here's the code from that file that's responsible for the errors you're getting:

// Line 156 (Change Set df266524321d)
// Convert to the target type.
EmitTypeConversion(generator, typeof(object), argument.Type);

if (argument.Type != typeof(ObjectInstance) && inheritsFromObjectInstance == true)
{
   // EmitConversionToObjectInstance can emit null if the toType is derived from ObjectInstance.
   // Therefore, if the value emitted is null it means that the "thisObject" is a type derived
   // from ObjectInstance (e.g. FunctionInstance) and the value provided is a different type
   // (e.g. ArrayInstance).  In this case, throw an exception explaining that the function is
   // not generic.
   var endOfThrowLabel = generator.CreateLabel();
   generator.Duplicate();
   generator.BranchIfNotNull(endOfThrowLabel);
   generator.LoadArgument(0);
   EmitHelpers.EmitThrow(generator, "TypeError", string.Format("The method '{0}' is not generic", binderMethod.Name));
   generator.DefineLabelPosition(endOfThrowLabel);
}

If you would like to digg a bit deeper, you might take a look at the Jurassic\Library\Array\ArrayInstance.cs and Jurassic\Library\Object\ObjectInstance.cs where the public static string ToStringJS(ScriptEngine engine, object thisObject) is implemented. Also in the Chirpy lib the CSSLint.cs file contains a bit of interesting code lines (places where Jurassic is used).

I must admit, I don't know exactly why you're getting the "fatal error" or how the problem can be fixed. This would require quite a bit of testing/debuggin effort. Anyone?

Anyway, don't blame Resharper! It's great software ;-)

like image 76
nowaq Avatar answered Sep 18 '22 01:09

nowaq


The problem is with CSSLint. You can either download the source code and attempt to fix it, or you can simply disable it.

Go to Tools > Options > Chirpy > CssLint

Uncheck the 'Run CSS Lint' box.

If you encounter the same problem with JS, than disable the JSHint as well

like image 29
Segev -CJ- Shmueli Avatar answered Sep 20 '22 01:09

Segev -CJ- Shmueli