Adjusted verbosity of some property names and made

TagHelperIntermediateNode.TagHelpers and IList
This commit is contained in:
Ajay Bhargav Baaskaran 2017-07-06 17:40:22 -07:00
parent 02160a04d9
commit d6e892b30c
52 changed files with 197 additions and 197 deletions

View File

@ -22,13 +22,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
}
var @class = documentNode.FindPrimaryClass();
if (@class == null || string.IsNullOrEmpty(@class.Name))
if (@class == null || string.IsNullOrEmpty(@class.ClassName))
{
// No class node or it's incomplete. Skip.
return;
}
var generatedTypeName = $"{@namespace.Content}.{@class.Name}";
var generatedTypeName = $"{@namespace.Content}.{@class.ClassName}";
var path = codeDocument.GetRelativePath();
var escapedPath = EscapeAsVerbatimLiteral(path);

View File

@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public override void VisitDirective(DirectiveIntermediateNode node)
{
if (node.Descriptor == Directive)
if (node.Directive == Directive)
{
Directives.Add(node);
}

View File

@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
if (document.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind)
{
return visitor.Class.Name;
return visitor.Class.ClassName;
}
else
{
@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public override void VisitDirective(DirectiveIntermediateNode node)
{
if (node.Descriptor == Directive)
if (node.Directive == Directive)
{
ModelDirectives.Add(node);
}

View File

@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public override RazorCodeDocument CreateCodeDocument(RazorProjectItem projectItem)
{
var codeDocument = base.CreateCodeDocument(projectItem);
codeDocument.SetRelativePath(projectItem.Path);
codeDocument.SetRelativePath(projectItem.FilePath);
return codeDocument;
}

View File

@ -26,12 +26,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
@namespace.Content = "AspNetCore";
@class.Name = CSharpIdentifier.GetClassNameFromPath(filePath);
@class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath);
@class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>";
@class.Modifiers.Clear();
@class.Modifiers.Add("public");
method.Name = "ExecuteAsync";
method.MethodName = "ExecuteAsync";
method.Modifiers.Clear();
method.Modifiers.Add("public");
method.Modifiers.Add("async");

View File

@ -70,11 +70,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var prefix = CSharpIdentifier.SanitizeClassName(Path.GetFileNameWithoutExtension(codeDocument.Source.FilePath));
if (@class != null && documentNode.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind)
{
@class.Name = prefix + "_Page";
@class.ClassName = prefix + "_Page";
}
else if (@class != null && documentNode.DocumentKind == MvcViewDocumentClassifierPass.MvcViewDocumentKind)
{
@class.Name = prefix + "_View";
@class.ClassName = prefix + "_View";
}
}
@ -194,7 +194,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public override void VisitDirective(DirectiveIntermediateNode node)
{
if (node.Descriptor == Directive)
if (node.Directive == Directive)
{
LastNamespaceDirective = node;
}

View File

@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public override void VisitDirective(DirectiveIntermediateNode node)
{
if (node.Descriptor == Directive)
if (node.Directive == Directive)
{
DirectiveNode = node;
DirectiveTokens = node.Tokens;
@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public override void VisitMalformedDirective(MalformedDirectiveIntermediateNode node)
{
if (DirectiveTokens == null && node.Descriptor == Directive)
if (DirectiveTokens == null && node.Directive == Directive)
{
DirectiveNode = node;
DirectiveTokens = node.Tokens;

View File

@ -31,12 +31,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
@namespace.Content = "AspNetCore";
@class.BaseType = "global::Microsoft.AspNetCore.Mvc.RazorPages.Page";
@class.Name = CSharpIdentifier.GetClassNameFromPath(filePath);
@class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath);
@class.Modifiers.Clear();
@class.Modifiers.Add("public");
method.Name = "ExecuteAsync";
method.MethodName = "ExecuteAsync";
method.Modifiers.Clear();
method.Modifiers.Add("public");
method.Modifiers.Add("async");

View File

@ -135,8 +135,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
{
"private",
},
Name = context.GetFieldName(tagHelper),
Type = "global::" + context.GetFullyQualifiedName(tagHelper),
FieldName = context.GetFieldName(tagHelper),
FieldType = "global::" + context.GetFullyQualifiedName(tagHelper),
});
}
@ -310,7 +310,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
}
var className = $"__Generated__{tagHelper.GetViewComponentName()}ViewComponentTagHelper";
var fullyQualifiedName = $"{Namespace.Content}.{Class.Name}.{className}";
var fullyQualifiedName = $"{Namespace.Content}.{Class.ClassName}.{className}";
var fieldName = GenerateFieldName(tagHelper);
_tagHelpers.Add(tagHelper, (className, fullyQualifiedName, fieldName));

View File

@ -118,7 +118,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node)
{
using (Context.CodeWriter.BuildClassDeclaration(node.Modifiers, node.Name, node.BaseType, node.Interfaces))
using (Context.CodeWriter.BuildClassDeclaration(node.Modifiers, node.ClassName, node.BaseType, node.Interfaces))
{
VisitDefault(node);
}
@ -137,7 +137,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
Context.CodeWriter
.Write(node.ReturnType)
.Write(" ")
.Write(node.Name)
.Write(node.MethodName)
.WriteLine("()");
using (Context.CodeWriter.BuildScope())
@ -150,12 +150,12 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
public override void VisitFieldDeclaration(FieldDeclarationIntermediateNode node)
{
Context.CodeWriter.WriteField(node.Modifiers, node.Type, node.Name);
Context.CodeWriter.WriteField(node.Modifiers, node.FieldType, node.FieldName);
}
public override void VisitPropertyDeclaration(PropertyDeclarationIntermediateNode node)
{
Context.CodeWriter.WriteAutoPropertyDeclaration(node.Modifiers, node.Type, node.Name);
Context.CodeWriter.WriteAutoPropertyDeclaration(node.Modifiers, node.PropertyType, node.PropertyName);
}
public override void VisitExtension(ExtensionIntermediateNode node)

View File

@ -107,7 +107,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
var reference = visitor.Directives[i];
var directive = (DirectiveIntermediateNode)reference.Node;
var descriptor = directive.Descriptor;
var descriptor = directive.Directive;
var seenDirective = !seenDirectives.Add(descriptor);
if (!directive.IsImported())
@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Razor.Language
_builder.Add(new DirectiveTokenIntermediateNode()
{
Content = span.Content,
Descriptor = chunkGenerator.Descriptor,
DirectiveToken = chunkGenerator.Descriptor,
Source = BuildSourceSpanFromNode(span),
});
}
@ -189,8 +189,8 @@ namespace Microsoft.AspNetCore.Razor.Language
{
directiveNode = new MalformedDirectiveIntermediateNode()
{
Name = chunkGenerator.Descriptor.Directive,
Descriptor = chunkGenerator.Descriptor,
DirectiveName = chunkGenerator.Descriptor.Directive,
Directive = chunkGenerator.Descriptor,
Source = BuildSourceSpanFromNode(block),
};
}
@ -198,8 +198,8 @@ namespace Microsoft.AspNetCore.Razor.Language
{
directiveNode = new DirectiveIntermediateNode()
{
Name = chunkGenerator.Descriptor.Directive,
Descriptor = chunkGenerator.Descriptor,
DirectiveName = chunkGenerator.Descriptor.Directive,
Directive = chunkGenerator.Descriptor,
Source = BuildSourceSpanFromNode(block),
};
}
@ -230,8 +230,8 @@ namespace Microsoft.AspNetCore.Razor.Language
{
directiveNode = new MalformedDirectiveIntermediateNode()
{
Name = CSharpCodeParser.AddTagHelperDirectiveDescriptor.Directive,
Descriptor = CSharpCodeParser.AddTagHelperDirectiveDescriptor,
DirectiveName = CSharpCodeParser.AddTagHelperDirectiveDescriptor.Directive,
Directive = CSharpCodeParser.AddTagHelperDirectiveDescriptor,
Source = BuildSourceSpanFromNode(span),
};
}
@ -239,8 +239,8 @@ namespace Microsoft.AspNetCore.Razor.Language
{
directiveNode = new DirectiveIntermediateNode()
{
Name = CSharpCodeParser.AddTagHelperDirectiveDescriptor.Directive,
Descriptor = CSharpCodeParser.AddTagHelperDirectiveDescriptor,
DirectiveName = CSharpCodeParser.AddTagHelperDirectiveDescriptor.Directive,
Directive = CSharpCodeParser.AddTagHelperDirectiveDescriptor,
Source = BuildSourceSpanFromNode(span),
};
}
@ -255,7 +255,7 @@ namespace Microsoft.AspNetCore.Razor.Language
_builder.Add(new DirectiveTokenIntermediateNode()
{
Content = chunkGenerator.LookupText,
Descriptor = CSharpCodeParser.AddTagHelperDirectiveDescriptor.Tokens.First(),
DirectiveToken = CSharpCodeParser.AddTagHelperDirectiveDescriptor.Tokens.First(),
Source = BuildSourceSpanFromNode(span),
});
@ -269,8 +269,8 @@ namespace Microsoft.AspNetCore.Razor.Language
{
directiveNode = new MalformedDirectiveIntermediateNode()
{
Name = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor.Directive,
Descriptor = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor,
DirectiveName = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor.Directive,
Directive = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor,
Source = BuildSourceSpanFromNode(span),
};
}
@ -278,8 +278,8 @@ namespace Microsoft.AspNetCore.Razor.Language
{
directiveNode = new DirectiveIntermediateNode()
{
Name = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor.Directive,
Descriptor = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor,
DirectiveName = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor.Directive,
Directive = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor,
Source = BuildSourceSpanFromNode(span),
};
}
@ -294,7 +294,7 @@ namespace Microsoft.AspNetCore.Razor.Language
_builder.Add(new DirectiveTokenIntermediateNode()
{
Content = chunkGenerator.LookupText,
Descriptor = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor.Tokens.First(),
DirectiveToken = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor.Tokens.First(),
Source = BuildSourceSpanFromNode(span),
});
@ -308,8 +308,8 @@ namespace Microsoft.AspNetCore.Razor.Language
{
directiveNode = new MalformedDirectiveIntermediateNode()
{
Name = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor.Directive,
Descriptor = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor,
DirectiveName = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor.Directive,
Directive = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor,
Source = BuildSourceSpanFromNode(span),
};
}
@ -317,8 +317,8 @@ namespace Microsoft.AspNetCore.Razor.Language
{
directiveNode = new DirectiveIntermediateNode()
{
Name = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor.Directive,
Descriptor = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor,
DirectiveName = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor.Directive,
Directive = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor,
Source = BuildSourceSpanFromNode(span),
};
}
@ -333,7 +333,7 @@ namespace Microsoft.AspNetCore.Razor.Language
_builder.Add(new DirectiveTokenIntermediateNode()
{
Content = chunkGenerator.Prefix,
Descriptor = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor.Tokens.First(),
DirectiveToken = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor.Tokens.First(),
Source = BuildSourceSpanFromNode(span),
});

View File

@ -201,8 +201,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
{
"private",
},
Name = context.GetFieldName(tagHelper),
Type = "global::" + tagHelper.GetTypeName(),
FieldName = context.GetFieldName(tagHelper),
FieldType = "global::" + tagHelper.GetTypeName(),
});
}

View File

@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
private void WriteDesignTimeDirectiveToken(CodeRenderingContext context, DirectiveTokenIntermediateNode node)
{
var tokenKind = node.Descriptor.Kind;
var tokenKind = node.DirectiveToken.Kind;
if (!node.Source.HasValue ||
!string.Equals(
context.SourceDocument?.FilePath,

View File

@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Razor.Language
public FileSystemRazorProjectItem(string basePath, string path, FileInfo file)
{
BasePath = basePath;
Path = path;
FilePath = path;
File = file;
}
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Razor.Language
public override string BasePath { get; }
public override string Path { get; }
public override string FilePath { get; }
public override bool Exists => File.Exists;

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public IList<string> Modifiers { get; } = new List<string>();
public string Name { get; set; }
public string ClassName { get; set; }
public string BaseType { get; set; }

View File

@ -10,11 +10,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
{
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
public string Name { get; set; }
public string DirectiveName { get; set; }
public IEnumerable<DirectiveTokenIntermediateNode> Tokens => Children.OfType<DirectiveTokenIntermediateNode>();
public DirectiveDescriptor Descriptor { get; set; }
public DirectiveDescriptor Directive { get; set; }
public override void Accept(IntermediateNodeVisitor visitor)
{

View File

@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public string Content { get; set; }
public DirectiveTokenDescriptor Descriptor { get; set; }
public DirectiveTokenDescriptor DirectiveToken { get; set; }
public override void Accept(IntermediateNodeVisitor visitor)
{

View File

@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public override void VisitDirective(DirectiveIntermediateNode node)
{
if (_directive == node.Descriptor)
if (_directive == node.Directive)
{
Directives.Add(new IntermediateNodeReference(Parent, node));
}

View File

@ -12,9 +12,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public IList<string> Modifiers { get; } = new List<string>();
public string Name { get; set; }
public string FieldName { get; set; }
public string Type { get; set; }
public string FieldType { get; set; }
public override void Accept(IntermediateNodeVisitor visitor)
{

View File

@ -10,11 +10,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
{
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
public string Name { get; set; }
public string DirectiveName { get; set; }
public IEnumerable<DirectiveTokenIntermediateNode> Tokens => Children.OfType<DirectiveTokenIntermediateNode>();
public DirectiveDescriptor Descriptor { get; set; }
public DirectiveDescriptor Directive { get; set; }
public override void Accept(IntermediateNodeVisitor visitor)
{

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public IList<string> Modifiers { get; } = new List<string>();
public string Name { get; set; }
public string MethodName { get; set; }
public string ReturnType { get; set; }

View File

@ -12,9 +12,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public IList<string> Modifiers { get; } = new List<string>();
public string Name { get; set; }
public string PropertyName { get; set; }
public string Type { get; set; }
public string PropertyType { get; set; }
public override void Accept(IntermediateNodeVisitor visitor)
{

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public string TagName { get; set; }
public ICollection<TagHelperDescriptor> TagHelpers { get; } = new List<TagHelperDescriptor>();
public IList<TagHelperDescriptor> TagHelpers { get; } = new List<TagHelperDescriptor>();
public TagHelperBodyIntermediateNode Body => Children.OfType<TagHelperBodyIntermediateNode>().SingleOrDefault();

View File

@ -19,14 +19,14 @@ namespace Microsoft.AspNetCore.Razor.Language
public NotFoundProjectItem(string basePath, string path)
{
BasePath = basePath;
Path = path;
FilePath = path;
}
/// <inheritdoc />
public override string BasePath { get; }
/// <inheritdoc />
public override string Path { get; }
public override string FilePath { get; }
/// <inheritdoc />
public override bool Exists => false;

View File

@ -77,7 +77,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var configurationFeature = new DefaultDocumentClassifierPassFeature();
configurationFeature.ConfigureClass.Add((document, @class) =>
{
@class.Name = "Template";
@class.ClassName = "Template";
@class.Modifiers.Add("public");
});
@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Razor.Language
configurationFeature.ConfigureMethod.Add((document, method) =>
{
method.Name = "ExecuteAsync";
method.MethodName = "ExecuteAsync";
method.ReturnType = $"global::{typeof(Task).FullName}";
method.Modifiers.Add("public");

View File

@ -18,9 +18,9 @@ namespace Microsoft.AspNetCore.Razor.Language
public abstract string BasePath { get; }
/// <summary>
/// Path relative to <see cref="BasePath"/>.
/// File path relative to <see cref="BasePath"/>.
/// </summary>
public abstract string Path { get; }
public abstract string FilePath { get; }
/// <summary>
/// The absolute path to the file, including the file name.
@ -47,11 +47,11 @@ namespace Microsoft.AspNetCore.Razor.Language
{
if (BasePath == "/")
{
return Path;
return FilePath;
}
else
{
return BasePath + Path;
return BasePath + FilePath;
}
}
}
@ -82,26 +82,26 @@ namespace Microsoft.AspNetCore.Razor.Language
{
get
{
var index = Path.LastIndexOf('/');
return Path.Substring(index + 1);
var index = FilePath.LastIndexOf('/');
return FilePath.Substring(index + 1);
}
}
/// <summary>
/// Path relative to <see cref="BasePath"/> without the extension.
/// File path relative to <see cref="BasePath"/> without the extension.
/// </summary>
public string PathWithoutExtension
public string FilePathWithoutExtension
{
get
{
var index = Path.LastIndexOf('.');
var index = FilePath.LastIndexOf('.');
if (index == -1)
{
return Path;
return FilePath;
}
else
{
return Path.Substring(0, index);
return FilePath.Substring(0, index);
}
}
}

View File

@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var path = projectItem.PhysicalPath;
if (string.IsNullOrEmpty(path))
{
path = projectItem.Path;
path = projectItem.FilePath;
}
using (var inputStream = projectItem.Read())

View File

@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Razor.Language
if (!projectItem.Exists)
{
throw new InvalidOperationException(Resources.FormatRazorTemplateEngine_ItemCouldNotBeFound(projectItem.Path));
throw new InvalidOperationException(Resources.FormatRazorTemplateEngine_ItemCouldNotBeFound(projectItem.FilePath));
}
var codeDocument = CreateCodeDocument(projectItem);
@ -146,7 +146,7 @@ namespace Microsoft.AspNetCore.Razor.Language
if (!projectItem.Exists)
{
throw new InvalidOperationException(Resources.FormatRazorTemplateEngine_ItemCouldNotBeFound(projectItem.Path));
throw new InvalidOperationException(Resources.FormatRazorTemplateEngine_ItemCouldNotBeFound(projectItem.FilePath));
}
var source = RazorSourceDocument.ReadFrom(projectItem);
@ -233,7 +233,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var importsFileName = Options.ImportsFileName;
if (!string.IsNullOrEmpty(importsFileName))
{
return Project.FindHierarchicalItems(projectItem.Path, importsFileName);
return Project.FindHierarchicalItems(projectItem.FilePath, importsFileName);
}
return Enumerable.Empty<RazorProjectItem>();

View File

@ -46,7 +46,7 @@ namespace RazorPageGenerator
.SetBaseType("Microsoft.Extensions.RazorViews.BaseView")
.ConfigureClass((document, @class) =>
{
@class.Name = Path.GetFileNameWithoutExtension(document.Source.FilePath);
@class.ClassName = Path.GetFileNameWithoutExtension(document.Source.FilePath);
@class.Modifiers.Clear();
@class.Modifiers.Add("internal");
});
@ -134,7 +134,7 @@ namespace RazorPageGenerator
public override string BasePath => _source.BasePath;
public override string Path => _source.Path;
public override string FilePath => _source.FilePath;
// Mask the full name since we don't want a developer's local file paths to be commited.
public override string PhysicalPath => _source.FileName;

View File

@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode
{
Name = "SomeName",
ClassName = "SomeName",
Annotations =
{
[CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass,
@ -163,7 +163,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode
{
Name = "SomeName",
ClassName = "SomeName",
Annotations =
{
[CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass,
@ -214,7 +214,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode
{
Name = "SomeName",
ClassName = "SomeName",
Annotations =
{
[CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass,
@ -256,7 +256,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var builder = IntermediateNodeBuilder.Create(irDocument);
var pageDirective = new DirectiveIntermediateNode
{
Descriptor = PageDirective.Directive,
Directive = PageDirective.Directive,
};
builder.Add(pageDirective);
@ -271,7 +271,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode
{
Name = "SomeName",
ClassName = "SomeName",
Annotations =
{
[CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass,
@ -323,7 +323,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode
{
Name = "SomeName",
ClassName = "SomeName",
Annotations =
{
[CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass,

View File

@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// Assert
Assert.Equal("global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>", visitor.Class.BaseType);
Assert.Equal(new[] { "public" }, visitor.Class.Modifiers);
Assert.Equal("Test_cshtml", visitor.Class.Name);
Assert.Equal("Test_cshtml", visitor.Class.ClassName);
}
[Theory]
@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument);
// Assert
Assert.Equal(expected, visitor.Class.Name);
Assert.Equal(expected, visitor.Class.ClassName);
}
[Fact]
@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument);
// Assert
Assert.Equal(expected, visitor.Class.Name);
Assert.Equal(expected, visitor.Class.ClassName);
}
[Fact]
@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument);
// Assert
Assert.Equal(expected, visitor.Class.Name);
Assert.Equal(expected, visitor.Class.ClassName);
}
[Fact]
@ -182,7 +182,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument);
// Assert
Assert.Equal("ExecuteAsync", visitor.Method.Name);
Assert.Equal("ExecuteAsync", visitor.Method.MethodName);
Assert.Equal("global::System.Threading.Tasks.Task", visitor.Method.ReturnType);
Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers);
}

View File

@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var imports = "c:\\foo\\baz\\bleh.cshtml";
var node = new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan(imports, 0, 0, 0, 0),
};
@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var imports = "c:\\foo\\baz\\bleh.cshtml";
var node = new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan(imports, 0, 0, 0, 0),
};
node.Children.Add(new DirectiveTokenIntermediateNode() { Content = string.Empty });
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// Arrange
var node = new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan(imports, 0, 0, 0, 0),
};
@ -95,7 +95,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// Arrange
var node = new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan(imports, 0, 0, 0, 0),
};
@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
builder.Push(new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan("/Account/_ViewImports.cshtml", 0, 0, 0, 0),
});
builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account" });
@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" };
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode() { Name = "default" };
var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" };
builder.Add(@class);
document.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind;
@ -143,7 +143,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// Assert
Assert.Equal("WebApplication.Account.Manage", @namespace.Content);
Assert.Equal("AddUser_Page", @class.Name);
Assert.Equal("AddUser_Page", @class.ClassName);
}
// This is the case where the source file sets the namespace.
@ -157,7 +157,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// This will be ignored.
builder.Push(new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan("/Account/_ViewImports.cshtml", 0, 0, 0, 0),
});
builder.Add(new DirectiveTokenIntermediateNode() { Content = "ignored" });
@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// This will be used.
builder.Push(new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan("/Account/Manage/AddUser.cshtml", 0, 0, 0, 0),
});
builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account.Manage" });
@ -175,7 +175,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" };
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode() { Name = "default" };
var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" };
builder.Add(@class);
document.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind;
@ -190,7 +190,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// Assert
Assert.Equal("WebApplication.Account.Manage", @namespace.Content);
Assert.Equal("AddUser_Page", @class.Name);
Assert.Equal("AddUser_Page", @class.ClassName);
}
// Handles cases where invalid characters appears in FileNames. Note that we don't sanitize the part of
@ -204,7 +204,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
builder.Push(new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan("/Account/_ViewImports.cshtml", 0, 0, 0, 0),
});
builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account" });
@ -213,7 +213,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" };
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode() { Name = "default" };
var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" };
builder.Add(@class);
document.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind;
@ -228,7 +228,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// Assert
Assert.Equal("WebApplication.Account.Manage_Info", @namespace.Content);
Assert.Equal("Add_User_Page", @class.Name);
Assert.Equal("Add_User_Page", @class.ClassName);
}
// This is the case where the source file sets the namespace.
@ -242,7 +242,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// This will be ignored.
builder.Push(new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan("/Account/_ViewImports.cshtml", 0, 0, 0, 0),
});
builder.Add(new DirectiveTokenIntermediateNode() { Content = "ignored" });
@ -251,7 +251,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// This will be used.
builder.Push(new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan("/Account/Manage/AddUser.cshtml", 0, 0, 0, 0),
});
builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account.Manage" });
@ -260,7 +260,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" };
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode() { Name = "default" };
var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" };
builder.Add(@class);
document.DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind;
@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// Assert
Assert.Equal("WebApplication.Account.Manage", @namespace.Content);
Assert.Equal("AddUser_View", @class.Name);
Assert.Equal("AddUser_View", @class.ClassName);
}
// This handles an error case where we can't determine the relationship between the
@ -289,7 +289,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
builder.Push(new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan(null, 0, 0, 0, 0),
});
builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account" });
@ -298,7 +298,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" };
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode() { Name = "default" };
var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" };
builder.Add(@class);
document.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind;
@ -313,7 +313,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// Assert
Assert.Equal("WebApplication.Account", @namespace.Content);
Assert.Equal("default", @class.Name);
Assert.Equal("default", @class.ClassName);
}
[Fact]
@ -325,7 +325,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
builder.Push(new DirectiveIntermediateNode()
{
Descriptor = NamespaceDirective.Directive,
Directive = NamespaceDirective.Directive,
Source = new SourceSpan(null, 0, 0, 0, 0),
});
builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account" });
@ -334,7 +334,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" };
builder.Push(@namespace);
var @class = new ClassDeclarationIntermediateNode() { Name = "default" };
var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" };
builder.Add(@class);
document.DocumentKind = null;
@ -349,7 +349,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// Assert
Assert.Equal("default", @namespace.Content);
Assert.Equal("default", @class.Name);
Assert.Equal("default", @class.ClassName);
}
}
}

View File

@ -137,7 +137,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// Assert
Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", visitor.Class.BaseType);
Assert.Equal(new[] { "public" }, visitor.Class.Modifiers);
Assert.Equal("Test_cshtml", visitor.Class.Name);
Assert.Equal("Test_cshtml", visitor.Class.ClassName);
}
[Theory]
@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument);
// Assert
Assert.Equal(expected, visitor.Class.Name);
Assert.Equal(expected, visitor.Class.ClassName);
}
[Fact]
@ -184,7 +184,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument);
// Assert
Assert.Equal(expected, visitor.Class.Name);
Assert.Equal(expected, visitor.Class.ClassName);
}
[Fact]
@ -207,7 +207,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument);
// Assert
Assert.Equal(expected, visitor.Class.Name);
Assert.Equal(expected, visitor.Class.ClassName);
}
[Fact]
@ -228,7 +228,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument);
// Assert
Assert.Equal("ExecuteAsync", visitor.Method.Name);
Assert.Equal("ExecuteAsync", visitor.Method.MethodName);
Assert.Equal("global::System.Threading.Tasks.Task", visitor.Method.ReturnType);
Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers);
}

View File

@ -116,7 +116,7 @@ namespace TestNamespace
},
BaseType = "TestBase",
Interfaces = new List<string> { "IFoo", "IBar", },
Name = "TestClass",
ClassName = "TestClass",
});
var codeDocument = TestRazorCodeDocument.CreateEmpty();
@ -157,7 +157,7 @@ internal class TestClass : TestBase, IFoo, IBar
"virtual",
"async",
},
Name = "TestMethod",
MethodName = "TestMethod",
ReturnType = "string",
});
@ -200,8 +200,8 @@ internal virtual async string TestMethod()
"internal",
"readonly",
},
Name = "_foo",
Type = "string",
FieldName = "_foo",
FieldType = "string",
});
var codeDocument = TestRazorCodeDocument.CreateEmpty();
@ -239,8 +239,8 @@ internal readonly string _foo;
"internal",
"virtual",
},
Name = "Foo",
Type = "string",
PropertyName = "Foo",
PropertyType = "string",
});
var codeDocument = TestRazorCodeDocument.CreateEmpty();

View File

@ -201,10 +201,10 @@ namespace Microsoft.AspNetCore.Razor.Language
Assert.Equal("TestNamespace", @namespace.Content);
var @class = SingleChild<ClassDeclarationIntermediateNode>(@namespace);
Assert.Equal("TestClass", @class.Name);
Assert.Equal("TestClass", @class.ClassName);
var method = SingleChild<MethodDeclarationIntermediateNode>(@class);
Assert.Equal("TestMethod", method.Name);
Assert.Equal("TestMethod", method.MethodName);
}
[Fact]
@ -270,8 +270,8 @@ namespace Microsoft.AspNetCore.Razor.Language
MethodDeclarationIntermediateNode method)
{
@namespace.Content = Namespace;
@class.Name = Class;
@method.Name = Method;
@class.ClassName = Class;
@method.MethodName = Method;
}
protected override void ConfigureTarget(ICodeTargetBuilder builder)

View File

@ -45,7 +45,7 @@ private void __RazorDirectiveTokenHelpers__() {
{
Source = new SourceSpan("test.cshtml", 0, 0, 0, 5),
Content = "System.String",
Descriptor = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Type),
DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Type),
};
node.Children.Add(token);
@ -80,7 +80,7 @@ System.String __typeHelper = default(System.String);
{
Source = new SourceSpan("test.cshtml", 0, 0, 0, 5),
Content = "System.Collections.Generic",
Descriptor = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Namespace),
DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Namespace),
};
node.Children.Add(token);
@ -115,7 +115,7 @@ global::System.Object __typeHelper = nameof(System.Collections.Generic);
{
Source = new SourceSpan("test.cshtml", 0, 0, 0, 5),
Content = "Foo",
Descriptor = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Member),
DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Member),
};
node.Children.Add(token);
@ -150,13 +150,13 @@ global::System.Object Foo = null;
{
Source = new SourceSpan("test.cshtml", 0, 0, 0, 5),
Content = "Value",
Descriptor = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String),
DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String),
};
var tokenWithQuotedContent = new DirectiveTokenIntermediateNode()
{
Source = new SourceSpan("test.cshtml", 0, 0, 0, 5),
Content = "\"Value\"",
Descriptor = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String),
DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String),
};
node.Children.Add(token);
node.Children.Add(tokenWithQuotedContent);
@ -195,7 +195,7 @@ global::System.Object __typeHelper = ""Value"";
var token = new DirectiveTokenIntermediateNode()
{
Content = "Value",
Descriptor = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String),
DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String),
};
node.Children.Add(token);

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
var codeDocument = RazorCodeDocument.Create(sourceDocument);
var irDocument = new DocumentIntermediateNode();
irDocument.Children.Add(new DirectiveIntermediateNode() { Descriptor = FunctionsDirective.Directive, });
irDocument.Children.Add(new DirectiveIntermediateNode() { Directive = FunctionsDirective.Directive, });
// Act
pass.Execute(codeDocument, irDocument);

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
var codeDocument = RazorCodeDocument.Create(sourceDocument);
var irDocument = new DocumentIntermediateNode();
irDocument.Children.Add(new DirectiveIntermediateNode() { Descriptor = FunctionsDirective.Directive, });
irDocument.Children.Add(new DirectiveIntermediateNode() { Directive = FunctionsDirective.Directive, });
// Act
pass.Execute(codeDocument, irDocument);

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
var codeDocument = RazorCodeDocument.Create(sourceDocument);
var irDocument = new DocumentIntermediateNode();
irDocument.Children.Add(new DirectiveIntermediateNode() { Descriptor = SectionDirective.Directive, });
irDocument.Children.Add(new DirectiveIntermediateNode() { Directive = SectionDirective.Directive, });
// Act
pass.Execute(codeDocument, irDocument);

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var projectItem = new FileSystemRazorProjectItem("/Views", "/Home.cshtml", fileInfo);
// Assert
Assert.Equal("/Home.cshtml", projectItem.Path);
Assert.Equal("/Home.cshtml", projectItem.FilePath);
Assert.Equal("/Views", projectItem.BasePath);
Assert.True(projectItem.Exists);
Assert.Equal("Home.cshtml", projectItem.FileName);

View File

@ -76,20 +76,20 @@ namespace Microsoft.AspNetCore.Razor.Language
var files = fileSystemProject.EnumerateItems("/");
// Assert
Assert.Collection(files.OrderBy(f => f.Path),
Assert.Collection(files.OrderBy(f => f.FilePath),
file =>
{
Assert.Equal("/Home.cshtml", file.Path);
Assert.Equal("/Home.cshtml", file.FilePath);
Assert.Equal("/", file.BasePath);
},
file =>
{
Assert.Equal("/Views/About/About.cshtml", file.Path);
Assert.Equal("/Views/About/About.cshtml", file.FilePath);
Assert.Equal("/", file.BasePath);
},
file =>
{
Assert.Equal("/Views/Home/Index.cshtml", file.Path);
Assert.Equal("/Views/Home/Index.cshtml", file.FilePath);
Assert.Equal("/", file.BasePath);
});
}
@ -104,15 +104,15 @@ namespace Microsoft.AspNetCore.Razor.Language
var files = fileSystemProject.EnumerateItems("/Views");
// Assert
Assert.Collection(files.OrderBy(f => f.Path),
Assert.Collection(files.OrderBy(f => f.FilePath),
file =>
{
Assert.Equal("/About/About.cshtml", file.Path);
Assert.Equal("/About/About.cshtml", file.FilePath);
Assert.Equal("/Views", file.BasePath);
},
file =>
{
Assert.Equal("/Home/Index.cshtml", file.Path);
Assert.Equal("/Home/Index.cshtml", file.FilePath);
Assert.Equal("/Views", file.BasePath);
});
}
@ -142,7 +142,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
Assert.True(file.Exists);
Assert.Equal(path, file.Path);
Assert.Equal(path, file.FilePath);
}
[Fact]

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
var templateEngine = new RazorTemplateEngine(razorEngine, project);
// Act
var resultcSharpDocument = templateEngine.GenerateCode(projectItem.Path);
var resultcSharpDocument = templateEngine.GenerateCode(projectItem.FilePath);
// Assert
AssertCSharpDocumentMatchesBaseline(resultcSharpDocument);
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
var templateEngine = new RazorTemplateEngine(razorEngine, project);
// Act
var cSharpDocument = templateEngine.GenerateCode(projectItem.Path);
var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath);
// Assert
AssertCSharpDocumentMatchesBaseline(cSharpDocument);
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
{
engine.ConfigureClass((document, @class) =>
{
@class.Name = "MyClass";
@class.ClassName = "MyClass";
@class.Modifiers.Clear();
@class.Modifiers.Add("protected");
@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
var templateEngine = new RazorTemplateEngine(razorEngine, project);
// Act
var cSharpDocument = templateEngine.GenerateCode(projectItem.Path);
var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath);
// Assert
AssertCSharpDocumentMatchesBaseline(cSharpDocument);
@ -105,7 +105,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
var templateEngine = new RazorTemplateEngine(razorEngine, project);
// Act
var cSharpDocument = templateEngine.GenerateCode(projectItem.Path);
var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath);
// Assert
AssertCSharpDocumentMatchesBaseline(cSharpDocument);

View File

@ -76,19 +76,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
var match1 = new DirectiveIntermediateNode()
{
Descriptor = directive,
Directive = directive,
};
builder.Add(match1);
var nonMatch = new DirectiveIntermediateNode()
{
Descriptor = directive2,
Directive = directive2,
};
builder.Add(nonMatch);
var match2 = new DirectiveIntermediateNode()
{
Descriptor = directive,
Directive = directive,
};
builder.Add(match2);

View File

@ -95,7 +95,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var projectItem = new TestRazorProjectItem(path, basePath: "/");
// Act
var fileName = projectItem.PathWithoutExtension;
var fileName = projectItem.FilePathWithoutExtension;
// Assert
Assert.Equal(expected, fileName);

View File

@ -86,9 +86,9 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
Assert.Collection(
result,
item => Assert.Equal($"/Views/Home/{fileName}", item.Path),
item => Assert.Equal($"/Views/{fileName}", item.Path),
item => Assert.Equal($"/{fileName}", item.Path));
item => Assert.Equal($"/Views/Home/{fileName}", item.FilePath),
item => Assert.Equal($"/Views/{fileName}", item.FilePath),
item => Assert.Equal($"/{fileName}", item.FilePath));
}
[Fact]
@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
Assert.Collection(
result,
item => Assert.Equal("/File.cshtml", item.Path));
item => Assert.Equal("/File.cshtml", item.FilePath));
}
[Fact]
@ -132,10 +132,10 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
Assert.Collection(
result,
item => Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.Path),
item => Assert.Equal("/Areas/MyArea/File.cshtml", item.Path),
item => Assert.Equal("/Areas/File.cshtml", item.Path),
item => Assert.Equal("/File.cshtml", item.Path));
item => Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.FilePath),
item => Assert.Equal("/Areas/MyArea/File.cshtml", item.FilePath),
item => Assert.Equal("/Areas/File.cshtml", item.FilePath),
item => Assert.Equal("/File.cshtml", item.FilePath));
}
[Fact]
@ -176,27 +176,27 @@ namespace Microsoft.AspNetCore.Razor.Language
result,
item =>
{
Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.Path);
Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.FilePath);
Assert.False(item.Exists);
},
item =>
{
Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.Path);
Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.FilePath);
Assert.False(item.Exists);
},
item =>
{
Assert.Equal("/Areas/MyArea/File.cshtml", item.Path);
Assert.Equal("/Areas/MyArea/File.cshtml", item.FilePath);
Assert.True(item.Exists);
},
item =>
{
Assert.Equal("/Areas/File.cshtml", item.Path);
Assert.Equal("/Areas/File.cshtml", item.FilePath);
Assert.False(item.Exists);
},
item =>
{
Assert.Equal("/File.cshtml", item.Path);
Assert.Equal("/File.cshtml", item.FilePath);
Assert.True(item.Exists);
});
}
@ -223,22 +223,22 @@ namespace Microsoft.AspNetCore.Razor.Language
result,
item =>
{
Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.Path);
Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.FilePath);
Assert.False(item.Exists);
},
item =>
{
Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.Path);
Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.FilePath);
Assert.False(item.Exists);
},
item =>
{
Assert.Equal("/Areas/MyArea/File.cshtml", item.Path);
Assert.Equal("/Areas/MyArea/File.cshtml", item.FilePath);
Assert.True(item.Exists);
},
item =>
{
Assert.Equal("/Areas/File.cshtml", item.Path);
Assert.Equal("/Areas/File.cshtml", item.FilePath);
Assert.False(item.Exists);
});
}
@ -265,12 +265,12 @@ namespace Microsoft.AspNetCore.Razor.Language
result,
item =>
{
Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.Path);
Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.FilePath);
Assert.False(item.Exists);
},
item =>
{
Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.Path);
Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.FilePath);
Assert.False(item.Exists);
});
}
@ -297,7 +297,7 @@ namespace Microsoft.AspNetCore.Razor.Language
result,
item =>
{
Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.Path);
Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.FilePath);
Assert.False(item.Exists);
});
}
@ -325,7 +325,7 @@ namespace Microsoft.AspNetCore.Razor.Language
private RazorProjectItem CreateProjectItem(string path)
{
var projectItem = new Mock<RazorProjectItem>();
projectItem.SetupGet(f => f.Path).Returns(path);
projectItem.SetupGet(f => f.FilePath).Returns(path);
projectItem.SetupGet(f => f.Exists).Returns(true);
return projectItem.Object;
}

View File

@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var document = RazorSourceDocument.ReadFrom(projectItem);
// Assert
Assert.Equal(projectItem.Path, document.FilePath);
Assert.Equal(projectItem.FilePath, document.FilePath);
Assert.Equal(projectItem.Content, ReadContent(document));
}

View File

@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
var import = Assert.Single(imports);
Assert.Equal(projectItem.Path, import.FilePath);
Assert.Equal(projectItem.FilePath, import.FilePath);
}
[Fact]
@ -283,7 +283,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var imports = templateEngine.GetImportItems("/Views/Home/Index.cshtml");
// Assert
var paths = imports.Select(i => i.Path);
var paths = imports.Select(i => i.FilePath);
Assert.Equal(expected, paths);
}
@ -307,7 +307,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var imports = templateEngine.GetImportItems(projectItem);
// Assert
var paths = imports.Select(i => i.Path);
var paths = imports.Select(i => i.FilePath);
Assert.Equal(expected, paths);
}
}

View File

@ -240,7 +240,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
{
public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node)
{
node.Name = FileName.Replace('/', '_');
node.ClassName = FileName.Replace('/', '_');
node.Modifiers.Clear();
node.Modifiers.Add("public");
@ -260,7 +260,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
node.Modifiers.Clear();
node.Modifiers.Add("public");
node.Modifiers.Add("async");
node.Name = "ExecuteAsync";
node.MethodName = "ExecuteAsync";
node.ReturnType = typeof(Task).FullName;
VisitDefault(node);

View File

@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node)
{
WriteContentNode(node, string.Join(" ", node.Modifiers), node.Name, node.BaseType, string.Join(", ", node.Interfaces ?? new List<string>()));
WriteContentNode(node, string.Join(" ", node.Modifiers), node.ClassName, node.BaseType, string.Join(", ", node.Interfaces ?? new List<string>()));
}
public override void VisitCSharpExpressionAttributeValue(CSharpExpressionAttributeValueIntermediateNode node)
@ -52,12 +52,12 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
public override void VisitMalformedDirective(MalformedDirectiveIntermediateNode node)
{
WriteContentNode(node, node.Name);
WriteContentNode(node, node.DirectiveName);
}
public override void VisitDirective(DirectiveIntermediateNode node)
{
WriteContentNode(node, node.Name);
WriteContentNode(node, node.DirectiveName);
}
public override void VisitDirectiveToken(DirectiveTokenIntermediateNode node)
@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
public override void VisitFieldDeclaration(FieldDeclarationIntermediateNode node)
{
WriteContentNode(node, string.Join(" ", node.Modifiers), node.Type, node.Name);
WriteContentNode(node, string.Join(" ", node.Modifiers), node.FieldType, node.FieldName);
}
public override void VisitHtmlAttribute(HtmlAttributeIntermediateNode node)
@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
public override void VisitMethodDeclaration(MethodDeclarationIntermediateNode node)
{
WriteContentNode(node, string.Join(" ", node.Modifiers), node.ReturnType, node.Name);
WriteContentNode(node, string.Join(" ", node.Modifiers), node.ReturnType, node.MethodName);
}
public override void VisitUsingDirective(UsingDirectiveIntermediateNode node)

View File

@ -140,7 +140,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
try
{
var directive = Assert.IsType<DirectiveIntermediateNode>(node);
Assert.Equal(expectedName, directive.Name);
Assert.Equal(expectedName, directive.DirectiveName);
}
catch (XunitException e)
{
@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
try
{
var token = Assert.IsType<DirectiveTokenIntermediateNode>(node);
Assert.Equal(expectedKind, token.Descriptor.Kind);
Assert.Equal(expectedKind, token.DirectiveToken.Kind);
Assert.Equal(expectedContent, token.Content);
}
catch (XunitException e)
@ -314,7 +314,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
try
{
var fieldNode = Assert.IsType<FieldDeclarationIntermediateNode>(node);
Assert.Equal(typeFullName, fieldNode.Type);
Assert.Equal(typeFullName, fieldNode.FieldType);
}
catch (XunitException e)
{

View File

@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Razor.Language
public TestRazorProject(IList<RazorProjectItem> items)
{
_lookup = items.ToDictionary(item => item.Path);
_lookup = items.ToDictionary(item => item.FilePath);
}
public override IEnumerable<RazorProjectItem> EnumerateItems(string basePath)

View File

@ -13,14 +13,14 @@ namespace Microsoft.AspNetCore.Razor.Language
string physicalPath = null,
string basePath = "/")
{
Path = path;
FilePath = path;
PhysicalPath = physicalPath;
BasePath = basePath;
}
public override string BasePath { get; }
public override string Path { get; }
public override string FilePath { get; }
public override string PhysicalPath { get; }