PR feedback
This commit is contained in:
parent
2a88d6efcf
commit
f4f291a7f2
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue