PR feedback

This commit is contained in:
Ryan Nowak 2017-05-19 09:47:55 -07:00
parent 2a88d6efcf
commit f4f291a7f2
4 changed files with 7 additions and 7 deletions

View File

@ -6,7 +6,7 @@ using System.Text;
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
{
internal static class ClassName
internal static class CSharpIdentifier
{
public static string GetClassNameFromPath(string path)
{

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FileName;
base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method);
@class.Name = ClassName.GetClassNameFromPath(filePath);
@class.Name = CSharpIdentifier.GetClassNameFromPath(filePath);
@class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>";
@class.AccessModifier = "public";
@namespace.Content = "AspNetCore";

View File

@ -63,14 +63,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
{
// Beautify the class name since we're using a hierarchy for namespaces.
var @class = visitor.FirstClass;
var prefix = Path.GetFileNameWithoutExtension(codeDocument.Source.FileName);
var prefix = CSharpIdentifier.SanitizeClassName(Path.GetFileNameWithoutExtension(codeDocument.Source.FileName));
if (@class != null && irDocument.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind)
{
@class.Name = ClassName.SanitizeClassName(prefix + "_Page");
@class.Name = prefix + "_Page";
}
else if (@class != null && irDocument.DocumentKind == MvcViewDocumentClassifierPass.MvcViewDocumentKind)
{
@class.Name = ClassName.SanitizeClassName(prefix + "_View");
@class.Name = prefix + "_View";
}
}
@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
for (var i = 0; i < segments.Length - 1; i++)
{
builder.Append('.');
builder.Append(ClassName.SanitizeClassName(segments[i]));
builder.Append(CSharpIdentifier.SanitizeClassName(segments[i]));
}
@namespace = builder.ToString();

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method);
@class.BaseType = "global::Microsoft.AspNetCore.Mvc.RazorPages.Page";
@class.Name = ClassName.GetClassNameFromPath(filePath);
@class.Name = CSharpIdentifier.GetClassNameFromPath(filePath);
@class.AccessModifier = "public";
@namespace.Content = "AspNetCore";
method.Name = "ExecuteAsync";