This project is read-only.


Breaking razor change reports incorrect error, "} expected"


in v1, the following was legal (in that: it worked) in razor, in a code region:
string foo = @Some.Complex.Expression;
obviously the @ is redundant, but: it worked. When upgrading to v2, it errors (which I could respect), but in the wrong way. It should say something about the @ being illegal in that syntax; instead, this can manifest in "} expected", especially if this is inside an if-block etc. The correct code is of course:
string foo = Some.Complex.Expression;
but the error message "} expected" makes the developer look for the wrong thing.
Closed Jun 14, 2013 at 7:52 PM by yishaigalatzer
Hey Marc,

This is a really great comment. We discovered this a while ago as well, and it's unfortunate that this doesn't work, as the @ is a valid C#, but it collides with the Razor @. Your suggestion is correct, and the code should be written without the @. However fixing the parser is rather complex, and we are concerned with introducing regressions for this case. So we decided not to fix. If you feel strongly that this is critical please let us know.

The MVC team.