-
Notifications
You must be signed in to change notification settings - Fork 649
Usability improvement: Block script tags in components, giving explanation #553
Conversation
STILL TO DO: Replace the fake link in the error message with a real fwlink. |
a90638e
to
d1bfdfe
Compare
I propose we include this in 0.2.0. |
{ | ||
var adjustedSpan = CalculateSourcePosition(node.Source, tagToken.Position); | ||
var diagnostic = BlazorDiagnosticFactory.Create_DisallowedScriptTag(adjustedSpan); | ||
throw new RazorCompilerException(diagnostic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine for now, but keep in mind that any time you throw and catch in the compiler, that means that someone hitting the error will lose all intellisense and colorization in the rest of the file after this point. If at all possible, we should just skip the offending tag and its contents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that the case for code in the runtime node writer as well as the design-time one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with the runtime writer is that you won't run through the rest of the file, so if you throw here it will suppress any other errors in the file.
I don't have a problem with doing this as a temporary fix. I have a todo to remove all of these and the exception.
Note that (as expected) this doesn't prevent a script tag from being used when writing a component directly without Razor. |
Implementation for #552