Refactor some pieces of Razor.
- String => string - Updated RazorTemplateEngine to have better spacing.
This commit is contained in:
parent
744c9c47b4
commit
9722319762
|
|
@ -50,7 +50,7 @@ namespace Microsoft.AspNet.Razor.Parser.SyntaxTree
|
||||||
var other = obj as AutoCompleteEditHandler;
|
var other = obj as AutoCompleteEditHandler;
|
||||||
return base.Equals(obj) &&
|
return base.Equals(obj) &&
|
||||||
other != null &&
|
other != null &&
|
||||||
String.Equals(other.AutoCompleteString, AutoCompleteString, StringComparison.Ordinal) &&
|
string.Equals(other.AutoCompleteString, AutoCompleteString, StringComparison.Ordinal) &&
|
||||||
AutoCompleteAtEndOfSpan == other.AutoCompleteAtEndOfSpan;
|
AutoCompleteAtEndOfSpan == other.AutoCompleteAtEndOfSpan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Razor.Editor
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format(CultureInfo.InvariantCulture, "{0};ImplicitExpression[{1}];K{2}", base.ToString(), AcceptTrailingDot ? "ATD" : "RTD", Keywords.Count);
|
return string.Format(CultureInfo.InvariantCulture, "{0};ImplicitExpression[{1}];K{2}", base.ToString(), AcceptTrailingDot ? "ATD" : "RTD", Keywords.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
@ -134,7 +134,7 @@ namespace Microsoft.AspNet.Razor.Editor
|
||||||
{
|
{
|
||||||
// Do not need to worry about other punctuation, just looking for double '.' (after change)
|
// Do not need to worry about other punctuation, just looking for double '.' (after change)
|
||||||
return change.NewLength == 1 &&
|
return change.NewLength == 1 &&
|
||||||
!String.IsNullOrEmpty(target.Content) &&
|
!string.IsNullOrEmpty(target.Content) &&
|
||||||
target.Content.Last() == '.' &&
|
target.Content.Last() == '.' &&
|
||||||
change.NewText == "." &&
|
change.NewText == "." &&
|
||||||
change.OldLength == 0;
|
change.OldLength == 0;
|
||||||
|
|
@ -187,7 +187,7 @@ namespace Microsoft.AspNet.Razor.Editor
|
||||||
private static bool RemainingIsWhitespace(Span target, TextChange change)
|
private static bool RemainingIsWhitespace(Span target, TextChange change)
|
||||||
{
|
{
|
||||||
var offset = (change.OldPosition - target.Start.AbsoluteIndex) + change.OldLength;
|
var offset = (change.OldPosition - target.Start.AbsoluteIndex) + change.OldLength;
|
||||||
return String.IsNullOrWhiteSpace(target.Content.Substring(offset));
|
return string.IsNullOrWhiteSpace(target.Content.Substring(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
private PartialParseResult HandleDotlessCommitInsertion(Span target)
|
private PartialParseResult HandleDotlessCommitInsertion(Span target)
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Razor.Editor
|
||||||
// No Trace in CoreCLR
|
// No Trace in CoreCLR
|
||||||
|
|
||||||
Trace.WriteLine(RazorResources.FormatTrace_Format(
|
Trace.WriteLine(RazorResources.FormatTrace_Format(
|
||||||
String.Format(CultureInfo.CurrentCulture, format, args)));
|
string.Format(CultureInfo.CurrentCulture, format, args)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ namespace Microsoft.AspNet.Razor.Editor
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return GetType().Name + ";Accepts:" + AcceptedCharacters + ((EditorHints == EditorHints.None) ? String.Empty : (";Hints: " + EditorHints.ToString()));
|
return GetType().Name + ";Accepts:" + AcceptedCharacters + ((EditorHints == EditorHints.None) ? string.Empty : (";Hints: " + EditorHints.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
{
|
{
|
||||||
var ns = Namespace;
|
var ns = Namespace;
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(ns) && Char.IsWhiteSpace(ns[0]))
|
if (!string.IsNullOrEmpty(ns) && Char.IsWhiteSpace(ns[0]))
|
||||||
{
|
{
|
||||||
ns = ns.Substring(1);
|
ns = ns.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
{
|
{
|
||||||
var other = obj as AddImportCodeGenerator;
|
var other = obj as AddImportCodeGenerator;
|
||||||
return other != null &&
|
return other != null &&
|
||||||
String.Equals(Namespace, other.Namespace, StringComparison.Ordinal) &&
|
string.Equals(Namespace, other.Namespace, StringComparison.Ordinal) &&
|
||||||
NamespaceKeywordLength == other.NamespaceKeywordLength;
|
NamespaceKeywordLength == other.NamespaceKeywordLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,14 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format(CultureInfo.CurrentCulture, "Attr:{0},{1:F},{2:F}", Name, Prefix, Suffix);
|
return string.Format(CultureInfo.CurrentCulture, "Attr:{0},{1:F},{2:F}", Name, Prefix, Suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
var other = obj as AttributeBlockCodeGenerator;
|
var other = obj as AttributeBlockCodeGenerator;
|
||||||
return other != null &&
|
return other != null &&
|
||||||
String.Equals(other.Name, Name, StringComparison.Ordinal) &&
|
string.Equals(other.Name, Name, StringComparison.Ordinal) &&
|
||||||
Equals(other.Prefix, Prefix) &&
|
Equals(other.Prefix, Prefix) &&
|
||||||
Equals(other.Suffix, Suffix);
|
Equals(other.Suffix, Suffix);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||||
public CSharpCodeWriter WriteVariableDeclaration(string type, string name, string value)
|
public CSharpCodeWriter WriteVariableDeclaration(string type, string name, string value)
|
||||||
{
|
{
|
||||||
Write(type).Write(" ").Write(name);
|
Write(type).Write(" ").Write(name);
|
||||||
if (!String.IsNullOrEmpty(value))
|
if (!string.IsNullOrEmpty(value))
|
||||||
{
|
{
|
||||||
Write(" = ").Write(value);
|
Write(" = ").Write(value);
|
||||||
}
|
}
|
||||||
|
|
@ -145,7 +145,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||||
|
|
||||||
public CSharpCodeWriter WriteUsing(string name, bool endLine)
|
public CSharpCodeWriter WriteUsing(string name, bool endLine)
|
||||||
{
|
{
|
||||||
Write(String.Format("using {0}", name));
|
Write(string.Format("using {0}", name));
|
||||||
|
|
||||||
if (endLine)
|
if (endLine)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||||
if (_host.DesignTimeMode &&
|
if (_host.DesignTimeMode &&
|
||||||
padding > 0 &&
|
padding > 0 &&
|
||||||
target.Previous.Kind == SpanKind.Transition && // target.Previous is guaranteed to not be null if you have padding.
|
target.Previous.Kind == SpanKind.Transition && // target.Previous is guaranteed to not be null if you have padding.
|
||||||
String.Equals(target.Previous.Content, SyntaxConstants.TransitionString, StringComparison.Ordinal))
|
string.Equals(target.Previous.Content, SyntaxConstants.TransitionString, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
padding--;
|
padding--;
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||||
// When scanning previous spans we need to be break down the spans with spaces. The parser combines
|
// When scanning previous spans we need to be break down the spans with spaces. The parser combines
|
||||||
// whitespace into existing spans so you'll see tabs, newlines etc. within spans. We only care about
|
// whitespace into existing spans so you'll see tabs, newlines etc. within spans. We only care about
|
||||||
// the \t in existing spans.
|
// the \t in existing spans.
|
||||||
var previousContent = firstSpanInLine.Previous.Content ?? String.Empty;
|
var previousContent = firstSpanInLine.Previous.Content ?? string.Empty;
|
||||||
|
|
||||||
var lastNewLineIndex = previousContent.LastIndexOfAny(_newLineChars);
|
var lastNewLineIndex = previousContent.LastIndexOfAny(_newLineChars);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||||
|
|
||||||
protected override void Visit(SetLayoutChunk chunk)
|
protected override void Visit(SetLayoutChunk chunk)
|
||||||
{
|
{
|
||||||
if (!Context.Host.DesignTimeMode && !String.IsNullOrEmpty(Context.Host.GeneratedClassContext.LayoutPropertyName))
|
if (!Context.Host.DesignTimeMode && !string.IsNullOrEmpty(Context.Host.GeneratedClassContext.LayoutPropertyName))
|
||||||
{
|
{
|
||||||
Writer.Write(Context.Host.GeneratedClassContext.LayoutPropertyName)
|
Writer.Write(Context.Host.GeneratedClassContext.LayoutPropertyName)
|
||||||
.Write(" = ")
|
.Write(" = ")
|
||||||
|
|
@ -110,7 +110,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||||
|
|
||||||
protected override void Visit(ResolveUrlChunk chunk)
|
protected override void Visit(ResolveUrlChunk chunk)
|
||||||
{
|
{
|
||||||
if (!Context.Host.DesignTimeMode && String.IsNullOrEmpty(chunk.Url))
|
if (!Context.Host.DesignTimeMode && string.IsNullOrEmpty(chunk.Url))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||||
Writer.WriteStartInstrumentationContext(Context, chunk.Association, isLiteral: false);
|
Writer.WriteStartInstrumentationContext(Context, chunk.Association, isLiteral: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(chunk.Url) && !Context.Host.DesignTimeMode)
|
if (!string.IsNullOrEmpty(chunk.Url) && !Context.Host.DesignTimeMode)
|
||||||
{
|
{
|
||||||
if (Context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput)
|
if (Context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput)
|
||||||
{
|
{
|
||||||
|
|
@ -320,7 +320,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(Context.TargetWriterName))
|
if (!string.IsNullOrEmpty(Context.TargetWriterName))
|
||||||
{
|
{
|
||||||
Writer.WriteStartMethodInvocation(Context.Host.GeneratedClassContext.WriteAttributeToMethodName)
|
Writer.WriteStartMethodInvocation(Context.Host.GeneratedClassContext.WriteAttributeToMethodName)
|
||||||
.Write(Context.TargetWriterName)
|
.Write(Context.TargetWriterName)
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||||
|
|
||||||
protected override void Visit(TypeMemberChunk chunk)
|
protected override void Visit(TypeMemberChunk chunk)
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(chunk.Code))
|
if (!string.IsNullOrEmpty(chunk.Code))
|
||||||
{
|
{
|
||||||
_csharpCodeVisitor.CreateCodeMapping(String.Empty, chunk.Code, chunk);
|
_csharpCodeVisitor.CreateCodeMapping(string.Empty, chunk.Code, chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format(CultureInfo.CurrentCulture, "DynAttr:{0:F}", Prefix);
|
return string.Format(CultureInfo.CurrentCulture, "DynAttr:{0:F}", Prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,11 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
{
|
{
|
||||||
if (ValueGenerator == null)
|
if (ValueGenerator == null)
|
||||||
{
|
{
|
||||||
return String.Format(CultureInfo.CurrentCulture, "LitAttr:{0:F},{1:F}", Prefix, Value);
|
return string.Format(CultureInfo.CurrentCulture, "LitAttr:{0:F},{1:F}", Prefix, Value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return String.Format(CultureInfo.CurrentCulture, "LitAttr:{0:F},<Sub:{1:F}>", Prefix, ValueGenerator);
|
return string.Format(CultureInfo.CurrentCulture, "LitAttr:{0:F},<Sub:{1:F}>", Prefix, ValueGenerator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
|
|
||||||
protected RazorCodeGenerator(string className, string rootNamespaceName, string sourceFileName, RazorEngineHost host)
|
protected RazorCodeGenerator(string className, string rootNamespaceName, string sourceFileName, RazorEngineHost host)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(className))
|
if (string.IsNullOrEmpty(className))
|
||||||
{
|
{
|
||||||
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "className");
|
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "className");
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
ClassName = className;
|
ClassName = className;
|
||||||
RootNamespaceName = rootNamespaceName;
|
RootNamespaceName = rootNamespaceName;
|
||||||
SourceFileName = sourceFileName;
|
SourceFileName = sourceFileName;
|
||||||
GenerateLinePragmas = String.IsNullOrEmpty(SourceFileName) ? false : true;
|
GenerateLinePragmas = string.IsNullOrEmpty(SourceFileName) ? false : true;
|
||||||
Host = host;
|
Host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
||||||
{
|
{
|
||||||
// Check if the host supports it
|
// Check if the host supports it
|
||||||
if (String.IsNullOrEmpty(context.Host.GeneratedClassContext.ResolveUrlMethodName))
|
if (string.IsNullOrEmpty(context.Host.GeneratedClassContext.ResolveUrlMethodName))
|
||||||
{
|
{
|
||||||
// Nope, just use the default MarkupCodeGenerator behavior
|
// Nope, just use the default MarkupCodeGenerator behavior
|
||||||
new MarkupCodeGenerator().GenerateCode(target, context);
|
new MarkupCodeGenerator().GenerateCode(target, context);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
var other = obj as SectionCodeGenerator;
|
var other = obj as SectionCodeGenerator;
|
||||||
return other != null &&
|
return other != null &&
|
||||||
base.Equals(other) &&
|
base.Equals(other) &&
|
||||||
String.Equals(SectionName, other.SectionName, StringComparison.Ordinal);
|
string.Equals(SectionName, other.SectionName, StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
{
|
{
|
||||||
var other = obj as SetBaseTypeCodeGenerator;
|
var other = obj as SetBaseTypeCodeGenerator;
|
||||||
return other != null &&
|
return other != null &&
|
||||||
String.Equals(BaseType, other.BaseType, StringComparison.Ordinal);
|
string.Equals(BaseType, other.BaseType, StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
var other = obj as SetLayoutCodeGenerator;
|
var other = obj as SetLayoutCodeGenerator;
|
||||||
return other != null && String.Equals(other.LayoutPath, LayoutPath, StringComparison.Ordinal);
|
return other != null && string.Equals(other.LayoutPath, LayoutPath, StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
IEnumerable<CSharpSymbol> ws = ReadWhile(IsSpacingToken(includeNewLines: true, includeComments: false));
|
IEnumerable<CSharpSymbol> ws = ReadWhile(IsSpacingToken(includeNewLines: true, includeComments: false));
|
||||||
|
|
||||||
// Get the section name
|
// Get the section name
|
||||||
var sectionName = String.Empty;
|
var sectionName = string.Empty;
|
||||||
if (!Required(CSharpSymbolType.Identifier,
|
if (!Required(CSharpSymbolType.Identifier,
|
||||||
errorIfNotFound: true,
|
errorIfNotFound: true,
|
||||||
errorBase: RazorResources.FormatParseError_Unexpected_Character_At_Section_Name_Start))
|
errorBase: RazorResources.FormatParseError_Unexpected_Character_At_Section_Name_Start))
|
||||||
|
|
@ -236,7 +236,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
protected void AssertDirective(string directive)
|
protected void AssertDirective(string directive)
|
||||||
{
|
{
|
||||||
Assert(CSharpSymbolType.Identifier);
|
Assert(CSharpSymbolType.Identifier);
|
||||||
Debug.Assert(String.Equals(CurrentSymbol.Content, directive, StringComparison.Ordinal));
|
Debug.Assert(string.Equals(CurrentSymbol.Content, directive, StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void InheritsDirectiveCore()
|
protected void InheritsDirectiveCore()
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
// If necessary, put an empty-content marker symbol here
|
// If necessary, put an empty-content marker symbol here
|
||||||
if (Span.Symbols.Count == 0)
|
if (Span.Symbols.Count == 0)
|
||||||
{
|
{
|
||||||
Accept(new CSharpSymbol(CurrentLocation, String.Empty, CSharpSymbolType.Unknown));
|
Accept(new CSharpSymbol(CurrentLocation, string.Empty, CSharpSymbolType.Unknown));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output the content span and then capture the ")"
|
// Output the content span and then capture the ")"
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
|
|
||||||
public override CSharpSymbol CreateMarkerSymbol(SourceLocation location)
|
public override CSharpSymbol CreateMarkerSymbol(SourceLocation location)
|
||||||
{
|
{
|
||||||
return new CSharpSymbol(location, String.Empty, CSharpSymbolType.Unknown);
|
return new CSharpSymbol(location, string.Empty, CSharpSymbolType.Unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override CSharpSymbolType GetKnownSymbolType(KnownSymbolType type)
|
public override CSharpSymbolType GetKnownSymbolType(KnownSymbolType type)
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
protected override SyntaxTreeNode RewriteBlock(BlockBuilder parent, Block block)
|
protected override SyntaxTreeNode RewriteBlock(BlockBuilder parent, Block block)
|
||||||
{
|
{
|
||||||
// Collect the content of this node
|
// Collect the content of this node
|
||||||
var content = String.Concat(block.Children.Cast<Span>().Select(s => s.Content));
|
var content = string.Concat(block.Children.Cast<Span>().Select(s => s.Content));
|
||||||
|
|
||||||
// Create a new span containing this content
|
// Create a new span containing this content
|
||||||
var span = new SpanBuilder();
|
var span = new SpanBuilder();
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
|
|
||||||
public override HtmlSymbol CreateMarkerSymbol(SourceLocation location)
|
public override HtmlSymbol CreateMarkerSymbol(SourceLocation location)
|
||||||
{
|
{
|
||||||
return new HtmlSymbol(location, String.Empty, HtmlSymbolType.Unknown);
|
return new HtmlSymbol(location, string.Empty, HtmlSymbolType.Unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override HtmlSymbolType GetKnownSymbolType(KnownSymbolType type)
|
public override HtmlSymbolType GetKnownSymbolType(KnownSymbolType type)
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
|
|
||||||
private bool CData()
|
private bool CData()
|
||||||
{
|
{
|
||||||
if (CurrentSymbol.Type == HtmlSymbolType.Text && String.Equals(CurrentSymbol.Content, "cdata", StringComparison.OrdinalIgnoreCase))
|
if (CurrentSymbol.Type == HtmlSymbolType.Text && string.Equals(CurrentSymbol.Content, "cdata", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (AcceptAndMoveNext())
|
if (AcceptAndMoveNext())
|
||||||
{
|
{
|
||||||
|
|
@ -521,7 +521,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capture the suffix
|
// Capture the suffix
|
||||||
LocationTagged<string> suffix = new LocationTagged<string>(String.Empty, CurrentLocation);
|
LocationTagged<string> suffix = new LocationTagged<string>(string.Empty, CurrentLocation);
|
||||||
if (quote != HtmlSymbolType.Unknown && At(quote))
|
if (quote != HtmlSymbolType.Unknown && At(quote))
|
||||||
{
|
{
|
||||||
suffix = CurrentSymbol.GetContent();
|
suffix = CurrentSymbol.GetContent();
|
||||||
|
|
@ -967,7 +967,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
while (tags.Count > 0)
|
while (tags.Count > 0)
|
||||||
{
|
{
|
||||||
currentTag = tags.Pop();
|
currentTag = tags.Pop();
|
||||||
if (String.Equals(tagName, currentTag.Item1.Content, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(tagName, currentTag.Item1.Content, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// Matched the tag
|
// Matched the tag
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -90,14 +90,14 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
private bool AtEnd(string[] nestingSequenceComponents)
|
private bool AtEnd(string[] nestingSequenceComponents)
|
||||||
{
|
{
|
||||||
EnsureCurrent();
|
EnsureCurrent();
|
||||||
if (String.Equals(CurrentSymbol.Content, nestingSequenceComponents[0], Comparison))
|
if (string.Equals(CurrentSymbol.Content, nestingSequenceComponents[0], Comparison))
|
||||||
{
|
{
|
||||||
var bookmark = CurrentSymbol.Start.AbsoluteIndex;
|
var bookmark = CurrentSymbol.Start.AbsoluteIndex;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (string component in nestingSequenceComponents)
|
foreach (string component in nestingSequenceComponents)
|
||||||
{
|
{
|
||||||
if (!EndOfFile && !String.Equals(CurrentSymbol.Content, component, Comparison))
|
if (!EndOfFile && !string.Equals(CurrentSymbol.Content, component, Comparison))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +143,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
position + sequence.Length <= CurrentSymbol.Content.Length)
|
position + sequence.Length <= CurrentSymbol.Content.Length)
|
||||||
{
|
{
|
||||||
var possibleStart = CurrentSymbol.Content.Substring(position, sequence.Length);
|
var possibleStart = CurrentSymbol.Content.Substring(position, sequence.Length);
|
||||||
if (String.Equals(possibleStart, sequence, Comparison))
|
if (string.Equals(possibleStart, sequence, Comparison))
|
||||||
{
|
{
|
||||||
// Capture the current symbol and "put it back" (really we just want to clear CurrentSymbol)
|
// Capture the current symbol and "put it back" (really we just want to clear CurrentSymbol)
|
||||||
var bookmark = Context.Source.Position;
|
var bookmark = Context.Source.Position;
|
||||||
|
|
@ -159,7 +159,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
var postSequence = pair.Item2;
|
var postSequence = pair.Item2;
|
||||||
|
|
||||||
// Accept the first chunk (up to the nesting sequence we just saw)
|
// Accept the first chunk (up to the nesting sequence we just saw)
|
||||||
if (!String.IsNullOrEmpty(preSequence.Content))
|
if (!string.IsNullOrEmpty(preSequence.Content))
|
||||||
{
|
{
|
||||||
Accept(preSequence);
|
Accept(preSequence);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
public static bool IsNewLine(string value)
|
public static bool IsNewLine(string value)
|
||||||
{
|
{
|
||||||
return (value.Length == 1 && (IsNewLine(value[0]))) ||
|
return (value.Length == 1 && (IsNewLine(value[0]))) ||
|
||||||
(String.Equals(value, "\r\n", StringComparison.Ordinal));
|
(string.Equals(value, "\r\n", StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the character is Whitespace and NOT a newline
|
// Returns true if the character is Whitespace and NOT a newline
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ namespace Microsoft.AspNet.Razor.Parser.SyntaxTree
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format(CultureInfo.CurrentCulture, "{0} Block at {1}::{2} (Gen:{3})", Type, Start, Length, CodeGenerator);
|
return string.Format(CultureInfo.CurrentCulture, "{0} Block at {1}::{2} (Gen:{3})", Type, Start, Length, CodeGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ namespace Microsoft.AspNet.Razor.Parser.SyntaxTree
|
||||||
builder.Append(" Gen: <");
|
builder.Append(" Gen: <");
|
||||||
builder.Append(CodeGenerator.ToString());
|
builder.Append(CodeGenerator.ToString());
|
||||||
builder.Append("> {");
|
builder.Append("> {");
|
||||||
builder.Append(String.Join(";", Symbols.GroupBy(sym => sym.GetType()).Select(grp => String.Concat(grp.Key.Name, ":", grp.Count()))));
|
builder.Append(string.Join(";", Symbols.GroupBy(sym => sym.GetType()).Select(grp => string.Concat(grp.Key.Name, ":", grp.Count()))));
|
||||||
builder.Append("}");
|
builder.Append("}");
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ namespace Microsoft.AspNet.Razor.Parser.SyntaxTree
|
||||||
Kind.Equals(other.Kind) &&
|
Kind.Equals(other.Kind) &&
|
||||||
Start.Equals(other.Start) &&
|
Start.Equals(other.Start) &&
|
||||||
EditHandler.Equals(other.EditHandler) &&
|
EditHandler.Equals(other.EditHandler) &&
|
||||||
String.Equals(other.Content, Content, StringComparison.Ordinal);
|
string.Equals(other.Content, Content, StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
|
||||||
|
|
@ -375,7 +375,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
AcceptWhile(sym => Equals(type, sym.Type));
|
AcceptWhile(sym => Equals(type, sym.Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to avoid array allocations and enumeration where possible, so we use the same technique as String.Format
|
// We want to avoid array allocations and enumeration where possible, so we use the same technique as string.Format
|
||||||
protected internal void AcceptWhile(TSymbolType type1, TSymbolType type2)
|
protected internal void AcceptWhile(TSymbolType type1, TSymbolType type2)
|
||||||
{
|
{
|
||||||
AcceptWhile(sym => Equals(type1, sym.Type) || Equals(type2, sym.Type));
|
AcceptWhile(sym => Equals(type1, sym.Type) || Equals(type2, sym.Type));
|
||||||
|
|
@ -396,7 +396,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
AcceptWhile(sym => !Equals(type, sym.Type));
|
AcceptWhile(sym => !Equals(type, sym.Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to avoid array allocations and enumeration where possible, so we use the same technique as String.Format
|
// We want to avoid array allocations and enumeration where possible, so we use the same technique as string.Format
|
||||||
protected internal void AcceptUntil(TSymbolType type1, TSymbolType type2)
|
protected internal void AcceptUntil(TSymbolType type1, TSymbolType type2)
|
||||||
{
|
{
|
||||||
AcceptWhile(sym => !Equals(type1, sym.Type) && !Equals(type2, sym.Type));
|
AcceptWhile(sym => !Equals(type1, sym.Type) && !Equals(type2, sym.Type));
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Razor
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("host");
|
throw new ArgumentNullException("host");
|
||||||
}
|
}
|
||||||
if (String.IsNullOrEmpty(sourceFileName))
|
if (string.IsNullOrEmpty(sourceFileName))
|
||||||
{
|
{
|
||||||
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "sourceFileName");
|
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "sourceFileName");
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +141,7 @@ namespace Microsoft.AspNet.Razor
|
||||||
var result = PartialParseResult.Rejected;
|
var result = PartialParseResult.Rejected;
|
||||||
|
|
||||||
// If there isn't already a parse underway, try partial-parsing
|
// If there isn't already a parse underway, try partial-parsing
|
||||||
var changeString = String.Empty;
|
var changeString = string.Empty;
|
||||||
using (_parser.SynchronizeMainThreadState())
|
using (_parser.SynchronizeMainThreadState())
|
||||||
{
|
{
|
||||||
// Capture the string value of the change while we're synchronized
|
// Capture the string value of the change while we're synchronized
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Razor
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format(CultureInfo.CurrentCulture, "Error @ {0}({2}) - [{1}]", Location, Message, Length);
|
return string.Format(CultureInfo.CurrentCulture, "Error @ {0}({2}) - [{1}]", Location, Message, Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Razor
|
||||||
|
|
||||||
public bool Equals(RazorError other)
|
public bool Equals(RazorError other)
|
||||||
{
|
{
|
||||||
return String.Equals(other.Message, Message, StringComparison.Ordinal) &&
|
return string.Equals(other.Message, Message, StringComparison.Ordinal) &&
|
||||||
Location.Equals(other.Location);
|
Location.Equals(other.Location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ Instead, wrap the contents of the block in "{{}}":
|
||||||
</data>
|
</data>
|
||||||
<data name="ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS" xml:space="preserve">
|
<data name="ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS" xml:space="preserve">
|
||||||
<value>"{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid.</value>
|
<value>"{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid.</value>
|
||||||
<comment>"{{" is an escape sequence for String.Format, when outputted to the user it will be displayed as "{"</comment>
|
<comment>"{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{"</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="ParseError_UnfinishedTag" xml:space="preserve">
|
<data name="ParseError_UnfinishedTag" xml:space="preserve">
|
||||||
<value>End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity.</value>
|
<value>End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity.</value>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Razor
|
||||||
{
|
{
|
||||||
private const int BufferSize = 1024;
|
private const int BufferSize = 1024;
|
||||||
public static readonly string DefaultClassName = "Template";
|
public static readonly string DefaultClassName = "Template";
|
||||||
public static readonly string DefaultNamespace = String.Empty;
|
public static readonly string DefaultNamespace = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new RazorTemplateEngine with the specified host
|
/// Constructs a new RazorTemplateEngine with the specified host
|
||||||
|
|
@ -41,11 +41,11 @@ namespace Microsoft.AspNet.Razor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The RazorEngineHost which defines the environment in which the generated template code will live
|
/// The RazorEngineHost which defines the environment in which the generated template code will live
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RazorEngineHost Host { get; private set; }
|
public RazorEngineHost Host { get; }
|
||||||
|
|
||||||
public ParserResults ParseTemplate(ITextBuffer input)
|
public ParserResults ParseTemplate(ITextBuffer input)
|
||||||
{
|
{
|
||||||
return ParseTemplate(input, null);
|
return ParseTemplate(input, cancelToken: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -63,7 +63,10 @@ namespace Microsoft.AspNet.Razor
|
||||||
/// <param name="input">The input text to parse</param>
|
/// <param name="input">The input text to parse</param>
|
||||||
/// <param name="cancelToken">A token used to cancel the parser</param>
|
/// <param name="cancelToken">A token used to cancel the parser</param>
|
||||||
/// <returns>The resulting parse tree</returns>
|
/// <returns>The resulting parse tree</returns>
|
||||||
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so we don't want to dispose it")]
|
[SuppressMessage(
|
||||||
|
"Microsoft.Reliability", "CA2000:Dispose objects before losing scope",
|
||||||
|
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
|
||||||
|
"we don't want to dispose it")]
|
||||||
public ParserResults ParseTemplate(ITextBuffer input, CancellationToken? cancelToken)
|
public ParserResults ParseTemplate(ITextBuffer input, CancellationToken? cancelToken)
|
||||||
{
|
{
|
||||||
return ParseTemplateCore(input.ToDocument(), sourceFileName: null, cancelToken: cancelToken);
|
return ParseTemplateCore(input.ToDocument(), sourceFileName: null, cancelToken: cancelToken);
|
||||||
|
|
@ -76,15 +79,20 @@ namespace Microsoft.AspNet.Razor
|
||||||
return ParseTemplateCore(new SeekableTextReader(input), sourceFileName, cancelToken: null);
|
return ParseTemplateCore(new SeekableTextReader(input), sourceFileName, cancelToken: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so we don't want to dispose it")]
|
[SuppressMessage(
|
||||||
|
"Microsoft.Reliability",
|
||||||
|
"CA2000:Dispose objects before losing scope",
|
||||||
|
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
|
||||||
|
"we don't want to dispose it")]
|
||||||
public ParserResults ParseTemplate(TextReader input, CancellationToken? cancelToken)
|
public ParserResults ParseTemplate(TextReader input, CancellationToken? cancelToken)
|
||||||
{
|
{
|
||||||
return ParseTemplateCore(new SeekableTextReader(input), sourceFileName: null, cancelToken: cancelToken);
|
return ParseTemplateCore(new SeekableTextReader(input), sourceFileName: null, cancelToken: cancelToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal virtual ParserResults ParseTemplateCore(ITextDocument input,
|
protected internal virtual ParserResults ParseTemplateCore(
|
||||||
string sourceFileName,
|
ITextDocument input,
|
||||||
CancellationToken? cancelToken)
|
string sourceFileName,
|
||||||
|
CancellationToken? cancelToken)
|
||||||
{
|
{
|
||||||
// Construct the parser
|
// Construct the parser
|
||||||
var parser = CreateParser(sourceFileName);
|
var parser = CreateParser(sourceFileName);
|
||||||
|
|
@ -94,17 +102,22 @@ namespace Microsoft.AspNet.Razor
|
||||||
|
|
||||||
public GeneratorResults GenerateCode(ITextBuffer input)
|
public GeneratorResults GenerateCode(ITextBuffer input)
|
||||||
{
|
{
|
||||||
return GenerateCode(input, null, null, null, null);
|
return GenerateCode(input, className: null, rootNamespace: null, sourceFileName: null, cancelToken: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeneratorResults GenerateCode(ITextBuffer input, CancellationToken? cancelToken)
|
public GeneratorResults GenerateCode(ITextBuffer input, CancellationToken? cancelToken)
|
||||||
{
|
{
|
||||||
return GenerateCode(input, null, null, null, cancelToken);
|
return GenerateCode(
|
||||||
|
input,
|
||||||
|
className: null,
|
||||||
|
rootNamespace: null,
|
||||||
|
sourceFileName: null,
|
||||||
|
cancelToken: cancelToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeneratorResults GenerateCode(ITextBuffer input, string className, string rootNamespace, string sourceFileName)
|
public GeneratorResults GenerateCode(ITextBuffer input, string className, string rootNamespace, string sourceFileName)
|
||||||
{
|
{
|
||||||
return GenerateCode(input, className, rootNamespace, sourceFileName, null);
|
return GenerateCode(input, className, rootNamespace, sourceFileName, cancelToken: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -128,31 +141,50 @@ namespace Microsoft.AspNet.Razor
|
||||||
/// <param name="rootNamespace">The namespace in which the generated class will reside, overriding whatever is specified in the Host. The default value (defined in the Host) can be used by providing null for this argument</param>
|
/// <param name="rootNamespace">The namespace in which the generated class will reside, overriding whatever is specified in the Host. The default value (defined in the Host) can be used by providing null for this argument</param>
|
||||||
/// <param name="sourceFileName">The file name to use in line pragmas, usually the original Razor file, overriding whatever is specified in the Host. The default value (defined in the Host) can be used by providing null for this argument</param>
|
/// <param name="sourceFileName">The file name to use in line pragmas, usually the original Razor file, overriding whatever is specified in the Host. The default value (defined in the Host) can be used by providing null for this argument</param>
|
||||||
/// <returns>The resulting parse tree AND generated code.</returns>
|
/// <returns>The resulting parse tree AND generated code.</returns>
|
||||||
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so we don't want to dispose it")]
|
[SuppressMessage(
|
||||||
public GeneratorResults GenerateCode(ITextBuffer input, string className, string rootNamespace, string sourceFileName, CancellationToken? cancelToken)
|
"Microsoft.Reliability",
|
||||||
|
"CA2000:Dispose objects before losing scope",
|
||||||
|
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
|
||||||
|
"we don't want to dispose it")]
|
||||||
|
public GeneratorResults GenerateCode(
|
||||||
|
ITextBuffer input,
|
||||||
|
string className,
|
||||||
|
string rootNamespace,
|
||||||
|
string sourceFileName,
|
||||||
|
CancellationToken? cancelToken)
|
||||||
{
|
{
|
||||||
return GenerateCodeCore(input.ToDocument(),
|
return GenerateCodeCore(
|
||||||
className,
|
input.ToDocument(),
|
||||||
rootNamespace,
|
className,
|
||||||
sourceFileName,
|
rootNamespace,
|
||||||
checksum: null,
|
sourceFileName,
|
||||||
cancelToken: cancelToken);
|
checksum: null,
|
||||||
|
cancelToken: cancelToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
// See GenerateCode override which takes ITextBuffer, and BufferingTextReader for details.
|
// See GenerateCode override which takes ITextBuffer, and BufferingTextReader for details.
|
||||||
public GeneratorResults GenerateCode(TextReader input)
|
public GeneratorResults GenerateCode(TextReader input)
|
||||||
{
|
{
|
||||||
return GenerateCode(input, null, null, null, null);
|
return GenerateCode(input, className: null, rootNamespace: null, sourceFileName: null, cancelToken: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeneratorResults GenerateCode(TextReader input, CancellationToken? cancelToken)
|
public GeneratorResults GenerateCode(TextReader input, CancellationToken? cancelToken)
|
||||||
{
|
{
|
||||||
return GenerateCode(input, null, null, null, cancelToken);
|
return GenerateCode(
|
||||||
|
input,
|
||||||
|
className: null,
|
||||||
|
rootNamespace: null,
|
||||||
|
sourceFileName: null,
|
||||||
|
cancelToken: cancelToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeneratorResults GenerateCode(TextReader input, string className, string rootNamespace, string sourceFileName)
|
public GeneratorResults GenerateCode(
|
||||||
|
TextReader input,
|
||||||
|
string className,
|
||||||
|
|
||||||
|
string rootNamespace, string sourceFileName)
|
||||||
{
|
{
|
||||||
return GenerateCode(input, className, rootNamespace, sourceFileName, null);
|
return GenerateCode(input, className, rootNamespace, sourceFileName, cancelToken: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -170,10 +202,11 @@ namespace Microsoft.AspNet.Razor
|
||||||
/// generation. The checksum is used for producing the <c>#pragma checksum</c> line pragma required for
|
/// generation. The checksum is used for producing the <c>#pragma checksum</c> line pragma required for
|
||||||
/// debugging.
|
/// debugging.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public GeneratorResults GenerateCode([NotNull] Stream inputStream,
|
public GeneratorResults GenerateCode(
|
||||||
string className,
|
[NotNull] Stream inputStream,
|
||||||
string rootNamespace,
|
string className,
|
||||||
string sourceFileName)
|
string rootNamespace,
|
||||||
|
string sourceFileName)
|
||||||
{
|
{
|
||||||
MemoryStream memoryStream = null;
|
MemoryStream memoryStream = null;
|
||||||
string checksum = null;
|
string checksum = null;
|
||||||
|
|
@ -197,19 +230,22 @@ namespace Microsoft.AspNet.Razor
|
||||||
inputStream.Position = 0;
|
inputStream.Position = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var reader = new StreamReader(inputStream,
|
using (var reader =
|
||||||
Encoding.UTF8,
|
new StreamReader(
|
||||||
detectEncodingFromByteOrderMarks: true,
|
inputStream,
|
||||||
bufferSize: BufferSize,
|
Encoding.UTF8,
|
||||||
leaveOpen: true))
|
detectEncodingFromByteOrderMarks: true,
|
||||||
|
bufferSize: BufferSize,
|
||||||
|
leaveOpen: true))
|
||||||
{
|
{
|
||||||
var seekableStream = new SeekableTextReader(reader);
|
var seekableStream = new SeekableTextReader(reader);
|
||||||
return GenerateCodeCore(seekableStream,
|
return GenerateCodeCore(
|
||||||
className,
|
seekableStream,
|
||||||
rootNamespace,
|
className,
|
||||||
sourceFileName,
|
rootNamespace,
|
||||||
checksum,
|
sourceFileName,
|
||||||
cancelToken: null);
|
checksum,
|
||||||
|
cancelToken: null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
@ -221,23 +257,34 @@ namespace Microsoft.AspNet.Razor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so we don't want to dispose it")]
|
[SuppressMessage(
|
||||||
public GeneratorResults GenerateCode(TextReader input, string className, string rootNamespace, string sourceFileName, CancellationToken? cancelToken)
|
"Microsoft.Reliability",
|
||||||
|
"CA2000:Dispose objects before losing scope",
|
||||||
|
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
|
||||||
|
"we don't want to dispose it")]
|
||||||
|
public GeneratorResults GenerateCode(
|
||||||
|
TextReader input,
|
||||||
|
string className,
|
||||||
|
string rootNamespace,
|
||||||
|
string sourceFileName,
|
||||||
|
CancellationToken? cancelToken)
|
||||||
{
|
{
|
||||||
return GenerateCodeCore(new SeekableTextReader(input),
|
return GenerateCodeCore(
|
||||||
className,
|
new SeekableTextReader(input),
|
||||||
rootNamespace,
|
className,
|
||||||
sourceFileName,
|
rootNamespace,
|
||||||
checksum: null,
|
sourceFileName,
|
||||||
cancelToken: cancelToken);
|
checksum: null,
|
||||||
|
cancelToken: cancelToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal virtual GeneratorResults GenerateCodeCore(ITextDocument input,
|
protected internal virtual GeneratorResults GenerateCodeCore(
|
||||||
string className,
|
ITextDocument input,
|
||||||
string rootNamespace,
|
string className,
|
||||||
string sourceFileName,
|
string rootNamespace,
|
||||||
string checksum,
|
string sourceFileName,
|
||||||
CancellationToken? cancelToken)
|
string checksum,
|
||||||
|
CancellationToken? cancelToken)
|
||||||
{
|
{
|
||||||
className = (className ?? Host.DefaultClassName) ?? DefaultClassName;
|
className = (className ?? Host.DefaultClassName) ?? DefaultClassName;
|
||||||
rootNamespace = (rootNamespace ?? Host.DefaultNamespace) ?? DefaultNamespace;
|
rootNamespace = (rootNamespace ?? Host.DefaultNamespace) ?? DefaultNamespace;
|
||||||
|
|
@ -261,7 +308,10 @@ namespace Microsoft.AspNet.Razor
|
||||||
return new GeneratorResults(results, builderResult, codeBuilderContext.CodeTreeBuilder.CodeTree);
|
return new GeneratorResults(results, builderResult, codeBuilderContext.CodeTreeBuilder.CodeTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal virtual RazorCodeGenerator CreateCodeGenerator(string className, string rootNamespace, string sourceFileName)
|
protected internal virtual RazorCodeGenerator CreateCodeGenerator(
|
||||||
|
string className,
|
||||||
|
string rootNamespace,
|
||||||
|
string sourceFileName)
|
||||||
{
|
{
|
||||||
return Host.DecorateCodeGenerator(
|
return Host.DecorateCodeGenerator(
|
||||||
Host.CodeLanguage.CreateCodeGenerator(className, rootNamespace, sourceFileName, Host));
|
Host.CodeLanguage.CreateCodeGenerator(className, rootNamespace, sourceFileName, Host));
|
||||||
|
|
@ -272,9 +322,10 @@ namespace Microsoft.AspNet.Razor
|
||||||
var codeParser = Host.CodeLanguage.CreateCodeParser();
|
var codeParser = Host.CodeLanguage.CreateCodeParser();
|
||||||
var markupParser = Host.CreateMarkupParser();
|
var markupParser = Host.CreateMarkupParser();
|
||||||
|
|
||||||
var parser = new RazorParser(Host.DecorateCodeParser(codeParser),
|
var parser = new RazorParser(
|
||||||
Host.DecorateMarkupParser(markupParser),
|
Host.DecorateCodeParser(codeParser),
|
||||||
Host.TagHelperDescriptorResolver)
|
Host.DecorateMarkupParser(markupParser),
|
||||||
|
Host.TagHelperDescriptorResolver)
|
||||||
{
|
{
|
||||||
DesignTimeMode = Host.DesignTimeMode
|
DesignTimeMode = Host.DesignTimeMode
|
||||||
};
|
};
|
||||||
|
|
@ -284,8 +335,7 @@ namespace Microsoft.AspNet.Razor
|
||||||
|
|
||||||
protected internal virtual CodeBuilder CreateCodeBuilder(CodeBuilderContext context)
|
protected internal virtual CodeBuilder CreateCodeBuilder(CodeBuilderContext context)
|
||||||
{
|
{
|
||||||
return Host.DecorateCodeBuilder(Host.CodeLanguage.CreateCodeBuilder(context),
|
return Host.DecorateCodeBuilder(Host.CodeLanguage.CreateCodeBuilder(context), context);
|
||||||
context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ComputeChecksum(Stream inputStream)
|
private static string ComputeChecksum(Stream inputStream)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Razor
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format(
|
return string.Format(
|
||||||
CultureInfo.CurrentCulture,
|
CultureInfo.CurrentCulture,
|
||||||
"({0}:{1},{2})",
|
"({0}:{1},{2})",
|
||||||
AbsoluteIndex,
|
AbsoluteIndex,
|
||||||
|
|
@ -58,9 +58,10 @@ namespace Microsoft.AspNet.Razor
|
||||||
|
|
||||||
public bool Equals(SourceLocation other)
|
public bool Equals(SourceLocation other)
|
||||||
{
|
{
|
||||||
return AbsoluteIndex == other.AbsoluteIndex &&
|
return
|
||||||
LineIndex == other.LineIndex &&
|
AbsoluteIndex == other.AbsoluteIndex &&
|
||||||
CharacterIndex == other.CharacterIndex;
|
LineIndex == other.LineIndex &&
|
||||||
|
CharacterIndex == other.CharacterIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CompareTo(SourceLocation other)
|
public int CompareTo(SourceLocation other)
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Razor.Text
|
||||||
|
|
||||||
public string ToString(string format, IFormatProvider formatProvider)
|
public string ToString(string format, IFormatProvider formatProvider)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(format))
|
if (string.IsNullOrEmpty(format))
|
||||||
{
|
{
|
||||||
format = "P";
|
format = "P";
|
||||||
}
|
}
|
||||||
|
|
@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Razor.Text
|
||||||
switch (format.ToUpperInvariant())
|
switch (format.ToUpperInvariant())
|
||||||
{
|
{
|
||||||
case "F":
|
case "F":
|
||||||
return String.Format(formatProvider, "{0}@{1}", Value, Location);
|
return string.Format(formatProvider, "{0}@{1}", Value, Location);
|
||||||
default:
|
default:
|
||||||
return Value.ToString();
|
return Value.ToString();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ namespace Microsoft.AspNet.Razor.Text
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format(CultureInfo.CurrentCulture, "({0}:{1}) \"{3}\" -> ({0}:{2}) \"{4}\"", OldPosition, OldLength, NewLength, OldText, NewText);
|
return string.Format(CultureInfo.CurrentCulture, "({0}:{1}) \"{3}\" -> ({0}:{2}) \"{4}\"", OldPosition, OldLength, NewLength, OldText, NewText);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -181,7 +181,7 @@ namespace Microsoft.AspNet.Razor.Text
|
||||||
// Optimization for the common case of one char inserts, in this case we don't even need to seek the buffer.
|
// Optimization for the common case of one char inserts, in this case we don't even need to seek the buffer.
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
{
|
{
|
||||||
return String.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldPosition = buffer.Position;
|
var oldPosition = buffer.Position;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
||||||
SymbolBase<TType> other = obj as SymbolBase<TType>;
|
SymbolBase<TType> other = obj as SymbolBase<TType>;
|
||||||
return other != null &&
|
return other != null &&
|
||||||
Start.Equals(other.Start) &&
|
Start.Equals(other.Start) &&
|
||||||
String.Equals(Content, other.Content, StringComparison.Ordinal) &&
|
string.Equals(Content, other.Content, StringComparison.Ordinal) &&
|
||||||
Type.Equals(other.Type);
|
Type.Equals(other.Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format(CultureInfo.InvariantCulture, "{0} {1} - [{2}]", Start, Type, Content);
|
return string.Format(CultureInfo.InvariantCulture, "{0} {1} - [{2}]", Start, Type, Content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OffsetStart(SourceLocation documentStart)
|
public void OffsetStart(SourceLocation documentStart)
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,11 @@ namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
||||||
{
|
{
|
||||||
if (symbols.Any())
|
if (symbols.Any())
|
||||||
{
|
{
|
||||||
return new LocationTagged<string>(String.Concat(symbols.Select(s => s.Content)), spanStart + symbols.First().Start);
|
return new LocationTagged<string>(string.Concat(symbols.Select(s => s.Content)), spanStart + symbols.First().Start);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new LocationTagged<string>(String.Empty, spanStart);
|
return new LocationTagged<string>(string.Empty, spanStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -327,7 +327,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer
|
||||||
|
|
||||||
Debug.Assert(CurrentCharacter == current, "CurrentCharacter Assumption violated", "Assumed that the current character would be {0}, but it is actually {1}", current, CurrentCharacter);
|
Debug.Assert(CurrentCharacter == current, "CurrentCharacter Assumption violated", "Assumed that the current character would be {0}, but it is actually {1}", current, CurrentCharacter);
|
||||||
#else
|
#else
|
||||||
Debug.Assert(CurrentCharacter == current, String.Format("CurrentCharacter Assumption violated. Assumed that the current character would be {0}, but it is actually {1}", current, CurrentCharacter));
|
Debug.Assert(CurrentCharacter == current, string.Format("CurrentCharacter Assumption violated. Assumed that the current character would be {0}, but it is actually {1}", current, CurrentCharacter));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,7 +345,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer
|
||||||
|
|
||||||
public string DebugDisplay
|
public string DebugDisplay
|
||||||
{
|
{
|
||||||
get { return String.Format(CultureInfo.InvariantCulture, "[{0}] [{1}] [{2}]", _read.ToString(), CurrentCharacter, Remaining); }
|
get { return string.Format(CultureInfo.InvariantCulture, "[{0}] [{1}] [{2}]", _read.ToString(), CurrentCharacter, Remaining); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Remaining
|
public string Remaining
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ namespace Microsoft.AspNet.Razor.Test.Editor
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
parser.CheckForStructureChanges(new TextChange(0, 0, new StringTextBuffer(String.Empty), input.Length, input));
|
parser.CheckForStructureChanges(new TextChange(0, 0, new StringTextBuffer(string.Empty), input.Length, input));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait);
|
MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait);
|
||||||
|
|
@ -162,7 +162,7 @@ namespace Microsoft.AspNet.Razor.Test.Editor
|
||||||
parseComplete.Set();
|
parseComplete.Set();
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.Equal(PartialParseResult.Rejected, parser.CheckForStructureChanges(new TextChange(0, 0, new StringTextBuffer(String.Empty), 12, original)));
|
Assert.Equal(PartialParseResult.Rejected, parser.CheckForStructureChanges(new TextChange(0, 0, new StringTextBuffer(string.Empty), 12, original)));
|
||||||
MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait); // Wait for the parse to finish
|
MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait); // Wait for the parse to finish
|
||||||
parseComplete.Reset();
|
parseComplete.Reset();
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ namespace Microsoft.AspNet.Razor.Test.Editor
|
||||||
|
|
||||||
private TextChange CreateDummyChange()
|
private TextChange CreateDummyChange()
|
||||||
{
|
{
|
||||||
return new TextChange(0, 0, new StringTextBuffer(String.Empty), 3, new StringTextBuffer("foo"));
|
return new TextChange(0, 0, new StringTextBuffer(string.Empty), 3, new StringTextBuffer("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RazorEditorParser CreateClientParser()
|
private static RazorEditorParser CreateClientParser()
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
||||||
{
|
{
|
||||||
if (results != null && results.Document != null)
|
if (results != null && results.Document != null)
|
||||||
{
|
{
|
||||||
WriteTraceLine(String.Empty);
|
WriteTraceLine(string.Empty);
|
||||||
WriteTraceLine("Actual Parse Tree:");
|
WriteTraceLine("Actual Parse Tree:");
|
||||||
WriteNode(0, results.Document);
|
WriteNode(0, results.Document);
|
||||||
}
|
}
|
||||||
|
|
@ -491,7 +491,7 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
||||||
[Conditional("PARSER_TRACE")]
|
[Conditional("PARSER_TRACE")]
|
||||||
private static void WriteTraceLine(string format, params object[] args)
|
private static void WriteTraceLine(string format, params object[] args)
|
||||||
{
|
{
|
||||||
Trace.WriteLine(String.Format(format, args));
|
Trace.WriteLine(string.Format(format, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Block CreateSimpleBlockAndSpan(string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
|
protected virtual Block CreateSimpleBlockAndSpan(string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format(CultureInfo.InvariantCulture, "{0} RAW - [{1}]", Start, Content);
|
return string.Format(CultureInfo.InvariantCulture, "{0} RAW - [{1}]", Start, Content);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void CalculateStart(Span prev)
|
internal void CalculateStart(Span prev)
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
||||||
public static UnclassifiedCodeSpanConstructor EmptyCSharp(this SpanFactory self)
|
public static UnclassifiedCodeSpanConstructor EmptyCSharp(this SpanFactory self)
|
||||||
{
|
{
|
||||||
return new UnclassifiedCodeSpanConstructor(
|
return new UnclassifiedCodeSpanConstructor(
|
||||||
self.Span(SpanKind.Code, new CSharpSymbol(self.LocationTracker.CurrentLocation, String.Empty, CSharpSymbolType.Unknown)));
|
self.Span(SpanKind.Code, new CSharpSymbol(self.LocationTracker.CurrentLocation, string.Empty, CSharpSymbolType.Unknown)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SpanConstructor EmptyHtml(this SpanFactory self)
|
public static SpanConstructor EmptyHtml(this SpanFactory self)
|
||||||
{
|
{
|
||||||
return self.Span(SpanKind.Markup, new HtmlSymbol(self.LocationTracker.CurrentLocation, String.Empty, HtmlSymbolType.Unknown))
|
return self.Span(SpanKind.Markup, new HtmlSymbol(self.LocationTracker.CurrentLocation, string.Empty, HtmlSymbolType.Unknown))
|
||||||
.With(new MarkupCodeGenerator());
|
.With(new MarkupCodeGenerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ConstructorAllowsEmptyRootNamespaceName()
|
public void ConstructorAllowsEmptyRootNamespaceName()
|
||||||
{
|
{
|
||||||
new CSharpRazorCodeGenerator("Foo", String.Empty, TestPhysicalPath, CreateHost());
|
new CSharpRazorCodeGenerator("Foo", string.Empty, TestPhysicalPath, CreateHost());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -173,11 +173,11 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
||||||
using (var source = TestFile.Create(sourceLocation).OpenRead())
|
using (var source = TestFile.Create(sourceLocation).OpenRead())
|
||||||
{
|
{
|
||||||
var sourceFile = NormalizeNewLines(source);
|
var sourceFile = NormalizeNewLines(source);
|
||||||
var sourceFileName = generatePragmas ? String.Format("{0}.{1}", name, FileExtension) : null;
|
var sourceFileName = generatePragmas ? string.Format("{0}.{1}", name, FileExtension) : null;
|
||||||
results = engine.GenerateCode(sourceFile, className: name, rootNamespace: TestRootNamespaceName, sourceFileName: sourceFileName);
|
results = engine.GenerateCode(sourceFile, className: name, rootNamespace: TestRootNamespaceName, sourceFileName: sourceFileName);
|
||||||
}
|
}
|
||||||
// Only called if GENERATE_BASELINES is set, otherwise compiled out.
|
// Only called if GENERATE_BASELINES is set, otherwise compiled out.
|
||||||
BaselineWriter.WriteBaseline(String.Format(@"test\Microsoft.AspNet.Razor.Test\TestFiles\CodeGenerator\{0}\Output\{1}.{2}", LanguageName, baselineName, BaselineExtension), results.GeneratedCode);
|
BaselineWriter.WriteBaseline(string.Format(@"test\Microsoft.AspNet.Razor.Test\TestFiles\CodeGenerator\{0}\Output\{1}.{2}", LanguageName, baselineName, BaselineExtension), results.GeneratedCode);
|
||||||
|
|
||||||
#if !GENERATE_BASELINES
|
#if !GENERATE_BASELINES
|
||||||
var textOutput = results.GeneratedCode;
|
var textOutput = results.GeneratedCode;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format("{0}: {1}-{2}", Kind, Start, End);
|
return string.Format("{0}: {1}-{2}", Kind, Start, End);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
Factory.Markup("<p>").Accepts(AcceptedCharacters.None)),
|
Factory.Markup("<p>").Accepts(AcceptedCharacters.None)),
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None))),
|
Factory.Markup("</p>").Accepts(AcceptedCharacters.None))),
|
||||||
Factory.Span(SpanKind.Code, new CSharpSymbol(Factory.LocationTracker.CurrentLocation, String.Empty, CSharpSymbolType.Unknown))
|
Factory.Span(SpanKind.Code, new CSharpSymbol(Factory.LocationTracker.CurrentLocation, string.Empty, CSharpSymbolType.Unknown))
|
||||||
.With(new StatementCodeGenerator())
|
.With(new StatementCodeGenerator())
|
||||||
),
|
),
|
||||||
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
|
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
|
||||||
|
|
|
||||||
|
|
@ -772,7 +772,7 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
|
||||||
private void NamespaceImportTest(string content, string expectedNS, AcceptedCharacters acceptedCharacters = AcceptedCharacters.None, string errorMessage = null, SourceLocation? location = null)
|
private void NamespaceImportTest(string content, string expectedNS, AcceptedCharacters acceptedCharacters = AcceptedCharacters.None, string errorMessage = null, SourceLocation? location = null)
|
||||||
{
|
{
|
||||||
var errors = new RazorError[0];
|
var errors = new RazorError[0];
|
||||||
if (!String.IsNullOrEmpty(errorMessage) && location.HasValue)
|
if (!string.IsNullOrEmpty(errorMessage) && location.HasValue)
|
||||||
{
|
{
|
||||||
errors = new RazorError[]
|
errors = new RazorError[]
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -588,10 +588,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode()
|
public void ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode()
|
||||||
{
|
{
|
||||||
ParseBlockTest(@"{String.Format(<html></html>}",
|
ParseBlockTest(@"{string.Format(<html></html>}",
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||||
Factory.Code("String.Format(")
|
Factory.Code("string.Format(")
|
||||||
.AsStatement(),
|
.AsStatement(),
|
||||||
new MarkupBlock(
|
new MarkupBlock(
|
||||||
BlockFactory.MarkupTagBlock("<html>", AcceptedCharacters.None),
|
BlockFactory.MarkupTagBlock("<html>", AcceptedCharacters.None),
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
Factory.MetaCode("layout ").Accepts(AcceptedCharacters.None),
|
Factory.MetaCode("layout ").Accepts(AcceptedCharacters.None),
|
||||||
Factory.EmptyCSharp()
|
Factory.EmptyCSharp()
|
||||||
.AsMetaCode()
|
.AsMetaCode()
|
||||||
.With(new SetLayoutCodeGenerator(String.Empty))
|
.With(new SetLayoutCodeGenerator(string.Empty))
|
||||||
.WithEditorHints(EditorHints.VirtualPath | EditorHints.LayoutPage)
|
.WithEditorHints(EditorHints.VirtualPath | EditorHints.LayoutPage)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
.Accepts(AcceptedCharacters.None),
|
.Accepts(AcceptedCharacters.None),
|
||||||
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
||||||
Factory.LocationTracker.CurrentLocation,
|
Factory.LocationTracker.CurrentLocation,
|
||||||
String.Empty,
|
string.Empty,
|
||||||
HtmlSymbolType.Unknown))
|
HtmlSymbolType.Unknown))
|
||||||
.Accepts(AcceptedCharacters.Any))),
|
.Accepts(AcceptedCharacters.Any))),
|
||||||
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 0, 0, 0));
|
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 0, 0, 0));
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
.Accepts(AcceptedCharacters.None),
|
.Accepts(AcceptedCharacters.None),
|
||||||
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
||||||
Factory.LocationTracker.CurrentLocation,
|
Factory.LocationTracker.CurrentLocation,
|
||||||
String.Empty,
|
string.Empty,
|
||||||
HtmlSymbolType.Unknown))
|
HtmlSymbolType.Unknown))
|
||||||
.Accepts(AcceptedCharacters.Any),
|
.Accepts(AcceptedCharacters.Any),
|
||||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
.Accepts(AcceptedCharacters.None),
|
.Accepts(AcceptedCharacters.None),
|
||||||
Factory.Span(SpanKind.Comment, new CSharpSymbol(
|
Factory.Span(SpanKind.Comment, new CSharpSymbol(
|
||||||
Factory.LocationTracker.CurrentLocation,
|
Factory.LocationTracker.CurrentLocation,
|
||||||
String.Empty,
|
string.Empty,
|
||||||
CSharpSymbolType.Unknown))
|
CSharpSymbolType.Unknown))
|
||||||
.Accepts(AcceptedCharacters.Any),
|
.Accepts(AcceptedCharacters.Any),
|
||||||
Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar)
|
Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar)
|
||||||
|
|
@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
.Accepts(AcceptedCharacters.None),
|
.Accepts(AcceptedCharacters.None),
|
||||||
Factory.Span(SpanKind.Comment, new CSharpSymbol(
|
Factory.Span(SpanKind.Comment, new CSharpSymbol(
|
||||||
Factory.LocationTracker.CurrentLocation,
|
Factory.LocationTracker.CurrentLocation,
|
||||||
String.Empty,
|
string.Empty,
|
||||||
CSharpSymbolType.Unknown))
|
CSharpSymbolType.Unknown))
|
||||||
.Accepts(AcceptedCharacters.Any)))),
|
.Accepts(AcceptedCharacters.Any)))),
|
||||||
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 5, 0, 5),
|
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 5, 0, 5),
|
||||||
|
|
@ -135,7 +135,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
.Accepts(AcceptedCharacters.None),
|
.Accepts(AcceptedCharacters.None),
|
||||||
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
||||||
Factory.LocationTracker.CurrentLocation,
|
Factory.LocationTracker.CurrentLocation,
|
||||||
String.Empty,
|
string.Empty,
|
||||||
HtmlSymbolType.Unknown))
|
HtmlSymbolType.Unknown))
|
||||||
.Accepts(AcceptedCharacters.Any),
|
.Accepts(AcceptedCharacters.Any),
|
||||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
||||||
|
|
@ -165,7 +165,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar)
|
Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar)
|
||||||
.Accepts(AcceptedCharacters.None),
|
.Accepts(AcceptedCharacters.None),
|
||||||
Factory.Span(SpanKind.Comment, new CSharpSymbol(Factory.LocationTracker.CurrentLocation,
|
Factory.Span(SpanKind.Comment, new CSharpSymbol(Factory.LocationTracker.CurrentLocation,
|
||||||
String.Empty,
|
string.Empty,
|
||||||
CSharpSymbolType.Unknown))
|
CSharpSymbolType.Unknown))
|
||||||
.Accepts(AcceptedCharacters.Any)))),
|
.Accepts(AcceptedCharacters.Any)))),
|
||||||
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 2, 0, 2),
|
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 2, 0, 2),
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
ParseDocumentTest("@section" + Environment.NewLine,
|
ParseDocumentTest("@section" + Environment.NewLine,
|
||||||
new MarkupBlock(
|
new MarkupBlock(
|
||||||
Factory.EmptyHtml(),
|
Factory.EmptyHtml(),
|
||||||
new SectionBlock(new SectionCodeGenerator(String.Empty),
|
new SectionBlock(new SectionCodeGenerator(string.Empty),
|
||||||
Factory.CodeTransition(),
|
Factory.CodeTransition(),
|
||||||
Factory.MetaCode("section" + Environment.NewLine))),
|
Factory.MetaCode("section" + Environment.NewLine))),
|
||||||
new RazorError(
|
new RazorError(
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
new DirectiveBlock(
|
new DirectiveBlock(
|
||||||
Factory.MetaCode("inherits ").Accepts(AcceptedCharacters.None),
|
Factory.MetaCode("inherits ").Accepts(AcceptedCharacters.None),
|
||||||
Factory.Code(" " + Environment.NewLine)
|
Factory.Code(" " + Environment.NewLine)
|
||||||
.AsBaseType(String.Empty)
|
.AsBaseType(string.Empty)
|
||||||
),
|
),
|
||||||
new RazorError(RazorResources.ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName, 24, 0, 24));
|
new RazorError(RazorResources.ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName, 24, 0, 24));
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
public void ParseBlockBalancesBracesOutsideStringsIfFirstCharacterIsBraceAndReturnsSpanOfTypeCode()
|
public void ParseBlockBalancesBracesOutsideStringsIfFirstCharacterIsBraceAndReturnsSpanOfTypeCode()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
const string code = "foo\"b}ar\" if(condition) { String.Format(\"{0}\"); } ";
|
const string code = "foo\"b}ar\" if(condition) { string.Format(\"{0}\"); } ";
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
ParseBlockTest("{" + code + "}",
|
ParseBlockTest("{" + code + "}",
|
||||||
|
|
@ -118,7 +118,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
||||||
public void ParseBlockBalancesParensOutsideStringsIfFirstCharacterIsParenAndReturnsSpanOfTypeExpression()
|
public void ParseBlockBalancesParensOutsideStringsIfFirstCharacterIsParenAndReturnsSpanOfTypeExpression()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
const string code = "foo\"b)ar\" if(condition) { String.Format(\"{0}\"); } ";
|
const string code = "foo\"b)ar\" if(condition) { string.Format(\"{0}\"); } ";
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
ParseBlockTest("(" + code + ")",
|
ParseBlockTest("(" + code + ")",
|
||||||
|
|
|
||||||
|
|
@ -215,16 +215,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("<foo"),
|
Factory.Markup("<foo"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("bar", new LocationTagged<string>(" bar=\"", 4, 0, 4), new LocationTagged<string>("\"", 13, 0, 13)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("bar", new LocationTagged<string>(" bar=\"", 4, 0, 4), new LocationTagged<string>("\"", 13, 0, 13)),
|
||||||
Factory.Markup(" bar=\"").With(SpanCodeGenerator.Null),
|
Factory.Markup(" bar=\"").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup("baz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 10, 0, 10), new LocationTagged<string>("baz", 10, 0, 10))),
|
Factory.Markup("baz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 10, 0, 10), new LocationTagged<string>("baz", 10, 0, 10))),
|
||||||
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
|
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(">").Accepts(AcceptedCharacters.None)),
|
Factory.Markup(">").Accepts(AcceptedCharacters.None)),
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup("<biz>").Accepts(AcceptedCharacters.None)),
|
Factory.Markup("<biz>").Accepts(AcceptedCharacters.None)),
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup("<boz"),
|
Factory.Markup("<boz"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("zoop", new LocationTagged<string>(" zoop=", 24, 0, 24), new LocationTagged<string>(String.Empty, 34, 0, 34)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("zoop", new LocationTagged<string>(" zoop=", 24, 0, 24), new LocationTagged<string>(string.Empty, 34, 0, 34)),
|
||||||
Factory.Markup(" zoop=").With(SpanCodeGenerator.Null),
|
Factory.Markup(" zoop=").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup("zork").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 30, 0, 30), new LocationTagged<string>("zork", 30, 0, 30)))),
|
Factory.Markup("zork").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 30, 0, 30), new LocationTagged<string>("zork", 30, 0, 30)))),
|
||||||
Factory.Markup("/>").Accepts(AcceptedCharacters.None)),
|
Factory.Markup("/>").Accepts(AcceptedCharacters.None)),
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup("</biz>").Accepts(AcceptedCharacters.None)),
|
Factory.Markup("</biz>").Accepts(AcceptedCharacters.None)),
|
||||||
|
|
@ -243,7 +243,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("<bar"),
|
Factory.Markup("<bar"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("baz", new LocationTagged<string>(" baz=\"", 9, 0, 9), new LocationTagged<string>("\"", 16, 0, 16)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("baz", new LocationTagged<string>(" baz=\"", 9, 0, 9), new LocationTagged<string>("\"", 16, 0, 16)),
|
||||||
Factory.Markup(" baz=\"").With(SpanCodeGenerator.Null),
|
Factory.Markup(" baz=\"").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup(">").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 15, 0, 15), new LocationTagged<string>(">", 15, 0, 15))),
|
Factory.Markup(">").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 15, 0, 15), new LocationTagged<string>(">", 15, 0, 15))),
|
||||||
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
|
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(" />").Accepts(AcceptedCharacters.None)),
|
Factory.Markup(" />").Accepts(AcceptedCharacters.None)),
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
|
|
@ -261,7 +261,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("<bar"),
|
Factory.Markup("<bar"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("baz", new LocationTagged<string>(" baz='", 9, 0, 9), new LocationTagged<string>("'", 16, 0, 16)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("baz", new LocationTagged<string>(" baz='", 9, 0, 9), new LocationTagged<string>("'", 16, 0, 16)),
|
||||||
Factory.Markup(" baz='").With(SpanCodeGenerator.Null),
|
Factory.Markup(" baz='").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup(">").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 15, 0, 15), new LocationTagged<string>(">", 15, 0, 15))),
|
Factory.Markup(">").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 15, 0, 15), new LocationTagged<string>(">", 15, 0, 15))),
|
||||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(" />").Accepts(AcceptedCharacters.None)),
|
Factory.Markup(" />").Accepts(AcceptedCharacters.None)),
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
|
|
@ -279,7 +279,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("<bar"),
|
Factory.Markup("<bar"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("baz", new LocationTagged<string>(" baz=\"", 9, 0, 9), new LocationTagged<string>("\"", 16, 0, 16)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("baz", new LocationTagged<string>(" baz=\"", 9, 0, 9), new LocationTagged<string>("\"", 16, 0, 16)),
|
||||||
Factory.Markup(" baz=\"").With(SpanCodeGenerator.Null),
|
Factory.Markup(" baz=\"").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup("/").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 15, 0, 15), new LocationTagged<string>("/", 15, 0, 15))),
|
Factory.Markup("/").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 15, 0, 15), new LocationTagged<string>("/", 15, 0, 15))),
|
||||||
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
|
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(">").Accepts(AcceptedCharacters.None)),
|
Factory.Markup(">").Accepts(AcceptedCharacters.None)),
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
|
|
@ -299,7 +299,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("<bar"),
|
Factory.Markup("<bar"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("baz", new LocationTagged<string>(" baz='", 9, 0, 9), new LocationTagged<string>("'", 16, 0, 16)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("baz", new LocationTagged<string>(" baz='", 9, 0, 9), new LocationTagged<string>("'", 16, 0, 16)),
|
||||||
Factory.Markup(" baz='").With(SpanCodeGenerator.Null),
|
Factory.Markup(" baz='").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup("/").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 15, 0, 15), new LocationTagged<string>("/", 15, 0, 15))),
|
Factory.Markup("/").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 15, 0, 15), new LocationTagged<string>("/", 15, 0, 15))),
|
||||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(">").Accepts(AcceptedCharacters.None)),
|
Factory.Markup(">").Accepts(AcceptedCharacters.None)),
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentOutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString()
|
public void ParseDocumentOutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(String.Empty, new MarkupBlock(Factory.EmptyHtml()));
|
ParseDocumentTest(string.Empty, new MarkupBlock(Factory.EmptyHtml()));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -176,7 +176,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=\"", 2, 0, 2), new LocationTagged<string>("\"", 36, 0, 36)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=\"", 2, 0, 2), new LocationTagged<string>("\"", 36, 0, 36)),
|
||||||
Factory.Markup(" href=\"").With(SpanCodeGenerator.Null),
|
Factory.Markup(" href=\"").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup("mailto:anurse@microsoft.com")
|
Factory.Markup("mailto:anurse@microsoft.com")
|
||||||
.With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 9, 0, 9), new LocationTagged<string>("mailto:anurse@microsoft.com", 9, 0, 9))),
|
.With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 9, 0, 9), new LocationTagged<string>("mailto:anurse@microsoft.com", 9, 0, 9))),
|
||||||
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
|
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(">")),
|
Factory.Markup(">")),
|
||||||
Factory.Markup("Email me"),
|
Factory.Markup("Email me"),
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
new MarkupBlock(
|
new MarkupBlock(
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup("<foo"),
|
Factory.Markup("<foo"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("bar", new LocationTagged<string>(" bar=", 4, 0, 4), new LocationTagged<string>(String.Empty, 12, 0, 12)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("bar", new LocationTagged<string>(" bar=", 4, 0, 4), new LocationTagged<string>(string.Empty, 12, 0, 12)),
|
||||||
Factory.Markup(" bar=").With(SpanCodeGenerator.Null),
|
Factory.Markup(" bar=").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup("baz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 9, 0, 9), new LocationTagged<string>("baz", 9, 0, 9)))))),
|
Factory.Markup("baz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 9, 0, 9), new LocationTagged<string>("baz", 9, 0, 9)))))),
|
||||||
new RazorError(RazorResources.FormatParseError_UnfinishedTag("foo"), new SourceLocation(0, 0, 0)));
|
new RazorError(RazorResources.FormatParseError_UnfinishedTag("foo"), new SourceLocation(0, 0, 0)));
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("<foo"),
|
Factory.Markup("<foo"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("bar", new LocationTagged<string>(" bar=\"", 4, 0, 4), new LocationTagged<string>("\"", 14, 0, 14)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("bar", new LocationTagged<string>(" bar=\"", 4, 0, 4), new LocationTagged<string>("\"", 14, 0, 14)),
|
||||||
Factory.Markup(" bar=\"").With(SpanCodeGenerator.Null),
|
Factory.Markup(" bar=\"").With(SpanCodeGenerator.Null),
|
||||||
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 10, 0, 10), 10, 0, 10),
|
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 10, 0, 10), 10, 0, 10),
|
||||||
new ExpressionBlock(
|
new ExpressionBlock(
|
||||||
Factory.CodeTransition(),
|
Factory.CodeTransition(),
|
||||||
Factory.Code("baz")
|
Factory.Code("baz")
|
||||||
|
|
@ -204,7 +204,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=\"", 2, 0, 2), new LocationTagged<string>("\"", 36, 0, 36)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=\"", 2, 0, 2), new LocationTagged<string>("\"", 36, 0, 36)),
|
||||||
Factory.Markup(" href=\"").With(SpanCodeGenerator.Null),
|
Factory.Markup(" href=\"").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup("mailto:anurse@microsoft.com")
|
Factory.Markup("mailto:anurse@microsoft.com")
|
||||||
.With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 9, 0, 9), new LocationTagged<string>("mailto:anurse@microsoft.com", 9, 0, 9))),
|
.With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 9, 0, 9), new LocationTagged<string>("mailto:anurse@microsoft.com", 9, 0, 9))),
|
||||||
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
|
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(">").Accepts(AcceptedCharacters.None)),
|
Factory.Markup(">").Accepts(AcceptedCharacters.None)),
|
||||||
Factory.Markup("Email me"),
|
Factory.Markup("Email me"),
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("~/Foo/Bar/Baz")
|
Factory.Markup("~/Foo/Bar/Baz")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 9, 0, 9),
|
new LocationTagged<string>(string.Empty, 9, 0, 9),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
||||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(" />").Accepts(AcceptedCharacters.None))));
|
Factory.Markup(" />").Accepts(AcceptedCharacters.None))));
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("~/Foo/Bar/Baz")
|
Factory.Markup("~/Foo/Bar/Baz")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 9, 0, 9),
|
new LocationTagged<string>(string.Empty, 9, 0, 9),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
||||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(" />"))));
|
Factory.Markup(" />"))));
|
||||||
|
|
@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("~/Foo/Bar/Baz")
|
Factory.Markup("~/Foo/Bar/Baz")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 24, 0, 24),
|
new LocationTagged<string>(string.Empty, 24, 0, 24),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 24, 0, 24))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 24, 0, 24))),
|
||||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(" />")),
|
Factory.Markup(" />")),
|
||||||
|
|
@ -92,16 +92,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("~/Foo/")
|
Factory.Markup("~/Foo/")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 9, 0, 9),
|
new LocationTagged<string>(string.Empty, 9, 0, 9),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
||||||
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 15, 0, 15), 15, 0, 15),
|
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 15, 0, 15), 15, 0, 15),
|
||||||
new ExpressionBlock(
|
new ExpressionBlock(
|
||||||
Factory.CodeTransition().Accepts(AcceptedCharacters.None),
|
Factory.CodeTransition().Accepts(AcceptedCharacters.None),
|
||||||
Factory.Code("id")
|
Factory.Code("id")
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
||||||
Factory.Markup("/Baz")
|
Factory.Markup("/Baz")
|
||||||
.With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 18, 0, 18), new LocationTagged<string>("/Baz", 18, 0, 18))),
|
.With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 18, 0, 18), new LocationTagged<string>("/Baz", 18, 0, 18))),
|
||||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(" />").Accepts(AcceptedCharacters.None))));
|
Factory.Markup(" />").Accepts(AcceptedCharacters.None))));
|
||||||
}
|
}
|
||||||
|
|
@ -118,16 +118,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("~/Foo/")
|
Factory.Markup("~/Foo/")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 9, 0, 9),
|
new LocationTagged<string>(string.Empty, 9, 0, 9),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
||||||
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 15, 0, 15), 15, 0, 15),
|
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 15, 0, 15), 15, 0, 15),
|
||||||
new ExpressionBlock(
|
new ExpressionBlock(
|
||||||
Factory.CodeTransition().Accepts(AcceptedCharacters.None),
|
Factory.CodeTransition().Accepts(AcceptedCharacters.None),
|
||||||
Factory.Code("id")
|
Factory.Code("id")
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
||||||
Factory.Markup("/Baz")
|
Factory.Markup("/Baz")
|
||||||
.With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 18, 0, 18), new LocationTagged<string>("/Baz", 18, 0, 18))),
|
.With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 18, 0, 18), new LocationTagged<string>("/Baz", 18, 0, 18))),
|
||||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(" />"))));
|
Factory.Markup(" />"))));
|
||||||
}
|
}
|
||||||
|
|
@ -151,16 +151,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("~/Foo/")
|
Factory.Markup("~/Foo/")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 24, 0, 24),
|
new LocationTagged<string>(string.Empty, 24, 0, 24),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 24, 0, 24))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 24, 0, 24))),
|
||||||
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 30, 0, 30), 30, 0, 30),
|
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 30, 0, 30), 30, 0, 30),
|
||||||
new ExpressionBlock(
|
new ExpressionBlock(
|
||||||
Factory.CodeTransition().Accepts(AcceptedCharacters.None),
|
Factory.CodeTransition().Accepts(AcceptedCharacters.None),
|
||||||
Factory.Code("id")
|
Factory.Code("id")
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
||||||
Factory.Markup("/Baz")
|
Factory.Markup("/Baz")
|
||||||
.With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 33, 0, 33), new LocationTagged<string>("/Baz", 33, 0, 33))),
|
.With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 33, 0, 33), new LocationTagged<string>("/Baz", 33, 0, 33))),
|
||||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(" />")),
|
Factory.Markup(" />")),
|
||||||
Factory.Markup(" ")
|
Factory.Markup(" ")
|
||||||
|
|
@ -181,7 +181,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz")
|
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 9, 0, 9),
|
new LocationTagged<string>(string.Empty, 9, 0, 9),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
||||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(" />").Accepts(AcceptedCharacters.None))));
|
Factory.Markup(" />").Accepts(AcceptedCharacters.None))));
|
||||||
|
|
@ -199,7 +199,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz")
|
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 9, 0, 9),
|
new LocationTagged<string>(string.Empty, 9, 0, 9),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
|
||||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||||
Factory.Markup(" />"))));
|
Factory.Markup(" />"))));
|
||||||
|
|
@ -212,21 +212,21 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
new MarkupBlock(
|
new MarkupBlock(
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup("<a"),
|
Factory.Markup("<a"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=", 2, 0, 2), new LocationTagged<string>(String.Empty, 38, 0, 38)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=", 2, 0, 2), new LocationTagged<string>(string.Empty, 38, 0, 38)),
|
||||||
Factory.Markup(" href=").With(SpanCodeGenerator.Null),
|
Factory.Markup(" href=").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz/")
|
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz/")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 8, 0, 8),
|
new LocationTagged<string>(string.Empty, 8, 0, 8),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 8, 0, 8))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 8, 0, 8))),
|
||||||
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 31, 0, 31), 31, 0, 31),
|
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 31, 0, 31), 31, 0, 31),
|
||||||
new ExpressionBlock(
|
new ExpressionBlock(
|
||||||
Factory.CodeTransition()
|
Factory.CodeTransition()
|
||||||
.Accepts(AcceptedCharacters.None),
|
.Accepts(AcceptedCharacters.None),
|
||||||
Factory.Code("id")
|
Factory.Code("id")
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
||||||
Factory.Markup("/Boz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 34, 0, 34), new LocationTagged<string>("/Boz", 34, 0, 34)))),
|
Factory.Markup("/Boz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 34, 0, 34), new LocationTagged<string>("/Boz", 34, 0, 34)))),
|
||||||
Factory.Markup(" />").Accepts(AcceptedCharacters.None))));
|
Factory.Markup(" />").Accepts(AcceptedCharacters.None))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,21 +237,21 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
new MarkupBlock(
|
new MarkupBlock(
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup("<a"),
|
Factory.Markup("<a"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=", 2, 0, 2), new LocationTagged<string>(String.Empty, 38, 0, 38)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=", 2, 0, 2), new LocationTagged<string>(string.Empty, 38, 0, 38)),
|
||||||
Factory.Markup(" href=").With(SpanCodeGenerator.Null),
|
Factory.Markup(" href=").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz/")
|
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz/")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 8, 0, 8),
|
new LocationTagged<string>(string.Empty, 8, 0, 8),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 8, 0, 8))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 8, 0, 8))),
|
||||||
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 31, 0, 31), 31, 0, 31),
|
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 31, 0, 31), 31, 0, 31),
|
||||||
new ExpressionBlock(
|
new ExpressionBlock(
|
||||||
Factory.CodeTransition()
|
Factory.CodeTransition()
|
||||||
.Accepts(AcceptedCharacters.None),
|
.Accepts(AcceptedCharacters.None),
|
||||||
Factory.Code("id")
|
Factory.Code("id")
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
||||||
Factory.Markup("/Boz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 34, 0, 34), new LocationTagged<string>("/Boz", 34, 0, 34)))),
|
Factory.Markup("/Boz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 34, 0, 34), new LocationTagged<string>("/Boz", 34, 0, 34)))),
|
||||||
Factory.Markup(" />"))));
|
Factory.Markup(" />"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,21 +269,21 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
||||||
Factory.Markup(" "),
|
Factory.Markup(" "),
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup("<a"),
|
Factory.Markup("<a"),
|
||||||
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=", 17, 0, 17), new LocationTagged<string>(String.Empty, 53, 0, 53)),
|
new MarkupBlock(new AttributeBlockCodeGenerator("href", new LocationTagged<string>(" href=", 17, 0, 17), new LocationTagged<string>(string.Empty, 53, 0, 53)),
|
||||||
Factory.Markup(" href=").With(SpanCodeGenerator.Null),
|
Factory.Markup(" href=").With(SpanCodeGenerator.Null),
|
||||||
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz/")
|
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz/")
|
||||||
.WithEditorHints(EditorHints.VirtualPath)
|
.WithEditorHints(EditorHints.VirtualPath)
|
||||||
.With(new LiteralAttributeCodeGenerator(
|
.With(new LiteralAttributeCodeGenerator(
|
||||||
new LocationTagged<string>(String.Empty, 23, 0, 23),
|
new LocationTagged<string>(string.Empty, 23, 0, 23),
|
||||||
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 23, 0, 23))),
|
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 23, 0, 23))),
|
||||||
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 46, 0, 46), 46, 0, 46),
|
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 46, 0, 46), 46, 0, 46),
|
||||||
new ExpressionBlock(
|
new ExpressionBlock(
|
||||||
Factory.CodeTransition()
|
Factory.CodeTransition()
|
||||||
.Accepts(AcceptedCharacters.None),
|
.Accepts(AcceptedCharacters.None),
|
||||||
Factory.Code("id")
|
Factory.Code("id")
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
||||||
Factory.Markup("/Boz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 49, 0, 49), new LocationTagged<string>("/Boz", 49, 0, 49)))),
|
Factory.Markup("/Boz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 49, 0, 49), new LocationTagged<string>("/Boz", 49, 0, 49)))),
|
||||||
Factory.Markup(" />")),
|
Factory.Markup(" />")),
|
||||||
Factory.Markup(" ")
|
Factory.Markup(" ")
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
||||||
|
|
||||||
public void InitializeWithDocument(ITextBuffer startDocument)
|
public void InitializeWithDocument(ITextBuffer startDocument)
|
||||||
{
|
{
|
||||||
CheckForStructureChangesAndWait(new TextChange(0, 0, new StringTextBuffer(String.Empty), startDocument.Length, startDocument));
|
CheckForStructureChangesAndWait(new TextChange(0, 0, new StringTextBuffer(string.Empty), startDocument.Length, startDocument));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PartialParseResult CheckForStructureChangesAndWait(TextChange change)
|
public PartialParseResult CheckForStructureChangesAndWait(TextChange change)
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ namespace Microsoft.AspNet.Razor.Test.Text
|
||||||
var text = textChange.NewText;
|
var text = textChange.NewText;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(String.Empty, text);
|
Assert.Equal(string.Empty, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
||||||
{
|
{
|
||||||
public abstract class CSharpTokenizerTestBase : TokenizerTestBase<CSharpSymbol, CSharpSymbolType>
|
public abstract class CSharpTokenizerTestBase : TokenizerTestBase<CSharpSymbol, CSharpSymbolType>
|
||||||
{
|
{
|
||||||
private static CSharpSymbol _ignoreRemaining = new CSharpSymbol(0, 0, 0, String.Empty, CSharpSymbolType.Unknown);
|
private static CSharpSymbol _ignoreRemaining = new CSharpSymbol(0, 0, 0, string.Empty, CSharpSymbolType.Unknown);
|
||||||
|
|
||||||
protected override CSharpSymbol IgnoreRemaining
|
protected override CSharpSymbol IgnoreRemaining
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
||||||
{
|
{
|
||||||
public abstract class HtmlTokenizerTestBase : TokenizerTestBase<HtmlSymbol, HtmlSymbolType>
|
public abstract class HtmlTokenizerTestBase : TokenizerTestBase<HtmlSymbol, HtmlSymbolType>
|
||||||
{
|
{
|
||||||
private static HtmlSymbol _ignoreRemaining = new HtmlSymbol(0, 0, 0, String.Empty, HtmlSymbolType.Unknown);
|
private static HtmlSymbol _ignoreRemaining = new HtmlSymbol(0, 0, 0, string.Empty, HtmlSymbolType.Unknown);
|
||||||
|
|
||||||
protected override HtmlSymbol IgnoreRemaining
|
protected override HtmlSymbol IgnoreRemaining
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -34,23 +34,23 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
||||||
{
|
{
|
||||||
if (counter >= expectedSymbols.Length)
|
if (counter >= expectedSymbols.Length)
|
||||||
{
|
{
|
||||||
output.AppendLine(String.Format("F: Expected: << Nothing >>; Actual: {0}", current));
|
output.AppendLine(string.Format("F: Expected: << Nothing >>; Actual: {0}", current));
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
else if (ReferenceEquals(expectedSymbols[counter], IgnoreRemaining))
|
else if (ReferenceEquals(expectedSymbols[counter], IgnoreRemaining))
|
||||||
{
|
{
|
||||||
output.AppendLine(String.Format("P: Ignored {0}", current));
|
output.AppendLine(string.Format("P: Ignored {0}", current));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!Equals(expectedSymbols[counter], current))
|
if (!Equals(expectedSymbols[counter], current))
|
||||||
{
|
{
|
||||||
output.AppendLine(String.Format("F: Expected: {0}; Actual: {1}", expectedSymbols[counter], current));
|
output.AppendLine(string.Format("F: Expected: {0}; Actual: {1}", expectedSymbols[counter], current));
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
output.AppendLine(String.Format("P: Expected: {0}", expectedSymbols[counter]));
|
output.AppendLine(string.Format("P: Expected: {0}", expectedSymbols[counter]));
|
||||||
}
|
}
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
||||||
success = false;
|
success = false;
|
||||||
for (; counter < expectedSymbols.Length; counter++)
|
for (; counter < expectedSymbols.Length; counter++)
|
||||||
{
|
{
|
||||||
output.AppendLine(String.Format("F: Expected: {0}; Actual: << None >>", expectedSymbols[counter]));
|
output.AppendLine(string.Format("F: Expected: {0}; Actual: << None >>", expectedSymbols[counter]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
||||||
[Conditional("PARSER_TRACE")]
|
[Conditional("PARSER_TRACE")]
|
||||||
private static void WriteTraceLine(string format, params object[] args)
|
private static void WriteTraceLine(string format, params object[] args)
|
||||||
{
|
{
|
||||||
Trace.WriteLine(String.Format(format, args));
|
Trace.WriteLine(string.Format(format, args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue