ifdef all of the razor bits that are reliant on non-coreclr bits.
Big thing we're missing is Char.GetUnicodeCategory(...) and Thread.Yield. Tried to do my best to fill in the blanks. Ripped out VB.
This commit is contained in:
parent
29571cce6d
commit
3a214ab213
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Razor
|
|||
{
|
||||
get { return CSharpLanguageName; }
|
||||
}
|
||||
|
||||
#if NET45
|
||||
/// <summary>
|
||||
/// Returns the type of the CodeDOM provider for this language
|
||||
/// </summary>
|
||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Razor
|
|||
{
|
||||
get { return typeof(CSharpCodeProvider); }
|
||||
}
|
||||
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Constructs a new instance of the code parser for this language
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@
|
|||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Internal.Web.Utils {
|
||||
namespace Microsoft.Internal.Web.Utils
|
||||
{
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
|
|
@ -22,112 +23,137 @@ namespace Microsoft.Internal.Web.Utils {
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class CommonResources {
|
||||
|
||||
internal class CommonResources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal CommonResources() {
|
||||
internal CommonResources()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
#if NET45
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.Razor.Common.CommonResources", typeof(CommonResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
#endif
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value cannot be null or an empty string..
|
||||
/// </summary>
|
||||
internal static string Argument_Cannot_Be_Null_Or_Empty {
|
||||
get {
|
||||
internal static string Argument_Cannot_Be_Null_Or_Empty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("Argument_Cannot_Be_Null_Or_Empty", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value must be between {0} and {1}..
|
||||
/// </summary>
|
||||
internal static string Argument_Must_Be_Between {
|
||||
get {
|
||||
internal static string Argument_Must_Be_Between
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("Argument_Must_Be_Between", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value must be a value from the "{0}" enumeration..
|
||||
/// </summary>
|
||||
internal static string Argument_Must_Be_Enum_Member {
|
||||
get {
|
||||
internal static string Argument_Must_Be_Enum_Member
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("Argument_Must_Be_Enum_Member", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value must be greater than {0}..
|
||||
/// </summary>
|
||||
internal static string Argument_Must_Be_GreaterThan {
|
||||
get {
|
||||
internal static string Argument_Must_Be_GreaterThan
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("Argument_Must_Be_GreaterThan", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value must be greater than or equal to {0}..
|
||||
/// </summary>
|
||||
internal static string Argument_Must_Be_GreaterThanOrEqualTo {
|
||||
get {
|
||||
internal static string Argument_Must_Be_GreaterThanOrEqualTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("Argument_Must_Be_GreaterThanOrEqualTo", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value must be less than {0}..
|
||||
/// </summary>
|
||||
internal static string Argument_Must_Be_LessThan {
|
||||
get {
|
||||
internal static string Argument_Must_Be_LessThan
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("Argument_Must_Be_LessThan", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value must be less than or equal to {0}..
|
||||
/// </summary>
|
||||
internal static string Argument_Must_Be_LessThanOrEqualTo {
|
||||
get {
|
||||
internal static string Argument_Must_Be_LessThanOrEqualTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("Argument_Must_Be_LessThanOrEqualTo", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value cannot be an empty string. It must either be null or a non-empty string..
|
||||
/// </summary>
|
||||
internal static string Argument_Must_Be_Null_Or_Non_Empty {
|
||||
get {
|
||||
internal static string Argument_Must_Be_Null_Or_Non_Empty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("Argument_Must_Be_Null_Or_Non_Empty", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,7 +424,9 @@ namespace Microsoft.AspNet.Razor.Editor
|
|||
else
|
||||
{
|
||||
RazorEditorTrace.TraceLine(RazorResources.Trace_NoChangesArrived, fileNameOnly, parcel.Changes.Count);
|
||||
#if NET45
|
||||
Thread.Yield();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,12 @@ namespace Microsoft.AspNet.Razor.Editor
|
|||
bool enabled;
|
||||
if (Boolean.TryParse(Environment.GetEnvironmentVariable("RAZOR_EDITOR_TRACE"), out enabled))
|
||||
{
|
||||
#if NET45
|
||||
Trace.WriteLine(String.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
RazorResources.Trace_Startup,
|
||||
enabled ? RazorResources.Trace_Enabled : RazorResources.Trace_Disabled));
|
||||
#endif
|
||||
_enabled = enabled;
|
||||
}
|
||||
else
|
||||
|
|
@ -43,10 +45,12 @@ namespace Microsoft.AspNet.Razor.Editor
|
|||
{
|
||||
if (IsEnabled())
|
||||
{
|
||||
#if NET45
|
||||
Trace.WriteLine(String.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
RazorResources.Trace_Format,
|
||||
String.Format(CultureInfo.CurrentCulture, format, args)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
// Try to find the namespace in the existing imports
|
||||
string ns = Namespace;
|
||||
if (!String.IsNullOrEmpty(ns) && Char.IsWhiteSpace(ns[0]))
|
||||
|
|
@ -57,7 +58,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
// Attach our info to the existing/new import.
|
||||
import.LinePragma = context.GenerateLinePragma(target);
|
||||
|
||||
#endif
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateCode(target, context.CodeTreeBuilder, context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
if (context.Host.DesignTimeMode)
|
||||
{
|
||||
return; // Don't generate anything!
|
||||
|
|
@ -56,10 +57,8 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
cw.WriteLocationTaggedString(Prefix);
|
||||
cw.WriteParameterSeparator();
|
||||
cw.WriteLocationTaggedString(Suffix);
|
||||
|
||||
// In VB, we need a line continuation
|
||||
cw.WriteLineContinuation();
|
||||
}));
|
||||
#endif
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateStartBlockCode(target, context.CodeTreeBuilder, context);
|
||||
|
|
@ -72,6 +71,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
if (context.Host.DesignTimeMode)
|
||||
{
|
||||
return; // Don't generate anything!
|
||||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
cw.WriteEndMethodInvoke();
|
||||
cw.WriteEndStatement();
|
||||
}));
|
||||
|
||||
#endif
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateEndBlockCode(target, context.CodeTreeBuilder, context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
protected override void Initialize(CodeGeneratorContext context)
|
||||
{
|
||||
base.Initialize(context);
|
||||
|
||||
#if NET45
|
||||
context.GeneratedClass.Members.Insert(0, new CodeSnippetTypeMember(HiddenLinePragma));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using Microsoft.Internal.Web.Utils;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator
|
||||
{
|
||||
public class CodeGenerationCompleteEventArgs : EventArgs
|
||||
{
|
||||
public CodeGenerationCompleteEventArgs(string virtualPath, string physicalPath, CodeCompileUnit generatedCode)
|
||||
{
|
||||
if (String.IsNullOrEmpty(virtualPath))
|
||||
{
|
||||
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "virtualPath");
|
||||
}
|
||||
if (generatedCode == null)
|
||||
{
|
||||
throw new ArgumentNullException("generatedCode");
|
||||
}
|
||||
VirtualPath = virtualPath;
|
||||
PhysicalPath = physicalPath;
|
||||
GeneratedCode = generatedCode;
|
||||
}
|
||||
|
||||
public CodeCompileUnit GeneratedCode { get; private set; }
|
||||
public string VirtualPath { get; private set; }
|
||||
public string PhysicalPath { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -20,11 +20,6 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
internal const string DesignTimeHelperMethodName = "__RazorDesignTimeHelpers__";
|
||||
|
||||
private int _nextDesignTimePragmaId = 1;
|
||||
private bool _expressionHelperVariableWriten;
|
||||
private CodeMemberMethod _designTimeHelperMethod;
|
||||
private StatementBuffer _currentBuffer = new StatementBuffer();
|
||||
|
||||
private CodeGeneratorContext()
|
||||
{
|
||||
ExpressionRenderingMode = ExpressionRenderingMode.WriteToOutput;
|
||||
|
|
@ -33,62 +28,29 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
// Internal/Private state. Technically consumers might want to use some of these but they can implement them independently if necessary.
|
||||
// It's way safer to make them internal for now, especially with the code generator stuff in a bit of flux.
|
||||
internal ExpressionRenderingMode ExpressionRenderingMode { get; set; }
|
||||
public string SourceFile { get; internal set; }
|
||||
|
||||
#region deletable
|
||||
#if NET45
|
||||
private int _nextDesignTimePragmaId = 1;
|
||||
private bool _expressionHelperVariableWriten;
|
||||
private CodeMemberMethod _designTimeHelperMethod;
|
||||
private StatementBuffer _currentBuffer = new StatementBuffer();
|
||||
|
||||
private Action<string, CodeLinePragma> StatementCollector { get; set; }
|
||||
private Func<CodeWriter> CodeWriterFactory { get; set; }
|
||||
|
||||
public string SourceFile { get; internal set; }
|
||||
public CodeCompileUnit CompileUnit { get; internal set; }
|
||||
|
||||
public CodeNamespace Namespace { get; internal set; }
|
||||
public CodeTypeDeclaration GeneratedClass { get; internal set; }
|
||||
public RazorEngineHost Host { get; private set; }
|
||||
public IDictionary<int, GeneratedCodeMapping> CodeMappings { get; private set; }
|
||||
public string TargetWriterName { get; set; }
|
||||
public CodeMemberMethod TargetMethod { get; set; }
|
||||
|
||||
public CodeTreeBuilder CodeTreeBuilder { get; set; }
|
||||
|
||||
public IDictionary<int, GeneratedCodeMapping> CodeMappings { get; private set; }
|
||||
public string CurrentBufferedStatement
|
||||
{
|
||||
get { return _currentBuffer == null ? String.Empty : _currentBuffer.Builder.ToString(); }
|
||||
}
|
||||
|
||||
public static CodeGeneratorContext Create(RazorEngineHost host, string className, string rootNamespace, string sourceFile, bool shouldGenerateLinePragmas)
|
||||
{
|
||||
return Create(host, null, className, rootNamespace, sourceFile, shouldGenerateLinePragmas);
|
||||
}
|
||||
|
||||
internal static CodeGeneratorContext Create(RazorEngineHost host, Func<CodeWriter> writerFactory, string className, string rootNamespace, string sourceFile, bool shouldGenerateLinePragmas)
|
||||
{
|
||||
CodeGeneratorContext context = new CodeGeneratorContext()
|
||||
{
|
||||
CodeTreeBuilder = new CodeTreeBuilder(),
|
||||
Host = host,
|
||||
CodeWriterFactory = writerFactory,
|
||||
SourceFile = shouldGenerateLinePragmas ? sourceFile : null,
|
||||
CompileUnit = new CodeCompileUnit(),
|
||||
Namespace = new CodeNamespace(rootNamespace),
|
||||
GeneratedClass = new CodeTypeDeclaration(className)
|
||||
{
|
||||
IsClass = true
|
||||
},
|
||||
TargetMethod = new CodeMemberMethod()
|
||||
{
|
||||
Name = host.GeneratedClassContext.ExecuteMethodName,
|
||||
Attributes = MemberAttributes.Override | MemberAttributes.Public
|
||||
},
|
||||
CodeMappings = new Dictionary<int, GeneratedCodeMapping>()
|
||||
};
|
||||
context.CompileUnit.Namespaces.Add(context.Namespace);
|
||||
context.Namespace.Types.Add(context.GeneratedClass);
|
||||
context.GeneratedClass.Members.Add(context.TargetMethod);
|
||||
|
||||
context.Namespace.Imports.AddRange(host.NamespaceImports
|
||||
.Select(s => new CodeNamespaceImport(s))
|
||||
.ToArray());
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
public void AddDesignTimeHelperStatement(CodeSnippetStatement statement)
|
||||
{
|
||||
if (_designTimeHelperMethod == null)
|
||||
|
|
@ -184,7 +146,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
}
|
||||
|
||||
int paddingLength; // unused, in this case there is enough context in the original code to calculate the right padding length
|
||||
// (padded.Length - _currentBuffer.Builder.Length)
|
||||
// (padded.Length - _currentBuffer.Builder.Length)
|
||||
|
||||
string padded = CodeGeneratorPaddingHelper.Pad(Host, _currentBuffer.Builder.ToString(), sourceSpan, start, out paddingLength);
|
||||
_currentBuffer.GeneratedCodeStart = start + (padded.Length - _currentBuffer.Builder.Length);
|
||||
|
|
@ -335,5 +297,52 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
CodeLength = Builder.Length - GeneratedCodeStart;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
public RazorEngineHost Host { get; private set; }
|
||||
public string TargetWriterName { get; set; }
|
||||
|
||||
public CodeTreeBuilder CodeTreeBuilder { get; set; }
|
||||
|
||||
public static CodeGeneratorContext Create(RazorEngineHost host, string className, string rootNamespace, string sourceFile, bool shouldGenerateLinePragmas)
|
||||
{
|
||||
return Create(host, null, className, rootNamespace, sourceFile, shouldGenerateLinePragmas);
|
||||
}
|
||||
|
||||
internal static CodeGeneratorContext Create(RazorEngineHost host, Func<CodeWriter> writerFactory, string className, string rootNamespace, string sourceFile, bool shouldGenerateLinePragmas)
|
||||
{
|
||||
CodeGeneratorContext context = new CodeGeneratorContext()
|
||||
{
|
||||
CodeTreeBuilder = new CodeTreeBuilder(),
|
||||
Host = host,
|
||||
SourceFile = shouldGenerateLinePragmas ? sourceFile : null,
|
||||
#if NET45
|
||||
CodeWriterFactory = writerFactory,
|
||||
CompileUnit = new CodeCompileUnit(),
|
||||
Namespace = new CodeNamespace(rootNamespace),
|
||||
GeneratedClass = new CodeTypeDeclaration(className)
|
||||
{
|
||||
IsClass = true
|
||||
},
|
||||
TargetMethod = new CodeMemberMethod()
|
||||
{
|
||||
Name = host.GeneratedClassContext.ExecuteMethodName,
|
||||
Attributes = MemberAttributes.Override | MemberAttributes.Public
|
||||
},
|
||||
CodeMappings = new Dictionary<int, GeneratedCodeMapping>()
|
||||
#endif
|
||||
};
|
||||
#if NET45
|
||||
context.CompileUnit.Namespaces.Add(context.Namespace);
|
||||
context.Namespace.Types.Add(context.GeneratedClass);
|
||||
context.GeneratedClass.Members.Add(context.TargetMethod);
|
||||
|
||||
context.Namespace.Imports.AddRange(host.NamespaceImports
|
||||
.Select(s => new CodeNamespaceImport(s))
|
||||
.ToArray());
|
||||
#endif
|
||||
return context;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
|||
|
||||
namespace Microsoft.AspNet.Razor.Generator
|
||||
{
|
||||
#if NET45
|
||||
internal static class CodeGeneratorPaddingHelper
|
||||
{
|
||||
private static readonly char[] _newLineChars = { '\r', '\n' };
|
||||
|
|
@ -201,4 +202,5 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
return padding;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
public abstract void WriteSnippet(string snippet);
|
||||
public abstract void WriteStringLiteral(string literal);
|
||||
public abstract int WriteVariableDeclaration(string type, string name, string value);
|
||||
|
||||
#if NET45
|
||||
public virtual void WriteLinePragma()
|
||||
{
|
||||
WriteLinePragma(null);
|
||||
|
|
@ -71,6 +71,17 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
}
|
||||
}
|
||||
|
||||
public CodeSnippetStatement ToStatement()
|
||||
{
|
||||
return new CodeSnippetStatement(Content);
|
||||
}
|
||||
|
||||
public CodeSnippetTypeMember ToTypeMember()
|
||||
{
|
||||
return new CodeSnippetTypeMember(Content);
|
||||
}
|
||||
#endif
|
||||
|
||||
public virtual void WriteHiddenLinePragma()
|
||||
{
|
||||
}
|
||||
|
|
@ -157,7 +168,9 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public virtual void WriteBooleanLiteral(bool value)
|
||||
{
|
||||
#if NET45
|
||||
WriteSnippet(value.ToString(CultureInfo.InvariantCulture));
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
@ -174,16 +187,6 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
}
|
||||
}
|
||||
|
||||
public CodeSnippetStatement ToStatement()
|
||||
{
|
||||
return new CodeSnippetStatement(Content);
|
||||
}
|
||||
|
||||
public CodeSnippetTypeMember ToTypeMember()
|
||||
{
|
||||
return new CodeSnippetTypeMember(Content);
|
||||
}
|
||||
|
||||
protected internal abstract void EmitStartLambdaDelegate(string[] parameterNames);
|
||||
protected internal abstract void EmitStartLambdaExpression(string[] parameterNames);
|
||||
protected internal abstract void EmitStartConstructor(string typeName);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
writer.WriteComment(new string('-', 78))
|
||||
.WriteComment("<auto-generated>")
|
||||
.WriteComment(" This code was generated by a tool.")
|
||||
#if NET45
|
||||
.WriteComment(" Runtime Version: " + Assembly.GetExecutingAssembly().ImageRuntimeVersion)
|
||||
#endif
|
||||
.WriteComment("")
|
||||
.WriteComment(" Changes to this file may cause incorrect behavior and will be lost if")
|
||||
.WriteComment(" the code is regenerated.")
|
||||
|
|
@ -45,7 +47,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
// TODO: Include current projects namespace? Does that happen to be included in the namespace imports?
|
||||
|
||||
var baseTypeVisitor = new CSharpBaseTypeVisitor(writer);
|
||||
|
||||
|
||||
baseTypeVisitor.Accept(Tree.Chunks);
|
||||
|
||||
string baseType = baseTypeVisitor.CurrentBaseType ?? Host.DefaultBaseClass;
|
||||
|
|
@ -55,7 +57,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
|
||||
new CSharpClassAttributeVisitor(writer).Accept(Tree.Chunks);
|
||||
|
||||
using (writer.BuildClassDeclaration("public", Host.DefaultClassName, String.IsNullOrEmpty(baseType) ? new string[0] : new string[]{baseType}))
|
||||
using (writer.BuildClassDeclaration("public", Host.DefaultClassName, String.IsNullOrEmpty(baseType) ? new string[0] : new string[] { baseType }))
|
||||
{
|
||||
if (Host.DesignTimeMode)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
if (context.Host.DesignTimeMode)
|
||||
{
|
||||
return; // Don't generate anything!
|
||||
|
|
@ -47,10 +48,13 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
// What kind of block is nested within
|
||||
string generatedCode;
|
||||
#endif
|
||||
Block child = target.Children.Where(n => n.IsBlock).Cast<Block>().FirstOrDefault();
|
||||
|
||||
if (child != null && child.Type == BlockType.Expression)
|
||||
{
|
||||
_isExpression = true;
|
||||
#if NET45
|
||||
generatedCode = context.BuildCodeString(cw =>
|
||||
{
|
||||
cw.WriteParameterSeparator();
|
||||
|
|
@ -59,10 +63,11 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
cw.WriteParameterSeparator();
|
||||
cw.WriteStartMethodInvoke("Tuple.Create", "System.Object", "System.Int32");
|
||||
});
|
||||
|
||||
#endif
|
||||
_oldRenderingMode = context.ExpressionRenderingMode;
|
||||
context.ExpressionRenderingMode = ExpressionRenderingMode.InjectCode;
|
||||
}
|
||||
#if NET45
|
||||
else
|
||||
{
|
||||
generatedCode = context.BuildCodeString(cw =>
|
||||
|
|
@ -79,7 +84,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
context.MarkEndOfGeneratedCode();
|
||||
context.BufferStatementFragment(generatedCode);
|
||||
|
||||
#endif
|
||||
_oldTargetWriter = context.TargetWriterName;
|
||||
context.TargetWriterName = ValueWriterName;
|
||||
|
||||
|
|
@ -102,6 +107,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
string generatedCode;
|
||||
if (_isExpression)
|
||||
{
|
||||
#if NET45
|
||||
generatedCode = context.BuildCodeString(cw =>
|
||||
{
|
||||
cw.WriteParameterSeparator();
|
||||
|
|
@ -113,8 +119,10 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
cw.WriteEndMethodInvoke();
|
||||
cw.WriteLineContinuation();
|
||||
});
|
||||
#endif
|
||||
context.ExpressionRenderingMode = _oldRenderingMode;
|
||||
}
|
||||
#if NET45
|
||||
else
|
||||
{
|
||||
generatedCode = context.BuildCodeString(cw =>
|
||||
|
|
@ -133,9 +141,9 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
}
|
||||
|
||||
context.AddStatement(generatedCode);
|
||||
#endif
|
||||
context.TargetWriterName = _oldTargetWriter;
|
||||
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateEndBlockCode(target, context.CodeTreeBuilder, context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
if (context.Host.EnableInstrumentation && context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput)
|
||||
{
|
||||
Span contentSpan = target.Children
|
||||
|
|
@ -54,6 +55,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
context.BufferStatementFragment(writeInvocation);
|
||||
context.MarkStartOfGeneratedCode();
|
||||
#endif
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateStartBlockCode(target, context.CodeTreeBuilder, context);
|
||||
|
|
@ -66,6 +68,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
string endBlock = context.BuildCodeString(cw =>
|
||||
{
|
||||
if (context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput)
|
||||
|
|
@ -98,6 +101,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
context.AddContextCall(contentSpan, context.Host.GeneratedClassContext.EndContextMethodName, false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateEndBlockCode(target, context.CodeTreeBuilder, context);
|
||||
|
|
@ -110,12 +114,14 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
Span sourceSpan = null;
|
||||
if (context.CreateCodeWriter().SupportsMidStatementLinePragmas || context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput)
|
||||
{
|
||||
sourceSpan = target;
|
||||
}
|
||||
context.BufferStatementFragment(target.Content, sourceSpan);
|
||||
#endif
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateCode(target, context.CodeTreeBuilder, context);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
_writer = context.CreateCodeWriter();
|
||||
|
||||
string prefix = context.BuildCodeString(
|
||||
|
|
@ -61,6 +62,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
}
|
||||
|
||||
_statementCollectorToken = context.ChangeStatementCollector(AddStatementToHelper);
|
||||
#endif
|
||||
_oldWriter = context.TargetWriterName;
|
||||
context.TargetWriterName = HelperWriterName;
|
||||
|
||||
|
|
@ -75,6 +77,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
_statementCollectorToken.Dispose();
|
||||
if (HeaderComplete)
|
||||
{
|
||||
|
|
@ -92,6 +95,8 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
_writer.WriteHelperTrailer();
|
||||
|
||||
context.GeneratedClass.Members.Add(new CodeSnippetTypeMember(_writer.Content));
|
||||
|
||||
#endif
|
||||
context.TargetWriterName = _oldWriter;
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
|
|
@ -120,6 +125,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
return "Helper:" + Signature.ToString("F", CultureInfo.CurrentCulture) + ";" + (HeaderComplete ? "C" : "I");
|
||||
}
|
||||
|
||||
#if NET45
|
||||
private void AddStatementToHelper(string statement, CodeLinePragma pragma)
|
||||
{
|
||||
if (pragma != null)
|
||||
|
|
@ -133,5 +139,6 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
_writer.WriteLinePragma();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,17 +44,22 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
}
|
||||
|
||||
ExpressionRenderingMode oldMode = context.ExpressionRenderingMode;
|
||||
#if NET45
|
||||
context.BufferStatementFragment(context.BuildCodeString(cw =>
|
||||
{
|
||||
cw.WriteParameterSeparator();
|
||||
cw.WriteStartMethodInvoke("Tuple.Create");
|
||||
cw.WriteLocationTaggedString(Prefix);
|
||||
cw.WriteParameterSeparator();
|
||||
#endif
|
||||
if (ValueGenerator != null)
|
||||
{
|
||||
#if NET45
|
||||
cw.WriteStartMethodInvoke("Tuple.Create", "System.Object", "System.Int32");
|
||||
#endif
|
||||
context.ExpressionRenderingMode = ExpressionRenderingMode.InjectCode;
|
||||
}
|
||||
#if NET45
|
||||
else
|
||||
{
|
||||
cw.WriteLocationTaggedString(Value);
|
||||
|
|
@ -62,20 +67,22 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
// literal: true - This attribute value is a literal value
|
||||
cw.WriteBooleanLiteral(true);
|
||||
cw.WriteEndMethodInvoke();
|
||||
|
||||
// In VB, we need a line continuation
|
||||
cw.WriteLineContinuation();
|
||||
}
|
||||
}));
|
||||
#endif
|
||||
if (ValueGenerator != null)
|
||||
{
|
||||
ValueGenerator.Value.GenerateCode(target, context);
|
||||
#if NET45
|
||||
context.FlushBufferedStatement();
|
||||
#endif
|
||||
context.ExpressionRenderingMode = oldMode;
|
||||
#if NET45
|
||||
context.AddStatement(context.BuildCodeString(cw =>
|
||||
{
|
||||
#endif
|
||||
chunk.ValueLocation = ValueGenerator.Location;
|
||||
|
||||
#if NET45
|
||||
cw.WriteParameterSeparator();
|
||||
cw.WriteSnippet(ValueGenerator.Location.AbsoluteIndex.ToString(CultureInfo.CurrentCulture));
|
||||
cw.WriteEndMethodInvoke();
|
||||
|
|
@ -83,14 +90,12 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
// literal: false - This attribute value is not a literal value, it is dynamically generated
|
||||
cw.WriteBooleanLiteral(false);
|
||||
cw.WriteEndMethodInvoke();
|
||||
|
||||
// In VB, we need a line continuation
|
||||
cw.WriteLineContinuation();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
context.FlushBufferedStatement();
|
||||
#endif
|
||||
}
|
||||
|
||||
context.CodeTreeBuilder.EndChunkBlock();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if NET45
|
||||
if (context.Host.EnableInstrumentation)
|
||||
{
|
||||
context.AddContextCall(target, context.Host.GeneratedClassContext.BeginContextMethodName, isLiteral: true);
|
||||
|
|
@ -50,6 +50,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
context.AddContextCall(target, context.Host.GeneratedClassContext.EndContextMethodName, isLiteral: true);
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateCode(target, context.CodeTreeBuilder, context);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,9 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void OnComplete()
|
||||
{
|
||||
#if NET45
|
||||
Context.FlushBufferedStatement();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void EnsureContextInitialized()
|
||||
|
|
@ -90,6 +92,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
protected virtual void Initialize(CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
context.Namespace.Imports.AddRange(Host.NamespaceImports.Select(s => new CodeNamespaceImport(s)).ToArray());
|
||||
|
||||
if (!String.IsNullOrEmpty(Host.DefaultBaseClass))
|
||||
|
|
@ -99,6 +102,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
// Dev10 Bug 937438: Generate explicit Parameter-less constructor on Razor generated class
|
||||
context.GeneratedClass.Members.Add(new CodeConstructor() { Attributes = MemberAttributes.Public });
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
// Flush the buffered statement since we're interrupting it with a comment.
|
||||
if (!String.IsNullOrEmpty(context.CurrentBufferedStatement))
|
||||
{
|
||||
|
|
@ -16,6 +17,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
context.BufferStatementFragment(context.BuildCodeString(cw => cw.WriteLineContinuation()));
|
||||
}
|
||||
context.FlushBufferedStatement();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public void GenerateCode(SyntaxTreeNode target, CodeTreeBuilder codeTreeBuilder, CodeGeneratorContext context)
|
||||
{
|
||||
if(Name == SyntaxConstants.CSharp.SessionStateKeyword)
|
||||
if (Name == SyntaxConstants.CSharp.SessionStateKeyword)
|
||||
{
|
||||
codeTreeBuilder.AddSessionStateChunk(Value, target, context);
|
||||
}
|
||||
|
|
@ -35,13 +35,14 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
var attributeType = new CodeTypeReference(typeof(RazorDirectiveAttribute));
|
||||
var attributeDeclaration = new CodeAttributeDeclaration(
|
||||
attributeType,
|
||||
new CodeAttributeArgument(new CodePrimitiveExpression(Name)),
|
||||
new CodeAttributeArgument(new CodePrimitiveExpression(Value)));
|
||||
context.GeneratedClass.CustomAttributes.Add(attributeDeclaration);
|
||||
|
||||
#endif
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateCode(target, context.CodeTreeBuilder, context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
new MarkupCodeGenerator().GenerateCode(target, context);
|
||||
return;
|
||||
}
|
||||
|
||||
#if NET45
|
||||
if (!context.Host.DesignTimeMode && String.IsNullOrEmpty(target.Content))
|
||||
{
|
||||
return;
|
||||
|
|
@ -79,7 +79,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
context.AddContextCall(target, context.Host.GeneratedClassContext.EndContextMethodName, isLiteral: false);
|
||||
}
|
||||
|
||||
#endif
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateCode(target, context.CodeTreeBuilder, context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
string startBlock = context.BuildCodeString(cw =>
|
||||
{
|
||||
cw.WriteStartMethodInvoke(context.Host.GeneratedClassContext.DefineSectionMethodName);
|
||||
|
|
@ -33,6 +34,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
cw.WriteStartLambdaDelegate();
|
||||
});
|
||||
context.AddStatement(startBlock);
|
||||
#endif
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateStartBlockCode(target, context.CodeTreeBuilder, context);
|
||||
|
|
@ -45,6 +47,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
string startBlock = context.BuildCodeString(cw =>
|
||||
{
|
||||
cw.WriteEndLambdaDelegate();
|
||||
|
|
@ -52,6 +55,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
cw.WriteEndStatement();
|
||||
});
|
||||
context.AddStatement(startBlock);
|
||||
#endif
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateEndBlockCode(target, context.CodeTreeBuilder, context);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
context.GeneratedClass.BaseTypes.Clear();
|
||||
context.GeneratedClass.BaseTypes.Add(new CodeTypeReference(ResolveType(context, BaseType.Trim())));
|
||||
|
||||
|
|
@ -44,6 +45,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
};
|
||||
context.AddDesignTimeHelperStatement(stmt);
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateCode(target, context.CodeTreeBuilder, context);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
if (!context.Host.DesignTimeMode && !String.IsNullOrEmpty(context.Host.GeneratedClassContext.LayoutPropertyName))
|
||||
{
|
||||
context.TargetMethod.Statements.Add(
|
||||
|
|
@ -30,6 +31,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
new CodePropertyReferenceExpression(null, context.Host.GeneratedClassContext.LayoutPropertyName),
|
||||
new CodePrimitiveExpression(LayoutPath)));
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateCode(target, context.CodeTreeBuilder, context);
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator
|
||||
{
|
||||
public class SetVBOptionCodeGenerator : SpanCodeGenerator
|
||||
{
|
||||
public static readonly string StrictCodeDomOptionName = "AllowLateBound";
|
||||
public static readonly string ExplicitCodeDomOptionName = "RequireVariableDeclaration";
|
||||
|
||||
public SetVBOptionCodeGenerator(string optionName, bool value)
|
||||
{
|
||||
OptionName = optionName;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
// CodeDOM Option Name, which is NOT the same as the VB Option Name
|
||||
public string OptionName { get; private set; }
|
||||
public bool Value { get; private set; }
|
||||
|
||||
public static SetVBOptionCodeGenerator Strict(bool onOffValue)
|
||||
{
|
||||
// Strict On = AllowLateBound Off
|
||||
return new SetVBOptionCodeGenerator(StrictCodeDomOptionName, !onOffValue);
|
||||
}
|
||||
|
||||
public static SetVBOptionCodeGenerator Explicit(bool onOffValue)
|
||||
{
|
||||
return new SetVBOptionCodeGenerator(ExplicitCodeDomOptionName, onOffValue);
|
||||
}
|
||||
|
||||
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
||||
{
|
||||
context.CompileUnit.UserData[OptionName] = Value;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Option:" + OptionName + "=" + Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
context.FlushBufferedStatement();
|
||||
|
||||
string generatedCode = context.BuildCodeString(cw =>
|
||||
|
|
@ -29,6 +30,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
context.AddStatement(
|
||||
generatedCode,
|
||||
context.GenerateLinePragma(target, paddingCharCount));
|
||||
#endif
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateCode(target, context.CodeTreeBuilder, context);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
string generatedCode = context.BuildCodeString(cw =>
|
||||
{
|
||||
cw.WriteStartLambdaExpression(ItemParameterName);
|
||||
|
|
@ -29,6 +30,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
context.MarkEndOfGeneratedCode();
|
||||
context.BufferStatementFragment(generatedCode);
|
||||
context.FlushBufferedStatement();
|
||||
#endif
|
||||
|
||||
_oldTargetWriter = context.TargetWriterName;
|
||||
context.TargetWriterName = TemplateWriterName;
|
||||
|
|
@ -44,6 +46,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
string generatedCode = context.BuildCodeString(cw =>
|
||||
{
|
||||
cw.WriteEndLambdaDelegate();
|
||||
|
|
@ -52,6 +55,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
});
|
||||
|
||||
context.BufferStatementFragment(generatedCode);
|
||||
#endif
|
||||
context.TargetWriterName = _oldTargetWriter;
|
||||
|
||||
// TODO: Make this generate the primary generator
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
|
||||
public override void GenerateCode(Span target, CodeGeneratorContext context)
|
||||
{
|
||||
#if NET45
|
||||
string generatedCode = context.BuildCodeString(cw =>
|
||||
{
|
||||
cw.WriteSnippet(target.Content);
|
||||
|
|
@ -31,7 +32,7 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
LinePragma = context.GenerateLinePragma(target, paddingCharCount)
|
||||
});
|
||||
|
||||
#endif
|
||||
// TODO: Make this generate the primary generator
|
||||
GenerateCode(target, context.CodeTreeBuilder, context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,201 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
namespace Microsoft.AspNet.Razor.Generator
|
||||
{
|
||||
internal class VBCodeWriter : BaseCodeWriter
|
||||
{
|
||||
public override bool SupportsMidStatementLinePragmas
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
protected internal override void WriteStartGenerics()
|
||||
{
|
||||
InnerWriter.Write("(Of ");
|
||||
}
|
||||
|
||||
protected internal override void WriteEndGenerics()
|
||||
{
|
||||
InnerWriter.Write(")");
|
||||
}
|
||||
|
||||
public override void WriteLineContinuation()
|
||||
{
|
||||
InnerWriter.Write(" _");
|
||||
}
|
||||
|
||||
public override int WriteVariableDeclaration(string type, string name, string value)
|
||||
{
|
||||
InnerWriter.Write("Dim ");
|
||||
InnerWriter.Write(name);
|
||||
InnerWriter.Write(" As ");
|
||||
int typePos = InnerWriter.GetStringBuilder().Length;
|
||||
InnerWriter.Write(type);
|
||||
if (!String.IsNullOrEmpty(value))
|
||||
{
|
||||
InnerWriter.Write(" = ");
|
||||
InnerWriter.Write(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
InnerWriter.Write(" = Nothing");
|
||||
}
|
||||
return typePos;
|
||||
}
|
||||
|
||||
public override void WriteStringLiteral(string literal)
|
||||
{
|
||||
bool inQuotes = true;
|
||||
InnerWriter.Write("\"");
|
||||
for (int i = 0; i < literal.Length; i++)
|
||||
{
|
||||
switch (literal[i])
|
||||
{
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\0':
|
||||
case '\u2028':
|
||||
case '\u2029':
|
||||
// Exit quotes
|
||||
EnsureOutOfQuotes(ref inQuotes);
|
||||
|
||||
// Write concat character
|
||||
InnerWriter.Write("&");
|
||||
|
||||
// Write character literal
|
||||
WriteCharLiteral(literal[i]);
|
||||
break;
|
||||
case '"':
|
||||
case '“':
|
||||
case '”':
|
||||
case (char)0xff02:
|
||||
EnsureInQuotes(ref inQuotes);
|
||||
InnerWriter.Write(literal[i]);
|
||||
InnerWriter.Write(literal[i]);
|
||||
break;
|
||||
default:
|
||||
EnsureInQuotes(ref inQuotes);
|
||||
InnerWriter.Write(literal[i]);
|
||||
break;
|
||||
}
|
||||
if (i > 0 && (i % 80) == 0)
|
||||
{
|
||||
if ((Char.IsHighSurrogate(literal[i]) && (i < (literal.Length - 1))) && Char.IsLowSurrogate(literal[i + 1]))
|
||||
{
|
||||
InnerWriter.Write(literal[++i]);
|
||||
}
|
||||
if (inQuotes)
|
||||
{
|
||||
InnerWriter.Write("\"");
|
||||
}
|
||||
inQuotes = true;
|
||||
InnerWriter.Write("& _ ");
|
||||
InnerWriter.Write(Environment.NewLine);
|
||||
InnerWriter.Write('"');
|
||||
}
|
||||
}
|
||||
EnsureOutOfQuotes(ref inQuotes);
|
||||
}
|
||||
|
||||
protected internal override void EmitStartLambdaExpression(string[] parameterNames)
|
||||
{
|
||||
InnerWriter.Write("Function (");
|
||||
WriteCommaSeparatedList(parameterNames, InnerWriter.Write);
|
||||
InnerWriter.Write(") ");
|
||||
}
|
||||
|
||||
protected internal override void EmitStartConstructor(string typeName)
|
||||
{
|
||||
InnerWriter.Write("New ");
|
||||
InnerWriter.Write(typeName);
|
||||
InnerWriter.Write("(");
|
||||
}
|
||||
|
||||
protected internal override void EmitStartLambdaDelegate(string[] parameterNames)
|
||||
{
|
||||
InnerWriter.Write("Sub (");
|
||||
WriteCommaSeparatedList(parameterNames, InnerWriter.Write);
|
||||
InnerWriter.WriteLine(")");
|
||||
}
|
||||
|
||||
protected internal override void EmitEndLambdaDelegate()
|
||||
{
|
||||
InnerWriter.Write("End Sub");
|
||||
}
|
||||
|
||||
private void WriteCharLiteral(char literal)
|
||||
{
|
||||
InnerWriter.Write("Global.Microsoft.VisualBasic.ChrW(");
|
||||
InnerWriter.Write((int)literal);
|
||||
InnerWriter.Write(")");
|
||||
}
|
||||
|
||||
private void EnsureInQuotes(ref bool inQuotes)
|
||||
{
|
||||
if (!inQuotes)
|
||||
{
|
||||
InnerWriter.Write("&\"");
|
||||
inQuotes = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureOutOfQuotes(ref bool inQuotes)
|
||||
{
|
||||
if (inQuotes)
|
||||
{
|
||||
InnerWriter.Write("\"");
|
||||
inQuotes = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteReturn()
|
||||
{
|
||||
InnerWriter.Write("Return ");
|
||||
}
|
||||
|
||||
public override void WriteLinePragma(int? lineNumber, string fileName)
|
||||
{
|
||||
InnerWriter.WriteLine();
|
||||
if (lineNumber != null)
|
||||
{
|
||||
InnerWriter.Write("#ExternalSource(\"");
|
||||
InnerWriter.Write(fileName);
|
||||
InnerWriter.Write("\", ");
|
||||
InnerWriter.Write(lineNumber);
|
||||
InnerWriter.WriteLine(")");
|
||||
}
|
||||
else
|
||||
{
|
||||
InnerWriter.WriteLine("#End ExternalSource");
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteHelperHeaderPrefix(string templateTypeName, bool isStatic)
|
||||
{
|
||||
InnerWriter.Write("Public ");
|
||||
if (isStatic)
|
||||
{
|
||||
InnerWriter.Write("Shared ");
|
||||
}
|
||||
InnerWriter.Write("Function ");
|
||||
}
|
||||
|
||||
public override void WriteHelperHeaderSuffix(string templateTypeName)
|
||||
{
|
||||
InnerWriter.Write(" As ");
|
||||
InnerWriter.WriteLine(templateTypeName);
|
||||
}
|
||||
|
||||
public override void WriteHelperTrailer()
|
||||
{
|
||||
InnerWriter.WriteLine("End Function");
|
||||
}
|
||||
|
||||
public override void WriteEndStatement()
|
||||
{
|
||||
InnerWriter.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
namespace Microsoft.AspNet.Razor.Generator
|
||||
{
|
||||
public class VBRazorCodeGenerator : RazorCodeGenerator
|
||||
{
|
||||
public VBRazorCodeGenerator(string className, string rootNamespaceName, string sourceFileName, RazorEngineHost host)
|
||||
: base(className, rootNamespaceName, sourceFileName, host)
|
||||
{
|
||||
}
|
||||
|
||||
internal override Func<CodeWriter> CodeWriterFactory
|
||||
{
|
||||
get { return () => new VBCodeWriter(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37,8 +37,9 @@ namespace Microsoft.AspNet.Razor
|
|||
public string GeneratedCode { get; private set; }
|
||||
public IList<LineMapping> DesignTimeLineMappings { get; private set; }
|
||||
|
||||
#if NET45
|
||||
public CodeCompileUnit CCU { get; set; }
|
||||
|
||||
#endif
|
||||
internal CodeTree CT { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System.CodeDom;
|
||||
using Microsoft.AspNet.Razor.Generator.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
|
||||
namespace Microsoft.AspNet.Razor
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents results from code generation (and parsing, since that is a pre-requisite of code generation)
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Since this inherits from ParserResults, it has all the data from ParserResults, and simply adds code generation data
|
||||
/// </remarks>
|
||||
public class GeneratorResultsOLD : ParserResults
|
||||
{
|
||||
public GeneratorResultsOLD(ParserResults parserResults,
|
||||
CodeCompileUnit generatedCode,
|
||||
IDictionary<int, GeneratedCodeMapping> designTimeLineMappings)
|
||||
: this(parserResults.Document, parserResults.ParserErrors, generatedCode, designTimeLineMappings)
|
||||
{
|
||||
}
|
||||
|
||||
public GeneratorResultsOLD(Block document,
|
||||
IList<RazorError> parserErrors,
|
||||
CodeCompileUnit generatedCode,
|
||||
IDictionary<int, GeneratedCodeMapping> designTimeLineMappings)
|
||||
: this(parserErrors.Count == 0, document, parserErrors, generatedCode, designTimeLineMappings)
|
||||
{
|
||||
}
|
||||
|
||||
protected GeneratorResultsOLD(bool success,
|
||||
Block document,
|
||||
IList<RazorError> parserErrors,
|
||||
CodeCompileUnit generatedCode,
|
||||
IDictionary<int, GeneratedCodeMapping> designTimeLineMappings)
|
||||
: base(success, document, parserErrors)
|
||||
{
|
||||
GeneratedCode = generatedCode;
|
||||
DesignTimeLineMappings = designTimeLineMappings;
|
||||
}
|
||||
|
||||
public CodeTree CodeTree { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The generated code
|
||||
/// </summary>
|
||||
public CodeCompileUnit GeneratedCode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// If design-time mode was used in the Code Generator, this will contain the dictionary
|
||||
/// of design-time generated code mappings
|
||||
/// </summary>
|
||||
public IDictionary<int, GeneratedCodeMapping> DesignTimeLineMappings { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -19,4 +19,3 @@ using System.Diagnostics.CodeAnalysis;
|
|||
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.AspNet.Razor.Parser", Justification = "These namespaces are design to group classes by function. They will be reviewed to ensure they remain relevant.")]
|
||||
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.AspNet.Razor.Editor", Justification = "These namespaces are design to group classes by function. They will be reviewed to ensure they remain relevant.")]
|
||||
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.AspNet.Razor", Justification = "These namespaces are design to group classes by function. They will be reviewed to ensure they remain relevant.")]
|
||||
[assembly: SuppressMessage("Microsoft.Web.FxCop", "MW1000:UnusedResourceUsageRule", Justification = "There are numerous unused resources due to VB being disabled. This rule will be re-run after VB is restored")]
|
||||
|
|
|
|||
|
|
@ -102,24 +102,24 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case KnownSymbolType.Identifier:
|
||||
return CSharpSymbolType.Identifier;
|
||||
case KnownSymbolType.Keyword:
|
||||
return CSharpSymbolType.Keyword;
|
||||
case KnownSymbolType.NewLine:
|
||||
return CSharpSymbolType.NewLine;
|
||||
case KnownSymbolType.WhiteSpace:
|
||||
return CSharpSymbolType.WhiteSpace;
|
||||
case KnownSymbolType.Transition:
|
||||
return CSharpSymbolType.Transition;
|
||||
case KnownSymbolType.CommentStart:
|
||||
return CSharpSymbolType.RazorCommentTransition;
|
||||
case KnownSymbolType.CommentStar:
|
||||
return CSharpSymbolType.RazorCommentStar;
|
||||
case KnownSymbolType.CommentBody:
|
||||
return CSharpSymbolType.RazorComment;
|
||||
default:
|
||||
return CSharpSymbolType.Unknown;
|
||||
case KnownSymbolType.Identifier:
|
||||
return CSharpSymbolType.Identifier;
|
||||
case KnownSymbolType.Keyword:
|
||||
return CSharpSymbolType.Keyword;
|
||||
case KnownSymbolType.NewLine:
|
||||
return CSharpSymbolType.NewLine;
|
||||
case KnownSymbolType.WhiteSpace:
|
||||
return CSharpSymbolType.WhiteSpace;
|
||||
case KnownSymbolType.Transition:
|
||||
return CSharpSymbolType.Transition;
|
||||
case KnownSymbolType.CommentStart:
|
||||
return CSharpSymbolType.RazorCommentTransition;
|
||||
case KnownSymbolType.CommentStar:
|
||||
return CSharpSymbolType.RazorCommentStar;
|
||||
case KnownSymbolType.CommentBody:
|
||||
return CSharpSymbolType.RazorComment;
|
||||
default:
|
||||
return CSharpSymbolType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,25 +127,27 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
{
|
||||
switch (bracket)
|
||||
{
|
||||
case CSharpSymbolType.LeftBrace:
|
||||
return CSharpSymbolType.RightBrace;
|
||||
case CSharpSymbolType.LeftBracket:
|
||||
return CSharpSymbolType.RightBracket;
|
||||
case CSharpSymbolType.LeftParenthesis:
|
||||
return CSharpSymbolType.RightParenthesis;
|
||||
case CSharpSymbolType.LessThan:
|
||||
return CSharpSymbolType.GreaterThan;
|
||||
case CSharpSymbolType.RightBrace:
|
||||
return CSharpSymbolType.LeftBrace;
|
||||
case CSharpSymbolType.RightBracket:
|
||||
return CSharpSymbolType.LeftBracket;
|
||||
case CSharpSymbolType.RightParenthesis:
|
||||
return CSharpSymbolType.LeftParenthesis;
|
||||
case CSharpSymbolType.GreaterThan:
|
||||
return CSharpSymbolType.LessThan;
|
||||
default:
|
||||
case CSharpSymbolType.LeftBrace:
|
||||
return CSharpSymbolType.RightBrace;
|
||||
case CSharpSymbolType.LeftBracket:
|
||||
return CSharpSymbolType.RightBracket;
|
||||
case CSharpSymbolType.LeftParenthesis:
|
||||
return CSharpSymbolType.RightParenthesis;
|
||||
case CSharpSymbolType.LessThan:
|
||||
return CSharpSymbolType.GreaterThan;
|
||||
case CSharpSymbolType.RightBrace:
|
||||
return CSharpSymbolType.LeftBrace;
|
||||
case CSharpSymbolType.RightBracket:
|
||||
return CSharpSymbolType.LeftBracket;
|
||||
case CSharpSymbolType.RightParenthesis:
|
||||
return CSharpSymbolType.LeftParenthesis;
|
||||
case CSharpSymbolType.GreaterThan:
|
||||
return CSharpSymbolType.LessThan;
|
||||
default:
|
||||
#if NET45
|
||||
Debug.Fail("FlipBracket must be called with a bracket character");
|
||||
return CSharpSymbolType.Unknown;
|
||||
#endif
|
||||
return CSharpSymbolType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -162,26 +164,26 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case CSharpSymbolType.Identifier:
|
||||
return RazorResources.CSharpSymbol_Identifier;
|
||||
case CSharpSymbolType.Keyword:
|
||||
return RazorResources.CSharpSymbol_Keyword;
|
||||
case CSharpSymbolType.IntegerLiteral:
|
||||
return RazorResources.CSharpSymbol_IntegerLiteral;
|
||||
case CSharpSymbolType.NewLine:
|
||||
return RazorResources.CSharpSymbol_Newline;
|
||||
case CSharpSymbolType.WhiteSpace:
|
||||
return RazorResources.CSharpSymbol_Whitespace;
|
||||
case CSharpSymbolType.Comment:
|
||||
return RazorResources.CSharpSymbol_Comment;
|
||||
case CSharpSymbolType.RealLiteral:
|
||||
return RazorResources.CSharpSymbol_RealLiteral;
|
||||
case CSharpSymbolType.CharacterLiteral:
|
||||
return RazorResources.CSharpSymbol_CharacterLiteral;
|
||||
case CSharpSymbolType.StringLiteral:
|
||||
return RazorResources.CSharpSymbol_StringLiteral;
|
||||
default:
|
||||
return RazorResources.Symbol_Unknown;
|
||||
case CSharpSymbolType.Identifier:
|
||||
return RazorResources.CSharpSymbol_Identifier;
|
||||
case CSharpSymbolType.Keyword:
|
||||
return RazorResources.CSharpSymbol_Keyword;
|
||||
case CSharpSymbolType.IntegerLiteral:
|
||||
return RazorResources.CSharpSymbol_IntegerLiteral;
|
||||
case CSharpSymbolType.NewLine:
|
||||
return RazorResources.CSharpSymbol_Newline;
|
||||
case CSharpSymbolType.WhiteSpace:
|
||||
return RazorResources.CSharpSymbol_Whitespace;
|
||||
case CSharpSymbolType.Comment:
|
||||
return RazorResources.CSharpSymbol_Comment;
|
||||
case CSharpSymbolType.RealLiteral:
|
||||
return RazorResources.CSharpSymbol_RealLiteral;
|
||||
case CSharpSymbolType.CharacterLiteral:
|
||||
return RazorResources.CSharpSymbol_CharacterLiteral;
|
||||
case CSharpSymbolType.StringLiteral:
|
||||
return RazorResources.CSharpSymbol_StringLiteral;
|
||||
default:
|
||||
return RazorResources.Symbol_Unknown;
|
||||
}
|
||||
}
|
||||
return sample;
|
||||
|
|
|
|||
|
|
@ -28,46 +28,46 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case HtmlSymbolType.Text:
|
||||
return RazorResources.HtmlSymbol_Text;
|
||||
case HtmlSymbolType.WhiteSpace:
|
||||
return RazorResources.HtmlSymbol_WhiteSpace;
|
||||
case HtmlSymbolType.NewLine:
|
||||
return RazorResources.HtmlSymbol_NewLine;
|
||||
case HtmlSymbolType.OpenAngle:
|
||||
return "<";
|
||||
case HtmlSymbolType.Bang:
|
||||
return "!";
|
||||
case HtmlSymbolType.Solidus:
|
||||
return "/";
|
||||
case HtmlSymbolType.QuestionMark:
|
||||
return "?";
|
||||
case HtmlSymbolType.DoubleHyphen:
|
||||
return "--";
|
||||
case HtmlSymbolType.LeftBracket:
|
||||
return "[";
|
||||
case HtmlSymbolType.CloseAngle:
|
||||
return ">";
|
||||
case HtmlSymbolType.RightBracket:
|
||||
return "]";
|
||||
case HtmlSymbolType.Equals:
|
||||
return "=";
|
||||
case HtmlSymbolType.DoubleQuote:
|
||||
return "\"";
|
||||
case HtmlSymbolType.SingleQuote:
|
||||
return "'";
|
||||
case HtmlSymbolType.Transition:
|
||||
return "@";
|
||||
case HtmlSymbolType.Colon:
|
||||
return ":";
|
||||
case HtmlSymbolType.RazorComment:
|
||||
return RazorResources.HtmlSymbol_RazorComment;
|
||||
case HtmlSymbolType.RazorCommentStar:
|
||||
return "*";
|
||||
case HtmlSymbolType.RazorCommentTransition:
|
||||
return "@";
|
||||
default:
|
||||
return RazorResources.Symbol_Unknown;
|
||||
case HtmlSymbolType.Text:
|
||||
return RazorResources.HtmlSymbol_Text;
|
||||
case HtmlSymbolType.WhiteSpace:
|
||||
return RazorResources.HtmlSymbol_WhiteSpace;
|
||||
case HtmlSymbolType.NewLine:
|
||||
return RazorResources.HtmlSymbol_NewLine;
|
||||
case HtmlSymbolType.OpenAngle:
|
||||
return "<";
|
||||
case HtmlSymbolType.Bang:
|
||||
return "!";
|
||||
case HtmlSymbolType.Solidus:
|
||||
return "/";
|
||||
case HtmlSymbolType.QuestionMark:
|
||||
return "?";
|
||||
case HtmlSymbolType.DoubleHyphen:
|
||||
return "--";
|
||||
case HtmlSymbolType.LeftBracket:
|
||||
return "[";
|
||||
case HtmlSymbolType.CloseAngle:
|
||||
return ">";
|
||||
case HtmlSymbolType.RightBracket:
|
||||
return "]";
|
||||
case HtmlSymbolType.Equals:
|
||||
return "=";
|
||||
case HtmlSymbolType.DoubleQuote:
|
||||
return "\"";
|
||||
case HtmlSymbolType.SingleQuote:
|
||||
return "'";
|
||||
case HtmlSymbolType.Transition:
|
||||
return "@";
|
||||
case HtmlSymbolType.Colon:
|
||||
return ":";
|
||||
case HtmlSymbolType.RazorComment:
|
||||
return RazorResources.HtmlSymbol_RazorComment;
|
||||
case HtmlSymbolType.RazorCommentStar:
|
||||
return "*";
|
||||
case HtmlSymbolType.RazorCommentTransition:
|
||||
return "@";
|
||||
default:
|
||||
return RazorResources.Symbol_Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,17 +80,19 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
{
|
||||
switch (bracket)
|
||||
{
|
||||
case HtmlSymbolType.LeftBracket:
|
||||
return HtmlSymbolType.RightBracket;
|
||||
case HtmlSymbolType.OpenAngle:
|
||||
return HtmlSymbolType.CloseAngle;
|
||||
case HtmlSymbolType.RightBracket:
|
||||
return HtmlSymbolType.LeftBracket;
|
||||
case HtmlSymbolType.CloseAngle:
|
||||
return HtmlSymbolType.OpenAngle;
|
||||
default:
|
||||
case HtmlSymbolType.LeftBracket:
|
||||
return HtmlSymbolType.RightBracket;
|
||||
case HtmlSymbolType.OpenAngle:
|
||||
return HtmlSymbolType.CloseAngle;
|
||||
case HtmlSymbolType.RightBracket:
|
||||
return HtmlSymbolType.LeftBracket;
|
||||
case HtmlSymbolType.CloseAngle:
|
||||
return HtmlSymbolType.OpenAngle;
|
||||
default:
|
||||
#if NET45
|
||||
Debug.Fail("FlipBracket must be called with a bracket character");
|
||||
return HtmlSymbolType.Unknown;
|
||||
#endif
|
||||
return HtmlSymbolType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,24 +105,24 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case KnownSymbolType.CommentStart:
|
||||
return HtmlSymbolType.RazorCommentTransition;
|
||||
case KnownSymbolType.CommentStar:
|
||||
return HtmlSymbolType.RazorCommentStar;
|
||||
case KnownSymbolType.CommentBody:
|
||||
return HtmlSymbolType.RazorComment;
|
||||
case KnownSymbolType.Identifier:
|
||||
return HtmlSymbolType.Text;
|
||||
case KnownSymbolType.Keyword:
|
||||
return HtmlSymbolType.Text;
|
||||
case KnownSymbolType.NewLine:
|
||||
return HtmlSymbolType.NewLine;
|
||||
case KnownSymbolType.Transition:
|
||||
return HtmlSymbolType.Transition;
|
||||
case KnownSymbolType.WhiteSpace:
|
||||
return HtmlSymbolType.WhiteSpace;
|
||||
default:
|
||||
return HtmlSymbolType.Unknown;
|
||||
case KnownSymbolType.CommentStart:
|
||||
return HtmlSymbolType.RazorCommentTransition;
|
||||
case KnownSymbolType.CommentStar:
|
||||
return HtmlSymbolType.RazorCommentStar;
|
||||
case KnownSymbolType.CommentBody:
|
||||
return HtmlSymbolType.RazorComment;
|
||||
case KnownSymbolType.Identifier:
|
||||
return HtmlSymbolType.Text;
|
||||
case KnownSymbolType.Keyword:
|
||||
return HtmlSymbolType.Text;
|
||||
case KnownSymbolType.NewLine:
|
||||
return HtmlSymbolType.NewLine;
|
||||
case KnownSymbolType.Transition:
|
||||
return HtmlSymbolType.Transition;
|
||||
case KnownSymbolType.WhiteSpace:
|
||||
return HtmlSymbolType.WhiteSpace;
|
||||
default:
|
||||
return HtmlSymbolType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -287,7 +287,9 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
_infiniteLoopGuardCount++;
|
||||
if (_infiniteLoopGuardCount > InfiniteLoopCountThreshold)
|
||||
{
|
||||
#if NET45
|
||||
Debug.Fail("An internal parser error is causing an infinite loop at this location.");
|
||||
#endif
|
||||
_terminated = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,11 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
value == '\f' ||
|
||||
value == '\t' ||
|
||||
value == '\u000B' || // Vertical Tab
|
||||
#if NET45
|
||||
Char.GetUnicodeCategory(value) == UnicodeCategory.SpaceSeparator;
|
||||
#else
|
||||
Char.IsSeparator(value);
|
||||
#endif
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Whitespace", Justification = "This would be a breaking change in a shipping API")]
|
||||
|
|
@ -88,7 +92,11 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
|
||||
public static bool IsDecimalDigit(char value)
|
||||
{
|
||||
#if NET45
|
||||
return Char.GetUnicodeCategory(value) == UnicodeCategory.DecimalDigitNumber;
|
||||
#else
|
||||
return Char.IsDigit(value);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool IsLetterOrDecimalDigit(char value)
|
||||
|
|
@ -98,29 +106,49 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
|
||||
public static bool IsLetter(char value)
|
||||
{
|
||||
#if NET45
|
||||
var cat = Char.GetUnicodeCategory(value);
|
||||
|
||||
return cat == UnicodeCategory.UppercaseLetter
|
||||
|| cat == UnicodeCategory.LowercaseLetter
|
||||
|| cat == UnicodeCategory.TitlecaseLetter
|
||||
|| cat == UnicodeCategory.ModifierLetter
|
||||
|| cat == UnicodeCategory.OtherLetter
|
||||
|| cat == UnicodeCategory.LetterNumber;
|
||||
#else
|
||||
return Char.IsLetter(value);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
public static bool IsFormatting(char value)
|
||||
{
|
||||
#if NET45
|
||||
return Char.GetUnicodeCategory(value) == UnicodeCategory.Format;
|
||||
#else
|
||||
return false; // TODO: Make the above work
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool IsCombining(char value)
|
||||
{
|
||||
#if NET45
|
||||
var cat = Char.GetUnicodeCategory(value);
|
||||
|
||||
return cat == UnicodeCategory.SpacingCombiningMark || cat == UnicodeCategory.NonSpacingMark;
|
||||
#else
|
||||
return false; // TODO: Make the above work
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
public static bool IsConnecting(char value)
|
||||
{
|
||||
#if NET45
|
||||
return Char.GetUnicodeCategory(value) == UnicodeCategory.ConnectorPunctuation;
|
||||
#else
|
||||
return false; // TODO: Make the above work
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string SanitizeClassName(string inputName)
|
||||
|
|
|
|||
|
|
@ -27,26 +27,5 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
public static readonly string LayoutKeyword = "layout";
|
||||
public static readonly string SessionStateKeyword = "sessionstate";
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Class is nested to provide better organization")]
|
||||
public static class VB
|
||||
{
|
||||
public static readonly int ImportsKeywordLength = 7;
|
||||
public static readonly string EndKeyword = "End";
|
||||
public static readonly string CodeKeyword = "Code";
|
||||
public static readonly string FunctionsKeyword = "Functions";
|
||||
public static readonly string SectionKeyword = "Section";
|
||||
public static readonly string StrictKeyword = "Strict";
|
||||
public static readonly string ExplicitKeyword = "Explicit";
|
||||
public static readonly string OffKeyword = "Off";
|
||||
public static readonly string HelperKeyword = "Helper";
|
||||
public static readonly string SelectCaseKeyword = "Select Case";
|
||||
public static readonly string LayoutKeyword = "Layout";
|
||||
public static readonly string EndCodeKeyword = "End Code";
|
||||
public static readonly string EndHelperKeyword = "End Helper";
|
||||
public static readonly string EndFunctionsKeyword = "End Functions";
|
||||
public static readonly string EndSectionKeyword = "End Section";
|
||||
public static readonly string SessionStateKeyword = "SessionState";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,411 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Razor.Editor;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.AspNet.Razor.Tokenizer;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Parser
|
||||
{
|
||||
public partial class VBCodeParser : TokenizerBackedParser<VBTokenizer, VBSymbol, VBSymbolType>
|
||||
{
|
||||
private void SetUpDirectives()
|
||||
{
|
||||
MapDirective(SyntaxConstants.VB.CodeKeyword, EndTerminatedDirective(SyntaxConstants.VB.CodeKeyword,
|
||||
BlockType.Statement,
|
||||
new StatementCodeGenerator(),
|
||||
allowMarkup: true));
|
||||
MapDirective(SyntaxConstants.VB.FunctionsKeyword, EndTerminatedDirective(SyntaxConstants.VB.FunctionsKeyword,
|
||||
BlockType.Functions,
|
||||
new TypeMemberCodeGenerator(),
|
||||
allowMarkup: false));
|
||||
MapDirective(SyntaxConstants.VB.SectionKeyword, SectionDirective);
|
||||
MapDirective(SyntaxConstants.VB.HelperKeyword, HelperDirective);
|
||||
|
||||
MapDirective(SyntaxConstants.VB.LayoutKeyword, LayoutDirective);
|
||||
MapDirective(SyntaxConstants.VB.SessionStateKeyword, SessionStateDirective);
|
||||
}
|
||||
|
||||
protected virtual bool LayoutDirective()
|
||||
{
|
||||
AssertDirective(SyntaxConstants.VB.LayoutKeyword);
|
||||
AcceptAndMoveNext();
|
||||
Context.CurrentBlock.Type = BlockType.Directive;
|
||||
|
||||
// Accept spaces, but not newlines
|
||||
bool foundSomeWhitespace = At(VBSymbolType.WhiteSpace);
|
||||
AcceptWhile(VBSymbolType.WhiteSpace);
|
||||
Output(SpanKind.MetaCode, foundSomeWhitespace ? AcceptedCharacters.None : AcceptedCharacters.Any);
|
||||
|
||||
// First non-whitespace character starts the Layout Page, then newline ends it
|
||||
AcceptUntil(VBSymbolType.NewLine);
|
||||
Span.CodeGenerator = new SetLayoutCodeGenerator(Span.GetContent());
|
||||
Span.EditHandler.EditorHints = EditorHints.LayoutPage | EditorHints.VirtualPath;
|
||||
bool foundNewline = Optional(VBSymbolType.NewLine);
|
||||
AddMarkerSymbolIfNecessary();
|
||||
Output(SpanKind.MetaCode, foundNewline ? AcceptedCharacters.None : AcceptedCharacters.Any);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool SessionStateDirective()
|
||||
{
|
||||
AssertDirective(SyntaxConstants.VB.SessionStateKeyword);
|
||||
AcceptAndMoveNext();
|
||||
Context.CurrentBlock.Type = BlockType.Directive;
|
||||
|
||||
// Accept spaces, but not newlines
|
||||
bool foundSomeWhitespace = At(VBSymbolType.WhiteSpace);
|
||||
AcceptWhile(VBSymbolType.WhiteSpace);
|
||||
Output(SpanKind.MetaCode, foundSomeWhitespace ? AcceptedCharacters.None : AcceptedCharacters.Any);
|
||||
|
||||
// First non-whitespace character starts the session state directive, then newline ends it
|
||||
AcceptUntil(VBSymbolType.NewLine);
|
||||
var value = String.Concat(Span.Symbols.Select(sym => sym.Content));
|
||||
Span.CodeGenerator = new RazorDirectiveAttributeCodeGenerator(SyntaxConstants.VB.SessionStateKeyword, value);
|
||||
bool foundNewline = Optional(VBSymbolType.NewLine);
|
||||
AddMarkerSymbolIfNecessary();
|
||||
Output(SpanKind.MetaCode, foundNewline ? AcceptedCharacters.None : AcceptedCharacters.Any);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool HelperDirective()
|
||||
{
|
||||
if (Context.IsWithin(BlockType.Helper))
|
||||
{
|
||||
Context.OnError(CurrentLocation, RazorResources.ParseError_Helpers_Cannot_Be_Nested);
|
||||
}
|
||||
|
||||
Context.CurrentBlock.Type = BlockType.Helper;
|
||||
SourceLocation blockStart = CurrentLocation;
|
||||
|
||||
AssertDirective(SyntaxConstants.VB.HelperKeyword);
|
||||
AcceptAndMoveNext();
|
||||
|
||||
VBSymbolType firstAfterKeyword = VBSymbolType.Unknown;
|
||||
if (CurrentSymbol != null)
|
||||
{
|
||||
firstAfterKeyword = CurrentSymbol.Type;
|
||||
}
|
||||
|
||||
VBSymbol remainingWs = null;
|
||||
if (At(VBSymbolType.NewLine))
|
||||
{
|
||||
// Accept a _single_ new line, we'll be aborting later.
|
||||
AcceptAndMoveNext();
|
||||
}
|
||||
else
|
||||
{
|
||||
remainingWs = AcceptSingleWhiteSpaceCharacter();
|
||||
}
|
||||
if (firstAfterKeyword == VBSymbolType.WhiteSpace || firstAfterKeyword == VBSymbolType.NewLine)
|
||||
{
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
|
||||
}
|
||||
Output(SpanKind.MetaCode);
|
||||
if (firstAfterKeyword != VBSymbolType.WhiteSpace)
|
||||
{
|
||||
string error;
|
||||
if (At(VBSymbolType.NewLine))
|
||||
{
|
||||
error = RazorResources.ErrorComponent_Newline;
|
||||
}
|
||||
else if (EndOfFile)
|
||||
{
|
||||
error = RazorResources.ErrorComponent_EndOfFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
error = String.Format(CultureInfo.CurrentCulture, RazorResources.ErrorComponent_Character, CurrentSymbol.Content);
|
||||
}
|
||||
|
||||
Context.OnError(
|
||||
CurrentLocation,
|
||||
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start,
|
||||
error);
|
||||
|
||||
// Bail out.
|
||||
PutCurrentBack();
|
||||
Output(SpanKind.Code);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (remainingWs != null)
|
||||
{
|
||||
Accept(remainingWs);
|
||||
}
|
||||
|
||||
bool errorReported = !Required(VBSymbolType.Identifier, RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start);
|
||||
|
||||
AcceptWhile(VBSymbolType.WhiteSpace);
|
||||
|
||||
SourceLocation parensStart = CurrentLocation;
|
||||
bool headerComplete = false;
|
||||
if (!Optional(VBSymbolType.LeftParenthesis))
|
||||
{
|
||||
if (!errorReported)
|
||||
{
|
||||
errorReported = true;
|
||||
Context.OnError(CurrentLocation,
|
||||
RazorResources.ParseError_MissingCharAfterHelperName,
|
||||
VBSymbol.GetSample(VBSymbolType.LeftParenthesis));
|
||||
}
|
||||
}
|
||||
else if (!Balance(BalancingModes.NoErrorOnFailure, VBSymbolType.LeftParenthesis, VBSymbolType.RightParenthesis, parensStart))
|
||||
{
|
||||
Context.OnError(parensStart, RazorResources.ParseError_UnterminatedHelperParameterList);
|
||||
}
|
||||
else
|
||||
{
|
||||
Expected(VBSymbolType.RightParenthesis);
|
||||
headerComplete = true;
|
||||
}
|
||||
|
||||
AddMarkerSymbolIfNecessary();
|
||||
Context.CurrentBlock.CodeGenerator = new HelperCodeGenerator(
|
||||
Span.GetContent(),
|
||||
headerComplete);
|
||||
AutoCompleteEditHandler editHandler = new AutoCompleteEditHandler(Language.TokenizeString);
|
||||
Span.EditHandler = editHandler;
|
||||
Output(SpanKind.Code);
|
||||
|
||||
if (headerComplete)
|
||||
{
|
||||
bool old = IsNested;
|
||||
IsNested = true;
|
||||
using (Context.StartBlock(BlockType.Statement))
|
||||
{
|
||||
using (PushSpanConfig(StatementBlockSpanConfiguration(new StatementCodeGenerator())))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!EndTerminatedDirectiveBody(SyntaxConstants.VB.HelperKeyword, blockStart, allowAllTransitions: true))
|
||||
{
|
||||
if (Context.LastAcceptedCharacters != AcceptedCharacters.Any)
|
||||
{
|
||||
AddMarkerSymbolIfNecessary();
|
||||
}
|
||||
|
||||
editHandler.AutoCompleteString = SyntaxConstants.VB.EndHelperKeyword;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Output(SpanKind.Code);
|
||||
IsNested = old;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(SpanKind.Code);
|
||||
}
|
||||
PutCurrentBack();
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual bool SectionDirective()
|
||||
{
|
||||
SourceLocation start = CurrentLocation;
|
||||
AssertDirective(SyntaxConstants.VB.SectionKeyword);
|
||||
AcceptAndMoveNext();
|
||||
|
||||
if (Context.IsWithin(BlockType.Section))
|
||||
{
|
||||
Context.OnError(CurrentLocation, RazorResources.ParseError_Sections_Cannot_Be_Nested, RazorResources.SectionExample_VB);
|
||||
}
|
||||
|
||||
if (At(VBSymbolType.NewLine))
|
||||
{
|
||||
AcceptAndMoveNext();
|
||||
}
|
||||
else
|
||||
{
|
||||
AcceptVBSpaces();
|
||||
}
|
||||
string sectionName = null;
|
||||
if (!At(VBSymbolType.Identifier))
|
||||
{
|
||||
Context.OnError(CurrentLocation,
|
||||
RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start,
|
||||
GetCurrentSymbolDisplay());
|
||||
}
|
||||
else
|
||||
{
|
||||
sectionName = CurrentSymbol.Content;
|
||||
AcceptAndMoveNext();
|
||||
}
|
||||
Context.CurrentBlock.Type = BlockType.Section;
|
||||
Context.CurrentBlock.CodeGenerator = new SectionCodeGenerator(sectionName ?? String.Empty);
|
||||
|
||||
AutoCompleteEditHandler editHandler = new AutoCompleteEditHandler(Language.TokenizeString);
|
||||
Span.EditHandler = editHandler;
|
||||
|
||||
PutCurrentBack();
|
||||
|
||||
Output(SpanKind.MetaCode);
|
||||
|
||||
// Parse the section
|
||||
OtherParserBlock(null, SyntaxConstants.VB.EndSectionKeyword);
|
||||
|
||||
Span.CodeGenerator = SpanCodeGenerator.Null;
|
||||
bool complete = false;
|
||||
if (!At(VBKeyword.End))
|
||||
{
|
||||
Context.OnError(start,
|
||||
RazorResources.ParseError_BlockNotTerminated,
|
||||
SyntaxConstants.VB.SectionKeyword,
|
||||
SyntaxConstants.VB.EndSectionKeyword);
|
||||
editHandler.AutoCompleteString = SyntaxConstants.VB.EndSectionKeyword;
|
||||
}
|
||||
else
|
||||
{
|
||||
AcceptAndMoveNext();
|
||||
AcceptWhile(VBSymbolType.WhiteSpace);
|
||||
if (!At(SyntaxConstants.VB.SectionKeyword))
|
||||
{
|
||||
Context.OnError(start,
|
||||
RazorResources.ParseError_BlockNotTerminated,
|
||||
SyntaxConstants.VB.SectionKeyword,
|
||||
SyntaxConstants.VB.EndSectionKeyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
AcceptAndMoveNext();
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
|
||||
complete = true;
|
||||
}
|
||||
}
|
||||
PutCurrentBack();
|
||||
Output(SpanKind.MetaCode);
|
||||
return complete;
|
||||
}
|
||||
|
||||
protected virtual Func<bool> EndTerminatedDirective(string directive, BlockType blockType, SpanCodeGenerator codeGenerator, bool allowMarkup)
|
||||
{
|
||||
return () =>
|
||||
{
|
||||
SourceLocation blockStart = CurrentLocation;
|
||||
Context.CurrentBlock.Type = blockType;
|
||||
AssertDirective(directive);
|
||||
AcceptAndMoveNext();
|
||||
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
|
||||
Span.CodeGenerator = SpanCodeGenerator.Null;
|
||||
Output(SpanKind.MetaCode);
|
||||
|
||||
using (PushSpanConfig(StatementBlockSpanConfiguration(codeGenerator)))
|
||||
{
|
||||
AutoCompleteEditHandler editHandler = new AutoCompleteEditHandler(Language.TokenizeString);
|
||||
Span.EditHandler = editHandler;
|
||||
|
||||
if (!EndTerminatedDirectiveBody(directive, blockStart, allowMarkup))
|
||||
{
|
||||
editHandler.AutoCompleteString = String.Concat(SyntaxConstants.VB.EndKeyword, " ", directive);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual bool EndTerminatedDirectiveBody(string directive, SourceLocation blockStart, bool allowAllTransitions)
|
||||
{
|
||||
while (!EndOfFile)
|
||||
{
|
||||
VBSymbol lastWhitespace = AcceptWhiteSpaceInLines();
|
||||
if (IsAtEmbeddedTransition(allowTemplatesAndComments: allowAllTransitions, allowTransitions: allowAllTransitions))
|
||||
{
|
||||
HandleEmbeddedTransition(lastWhitespace);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (At(VBKeyword.End))
|
||||
{
|
||||
Accept(lastWhitespace);
|
||||
VBSymbol end = CurrentSymbol;
|
||||
NextToken();
|
||||
IEnumerable<VBSymbol> ws = ReadVBSpaces();
|
||||
if (At(directive))
|
||||
{
|
||||
if (Context.LastAcceptedCharacters != AcceptedCharacters.Any)
|
||||
{
|
||||
AddMarkerSymbolIfNecessary(end.Start);
|
||||
}
|
||||
Output(SpanKind.Code);
|
||||
Accept(end);
|
||||
Accept(ws);
|
||||
AcceptAndMoveNext();
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
|
||||
Span.CodeGenerator = SpanCodeGenerator.Null;
|
||||
Output(SpanKind.MetaCode);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Accept(end);
|
||||
Accept(ws);
|
||||
AcceptAndMoveNext();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Accept(lastWhitespace);
|
||||
AcceptAndMoveNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is a language keyword, so it does not need to be localized
|
||||
Context.OnError(blockStart, RazorResources.ParseError_BlockNotTerminated, directive, String.Concat(SyntaxConstants.VB.EndKeyword, " ", directive));
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool At(string directive)
|
||||
{
|
||||
return At(VBSymbolType.Identifier) && String.Equals(CurrentSymbol.Content, directive, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "'this' is used in DEBUG builds")]
|
||||
[Conditional("DEBUG")]
|
||||
protected void AssertDirective(string directive)
|
||||
{
|
||||
Assert(VBSymbolType.Identifier);
|
||||
Debug.Assert(String.Equals(directive, CurrentSymbol.Content, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private string GetCurrentSymbolDisplay()
|
||||
{
|
||||
if (EndOfFile)
|
||||
{
|
||||
return RazorResources.ErrorComponent_EndOfFile;
|
||||
}
|
||||
else if (At(VBSymbolType.NewLine))
|
||||
{
|
||||
return RazorResources.ErrorComponent_Newline;
|
||||
}
|
||||
else if (At(VBSymbolType.WhiteSpace))
|
||||
{
|
||||
return RazorResources.ErrorComponent_Whitespace;
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(CultureInfo.CurrentCulture, RazorResources.ErrorComponent_Character, CurrentSymbol.Content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,315 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.AspNet.Razor.Tokenizer;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Parser
|
||||
{
|
||||
public partial class VBCodeParser : TokenizerBackedParser<VBTokenizer, VBSymbol, VBSymbolType>
|
||||
{
|
||||
private void SetUpKeywords()
|
||||
{
|
||||
MapKeyword(VBKeyword.Using, EndTerminatedStatement(VBKeyword.Using, supportsExit: false, supportsContinue: false)); // http://msdn.microsoft.com/en-us/library/htd05whh.aspx
|
||||
MapKeyword(VBKeyword.While, EndTerminatedStatement(VBKeyword.While, supportsExit: true, supportsContinue: true)); // http://msdn.microsoft.com/en-us/library/zh1f56zs.aspx
|
||||
MapKeyword(VBKeyword.If, EndTerminatedStatement(VBKeyword.If, supportsExit: false, supportsContinue: false)); // http://msdn.microsoft.com/en-us/library/752y8abs.aspx
|
||||
MapKeyword(VBKeyword.Select, EndTerminatedStatement(VBKeyword.Select, supportsExit: true, supportsContinue: false, blockName: SyntaxConstants.VB.SelectCaseKeyword)); // http://msdn.microsoft.com/en-us/library/cy37t14y.aspx
|
||||
MapKeyword(VBKeyword.Try, EndTerminatedStatement(VBKeyword.Try, supportsExit: true, supportsContinue: false)); // http://msdn.microsoft.com/en-us/library/fk6t46tz.aspx
|
||||
MapKeyword(VBKeyword.With, EndTerminatedStatement(VBKeyword.With, supportsExit: false, supportsContinue: false)); // http://msdn.microsoft.com/en-us/library/wc500chb.aspx
|
||||
MapKeyword(VBKeyword.SyncLock, EndTerminatedStatement(VBKeyword.SyncLock, supportsExit: false, supportsContinue: false)); // http://msdn.microsoft.com/en-us/library/3a86s51t.aspx
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/5z06z1kb.aspx
|
||||
// http://msdn.microsoft.com/en-us/library/5ebk1751.aspx
|
||||
MapKeyword(VBKeyword.For, KeywordTerminatedStatement(VBKeyword.For, VBKeyword.Next, supportsExit: true, supportsContinue: true));
|
||||
MapKeyword(VBKeyword.Do, KeywordTerminatedStatement(VBKeyword.Do, VBKeyword.Loop, supportsExit: true, supportsContinue: true)); // http://msdn.microsoft.com/en-us/library/eked04a7.aspx
|
||||
|
||||
MapKeyword(VBKeyword.Imports, ImportsStatement);
|
||||
MapKeyword(VBKeyword.Option, OptionStatement);
|
||||
MapKeyword(VBKeyword.Inherits, InheritsStatement);
|
||||
|
||||
MapKeyword(VBKeyword.Class, ReservedWord);
|
||||
MapKeyword(VBKeyword.Namespace, ReservedWord);
|
||||
}
|
||||
|
||||
protected virtual bool InheritsStatement()
|
||||
{
|
||||
Assert(VBKeyword.Inherits);
|
||||
|
||||
Span.CodeGenerator = SpanCodeGenerator.Null;
|
||||
Context.CurrentBlock.Type = BlockType.Directive;
|
||||
|
||||
AcceptAndMoveNext();
|
||||
SourceLocation endInherits = CurrentLocation;
|
||||
|
||||
if (At(VBSymbolType.WhiteSpace))
|
||||
{
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
|
||||
}
|
||||
|
||||
AcceptWhile(VBSymbolType.WhiteSpace);
|
||||
Output(SpanKind.MetaCode);
|
||||
|
||||
if (EndOfFile || At(VBSymbolType.WhiteSpace) || At(VBSymbolType.NewLine))
|
||||
{
|
||||
Context.OnError(endInherits, RazorResources.ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName);
|
||||
}
|
||||
|
||||
// Just accept to a newline
|
||||
AcceptUntil(VBSymbolType.NewLine);
|
||||
if (!Context.DesignTimeMode)
|
||||
{
|
||||
// We want the newline to be treated as code, but it causes issues at design-time.
|
||||
Optional(VBSymbolType.NewLine);
|
||||
}
|
||||
|
||||
string baseType = Span.GetContent();
|
||||
Span.CodeGenerator = new SetBaseTypeCodeGenerator(baseType.Trim());
|
||||
|
||||
Output(SpanKind.Code);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual bool OptionStatement()
|
||||
{
|
||||
try
|
||||
{
|
||||
Context.CurrentBlock.Type = BlockType.Directive;
|
||||
|
||||
Assert(VBKeyword.Option);
|
||||
AcceptAndMoveNext();
|
||||
AcceptWhile(VBSymbolType.WhiteSpace);
|
||||
if (!At(VBSymbolType.Identifier))
|
||||
{
|
||||
if (CurrentSymbol != null)
|
||||
{
|
||||
Context.OnError(CurrentLocation, String.Format(CultureInfo.CurrentCulture,
|
||||
RazorResources.ParseError_Unexpected,
|
||||
CurrentSymbol.Content));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
SourceLocation optionLoc = CurrentLocation;
|
||||
string option = CurrentSymbol.Content;
|
||||
AcceptAndMoveNext();
|
||||
|
||||
AcceptWhile(VBSymbolType.WhiteSpace);
|
||||
bool boolVal;
|
||||
if (At(VBKeyword.On))
|
||||
{
|
||||
AcceptAndMoveNext();
|
||||
boolVal = true;
|
||||
}
|
||||
else if (At(VBSymbolType.Identifier))
|
||||
{
|
||||
if (String.Equals(CurrentSymbol.Content, SyntaxConstants.VB.OffKeyword, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
AcceptAndMoveNext();
|
||||
boolVal = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.OnError(CurrentLocation, String.Format(CultureInfo.CurrentCulture,
|
||||
RazorResources.ParseError_InvalidOptionValue,
|
||||
option,
|
||||
CurrentSymbol.Content));
|
||||
AcceptAndMoveNext();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!EndOfFile)
|
||||
{
|
||||
Context.OnError(CurrentLocation, String.Format(CultureInfo.CurrentCulture,
|
||||
RazorResources.ParseError_Unexpected,
|
||||
CurrentSymbol.Content));
|
||||
AcceptAndMoveNext();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (String.Equals(option, SyntaxConstants.VB.StrictKeyword, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Span.CodeGenerator = SetVBOptionCodeGenerator.Strict(boolVal);
|
||||
}
|
||||
else if (String.Equals(option, SyntaxConstants.VB.ExplicitKeyword, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Span.CodeGenerator = SetVBOptionCodeGenerator.Explicit(boolVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
Span.CodeGenerator = new SetVBOptionCodeGenerator(option, boolVal);
|
||||
Context.OnError(optionLoc, RazorResources.ParseError_UnknownOption, option);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Span.Symbols.Count > 0)
|
||||
{
|
||||
Output(SpanKind.MetaCode);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool ImportsStatement()
|
||||
{
|
||||
Context.CurrentBlock.Type = BlockType.Directive;
|
||||
Assert(VBKeyword.Imports);
|
||||
AcceptAndMoveNext();
|
||||
|
||||
AcceptVBSpaces();
|
||||
if (At(VBSymbolType.WhiteSpace) || At(VBSymbolType.NewLine))
|
||||
{
|
||||
Context.OnError(CurrentLocation, RazorResources.ParseError_NamespaceOrTypeAliasExpected);
|
||||
}
|
||||
|
||||
// Just accept to a newline
|
||||
AcceptUntil(VBSymbolType.NewLine);
|
||||
Optional(VBSymbolType.NewLine);
|
||||
|
||||
string ns = String.Concat(Span.Symbols.Skip(1).Select(s => s.Content));
|
||||
Span.CodeGenerator = new AddImportCodeGenerator(ns, SyntaxConstants.VB.ImportsKeywordLength);
|
||||
|
||||
Output(SpanKind.MetaCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual Func<bool> EndTerminatedStatement(VBKeyword keyword, bool supportsExit, bool supportsContinue)
|
||||
{
|
||||
return EndTerminatedStatement(keyword, supportsExit, supportsContinue, blockName: keyword.ToString());
|
||||
}
|
||||
|
||||
protected virtual Func<bool> EndTerminatedStatement(VBKeyword keyword, bool supportsExit, bool supportsContinue, string blockName)
|
||||
{
|
||||
return () =>
|
||||
{
|
||||
using (PushSpanConfig(StatementBlockSpanConfiguration(new StatementCodeGenerator())))
|
||||
{
|
||||
SourceLocation blockStart = CurrentLocation;
|
||||
Assert(keyword);
|
||||
AcceptAndMoveNext();
|
||||
|
||||
while (!EndOfFile)
|
||||
{
|
||||
VBSymbol lastWhitespace = AcceptWhiteSpaceInLines();
|
||||
if (IsAtEmbeddedTransition(allowTemplatesAndComments: true, allowTransitions: true))
|
||||
{
|
||||
HandleEmbeddedTransition(lastWhitespace);
|
||||
}
|
||||
else
|
||||
{
|
||||
Accept(lastWhitespace);
|
||||
|
||||
if ((supportsExit && At(VBKeyword.Exit)) || (supportsContinue && At(VBKeyword.Continue)))
|
||||
{
|
||||
HandleExitOrContinue(keyword);
|
||||
}
|
||||
else if (At(VBKeyword.End))
|
||||
{
|
||||
AcceptAndMoveNext();
|
||||
AcceptVBSpaces();
|
||||
if (At(keyword))
|
||||
{
|
||||
AcceptAndMoveNext();
|
||||
if (!Context.DesignTimeMode)
|
||||
{
|
||||
Optional(VBSymbolType.NewLine);
|
||||
}
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (At(keyword))
|
||||
{
|
||||
// Parse nested statement
|
||||
EndTerminatedStatement(keyword, supportsExit, supportsContinue)();
|
||||
}
|
||||
else if (!EndOfFile)
|
||||
{
|
||||
AcceptAndMoveNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context.OnError(blockStart,
|
||||
RazorResources.ParseError_BlockNotTerminated,
|
||||
blockName,
|
||||
// This is a language keyword, so it does not need to be localized
|
||||
String.Concat(VBKeyword.End, " ", keyword));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual Func<bool> KeywordTerminatedStatement(VBKeyword start, VBKeyword terminator, bool supportsExit, bool supportsContinue)
|
||||
{
|
||||
return () =>
|
||||
{
|
||||
using (PushSpanConfig(StatementBlockSpanConfiguration(new StatementCodeGenerator())))
|
||||
{
|
||||
SourceLocation blockStart = CurrentLocation;
|
||||
Assert(start);
|
||||
AcceptAndMoveNext();
|
||||
while (!EndOfFile)
|
||||
{
|
||||
VBSymbol lastWhitespace = AcceptWhiteSpaceInLines();
|
||||
if (IsAtEmbeddedTransition(allowTemplatesAndComments: true, allowTransitions: true))
|
||||
{
|
||||
HandleEmbeddedTransition(lastWhitespace);
|
||||
}
|
||||
else
|
||||
{
|
||||
Accept(lastWhitespace);
|
||||
if ((supportsExit && At(VBKeyword.Exit)) || (supportsContinue && At(VBKeyword.Continue)))
|
||||
{
|
||||
HandleExitOrContinue(start);
|
||||
}
|
||||
else if (At(start))
|
||||
{
|
||||
// Parse nested statement
|
||||
KeywordTerminatedStatement(start, terminator, supportsExit, supportsContinue)();
|
||||
}
|
||||
else if (At(terminator))
|
||||
{
|
||||
AcceptUntil(VBSymbolType.NewLine);
|
||||
Optional(VBSymbolType.NewLine);
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.AnyExceptNewline;
|
||||
return false;
|
||||
}
|
||||
else if (!EndOfFile)
|
||||
{
|
||||
AcceptAndMoveNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context.OnError(blockStart,
|
||||
RazorResources.ParseError_BlockNotTerminated,
|
||||
start, terminator);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void HandleExitOrContinue(VBKeyword keyword)
|
||||
{
|
||||
Assert(VBSymbolType.Keyword);
|
||||
Debug.Assert(CurrentSymbol.Keyword == VBKeyword.Continue || CurrentSymbol.Keyword == VBKeyword.Exit);
|
||||
|
||||
// Accept, read whitespace and look for the next keyword
|
||||
AcceptAndMoveNext();
|
||||
AcceptWhile(VBSymbolType.WhiteSpace);
|
||||
|
||||
// If this is the start keyword, skip it and continue (to avoid starting a nested statement block)
|
||||
Optional(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,601 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Razor.Editor;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.AspNet.Razor.Tokenizer;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Parser
|
||||
{
|
||||
public partial class VBCodeParser : TokenizerBackedParser<VBTokenizer, VBSymbol, VBSymbolType>
|
||||
{
|
||||
internal static ISet<string> DefaultKeywords = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"functions",
|
||||
"code",
|
||||
"section",
|
||||
"do",
|
||||
"while",
|
||||
"if",
|
||||
"select",
|
||||
"for",
|
||||
"try",
|
||||
"with",
|
||||
"synclock",
|
||||
"using",
|
||||
"imports",
|
||||
"inherits",
|
||||
"option",
|
||||
"helper",
|
||||
"namespace",
|
||||
"class",
|
||||
"layout",
|
||||
"sessionstate"
|
||||
};
|
||||
|
||||
private Dictionary<VBKeyword, Func<bool>> _keywordHandlers = new Dictionary<VBKeyword, Func<bool>>();
|
||||
private Dictionary<string, Func<bool>> _directiveHandlers = new Dictionary<string, Func<bool>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
[SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "Necessary state is initialized before calling virtual methods")]
|
||||
public VBCodeParser()
|
||||
{
|
||||
DirectParentIsCode = false;
|
||||
Keywords = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
SetUpKeywords();
|
||||
SetUpDirectives();
|
||||
}
|
||||
|
||||
protected internal ISet<string> Keywords { get; private set; }
|
||||
|
||||
protected override LanguageCharacteristics<VBTokenizer, VBSymbol, VBSymbolType> Language
|
||||
{
|
||||
get { return VBLanguageCharacteristics.Instance; }
|
||||
}
|
||||
|
||||
protected override ParserBase OtherParser
|
||||
{
|
||||
get { return Context.MarkupParser; }
|
||||
}
|
||||
|
||||
private bool IsNested { get; set; }
|
||||
private bool DirectParentIsCode { get; set; }
|
||||
|
||||
protected override bool IsAtEmbeddedTransition(bool allowTemplatesAndComments, bool allowTransitions)
|
||||
{
|
||||
return (allowTransitions && Language.IsTransition(CurrentSymbol) && !Was(VBSymbolType.Dot)) ||
|
||||
(allowTemplatesAndComments && Language.IsCommentStart(CurrentSymbol)) ||
|
||||
(Language.IsTransition(CurrentSymbol) && NextIs(VBSymbolType.Transition));
|
||||
}
|
||||
|
||||
protected override void HandleEmbeddedTransition()
|
||||
{
|
||||
HandleEmbeddedTransition(null);
|
||||
}
|
||||
|
||||
protected void HandleEmbeddedTransition(VBSymbol lastWhiteSpace)
|
||||
{
|
||||
if (At(VBSymbolType.RazorCommentTransition))
|
||||
{
|
||||
Accept(lastWhiteSpace);
|
||||
RazorComment();
|
||||
}
|
||||
else if ((At(VBSymbolType.Transition) && !Was(VBSymbolType.Dot)))
|
||||
{
|
||||
HandleTransition(lastWhiteSpace);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ParseBlock()
|
||||
{
|
||||
if (Context == null)
|
||||
{
|
||||
throw new InvalidOperationException(RazorResources.Parser_Context_Not_Set);
|
||||
}
|
||||
using (PushSpanConfig())
|
||||
{
|
||||
if (Context == null)
|
||||
{
|
||||
throw new InvalidOperationException(RazorResources.Parser_Context_Not_Set);
|
||||
}
|
||||
|
||||
Initialize(Span);
|
||||
NextToken();
|
||||
using (Context.StartBlock())
|
||||
{
|
||||
IEnumerable<VBSymbol> syms = ReadWhile(sym => sym.Type == VBSymbolType.WhiteSpace);
|
||||
if (At(VBSymbolType.Transition))
|
||||
{
|
||||
Accept(syms);
|
||||
Span.CodeGenerator = new StatementCodeGenerator();
|
||||
Output(SpanKind.Code);
|
||||
}
|
||||
else
|
||||
{
|
||||
PutBack(syms);
|
||||
EnsureCurrent();
|
||||
}
|
||||
|
||||
// Allow a transition span, but don't require it
|
||||
if (Optional(VBSymbolType.Transition))
|
||||
{
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
|
||||
Span.CodeGenerator = SpanCodeGenerator.Null;
|
||||
Output(SpanKind.Transition);
|
||||
}
|
||||
|
||||
Context.CurrentBlock.Type = BlockType.Expression;
|
||||
Context.CurrentBlock.CodeGenerator = new ExpressionCodeGenerator();
|
||||
|
||||
// Determine the type of the block
|
||||
bool isComplete = false;
|
||||
Action<SpanBuilder> config = null;
|
||||
if (!EndOfFile)
|
||||
{
|
||||
switch (CurrentSymbol.Type)
|
||||
{
|
||||
case VBSymbolType.Identifier:
|
||||
if (!TryDirectiveBlock(ref isComplete))
|
||||
{
|
||||
ImplicitExpression();
|
||||
}
|
||||
break;
|
||||
case VBSymbolType.LeftParenthesis:
|
||||
isComplete = ExplicitExpression();
|
||||
break;
|
||||
case VBSymbolType.Keyword:
|
||||
Context.CurrentBlock.Type = BlockType.Statement;
|
||||
Context.CurrentBlock.CodeGenerator = BlockCodeGenerator.Null;
|
||||
isComplete = KeywordBlock();
|
||||
break;
|
||||
case VBSymbolType.WhiteSpace:
|
||||
case VBSymbolType.NewLine:
|
||||
config = ImplictExpressionSpanConfig;
|
||||
Context.OnError(CurrentLocation,
|
||||
RazorResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_VB);
|
||||
break;
|
||||
default:
|
||||
config = ImplictExpressionSpanConfig;
|
||||
Context.OnError(CurrentLocation,
|
||||
RazorResources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock_VB,
|
||||
CurrentSymbol.Content);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
config = ImplictExpressionSpanConfig;
|
||||
Context.OnError(CurrentLocation,
|
||||
RazorResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock);
|
||||
}
|
||||
using (PushSpanConfig(config))
|
||||
{
|
||||
if (!isComplete && Span.Symbols.Count == 0 && Context.LastAcceptedCharacters != AcceptedCharacters.Any)
|
||||
{
|
||||
AddMarkerSymbolIfNecessary();
|
||||
}
|
||||
Output(SpanKind.Code);
|
||||
PutCurrentBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ImplictExpressionSpanConfig(SpanBuilder span)
|
||||
{
|
||||
span.CodeGenerator = new ExpressionCodeGenerator();
|
||||
span.EditHandler = new ImplicitExpressionEditHandler(
|
||||
Language.TokenizeString,
|
||||
Keywords,
|
||||
acceptTrailingDot: DirectParentIsCode)
|
||||
{
|
||||
AcceptedCharacters = AcceptedCharacters.NonWhiteSpace
|
||||
};
|
||||
}
|
||||
|
||||
private Action<SpanBuilder> StatementBlockSpanConfiguration(SpanCodeGenerator codeGenerator)
|
||||
{
|
||||
return span =>
|
||||
{
|
||||
span.Kind = SpanKind.Code;
|
||||
span.CodeGenerator = codeGenerator;
|
||||
span.EditHandler = SpanEditHandler.CreateDefault(Language.TokenizeString);
|
||||
};
|
||||
}
|
||||
|
||||
// Pass "complete" flag by ref, not out because some paths may not change it.
|
||||
private bool TryDirectiveBlock(ref bool complete)
|
||||
{
|
||||
Assert(VBSymbolType.Identifier);
|
||||
Func<bool> handler;
|
||||
if (_directiveHandlers.TryGetValue(CurrentSymbol.Content, out handler))
|
||||
{
|
||||
Context.CurrentBlock.CodeGenerator = BlockCodeGenerator.Null;
|
||||
complete = handler();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool KeywordBlock()
|
||||
{
|
||||
Assert(VBSymbolType.Keyword);
|
||||
Func<bool> handler;
|
||||
if (_keywordHandlers.TryGetValue(CurrentSymbol.Keyword.Value, out handler))
|
||||
{
|
||||
Span.CodeGenerator = new StatementCodeGenerator();
|
||||
Context.CurrentBlock.Type = BlockType.Statement;
|
||||
return handler();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImplicitExpression();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ExplicitExpression()
|
||||
{
|
||||
Context.CurrentBlock.Type = BlockType.Expression;
|
||||
Context.CurrentBlock.CodeGenerator = new ExpressionCodeGenerator();
|
||||
SourceLocation start = CurrentLocation;
|
||||
Expected(VBSymbolType.LeftParenthesis);
|
||||
Span.CodeGenerator = SpanCodeGenerator.Null;
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
|
||||
Output(SpanKind.MetaCode);
|
||||
|
||||
Span.CodeGenerator = new ExpressionCodeGenerator();
|
||||
using (PushSpanConfig(span => span.CodeGenerator = new ExpressionCodeGenerator()))
|
||||
{
|
||||
if (!Balance(BalancingModes.NoErrorOnFailure |
|
||||
BalancingModes.BacktrackOnFailure |
|
||||
BalancingModes.AllowCommentsAndTemplates,
|
||||
VBSymbolType.LeftParenthesis,
|
||||
VBSymbolType.RightParenthesis,
|
||||
start))
|
||||
{
|
||||
Context.OnError(start,
|
||||
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF,
|
||||
RazorResources.BlockName_ExplicitExpression,
|
||||
VBSymbol.GetSample(VBSymbolType.RightParenthesis),
|
||||
VBSymbol.GetSample(VBSymbolType.LeftParenthesis));
|
||||
AcceptUntil(VBSymbolType.NewLine);
|
||||
AddMarkerSymbolIfNecessary();
|
||||
Output(SpanKind.Code);
|
||||
PutCurrentBack();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddMarkerSymbolIfNecessary();
|
||||
Output(SpanKind.Code);
|
||||
Expected(VBSymbolType.RightParenthesis);
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
|
||||
Span.CodeGenerator = SpanCodeGenerator.Null;
|
||||
Output(SpanKind.MetaCode);
|
||||
PutCurrentBack();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ImplicitExpression()
|
||||
{
|
||||
Context.CurrentBlock.Type = BlockType.Expression;
|
||||
Context.CurrentBlock.CodeGenerator = new ExpressionCodeGenerator();
|
||||
using (PushSpanConfig(ImplictExpressionSpanConfig))
|
||||
{
|
||||
Expected(VBSymbolType.Identifier, VBSymbolType.Keyword);
|
||||
Span.CodeGenerator = new ExpressionCodeGenerator();
|
||||
while (!EndOfFile)
|
||||
{
|
||||
switch (CurrentSymbol.Type)
|
||||
{
|
||||
case VBSymbolType.LeftParenthesis:
|
||||
SourceLocation start = CurrentLocation;
|
||||
AcceptAndMoveNext();
|
||||
|
||||
Action<SpanBuilder> oldConfig = SpanConfig;
|
||||
using (PushSpanConfig())
|
||||
{
|
||||
ConfigureSpan(span =>
|
||||
{
|
||||
oldConfig(span);
|
||||
span.EditHandler.AcceptedCharacters = AcceptedCharacters.Any;
|
||||
});
|
||||
Balance(BalancingModes.AllowCommentsAndTemplates,
|
||||
VBSymbolType.LeftParenthesis,
|
||||
VBSymbolType.RightParenthesis,
|
||||
start);
|
||||
}
|
||||
if (Optional(VBSymbolType.RightParenthesis))
|
||||
{
|
||||
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.NonWhiteSpace;
|
||||
}
|
||||
break;
|
||||
case VBSymbolType.Dot:
|
||||
VBSymbol dot = CurrentSymbol;
|
||||
NextToken();
|
||||
if (At(VBSymbolType.Identifier) || At(VBSymbolType.Keyword))
|
||||
{
|
||||
Accept(dot);
|
||||
AcceptAndMoveNext();
|
||||
}
|
||||
else if (At(VBSymbolType.Transition))
|
||||
{
|
||||
VBSymbol at = CurrentSymbol;
|
||||
NextToken();
|
||||
if (At(VBSymbolType.Identifier) || At(VBSymbolType.Keyword))
|
||||
{
|
||||
Accept(dot);
|
||||
Accept(at);
|
||||
AcceptAndMoveNext();
|
||||
}
|
||||
else
|
||||
{
|
||||
PutBack(at);
|
||||
PutBack(dot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PutCurrentBack();
|
||||
if (IsNested)
|
||||
{
|
||||
Accept(dot);
|
||||
}
|
||||
else
|
||||
{
|
||||
PutBack(dot);
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PutCurrentBack();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void MapKeyword(VBKeyword keyword, Func<bool> action)
|
||||
{
|
||||
_keywordHandlers[keyword] = action;
|
||||
Keywords.Add(keyword.ToString());
|
||||
}
|
||||
|
||||
protected void MapDirective(string directive, Func<bool> action)
|
||||
{
|
||||
_directiveHandlers[directive] = action;
|
||||
Keywords.Add(directive);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "This only occurs in Release builds, where this method is empty by design")]
|
||||
[Conditional("DEBUG")]
|
||||
protected void Assert(VBKeyword keyword)
|
||||
{
|
||||
Debug.Assert(CurrentSymbol.Type == VBSymbolType.Keyword && CurrentSymbol.Keyword == keyword);
|
||||
}
|
||||
|
||||
protected bool At(VBKeyword keyword)
|
||||
{
|
||||
return At(VBSymbolType.Keyword) && CurrentSymbol.Keyword == keyword;
|
||||
}
|
||||
|
||||
protected void OtherParserBlock()
|
||||
{
|
||||
OtherParserBlock(null, null);
|
||||
}
|
||||
|
||||
protected void OtherParserBlock(string startSequence, string endSequence)
|
||||
{
|
||||
using (PushSpanConfig())
|
||||
{
|
||||
if (Span.Symbols.Count > 0)
|
||||
{
|
||||
Output(SpanKind.Code);
|
||||
}
|
||||
|
||||
Context.SwitchActiveParser();
|
||||
|
||||
bool old = DirectParentIsCode;
|
||||
DirectParentIsCode = false;
|
||||
|
||||
Debug.Assert(ReferenceEquals(Context.ActiveParser, Context.MarkupParser));
|
||||
if (!String.IsNullOrEmpty(startSequence) || !String.IsNullOrEmpty(endSequence))
|
||||
{
|
||||
Context.MarkupParser.ParseSection(Tuple.Create(startSequence, endSequence), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.MarkupParser.ParseBlock();
|
||||
}
|
||||
|
||||
DirectParentIsCode = old;
|
||||
|
||||
Context.SwitchActiveParser();
|
||||
EnsureCurrent();
|
||||
}
|
||||
Initialize(Span);
|
||||
}
|
||||
|
||||
protected void HandleTransition(VBSymbol lastWhiteSpace)
|
||||
{
|
||||
if (At(VBSymbolType.RazorCommentTransition))
|
||||
{
|
||||
Accept(lastWhiteSpace);
|
||||
RazorComment();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check the next character
|
||||
VBSymbol transition = CurrentSymbol;
|
||||
NextToken();
|
||||
if (At(VBSymbolType.LessThan) || At(VBSymbolType.Colon))
|
||||
{
|
||||
// Put the transition back
|
||||
PutCurrentBack();
|
||||
PutBack(transition);
|
||||
|
||||
// If we're in design-time mode, accept the whitespace, otherwise put it back
|
||||
if (Context.DesignTimeMode)
|
||||
{
|
||||
Accept(lastWhiteSpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
PutBack(lastWhiteSpace);
|
||||
}
|
||||
|
||||
// Switch to markup
|
||||
OtherParserBlock();
|
||||
}
|
||||
else if (At(VBSymbolType.Transition))
|
||||
{
|
||||
if (Context.IsWithin(BlockType.Template))
|
||||
{
|
||||
Context.OnError(transition.Start, RazorResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested);
|
||||
}
|
||||
Accept(lastWhiteSpace);
|
||||
VBSymbol transition2 = CurrentSymbol;
|
||||
NextToken();
|
||||
if (At(VBSymbolType.LessThan) || At(VBSymbolType.Colon))
|
||||
{
|
||||
PutCurrentBack();
|
||||
PutBack(transition2);
|
||||
PutBack(transition);
|
||||
Output(SpanKind.Code);
|
||||
|
||||
// Start a template block and switch to Markup
|
||||
using (Context.StartBlock(BlockType.Template))
|
||||
{
|
||||
Context.CurrentBlock.CodeGenerator = new TemplateBlockCodeGenerator();
|
||||
OtherParserBlock();
|
||||
Initialize(Span);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Accept(transition);
|
||||
Accept(transition2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Accept(lastWhiteSpace);
|
||||
|
||||
PutCurrentBack();
|
||||
PutBack(transition);
|
||||
|
||||
bool old = IsNested;
|
||||
IsNested = true;
|
||||
NestedBlock();
|
||||
IsNested = old;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OutputSpanBeforeRazorComment()
|
||||
{
|
||||
Output(SpanKind.Code);
|
||||
}
|
||||
|
||||
protected bool ReservedWord()
|
||||
{
|
||||
Context.CurrentBlock.Type = BlockType.Directive;
|
||||
Context.OnError(CurrentLocation, RazorResources.ParseError_ReservedWord, CurrentSymbol.Content);
|
||||
Span.CodeGenerator = SpanCodeGenerator.Null;
|
||||
AcceptAndMoveNext();
|
||||
Output(SpanKind.MetaCode, AcceptedCharacters.None);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void NestedBlock()
|
||||
{
|
||||
using (PushSpanConfig())
|
||||
{
|
||||
Output(SpanKind.Code);
|
||||
|
||||
bool old = DirectParentIsCode;
|
||||
DirectParentIsCode = true;
|
||||
|
||||
ParseBlock();
|
||||
|
||||
DirectParentIsCode = old;
|
||||
}
|
||||
Initialize(Span);
|
||||
}
|
||||
|
||||
protected bool Required(VBSymbolType expected, string errorBase)
|
||||
{
|
||||
if (!Optional(expected))
|
||||
{
|
||||
Context.OnError(CurrentLocation, errorBase, GetCurrentSymbolDisplay());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool Optional(VBKeyword keyword)
|
||||
{
|
||||
if (At(keyword))
|
||||
{
|
||||
AcceptAndMoveNext();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void AcceptVBSpaces()
|
||||
{
|
||||
Accept(ReadVBSpacesLazy());
|
||||
}
|
||||
|
||||
protected IEnumerable<VBSymbol> ReadVBSpaces()
|
||||
{
|
||||
return ReadVBSpacesLazy().ToList();
|
||||
}
|
||||
|
||||
public bool IsDirectiveDefined(string directive)
|
||||
{
|
||||
return _directiveHandlers.ContainsKey(directive);
|
||||
}
|
||||
|
||||
private IEnumerable<VBSymbol> ReadVBSpacesLazy()
|
||||
{
|
||||
foreach (var symbol in ReadWhileLazy(sym => sym.Type == VBSymbolType.WhiteSpace))
|
||||
{
|
||||
yield return symbol;
|
||||
}
|
||||
while (At(VBSymbolType.LineContinuation))
|
||||
{
|
||||
int bookmark = CurrentLocation.AbsoluteIndex;
|
||||
VBSymbol under = CurrentSymbol;
|
||||
NextToken();
|
||||
if (At(VBSymbolType.NewLine))
|
||||
{
|
||||
yield return under;
|
||||
yield return CurrentSymbol;
|
||||
NextToken();
|
||||
foreach (var symbol in ReadVBSpaces())
|
||||
{
|
||||
yield return symbol;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.Source.Position = bookmark;
|
||||
NextToken();
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.AspNet.Razor.Tokenizer;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Parser
|
||||
{
|
||||
public class VBLanguageCharacteristics : LanguageCharacteristics<VBTokenizer, VBSymbol, VBSymbolType>
|
||||
{
|
||||
private static readonly VBLanguageCharacteristics _instance = new VBLanguageCharacteristics();
|
||||
|
||||
private VBLanguageCharacteristics()
|
||||
{
|
||||
}
|
||||
|
||||
public static VBLanguageCharacteristics Instance
|
||||
{
|
||||
get { return _instance; }
|
||||
}
|
||||
|
||||
public override VBTokenizer CreateTokenizer(ITextDocument source)
|
||||
{
|
||||
return new VBTokenizer(source);
|
||||
}
|
||||
|
||||
public override string GetSample(VBSymbolType type)
|
||||
{
|
||||
return VBSymbol.GetSample(type);
|
||||
}
|
||||
|
||||
public override VBSymbolType FlipBracket(VBSymbolType bracket)
|
||||
{
|
||||
switch (bracket)
|
||||
{
|
||||
case VBSymbolType.LeftBrace:
|
||||
return VBSymbolType.RightBrace;
|
||||
case VBSymbolType.LeftBracket:
|
||||
return VBSymbolType.RightBracket;
|
||||
case VBSymbolType.LeftParenthesis:
|
||||
return VBSymbolType.RightParenthesis;
|
||||
case VBSymbolType.RightBrace:
|
||||
return VBSymbolType.LeftBrace;
|
||||
case VBSymbolType.RightBracket:
|
||||
return VBSymbolType.LeftBracket;
|
||||
case VBSymbolType.RightParenthesis:
|
||||
return VBSymbolType.LeftParenthesis;
|
||||
default:
|
||||
return VBSymbolType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public override VBSymbol CreateMarkerSymbol(SourceLocation location)
|
||||
{
|
||||
return new VBSymbol(location, String.Empty, VBSymbolType.Unknown);
|
||||
}
|
||||
|
||||
public override VBSymbolType GetKnownSymbolType(KnownSymbolType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case KnownSymbolType.CommentStart:
|
||||
return VBSymbolType.RazorCommentTransition;
|
||||
case KnownSymbolType.CommentStar:
|
||||
return VBSymbolType.RazorCommentStar;
|
||||
case KnownSymbolType.CommentBody:
|
||||
return VBSymbolType.RazorComment;
|
||||
case KnownSymbolType.Identifier:
|
||||
return VBSymbolType.Identifier;
|
||||
case KnownSymbolType.Keyword:
|
||||
return VBSymbolType.Keyword;
|
||||
case KnownSymbolType.NewLine:
|
||||
return VBSymbolType.NewLine;
|
||||
case KnownSymbolType.Transition:
|
||||
return VBSymbolType.Transition;
|
||||
case KnownSymbolType.WhiteSpace:
|
||||
return VBSymbolType.WhiteSpace;
|
||||
default:
|
||||
return VBSymbolType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
protected override VBSymbol CreateSymbol(SourceLocation location, string content, VBSymbolType type, IEnumerable<RazorError> errors)
|
||||
{
|
||||
return new VBSymbol(location, content, type, errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,8 +14,7 @@ namespace Microsoft.AspNet.Razor
|
|||
{
|
||||
private static IDictionary<string, RazorCodeLanguage> _services = new Dictionary<string, RazorCodeLanguage>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ "cshtml", new CSharpRazorCodeLanguage() },
|
||||
{ "vbhtml", new VBRazorCodeLanguage() }
|
||||
{ "cshtml", new CSharpRazorCodeLanguage() }
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -30,11 +29,12 @@ namespace Microsoft.AspNet.Razor
|
|||
/// The name of the language (for use in System.Web.Compilation.BuildProvider.GetDefaultCompilerTypeForLanguage)
|
||||
/// </summary>
|
||||
public abstract string LanguageName { get; }
|
||||
|
||||
#if NET45
|
||||
/// <summary>
|
||||
/// The type of the CodeDOM provider for this language
|
||||
/// </summary>
|
||||
public abstract Type CodeDomProviderType { get; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the RazorCodeLanguage registered for the specified file extension
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Razor
|
|||
{
|
||||
get { return _outputDebuggingEnabled; }
|
||||
}
|
||||
|
||||
#if NET45
|
||||
[SuppressMessage("Microsoft.Security", "CA2141:TransparentMethodsMustNotSatisfyLinkDemandsFxCopRule", Justification = "This is debug only")]
|
||||
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "This is debug only")]
|
||||
[SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.IO.StringWriter.#ctor", Justification = "This is debug only")]
|
||||
|
|
@ -69,7 +69,7 @@ namespace Microsoft.AspNet.Razor
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endif
|
||||
internal static void WriteDebugTree(string sourceFile, Block document, PartialParseResult result, TextChange change, RazorEditorParser parser, bool treeStructureChanged)
|
||||
{
|
||||
if (!OutputDebuggingEnabled)
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ namespace Microsoft.AspNet.Razor
|
|||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
|
||||
public sealed class RazorDirectiveAttribute : Attribute
|
||||
{
|
||||
private readonly object _typeId = new object();
|
||||
|
||||
public RazorDirectiveAttribute(string name, string value)
|
||||
{
|
||||
if (String.IsNullOrEmpty(name))
|
||||
|
|
@ -24,11 +22,6 @@ namespace Microsoft.AspNet.Razor
|
|||
Value = value;
|
||||
}
|
||||
|
||||
public override object TypeId
|
||||
{
|
||||
get { return _typeId; }
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public string Value { get; private set; }
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ namespace Microsoft.AspNet.Razor
|
|||
}
|
||||
return incomingCodeGenerator;
|
||||
}
|
||||
|
||||
#if NET45
|
||||
/// <summary>
|
||||
/// Gets the important CodeDOM nodes generated by the code generator and has a chance to add to them.
|
||||
/// </summary>
|
||||
|
|
@ -236,5 +236,6 @@ namespace Microsoft.AspNet.Razor
|
|||
throw new ArgumentNullException("executeMethod");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,15 +166,18 @@ namespace Microsoft.AspNet.Razor
|
|||
RazorCodeGenerator generator = CreateCodeGenerator(className, rootNamespace, sourceFileName);
|
||||
generator.DesignTimeMode = Host.DesignTimeMode;
|
||||
generator.Visit(results);
|
||||
|
||||
#if NET45
|
||||
// Post process code
|
||||
Host.PostProcessGeneratedCode(generator.Context);
|
||||
#endif
|
||||
|
||||
// Extract design-time mappings
|
||||
IDictionary<int, GeneratedCodeMapping> designTimeLineMappings = null;
|
||||
if (Host.DesignTimeMode)
|
||||
{
|
||||
#if NET45
|
||||
designTimeLineMappings = generator.Context.CodeMappings;
|
||||
#endif
|
||||
}
|
||||
|
||||
var builder = new CSharpCodeBuilder(generator.Context.CodeTreeBuilder.CodeTree, rootNamespace, Host, sourceFileName);
|
||||
|
|
@ -183,7 +186,9 @@ namespace Microsoft.AspNet.Razor
|
|||
// Collect results and return
|
||||
return new GeneratorResults(results, builderResult)
|
||||
{
|
||||
#if NET45
|
||||
CCU = generator.Context.CompileUnit,
|
||||
#endif
|
||||
CT = generator.Context.CodeTreeBuilder.CodeTree
|
||||
};
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -177,10 +177,6 @@
|
|||
// OK here to use types from System.Drawing in the page.
|
||||
}</value>
|
||||
</data>
|
||||
<data name="ParseError_Sections_Cannot_Be_Nested" xml:space="preserve">
|
||||
<value>Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed.</value>
|
||||
<comment>{0} is one of SectionExample_VB or SectionExample_CS based on the language.</comment>
|
||||
</data>
|
||||
<data name="ParseError_SingleLine_ControlFlowStatements_Not_Allowed" xml:space="preserve">
|
||||
<value>Expected a "{0}" but found a "{1}". Block statements must be enclosed in "{{" and "}}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed:
|
||||
|
||||
|
|
@ -210,10 +206,6 @@ Instead, wrap the contents of the block in "{{}}":
|
|||
<data name="ParseError_Unterminated_String_Literal" xml:space="preserve">
|
||||
<value>Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines.</value>
|
||||
</data>
|
||||
<data name="ParseError_InvalidOptionValue" xml:space="preserve">
|
||||
<value>"{1}" is not a valid value for the "{0}" option. The "Option {0}" statement must be followed by either "On" or "Off". </value>
|
||||
<comment>{0} is either Strict or Explicit and represent VB's "Option Strict" and "Option Explicit" keywords</comment>
|
||||
</data>
|
||||
<data name="ParseError_UnknownOption" xml:space="preserve">
|
||||
<value>Unknown option: "{0}".</value>
|
||||
</data>
|
||||
|
|
@ -251,15 +243,9 @@ Instead, wrap the contents of the block in "{{}}":
|
|||
<data name="ErrorComponent_Whitespace" xml:space="preserve">
|
||||
<value>space or line break</value>
|
||||
</data>
|
||||
<data name="ParseError_Unexpected_Character_At_Start_Of_CodeBlock_VB" xml:space="preserve">
|
||||
<value>"{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, and "(" are valid.</value>
|
||||
</data>
|
||||
<data name="ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock" xml:space="preserve">
|
||||
<value>End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@"</value>
|
||||
</data>
|
||||
<data name="ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_VB" xml:space="preserve">
|
||||
<value>A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, and "(" are valid at the start of a code block and they must occur immediately following "@" with no space in between.</value>
|
||||
</data>
|
||||
<data name="Structure_Member_CannotBeNull" xml:space="preserve">
|
||||
<value>The {0} property of the {1} structure cannot be null.</value>
|
||||
</data>
|
||||
|
|
@ -347,43 +333,6 @@ Instead, wrap the contents of the block in "{{}}":
|
|||
<data name="ErrorComponent_Newline" xml:space="preserve">
|
||||
<value>line break</value>
|
||||
</data>
|
||||
<data name="SectionExample_VB" xml:space="preserve">
|
||||
<value>@Section Header ... End Section</value>
|
||||
<comment>In VBHTML, the @Section keyword is case-insensitive (as with all VB keywords), but the standard practice is to Title Case it</comment>
|
||||
</data>
|
||||
<data name="VBSymbol_CharacterLiteral" xml:space="preserve">
|
||||
<value><<character literal>></value>
|
||||
</data>
|
||||
<data name="VBSymbol_Comment" xml:space="preserve">
|
||||
<value><<comment>></value>
|
||||
</data>
|
||||
<data name="VBSymbol_DateLiteral" xml:space="preserve">
|
||||
<value><<date literal>></value>
|
||||
</data>
|
||||
<data name="VBSymbol_FloatingPointLiteral" xml:space="preserve">
|
||||
<value><<floating point literal>></value>
|
||||
</data>
|
||||
<data name="VBSymbol_Identifier" xml:space="preserve">
|
||||
<value><<identifier>></value>
|
||||
</data>
|
||||
<data name="VBSymbol_IntegerLiteral" xml:space="preserve">
|
||||
<value><<integer literal>></value>
|
||||
</data>
|
||||
<data name="VBSymbol_Keyword" xml:space="preserve">
|
||||
<value><<keyword>></value>
|
||||
</data>
|
||||
<data name="VBSymbol_NewLine" xml:space="preserve">
|
||||
<value><<newline sequence>></value>
|
||||
</data>
|
||||
<data name="VBSymbol_RazorComment" xml:space="preserve">
|
||||
<value><<razor comment>></value>
|
||||
</data>
|
||||
<data name="VBSymbol_StringLiteral" xml:space="preserve">
|
||||
<value><<string literal>></value>
|
||||
</data>
|
||||
<data name="VBSymbol_WhiteSpace" xml:space="preserve">
|
||||
<value><<white space>></value>
|
||||
</data>
|
||||
<data name="HtmlSymbol_NewLine" xml:space="preserve">
|
||||
<value><<newline sequence>></value>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ using System.Globalization;
|
|||
|
||||
namespace Microsoft.AspNet.Razor.Text
|
||||
{
|
||||
#if NET45
|
||||
[Serializable]
|
||||
#endif
|
||||
public struct SourceLocation : IEquatable<SourceLocation>, IComparable<SourceLocation>
|
||||
{
|
||||
public static readonly SourceLocation Undefined = CreateUndefined();
|
||||
|
|
|
|||
|
|
@ -11,8 +11,13 @@ namespace Microsoft.AspNet.Razor.Tokenizer
|
|||
public static bool IsIdentifierStart(char character)
|
||||
{
|
||||
return Char.IsLetter(character) ||
|
||||
character == '_' ||
|
||||
Char.GetUnicodeCategory(character) == UnicodeCategory.LetterNumber; // Ln
|
||||
character == '_'
|
||||
#if NET45
|
||||
|| Char.GetUnicodeCategory(character) == UnicodeCategory.LetterNumber
|
||||
#else
|
||||
|| Char.IsLetterOrDigit(character)
|
||||
#endif
|
||||
; // Ln
|
||||
}
|
||||
|
||||
public static bool IsIdentifierPart(char character)
|
||||
|
|
@ -34,11 +39,16 @@ namespace Microsoft.AspNet.Razor.Tokenizer
|
|||
|
||||
private static bool IsIdentifierPartByUnicodeCategory(char character)
|
||||
{
|
||||
#if NET45
|
||||
UnicodeCategory category = Char.GetUnicodeCategory(character);
|
||||
|
||||
return category == UnicodeCategory.NonSpacingMark || // Mn
|
||||
category == UnicodeCategory.SpacingCombiningMark || // Mc
|
||||
category == UnicodeCategory.ConnectorPunctuation || // Pc
|
||||
category == UnicodeCategory.Format; // Cf
|
||||
#else
|
||||
return false; // TODO: Make the above work
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,33 +127,35 @@ namespace Microsoft.AspNet.Razor.Tokenizer
|
|||
TakeCurrent();
|
||||
switch (sym)
|
||||
{
|
||||
case '<':
|
||||
return EndSymbol(HtmlSymbolType.OpenAngle);
|
||||
case '!':
|
||||
return EndSymbol(HtmlSymbolType.Bang);
|
||||
case '/':
|
||||
return EndSymbol(HtmlSymbolType.Solidus);
|
||||
case '?':
|
||||
return EndSymbol(HtmlSymbolType.QuestionMark);
|
||||
case '[':
|
||||
return EndSymbol(HtmlSymbolType.LeftBracket);
|
||||
case '>':
|
||||
return EndSymbol(HtmlSymbolType.CloseAngle);
|
||||
case ']':
|
||||
return EndSymbol(HtmlSymbolType.RightBracket);
|
||||
case '=':
|
||||
return EndSymbol(HtmlSymbolType.Equals);
|
||||
case '"':
|
||||
return EndSymbol(HtmlSymbolType.DoubleQuote);
|
||||
case '\'':
|
||||
return EndSymbol(HtmlSymbolType.SingleQuote);
|
||||
case '-':
|
||||
Debug.Assert(CurrentCharacter == '-');
|
||||
TakeCurrent();
|
||||
return EndSymbol(HtmlSymbolType.DoubleHyphen);
|
||||
default:
|
||||
case '<':
|
||||
return EndSymbol(HtmlSymbolType.OpenAngle);
|
||||
case '!':
|
||||
return EndSymbol(HtmlSymbolType.Bang);
|
||||
case '/':
|
||||
return EndSymbol(HtmlSymbolType.Solidus);
|
||||
case '?':
|
||||
return EndSymbol(HtmlSymbolType.QuestionMark);
|
||||
case '[':
|
||||
return EndSymbol(HtmlSymbolType.LeftBracket);
|
||||
case '>':
|
||||
return EndSymbol(HtmlSymbolType.CloseAngle);
|
||||
case ']':
|
||||
return EndSymbol(HtmlSymbolType.RightBracket);
|
||||
case '=':
|
||||
return EndSymbol(HtmlSymbolType.Equals);
|
||||
case '"':
|
||||
return EndSymbol(HtmlSymbolType.DoubleQuote);
|
||||
case '\'':
|
||||
return EndSymbol(HtmlSymbolType.SingleQuote);
|
||||
case '-':
|
||||
Debug.Assert(CurrentCharacter == '-');
|
||||
TakeCurrent();
|
||||
return EndSymbol(HtmlSymbolType.DoubleHyphen);
|
||||
default:
|
||||
#if NET45
|
||||
Debug.Fail("Unexpected symbol!");
|
||||
return EndSymbol(HtmlSymbolType.Unknown);
|
||||
#endif
|
||||
return EndSymbol(HtmlSymbolType.Unknown);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
// Centralized all the supressions for the CSharpSymbolType and VBSymbolType enum members here for clarity. They are
|
||||
// not in the CodeAnalysisDictionary because they are special case exclusions
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Foreach", Scope = "member", Target = "Microsoft.AspNet.Razor.Tokenizer.Symbols.CSharpKeyword.#Foreach", Justification = Justifications.SymbolTypeNames)]
|
||||
|
|
@ -14,11 +11,6 @@ using System.Diagnostics.CodeAnalysis;
|
|||
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Uint", Scope = "member", Target = "Microsoft.AspNet.Razor.Tokenizer.Symbols.CSharpKeyword.#Uint", Justification = Justifications.SymbolTypeNames)]
|
||||
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ulong", Scope = "member", Target = "Microsoft.AspNet.Razor.Tokenizer.Symbols.CSharpKeyword.#Ulong", Justification = Justifications.SymbolTypeNames)]
|
||||
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ushort", Scope = "member", Target = "Microsoft.AspNet.Razor.Tokenizer.Symbols.CSharpKeyword.#Ushort", Justification = Justifications.SymbolTypeNames)]
|
||||
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Val", Scope = "member", Target = "Microsoft.AspNet.Razor.Tokenizer.Symbols.VBKeyword.#ByVal", Justification = Justifications.SymbolTypeNames)]
|
||||
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sng", Scope = "member", Target = "Microsoft.AspNet.Razor.Tokenizer.Symbols.VBKeyword.#CSng", Justification = Justifications.SymbolTypeNames)]
|
||||
[assembly: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "ReDim", Scope = "member", Target = "Microsoft.AspNet.Razor.Tokenizer.Symbols.VBKeyword.#ReDim", Justification = Justifications.SymbolTypeNames)]
|
||||
[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Re", Scope = "member", Target = "Microsoft.AspNet.Razor.Tokenizer.Symbols.VBKeyword.#ReDim", Justification = Justifications.SymbolTypeNames)]
|
||||
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Str", Scope = "member", Target = "Microsoft.AspNet.Razor.Tokenizer.Symbols.VBKeyword.#CStr", Justification = Justifications.SymbolTypeNames)]
|
||||
|
||||
internal static partial class Justifications
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,168 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
||||
{
|
||||
public enum VBKeyword
|
||||
{
|
||||
AddHandler,
|
||||
AndAlso,
|
||||
Byte,
|
||||
Catch,
|
||||
CDate,
|
||||
CInt,
|
||||
Const,
|
||||
CSng,
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lng", Justification = "This is a VB Keyword. Note: Excluded here because it is a specific case")]
|
||||
CULng,
|
||||
Declare,
|
||||
DirectCast,
|
||||
Else,
|
||||
Enum,
|
||||
Exit,
|
||||
Friend,
|
||||
GetXmlNamespace,
|
||||
Handles,
|
||||
In,
|
||||
Is,
|
||||
Like,
|
||||
Mod,
|
||||
MyBase,
|
||||
New,
|
||||
AddressOf,
|
||||
As,
|
||||
ByVal,
|
||||
CBool,
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dbl", Justification = "This is a VB Keyword. Note: Excluded here because it is a specific case")]
|
||||
CDbl,
|
||||
Class,
|
||||
Continue,
|
||||
CStr,
|
||||
CUShort,
|
||||
Default,
|
||||
Do,
|
||||
ElseIf,
|
||||
Erase,
|
||||
False,
|
||||
Function,
|
||||
Global,
|
||||
If,
|
||||
Inherits,
|
||||
IsNot,
|
||||
Long,
|
||||
Module,
|
||||
MyClass,
|
||||
Next,
|
||||
Alias,
|
||||
Boolean,
|
||||
Call,
|
||||
CByte,
|
||||
CDec,
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lng", Justification = "This is a VB Keyword. Note: Excluded here because it is a specific case")]
|
||||
CLng,
|
||||
CSByte,
|
||||
CType,
|
||||
Date,
|
||||
Delegate,
|
||||
Double,
|
||||
End,
|
||||
Error,
|
||||
Finally,
|
||||
Get,
|
||||
GoSub,
|
||||
Implements,
|
||||
Integer,
|
||||
Let,
|
||||
Loop,
|
||||
MustInherit,
|
||||
Namespace,
|
||||
Not,
|
||||
And,
|
||||
ByRef,
|
||||
Case,
|
||||
CChar,
|
||||
Char,
|
||||
CObj,
|
||||
CShort,
|
||||
CUInt,
|
||||
Decimal,
|
||||
Dim,
|
||||
Each,
|
||||
EndIf,
|
||||
Event,
|
||||
For,
|
||||
GetType,
|
||||
GoTo,
|
||||
Imports,
|
||||
Interface,
|
||||
Lib,
|
||||
Me,
|
||||
MustOverride,
|
||||
Narrowing,
|
||||
Nothing,
|
||||
NotInheritable,
|
||||
On,
|
||||
Or,
|
||||
Overrides,
|
||||
Property,
|
||||
ReadOnly,
|
||||
Resume,
|
||||
Set,
|
||||
Single,
|
||||
String,
|
||||
Then,
|
||||
Try,
|
||||
ULong,
|
||||
Wend,
|
||||
With,
|
||||
NotOverridable,
|
||||
Operator,
|
||||
OrElse,
|
||||
ParamArray,
|
||||
Protected,
|
||||
ReDim,
|
||||
Return,
|
||||
Shadows,
|
||||
Static,
|
||||
Structure,
|
||||
Throw,
|
||||
TryCast,
|
||||
UShort,
|
||||
When,
|
||||
WithEvents,
|
||||
Object,
|
||||
Option,
|
||||
Overloads,
|
||||
Partial,
|
||||
Public,
|
||||
Rem,
|
||||
SByte,
|
||||
Shared,
|
||||
Step,
|
||||
Sub,
|
||||
To,
|
||||
TypeOf,
|
||||
Using,
|
||||
While,
|
||||
WriteOnly,
|
||||
Of,
|
||||
Optional,
|
||||
Overridable,
|
||||
Private,
|
||||
RaiseEvent,
|
||||
RemoveHandler,
|
||||
Select,
|
||||
Short,
|
||||
Stop,
|
||||
SyncLock,
|
||||
True,
|
||||
UInteger,
|
||||
Variant,
|
||||
Widening,
|
||||
Xor
|
||||
}
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
||||
{
|
||||
public class VBSymbol : SymbolBase<VBSymbolType>
|
||||
{
|
||||
// Helper constructor
|
||||
private static Dictionary<VBSymbolType, string> _symbolSamples = new Dictionary<VBSymbolType, string>()
|
||||
{
|
||||
{ VBSymbolType.LineContinuation, "_" },
|
||||
{ VBSymbolType.LeftParenthesis, "(" },
|
||||
{ VBSymbolType.RightParenthesis, ")" },
|
||||
{ VBSymbolType.LeftBracket, "[" },
|
||||
{ VBSymbolType.RightBracket, "]" },
|
||||
{ VBSymbolType.LeftBrace, "{" },
|
||||
{ VBSymbolType.RightBrace, "}" },
|
||||
{ VBSymbolType.Bang, "!" },
|
||||
{ VBSymbolType.Hash, "#" },
|
||||
{ VBSymbolType.Comma, "," },
|
||||
{ VBSymbolType.Dot, "." },
|
||||
{ VBSymbolType.Colon, ":" },
|
||||
{ VBSymbolType.QuestionMark, "?" },
|
||||
{ VBSymbolType.Concatenation, "&" },
|
||||
{ VBSymbolType.Multiply, "*" },
|
||||
{ VBSymbolType.Add, "+" },
|
||||
{ VBSymbolType.Subtract, "-" },
|
||||
{ VBSymbolType.Divide, "/" },
|
||||
{ VBSymbolType.IntegerDivide, "\\" },
|
||||
{ VBSymbolType.Exponentiation, "^" },
|
||||
{ VBSymbolType.Equal, "=" },
|
||||
{ VBSymbolType.LessThan, "<" },
|
||||
{ VBSymbolType.GreaterThan, ">" },
|
||||
{ VBSymbolType.Dollar, "$" },
|
||||
{ VBSymbolType.Transition, "@" },
|
||||
{ VBSymbolType.RazorCommentTransition, "@" },
|
||||
{ VBSymbolType.RazorCommentStar, "*" }
|
||||
};
|
||||
|
||||
public VBSymbol(int offset, int line, int column, string content, VBSymbolType type)
|
||||
: this(new SourceLocation(offset, line, column), content, type, Enumerable.Empty<RazorError>())
|
||||
{
|
||||
}
|
||||
|
||||
public VBSymbol(SourceLocation start, string content, VBSymbolType type)
|
||||
: this(start, content, type, Enumerable.Empty<RazorError>())
|
||||
{
|
||||
}
|
||||
|
||||
public VBSymbol(int offset, int line, int column, string content, VBSymbolType type, IEnumerable<RazorError> errors)
|
||||
: base(new SourceLocation(offset, line, column), content, type, errors)
|
||||
{
|
||||
}
|
||||
|
||||
public VBSymbol(SourceLocation start, string content, VBSymbolType type, IEnumerable<RazorError> errors)
|
||||
: base(start, content, type, errors)
|
||||
{
|
||||
}
|
||||
|
||||
public VBKeyword? Keyword { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
VBSymbol other = obj as VBSymbol;
|
||||
return base.Equals(obj) && other.Keyword == Keyword;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode() ^ Keyword.GetHashCode();
|
||||
}
|
||||
|
||||
public static string GetSample(VBSymbolType type)
|
||||
{
|
||||
string sample;
|
||||
if (!_symbolSamples.TryGetValue(type, out sample))
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VBSymbolType.WhiteSpace:
|
||||
return RazorResources.VBSymbol_WhiteSpace;
|
||||
case VBSymbolType.NewLine:
|
||||
return RazorResources.VBSymbol_NewLine;
|
||||
case VBSymbolType.Comment:
|
||||
return RazorResources.VBSymbol_Comment;
|
||||
case VBSymbolType.Identifier:
|
||||
return RazorResources.VBSymbol_Identifier;
|
||||
case VBSymbolType.Keyword:
|
||||
return RazorResources.VBSymbol_Keyword;
|
||||
case VBSymbolType.IntegerLiteral:
|
||||
return RazorResources.VBSymbol_IntegerLiteral;
|
||||
case VBSymbolType.FloatingPointLiteral:
|
||||
return RazorResources.VBSymbol_FloatingPointLiteral;
|
||||
case VBSymbolType.StringLiteral:
|
||||
return RazorResources.VBSymbol_StringLiteral;
|
||||
case VBSymbolType.CharacterLiteral:
|
||||
return RazorResources.VBSymbol_CharacterLiteral;
|
||||
case VBSymbolType.DateLiteral:
|
||||
return RazorResources.VBSymbol_DateLiteral;
|
||||
case VBSymbolType.RazorComment:
|
||||
return RazorResources.VBSymbol_RazorComment;
|
||||
default:
|
||||
return RazorResources.Symbol_Unknown;
|
||||
}
|
||||
}
|
||||
return sample;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
||||
{
|
||||
public enum VBSymbolType
|
||||
{
|
||||
Unknown,
|
||||
WhiteSpace,
|
||||
NewLine,
|
||||
LineContinuation,
|
||||
Comment,
|
||||
Identifier,
|
||||
Keyword,
|
||||
IntegerLiteral,
|
||||
FloatingPointLiteral,
|
||||
StringLiteral,
|
||||
CharacterLiteral,
|
||||
DateLiteral,
|
||||
LeftParenthesis,
|
||||
RightBrace,
|
||||
LeftBrace,
|
||||
RightParenthesis,
|
||||
Hash,
|
||||
Bang,
|
||||
Comma,
|
||||
Dot,
|
||||
Colon,
|
||||
Concatenation,
|
||||
QuestionMark,
|
||||
Subtract,
|
||||
Multiply,
|
||||
Add,
|
||||
Divide,
|
||||
IntegerDivide,
|
||||
Exponentiation,
|
||||
LessThan,
|
||||
GreaterThan,
|
||||
Equal,
|
||||
RightBracket,
|
||||
LeftBracket,
|
||||
Dollar,
|
||||
Transition,
|
||||
|
||||
RazorCommentTransition,
|
||||
RazorCommentStar,
|
||||
RazorComment
|
||||
}
|
||||
}
|
||||
|
|
@ -321,7 +321,9 @@ namespace Microsoft.AspNet.Razor.Tokenizer
|
|||
[Conditional("DEBUG")]
|
||||
internal void AssertCurrent(char current)
|
||||
{
|
||||
#if NET45
|
||||
Debug.Assert(CurrentCharacter == current, "CurrentCharacter Assumption violated", "Assumed that the current character would be {0}, but it is actually {1}", current, CurrentCharacter);
|
||||
#endif
|
||||
}
|
||||
|
||||
ISymbol ITokenizer.NextSymbol()
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer
|
||||
{
|
||||
public static class VBHelpers
|
||||
{
|
||||
public static bool IsSingleQuote(char character)
|
||||
{
|
||||
return character == '\'' || character == '‘' || character == '’';
|
||||
}
|
||||
|
||||
public static bool IsDoubleQuote(char character)
|
||||
{
|
||||
return character == '"' || character == '“' || character == '”';
|
||||
}
|
||||
|
||||
public static bool IsOctalDigit(char character)
|
||||
{
|
||||
return character >= '0' && character <= '7';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,177 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer
|
||||
{
|
||||
internal static class VBKeywordDetector
|
||||
{
|
||||
private static readonly Dictionary<string, VBKeyword> _keywords = new Dictionary<string, VBKeyword>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ "addhandler", VBKeyword.AddHandler },
|
||||
{ "andalso", VBKeyword.AndAlso },
|
||||
{ "byte", VBKeyword.Byte },
|
||||
{ "catch", VBKeyword.Catch },
|
||||
{ "cdate", VBKeyword.CDate },
|
||||
{ "cint", VBKeyword.CInt },
|
||||
{ "const", VBKeyword.Const },
|
||||
{ "csng", VBKeyword.CSng },
|
||||
{ "culng", VBKeyword.CULng },
|
||||
{ "declare", VBKeyword.Declare },
|
||||
{ "directcast", VBKeyword.DirectCast },
|
||||
{ "else", VBKeyword.Else },
|
||||
{ "enum", VBKeyword.Enum },
|
||||
{ "exit", VBKeyword.Exit },
|
||||
{ "friend", VBKeyword.Friend },
|
||||
{ "getxmlnamespace", VBKeyword.GetXmlNamespace },
|
||||
{ "handles", VBKeyword.Handles },
|
||||
{ "in", VBKeyword.In },
|
||||
{ "is", VBKeyword.Is },
|
||||
{ "like", VBKeyword.Like },
|
||||
{ "mod", VBKeyword.Mod },
|
||||
{ "mybase", VBKeyword.MyBase },
|
||||
{ "new", VBKeyword.New },
|
||||
{ "addressof", VBKeyword.AddressOf },
|
||||
{ "as", VBKeyword.As },
|
||||
{ "byval", VBKeyword.ByVal },
|
||||
{ "cbool", VBKeyword.CBool },
|
||||
{ "cdbl", VBKeyword.CDbl },
|
||||
{ "class", VBKeyword.Class },
|
||||
{ "continue", VBKeyword.Continue },
|
||||
{ "cstr", VBKeyword.CStr },
|
||||
{ "cushort", VBKeyword.CUShort },
|
||||
{ "default", VBKeyword.Default },
|
||||
{ "do", VBKeyword.Do },
|
||||
{ "elseif", VBKeyword.ElseIf },
|
||||
{ "erase", VBKeyword.Erase },
|
||||
{ "false", VBKeyword.False },
|
||||
{ "function", VBKeyword.Function },
|
||||
{ "global", VBKeyword.Global },
|
||||
{ "if", VBKeyword.If },
|
||||
{ "inherits", VBKeyword.Inherits },
|
||||
{ "isnot", VBKeyword.IsNot },
|
||||
{ "long", VBKeyword.Long },
|
||||
{ "module", VBKeyword.Module },
|
||||
{ "myclass", VBKeyword.MyClass },
|
||||
{ "next", VBKeyword.Next },
|
||||
{ "alias", VBKeyword.Alias },
|
||||
{ "boolean", VBKeyword.Boolean },
|
||||
{ "call", VBKeyword.Call },
|
||||
{ "cbyte", VBKeyword.CByte },
|
||||
{ "cdec", VBKeyword.CDec },
|
||||
{ "clng", VBKeyword.CLng },
|
||||
{ "csbyte", VBKeyword.CSByte },
|
||||
{ "ctype", VBKeyword.CType },
|
||||
{ "date", VBKeyword.Date },
|
||||
{ "delegate", VBKeyword.Delegate },
|
||||
{ "double", VBKeyword.Double },
|
||||
{ "end", VBKeyword.End },
|
||||
{ "error", VBKeyword.Error },
|
||||
{ "finally", VBKeyword.Finally },
|
||||
{ "get", VBKeyword.Get },
|
||||
{ "gosub", VBKeyword.GoSub },
|
||||
{ "implements", VBKeyword.Implements },
|
||||
{ "integer", VBKeyword.Integer },
|
||||
{ "let", VBKeyword.Let },
|
||||
{ "loop", VBKeyword.Loop },
|
||||
{ "mustinherit", VBKeyword.MustInherit },
|
||||
{ "namespace", VBKeyword.Namespace },
|
||||
{ "not", VBKeyword.Not },
|
||||
{ "and", VBKeyword.And },
|
||||
{ "byref", VBKeyword.ByRef },
|
||||
{ "case", VBKeyword.Case },
|
||||
{ "cchar", VBKeyword.CChar },
|
||||
{ "char", VBKeyword.Char },
|
||||
{ "cobj", VBKeyword.CObj },
|
||||
{ "cshort", VBKeyword.CShort },
|
||||
{ "cuint", VBKeyword.CUInt },
|
||||
{ "decimal", VBKeyword.Decimal },
|
||||
{ "dim", VBKeyword.Dim },
|
||||
{ "each", VBKeyword.Each },
|
||||
{ "endif", VBKeyword.EndIf },
|
||||
{ "event", VBKeyword.Event },
|
||||
{ "for", VBKeyword.For },
|
||||
{ "gettype", VBKeyword.GetType },
|
||||
{ "goto", VBKeyword.GoTo },
|
||||
{ "imports", VBKeyword.Imports },
|
||||
{ "interface", VBKeyword.Interface },
|
||||
{ "lib", VBKeyword.Lib },
|
||||
{ "me", VBKeyword.Me },
|
||||
{ "mustoverride", VBKeyword.MustOverride },
|
||||
{ "narrowing", VBKeyword.Narrowing },
|
||||
{ "nothing", VBKeyword.Nothing },
|
||||
{ "notinheritable", VBKeyword.NotInheritable },
|
||||
{ "on", VBKeyword.On },
|
||||
{ "or", VBKeyword.Or },
|
||||
{ "overrides", VBKeyword.Overrides },
|
||||
{ "property", VBKeyword.Property },
|
||||
{ "rem", VBKeyword.Rem },
|
||||
{ "readonly", VBKeyword.ReadOnly },
|
||||
{ "resume", VBKeyword.Resume },
|
||||
{ "set", VBKeyword.Set },
|
||||
{ "single", VBKeyword.Single },
|
||||
{ "string", VBKeyword.String },
|
||||
{ "then", VBKeyword.Then },
|
||||
{ "try", VBKeyword.Try },
|
||||
{ "ulong", VBKeyword.ULong },
|
||||
{ "wend", VBKeyword.Wend },
|
||||
{ "with", VBKeyword.With },
|
||||
{ "notoverridable", VBKeyword.NotOverridable },
|
||||
{ "operator", VBKeyword.Operator },
|
||||
{ "orelse", VBKeyword.OrElse },
|
||||
{ "paramarray", VBKeyword.ParamArray },
|
||||
{ "protected", VBKeyword.Protected },
|
||||
{ "redim", VBKeyword.ReDim },
|
||||
{ "return", VBKeyword.Return },
|
||||
{ "shadows", VBKeyword.Shadows },
|
||||
{ "static", VBKeyword.Static },
|
||||
{ "structure", VBKeyword.Structure },
|
||||
{ "throw", VBKeyword.Throw },
|
||||
{ "trycast", VBKeyword.TryCast },
|
||||
{ "ushort", VBKeyword.UShort },
|
||||
{ "when", VBKeyword.When },
|
||||
{ "withevents", VBKeyword.WithEvents },
|
||||
{ "object", VBKeyword.Object },
|
||||
{ "option", VBKeyword.Option },
|
||||
{ "overloads", VBKeyword.Overloads },
|
||||
{ "partial", VBKeyword.Partial },
|
||||
{ "public", VBKeyword.Public },
|
||||
{ "sbyte", VBKeyword.SByte },
|
||||
{ "shared", VBKeyword.Shared },
|
||||
{ "step", VBKeyword.Step },
|
||||
{ "sub", VBKeyword.Sub },
|
||||
{ "to", VBKeyword.To },
|
||||
{ "typeof", VBKeyword.TypeOf },
|
||||
{ "using", VBKeyword.Using },
|
||||
{ "while", VBKeyword.While },
|
||||
{ "writeonly", VBKeyword.WriteOnly },
|
||||
{ "of", VBKeyword.Of },
|
||||
{ "optional", VBKeyword.Optional },
|
||||
{ "overridable", VBKeyword.Overridable },
|
||||
{ "private", VBKeyword.Private },
|
||||
{ "raiseevent", VBKeyword.RaiseEvent },
|
||||
{ "removehandler", VBKeyword.RemoveHandler },
|
||||
{ "select", VBKeyword.Select },
|
||||
{ "short", VBKeyword.Short },
|
||||
{ "stop", VBKeyword.Stop },
|
||||
{ "synclock", VBKeyword.SyncLock },
|
||||
{ "true", VBKeyword.True },
|
||||
{ "uinteger", VBKeyword.UInteger },
|
||||
{ "variant", VBKeyword.Variant },
|
||||
{ "widening", VBKeyword.Widening },
|
||||
{ "xor", VBKeyword.Xor }
|
||||
};
|
||||
|
||||
public static VBKeyword? GetKeyword(string id)
|
||||
{
|
||||
VBKeyword type;
|
||||
if (!_keywords.TryGetValue(id, out type))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,384 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer
|
||||
{
|
||||
public class VBTokenizer : Tokenizer<VBSymbol, VBSymbolType>
|
||||
{
|
||||
private static Dictionary<char, VBSymbolType> _operatorTable = new Dictionary<char, VBSymbolType>()
|
||||
{
|
||||
{ '_', VBSymbolType.LineContinuation },
|
||||
{ '(', VBSymbolType.LeftParenthesis },
|
||||
{ ')', VBSymbolType.RightParenthesis },
|
||||
{ '[', VBSymbolType.LeftBracket },
|
||||
{ ']', VBSymbolType.RightBracket },
|
||||
{ '{', VBSymbolType.LeftBrace },
|
||||
{ '}', VBSymbolType.RightBrace },
|
||||
{ '!', VBSymbolType.Bang },
|
||||
{ '#', VBSymbolType.Hash },
|
||||
{ ',', VBSymbolType.Comma },
|
||||
{ '.', VBSymbolType.Dot },
|
||||
{ ':', VBSymbolType.Colon },
|
||||
{ '?', VBSymbolType.QuestionMark },
|
||||
{ '&', VBSymbolType.Concatenation },
|
||||
{ '*', VBSymbolType.Multiply },
|
||||
{ '+', VBSymbolType.Add },
|
||||
{ '-', VBSymbolType.Subtract },
|
||||
{ '/', VBSymbolType.Divide },
|
||||
{ '\\', VBSymbolType.IntegerDivide },
|
||||
{ '^', VBSymbolType.Exponentiation },
|
||||
{ '=', VBSymbolType.Equal },
|
||||
{ '<', VBSymbolType.LessThan },
|
||||
{ '>', VBSymbolType.GreaterThan },
|
||||
{ '$', VBSymbolType.Dollar },
|
||||
};
|
||||
|
||||
public VBTokenizer(ITextDocument source)
|
||||
: base(source)
|
||||
{
|
||||
CurrentState = Data;
|
||||
}
|
||||
|
||||
protected override State StartState
|
||||
{
|
||||
get { return Data; }
|
||||
}
|
||||
|
||||
public override VBSymbolType RazorCommentType
|
||||
{
|
||||
get { return VBSymbolType.RazorComment; }
|
||||
}
|
||||
|
||||
public override VBSymbolType RazorCommentTransitionType
|
||||
{
|
||||
get { return VBSymbolType.RazorCommentTransition; }
|
||||
}
|
||||
|
||||
public override VBSymbolType RazorCommentStarType
|
||||
{
|
||||
get { return VBSymbolType.RazorCommentStar; }
|
||||
}
|
||||
|
||||
internal static IEnumerable<VBSymbol> Tokenize(string content)
|
||||
{
|
||||
using (SeekableTextReader reader = new SeekableTextReader(content))
|
||||
{
|
||||
VBTokenizer tok = new VBTokenizer(reader);
|
||||
VBSymbol sym;
|
||||
while ((sym = tok.NextSymbol()) != null)
|
||||
{
|
||||
yield return sym;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override VBSymbol CreateSymbol(SourceLocation start, string content, VBSymbolType type, IEnumerable<RazorError> errors)
|
||||
{
|
||||
return new VBSymbol(start, content, type, errors);
|
||||
}
|
||||
|
||||
private StateResult Data()
|
||||
{
|
||||
// We are accepting more characters and whitespace/newlines then the VB Spec defines, to simplify things
|
||||
// Since the code must still be compiled by a VB compiler, this will not cause adverse effects.
|
||||
if (ParserHelpers.IsNewLine(CurrentCharacter))
|
||||
{
|
||||
// VB Spec §2.1.1
|
||||
bool checkTwoCharNewline = CurrentCharacter == '\r';
|
||||
TakeCurrent();
|
||||
if (checkTwoCharNewline && CurrentCharacter == '\n')
|
||||
{
|
||||
TakeCurrent();
|
||||
}
|
||||
return Stay(EndSymbol(VBSymbolType.NewLine));
|
||||
}
|
||||
else if (ParserHelpers.IsWhitespace(CurrentCharacter))
|
||||
{
|
||||
// CSharp Spec §2.1.3
|
||||
TakeUntil(c => !ParserHelpers.IsWhitespace(c));
|
||||
return Stay(EndSymbol(VBSymbolType.WhiteSpace));
|
||||
}
|
||||
else if (VBHelpers.IsSingleQuote(CurrentCharacter))
|
||||
{
|
||||
TakeCurrent();
|
||||
return CommentBody();
|
||||
}
|
||||
else if (IsIdentifierStart())
|
||||
{
|
||||
return Identifier();
|
||||
}
|
||||
else if (Char.IsDigit(CurrentCharacter))
|
||||
{
|
||||
return DecimalLiteral();
|
||||
}
|
||||
else if (CurrentCharacter == '&')
|
||||
{
|
||||
char next = Char.ToLower(Peek(), CultureInfo.InvariantCulture);
|
||||
if (next == 'h')
|
||||
{
|
||||
return HexLiteral();
|
||||
}
|
||||
else if (next == 'o')
|
||||
{
|
||||
return OctLiteral();
|
||||
}
|
||||
}
|
||||
else if (CurrentCharacter == '.' && Char.IsDigit(Peek()))
|
||||
{
|
||||
return FloatingPointLiteralEnd();
|
||||
}
|
||||
else if (VBHelpers.IsDoubleQuote(CurrentCharacter))
|
||||
{
|
||||
TakeCurrent();
|
||||
return Transition(QuotedLiteral);
|
||||
}
|
||||
else if (AtDateLiteral())
|
||||
{
|
||||
return DateLiteral();
|
||||
}
|
||||
else if (CurrentCharacter == '@')
|
||||
{
|
||||
TakeCurrent();
|
||||
if (CurrentCharacter == '*')
|
||||
{
|
||||
return Transition(EndSymbol(VBSymbolType.RazorCommentTransition), AfterRazorCommentTransition);
|
||||
}
|
||||
else if (CurrentCharacter == '@')
|
||||
{
|
||||
// Could be escaped comment transition
|
||||
return Transition(EndSymbol(VBSymbolType.Transition), () =>
|
||||
{
|
||||
TakeCurrent();
|
||||
return Transition(EndSymbol(VBSymbolType.Transition), Data);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return Stay(EndSymbol(VBSymbolType.Transition));
|
||||
}
|
||||
}
|
||||
return Stay(EndSymbol(Operator()));
|
||||
}
|
||||
|
||||
private StateResult DateLiteral()
|
||||
{
|
||||
AssertCurrent('#');
|
||||
TakeCurrent();
|
||||
TakeUntil(c => c == '#' || ParserHelpers.IsNewLine(c));
|
||||
if (CurrentCharacter == '#')
|
||||
{
|
||||
TakeCurrent();
|
||||
}
|
||||
return Stay(EndSymbol(VBSymbolType.DateLiteral));
|
||||
}
|
||||
|
||||
private bool AtDateLiteral()
|
||||
{
|
||||
if (CurrentCharacter != '#')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int start = Source.Position;
|
||||
try
|
||||
{
|
||||
MoveNext();
|
||||
while (ParserHelpers.IsWhitespace(CurrentCharacter))
|
||||
{
|
||||
MoveNext();
|
||||
}
|
||||
return Char.IsDigit(CurrentCharacter);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Source.Position = start;
|
||||
}
|
||||
}
|
||||
|
||||
private StateResult QuotedLiteral()
|
||||
{
|
||||
TakeUntil(c => VBHelpers.IsDoubleQuote(c) || ParserHelpers.IsNewLine(c));
|
||||
if (VBHelpers.IsDoubleQuote(CurrentCharacter))
|
||||
{
|
||||
TakeCurrent();
|
||||
if (VBHelpers.IsDoubleQuote(CurrentCharacter))
|
||||
{
|
||||
// Escape sequence, remain in the string
|
||||
TakeCurrent();
|
||||
return Stay();
|
||||
}
|
||||
}
|
||||
|
||||
VBSymbolType type = VBSymbolType.StringLiteral;
|
||||
if (Char.ToLowerInvariant(CurrentCharacter) == 'c')
|
||||
{
|
||||
TakeCurrent();
|
||||
type = VBSymbolType.CharacterLiteral;
|
||||
}
|
||||
return Transition(EndSymbol(type), Data);
|
||||
}
|
||||
|
||||
private StateResult DecimalLiteral()
|
||||
{
|
||||
TakeUntil(c => !Char.IsDigit(c));
|
||||
char lower = Char.ToLowerInvariant(CurrentCharacter);
|
||||
if (IsFloatTypeSuffix(lower) || lower == '.' || lower == 'e')
|
||||
{
|
||||
return FloatingPointLiteralEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
TakeIntTypeSuffix();
|
||||
return Stay(EndSymbol(VBSymbolType.IntegerLiteral));
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsFloatTypeSuffix(char chr)
|
||||
{
|
||||
chr = Char.ToLowerInvariant(chr);
|
||||
return chr == 'f' || chr == 'r' || chr == 'd';
|
||||
}
|
||||
|
||||
private StateResult FloatingPointLiteralEnd()
|
||||
{
|
||||
if (CurrentCharacter == '.')
|
||||
{
|
||||
TakeCurrent();
|
||||
TakeUntil(c => !Char.IsDigit(c));
|
||||
}
|
||||
if (Char.ToLowerInvariant(CurrentCharacter) == 'e')
|
||||
{
|
||||
TakeCurrent();
|
||||
if (CurrentCharacter == '+' || CurrentCharacter == '-')
|
||||
{
|
||||
TakeCurrent();
|
||||
}
|
||||
TakeUntil(c => !Char.IsDigit(c));
|
||||
}
|
||||
if (IsFloatTypeSuffix(CurrentCharacter))
|
||||
{
|
||||
TakeCurrent();
|
||||
}
|
||||
return Stay(EndSymbol(VBSymbolType.FloatingPointLiteral));
|
||||
}
|
||||
|
||||
private StateResult HexLiteral()
|
||||
{
|
||||
AssertCurrent('&');
|
||||
TakeCurrent();
|
||||
Debug.Assert(Char.ToLowerInvariant(CurrentCharacter) == 'h');
|
||||
TakeCurrent();
|
||||
TakeUntil(c => !ParserHelpers.IsHexDigit(c));
|
||||
TakeIntTypeSuffix();
|
||||
return Stay(EndSymbol(VBSymbolType.IntegerLiteral));
|
||||
}
|
||||
|
||||
private StateResult OctLiteral()
|
||||
{
|
||||
AssertCurrent('&');
|
||||
TakeCurrent();
|
||||
Debug.Assert(Char.ToLowerInvariant(CurrentCharacter) == 'o');
|
||||
TakeCurrent();
|
||||
TakeUntil(c => !VBHelpers.IsOctalDigit(c));
|
||||
TakeIntTypeSuffix();
|
||||
return Stay(EndSymbol(VBSymbolType.IntegerLiteral));
|
||||
}
|
||||
|
||||
private VBSymbolType Operator()
|
||||
{
|
||||
char op = CurrentCharacter;
|
||||
TakeCurrent();
|
||||
VBSymbolType ret;
|
||||
if (_operatorTable.TryGetValue(op, out ret))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
return VBSymbolType.Unknown;
|
||||
}
|
||||
|
||||
private void TakeIntTypeSuffix()
|
||||
{
|
||||
// Take the "U" in US, UI, UL
|
||||
if (Char.ToLowerInvariant(CurrentCharacter) == 'u')
|
||||
{
|
||||
TakeCurrent(); // Unsigned Prefix
|
||||
}
|
||||
|
||||
// Take the S, I or L integer suffix
|
||||
if (IsIntegerSuffix(CurrentCharacter))
|
||||
{
|
||||
TakeCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsIntegerSuffix(char chr)
|
||||
{
|
||||
chr = Char.ToLowerInvariant(chr);
|
||||
return chr == 's' || chr == 'i' || chr == 'l';
|
||||
}
|
||||
|
||||
private StateResult CommentBody()
|
||||
{
|
||||
TakeUntil(ParserHelpers.IsNewLine);
|
||||
return Stay(EndSymbol(VBSymbolType.Comment));
|
||||
}
|
||||
|
||||
private StateResult Identifier()
|
||||
{
|
||||
bool isEscaped = false;
|
||||
if (CurrentCharacter == '[')
|
||||
{
|
||||
TakeCurrent();
|
||||
isEscaped = true;
|
||||
}
|
||||
TakeUntil(c => !ParserHelpers.IsIdentifierPart(c));
|
||||
|
||||
// If we're escaped, take the ']'
|
||||
if (isEscaped)
|
||||
{
|
||||
if (CurrentCharacter == ']')
|
||||
{
|
||||
TakeCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
// Check for Keywords and build the symbol
|
||||
VBKeyword? keyword = VBKeywordDetector.GetKeyword(Buffer.ToString());
|
||||
if (keyword == VBKeyword.Rem)
|
||||
{
|
||||
return CommentBody();
|
||||
}
|
||||
|
||||
VBSymbol sym = new VBSymbol(CurrentStart, Buffer.ToString(), keyword == null ? VBSymbolType.Identifier : VBSymbolType.Keyword)
|
||||
{
|
||||
Keyword = keyword
|
||||
};
|
||||
|
||||
StartSymbol();
|
||||
|
||||
return Stay(sym);
|
||||
}
|
||||
|
||||
private bool IsIdentifierStart()
|
||||
{
|
||||
if (CurrentCharacter == '_')
|
||||
{
|
||||
// VB Spec §2.2:
|
||||
// If an identifier begins with an underscore, it must contain at least one other valid identifier character to disambiguate it from a line continuation.
|
||||
return ParserHelpers.IsIdentifierPart(Peek());
|
||||
}
|
||||
if (CurrentCharacter == '[')
|
||||
{
|
||||
return ParserHelpers.IsIdentifierPart(Peek());
|
||||
}
|
||||
return ParserHelpers.IsIdentifierStart(CurrentCharacter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNet.Razor
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the Visual Basic Code Language for Razor
|
||||
/// </summary>
|
||||
public class VBRazorCodeLanguage : RazorCodeLanguage
|
||||
{
|
||||
private const string VBLanguageName = "vb";
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the language: "vb"
|
||||
/// </summary>
|
||||
public override string LanguageName
|
||||
{
|
||||
get { return VBLanguageName; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the type of the CodeDOM provider for this language
|
||||
/// </summary>
|
||||
public override Type CodeDomProviderType
|
||||
{
|
||||
get { return typeof(VBCodeProvider); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of the code parser for this language
|
||||
/// </summary>
|
||||
public override ParserBase CreateCodeParser()
|
||||
{
|
||||
return new VBCodeParser();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of the code generator for this language with the specified settings
|
||||
/// </summary>
|
||||
public override RazorCodeGenerator CreateCodeGenerator(string className, string rootNamespaceName, string sourceFileName, RazorEngineHost host)
|
||||
{
|
||||
return new VBRazorCodeGenerator(className, rootNamespaceName, sourceFileName, host);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,12 +21,6 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
self.Span(SpanKind.Code, new CSharpSymbol(self.LocationTracker.CurrentLocation, String.Empty, CSharpSymbolType.Unknown)));
|
||||
}
|
||||
|
||||
public static UnclassifiedCodeSpanConstructor EmptyVB(this SpanFactory self)
|
||||
{
|
||||
return new UnclassifiedCodeSpanConstructor(
|
||||
self.Span(SpanKind.Code, new VBSymbol(self.LocationTracker.CurrentLocation, String.Empty, VBSymbolType.Unknown)));
|
||||
}
|
||||
|
||||
public static SpanConstructor EmptyHtml(this SpanFactory self)
|
||||
{
|
||||
return self.Span(SpanKind.Markup, new HtmlSymbol(self.LocationTracker.CurrentLocation, String.Empty, HtmlSymbolType.Unknown))
|
||||
|
|
@ -59,16 +53,6 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
return self.Span(SpanKind.Transition, content, type).Accepts(AcceptedCharacters.None);
|
||||
}
|
||||
|
||||
public static SpanConstructor CodeTransition(this SpanFactory self, VBSymbolType type)
|
||||
{
|
||||
return self.Span(SpanKind.Transition, SyntaxConstants.TransitionString, type).Accepts(AcceptedCharacters.None);
|
||||
}
|
||||
|
||||
public static SpanConstructor CodeTransition(this SpanFactory self, string content, VBSymbolType type)
|
||||
{
|
||||
return self.Span(SpanKind.Transition, content, type).Accepts(AcceptedCharacters.None);
|
||||
}
|
||||
|
||||
public static SpanConstructor MarkupTransition(this SpanFactory self)
|
||||
{
|
||||
return self.Span(SpanKind.Transition, SyntaxConstants.TransitionString, markup: true).Accepts(AcceptedCharacters.None);
|
||||
|
|
@ -99,11 +83,6 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
return self.Span(SpanKind.MetaCode, content, type);
|
||||
}
|
||||
|
||||
public static SpanConstructor MetaCode(this SpanFactory self, string content, VBSymbolType type)
|
||||
{
|
||||
return self.Span(SpanKind.MetaCode, content, type);
|
||||
}
|
||||
|
||||
public static SpanConstructor MetaMarkup(this SpanFactory self, string content)
|
||||
{
|
||||
return self.Span(SpanKind.MetaCode, content, markup: true);
|
||||
|
|
@ -119,11 +98,6 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
return self.Span(SpanKind.Comment, content, type);
|
||||
}
|
||||
|
||||
public static SpanConstructor Comment(this SpanFactory self, string content, VBSymbolType type)
|
||||
{
|
||||
return self.Span(SpanKind.Comment, content, type);
|
||||
}
|
||||
|
||||
public static SpanConstructor Comment(this SpanFactory self, string content, HtmlSymbolType type)
|
||||
{
|
||||
return self.Span(SpanKind.Comment, content, type);
|
||||
|
|
@ -162,15 +136,6 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
};
|
||||
}
|
||||
|
||||
public static SpanFactory CreateVbHtml()
|
||||
{
|
||||
return new SpanFactory()
|
||||
{
|
||||
MarkupTokenizerFactory = doc => new HtmlTokenizer(doc),
|
||||
CodeTokenizerFactory = doc => new VBTokenizer(doc)
|
||||
};
|
||||
}
|
||||
|
||||
public SpanFactory()
|
||||
{
|
||||
LocationTracker = new SourceLocationTracker();
|
||||
|
|
@ -181,11 +146,6 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
return CreateSymbolSpan(kind, content, st => new CSharpSymbol(st, content, type));
|
||||
}
|
||||
|
||||
public SpanConstructor Span(SpanKind kind, string content, VBSymbolType type)
|
||||
{
|
||||
return CreateSymbolSpan(kind, content, st => new VBSymbol(st, content, type));
|
||||
}
|
||||
|
||||
public SpanConstructor Span(SpanKind kind, string content, HtmlSymbolType type)
|
||||
{
|
||||
return CreateSymbolSpan(kind, content, st => new HtmlSymbol(st, content, type));
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Framework
|
||||
{
|
||||
public abstract class VBHtmlCodeParserTestBase : CodeParserTestBase
|
||||
{
|
||||
protected override ISet<string> KeywordSet
|
||||
{
|
||||
get { return VBCodeParser.DefaultKeywords; }
|
||||
}
|
||||
|
||||
protected override SpanFactory CreateSpanFactory()
|
||||
{
|
||||
return SpanFactory.CreateVbHtml();
|
||||
}
|
||||
|
||||
public override ParserBase CreateMarkupParser()
|
||||
{
|
||||
return new HtmlMarkupParser();
|
||||
}
|
||||
|
||||
public override ParserBase CreateCodeParser()
|
||||
{
|
||||
return new VBCodeParser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Framework
|
||||
{
|
||||
public abstract class VBHtmlMarkupParserTestBase : MarkupParserTestBase
|
||||
{
|
||||
protected override ISet<string> KeywordSet
|
||||
{
|
||||
get { return VBCodeParser.DefaultKeywords; }
|
||||
}
|
||||
|
||||
protected override SpanFactory CreateSpanFactory()
|
||||
{
|
||||
return SpanFactory.CreateVbHtml();
|
||||
}
|
||||
|
||||
public override ParserBase CreateMarkupParser()
|
||||
{
|
||||
return new HtmlMarkupParser();
|
||||
}
|
||||
|
||||
public override ParserBase CreateCodeParser()
|
||||
{
|
||||
return new VBCodeParser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,6 +22,6 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
File.WriteAllText("./testfile_ct.cs", results.GeneratedCode);
|
||||
File.WriteAllText("./testfile_cd.cs", codDOMOutput);
|
||||
}, designTimeMode: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,281 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Generator
|
||||
{
|
||||
public class VBRazorCodeGeneratorTest : RazorCodeGeneratorTest<VBRazorCodeLanguage>
|
||||
{
|
||||
private const string TestPhysicalPath = @"C:\Bar.vbhtml";
|
||||
private const string TestVirtualPath = "~/Foo/Bar.vbhtml";
|
||||
|
||||
protected override string FileExtension
|
||||
{
|
||||
get { return "vbhtml"; }
|
||||
}
|
||||
|
||||
protected override string LanguageName
|
||||
{
|
||||
get { return "VB"; }
|
||||
}
|
||||
|
||||
protected override string BaselineExtension
|
||||
{
|
||||
get { return "vb"; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullClassName()
|
||||
{
|
||||
Assert.ThrowsArgumentNullOrEmptyString(() => new VBRazorCodeGenerator(null, TestRootNamespaceName, TestPhysicalPath, CreateHost()), "className");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonEmptyClassName()
|
||||
{
|
||||
Assert.ThrowsArgumentNullOrEmptyString(() => new VBRazorCodeGenerator(String.Empty, TestRootNamespaceName, TestPhysicalPath, CreateHost()), "className");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullRootNamespaceName()
|
||||
{
|
||||
Assert.ThrowsArgumentNull(() => new VBRazorCodeGenerator("Foo", null, TestPhysicalPath, CreateHost()), "rootNamespaceName");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorAllowsEmptyRootNamespaceName()
|
||||
{
|
||||
new VBRazorCodeGenerator("Foo", String.Empty, TestPhysicalPath, CreateHost());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullHost()
|
||||
{
|
||||
Assert.ThrowsArgumentNull(() => new VBRazorCodeGenerator("Foo", TestRootNamespaceName, TestPhysicalPath, null), "host");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("NestedCodeBlocks")]
|
||||
[InlineData("NestedCodeBlocks")]
|
||||
[InlineData("CodeBlock")]
|
||||
[InlineData("ExplicitExpression")]
|
||||
[InlineData("MarkupInCodeBlock")]
|
||||
[InlineData("Blocks")]
|
||||
[InlineData("ImplicitExpression")]
|
||||
[InlineData("Imports")]
|
||||
[InlineData("ExpressionsInCode")]
|
||||
[InlineData("FunctionsBlock")]
|
||||
[InlineData("Options")]
|
||||
[InlineData("Templates")]
|
||||
[InlineData("RazorComments")]
|
||||
[InlineData("Sections")]
|
||||
[InlineData("EmptySection")] // this scenario causes a crash in Razor V2.0
|
||||
[InlineData("Helpers")]
|
||||
[InlineData("HelpersMissingCloseParen")]
|
||||
[InlineData("HelpersMissingOpenParen")]
|
||||
[InlineData("NestedHelpers")]
|
||||
[InlineData("LayoutDirective")]
|
||||
[InlineData("ConditionalAttributes")]
|
||||
[InlineData("ResolveUrl")]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesRunTimeCode(string testName)
|
||||
{
|
||||
RunTest(testName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesMappingsForRazorCommentsAtDesignTime()
|
||||
{
|
||||
// (4, 6) -> (?, 6) [6]
|
||||
// ( 5, 40) -> (?, 39) [2]
|
||||
// ( 8, 6) -> (?, 6) [33]
|
||||
// ( 9, 46) -> (?, 46) [3]
|
||||
// ( 12, 3) -> (?, 7) [3]
|
||||
// ( 12, 8) -> (?, 8) [1]
|
||||
RunTest("RazorComments", "RazorComments.DesignTime", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(4, 6, 6, 6),
|
||||
/* 02 */ new GeneratedCodeMapping(5, 40, 39, 2),
|
||||
/* 03 */ new GeneratedCodeMapping(8, 6, 6, 33),
|
||||
/* 04 */ new GeneratedCodeMapping(9, 46, 46, 3),
|
||||
/* 05 */ new GeneratedCodeMapping(12, 3, 7, 1),
|
||||
/* 06 */ new GeneratedCodeMapping(12, 8, 8, 1)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesHelperMissingNameAtDesignTime()
|
||||
{
|
||||
RunTest("HelpersMissingName", designTimeMode: true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesImportStatementsAtDesignTimeButCannotWrapPragmasAroundImportStatement()
|
||||
{
|
||||
RunTest("Imports", "Imports.DesignTime", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(1, 2, 1, 19),
|
||||
/* 02 */ new GeneratedCodeMapping(2, 2, 1, 36),
|
||||
/* 03 */ new GeneratedCodeMapping(3, 2, 1, 16),
|
||||
/* 04 */ new GeneratedCodeMapping(5, 30, 30, 22),
|
||||
/* 05 */ new GeneratedCodeMapping(6, 36, 36, 21),
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesFunctionsBlocksAtDesignTime()
|
||||
{
|
||||
RunTest("FunctionsBlock", "FunctionsBlock.DesignTime", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(1, 11, 11, 4),
|
||||
/* 02 */ new GeneratedCodeMapping(5, 11, 11, 129),
|
||||
/* 03 */ new GeneratedCodeMapping(12, 26, 26, 11)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesFunctionsBlocksAtDesignTimeTabs()
|
||||
{
|
||||
RunTest("FunctionsBlock", "FunctionsBlock.DesignTime.Tabs", designTimeMode: true, tabTest: TabTest.Tabs, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(1, 11, 5, 4),
|
||||
/* 02 */ new GeneratedCodeMapping(5, 11, 5, 129),
|
||||
/* 03 */ new GeneratedCodeMapping(12, 26, 14, 11)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorGeneratesCodeWithParserErrorsInDesignTimeMode()
|
||||
{
|
||||
RunTest("ParserError", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(1, 6, 6, 16)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesInheritsAtRuntime()
|
||||
{
|
||||
RunTest("Inherits", baselineName: "Inherits.Runtime");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesInheritsAtDesigntime()
|
||||
{
|
||||
RunTest("Inherits", baselineName: "Inherits.Designtime", designTimeMode: true, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(1, 11, 25, 27)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesDesignTimePragmasForUnfinishedExpressionsInCode()
|
||||
{
|
||||
RunTest("UnfinishedExpressionInCode", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(1, 6, 6, 2),
|
||||
/* 02 */ new GeneratedCodeMapping(2, 2, 7, 9),
|
||||
/* 03 */ new GeneratedCodeMapping(2, 11, 11, 2)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesDesignTimePragmasMarkupAndExpressions()
|
||||
{
|
||||
RunTest("DesignTime", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(2, 14, 13, 17),
|
||||
/* 02 */ new GeneratedCodeMapping(3, 20, 20, 1),
|
||||
/* 03 */ new GeneratedCodeMapping(3, 25, 25, 20),
|
||||
/* 04 */ new GeneratedCodeMapping(8, 3, 7, 12),
|
||||
/* 05 */ new GeneratedCodeMapping(9, 2, 7, 4),
|
||||
/* 06 */ new GeneratedCodeMapping(9, 16, 16, 3),
|
||||
/* 07 */ new GeneratedCodeMapping(9, 27, 27, 1),
|
||||
/* 08 */ new GeneratedCodeMapping(14, 6, 7, 3),
|
||||
/* 09 */ new GeneratedCodeMapping(17, 9, 24, 5),
|
||||
/* 10 */ new GeneratedCodeMapping(17, 14, 14, 28),
|
||||
/* 11 */ new GeneratedCodeMapping(19, 20, 20, 14)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesDesignTimePragmasForImplicitExpressionStartedAtEOF()
|
||||
{
|
||||
RunTest("ImplicitExpressionAtEOF", designTimeMode: true, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(3, 2, 7, 0)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesDesignTimePragmasForExplicitExpressionStartedAtEOF()
|
||||
{
|
||||
RunTest("ExplicitExpressionAtEOF", designTimeMode: true, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(3, 3, 7, 0)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesDesignTimePragmasForCodeBlockStartedAtEOF()
|
||||
{
|
||||
RunTest("CodeBlockAtEOF", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(3, 6, 6, 0)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyImplicitExpression()
|
||||
{
|
||||
RunTest("EmptyImplicitExpression", designTimeMode: true, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(3, 2, 7, 0)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyImplicitExpressionInCode()
|
||||
{
|
||||
RunTest("EmptyImplicitExpressionInCode", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(1, 6, 6, 6),
|
||||
/* 02 */ new GeneratedCodeMapping(2, 6, 7, 0),
|
||||
/* 03 */ new GeneratedCodeMapping(2, 6, 6, 2)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyExplicitExpression()
|
||||
{
|
||||
RunTest("EmptyExplicitExpression", designTimeMode: true, expectedDesignTimePragmas: new List<GeneratedCodeMapping>()
|
||||
{
|
||||
/* 01 */ new GeneratedCodeMapping(3, 3, 7, 0)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorDoesNotRenderLinePragmasIfGenerateLinePragmasIsSetToFalse()
|
||||
{
|
||||
RunTest("NoLinePragmas", generatePragmas: false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorRendersHelpersBlockCorrectlyWhenInstanceHelperRequested()
|
||||
{
|
||||
RunTest("Helpers", baselineName: "Helpers.Instance", hostConfig: h => h.StaticHelpers = false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VBCodeGeneratorCorrectlyInstrumentsRazorCodeWhenInstrumentationRequested()
|
||||
{
|
||||
RunTest("Instrumented", hostConfig: host =>
|
||||
{
|
||||
host.EnableInstrumentation = true;
|
||||
host.InstrumentedSourceFilePath = String.Format("~/{0}.vbhtml", host.DefaultClassName);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,8 +49,6 @@
|
|||
<Compile Include="Framework\ParserTestBase.cs" />
|
||||
<Compile Include="Framework\RawTextSymbol.cs" />
|
||||
<Compile Include="Framework\TestSpanBuilder.cs" />
|
||||
<Compile Include="Framework\VBHtmlCodeParserTestBase.cs" />
|
||||
<Compile Include="Framework\VBHtmlMarkupParserTestBase.cs" />
|
||||
<Compile Include="Generator\CodeTree\CodeTreeGenerationTest.cs" />
|
||||
<Compile Include="Generator\GeneratedCodeMappingTest.cs" />
|
||||
<Compile Include="Generator\PaddingTest.cs" />
|
||||
|
|
@ -76,35 +74,14 @@
|
|||
<Compile Include="Parser\Html\HtmlAttributeTest.cs" />
|
||||
<Compile Include="Parser\Html\HtmlUrlAttributeTest.cs" />
|
||||
<Compile Include="Parser\ParserVisitorExtensionsTest.cs" />
|
||||
<Compile Include="Parser\VB\VBRazorCommentsTest.cs" />
|
||||
<Compile Include="Parser\VB\VBLayoutDirectiveTest.cs" />
|
||||
<Compile Include="Parser\VB\VBAutoCompleteTest.cs" />
|
||||
<Compile Include="Parser\Html\HtmlTagsTest.cs" />
|
||||
<Compile Include="Parser\VB\VBContinueStatementTest.cs" />
|
||||
<Compile Include="Parser\VB\VBDirectiveTest.cs" />
|
||||
<Compile Include="Parser\VB\VBExitStatementTest.cs" />
|
||||
<Compile Include="Parser\VB\VBExplicitExpressionTest.cs" />
|
||||
<Compile Include="Parser\VB\VBImplicitExpressionTest.cs" />
|
||||
<Compile Include="Parser\VB\VBReservedWordsTest.cs" />
|
||||
<Compile Include="Parser\CSharp\CSharpReservedWordsTest.cs" />
|
||||
<Compile Include="Parser\PartialParsing\VBPartialParsingTest.cs" />
|
||||
<Compile Include="Parser\PartialParsing\CSharpPartialParsingTest.cs" />
|
||||
<Compile Include="Parser\VB\VBHelperTest.cs" />
|
||||
<Compile Include="Parser\CSharp\CSharpHelperTest.cs" />
|
||||
<Compile Include="Generator\RazorCodeGeneratorTest.cs" />
|
||||
<Compile Include="Parser\PartialParsing\PartialParsingTestBase.cs" />
|
||||
<Compile Include="Parser\VB\VBNestedStatementsTest.cs" />
|
||||
<Compile Include="Parser\VB\VBStatementTest.cs" />
|
||||
<Compile Include="Parser\WhitespaceRewriterTest.cs" />
|
||||
<Compile Include="RazorCodeLanguageTest.cs" />
|
||||
<Compile Include="Parser\VB\VBHtmlDocumentTest.cs" />
|
||||
<Compile Include="Parser\VB\VBErrorTest.cs" />
|
||||
<Compile Include="Parser\VB\VBSectionTest.cs" />
|
||||
<Compile Include="Parser\VB\VBTemplateTest.cs" />
|
||||
<Compile Include="Parser\VB\VBExpressionsInCodeTest.cs" />
|
||||
<Compile Include="Parser\VB\VBSpecialKeywordsTest.cs" />
|
||||
<Compile Include="Parser\VB\VBBlockTest.cs" />
|
||||
<Compile Include="Parser\VB\VBToMarkupSwitchTest.cs" />
|
||||
<Compile Include="Editor\RazorEditorParserTest.cs" />
|
||||
<Compile Include="RazorDirectiveAttributeTest.cs" />
|
||||
<Compile Include="RazorEngineHostTest.cs" />
|
||||
|
|
@ -165,12 +142,6 @@
|
|||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\HtmlCommentWithQuote_Double.cs" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\CodeTree.cs" />
|
||||
<Compile Include="Text\LineTrackingStringBufferTest.cs" />
|
||||
<Compile Include="Tokenizer\VBTokenizerLiteralTest.cs" />
|
||||
<Compile Include="Tokenizer\VBTokenizerIdentifierTest.cs" />
|
||||
<Compile Include="Tokenizer\VBTokenizerCommentTest.cs" />
|
||||
<Compile Include="Tokenizer\VBTokenizerOperatorsTest.cs" />
|
||||
<Compile Include="Tokenizer\VBTokenizerTestBase.cs" />
|
||||
<Compile Include="Tokenizer\VBTokenizerTest.cs" />
|
||||
<Compile Include="Tokenizer\CSharpTokenizerCommentTest.cs" />
|
||||
<Compile Include="Tokenizer\CSharpTokenizerLiteralTest.cs" />
|
||||
<Compile Include="Tokenizer\CSharpTokenizerIdentifierTest.cs" />
|
||||
|
|
@ -182,14 +153,12 @@
|
|||
<Compile Include="Tokenizer\HtmlTokenizerTestBase.cs" />
|
||||
<Compile Include="Tokenizer\TokenizerTestBase.cs" />
|
||||
<Compile Include="Utils\MiscUtils.cs" />
|
||||
<Compile Include="Generator\VBRazorCodeGeneratorTest.cs" />
|
||||
<Compile Include="Generator\CSharpRazorCodeGeneratorTest.cs" />
|
||||
<Compile Include="CSharpRazorCodeLanguageTest.cs" />
|
||||
<Compile Include="Parser\CallbackParserListenerTest.cs" />
|
||||
<Compile Include="Parser\CSharp\CSharpExplicitExpressionTest.cs" />
|
||||
<Compile Include="Parser\CSharp\CSharpSectionTest.cs" />
|
||||
<Compile Include="Parser\BlockTest.cs" />
|
||||
<Compile Include="Parser\VB\VBExpressionTest.cs" />
|
||||
<Compile Include="Text\BufferingTextReaderTest.cs" />
|
||||
<Compile Include="Parser\CSharp\CSharpErrorTest.cs" />
|
||||
<Compile Include="Parser\CSharp\CSharpImplicitExpressionTest.cs" />
|
||||
|
|
@ -210,7 +179,6 @@
|
|||
<Compile Include="Utils\SpanAssert.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="VBRazorCodeLanguageTest.cs" />
|
||||
<Compile Include="Text\TextChangeTest.cs" />
|
||||
<Compile Include="Text\TextReaderExtensionsTest.cs" />
|
||||
<Compile Include="Utils\EnumerableUtils.cs" />
|
||||
|
|
@ -233,45 +201,6 @@
|
|||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\CodeBlock.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\ExplicitExpression.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\MarkupInCodeBlock.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\Blocks.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\ImplicitExpression.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\NoLinePragmas.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\Imports.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\ExpressionsInCode.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\FunctionsBlock.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\Options.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\Templates.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\Sections.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\DesignTime.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Templates.cshtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Blocks.cshtml" />
|
||||
|
|
@ -296,26 +225,17 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Inherits.cshtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\Inherits.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\NestedHelpers.cshtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\NestedHelpers.vbhtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Instrumented.cshtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\Instrumented.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\RazorComments.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\RazorComments.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ParserError.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\ParserError.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ImplicitExpressionAtEOF.cshtml" />
|
||||
</ItemGroup>
|
||||
|
|
@ -334,27 +254,9 @@
|
|||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\EmptyImplicitExpression.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\CodeBlockAtEOF.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\EmptyExplicitExpression.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\EmptyImplicitExpression.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\ExplicitExpressionAtEOF.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\ImplicitExpressionAtEOF.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\UnfinishedExpressionInCode.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\UnfinishedExpressionInCode.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\DesignTime\Simple.cshtml" />
|
||||
</ItemGroup>
|
||||
|
|
@ -370,45 +272,23 @@
|
|||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\HelpersMissingOpenParen.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\HelpersMissingOpenParen.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\Helpers.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\HelpersMissingCloseParen.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\HelpersMissingName.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\NestedCodeBlocks.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\NestedCodeBlocks.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\InlineBlocks.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\EmptyImplicitExpressionInCode.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\EmptyImplicitExpressionInCode.vbhtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\HiddenSpansInCode.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ResolveUrl.cshtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\ResolveUrl.vbhtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\LayoutDirective.cshtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\LayoutDirective.vbhtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ConditionalAttributes.cshtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\ConditionalAttributes.vbhtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Source\EmptySection.vbhtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\OpenedIf.cshtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\FunctionsBlock_Tabs.cshtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\FunctionsBlockMinimal.cshtml" />
|
||||
|
|
@ -417,57 +297,8 @@
|
|||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\HtmlCommentWithQuote_Single.cshtml" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\CodeTree.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Blocks.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\CodeBlock.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\CodeBlockAtEOF.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Comments.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\ConditionalAttributes.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\DesignTime.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\EmptyExplicitExpression.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\EmptyImplicitExpression.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\EmptyImplicitExpressionInCode.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\ExplicitExpression.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\ExplicitExpressionAtEOF.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\ExpressionsInCode.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\FunctionsBlock.DesignTime.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\FunctionsBlock.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Helpers.Instance.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Helpers.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\HelpersMissingCloseParen.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\HelpersMissingName.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\HelpersMissingOpenParen.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\ImplicitExpression.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\ImplicitExpressionAtEOF.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Imports.DesignTime.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Imports.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Inherits.Designtime.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Inherits.Runtime.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Instrumented.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\LayoutDirective.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\MarkupInCodeBlock.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\NestedCodeBlocks.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\NestedHelpers.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\NoLinePragmas.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Options.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\ParserError.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\RazorComments.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\ResolveUrl.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Sections.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\Templates.vb" />
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\UnfinishedExpressionInCode.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\RazorComments.DesignTime.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\EmptySection.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\CodeGenerator\VB\Output\FunctionsBlock.DesignTime.Tabs.vb" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
@ -1,375 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using System.Web.WebPages.TestUtils;
|
||||
using Microsoft.TestCommon;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
|
||||
{
|
||||
public class VBPartialParsingTest : PartialParsingTestBase<VBRazorCodeLanguage>
|
||||
{
|
||||
[Fact]
|
||||
public void ImplicitExpressionProvisionallyAcceptsDeleteOfIdentifierPartsIfDotRemains()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
StringTextBuffer changed = new StringTextBuffer("foo @User. baz");
|
||||
StringTextBuffer old = new StringTextBuffer("foo @User.Name baz");
|
||||
RunPartialParseTest(new TextChange(10, 4, old, 0, changed),
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("User.")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" baz")),
|
||||
additionalFlags: PartialParseResult.Provisional);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionAcceptsDeleteOfIdentifierPartsIfSomeOfIdentifierRemains()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
StringTextBuffer changed = new StringTextBuffer("foo @Us baz");
|
||||
StringTextBuffer old = new StringTextBuffer("foo @User baz");
|
||||
RunPartialParseTest(new TextChange(7, 2, old, 0, changed),
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("Us")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" baz")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionProvisionallyAcceptsMultipleInsertionIfItCausesIdentifierExpansionAndTrailingDot()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
StringTextBuffer changed = new StringTextBuffer("foo @User. baz");
|
||||
StringTextBuffer old = new StringTextBuffer("foo @U baz");
|
||||
RunPartialParseTest(new TextChange(6, 0, old, 4, changed),
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("User.")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" baz")),
|
||||
additionalFlags: PartialParseResult.Provisional);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionAcceptsMultipleInsertionIfItOnlyCausesIdentifierExpansion()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
StringTextBuffer changed = new StringTextBuffer("foo @barbiz baz");
|
||||
StringTextBuffer old = new StringTextBuffer("foo @bar baz");
|
||||
RunPartialParseTest(new TextChange(8, 0, old, 3, changed),
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("barbiz")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" baz")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionRejectsChangeWhichWouldHaveBeenAcceptedIfLastChangeWasProvisionallyAcceptedOnDifferentSpan()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
|
||||
// Arrange
|
||||
TextChange dotTyped = new TextChange(8, 0, new StringTextBuffer("foo @foo @bar"), 1, new StringTextBuffer("foo @foo. @bar"));
|
||||
TextChange charTyped = new TextChange(14, 0, new StringTextBuffer("foo @foo. @barb"), 1, new StringTextBuffer("foo @foo. @barb"));
|
||||
TestParserManager manager = CreateParserManager();
|
||||
manager.InitializeWithDocument(dotTyped.OldBuffer);
|
||||
|
||||
// Apply the dot change
|
||||
Assert.Equal(PartialParseResult.Provisional | PartialParseResult.Accepted, manager.CheckForStructureChangesAndWait(dotTyped));
|
||||
|
||||
// Act (apply the identifier start char change)
|
||||
PartialParseResult result = manager.CheckForStructureChangesAndWait(charTyped);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Rejected, result);
|
||||
Assert.False(manager.Parser.LastResultProvisional, "LastResultProvisional flag should have been cleared but it was not");
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree,
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(". "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("barb")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionAcceptsIdentifierTypedAfterDotIfLastChangeWasProvisionalAcceptanceOfDot()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
|
||||
// Arrange
|
||||
TextChange dotTyped = new TextChange(8, 0, new StringTextBuffer("foo @foo bar"), 1, new StringTextBuffer("foo @foo. bar"));
|
||||
TextChange charTyped = new TextChange(9, 0, new StringTextBuffer("foo @foo. bar"), 1, new StringTextBuffer("foo @foo.b bar"));
|
||||
TestParserManager manager = CreateParserManager();
|
||||
manager.InitializeWithDocument(dotTyped.OldBuffer);
|
||||
|
||||
// Apply the dot change
|
||||
Assert.Equal(PartialParseResult.Provisional | PartialParseResult.Accepted, manager.CheckForStructureChangesAndWait(dotTyped));
|
||||
|
||||
// Act (apply the identifier start char change)
|
||||
PartialParseResult result = manager.CheckForStructureChangesAndWait(charTyped);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PartialParseResult.Accepted, result);
|
||||
Assert.False(manager.Parser.LastResultProvisional, "LastResultProvisional flag should have been cleared but it was not");
|
||||
ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree,
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo.b")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" bar")));
|
||||
}
|
||||
[Fact]
|
||||
public void ImplicitExpressionAcceptsIdentifierExpansionAtEndOfNonWhitespaceCharacters()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
StringTextBuffer changed = new StringTextBuffer("@Code" + Environment.NewLine
|
||||
+ " @food" + Environment.NewLine
|
||||
+ "End Code");
|
||||
StringTextBuffer old = new StringTextBuffer("@Code" + Environment.NewLine
|
||||
+ " @foo" + Environment.NewLine
|
||||
+ "End Code");
|
||||
RunPartialParseTest(new TextChange(15, 0, old, 1, changed),
|
||||
new MarkupBlock(
|
||||
factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.MetaCode("Code")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
factory.Code("\r\n ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("food")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code("\r\n").AsStatement(),
|
||||
factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionProvisionallyAcceptsDotAfterIdentifierInMarkup()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
StringTextBuffer changed = new StringTextBuffer("foo @foo. bar");
|
||||
StringTextBuffer old = new StringTextBuffer("foo @foo bar");
|
||||
RunPartialParseTest(new TextChange(8, 0, old, 1, changed),
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo.")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" bar")),
|
||||
additionalFlags: PartialParseResult.Provisional);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionAcceptsAdditionalIdentifierCharactersIfEndOfSpanIsIdentifier()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
StringTextBuffer changed = new StringTextBuffer("foo @foob baz");
|
||||
StringTextBuffer old = new StringTextBuffer("foo @foo bar");
|
||||
RunPartialParseTest(new TextChange(8, 0, old, 1, changed),
|
||||
new MarkupBlock(
|
||||
factory.Markup("foo "),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foob")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Markup(" bar")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionAcceptsAdditionalIdentifierStartCharactersIfEndOfSpanIsDot()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
StringTextBuffer changed = new StringTextBuffer("@Code @foo.b End Code");
|
||||
StringTextBuffer old = new StringTextBuffer("@Code @foo. End Code");
|
||||
RunPartialParseTest(new TextChange(11, 0, old, 1, changed),
|
||||
new MarkupBlock(
|
||||
factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
factory.Code(" ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo.b")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code(" ").AsStatement(),
|
||||
factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionAcceptsDotIfTrailingDotsAreAllowed()
|
||||
{
|
||||
var factory = SpanFactory.CreateVbHtml();
|
||||
StringTextBuffer changed = new StringTextBuffer("@Code @foo. End Code");
|
||||
StringTextBuffer old = new StringTextBuffer("@Code @foo End Code");
|
||||
RunPartialParseTest(new TextChange(10, 0, old, 1, changed),
|
||||
new MarkupBlock(
|
||||
factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
factory.Code(" ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo.")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
factory.Code(" ").AsStatement(),
|
||||
factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)),
|
||||
factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfFunctionsKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("functions");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfCodeKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("code");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfSectionKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("section");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfDoKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("do");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfWhileKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("while");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfIfKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("if");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfSelectKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("select");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfForKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("for");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfTryKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("try");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfWithKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("with");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfSyncLockKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("synclock");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfUsingKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("using");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfImportsKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("imports");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfInheritsKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("inherits");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfOptionKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("option");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfHelperKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("helper");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfNamespaceKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("namespace");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfClassKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplicitExpressionCorrectlyTriggersReparseIfLayoutKeywordTyped()
|
||||
{
|
||||
RunTypeKeywordTest("layout");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBAutoCompleteTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void FunctionsDirective_AutoComplete_At_EOF()
|
||||
{
|
||||
ParseBlockTest("@Functions",
|
||||
new FunctionsBlock(
|
||||
Factory.CodeTransition("@")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("Functions")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.EmptyVB()
|
||||
.AsFunctionsBody()
|
||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString)
|
||||
{
|
||||
AutoCompleteString = SyntaxConstants.VB.EndFunctionsKeyword
|
||||
})),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Functions", "End Functions"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HelperDirective_AutoComplete_At_EOF()
|
||||
{
|
||||
ParseBlockTest("@Helper Strong(value As String)",
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Strong(value As String)", 8, 0, 8), headerComplete: true),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Strong(value As String)")
|
||||
.Hidden()
|
||||
.Accepts(AcceptedCharacters.None)
|
||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndHelperKeyword }),
|
||||
new StatementBlock()),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Helper", "End Helper"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SectionDirective_AutoComplete_At_EOF()
|
||||
{
|
||||
ParseBlockTest("@Section Header",
|
||||
new SectionBlock(new SectionCodeGenerator("Header"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section Header")
|
||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndSectionKeyword }),
|
||||
new MarkupBlock()),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Section", "End Section"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VerbatimBlock_AutoComplete_At_EOF()
|
||||
{
|
||||
ParseBlockTest("@Code",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Code, new VBSymbol(5, 0, 5, String.Empty, VBSymbolType.Unknown))
|
||||
.With(new StatementCodeGenerator())
|
||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndCodeKeyword })),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Code", "End Code"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FunctionsDirective_AutoComplete_At_StartOfFile()
|
||||
{
|
||||
ParseBlockTest("@Functions" + Environment.NewLine
|
||||
+ "foo",
|
||||
new FunctionsBlock(
|
||||
Factory.CodeTransition("@").Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("Functions").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\nfoo")
|
||||
.AsFunctionsBody()
|
||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString)
|
||||
{
|
||||
AutoCompleteString = SyntaxConstants.VB.EndFunctionsKeyword
|
||||
})),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Functions", "End Functions"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HelperDirective_AutoComplete_At_StartOfFile()
|
||||
{
|
||||
ParseBlockTest("@Helper Strong(value As String)" + Environment.NewLine
|
||||
+ "Foo",
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Strong(value As String)", 8, 0, 8), headerComplete: true),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Strong(value As String)")
|
||||
.Hidden()
|
||||
.Accepts(AcceptedCharacters.None)
|
||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndHelperKeyword }),
|
||||
new StatementBlock(
|
||||
Factory.Code("\r\nFoo").AsStatement())),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Helper", "End Helper"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SectionDirective_AutoComplete_At_StartOfFile()
|
||||
{
|
||||
ParseBlockTest("@Section Header" + Environment.NewLine
|
||||
+ "Foo",
|
||||
new SectionBlock(new SectionCodeGenerator("Header"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section Header")
|
||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndSectionKeyword }),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\nFoo")
|
||||
.With(new MarkupCodeGenerator()))),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Section", "End Section"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VerbatimBlock_AutoComplete_At_StartOfFile()
|
||||
{
|
||||
ParseBlockTest("@Code" + Environment.NewLine
|
||||
+ "Foo",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\nFoo")
|
||||
.AsStatement()
|
||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndCodeKeyword })),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Code", "End Code"),
|
||||
1, 0, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,367 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBBlockTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ParseBlockMethodThrowsArgNullExceptionOnNullContext()
|
||||
{
|
||||
// Arrange
|
||||
VBCodeParser parser = new VBCodeParser();
|
||||
|
||||
// Act and Assert
|
||||
Assert.Throws<InvalidOperationException>(() => parser.ParseBlock(), RazorResources.Parser_Context_Not_Set);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockAcceptsImplicitExpression()
|
||||
{
|
||||
ParseBlockTest("If True Then" + Environment.NewLine
|
||||
+ " @foo" + Environment.NewLine
|
||||
+ "End If",
|
||||
new StatementBlock(
|
||||
Factory.Code("If True Then\r\n ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Code("\r\nEnd If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockAcceptsIfStatementWithinCodeBlockIfInDesignTimeMode()
|
||||
{
|
||||
ParseBlockTest("If True Then" + Environment.NewLine
|
||||
+ " @If True Then" + Environment.NewLine
|
||||
+ " End If" + Environment.NewLine
|
||||
+ "End If",
|
||||
new StatementBlock(
|
||||
Factory.Code("If True Then\r\n ").AsStatement(),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If True Then\r\n End If\r\n")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(@"End If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockSupportsSpacesInStrings()
|
||||
{
|
||||
ParseBlockTest("for each p in db.Query(\"SELECT * FROM PRODUCTS\")" + Environment.NewLine
|
||||
+ " @<p>@p.Name</p>" + Environment.NewLine
|
||||
+ "next",
|
||||
new StatementBlock(
|
||||
Factory.Code("for each p in db.Query(\"SELECT * FROM PRODUCTS\")\r\n")
|
||||
.AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.Markup("<p>"),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("p.Name")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Markup("</p>\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code("next")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.WhiteSpace | AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockSupportsSimpleCodeBlock()
|
||||
{
|
||||
ParseBlockTest("Code" + Environment.NewLine
|
||||
+ " If foo IsNot Nothing" + Environment.NewLine
|
||||
+ " Bar(foo)" + Environment.NewLine
|
||||
+ " End If" + Environment.NewLine
|
||||
+ "End Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n If foo IsNot Nothing\r\n Bar(foo)\r\n End If\r\n")
|
||||
.AsStatement(),
|
||||
Factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockRejectsNewlineBetweenEndAndCodeIfNotPrefixedWithUnderscore()
|
||||
{
|
||||
ParseBlockTest("Code" + Environment.NewLine
|
||||
+ " If foo IsNot Nothing" + Environment.NewLine
|
||||
+ " Bar(foo)" + Environment.NewLine
|
||||
+ " End If" + Environment.NewLine
|
||||
+ "End" + Environment.NewLine
|
||||
+ "Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n If foo IsNot Nothing\r\n Bar(foo)\r\n End If\r\nEnd\r\nCode")
|
||||
.AsStatement()),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Code", "End Code"),
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockAcceptsNewlineBetweenEndAndCodeIfPrefixedWithUnderscore()
|
||||
{
|
||||
ParseBlockTest("Code" + Environment.NewLine
|
||||
+ " If foo IsNot Nothing" + Environment.NewLine
|
||||
+ " Bar(foo)" + Environment.NewLine
|
||||
+ " End If" + Environment.NewLine
|
||||
+ "End _" + Environment.NewLine
|
||||
+ "_" + Environment.NewLine
|
||||
+ " _" + Environment.NewLine
|
||||
+ "Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n If foo IsNot Nothing\r\n Bar(foo)\r\n End If\r\n")
|
||||
.AsStatement(),
|
||||
Factory.MetaCode("End _\r\n_\r\n _\r\nCode").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockSupportsSimpleFunctionsBlock()
|
||||
{
|
||||
ParseBlockTest("Functions" + Environment.NewLine
|
||||
+ " Public Sub Foo()" + Environment.NewLine
|
||||
+ " Bar()" + Environment.NewLine
|
||||
+ " End Sub" + Environment.NewLine
|
||||
+ Environment.NewLine
|
||||
+ " Private Function Bar() As Object" + Environment.NewLine
|
||||
+ " Return Nothing" + Environment.NewLine
|
||||
+ " End Function" + Environment.NewLine
|
||||
+ "End Functions",
|
||||
new FunctionsBlock(
|
||||
Factory.MetaCode("Functions").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n Public Sub Foo()\r\n Bar()\r\n End Sub\r\n\r\n Private Function Bar() As Object\r\n Return Nothing\r\n End Function\r\n")
|
||||
.AsFunctionsBody(),
|
||||
Factory.MetaCode("End Functions").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockRejectsNewlineBetweenEndAndFunctionsIfNotPrefixedWithUnderscore()
|
||||
{
|
||||
ParseBlockTest("Functions" + Environment.NewLine
|
||||
+ " If foo IsNot Nothing" + Environment.NewLine
|
||||
+ " Bar(foo)" + Environment.NewLine
|
||||
+ " End If" + Environment.NewLine
|
||||
+ "End" + Environment.NewLine
|
||||
+ "Functions",
|
||||
new FunctionsBlock(
|
||||
Factory.MetaCode("Functions").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n If foo IsNot Nothing\r\n Bar(foo)\r\n End If\r\nEnd\r\nFunctions")
|
||||
.AsFunctionsBody()),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Functions", "End Functions"),
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockAcceptsNewlineBetweenEndAndFunctionsIfPrefixedWithUnderscore()
|
||||
{
|
||||
ParseBlockTest("Functions" + Environment.NewLine
|
||||
+ " If foo IsNot Nothing" + Environment.NewLine
|
||||
+ " Bar(foo)" + Environment.NewLine
|
||||
+ " End If" + Environment.NewLine
|
||||
+ "End _" + Environment.NewLine
|
||||
+ "_" + Environment.NewLine
|
||||
+ " _" + Environment.NewLine
|
||||
+ "Functions",
|
||||
new FunctionsBlock(
|
||||
Factory.MetaCode("Functions").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n If foo IsNot Nothing\r\n Bar(foo)\r\n End If\r\n")
|
||||
.AsFunctionsBody(),
|
||||
Factory.MetaCode("End _\r\n_\r\n _\r\nFunctions").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockCorrectlyHandlesExtraEndsInEndCode()
|
||||
{
|
||||
ParseBlockTest("Code" + Environment.NewLine
|
||||
+ " Bar End" + Environment.NewLine
|
||||
+ "End Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n Bar End\r\n").AsStatement(),
|
||||
Factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockCorrectlyHandlesExtraEndsInEndFunctions()
|
||||
{
|
||||
ParseBlockTest("Functions" + Environment.NewLine
|
||||
+ " Bar End" + Environment.NewLine
|
||||
+ "End Functions",
|
||||
new FunctionsBlock(
|
||||
Factory.MetaCode("Functions").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n Bar End\r\n").AsFunctionsBody().AutoCompleteWith(null, atEndOfSpan: false),
|
||||
Factory.MetaCode("End Functions").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("If", "End", "If")]
|
||||
[InlineData("Try", "End", "Try")]
|
||||
[InlineData("While", "End", "While")]
|
||||
[InlineData("Using", "End", "Using")]
|
||||
[InlineData("With", "End", "With")]
|
||||
public void KeywordAllowsNewlinesIfPrefixedByUnderscore(string startKeyword, string endKeyword1, string endKeyword2)
|
||||
{
|
||||
string code = startKeyword + Environment.NewLine
|
||||
+ " ' In the block" + Environment.NewLine
|
||||
+ endKeyword1 + " _" + Environment.NewLine
|
||||
+ "_" + Environment.NewLine
|
||||
+ "_" + Environment.NewLine
|
||||
+ "_" + Environment.NewLine
|
||||
+ "_" + Environment.NewLine
|
||||
+ "_" + Environment.NewLine
|
||||
+ " " + endKeyword2 + Environment.NewLine;
|
||||
ParseBlockTest(code + "foo bar baz",
|
||||
new StatementBlock(
|
||||
Factory.Code(code)
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("While", "EndWhile", "End While")]
|
||||
[InlineData("If", "EndIf", "End If")]
|
||||
[InlineData("Select", "EndSelect", "End Select")]
|
||||
[InlineData("Try", "EndTry", "End Try")]
|
||||
[InlineData("With", "EndWith", "End With")]
|
||||
[InlineData("Using", "EndUsing", "End Using")]
|
||||
public void EndTerminatedKeywordRequiresSpaceBetweenEndAndKeyword(string startKeyword, string wrongEndKeyword, string endKeyword)
|
||||
{
|
||||
string code = startKeyword + Environment.NewLine
|
||||
+ " ' This should not end the code" + Environment.NewLine
|
||||
+ " " + wrongEndKeyword + Environment.NewLine
|
||||
+ " ' But this should" + Environment.NewLine
|
||||
+ endKeyword;
|
||||
ParseBlockTest(code,
|
||||
new StatementBlock(
|
||||
Factory.Code(code)
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("While", "End While", false)]
|
||||
[InlineData("Do", "Loop", true)]
|
||||
[InlineData("If", "End If", false)]
|
||||
[InlineData("Select", "End Select", false)]
|
||||
[InlineData("For", "Next", true)]
|
||||
[InlineData("Try", "End Try", false)]
|
||||
[InlineData("With", "End With", false)]
|
||||
[InlineData("Using", "End Using", false)]
|
||||
public void EndSequenceInString(string keyword, string endSequence, bool acceptToEndOfLine)
|
||||
{
|
||||
string code = keyword + Environment.NewLine
|
||||
+ " \"" + endSequence + "\"" + Environment.NewLine
|
||||
+ endSequence + (acceptToEndOfLine ? " foo bar baz" : "") + Environment.NewLine;
|
||||
ParseBlockTest(code + "biz boz",
|
||||
new StatementBlock(
|
||||
Factory.Code(code).AsStatement().Accepts(GetAcceptedCharacters(acceptToEndOfLine))));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("While", "End While", false)]
|
||||
[InlineData("Do", "Loop", true)]
|
||||
[InlineData("If", "End If", false)]
|
||||
[InlineData("Select", "End Select", false)]
|
||||
[InlineData("For", "Next", true)]
|
||||
[InlineData("Try", "End Try", false)]
|
||||
[InlineData("With", "End With", false)]
|
||||
[InlineData("Using", "End Using", false)]
|
||||
private void CommentedEndSequence(string keyword, string endSequence, bool acceptToEndOfLine)
|
||||
{
|
||||
string code = keyword + Environment.NewLine
|
||||
+ " '" + endSequence + Environment.NewLine
|
||||
+ endSequence + (acceptToEndOfLine ? @" foo bar baz" : "") + Environment.NewLine;
|
||||
ParseBlockTest(code + "biz boz",
|
||||
new StatementBlock(
|
||||
Factory.Code(code).AsStatement().Accepts(GetAcceptedCharacters(acceptToEndOfLine))));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("While", "End While", false)]
|
||||
[InlineData("Do", "Loop", true)]
|
||||
[InlineData("If", "End If", false)]
|
||||
[InlineData("Select", "End Select", false)]
|
||||
[InlineData("For", "Next", true)]
|
||||
[InlineData("Try", "End Try", false)]
|
||||
[InlineData("With", "End With", false)]
|
||||
[InlineData("SyncLock", "End SyncLock", false)]
|
||||
[InlineData("Using", "End Using", false)]
|
||||
private void NestedKeywordBlock(string keyword, string endSequence, bool acceptToEndOfLine)
|
||||
{
|
||||
string code = keyword + Environment.NewLine
|
||||
+ " " + keyword + Environment.NewLine
|
||||
+ " Bar(foo)" + Environment.NewLine
|
||||
+ " " + endSequence + Environment.NewLine
|
||||
+ endSequence + (acceptToEndOfLine ? " foo bar baz" : "") + Environment.NewLine;
|
||||
ParseBlockTest(code + "biz boz",
|
||||
new StatementBlock(
|
||||
Factory.Code(code).AsStatement().Accepts(GetAcceptedCharacters(acceptToEndOfLine))));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("While True", "End While", false)]
|
||||
[InlineData("Do", "Loop", true)]
|
||||
[InlineData("If foo IsNot Nothing", "End If", false)]
|
||||
[InlineData("Select Case foo", "End Select", false)]
|
||||
[InlineData("For Each p in Products", "Next", true)]
|
||||
[InlineData("Try", "End Try", false)]
|
||||
[InlineData("With", "End With", false)]
|
||||
[InlineData("SyncLock", "End SyncLock", false)]
|
||||
[InlineData("Using", "End Using", false)]
|
||||
private void SimpleKeywordBlock(string keyword, string endSequence, bool acceptToEndOfLine)
|
||||
{
|
||||
string code = keyword + Environment.NewLine
|
||||
+ " Bar(foo)" + Environment.NewLine
|
||||
+ endSequence + (acceptToEndOfLine ? " foo bar baz" : "") + Environment.NewLine;
|
||||
ParseBlockTest(code + "biz boz",
|
||||
new StatementBlock(
|
||||
Factory.Code(code).AsStatement().Accepts(GetAcceptedCharacters(acceptToEndOfLine))));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("While True", "Exit While", "End While", false)]
|
||||
[InlineData("Do", "Exit Do", "Loop", true)]
|
||||
[InlineData("For Each p in Products", "Exit For", "Next", true)]
|
||||
[InlineData("While True", "Continue While", "End While", false)]
|
||||
[InlineData("Do", "Continue Do", "Loop", true)]
|
||||
[InlineData("For Each p in Products", "Continue For", "Next", true)]
|
||||
private void KeywordWithExitOrContinue(string startKeyword, string exitKeyword, string endKeyword, bool acceptToEndOfLine)
|
||||
{
|
||||
string code = startKeyword + Environment.NewLine
|
||||
+ " ' This is before the exit" + Environment.NewLine
|
||||
+ " " + exitKeyword + Environment.NewLine
|
||||
+ " ' This is after the exit" + Environment.NewLine
|
||||
+ endKeyword + Environment.NewLine;
|
||||
ParseBlockTest(code + "foo bar baz",
|
||||
new StatementBlock(
|
||||
Factory.Code(code).AsStatement().Accepts(GetAcceptedCharacters(acceptToEndOfLine))));
|
||||
}
|
||||
|
||||
private AcceptedCharacters GetAcceptedCharacters(bool acceptToEndOfLine)
|
||||
{
|
||||
return acceptToEndOfLine ?
|
||||
AcceptedCharacters.WhiteSpace | AcceptedCharacters.NonWhiteSpace :
|
||||
AcceptedCharacters.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
// VB Continue Statement: http://msdn.microsoft.com/en-us/library/801hyx6f.aspx
|
||||
public class VBContinueStatementTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void VB_Do_Statement_With_Continue()
|
||||
{
|
||||
ParseBlockTest("@Do While True" + Environment.NewLine
|
||||
+ " Continue Do" + Environment.NewLine
|
||||
+ "Loop" + Environment.NewLine
|
||||
+ "' Not in the block!",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Do While True\r\n Continue Do\r\nLoop\r\n")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.AnyExceptNewline)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_For_Statement_With_Continue()
|
||||
{
|
||||
ParseBlockTest("@For i = 1 To 12" + Environment.NewLine
|
||||
+ " Continue For" + Environment.NewLine
|
||||
+ "Next i" + Environment.NewLine
|
||||
+ "' Not in the block!",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("For i = 1 To 12\r\n Continue For\r\nNext i\r\n")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.AnyExceptNewline)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_While_Statement_With_Continue()
|
||||
{
|
||||
ParseBlockTest("@While True" + Environment.NewLine
|
||||
+ " Continue While" + Environment.NewLine
|
||||
+ "End While" + Environment.NewLine
|
||||
+ "' Not in the block!",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("While True\r\n Continue While\r\nEnd While\r\n")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBDirectiveTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void VB_Code_Directive()
|
||||
{
|
||||
ParseBlockTest("@Code" + Environment.NewLine
|
||||
+ " foo()" + Environment.NewLine
|
||||
+ "End Code" + Environment.NewLine
|
||||
+ "' Not part of the block",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("Code")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n foo()\r\n")
|
||||
.AsStatement()
|
||||
.With(new AutoCompleteEditHandler(VBLanguageCharacteristics.Instance.TokenizeString)),
|
||||
Factory.MetaCode("End Code")
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Functions_Directive()
|
||||
{
|
||||
ParseBlockTest("@Functions" + Environment.NewLine
|
||||
+ " Public Function Foo() As String" + Environment.NewLine
|
||||
+ " Return \"Foo\"" + Environment.NewLine
|
||||
+ " End Function" + Environment.NewLine
|
||||
+ Environment.NewLine
|
||||
+ " Public Sub Bar()" + Environment.NewLine
|
||||
+ " End Sub" + Environment.NewLine
|
||||
+ "End Functions" + Environment.NewLine
|
||||
+ "' Not part of the block",
|
||||
new FunctionsBlock(
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("Functions")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n Public Function Foo() As String\r\n Return \"Foo\"\r\n End Function\r\n\r\n Public Sub Bar()\r\n End Sub\r\n")
|
||||
.AsFunctionsBody(),
|
||||
Factory.MetaCode("End Functions")
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Section_Directive()
|
||||
{
|
||||
ParseBlockTest("@Section Header" + Environment.NewLine
|
||||
+ " <p>Foo</p>" + Environment.NewLine
|
||||
+ "End Section",
|
||||
new SectionBlock(new SectionCodeGenerator("Header"),
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString),
|
||||
Factory.MetaCode("Section Header"),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n <p>Foo</p>\r\n")),
|
||||
Factory.MetaCode("End Section")
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SessionStateDirectiveWorks()
|
||||
{
|
||||
ParseBlockTest("@SessionState InProc" + Environment.NewLine,
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("SessionState ")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("InProc\r\n")
|
||||
.Accepts(AcceptedCharacters.None)
|
||||
.With(new RazorDirectiveAttributeCodeGenerator("SessionState", "InProc"))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SessionStateDirectiveIsCaseInsensitive()
|
||||
{
|
||||
ParseBlockTest("@sessionstate disabled" + Environment.NewLine,
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("sessionstate ")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("disabled\r\n")
|
||||
.Accepts(AcceptedCharacters.None)
|
||||
.With(new RazorDirectiveAttributeCodeGenerator("SessionState", "disabled"))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Helper_Directive()
|
||||
{
|
||||
ParseBlockTest("@Helper Strong(s as String)" + Environment.NewLine
|
||||
+ " s = s.ToUpperCase()" + Environment.NewLine
|
||||
+ " @<strong>s</strong>" + Environment.NewLine
|
||||
+ "End Helper",
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Strong(s as String)", 8, 0, 8), headerComplete: true),
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString),
|
||||
Factory.MetaCode("Helper ")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Strong(s as String)").Hidden(),
|
||||
new StatementBlock(
|
||||
Factory.Code("\r\n s = s.ToUpperCase()\r\n")
|
||||
.AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(SyntaxConstants.TransitionString),
|
||||
Factory.Markup("<strong>s</strong>\r\n")
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyVB()
|
||||
.AsStatement(),
|
||||
Factory.MetaCode("End Helper")
|
||||
.Accepts(AcceptedCharacters.None))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,174 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Editor;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBErrorTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ParserOutputsErrorAndRecoversToEndOfLineIfExplicitExpressionUnterminated()
|
||||
{
|
||||
ParseBlockTest(@"(foo
|
||||
bar",
|
||||
new ExpressionBlock(
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("foo").AsExpression()),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF,
|
||||
RazorResources.BlockName_ExplicitExpression,
|
||||
")", "("),
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParserOutputsZeroLengthCodeSpanIfEofReachedAfterStartOfExplicitExpression()
|
||||
{
|
||||
ParseBlockTest("(",
|
||||
new ExpressionBlock(
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.EmptyVB().AsExpression()),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF, "explicit expression", ")", "("),
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParserOutputsZeroLengthCodeSpanIfEofReachedAfterAtSign()
|
||||
{
|
||||
ParseBlockTest(String.Empty,
|
||||
new ExpressionBlock(
|
||||
Factory.EmptyVB().AsImplicitExpression(KeywordSet).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
new RazorError(
|
||||
RazorResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock,
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParserOutputsZeroLengthCodeSpanIfOnlyWhitespaceFoundAfterAtSign()
|
||||
{
|
||||
ParseBlockTest(" ",
|
||||
new ExpressionBlock(
|
||||
Factory.EmptyVB().AsImplicitExpression(KeywordSet).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
new RazorError(
|
||||
RazorResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_VB,
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParserOutputsZeroLengthCodeSpanIfInvalidCharacterFoundAfterAtSign()
|
||||
{
|
||||
ParseBlockTest("!!!",
|
||||
new ExpressionBlock(
|
||||
Factory.EmptyVB().AsImplicitExpression(KeywordSet).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock_VB, "!"),
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Code", "End Code", true, true)]
|
||||
[InlineData("Do", "Loop", false, false)]
|
||||
[InlineData("While", "End While", false, false)]
|
||||
[InlineData("If", "End If", false, false)]
|
||||
[InlineData("Select Case", "End Select", false, false)]
|
||||
[InlineData("For", "Next", false, false)]
|
||||
[InlineData("Try", "End Try", false, false)]
|
||||
[InlineData("With", "End With", false, false)]
|
||||
[InlineData("Using", "End Using", false, false)]
|
||||
public void EofBlock(string keyword, string expectedTerminator, bool autoComplete, bool keywordIsMetaCode)
|
||||
{
|
||||
EofBlockCore(keyword, expectedTerminator, autoComplete, BlockType.Statement, keywordIsMetaCode, c => c.AsStatement());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EofFunctionsBlock()
|
||||
{
|
||||
EofBlockCore("Functions", "End Functions", true, BlockType.Functions, true, c => c.AsFunctionsBody());
|
||||
}
|
||||
|
||||
private void EofBlockCore(string keyword, string expectedTerminator, bool autoComplete, BlockType blockType, bool keywordIsMetaCode, Func<UnclassifiedCodeSpanConstructor, SpanConstructor> classifier)
|
||||
{
|
||||
BlockBuilder expected = new BlockBuilder();
|
||||
expected.Type = blockType;
|
||||
if (keywordIsMetaCode)
|
||||
{
|
||||
expected.Children.Add(Factory.MetaCode(keyword).Accepts(AcceptedCharacters.None));
|
||||
expected.Children.Add(
|
||||
classifier(Factory.EmptyVB())
|
||||
.With((SpanEditHandler)(
|
||||
autoComplete ?
|
||||
new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = expectedTerminator } :
|
||||
SpanEditHandler.CreateDefault())));
|
||||
}
|
||||
else
|
||||
{
|
||||
expected.Children.Add(
|
||||
classifier(Factory.Code(keyword))
|
||||
.With((SpanEditHandler)(
|
||||
autoComplete ?
|
||||
new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = expectedTerminator } :
|
||||
SpanEditHandler.CreateDefault())));
|
||||
}
|
||||
|
||||
ParseBlockTest(keyword,
|
||||
expected.Build(),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, keyword, expectedTerminator),
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Code", "End Code", true)]
|
||||
[InlineData("Do", "Loop", false)]
|
||||
[InlineData("While", "End While", false)]
|
||||
[InlineData("If", "End If", false)]
|
||||
[InlineData("Select Case", "End Select", false)]
|
||||
[InlineData("For", "Next", false)]
|
||||
[InlineData("Try", "End Try", false)]
|
||||
[InlineData("With", "End With", false)]
|
||||
[InlineData("Using", "End Using", false)]
|
||||
public void UnterminatedBlock(string keyword, string expectedTerminator, bool keywordIsMetaCode)
|
||||
{
|
||||
UnterminatedBlockCore(keyword, expectedTerminator, BlockType.Statement, keywordIsMetaCode, c => c.AsStatement());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnterminatedFunctionsBlock()
|
||||
{
|
||||
UnterminatedBlockCore("Functions", "End Functions", BlockType.Functions, true, c => c.AsFunctionsBody());
|
||||
}
|
||||
|
||||
private void UnterminatedBlockCore(string keyword, string expectedTerminator, BlockType blockType, bool keywordIsMetaCode, Func<UnclassifiedCodeSpanConstructor, SpanConstructor> classifier)
|
||||
{
|
||||
const string blockBody = @"
|
||||
' This block is not correctly terminated!";
|
||||
|
||||
BlockBuilder expected = new BlockBuilder();
|
||||
expected.Type = blockType;
|
||||
if (keywordIsMetaCode)
|
||||
{
|
||||
expected.Children.Add(Factory.MetaCode(keyword).Accepts(AcceptedCharacters.None));
|
||||
expected.Children.Add(classifier(Factory.Code(blockBody)));
|
||||
}
|
||||
else
|
||||
{
|
||||
expected.Children.Add(classifier(Factory.Code(keyword + blockBody)));
|
||||
}
|
||||
|
||||
ParseBlockTest(keyword + blockBody,
|
||||
expected.Build(),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, keyword, expectedTerminator),
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
// VB Exit Statement: http://msdn.microsoft.com/en-us/library/t2at9t47.aspx
|
||||
public class VBExitStatementTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void VB_Do_Statement_With_Exit()
|
||||
{
|
||||
ParseBlockTest("@Do While True" + Environment.NewLine
|
||||
+ " Exit Do" + Environment.NewLine
|
||||
+ "Loop" + Environment.NewLine
|
||||
+ "' Not in the block!",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Do While True\r\n Exit Do\r\nLoop\r\n")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.AnyExceptNewline)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_For_Statement_With_Exit()
|
||||
{
|
||||
ParseBlockTest("@For i = 1 To 12" + Environment.NewLine
|
||||
+ " Exit For" + Environment.NewLine
|
||||
+ "Next i" + Environment.NewLine
|
||||
+ "' Not in the block!",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("For i = 1 To 12\r\n Exit For\r\nNext i\r\n")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.AnyExceptNewline)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Select_Statement_With_Exit()
|
||||
{
|
||||
ParseBlockTest("@Select Case Foo" + Environment.NewLine
|
||||
+ " Case 1" + Environment.NewLine
|
||||
+ " Exit Select" + Environment.NewLine
|
||||
+ " Case 2" + Environment.NewLine
|
||||
+ " Exit Select" + Environment.NewLine
|
||||
+ "End Select" + Environment.NewLine
|
||||
+ "' Not in the block!",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Select Case Foo\r\n Case 1\r\n Exit Select\r\n Case 2\r\n Exit Select\r\nEnd Select\r\n")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Try_Statement_With_Exit()
|
||||
{
|
||||
ParseBlockTest("@Try" + Environment.NewLine
|
||||
+ " Foo()" + Environment.NewLine
|
||||
+ " Exit Try" + Environment.NewLine
|
||||
+ "Catch Bar" + Environment.NewLine
|
||||
+ " Throw Bar" + Environment.NewLine
|
||||
+ "Finally" + Environment.NewLine
|
||||
+ " Baz()" + Environment.NewLine
|
||||
+ "End Try" + Environment.NewLine
|
||||
+ "' Not in the block!",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Try\r\n Foo()\r\n Exit Try\r\nCatch Bar\r\n Throw Bar\r\nFinally\r\n Baz()\r\nEnd Try\r\n")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_While_Statement_With_Exit()
|
||||
{
|
||||
ParseBlockTest("@While True" + Environment.NewLine
|
||||
+ " Exit While" + Environment.NewLine
|
||||
+ "End While" + Environment.NewLine
|
||||
+ "' Not in the block!",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(SyntaxConstants.TransitionString)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("While True\r\n Exit While\r\nEnd While\r\n")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBExplicitExpressionTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void VB_Simple_ExplicitExpression()
|
||||
{
|
||||
ParseBlockTest("@(foo)",
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("foo").AsExpression(),
|
||||
Factory.MetaCode(")").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBExpressionTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ParseBlockCorrectlyHandlesCodeBlockInBodyOfExplicitExpressionDueToUnclosedExpression()
|
||||
{
|
||||
ParseBlockTest(@"(
|
||||
@Code
|
||||
Dim foo = bar
|
||||
End Code",
|
||||
new ExpressionBlock(
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.EmptyVB().AsExpression()),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF,
|
||||
RazorResources.BlockName_ExplicitExpression,
|
||||
")", "("),
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockAcceptsNonEnglishCharactersThatAreValidIdentifiers()
|
||||
{
|
||||
ImplicitExpressionTest("हळूँजद॔.", "हळूँजद॔");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockDoesNotTreatXmlAxisPropertyAsTransitionToMarkup()
|
||||
{
|
||||
SingleSpanBlockTest(
|
||||
@"If foo Is Nothing Then
|
||||
Dim bar As XElement
|
||||
Dim foo = bar.<foo>
|
||||
End If",
|
||||
BlockType.Statement,
|
||||
SpanKind.Code,
|
||||
acceptedCharacters: AcceptedCharacters.None);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockDoesNotTreatXmlAttributePropertyAsTransitionToMarkup()
|
||||
{
|
||||
SingleSpanBlockTest(
|
||||
@"If foo Is Nothing Then
|
||||
Dim bar As XElement
|
||||
Dim foo = bar.@foo
|
||||
End If",
|
||||
BlockType.Statement,
|
||||
SpanKind.Code,
|
||||
acceptedCharacters: AcceptedCharacters.None);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockSupportsSimpleImplicitExpression()
|
||||
{
|
||||
ImplicitExpressionTest("Foo");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockSupportsImplicitExpressionWithDots()
|
||||
{
|
||||
ImplicitExpressionTest("Foo.Bar.Baz");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockSupportsImplicitExpressionWithParens()
|
||||
{
|
||||
ImplicitExpressionTest("Foo().Bar().Baz()");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockSupportsImplicitExpressionWithStuffInParens()
|
||||
{
|
||||
ImplicitExpressionTest("Foo().Bar(sdfkhj sdfksdfjs \")\" sjdfkjsdf).Baz()");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockSupportsImplicitExpressionWithCommentInParens()
|
||||
{
|
||||
ImplicitExpressionTest("Foo().Bar(sdfkhj sdfksdfjs \")\" '))))))))\r\nsjdfkjsdf).Baz()");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Foo")]
|
||||
[InlineData("Foo(Of String).Bar(1, 2, 3).Biz")]
|
||||
[InlineData("Foo(Of String).Bar(\")\").Biz")]
|
||||
[InlineData("Foo(Of String).Bar(\"Foo\"\"Bar)\"\"Baz\").Biz")]
|
||||
[InlineData("\"foo\r\nbar")]
|
||||
[InlineData("Foo.Bar. _\r\nREM )\r\nBaz()\r\n")]
|
||||
[InlineData("Foo.Bar. _\r\n' )\r\nBaz()\r\n")]
|
||||
public void ValidExplicitExpressions(string body)
|
||||
{
|
||||
ParseBlockTest("(" + body + ")",
|
||||
new ExpressionBlock(
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code(body).AsExpression(),
|
||||
Factory.MetaCode(")").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBExpressionsInCodeTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void InnerImplicitExpressionWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime()
|
||||
{
|
||||
ParseBlockTest("Code" + Environment.NewLine
|
||||
+ " @" + Environment.NewLine
|
||||
+ "End Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.EmptyVB()
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
Factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)),
|
||||
designTimeParser: true,
|
||||
expectedErrors: new[]
|
||||
{
|
||||
new RazorError(RazorResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_VB, 11, 1, 5)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InnerImplicitExpressionDoesNotAcceptDotAfterAt()
|
||||
{
|
||||
ParseBlockTest("Code" + Environment.NewLine
|
||||
+ " @." + Environment.NewLine
|
||||
+ "End Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.EmptyVB()
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Code(".\r\n").AsStatement(),
|
||||
Factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)),
|
||||
designTimeParser: true,
|
||||
expectedErrors: new[]
|
||||
{
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock_VB, "."),
|
||||
11, 1, 5)
|
||||
});
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Foo.Bar.", true)]
|
||||
[InlineData("Foo", true)]
|
||||
[InlineData("Foo.Bar.Baz", true)]
|
||||
[InlineData("Foo().Bar().Baz()", true)]
|
||||
[InlineData("Foo().Bar(sdfkhj sdfksdfjs \")\" sjdfkjsdf).Baz()", true)]
|
||||
[InlineData("Foo().Bar(sdfkhj sdfksdfjs \")\" '))))))))\r\nsjdfkjsdf).Baz()", true)]
|
||||
[InlineData("Foo", false)]
|
||||
[InlineData("Foo(Of String).Bar(1, 2, 3).Biz", false)]
|
||||
[InlineData("Foo(Of String).Bar(\")\").Biz", false)]
|
||||
[InlineData("Foo(Of String).Bar(\"Foo\"\"Bar)\"\"Baz\").Biz", false)]
|
||||
[InlineData("Foo.Bar. _\r\nREM )\r\nBaz()\r\n", false)]
|
||||
[InlineData("Foo.Bar. _\r\n' )\r\nBaz()\r\n", false)]
|
||||
public void ExpressionInCode(string expression, bool isImplicit)
|
||||
{
|
||||
ExpressionBlock expressionBlock;
|
||||
if (isImplicit)
|
||||
{
|
||||
expressionBlock =
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code(expression)
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords, acceptTrailingDot: true)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace));
|
||||
}
|
||||
else
|
||||
{
|
||||
expressionBlock =
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code(expression).AsExpression(),
|
||||
Factory.MetaCode(")").Accepts(AcceptedCharacters.None));
|
||||
}
|
||||
|
||||
string code;
|
||||
if (isImplicit)
|
||||
{
|
||||
code = "If foo IsNot Nothing Then" + Environment.NewLine
|
||||
+ " @" + expression + Environment.NewLine
|
||||
+ "End If";
|
||||
}
|
||||
else
|
||||
{
|
||||
code = "If foo IsNot Nothing Then" + Environment.NewLine
|
||||
+ " @(" + expression + ")" + Environment.NewLine
|
||||
+ "End If";
|
||||
}
|
||||
|
||||
ParseBlockTest(code,
|
||||
new StatementBlock(
|
||||
Factory.Code("If foo IsNot Nothing Then\r\n ")
|
||||
.AsStatement(),
|
||||
expressionBlock,
|
||||
Factory.Code("\r\nEnd If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,324 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBHelperTest : VBHtmlMarkupParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ParseHelperOutputsErrorButContinuesIfLParenFoundAfterHelperKeyword()
|
||||
{
|
||||
ParseDocumentTest("@Helper ()",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("()", 8, 0, 8), headerComplete: true),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("()").Hidden().AutoCompleteWith(SyntaxConstants.VB.EndHelperKeyword),
|
||||
new StatementBlock())),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start,
|
||||
String.Format(RazorResources.ErrorComponent_Character, "(")),
|
||||
8, 0, 8),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Helper", "End Helper"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementOutputsMarkerHelperHeaderSpanOnceKeywordComplete()
|
||||
{
|
||||
ParseDocumentTest("@Helper ",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>(String.Empty, 8, 0, 8), headerComplete: false),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.EmptyVB().Hidden())),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start, RazorResources.ErrorComponent_EndOfFile),
|
||||
8, 0, 8));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementMarksHelperSpanAsCanGrowIfMissingTrailingSpace()
|
||||
{
|
||||
ParseDocumentTest("@Helper",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper"))),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start, RazorResources.ErrorComponent_EndOfFile),
|
||||
7, 0, 7));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementTerminatesEarlyIfHeaderNotComplete()
|
||||
{
|
||||
ParseDocumentTest("@Helper" + Environment.NewLine
|
||||
+ "@Helper",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper\r\n").Accepts(AcceptedCharacters.None),
|
||||
Factory.EmptyVB().Hidden()),
|
||||
new HelperBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper"))),
|
||||
designTimeParser: true,
|
||||
expectedErrors: new[]
|
||||
{
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start,
|
||||
String.Format(RazorResources.ErrorComponent_Character, "@")),
|
||||
9, 1, 0),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start,
|
||||
RazorResources.ErrorComponent_EndOfFile),
|
||||
16, 1, 7)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementTerminatesEarlyIfHeaderNotCompleteWithSpace()
|
||||
{
|
||||
ParseDocumentTest(@"@Helper @Helper",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>(String.Empty, 8, 0, 8), headerComplete: false),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode(@"Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.EmptyVB().Hidden()),
|
||||
new HelperBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper").Accepts(AcceptedCharacters.Any))),
|
||||
designTimeParser: true,
|
||||
expectedErrors: new[]
|
||||
{
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start,
|
||||
String.Format(RazorResources.ErrorComponent_Character, "@")),
|
||||
8, 0, 8),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start,
|
||||
RazorResources.ErrorComponent_EndOfFile),
|
||||
15, 0, 15)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementAllowsDifferentlyCasedEndHelperKeyword()
|
||||
{
|
||||
ParseDocumentTest("@Helper Foo()" + Environment.NewLine
|
||||
+ "end helper",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo()", 8, 0, 8), headerComplete: true),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Foo()").Hidden(),
|
||||
new StatementBlock(
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
Factory.MetaCode("end helper").Accepts(AcceptedCharacters.None))),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementCapturesWhitespaceToEndOfLineIfHelperStatementMissingName()
|
||||
{
|
||||
ParseDocumentTest("@Helper " + Environment.NewLine
|
||||
+ " ",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>(" ", 8, 0, 8), headerComplete: false),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code(" ").Hidden()),
|
||||
Factory.Markup("\r\n ")),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start,
|
||||
RazorResources.ErrorComponent_Newline),
|
||||
30, 0, 30));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementCapturesWhitespaceToEndOfLineIfHelperStatementMissingOpenParen()
|
||||
{
|
||||
ParseDocumentTest("@Helper Foo " + Environment.NewLine
|
||||
+ " ",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo ", 8, 0, 8), headerComplete: false),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Foo ").Hidden()),
|
||||
Factory.Markup("\r\n ")),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_MissingCharAfterHelperName, "("),
|
||||
15, 0, 15));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementCapturesAllContentToEndOfFileIfHelperStatementMissingCloseParenInParameterList()
|
||||
{
|
||||
ParseDocumentTest("@Helper Foo(Foo Bar" + Environment.NewLine
|
||||
+ "Biz" + Environment.NewLine
|
||||
+ "Boz",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(Foo Bar\r\nBiz\r\nBoz", 8, 0, 8), headerComplete: false),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Foo(Foo Bar\r\nBiz\r\nBoz").Hidden())),
|
||||
new RazorError(RazorResources.ParseError_UnterminatedHelperParameterList, 11, 0, 11));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementCapturesWhitespaceToEndOfLineIfHelperStatementMissingOpenBraceAfterParameterList()
|
||||
{
|
||||
ParseDocumentTest("@Helper Foo(foo as String) " + Environment.NewLine,
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(foo as String)", 8, 0, 8), headerComplete: true),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Foo(foo as String)")
|
||||
.Hidden()
|
||||
.AutoCompleteWith(SyntaxConstants.VB.EndHelperKeyword),
|
||||
new StatementBlock(
|
||||
Factory.Code(" \r\n").AsStatement()))),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Helper", "End Helper"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementContinuesParsingHelperUntilEOF()
|
||||
{
|
||||
ParseDocumentTest("@Helper Foo(foo as String)" + Environment.NewLine
|
||||
+ " @<p>Foo</p>",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(foo as String)", 8, 0, 8), headerComplete: true),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Foo(foo as String)")
|
||||
.Hidden()
|
||||
.AutoCompleteWith(SyntaxConstants.VB.EndHelperKeyword),
|
||||
new StatementBlock(
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.Markup("<p>Foo</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyVB().AsStatement()))),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_BlockNotTerminated, "Helper", "End Helper"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementCorrectlyParsesHelperWithEmbeddedCode()
|
||||
{
|
||||
ParseDocumentTest("@Helper Foo(foo as String, bar as String)" + Environment.NewLine
|
||||
+ " @<p>@foo</p>" + Environment.NewLine
|
||||
+ "End Helper",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(foo as String, bar as String)", 8, 0, 8), headerComplete: true),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Foo(foo as String, bar as String)").Hidden(),
|
||||
new StatementBlock(
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.Markup("<p>"),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Markup("</p>\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyVB().AsStatement(),
|
||||
Factory.MetaCode("End Helper").Accepts(AcceptedCharacters.None))),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperStatementGivesWhitespaceAfterCloseParenToMarkup()
|
||||
{
|
||||
ParseDocumentTest("@Helper Foo(string foo) " + Environment.NewLine
|
||||
+ " ",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(string foo)", 8, 0, 8), headerComplete: true),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Foo(string foo)")
|
||||
.Hidden()
|
||||
.AutoCompleteWith(SyntaxConstants.VB.EndHelperKeyword),
|
||||
new StatementBlock(
|
||||
Factory.Code(" \r\n ").AsStatement()))),
|
||||
designTimeParser: true,
|
||||
expectedErrors:
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_BlockNotTerminated,
|
||||
"Helper", "End Helper"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseHelperAcceptsNestedHelpersButOutputsError()
|
||||
{
|
||||
ParseDocumentTest("@Helper Foo(string foo)" + Environment.NewLine
|
||||
+ " @Helper Bar(string baz)" + Environment.NewLine
|
||||
+ " End Helper" + Environment.NewLine
|
||||
+ "End Helper",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(string foo)", 8, 0, 8), headerComplete: true),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Foo(string foo)").Hidden(),
|
||||
new StatementBlock(
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Bar(string baz)", 37, 1, 12), headerComplete: true),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Helper ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Bar(string baz)").Hidden(),
|
||||
new StatementBlock(
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
Factory.MetaCode("End Helper").Accepts(AcceptedCharacters.None))),
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
Factory.MetaCode("End Helper").Accepts(AcceptedCharacters.None))),
|
||||
Factory.EmptyHtml()),
|
||||
designTimeParser: true,
|
||||
expectedErrors: new[]
|
||||
{
|
||||
new RazorError(
|
||||
RazorResources.ParseError_Helpers_Cannot_Be_Nested,
|
||||
30, 1, 5)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,251 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBHtmlDocumentTest : VBHtmlMarkupParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void BlockCommentInMarkupDocumentIsHandledCorrectly()
|
||||
{
|
||||
ParseDocumentTest(@"<ul>" + Environment.NewLine
|
||||
+ @" @* This is a block comment </ul> *@ foo",
|
||||
new MarkupBlock(
|
||||
Factory.Markup("<ul>" + Environment.NewLine + " "),
|
||||
new CommentBlock(
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.Comment(" This is a block comment </ul> ", HtmlSymbolType.RazorComment),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)),
|
||||
Factory.Markup(" foo")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentInMarkupBlockIsHandledCorrectly()
|
||||
{
|
||||
ParseBlockTest(@"<ul>" + Environment.NewLine
|
||||
+ @" @* This is a block comment </ul> *@ foo </ul>",
|
||||
new MarkupBlock(
|
||||
Factory.Markup("<ul>" + Environment.NewLine + " "),
|
||||
new CommentBlock(
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.Comment(" This is a block comment </ul> ", HtmlSymbolType.RazorComment),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)),
|
||||
Factory.Markup(" foo </ul>").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentAtStatementStartInCodeBlockIsHandledCorrectly()
|
||||
{
|
||||
ParseDocumentTest(@"@If Request.IsAuthenticated Then" + Environment.NewLine
|
||||
+ @" @* User is logged in! End If *@" + Environment.NewLine
|
||||
+ @" Write(""Hello friend!"")" + Environment.NewLine
|
||||
+ @"End If",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If Request.IsAuthenticated Then" + Environment.NewLine + " ").AsStatement(),
|
||||
new CommentBlock(
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.Comment(" User is logged in! End If ", VBSymbolType.RazorComment),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition)),
|
||||
Factory.Code("" + Environment.NewLine + " Write(\"Hello friend!\")" + Environment.NewLine + "End If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentInStatementInCodeBlockIsHandledCorrectly()
|
||||
{
|
||||
ParseDocumentTest(@"@If Request.IsAuthenticated Then" + Environment.NewLine
|
||||
+ @" Dim foo = @* User is logged in! End If *@ bar" + Environment.NewLine
|
||||
+ @" Write(""Hello friend!"")" + Environment.NewLine
|
||||
+ @"End If",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If Request.IsAuthenticated Then" + Environment.NewLine + " Dim foo = ").AsStatement(),
|
||||
new CommentBlock(
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.Comment(" User is logged in! End If ", VBSymbolType.RazorComment),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition)),
|
||||
Factory.Code(" bar" + Environment.NewLine + " Write(\"Hello friend!\")" + Environment.NewLine + "End If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentInStringInCodeBlockIsIgnored()
|
||||
{
|
||||
ParseDocumentTest(@"@If Request.IsAuthenticated Then" + Environment.NewLine
|
||||
+ @" Dim foo = ""@* User is logged in! End If *@ bar""" + Environment.NewLine
|
||||
+ @" Write(""Hello friend!"")" + Environment.NewLine
|
||||
+ @"End If",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If Request.IsAuthenticated Then" + Environment.NewLine + " Dim foo = \"@* User is logged in! End If *@ bar\"" + Environment.NewLine + " Write(\"Hello friend!\")" + Environment.NewLine + "End If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentInTickCommentInCodeBlockIsIgnored()
|
||||
{
|
||||
ParseDocumentTest(@"@If Request.IsAuthenticated Then" + Environment.NewLine
|
||||
+ @" Dim foo = '@* User is logged in! End If *@ bar" + Environment.NewLine
|
||||
+ @" Write(""Hello friend!"")" + Environment.NewLine
|
||||
+ @"End If",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If Request.IsAuthenticated Then" + Environment.NewLine + " Dim foo = '@* User is logged in! End If *@ bar" + Environment.NewLine + " Write(\"Hello friend!\")" + Environment.NewLine + "End If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentInRemCommentInCodeBlockIsIgnored()
|
||||
{
|
||||
ParseDocumentTest(@"@If Request.IsAuthenticated Then" + Environment.NewLine
|
||||
+ @" Dim foo = REM @* User is logged in! End If *@ bar" + Environment.NewLine
|
||||
+ @" Write(""Hello friend!"")" + Environment.NewLine
|
||||
+ @"End If",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If Request.IsAuthenticated Then" + Environment.NewLine + " Dim foo = REM @* User is logged in! End If *@ bar" + Environment.NewLine + " Write(\"Hello friend!\")" + Environment.NewLine + "End If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentInImplicitExpressionIsHandledCorrectly()
|
||||
{
|
||||
ParseDocumentTest("@Html.Foo@*bar*@",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Html.Foo")
|
||||
.AsImplicitExpression(KeywordSet)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.EmptyHtml(),
|
||||
new CommentBlock(
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.Comment("bar", HtmlSymbolType.RazorComment),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentAfterDotOfImplicitExpressionIsHandledCorrectly()
|
||||
{
|
||||
ParseDocumentTest("@Html.@*bar*@",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Html")
|
||||
.AsImplicitExpression(KeywordSet)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Markup("."),
|
||||
new CommentBlock(
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.Comment("bar", HtmlSymbolType.RazorComment),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentInParensOfImplicitExpressionIsHandledCorrectly()
|
||||
{
|
||||
ParseDocumentTest("@Html.Foo(@*bar*@ 4)",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Html.Foo(")
|
||||
.AsImplicitExpression(KeywordSet)
|
||||
.Accepts(AcceptedCharacters.Any),
|
||||
new CommentBlock(
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.Comment("bar", VBSymbolType.RazorComment),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition)),
|
||||
Factory.Code(" 4)")
|
||||
.AsImplicitExpression(KeywordSet)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentInConditionIsHandledCorrectly()
|
||||
{
|
||||
ParseDocumentTest("@If @*bar*@ Then End If",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If ").AsStatement(),
|
||||
new CommentBlock(
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.Comment("bar", VBSymbolType.RazorComment),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition)),
|
||||
Factory.Code(" Then End If").AsStatement().Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockCommentInExplicitExpressionIsHandledCorrectly()
|
||||
{
|
||||
ParseDocumentTest(@"@(1 + @*bar*@ 1)",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code(@"1 + ").AsExpression(),
|
||||
new CommentBlock(
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.Comment("bar", VBSymbolType.RazorComment),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None),
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition)
|
||||
),
|
||||
Factory.Code(" 1").AsExpression(),
|
||||
Factory.MetaCode(")").Accepts(AcceptedCharacters.None)
|
||||
),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBImplicitExpressionTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void VB_Simple_ImplicitExpression()
|
||||
{
|
||||
ParseBlockTest("@foo not-part-of-the-block",
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_ImplicitExpression_With_Keyword_At_Start()
|
||||
{
|
||||
ParseBlockTest("@Partial",
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Partial")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_ImplicitExpression_With_Keyword_In_Body()
|
||||
{
|
||||
ParseBlockTest("@Html.Partial",
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Html.Partial")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_ImplicitExpression_With_MethodCallOrArrayIndex()
|
||||
{
|
||||
ParseBlockTest("@foo(42) not-part-of-the-block",
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo(42)")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_ImplicitExpression_Terminates_If_Trailing_Dot_Not_Followed_By_Valid_Token()
|
||||
{
|
||||
ParseBlockTest("@foo(42). ",
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo(42)")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_ImplicitExpression_Supports_Complex_Expressions()
|
||||
{
|
||||
ParseBlockTest("@foo(42).bar(Biz.Boz / 42 * 8)(1).Burf not part of the block",
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition()
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("foo(42).bar(Biz.Boz / 42 * 8)(1).Burf")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Editor;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBLayoutDirectiveTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("layout")]
|
||||
[InlineData("Layout")]
|
||||
[InlineData("LAYOUT")]
|
||||
[InlineData("layOut")]
|
||||
[InlineData("LayOut")]
|
||||
[InlineData("LaYoUt")]
|
||||
[InlineData("lAyOuT")]
|
||||
public void LayoutDirectiveSupportsAnyCasingOfKeyword(string keyword)
|
||||
{
|
||||
ParseBlockTest("@" + keyword,
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode(keyword)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LayoutDirectiveAcceptsAllTextToEndOfLine()
|
||||
{
|
||||
ParseBlockTest("@Layout Foo Bar Baz",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Layout ").Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("Foo Bar Baz")
|
||||
.With(new SetLayoutCodeGenerator("Foo Bar Baz"))
|
||||
.WithEditorHints(EditorHints.VirtualPath | EditorHints.LayoutPage)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LayoutDirectiveAcceptsAnyIfNoWhitespaceFollowingLayoutKeyword()
|
||||
{
|
||||
ParseBlockTest("@Layout",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Layout")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LayoutDirectiveOutputsMarkerSpanIfAnyWhitespaceAfterLayoutKeyword()
|
||||
{
|
||||
ParseBlockTest("@Layout ",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Layout ").Accepts(AcceptedCharacters.None),
|
||||
Factory.EmptyVB()
|
||||
.AsMetaCode()
|
||||
.With(new SetLayoutCodeGenerator(String.Empty))
|
||||
.WithEditorHints(EditorHints.VirtualPath | EditorHints.LayoutPage)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LayoutDirectiveAcceptsTrailingNewlineButDoesNotIncludeItInLayoutPath()
|
||||
{
|
||||
ParseBlockTest("@Layout Foo" + Environment.NewLine,
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Layout ").Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("Foo\r\n")
|
||||
.With(new SetLayoutCodeGenerator("Foo"))
|
||||
.Accepts(AcceptedCharacters.None)
|
||||
.WithEditorHints(EditorHints.VirtualPath | EditorHints.LayoutPage)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBNestedStatementsTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void VB_Nested_If_Statement()
|
||||
{
|
||||
ParseBlockTest("@If True Then" + Environment.NewLine
|
||||
+ " If False Then" + Environment.NewLine
|
||||
+ " End If" + Environment.NewLine
|
||||
+ "End If",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If True Then\r\n If False Then\r\n End If\r\nEnd If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Nested_Do_Statement()
|
||||
{
|
||||
ParseBlockTest("@Do While True" + Environment.NewLine
|
||||
+ " Do" + Environment.NewLine
|
||||
+ " Loop Until False" + Environment.NewLine
|
||||
+ "Loop",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Do While True\r\n Do\r\n Loop Until False\r\nLoop")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.AnyExceptNewline)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Nested_Markup_Statement_In_If()
|
||||
{
|
||||
ParseBlockTest("@If True Then" + Environment.NewLine
|
||||
+ " @<p>Tag</p>" + Environment.NewLine
|
||||
+ "End If",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If True Then\r\n")
|
||||
.AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.Markup("<p>Tag</p>\r\n")
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code("End If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Nested_Markup_Statement_In_Code()
|
||||
{
|
||||
ParseBlockTest("@Code" + Environment.NewLine
|
||||
+ " Foo()" + Environment.NewLine
|
||||
+ " @<p>Tag</p>" + Environment.NewLine
|
||||
+ " Bar()" + Environment.NewLine
|
||||
+ "End Code",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Code")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n Foo()\r\n")
|
||||
.AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.Markup("<p>Tag</p>\r\n")
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" Bar()\r\n")
|
||||
.AsStatement(),
|
||||
Factory.MetaCode("End Code")
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Nested_Markup_Statement_In_Do()
|
||||
{
|
||||
ParseBlockTest("@Do" + Environment.NewLine
|
||||
+ " @<p>Tag</p>" + Environment.NewLine
|
||||
+ "Loop While True",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Do\r\n")
|
||||
.AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.Markup("<p>Tag</p>\r\n")
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code("Loop While True")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.AnyExceptNewline)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Nested_Single_Line_Markup_Statement_In_Do()
|
||||
{
|
||||
ParseBlockTest("@Do" + Environment.NewLine
|
||||
+ " @:<p>Tag" + Environment.NewLine
|
||||
+ "Loop While True",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Do\r\n")
|
||||
.AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("<p>Tag\r\n")
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code("Loop While True")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.AnyExceptNewline)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Nested_Implicit_Expression_In_If()
|
||||
{
|
||||
ParseBlockTest("@If True Then" + Environment.NewLine
|
||||
+ " @Foo.Bar" + Environment.NewLine
|
||||
+ "End If",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If True Then\r\n ")
|
||||
.AsStatement(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Foo.Bar")
|
||||
.AsExpression()
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Code("\r\nEnd If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Nested_Explicit_Expression_In_If()
|
||||
{
|
||||
ParseBlockTest("@If True Then" + Environment.NewLine
|
||||
+ " @(Foo.Bar + 42)" + Environment.NewLine
|
||||
+ "End If",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If True Then\r\n ")
|
||||
.AsStatement(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("(")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Foo.Bar + 42")
|
||||
.AsExpression(),
|
||||
Factory.MetaCode(")")
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code("\r\nEnd If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBRazorCommentsTest : VBHtmlMarkupParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void UnterminatedRazorComment()
|
||||
{
|
||||
ParseDocumentTest("@*",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new CommentBlock(
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
||||
Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
HtmlSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any))),
|
||||
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 0, 0, 0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyRazorComment()
|
||||
{
|
||||
ParseDocumentTest("@**@",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new CommentBlock(
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
||||
Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
HtmlSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RazorCommentInImplicitExpressionMethodCall()
|
||||
{
|
||||
ParseDocumentTest(@"@foo(@**@",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo(")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords),
|
||||
new CommentBlock(
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new VBSymbol(
|
||||
Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
VBSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyVB()
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords))),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_Expected_CloseBracket_Before_EOF, "(", ")"),
|
||||
4, 0, 4));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnterminatedRazorCommentInImplicitExpressionMethodCall()
|
||||
{
|
||||
ParseDocumentTest("@foo(@*",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo(")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords),
|
||||
new CommentBlock(
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new VBSymbol(
|
||||
Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
VBSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any)))),
|
||||
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 5, 0, 5),
|
||||
new RazorError(String.Format(RazorResources.ParseError_Expected_CloseBracket_Before_EOF, "(", ")"), 4, 0, 4));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RazorCommentInVerbatimBlock()
|
||||
{
|
||||
ParseDocumentTest("@Code" + Environment.NewLine
|
||||
+ " @<text" + Environment.NewLine
|
||||
+ " @**@" + Environment.NewLine
|
||||
+ "End Code",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition("@"),
|
||||
Factory.MarkupTransition("<text").Accepts(AcceptedCharacters.Any),
|
||||
Factory.Markup("\r\n "),
|
||||
new CommentBlock(
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new HtmlSymbol(
|
||||
Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
HtmlSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any),
|
||||
Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\nEnd Code")))),
|
||||
new RazorError(RazorResources.ParseError_TextTagCannotContainAttributes, 12, 1, 5),
|
||||
new RazorError(String.Format(RazorResources.ParseError_MissingEndTag, "text"), 12, 1, 5),
|
||||
new RazorError(String.Format(RazorResources.ParseError_BlockNotTerminated, SyntaxConstants.VB.CodeKeyword, SyntaxConstants.VB.EndCodeKeyword), 1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnterminatedRazorCommentInVerbatimBlock()
|
||||
{
|
||||
ParseDocumentTest("@Code" + Environment.NewLine
|
||||
+ "@*",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n")
|
||||
.AsStatement(),
|
||||
new CommentBlock(
|
||||
Factory.CodeTransition(VBSymbolType.RazorCommentTransition)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.MetaCode("*", VBSymbolType.RazorCommentStar)
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Comment, new VBSymbol(Factory.LocationTracker.CurrentLocation,
|
||||
String.Empty,
|
||||
VBSymbolType.Unknown))
|
||||
.Accepts(AcceptedCharacters.Any)))),
|
||||
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 7, 1, 0),
|
||||
new RazorError(String.Format(RazorResources.ParseError_BlockNotTerminated, SyntaxConstants.VB.CodeKeyword, SyntaxConstants.VB.EndCodeKeyword), 1, 0, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBReservedWordsTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("Namespace")]
|
||||
[InlineData("Class")]
|
||||
[InlineData("NAMESPACE")]
|
||||
[InlineData("CLASS")]
|
||||
[InlineData("NameSpace")]
|
||||
[InlineData("nameSpace")]
|
||||
private void ReservedWords(string word)
|
||||
{
|
||||
ParseBlockTest(word,
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode(word).Accepts(AcceptedCharacters.None)),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_ReservedWord, word),
|
||||
SourceLocation.Zero));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,277 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBSectionTest : VBHtmlMarkupParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ParseSectionBlockCapturesNewlineImmediatelyFollowing()
|
||||
{
|
||||
ParseDocumentTest("@Section" + Environment.NewLine,
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator(String.Empty),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section\r\n"),
|
||||
new MarkupBlock())),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start,
|
||||
RazorResources.ErrorComponent_EndOfFile),
|
||||
10, 1, 0),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_BlockNotTerminated,
|
||||
"Section", "End Section"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseSectionRequiresNameBeOnSameLineAsSectionKeyword()
|
||||
{
|
||||
ParseDocumentTest("@Section " + Environment.NewLine
|
||||
+ "Foo" + Environment.NewLine
|
||||
+ " <p>Body</p>" + Environment.NewLine
|
||||
+ "End Section",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator(String.Empty),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section "),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\nFoo\r\n <p>Body</p>\r\n")),
|
||||
Factory.MetaCode("End Section").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start,
|
||||
RazorResources.ErrorComponent_Newline),
|
||||
9, 0, 9));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseSectionAllowsNameToBeOnDifferentLineAsSectionKeywordIfUnderscoresUsed()
|
||||
{
|
||||
ParseDocumentTest("@Section _" + Environment.NewLine
|
||||
+ "_" + Environment.NewLine
|
||||
+ "Foo" + Environment.NewLine
|
||||
+ " <p>Body</p>" + Environment.NewLine
|
||||
+ "End Section",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("Foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section _\r\n_\r\nFoo"),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n <p>Body</p>\r\n")),
|
||||
Factory.MetaCode("End Section").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseSectionReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartCharacter()
|
||||
{
|
||||
ParseDocumentTest("@Section 9" + Environment.NewLine
|
||||
+ " <p>Foo</p>" + Environment.NewLine
|
||||
+ "End Section",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator(String.Empty),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section "),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("9\r\n <p>Foo</p>\r\n")),
|
||||
Factory.MetaCode("End Section").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start,
|
||||
String.Format(RazorResources.ErrorComponent_Character, "9")),
|
||||
9, 0, 9));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParserOutputsErrorOnNestedSections()
|
||||
{
|
||||
ParseDocumentTest("@Section foo" + Environment.NewLine
|
||||
+ " @Section bar" + Environment.NewLine
|
||||
+ " <p>Foo</p>" + Environment.NewLine
|
||||
+ " End Section" + Environment.NewLine
|
||||
+ "End Section",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section foo"),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n"),
|
||||
new SectionBlock(new SectionCodeGenerator("bar"),
|
||||
Factory.Code(" ").AsStatement(),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section bar"),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n <p>Foo</p>\r\n ")),
|
||||
Factory.MetaCode("End Section").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("\r\n")),
|
||||
Factory.MetaCode("End Section").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_Sections_Cannot_Be_Nested,
|
||||
RazorResources.SectionExample_VB),
|
||||
26, 1, 12));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseSectionHandlesEOFAfterIdentifier()
|
||||
{
|
||||
ParseDocumentTest("@Section foo",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section foo")
|
||||
.AutoCompleteWith(SyntaxConstants.VB.EndSectionKeyword),
|
||||
new MarkupBlock())),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_BlockNotTerminated,
|
||||
"Section", "End Section"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseSectionHandlesUnterminatedSection()
|
||||
{
|
||||
ParseDocumentTest("@Section foo" + Environment.NewLine
|
||||
+ " <p>Foo</p>",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section foo")
|
||||
.AutoCompleteWith(SyntaxConstants.VB.EndSectionKeyword),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n <p>Foo</p>")))),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_BlockNotTerminated,
|
||||
"Section", "End Section"),
|
||||
1, 0, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseDocumentParsesNamedSectionCorrectly()
|
||||
{
|
||||
ParseDocumentTest("@Section foo" + Environment.NewLine
|
||||
+ " <p>Foo</p>" + Environment.NewLine
|
||||
+ "End Section",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section foo"),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n <p>Foo</p>\r\n")),
|
||||
Factory.MetaCode("End Section").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseSectionTerminatesOnFirstEndSection()
|
||||
{
|
||||
ParseDocumentTest("@Section foo" + Environment.NewLine
|
||||
+ " <p>End Section</p>",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section foo"),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n <p>")),
|
||||
Factory.MetaCode("End Section").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup("</p>")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseSectionAllowsEndSectionInVBExpression()
|
||||
{
|
||||
ParseDocumentTest("@Section foo" + Environment.NewLine
|
||||
+ " I really want to render the word @(\"End Section\"), so this is how I do it" + Environment.NewLine
|
||||
+ "End Section",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section foo"),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n I really want to render the word "),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\"End Section\"").AsExpression(),
|
||||
Factory.MetaCode(")").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Markup(", so this is how I do it\r\n")),
|
||||
Factory.MetaCode("End Section").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
// These are tests that are normally in HtmlToCodeSwitchTest, but we want to verify them for VB
|
||||
// since VB has slightly different section terminating behavior which follow slightly different
|
||||
// code paths
|
||||
|
||||
[Fact]
|
||||
public void SectionBodyTreatsTwoAtSignsAsEscapeSequence()
|
||||
{
|
||||
ParseDocumentTest("@Section Foo" + Environment.NewLine
|
||||
+ " <foo>@@bar</foo>" + Environment.NewLine
|
||||
+ "End Section",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("Foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section Foo").AutoCompleteWith(null),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n <foo>"),
|
||||
Factory.Markup("@").Hidden(),
|
||||
Factory.Markup("@bar</foo>\r\n")),
|
||||
Factory.MetaCode("End Section").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SectionBodyTreatsPairsOfAtSignsAsEscapeSequence()
|
||||
{
|
||||
ParseDocumentTest("@Section Foo" + Environment.NewLine
|
||||
+ " <foo>@@@@@bar</foo>" + Environment.NewLine
|
||||
+ "End Section",
|
||||
new MarkupBlock(
|
||||
Factory.EmptyHtml(),
|
||||
new SectionBlock(new SectionCodeGenerator("Foo"),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Section Foo").AutoCompleteWith(null),
|
||||
new MarkupBlock(
|
||||
Factory.Markup("\r\n <foo>"),
|
||||
Factory.Markup("@").Hidden(),
|
||||
Factory.Markup("@"),
|
||||
Factory.Markup("@").Hidden(),
|
||||
Factory.Markup("@"),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("bar")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Markup("</foo>\r\n")),
|
||||
Factory.MetaCode("End Section").Accepts(AcceptedCharacters.None)),
|
||||
Factory.EmptyHtml()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBSpecialKeywordsTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ParseInheritsStatementMarksInheritsSpanAsCanGrowIfMissingTrailingSpace()
|
||||
{
|
||||
ParseBlockTest("inherits",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("inherits")),
|
||||
new RazorError(
|
||||
RazorResources.ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName,
|
||||
8, 0, 8));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InheritsBlockAcceptsMultipleGenericArguments()
|
||||
{
|
||||
ParseBlockTest("inherits Foo.Bar(Of Biz(Of Qux), String, Integer).Baz",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("inherits ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Foo.Bar(Of Biz(Of Qux), String, Integer).Baz")
|
||||
.AsBaseType("Foo.Bar(Of Biz(Of Qux), String, Integer).Baz")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InheritsDirectiveSupportsVSTemplateTokens()
|
||||
{
|
||||
ParseBlockTest("@Inherits $rootnamespace$.MyBase",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Inherits ")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("$rootnamespace$.MyBase")
|
||||
.AsBaseType("$rootnamespace$.MyBase")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InheritsBlockOutputsErrorIfInheritsNotFollowedByTypeButAcceptsEntireLineAsCode()
|
||||
{
|
||||
ParseBlockTest("inherits " + Environment.NewLine
|
||||
+ "foo",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("inherits ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n").AsBaseType(String.Empty)),
|
||||
new RazorError(
|
||||
RazorResources.ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName,
|
||||
8, 0, 8));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockShouldSupportNamespaceImports()
|
||||
{
|
||||
ParseBlockTest("Imports Foo.Bar.Baz.Biz.Boz",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("Imports Foo.Bar.Baz.Biz.Boz")
|
||||
.With(new AddImportCodeGenerator(
|
||||
ns: " Foo.Bar.Baz.Biz.Boz",
|
||||
namespaceKeywordLength: SyntaxConstants.VB.ImportsKeywordLength))));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockShowsErrorIfNamespaceNotOnSameLineAsImportsKeyword()
|
||||
{
|
||||
ParseBlockTest("Imports" + Environment.NewLine
|
||||
+ "Foo",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("Imports\r\n")
|
||||
.With(new AddImportCodeGenerator(
|
||||
ns: "\r\n",
|
||||
namespaceKeywordLength: SyntaxConstants.VB.ImportsKeywordLength))),
|
||||
new RazorError(
|
||||
RazorResources.ParseError_NamespaceOrTypeAliasExpected,
|
||||
7, 0, 7));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockShowsErrorIfTypeBeingAliasedNotOnSameLineAsImportsKeyword()
|
||||
{
|
||||
ParseBlockTest("Imports Foo =" + Environment.NewLine
|
||||
+ "System.Bar",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("Imports Foo =\r\n")
|
||||
.With(new AddImportCodeGenerator(
|
||||
ns: " Foo =\r\n",
|
||||
namespaceKeywordLength: SyntaxConstants.VB.ImportsKeywordLength))));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockShouldSupportTypeAliases()
|
||||
{
|
||||
ParseBlockTest("Imports Foo = Bar.Baz.Biz.Boz",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("Imports Foo = Bar.Baz.Biz.Boz")
|
||||
.With(new AddImportCodeGenerator(
|
||||
ns: " Foo = Bar.Baz.Biz.Boz",
|
||||
namespaceKeywordLength: SyntaxConstants.VB.ImportsKeywordLength))));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockThrowsErrorIfOptionIsNotFollowedByStrictOrExplicit()
|
||||
{
|
||||
ParseBlockTest("Option FizzBuzz On",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("Option FizzBuzz On")
|
||||
.With(new SetVBOptionCodeGenerator(optionName: null, value: true))),
|
||||
new RazorError(
|
||||
String.Format(RazorResources.ParseError_UnknownOption, "FizzBuzz"),
|
||||
7, 0, 7));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockThrowsErrorIfOptionStrictIsNotFollowedByOnOrOff()
|
||||
{
|
||||
ParseBlockTest("Option Strict Yes",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("Option Strict Yes")
|
||||
.With(SetVBOptionCodeGenerator.Strict(true))),
|
||||
new RazorError(
|
||||
String.Format(
|
||||
RazorResources.ParseError_InvalidOptionValue,
|
||||
"Strict", "Yes"),
|
||||
14, 0, 14));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockReadsToAfterOnKeywordIfOptionStrictBlock()
|
||||
{
|
||||
ParseBlockTest("Option Strict On Foo Bar Baz",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("Option Strict On")
|
||||
.With(SetVBOptionCodeGenerator.Strict(true))));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockReadsToAfterOffKeywordIfOptionStrictBlock()
|
||||
{
|
||||
ParseBlockTest("Option Strict Off Foo Bar Baz",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("Option Strict Off")
|
||||
.With(SetVBOptionCodeGenerator.Strict(false))));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockReadsToAfterOnKeywordIfOptionExplicitBlock()
|
||||
{
|
||||
ParseBlockTest("Option Explicit On Foo Bar Baz",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("Option Explicit On")
|
||||
.With(SetVBOptionCodeGenerator.Explicit(true))));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockReadsToAfterOffKeywordIfOptionExplicitBlock()
|
||||
{
|
||||
ParseBlockTest("Option Explicit Off Foo Bar Baz",
|
||||
new DirectiveBlock(
|
||||
Factory.MetaCode("Option Explicit Off")
|
||||
.With(SetVBOptionCodeGenerator.Explicit(false))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,221 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBStatementTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void VB_Inherits_Statement()
|
||||
{
|
||||
ParseBlockTest("@Inherits System.Foo.Bar(Of Baz)",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Inherits ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("System.Foo.Bar(Of Baz)")
|
||||
.AsBaseType("System.Foo.Bar(Of Baz)")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InheritsDirectiveSupportsArrays()
|
||||
{
|
||||
ParseBlockTest("@Inherits System.String(())()",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Inherits ")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("System.String(())()")
|
||||
.AsBaseType("System.String(())()")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InheritsDirectiveSupportsNestedGenerics()
|
||||
{
|
||||
ParseBlockTest("@Inherits System.Web.Mvc.WebViewPage(Of IEnumerable(Of MvcApplication2.Models.RegisterModel))",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Inherits ")
|
||||
.Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("System.Web.Mvc.WebViewPage(Of IEnumerable(Of MvcApplication2.Models.RegisterModel))")
|
||||
.AsBaseType("System.Web.Mvc.WebViewPage(Of IEnumerable(Of MvcApplication2.Models.RegisterModel))")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InheritsDirectiveSupportsTypeKeywords()
|
||||
{
|
||||
ParseBlockTest("@Inherits String",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Inherits ").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("String").AsBaseType("String")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Option_Strict_Statement()
|
||||
{
|
||||
ParseBlockTest("@Option Strict Off",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Option Strict Off")
|
||||
.With(SetVBOptionCodeGenerator.Strict(false))));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Option_Explicit_Statement()
|
||||
{
|
||||
ParseBlockTest("@Option Explicit Off",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Option Explicit Off")
|
||||
.With(SetVBOptionCodeGenerator.Explicit(false))));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Imports_Statement()
|
||||
{
|
||||
ParseBlockTest("@Imports Biz = System.Foo.Bar(Of Boz.Baz(Of Qux))",
|
||||
new DirectiveBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("Imports Biz = System.Foo.Bar(Of Boz.Baz(Of Qux))")
|
||||
.With(new AddImportCodeGenerator(
|
||||
ns: " Biz = System.Foo.Bar(Of Boz.Baz(Of Qux))",
|
||||
namespaceKeywordLength: SyntaxConstants.VB.ImportsKeywordLength))));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Using_Statement()
|
||||
{
|
||||
ParseBlockTest("@Using foo as Bar" + Environment.NewLine
|
||||
+ " foo()" + Environment.NewLine
|
||||
+ "End Using",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Using foo as Bar\r\n foo()\r\nEnd Using")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Do_Loop_Statement()
|
||||
{
|
||||
ParseBlockTest("@Do" + Environment.NewLine
|
||||
+ " foo()" + Environment.NewLine
|
||||
+ "Loop While True",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Do\r\n foo()\r\nLoop While True")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.AnyExceptNewline)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_While_Statement()
|
||||
{
|
||||
ParseBlockTest("@While True" + Environment.NewLine
|
||||
+ " foo()" + Environment.NewLine
|
||||
+ "End While",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("While True\r\n foo()\r\nEnd While")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_If_Statement()
|
||||
{
|
||||
ParseBlockTest("@If True Then" + Environment.NewLine
|
||||
+ " foo()" + Environment.NewLine
|
||||
+ "ElseIf False Then" + Environment.NewLine
|
||||
+ " bar()" + Environment.NewLine
|
||||
+ "Else" + Environment.NewLine
|
||||
+ " baz()" + Environment.NewLine
|
||||
+ "End If",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("If True Then\r\n foo()\r\nElseIf False Then\r\n bar()\r\nElse\r\n baz()\r\nEnd If")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Select_Statement()
|
||||
{
|
||||
ParseBlockTest("@Select Case foo" + Environment.NewLine
|
||||
+ " Case 1" + Environment.NewLine
|
||||
+ " foo()" + Environment.NewLine
|
||||
+ " Case 2" + Environment.NewLine
|
||||
+ " bar()" + Environment.NewLine
|
||||
+ " Case Else" + Environment.NewLine
|
||||
+ " baz()" + Environment.NewLine
|
||||
+ "End Select",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Select Case foo\r\n Case 1\r\n foo()\r\n Case 2\r\n bar()\r\n Case Else\r\n baz()\r\nEnd Select")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_For_Statement()
|
||||
{
|
||||
ParseBlockTest("@For Each foo In bar" + Environment.NewLine
|
||||
+ " baz()" + Environment.NewLine
|
||||
+ "Next",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("For Each foo In bar\r\n baz()\r\nNext")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.AnyExceptNewline)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_Try_Statement()
|
||||
{
|
||||
ParseBlockTest("@Try" + Environment.NewLine
|
||||
+ " foo()" + Environment.NewLine
|
||||
+ "Catch ex as Exception" + Environment.NewLine
|
||||
+ " bar()" + Environment.NewLine
|
||||
+ "Finally" + Environment.NewLine
|
||||
+ " baz()" + Environment.NewLine
|
||||
+ "End Try",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Try\r\n foo()\r\nCatch ex as Exception\r\n bar()\r\nFinally\r\n baz()\r\nEnd Try")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_With_Statement()
|
||||
{
|
||||
ParseBlockTest("@With foo" + Environment.NewLine
|
||||
+ " .bar()" + Environment.NewLine
|
||||
+ "End With",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("With foo\r\n .bar()\r\nEnd With")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VB_SyncLock_Statement()
|
||||
{
|
||||
ParseBlockTest("@SyncLock foo" + Environment.NewLine
|
||||
+ " foo.bar()" + Environment.NewLine
|
||||
+ "End SyncLock",
|
||||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("SyncLock foo\r\n foo.bar()\r\nEnd SyncLock")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,214 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Resources;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBTemplateTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
private const string TestTemplateCode = "@@<p>Foo #@item</p>";
|
||||
|
||||
private TemplateBlock TestTemplate()
|
||||
{
|
||||
return new TemplateBlock(new TemplateBlockCodeGenerator(),
|
||||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup("@"),
|
||||
Factory.Markup("<p>Foo #"),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("item")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
private const string TestNestedTemplateCode = "@@<p>Foo #@Html.Repeat(10,@@<p>@item</p>)</p>";
|
||||
|
||||
private TemplateBlock TestNestedTemplate()
|
||||
{
|
||||
return new TemplateBlock(new TemplateBlockCodeGenerator(),
|
||||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup("@"),
|
||||
Factory.Markup("<p>Foo #"),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("Html.Repeat(10,")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.Any),
|
||||
new TemplateBlock(new TemplateBlockCodeGenerator(),
|
||||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup("@"),
|
||||
Factory.Markup("<p>"),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("item")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None))),
|
||||
Factory.Code(")")
|
||||
.AsImplicitExpression(VBCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockHandlesSimpleAnonymousSectionInExplicitExpressionParens()
|
||||
{
|
||||
ParseBlockTest("(Html.Repeat(10," + TestTemplateCode + "))",
|
||||
new ExpressionBlock(
|
||||
Factory.MetaCode("(").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("Html.Repeat(10,").AsExpression(),
|
||||
TestTemplate(),
|
||||
Factory.Code(")").AsExpression(),
|
||||
Factory.MetaCode(")").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockHandlesSimpleAnonymousSectionInImplicitExpressionParens()
|
||||
{
|
||||
ParseBlockTest("Html.Repeat(10," + TestTemplateCode + ")",
|
||||
new ExpressionBlock(
|
||||
Factory.Code("Html.Repeat(10,").AsImplicitExpression(KeywordSet),
|
||||
TestTemplate(),
|
||||
Factory.Code(")").AsImplicitExpression(KeywordSet).Accepts(AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockHandlesTwoAnonymousSectionsInImplicitExpressionParens()
|
||||
{
|
||||
ParseBlockTest("Html.Repeat(10," + TestTemplateCode + "," + TestTemplateCode + ")",
|
||||
new ExpressionBlock(
|
||||
Factory.Code("Html.Repeat(10,").AsImplicitExpression(KeywordSet),
|
||||
TestTemplate(),
|
||||
Factory.Code(",").AsImplicitExpression(KeywordSet),
|
||||
TestTemplate(),
|
||||
Factory.Code(")").AsImplicitExpression(KeywordSet).Accepts(AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockProducesErrorButCorrectlyParsesNestedAnonymousSectionInImplicitExpressionParens()
|
||||
{
|
||||
ParseBlockTest("Html.Repeat(10," + TestNestedTemplateCode + ")",
|
||||
new ExpressionBlock(
|
||||
Factory.Code("Html.Repeat(10,").AsImplicitExpression(KeywordSet),
|
||||
TestNestedTemplate(),
|
||||
Factory.Code(")").AsImplicitExpression(KeywordSet).Accepts(AcceptedCharacters.NonWhiteSpace)),
|
||||
GetNestedSectionError(41, 0, 41));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockHandlesSimpleAnonymousSectionInStatementWithinCodeBlock()
|
||||
{
|
||||
ParseBlockTest("For Each foo in Bar " + Environment.NewLine
|
||||
+ " Html.ExecuteTemplate(foo," + TestTemplateCode + ")" + Environment.NewLine
|
||||
+ "Next foo",
|
||||
new StatementBlock(
|
||||
Factory.Code("For Each foo in Bar \r\n Html.ExecuteTemplate(foo,")
|
||||
.AsStatement(),
|
||||
TestTemplate(),
|
||||
Factory.Code(")\r\nNext foo")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.WhiteSpace | AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockHandlesTwoAnonymousSectionsInStatementWithinCodeBlock()
|
||||
{
|
||||
ParseBlockTest("For Each foo in Bar " + Environment.NewLine
|
||||
+ " Html.ExecuteTemplate(foo," + TestTemplateCode + "," + TestTemplateCode + ")" + Environment.NewLine
|
||||
+ "Next foo",
|
||||
new StatementBlock(
|
||||
Factory.Code("For Each foo in Bar \r\n Html.ExecuteTemplate(foo,")
|
||||
.AsStatement(),
|
||||
TestTemplate(),
|
||||
Factory.Code(",").AsStatement(),
|
||||
TestTemplate(),
|
||||
Factory.Code(")\r\nNext foo")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.WhiteSpace | AcceptedCharacters.NonWhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockProducesErrorButCorrectlyParsesNestedAnonymousSectionInStatementWithinCodeBlock()
|
||||
{
|
||||
ParseBlockTest("For Each foo in Bar " + Environment.NewLine
|
||||
+ " Html.ExecuteTemplate(foo," + TestNestedTemplateCode + ")" + Environment.NewLine
|
||||
+ "Next foo",
|
||||
new StatementBlock(
|
||||
Factory.Code("For Each foo in Bar \r\n Html.ExecuteTemplate(foo,")
|
||||
.AsStatement(),
|
||||
TestNestedTemplate(),
|
||||
Factory.Code(")\r\nNext foo")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.WhiteSpace | AcceptedCharacters.NonWhiteSpace)),
|
||||
GetNestedSectionError(77, 1, 55));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockHandlesSimpleAnonymousSectionInStatementWithinStatementBlock()
|
||||
{
|
||||
ParseBlockTest("Code " + Environment.NewLine
|
||||
+ " Dim foo = bar" + Environment.NewLine
|
||||
+ " Html.ExecuteTemplate(foo," + TestTemplateCode + ")" + Environment.NewLine
|
||||
+ "End Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code(" \r\n Dim foo = bar\r\n Html.ExecuteTemplate(foo,")
|
||||
.AsStatement(),
|
||||
TestTemplate(),
|
||||
Factory.Code(")\r\n").AsStatement(),
|
||||
Factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockHandlessTwoAnonymousSectionsInStatementWithinStatementBlock()
|
||||
{
|
||||
ParseBlockTest("Code" + Environment.NewLine
|
||||
+ " Dim foo = bar" + Environment.NewLine
|
||||
+ " Html.ExecuteTemplate(foo," + TestTemplateCode + "," + TestTemplateCode + ")" + Environment.NewLine
|
||||
+ "End Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n Dim foo = bar\r\n Html.ExecuteTemplate(foo,")
|
||||
.AsStatement(),
|
||||
TestTemplate(),
|
||||
Factory.Code(",").AsStatement(),
|
||||
TestTemplate(),
|
||||
Factory.Code(")\r\n").AsStatement(),
|
||||
Factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockProducesErrorButCorrectlyParsesNestedAnonymousSectionInStatementWithinStatementBlock()
|
||||
{
|
||||
ParseBlockTest("Code" + Environment.NewLine
|
||||
+ " Dim foo = bar" + Environment.NewLine
|
||||
+ " Html.ExecuteTemplate(foo," + TestNestedTemplateCode + ")" + Environment.NewLine
|
||||
+ "End Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n Dim foo = bar\r\n Html.ExecuteTemplate(foo,")
|
||||
.AsStatement(),
|
||||
TestNestedTemplate(),
|
||||
Factory.Code(")\r\n").AsStatement(),
|
||||
Factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)),
|
||||
GetNestedSectionError(80, 2, 55));
|
||||
}
|
||||
|
||||
private static RazorError GetNestedSectionError(int absoluteIndex, int lineIndex, int characterIndex)
|
||||
{
|
||||
return new RazorError(
|
||||
RazorResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested,
|
||||
absoluteIndex, lineIndex, characterIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Razor.Editor;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Parser.VB
|
||||
{
|
||||
public class VBToMarkupSwitchTest : VBHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ParseBlockSwitchesToMarkupWhenAtSignFollowedByLessThanInStatementBlock()
|
||||
{
|
||||
ParseBlockTest("Code" + Environment.NewLine
|
||||
+ " If True Then" + Environment.NewLine
|
||||
+ " @<p>It's True!</p>" + Environment.NewLine
|
||||
+ " End If" + Environment.NewLine
|
||||
+ "End Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n If True Then\r\n").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.Markup("<p>It's True!</p>\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" End If\r\n").AsStatement(),
|
||||
Factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlockGivesWhiteSpacePreceedingMarkupBlockToCodeInDesignTimeMode()
|
||||
{
|
||||
ParseBlockTest("Code" + Environment.NewLine
|
||||
+ " @<p>Foo</p>" + Environment.NewLine
|
||||
+ "End Code",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
|
||||
Factory.Code("\r\n ").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.MarkupTransition(),
|
||||
Factory.Markup("<p>Foo</p>").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code("\r\n").AsStatement(),
|
||||
Factory.MetaCode("End Code").Accepts(AcceptedCharacters.None)),
|
||||
designTimeParser: true);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("While", "End While", AcceptedCharacters.None)]
|
||||
[InlineData("If", "End If", AcceptedCharacters.None)]
|
||||
[InlineData("Select", "End Select", AcceptedCharacters.None)]
|
||||
[InlineData("For", "Next", AcceptedCharacters.WhiteSpace | AcceptedCharacters.NonWhiteSpace)]
|
||||
[InlineData("Try", "End Try", AcceptedCharacters.None)]
|
||||
[InlineData("With", "End With", AcceptedCharacters.None)]
|
||||
[InlineData("Using", "End Using", AcceptedCharacters.None)]
|
||||
public void SimpleMarkupSwitch(string keyword, string endSequence, AcceptedCharacters acceptedCharacters)
|
||||
{
|
||||
ParseBlockTest(keyword + Environment.NewLine
|
||||
+ " If True Then" + Environment.NewLine
|
||||
+ " @<p>It's True!</p>" + Environment.NewLine
|
||||
+ " End If" + Environment.NewLine
|
||||
+ endSequence,
|
||||
new StatementBlock(
|
||||
Factory.Code(keyword + "\r\n If True Then\r\n").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.Markup("<p>It's True!</p>\r\n").Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" End If\r\n" + endSequence).AsStatement().Accepts(acceptedCharacters)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("While", "End While", AcceptedCharacters.None)]
|
||||
[InlineData("If", "End If", AcceptedCharacters.None)]
|
||||
[InlineData("Select", "End Select", AcceptedCharacters.None)]
|
||||
[InlineData("For", "Next", AcceptedCharacters.WhiteSpace | AcceptedCharacters.NonWhiteSpace)]
|
||||
[InlineData("Try", "End Try", AcceptedCharacters.None)]
|
||||
[InlineData("With", "End With", AcceptedCharacters.None)]
|
||||
[InlineData("Using", "End Using", AcceptedCharacters.None)]
|
||||
public void SingleLineMarkupSwitch(string keyword, string endSequence, AcceptedCharacters acceptedCharacters)
|
||||
{
|
||||
ParseBlockTest(keyword + Environment.NewLine
|
||||
+ " If True Then" + Environment.NewLine
|
||||
+ " @:<p>It's True!</p>" + Environment.NewLine
|
||||
+ " This is code!" + Environment.NewLine
|
||||
+ " End If" + Environment.NewLine
|
||||
+ endSequence,
|
||||
new StatementBlock(
|
||||
Factory.Code(keyword + "\r\n If True Then\r\n").AsStatement(),
|
||||
new MarkupBlock(
|
||||
Factory.Markup(" "),
|
||||
Factory.MarkupTransition(),
|
||||
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
|
||||
Factory.Markup("<p>It's True!</p>\r\n")
|
||||
.With(new SingleLineMarkupEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString))
|
||||
.Accepts(AcceptedCharacters.None)),
|
||||
Factory.Code(" This is code!\r\n End If\r\n" + endSequence)
|
||||
.AsStatement()
|
||||
.Accepts(acceptedCharacters)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ namespace Microsoft.AspNet.Razor.Test
|
|||
// Assert
|
||||
Assert.Equal(2, RazorCodeLanguage.Languages.Count);
|
||||
Assert.IsType<CSharpRazorCodeLanguage>(RazorCodeLanguage.Languages["cshtml"]);
|
||||
Assert.IsType<VBRazorCodeLanguage>(RazorCodeLanguage.Languages["vbhtml"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -1,255 +0,0 @@
|
|||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:N.N.NNNNN.N
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace TestOutput
|
||||
Public Class Blocks
|
||||
Public Sub New()
|
||||
MyBase.New
|
||||
End Sub
|
||||
Public Overrides Sub Execute()
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",1)
|
||||
|
||||
Dim i as Integer = 1
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",5)
|
||||
While i <= 10
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>Hello from VB.Net, #")
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",6)
|
||||
Write(i)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral("</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",7)
|
||||
i += 1
|
||||
End While
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",10)
|
||||
If i = 11 Then
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>We wrote 10 lines!</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",12)
|
||||
End If
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",14)
|
||||
Do
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>Hello again: ")
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",15)
|
||||
Write(i)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral("</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",16)
|
||||
i -= 1
|
||||
Loop While i > 0
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",19)
|
||||
Select Case i
|
||||
Case 11
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>No really, we wrote 10 lines!</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",22)
|
||||
Case Else
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>We wrote a bunch more lines too!</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",24)
|
||||
End Select
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",26)
|
||||
For j as Integer = 1 to 10 Step 2
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>Hello again from VB.Net, #")
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",27)
|
||||
Write(j)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral("</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",28)
|
||||
Next j
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",30)
|
||||
Try
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>That time, we wrote 5 lines!</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",32)
|
||||
Catch ex as Exception
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>Oh no! An error occurred: ")
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",33)
|
||||
Write(ex.Message)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral("</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",34)
|
||||
End Try
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",36)
|
||||
With i
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>i is now ")
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",37)
|
||||
Write(.ToString())
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral("</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",38)
|
||||
End With
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",40)
|
||||
SyncLock New Object()
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>This block is locked, for your security!</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",42)
|
||||
End SyncLock
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",44)
|
||||
Using New System.IO.MemoryStream()
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p>Some random memory stream will be disposed after rendering this block</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("Blocks.vbhtml",46)
|
||||
End Using
|
||||
|
||||
#End ExternalSource
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:N.N.NNNNN.N
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace TestOutput
|
||||
Public Class CodeBlock
|
||||
Public Sub New()
|
||||
MyBase.New
|
||||
End Sub
|
||||
Public Overrides Sub Execute()
|
||||
|
||||
#ExternalSource("CodeBlock.vbhtml",1)
|
||||
|
||||
Test()
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:N.N.NNNNN.N
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace TestOutput
|
||||
Public Class CodeBlockAtEOF
|
||||
Public Sub New()
|
||||
MyBase.New
|
||||
End Sub
|
||||
Public Overrides Sub Execute()
|
||||
|
||||
#ExternalSource("CodeBlockAtEOF.vbhtml",1)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:N.N.NNNNN.N
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace TestOutput
|
||||
Public Class Comments
|
||||
Public Overrides Sub Execute()
|
||||
|
||||
|
||||
#ExternalSource("Comments.vbhtml",1)
|
||||
'This is not going to be rendered
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral("<p>This is going to be rendered</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
|
||||
#ExternalSource("Comments.vbhtml",3)
|
||||
REM Neither is this
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
|
||||
#ExternalSource("Comments.vbhtml",4)
|
||||
rem nor this
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
|
||||
#ExternalSource("Comments.vbhtml",5)
|
||||
rEm nor this
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
|
@ -1,187 +0,0 @@
|
|||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:N.N.NNNNN.N
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace TestOutput
|
||||
Public Class ConditionalAttributes
|
||||
|
||||
#ExternalSource("ConditionalAttributes.vbhtml", 1)
|
||||
Public Shared Function Link(ByVal url As String, text As String) As Template
|
||||
|
||||
#End ExternalSource
|
||||
Return New Template(Sub (__razor_helper_writer)
|
||||
|
||||
#ExternalSource("ConditionalAttributes.vbhtml", 1)
|
||||
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteralTo(__razor_helper_writer, " ")
|
||||
|
||||
WriteLiteralTo(__razor_helper_writer, "<a")
|
||||
|
||||
WriteAttributeTo(__razor_helper_writer, "href", Tuple.Create(" href=""", 59), Tuple.Create("""", 70) _
|
||||
, Tuple.Create(Tuple.Create("", 66), Tuple.Create(Of System.Object, System.Int32)(url _
|
||||
, 66), False) _
|
||||
)
|
||||
|
||||
WriteLiteralTo(__razor_helper_writer, ">")
|
||||
|
||||
|
||||
#ExternalSource("ConditionalAttributes.vbhtml", 2)
|
||||
WriteTo(__razor_helper_writer, text)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteralTo(__razor_helper_writer, "</a> "&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("ConditionalAttributes.vbhtml", 3)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
End Sub)
|
||||
End Function
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New
|
||||
End Sub
|
||||
Public Overrides Sub Execute()
|
||||
WriteLiteral(" "&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("ConditionalAttributes.vbhtml",5)
|
||||
|
||||
Dim ch = True
|
||||
Dim cls = "bar"
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<a")
|
||||
|
||||
WriteLiteral(" href=""Foo""")
|
||||
|
||||
WriteLiteral(" />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p")
|
||||
|
||||
WriteAttribute("class", Tuple.Create(" class=""", 176), Tuple.Create("""", 188) _
|
||||
, Tuple.Create(Tuple.Create("", 184), Tuple.Create(Of System.Object, System.Int32)(cls _
|
||||
, 184), False) _
|
||||
)
|
||||
|
||||
WriteLiteral(" />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p")
|
||||
|
||||
WriteAttribute("class", Tuple.Create(" class=""", 201), Tuple.Create("""", 217) _
|
||||
, Tuple.Create(Tuple.Create("", 209), Tuple.Create("foo", 209), True) _
|
||||
, Tuple.Create(Tuple.Create(" ", 212), Tuple.Create(Of System.Object, System.Int32)(cls _
|
||||
, 213), False) _
|
||||
)
|
||||
|
||||
WriteLiteral(" />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p")
|
||||
|
||||
WriteAttribute("class", Tuple.Create(" class=""", 230), Tuple.Create("""", 246) _
|
||||
, Tuple.Create(Tuple.Create("", 238), Tuple.Create(Of System.Object, System.Int32)(cls _
|
||||
, 238), False) _
|
||||
, Tuple.Create(Tuple.Create(" ", 242), Tuple.Create("foo", 243), True) _
|
||||
)
|
||||
|
||||
WriteLiteral(" />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<input")
|
||||
|
||||
WriteLiteral(" type=""checkbox""")
|
||||
|
||||
WriteAttribute("checked", Tuple.Create(" checked=""", 279), Tuple.Create("""", 292) _
|
||||
, Tuple.Create(Tuple.Create("", 289), Tuple.Create(Of System.Object, System.Int32)(ch _
|
||||
, 289), False) _
|
||||
)
|
||||
|
||||
WriteLiteral(" />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<input")
|
||||
|
||||
WriteLiteral(" type=""checkbox""")
|
||||
|
||||
WriteAttribute("checked", Tuple.Create(" checked=""", 325), Tuple.Create("""", 342) _
|
||||
, Tuple.Create(Tuple.Create("", 335), Tuple.Create("foo", 335), True) _
|
||||
, Tuple.Create(Tuple.Create(" ", 338), Tuple.Create(Of System.Object, System.Int32)(ch _
|
||||
, 339), False) _
|
||||
)
|
||||
|
||||
WriteLiteral(" />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<p")
|
||||
|
||||
WriteAttribute("class", Tuple.Create(" class=""", 355), Tuple.Create("""", 401) _
|
||||
, Tuple.Create(Tuple.Create("", 363), Tuple.Create(Of System.Object, System.Int32)(New Template(Sub (__razor_attribute_value_writer)
|
||||
|
||||
|
||||
#ExternalSource("ConditionalAttributes.vbhtml",14)
|
||||
If cls IsNot Nothing Then
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("ConditionalAttributes.vbhtml",14)
|
||||
WriteTo(__razor_attribute_value_writer, cls)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("ConditionalAttributes.vbhtml",14)
|
||||
End If
|
||||
|
||||
#End ExternalSource
|
||||
End Sub), 363), False) _
|
||||
)
|
||||
|
||||
WriteLiteral(" />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
WriteLiteral(" ")
|
||||
|
||||
WriteLiteral("<a")
|
||||
|
||||
WriteAttribute("href", Tuple.Create(" href=""", 414), Tuple.Create("""", 426) _
|
||||
, Tuple.Create(Tuple.Create("", 421), Tuple.Create(Of System.Object, System.Int32)(Href("~/Foo") _
|
||||
, 421), False) _
|
||||
)
|
||||
|
||||
WriteLiteral(" />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
|
||||
|
||||
|
||||
#ExternalSource("ConditionalAttributes.vbhtml",16)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:N.N.NNNNN.N
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace TestOutput
|
||||
Public Class DesignTime
|
||||
Private Shared __o As Object
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml", 9)
|
||||
Public Shared Function Foo() As Template
|
||||
|
||||
#End ExternalSource
|
||||
Return New Template(Sub (__razor_helper_writer)
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml", 10)
|
||||
|
||||
If True Then
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml", 11)
|
||||
|
||||
End If
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
End Sub)
|
||||
End Function
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New
|
||||
End Sub
|
||||
Public Overrides Sub Execute()
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml",1)
|
||||
For i = 1 to 10
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml",2)
|
||||
__o = i
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml",3)
|
||||
|
||||
Next
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml",4)
|
||||
__o = Foo(Bar.Baz)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml",5)
|
||||
__o = Foo(Function (item) New Template(Sub (__razor_template_writer)
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml",6)
|
||||
__o = baz
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml",7)
|
||||
End Sub))
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
DefineSection("Footer", Sub ()
|
||||
|
||||
|
||||
#ExternalSource("DesignTime.vbhtml",8)
|
||||
__o = bar
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
End Sub)
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:N.N.NNNNN.N
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace TestOutput
|
||||
Public Class EmptyExplicitExpression
|
||||
Private Shared __o As Object
|
||||
Public Sub New()
|
||||
MyBase.New
|
||||
End Sub
|
||||
Public Overrides Sub Execute()
|
||||
|
||||
#ExternalSource("EmptyExplicitExpression.vbhtml",1)
|
||||
__o =
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:N.N.NNNNN.N
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace TestOutput
|
||||
Public Class EmptyImplicitExpression
|
||||
Private Shared __o As Object
|
||||
Public Sub New()
|
||||
MyBase.New
|
||||
End Sub
|
||||
Public Overrides Sub Execute()
|
||||
|
||||
#ExternalSource("EmptyImplicitExpression.vbhtml",1)
|
||||
__o =
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:N.N.NNNNN.N
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace TestOutput
|
||||
Public Class EmptyImplicitExpressionInCode
|
||||
Private Shared __o As Object
|
||||
Public Sub New()
|
||||
MyBase.New
|
||||
End Sub
|
||||
Public Overrides Sub Execute()
|
||||
|
||||
#ExternalSource("EmptyImplicitExpressionInCode.vbhtml",1)
|
||||
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("EmptyImplicitExpressionInCode.vbhtml",2)
|
||||
__o =
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
|
||||
#ExternalSource("EmptyImplicitExpressionInCode.vbhtml",3)
|
||||
|
||||
|
||||
|
||||
#End ExternalSource
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:N.N.NNNNN.N
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace TestOutput
|
||||
Public Class EmptySection
|
||||
Public Sub New()
|
||||
MyBase.New
|
||||
End Sub
|
||||
Public Overrides Sub Execute()
|
||||
DefineSection("anything", Sub ()
|
||||
|
||||
WriteLiteral(" ")
|
||||
|
||||
End Sub)
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue