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 namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
{ {
internal static class ClassName internal static class CSharpIdentifier
{ {
public static string GetClassNameFromPath(string path) 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; var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FileName;
base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); 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.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>";
@class.AccessModifier = "public"; @class.AccessModifier = "public";
@namespace.Content = "AspNetCore"; @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. // Beautify the class name since we're using a hierarchy for namespaces.
var @class = visitor.FirstClass; 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) 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) 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++) for (var i = 0; i < segments.Length - 1; i++)
{ {
builder.Append('.'); builder.Append('.');
builder.Append(ClassName.SanitizeClassName(segments[i])); builder.Append(CSharpIdentifier.SanitizeClassName(segments[i]));
} }
@namespace = builder.ToString(); @namespace = builder.ToString();

View File

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