Skip to content

Commit

Permalink
Merge pull request stride3d#759 from Eideren/template_validation
Browse files Browse the repository at this point in the history
Template validation
  • Loading branch information
xen2 authored Jun 14, 2020
2 parents 7ee24d0 + 500fcf6 commit 9578a99
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sources/core/Stride.Core.AssemblyProcessor/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public static string BuildValidClassName([NotNull] string originalName, char rep
[NotNull]
public static string BuildValidClassName([NotNull] string originalName, IEnumerable<string> additionalReservedWords, char replacementCharacter = '_')
{
// C# identifiers must start with a letter or underscore
if (char.IsLetter(originalName[0]) == false && originalName[0] != '_')
originalName = "_" + originalName;

if (ReservedNames.Contains(originalName))
return originalName + replacementCharacter;

Expand Down Expand Up @@ -70,6 +74,10 @@ public static string BuildValidNamespaceName([NotNull] string originalName, char
[NotNull]
public static string BuildValidNamespaceName([NotNull] string originalName, IEnumerable<string> additionalReservedWords, char replacementCharacter = '_')
{
// C# identifiers must start with a letter or underscore
if (char.IsLetter(originalName[0]) == false && originalName[0] != '_')
originalName = "_" + originalName;

if (ReservedNames.Contains(originalName))
return originalName + replacementCharacter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
Description = parameters.Description,
Package = package,
Logger = parameters.Logger,
Namespace = parameters.Namespace
};

// Generate executable projects for each platform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static IEnumerable<SolutionProject> UpdatePackagePlatforms(PackageTemplat
OutputDirectory = package.FullPath.GetFullDirectory().GetParent(),
Session = package.Session,
Description = packageParameters.Description,
Namespace = packageParameters.Namespace
};

// Setup the ProjectGameGuid to be accessible from exec (in order to be able to link to the game project.
Expand Down
1 change: 1 addition & 0 deletions sources/tools/Stride.ProjectGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private static void GenerateUnitTestProject(string outputDirectory, string templ
templateGeneratorParameters.Logger = result;
templateGeneratorParameters.Description = new TemplateDescription();
templateGeneratorParameters.Id = assetId;
templateGeneratorParameters.Namespace = projectNamespace;

if (!PackageUnitTestGenerator.Default.PrepareForRun(templateGeneratorParameters).Result)
{
Expand Down

0 comments on commit 9578a99

Please sign in to comment.