Fixed generic components with fully qualified names (dotnet/aspnetcore-tooling#356)

\n\nCommit migrated from b7392f1f84
This commit is contained in:
Ajay Bhargav Baaskaran 2019-03-22 14:22:12 -07:00 committed by GitHub
parent 92d931c229
commit 1d53925b8e
4 changed files with 16 additions and 1 deletions

View File

@ -53,6 +53,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
public static string SanitizeClassName(string inputName)
{
if (string.IsNullOrEmpty(inputName))
{
return inputName;
}
if (!IsIdentifierStart(inputName[0]) && IsIdentifierPart(inputName[0]))
{
inputName = "_" + inputName;

View File

@ -53,6 +53,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X
public static string SanitizeClassName(string inputName)
{
if (string.IsNullOrEmpty(inputName))
{
return inputName;
}
if (!IsIdentifierStart(inputName[0]) && IsIdentifierPart(inputName[0]))
{
inputName = "_" + inputName;

View File

@ -35,6 +35,11 @@ namespace Microsoft.AspNetCore.Razor.Language
public static string SanitizeIdentifier(string inputName)
{
if (string.IsNullOrEmpty(inputName))
{
return inputName;
}
if (!IsIdentifierStart(inputName[0]) && IsIdentifierPart(inputName[0]))
{
inputName = "_" + inputName;

View File

@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
// Method name is generated and guaranteed not to collide, since it's unique for each
// component call site.
MethodName = $"Create{node.TagName}_{_id++}",
MethodName = $"Create{CSharpIdentifier.SanitizeIdentifier(node.TagName)}_{_id++}",
FullTypeName = @namespace + ".TypeInference",
};