Remove error for "@" in nested codeblocks.

Also removed the corresponding test and resource for this change.

#64
This commit is contained in:
N. Taylor Mullen 2014-06-09 16:58:17 -07:00
parent 9afab74b8c
commit 8099dcda63
4 changed files with 3 additions and 31 deletions

View File

@ -507,13 +507,7 @@ namespace Microsoft.AspNet.Razor.Parser
else else
{ {
// Throw errors as necessary, but continue parsing // Throw errors as necessary, but continue parsing
if (At(CSharpSymbolType.Keyword)) if (At(CSharpSymbolType.LeftBrace))
{
Context.OnError(CurrentLocation,
RazorResources.FormatParseError_Unexpected_Keyword_After_At(
CSharpLanguageCharacteristics.GetKeyword(CurrentSymbol.Keyword.Value)));
}
else if (At(CSharpSymbolType.LeftBrace))
{ {
Context.OnError(CurrentLocation, RazorResources.ParseError_Unexpected_Nested_CodeBlock); Context.OnError(CurrentLocation, RazorResources.ParseError_Unexpected_Nested_CodeBlock);
} }

View File

@ -694,22 +694,6 @@ namespace Microsoft.AspNet.Razor
return GetString("Parser_Context_Not_Set"); return GetString("Parser_Context_Not_Set");
} }
/// <summary>
/// Unexpected "{0}" keyword after "@" character. Once inside code, you do not need to prefix constructs like "{0}" with "@".
/// </summary>
internal static string ParseError_Unexpected_Keyword_After_At
{
get { return GetString("ParseError_Unexpected_Keyword_After_At"); }
}
/// <summary>
/// Unexpected "{0}" keyword after "@" character. Once inside code, you do not need to prefix constructs like "{0}" with "@".
/// </summary>
internal static string FormatParseError_Unexpected_Keyword_After_At(object p0)
{
return string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Unexpected_Keyword_After_At"), p0);
}
/// <summary> /// <summary>
/// "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. /// "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used.
/// </summary> /// </summary>

View File

@ -264,9 +264,6 @@ Instead, wrap the contents of the block in "{{}}":
<data name="Parser_Context_Not_Set" xml:space="preserve"> <data name="Parser_Context_Not_Set" xml:space="preserve">
<value>Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser.</value> <value>Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser.</value>
</data> </data>
<data name="ParseError_Unexpected_Keyword_After_At" xml:space="preserve">
<value>Unexpected "{0}" keyword after "@" character. Once inside code, you do not need to prefix constructs like "{0}" with "@".</value>
</data>
<data name="ParseError_ReservedWord" xml:space="preserve"> <data name="ParseError_ReservedWord" xml:space="preserve">
<value>"{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used.</value> <value>"{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used.</value>
</data> </data>

View File

@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
} }
[Fact] [Fact]
public void NestedCodeBlockWithAtCausesError() public void NestedCodeBlockWithAtDoesntCauseError()
{ {
ParseBlockTest("if (true) { @if(false) { } }", ParseBlockTest("if (true) { @if(false) { } }",
new StatementBlock( new StatementBlock(
@ -44,10 +44,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.CodeTransition(), Factory.CodeTransition(),
Factory.Code("if(false) { }").AsStatement() Factory.Code("if(false) { }").AsStatement()
), ),
Factory.Code(" }").AsStatement()), Factory.Code(" }").AsStatement()));
new RazorError(
RazorResources.FormatParseError_Unexpected_Keyword_After_At("if"),
new SourceLocation(13, 0, 13)));
} }
[Fact] [Fact]