I’ve found what appears to be a strangeness in VS 11 Beta Views regarding how Javascript is parsed and handled in Views. I’ve boiled it down to the smallest possible example to show the problem.
@section tester {
<script type="text/javascript">
function Something(direction) {
if (direction == "-") {
} else if (direction == "+") {
} else { // direction = "" or anything else
for (var idx = 0; idx < forms.length; idx++) {
}
}
}
</script>
}
This looks to me like it should be a valid (although meaningless) definition of a section which does something, however, VS11Beta doesn’t recognise it as a complete section for me. The final closing brace is not coloured yellow, and it reports a build error.
Removing any one of the JS sections (brace to brace) makes it work (the closing brace is coloured, etc.)
Can anyone repeat this, or is it just me? I don’t need a workaround, just some confirmation that this is actually a bug, and not something stupid at my end.
Thanks!
This was confirmed as a bug by Microsoft, will be fixed in the next release.
http://connect.microsoft.com/VisualStudio/feedback/details/736777/vs-11-beta-possible-razor-parser-bug