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;
|
||||
return base.Equals(obj) &&
|
||||
other != null &&
|
||||
String.Equals(other.AutoCompleteString, AutoCompleteString, StringComparison.Ordinal) &&
|
||||
string.Equals(other.AutoCompleteString, AutoCompleteString, StringComparison.Ordinal) &&
|
||||
AutoCompleteAtEndOfSpan == other.AutoCompleteAtEndOfSpan;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Razor.Editor
|
|||
|
||||
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)
|
||||
|
|
@ -134,7 +134,7 @@ namespace Microsoft.AspNet.Razor.Editor
|
|||
{
|
||||
// Do not need to worry about other punctuation, just looking for double '.' (after change)
|
||||
return change.NewLength == 1 &&
|
||||
!String.IsNullOrEmpty(target.Content) &&
|
||||
!string.IsNullOrEmpty(target.Content) &&
|
||||
target.Content.Last() == '.' &&
|
||||
change.NewText == "." &&
|
||||
change.OldLength == 0;
|
||||
|
|
@ -187,7 +187,7 @@ namespace Microsoft.AspNet.Razor.Editor
|
|||
private static bool RemainingIsWhitespace(Span target, TextChange change)
|
||||
{
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Razor.Editor
|
|||
// No Trace in CoreCLR
|
||||
|
||||
Trace.WriteLine(RazorResources.FormatTrace_Format(
|
||||
String.Format(CultureInfo.CurrentCulture, format, args)));
|
||||
string.Format(CultureInfo.CurrentCulture, format, args)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ namespace Microsoft.AspNet.Razor.Editor
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
var ns = Namespace;
|
||||
|
||||
if (!String.IsNullOrEmpty(ns) && Char.IsWhiteSpace(ns[0]))
|
||||
if (!string.IsNullOrEmpty(ns) && Char.IsWhiteSpace(ns[0]))
|
||||
{
|
||||
ns = ns.Substring(1);
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
var other = obj as AddImportCodeGenerator;
|
||||
return other != null &&
|
||||
String.Equals(Namespace, other.Namespace, StringComparison.Ordinal) &&
|
||||
string.Equals(Namespace, other.Namespace, StringComparison.Ordinal) &&
|
||||
NamespaceKeywordLength == other.NamespaceKeywordLength;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
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)
|
||||
{
|
||||
var other = obj as AttributeBlockCodeGenerator;
|
||||
return other != null &&
|
||||
String.Equals(other.Name, Name, StringComparison.Ordinal) &&
|
||||
string.Equals(other.Name, Name, StringComparison.Ordinal) &&
|
||||
Equals(other.Prefix, Prefix) &&
|
||||
Equals(other.Suffix, Suffix);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
public CSharpCodeWriter WriteVariableDeclaration(string type, string name, string value)
|
||||
{
|
||||
Write(type).Write(" ").Write(name);
|
||||
if (!String.IsNullOrEmpty(value))
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
Write(" = ").Write(value);
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
|
||||
public CSharpCodeWriter WriteUsing(string name, bool endLine)
|
||||
{
|
||||
Write(String.Format("using {0}", name));
|
||||
Write(string.Format("using {0}", name));
|
||||
|
||||
if (endLine)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
if (_host.DesignTimeMode &&
|
||||
padding > 0 &&
|
||||
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--;
|
||||
}
|
||||
|
|
@ -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
|
||||
// whitespace into existing spans so you'll see tabs, newlines etc. within spans. We only care about
|
||||
// the \t in existing spans.
|
||||
var previousContent = firstSpanInLine.Previous.Content ?? String.Empty;
|
||||
var previousContent = firstSpanInLine.Previous.Content ?? string.Empty;
|
||||
|
||||
var lastNewLineIndex = previousContent.LastIndexOfAny(_newLineChars);
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
|
||||
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)
|
||||
.Write(" = ")
|
||||
|
|
@ -110,7 +110,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
|
||||
protected override void Visit(ResolveUrlChunk chunk)
|
||||
{
|
||||
if (!Context.Host.DesignTimeMode && String.IsNullOrEmpty(chunk.Url))
|
||||
if (!Context.Host.DesignTimeMode && string.IsNullOrEmpty(chunk.Url))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
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)
|
||||
{
|
||||
|
|
@ -320,7 +320,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
return;
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(Context.TargetWriterName))
|
||||
if (!string.IsNullOrEmpty(Context.TargetWriterName))
|
||||
{
|
||||
Writer.WriteStartMethodInvocation(Context.Host.GeneratedClassContext.WriteAttributeToMethodName)
|
||||
.Write(Context.TargetWriterName)
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
|
||||
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()
|
||||
{
|
||||
return String.Format(CultureInfo.CurrentCulture, "DynAttr:{0:F}", Prefix);
|
||||
return string.Format(CultureInfo.CurrentCulture, "DynAttr:{0:F}", Prefix);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (String.IsNullOrEmpty(className))
|
||||
if (string.IsNullOrEmpty(className))
|
||||
{
|
||||
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "className");
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
ClassName = className;
|
||||
RootNamespaceName = rootNamespaceName;
|
||||
SourceFileName = sourceFileName;
|
||||
GenerateLinePragmas = String.IsNullOrEmpty(SourceFileName) ? false : true;
|
||||
GenerateLinePragmas = string.IsNullOrEmpty(SourceFileName) ? false : true;
|
||||
Host = host;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
||||
{
|
||||
// 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
|
||||
new MarkupCodeGenerator().GenerateCode(target, context);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
var other = obj as SectionCodeGenerator;
|
||||
return other != null &&
|
||||
base.Equals(other) &&
|
||||
String.Equals(SectionName, other.SectionName, StringComparison.Ordinal);
|
||||
string.Equals(SectionName, other.SectionName, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
var other = obj as SetBaseTypeCodeGenerator;
|
||||
return other != null &&
|
||||
String.Equals(BaseType, other.BaseType, StringComparison.Ordinal);
|
||||
string.Equals(BaseType, other.BaseType, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
public override bool Equals(object obj)
|
||||
{
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
IEnumerable<CSharpSymbol> ws = ReadWhile(IsSpacingToken(includeNewLines: true, includeComments: false));
|
||||
|
||||
// Get the section name
|
||||
var sectionName = String.Empty;
|
||||
var sectionName = string.Empty;
|
||||
if (!Required(CSharpSymbolType.Identifier,
|
||||
errorIfNotFound: true,
|
||||
errorBase: RazorResources.FormatParseError_Unexpected_Character_At_Section_Name_Start))
|
||||
|
|
@ -236,7 +236,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
protected void AssertDirective(string directive)
|
||||
{
|
||||
Assert(CSharpSymbolType.Identifier);
|
||||
Debug.Assert(String.Equals(CurrentSymbol.Content, directive, StringComparison.Ordinal));
|
||||
Debug.Assert(string.Equals(CurrentSymbol.Content, directive, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
protected void InheritsDirectiveCore()
|
||||
|
|
|
|||
|
|
@ -508,7 +508,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
// If necessary, put an empty-content marker symbol here
|
||||
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 ")"
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
protected override SyntaxTreeNode RewriteBlock(BlockBuilder parent, Block block)
|
||||
{
|
||||
// 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
|
||||
var span = new SpanBuilder();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
|
||||
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())
|
||||
{
|
||||
|
|
@ -521,7 +521,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
}
|
||||
|
||||
// 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))
|
||||
{
|
||||
suffix = CurrentSymbol.GetContent();
|
||||
|
|
@ -967,7 +967,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
while (tags.Count > 0)
|
||||
{
|
||||
currentTag = tags.Pop();
|
||||
if (String.Equals(tagName, currentTag.Item1.Content, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(tagName, currentTag.Item1.Content, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Matched the tag
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -90,14 +90,14 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
private bool AtEnd(string[] nestingSequenceComponents)
|
||||
{
|
||||
EnsureCurrent();
|
||||
if (String.Equals(CurrentSymbol.Content, nestingSequenceComponents[0], Comparison))
|
||||
if (string.Equals(CurrentSymbol.Content, nestingSequenceComponents[0], Comparison))
|
||||
{
|
||||
var bookmark = CurrentSymbol.Start.AbsoluteIndex;
|
||||
try
|
||||
{
|
||||
foreach (string component in nestingSequenceComponents)
|
||||
{
|
||||
if (!EndOfFile && !String.Equals(CurrentSymbol.Content, component, Comparison))
|
||||
if (!EndOfFile && !string.Equals(CurrentSymbol.Content, component, Comparison))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
position + sequence.Length <= CurrentSymbol.Content.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)
|
||||
var bookmark = Context.Source.Position;
|
||||
|
|
@ -159,7 +159,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
var postSequence = pair.Item2;
|
||||
|
||||
// Accept the first chunk (up to the nesting sequence we just saw)
|
||||
if (!String.IsNullOrEmpty(preSequence.Content))
|
||||
if (!string.IsNullOrEmpty(preSequence.Content))
|
||||
{
|
||||
Accept(preSequence);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
public static bool IsNewLine(string value)
|
||||
{
|
||||
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
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace Microsoft.AspNet.Razor.Parser.SyntaxTree
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ namespace Microsoft.AspNet.Razor.Parser.SyntaxTree
|
|||
builder.Append(" Gen: <");
|
||||
builder.Append(CodeGenerator.ToString());
|
||||
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("}");
|
||||
return builder.ToString();
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ namespace Microsoft.AspNet.Razor.Parser.SyntaxTree
|
|||
Kind.Equals(other.Kind) &&
|
||||
Start.Equals(other.Start) &&
|
||||
EditHandler.Equals(other.EditHandler) &&
|
||||
String.Equals(other.Content, Content, StringComparison.Ordinal);
|
||||
string.Equals(other.Content, Content, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
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)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
AcceptWhile(sym => !Equals(type1, sym.Type) && !Equals(type2, sym.Type));
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Razor
|
|||
{
|
||||
throw new ArgumentNullException("host");
|
||||
}
|
||||
if (String.IsNullOrEmpty(sourceFileName))
|
||||
if (string.IsNullOrEmpty(sourceFileName))
|
||||
{
|
||||
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "sourceFileName");
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ namespace Microsoft.AspNet.Razor
|
|||
var result = PartialParseResult.Rejected;
|
||||
|
||||
// If there isn't already a parse underway, try partial-parsing
|
||||
var changeString = String.Empty;
|
||||
var changeString = string.Empty;
|
||||
using (_parser.SynchronizeMainThreadState())
|
||||
{
|
||||
// Capture the string value of the change while we're synchronized
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Razor
|
|||
|
||||
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)
|
||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Razor
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ Instead, wrap the contents of the block in "{{}}":
|
|||
</data>
|
||||
<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>
|
||||
<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 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>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Razor
|
|||
{
|
||||
private const int BufferSize = 1024;
|
||||
public static readonly string DefaultClassName = "Template";
|
||||
public static readonly string DefaultNamespace = String.Empty;
|
||||
public static readonly string DefaultNamespace = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new RazorTemplateEngine with the specified host
|
||||
|
|
@ -41,11 +41,11 @@ namespace Microsoft.AspNet.Razor
|
|||
/// <summary>
|
||||
/// The RazorEngineHost which defines the environment in which the generated template code will live
|
||||
/// </summary>
|
||||
public RazorEngineHost Host { get; private set; }
|
||||
public RazorEngineHost Host { get; }
|
||||
|
||||
public ParserResults ParseTemplate(ITextBuffer input)
|
||||
{
|
||||
return ParseTemplate(input, null);
|
||||
return ParseTemplate(input, cancelToken: null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -63,7 +63,10 @@ namespace Microsoft.AspNet.Razor
|
|||
/// <param name="input">The input text to parse</param>
|
||||
/// <param name="cancelToken">A token used to cancel the parser</param>
|
||||
/// <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)
|
||||
{
|
||||
return ParseTemplateCore(input.ToDocument(), sourceFileName: null, cancelToken: cancelToken);
|
||||
|
|
@ -76,15 +79,20 @@ namespace Microsoft.AspNet.Razor
|
|||
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)
|
||||
{
|
||||
return ParseTemplateCore(new SeekableTextReader(input), sourceFileName: null, cancelToken: cancelToken);
|
||||
}
|
||||
|
||||
protected internal virtual ParserResults ParseTemplateCore(ITextDocument input,
|
||||
string sourceFileName,
|
||||
CancellationToken? cancelToken)
|
||||
protected internal virtual ParserResults ParseTemplateCore(
|
||||
ITextDocument input,
|
||||
string sourceFileName,
|
||||
CancellationToken? cancelToken)
|
||||
{
|
||||
// Construct the parser
|
||||
var parser = CreateParser(sourceFileName);
|
||||
|
|
@ -94,17 +102,22 @@ namespace Microsoft.AspNet.Razor
|
|||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return GenerateCode(input, className, rootNamespace, sourceFileName, null);
|
||||
return GenerateCode(input, className, rootNamespace, sourceFileName, cancelToken: null);
|
||||
}
|
||||
|
||||
/// <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="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>
|
||||
[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 GeneratorResults GenerateCode(ITextBuffer input, string className, string rootNamespace, string sourceFileName, CancellationToken? cancelToken)
|
||||
[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 GeneratorResults GenerateCode(
|
||||
ITextBuffer input,
|
||||
string className,
|
||||
string rootNamespace,
|
||||
string sourceFileName,
|
||||
CancellationToken? cancelToken)
|
||||
{
|
||||
return GenerateCodeCore(input.ToDocument(),
|
||||
className,
|
||||
rootNamespace,
|
||||
sourceFileName,
|
||||
checksum: null,
|
||||
cancelToken: cancelToken);
|
||||
return GenerateCodeCore(
|
||||
input.ToDocument(),
|
||||
className,
|
||||
rootNamespace,
|
||||
sourceFileName,
|
||||
checksum: null,
|
||||
cancelToken: cancelToken);
|
||||
}
|
||||
|
||||
// See GenerateCode override which takes ITextBuffer, and BufferingTextReader for details.
|
||||
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)
|
||||
{
|
||||
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>
|
||||
|
|
@ -170,10 +202,11 @@ namespace Microsoft.AspNet.Razor
|
|||
/// generation. The checksum is used for producing the <c>#pragma checksum</c> line pragma required for
|
||||
/// debugging.
|
||||
/// </remarks>
|
||||
public GeneratorResults GenerateCode([NotNull] Stream inputStream,
|
||||
string className,
|
||||
string rootNamespace,
|
||||
string sourceFileName)
|
||||
public GeneratorResults GenerateCode(
|
||||
[NotNull] Stream inputStream,
|
||||
string className,
|
||||
string rootNamespace,
|
||||
string sourceFileName)
|
||||
{
|
||||
MemoryStream memoryStream = null;
|
||||
string checksum = null;
|
||||
|
|
@ -197,19 +230,22 @@ namespace Microsoft.AspNet.Razor
|
|||
inputStream.Position = 0;
|
||||
}
|
||||
|
||||
using (var reader = new StreamReader(inputStream,
|
||||
Encoding.UTF8,
|
||||
detectEncodingFromByteOrderMarks: true,
|
||||
bufferSize: BufferSize,
|
||||
leaveOpen: true))
|
||||
using (var reader =
|
||||
new StreamReader(
|
||||
inputStream,
|
||||
Encoding.UTF8,
|
||||
detectEncodingFromByteOrderMarks: true,
|
||||
bufferSize: BufferSize,
|
||||
leaveOpen: true))
|
||||
{
|
||||
var seekableStream = new SeekableTextReader(reader);
|
||||
return GenerateCodeCore(seekableStream,
|
||||
className,
|
||||
rootNamespace,
|
||||
sourceFileName,
|
||||
checksum,
|
||||
cancelToken: null);
|
||||
return GenerateCodeCore(
|
||||
seekableStream,
|
||||
className,
|
||||
rootNamespace,
|
||||
sourceFileName,
|
||||
checksum,
|
||||
cancelToken: null);
|
||||
}
|
||||
}
|
||||
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")]
|
||||
public GeneratorResults GenerateCode(TextReader input, string className, string rootNamespace, string sourceFileName, CancellationToken? cancelToken)
|
||||
[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 GeneratorResults GenerateCode(
|
||||
TextReader input,
|
||||
string className,
|
||||
string rootNamespace,
|
||||
string sourceFileName,
|
||||
CancellationToken? cancelToken)
|
||||
{
|
||||
return GenerateCodeCore(new SeekableTextReader(input),
|
||||
className,
|
||||
rootNamespace,
|
||||
sourceFileName,
|
||||
checksum: null,
|
||||
cancelToken: cancelToken);
|
||||
return GenerateCodeCore(
|
||||
new SeekableTextReader(input),
|
||||
className,
|
||||
rootNamespace,
|
||||
sourceFileName,
|
||||
checksum: null,
|
||||
cancelToken: cancelToken);
|
||||
}
|
||||
|
||||
protected internal virtual GeneratorResults GenerateCodeCore(ITextDocument input,
|
||||
string className,
|
||||
string rootNamespace,
|
||||
string sourceFileName,
|
||||
string checksum,
|
||||
CancellationToken? cancelToken)
|
||||
protected internal virtual GeneratorResults GenerateCodeCore(
|
||||
ITextDocument input,
|
||||
string className,
|
||||
string rootNamespace,
|
||||
string sourceFileName,
|
||||
string checksum,
|
||||
CancellationToken? cancelToken)
|
||||
{
|
||||
className = (className ?? Host.DefaultClassName) ?? DefaultClassName;
|
||||
rootNamespace = (rootNamespace ?? Host.DefaultNamespace) ?? DefaultNamespace;
|
||||
|
|
@ -261,7 +308,10 @@ namespace Microsoft.AspNet.Razor
|
|||
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(
|
||||
Host.CodeLanguage.CreateCodeGenerator(className, rootNamespace, sourceFileName, Host));
|
||||
|
|
@ -272,9 +322,10 @@ namespace Microsoft.AspNet.Razor
|
|||
var codeParser = Host.CodeLanguage.CreateCodeParser();
|
||||
var markupParser = Host.CreateMarkupParser();
|
||||
|
||||
var parser = new RazorParser(Host.DecorateCodeParser(codeParser),
|
||||
Host.DecorateMarkupParser(markupParser),
|
||||
Host.TagHelperDescriptorResolver)
|
||||
var parser = new RazorParser(
|
||||
Host.DecorateCodeParser(codeParser),
|
||||
Host.DecorateMarkupParser(markupParser),
|
||||
Host.TagHelperDescriptorResolver)
|
||||
{
|
||||
DesignTimeMode = Host.DesignTimeMode
|
||||
};
|
||||
|
|
@ -284,8 +335,7 @@ namespace Microsoft.AspNet.Razor
|
|||
|
||||
protected internal virtual CodeBuilder CreateCodeBuilder(CodeBuilderContext context)
|
||||
{
|
||||
return Host.DecorateCodeBuilder(Host.CodeLanguage.CreateCodeBuilder(context),
|
||||
context);
|
||||
return Host.DecorateCodeBuilder(Host.CodeLanguage.CreateCodeBuilder(context), context);
|
||||
}
|
||||
|
||||
private static string ComputeChecksum(Stream inputStream)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Razor
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format(
|
||||
return string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
"({0}:{1},{2})",
|
||||
AbsoluteIndex,
|
||||
|
|
@ -58,9 +58,10 @@ namespace Microsoft.AspNet.Razor
|
|||
|
||||
public bool Equals(SourceLocation other)
|
||||
{
|
||||
return AbsoluteIndex == other.AbsoluteIndex &&
|
||||
LineIndex == other.LineIndex &&
|
||||
CharacterIndex == other.CharacterIndex;
|
||||
return
|
||||
AbsoluteIndex == other.AbsoluteIndex &&
|
||||
LineIndex == other.LineIndex &&
|
||||
CharacterIndex == other.CharacterIndex;
|
||||
}
|
||||
|
||||
public int CompareTo(SourceLocation other)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Razor.Text
|
|||
|
||||
public string ToString(string format, IFormatProvider formatProvider)
|
||||
{
|
||||
if (String.IsNullOrEmpty(format))
|
||||
if (string.IsNullOrEmpty(format))
|
||||
{
|
||||
format = "P";
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Razor.Text
|
|||
switch (format.ToUpperInvariant())
|
||||
{
|
||||
case "F":
|
||||
return String.Format(formatProvider, "{0}@{1}", Value, Location);
|
||||
return string.Format(formatProvider, "{0}@{1}", Value, Location);
|
||||
default:
|
||||
return Value.ToString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ namespace Microsoft.AspNet.Razor.Text
|
|||
|
||||
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>
|
||||
|
|
@ -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.
|
||||
if (length == 0)
|
||||
{
|
||||
return String.Empty;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var oldPosition = buffer.Position;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
|||
SymbolBase<TType> other = obj as SymbolBase<TType>;
|
||||
return other != null &&
|
||||
Start.Equals(other.Start) &&
|
||||
String.Equals(Content, other.Content, StringComparison.Ordinal) &&
|
||||
string.Equals(Content, other.Content, StringComparison.Ordinal) &&
|
||||
Type.Equals(other.Type);
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
|||
{
|
||||
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
|
||||
{
|
||||
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);
|
||||
#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
|
||||
}
|
||||
|
||||
|
|
@ -345,7 +345,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer
|
|||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ namespace Microsoft.AspNet.Razor.Test.Editor
|
|||
};
|
||||
|
||||
// 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
|
||||
MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait);
|
||||
|
|
@ -162,7 +162,7 @@ namespace Microsoft.AspNet.Razor.Test.Editor
|
|||
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
|
||||
parseComplete.Reset();
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ namespace Microsoft.AspNet.Razor.Test.Editor
|
|||
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
{
|
||||
if (results != null && results.Document != null)
|
||||
{
|
||||
WriteTraceLine(String.Empty);
|
||||
WriteTraceLine(string.Empty);
|
||||
WriteTraceLine("Actual Parse Tree:");
|
||||
WriteNode(0, results.Document);
|
||||
}
|
||||
|
|
@ -491,7 +491,7 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
[Conditional("PARSER_TRACE")]
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
public static UnclassifiedCodeSpanConstructor EmptyCSharp(this SpanFactory self)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
[Fact]
|
||||
public void ConstructorAllowsEmptyRootNamespaceName()
|
||||
{
|
||||
new CSharpRazorCodeGenerator("Foo", String.Empty, TestPhysicalPath, CreateHost());
|
||||
new CSharpRazorCodeGenerator("Foo", string.Empty, TestPhysicalPath, CreateHost());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -173,11 +173,11 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
using (var source = TestFile.Create(sourceLocation).OpenRead())
|
||||
{
|
||||
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);
|
||||
}
|
||||
// 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
|
||||
var textOutput = results.GeneratedCode;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.Markup("<p>").Accepts(AcceptedCharacters.None)),
|
||||
new MarkupTagBlock(
|
||||
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())
|
||||
),
|
||||
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)
|
||||
{
|
||||
var errors = new RazorError[0];
|
||||
if (!String.IsNullOrEmpty(errorMessage) && location.HasValue)
|
||||
if (!string.IsNullOrEmpty(errorMessage) && location.HasValue)
|
||||
{
|
||||
errors = new RazorError[]
|
||||
{
|
||||
|
|
|
|||
|
|
@ -588,10 +588,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
[Fact]
|
||||
public void ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode()
|
||||
{
|
||||
ParseBlockTest(@"{String.Format(<html></html>}",
|
||||
ParseBlockTest(@"{string.Format(<html></html>}",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("String.Format(")
|
||||
Factory.Code("string.Format(")
|
||||
.AsStatement(),
|
||||
new MarkupBlock(
|
||||
BlockFactory.MarkupTagBlock("<html>", AcceptedCharacters.None),
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.MetaCode("layout ").Accepts(AcceptedCharacters.None),
|
||||
Factory.EmptyCSharp()
|
||||
.AsMetaCode()
|
||||
.With(new SetLayoutCodeGenerator(String.Empty))
|
||||
.With(new SetLayoutCodeGenerator(string.Empty))
|
||||
.WithEditorHints(EditorHints.VirtualPath | EditorHints.LayoutPage)
|
||||
)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
||||
Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
string.Empty,
|
||||
HtmlSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any))),
|
||||
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 0, 0, 0));
|
||||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
||||
Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
string.Empty,
|
||||
HtmlSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
||||
|
|
@ -72,7 +72,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new CSharpSymbol(
|
||||
Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
string.Empty,
|
||||
CSharpSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any),
|
||||
Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar)
|
||||
|
|
@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new CSharpSymbol(
|
||||
Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
string.Empty,
|
||||
CSharpSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any)))),
|
||||
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 5, 0, 5),
|
||||
|
|
@ -135,7 +135,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
||||
Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
string.Empty,
|
||||
HtmlSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
||||
|
|
@ -165,7 +165,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new CSharpSymbol(Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
string.Empty,
|
||||
CSharpSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any)))),
|
||||
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,
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator(String.Empty),
|
||||
new SectionBlock(new SectionCodeGenerator(string.Empty),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("section" + Environment.NewLine))),
|
||||
new RazorError(
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
new DirectiveBlock(
|
||||
Factory.MetaCode("inherits ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code(" " + Environment.NewLine)
|
||||
.AsBaseType(String.Empty)
|
||||
.AsBaseType(string.Empty)
|
||||
),
|
||||
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()
|
||||
{
|
||||
// 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
|
||||
ParseBlockTest("{" + code + "}",
|
||||
|
|
@ -118,7 +118,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
public void ParseBlockBalancesParensOutsideStringsIfFirstCharacterIsParenAndReturnsSpanOfTypeExpression()
|
||||
{
|
||||
// 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
|
||||
ParseBlockTest("(" + code + ")",
|
||||
|
|
|
|||
|
|
@ -215,16 +215,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("<foo"),
|
||||
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("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(">").Accepts(AcceptedCharacters.None)),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<biz>").Accepts(AcceptedCharacters.None)),
|
||||
new MarkupTagBlock(
|
||||
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("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)),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</biz>").Accepts(AcceptedCharacters.None)),
|
||||
|
|
@ -243,7 +243,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("<bar"),
|
||||
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(">").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(" />").Accepts(AcceptedCharacters.None)),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -261,7 +261,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("<bar"),
|
||||
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(">").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(" />").Accepts(AcceptedCharacters.None)),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -279,7 +279,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("<bar"),
|
||||
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("/").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(">").Accepts(AcceptedCharacters.None)),
|
||||
new MarkupTagBlock(
|
||||
|
|
@ -299,7 +299,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("<bar"),
|
||||
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("/").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(">").Accepts(AcceptedCharacters.None)),
|
||||
new MarkupTagBlock(
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
[Fact]
|
||||
public void ParseDocumentOutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString()
|
||||
{
|
||||
ParseDocumentTest(String.Empty, new MarkupBlock(Factory.EmptyHtml()));
|
||||
ParseDocumentTest(string.Empty, new MarkupBlock(Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[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)),
|
||||
Factory.Markup(" href=\"").With(SpanCodeGenerator.Null),
|
||||
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(">")),
|
||||
Factory.Markup("Email me"),
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
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("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)));
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("<foo"),
|
||||
new MarkupBlock(new AttributeBlockCodeGenerator("bar", new LocationTagged<string>(" bar=\"", 4, 0, 4), new LocationTagged<string>("\"", 14, 0, 14)),
|
||||
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(
|
||||
Factory.CodeTransition(),
|
||||
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)),
|
||||
Factory.Markup(" href=\"").With(SpanCodeGenerator.Null),
|
||||
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(">").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("Email me"),
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("~/Foo/Bar/Baz")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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))),
|
||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||
Factory.Markup(" />").Accepts(AcceptedCharacters.None))));
|
||||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("~/Foo/Bar/Baz")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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))),
|
||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||
Factory.Markup(" />"))));
|
||||
|
|
@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("~/Foo/Bar/Baz")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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))),
|
||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||
Factory.Markup(" />")),
|
||||
|
|
@ -92,16 +92,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("~/Foo/")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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 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(
|
||||
Factory.CodeTransition().Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("id")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
||||
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(" />").Accepts(AcceptedCharacters.None))));
|
||||
}
|
||||
|
|
@ -118,16 +118,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("~/Foo/")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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 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(
|
||||
Factory.CodeTransition().Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("id")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
||||
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(" />"))));
|
||||
}
|
||||
|
|
@ -151,16 +151,16 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("~/Foo/")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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 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(
|
||||
Factory.CodeTransition().Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("id")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace))),
|
||||
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(" />")),
|
||||
Factory.Markup(" ")
|
||||
|
|
@ -181,7 +181,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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))),
|
||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||
Factory.Markup(" />").Accepts(AcceptedCharacters.None))));
|
||||
|
|
@ -199,7 +199,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup("~/Foo+Bar:Baz(Biz),Boz")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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))),
|
||||
Factory.Markup("'").With(SpanCodeGenerator.Null)),
|
||||
Factory.Markup(" />"))));
|
||||
|
|
@ -212,21 +212,21 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
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("~/Foo+Bar:Baz(Biz),Boz/")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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 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(
|
||||
Factory.CodeTransition()
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("id")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.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))));
|
||||
}
|
||||
|
||||
|
|
@ -237,21 +237,21 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
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("~/Foo+Bar:Baz(Biz),Boz/")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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 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(
|
||||
Factory.CodeTransition()
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("id")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.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(" />"))));
|
||||
}
|
||||
|
||||
|
|
@ -269,21 +269,21 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
|
|||
Factory.Markup(" "),
|
||||
new MarkupTagBlock(
|
||||
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("~/Foo+Bar:Baz(Biz),Boz/")
|
||||
.WithEditorHints(EditorHints.VirtualPath)
|
||||
.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 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(
|
||||
Factory.CodeTransition()
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("id")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.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(" ")
|
||||
),
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ namespace Microsoft.AspNet.Razor.Test.Text
|
|||
var text = textChange.NewText;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(String.Empty, text);
|
||||
Assert.Equal(string.Empty, text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
|||
{
|
||||
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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
|||
{
|
||||
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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,23 +34,23 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
|||
{
|
||||
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;
|
||||
}
|
||||
else if (ReferenceEquals(expectedSymbols[counter], IgnoreRemaining))
|
||||
{
|
||||
output.AppendLine(String.Format("P: Ignored {0}", current));
|
||||
output.AppendLine(string.Format("P: Ignored {0}", current));
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
output.AppendLine(String.Format("P: Expected: {0}", expectedSymbols[counter]));
|
||||
output.AppendLine(string.Format("P: Expected: {0}", expectedSymbols[counter]));
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
|||
success = false;
|
||||
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")]
|
||||
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