Update ContentPathGenerator.tt (PascalCase)

This commit is contained in:
foxnne 2019-09-12 11:54:44 -05:00
parent 4f8a7af367
commit d36e9c03b2

View File

@ -23,7 +23,7 @@ namespace Nez
WriteLine( $"\t\t// folder: {sourceFolder}" );
// handle any files in the root sourceFolder
printContentFiles( sourceFolder, 2, sourceFolder );
PrintContentFiles( sourceFolder, 2, sourceFolder );
// loop through all the directories in our sourceFolder
var directories = Directory.GetDirectories( sourceFolder );
@ -34,11 +34,11 @@ namespace Nez
continue;
// dont delve into directories that don't contan xnb files if this is the CompiledContent folder
if( !shouldTraverseSubfolders( dir ) )
if( !ShouldTraverseSubfolders( dir ) )
continue;
// start off the recursive directory printing
printDirectoryClass( dir, 2, sourceFolder );
PrintDirectoryClass( dir, 2, sourceFolder );
}
}
#>
@ -61,7 +61,7 @@ namespace Nez
"throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while"
};
bool shouldTraverseSubfolders( string path )
bool ShouldTraverseSubfolders( string path )
{
if( !path.Contains( "/bin/" ) )
{
@ -72,26 +72,26 @@ namespace Nez
}
// recursively creates a class for each directory
void printDirectoryClass( string dir, int depth, string sourceFolder )
void PrintDirectoryClass( string dir, int depth, string sourceFolder )
{
var dirInfo = new DirectoryInfo( dir );
var firstIndent = new string( ' ', depth * 4 );
var className = generateClassName( dirInfo.Name, true );
var className = GenerateClassName( dirInfo.Name );
WriteLine( "{0}public static class {1}\n{2}{{", firstIndent, className, firstIndent );
// handle subdirectories
foreach( var subdir in Directory.GetDirectories( dir ) )
printDirectoryClass( subdir, depth + 1, sourceFolder );
PrintDirectoryClass( subdir, depth + 1, sourceFolder );
// handle files
printContentFiles( dir, depth + 1, sourceFolder );
PrintContentFiles( dir, depth + 1, sourceFolder );
WriteLine( "{0}}}\n", firstIndent );
}
// prints a const string for each file in the directory
void printContentFiles( string dir, int depth, string sourceFolder )
void PrintContentFiles( string dir, int depth, string sourceFolder )
{
var firstIndent = new string( ' ', depth * 4 );
@ -110,7 +110,7 @@ namespace Nez
fileName = fileName.Replace( extension, string.Empty );
}
var className = generateClassName( fileName, false );
var className = GenerateClassName( fileName );
if( finalPath[0] == '/' || finalPath[0] == '\\' )
finalPath = finalPath.Substring( 1 );
@ -129,14 +129,14 @@ namespace Nez
}
string stripInvalidPathChars( string input )
string StripInvalidPathChars( string input )
{
var invalidChars = Path.GetInvalidPathChars();
return new string( input.Where( m => !invalidChars.Contains( m ) ).ToArray<char>() );
}
string stripInvalidFilenameChars( string input )
string StripInvalidFilenameChars( string input )
{
var invalidChars = Path.GetInvalidFileNameChars();
return new string( input.Where( m => !invalidChars.Contains( m ) ).ToArray<char>() );
@ -144,13 +144,9 @@ namespace Nez
// attempts to generate a proper path name
string generateClassName( string className, bool uppercaseFirstChar )
string GenerateClassName( string className )
{
// handle upper or lower casing the first char in the className
if( uppercaseFirstChar && char.IsLower( className[0] ) )
className = char.ToUpper( className[0] ) + className.Substring( 1 );
else if( !uppercaseFirstChar && char.IsUpper( className[0] ) )
className = char.ToLower( className[0] ) + className.Substring( 1 );
className = char.ToUpper( className[0] ) + className.Substring( 1 );
// remove invalid characters
var regex = new Regex( @"[^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Nl}\p{Mn}\p{Mc}\p{Cf}\p{Pc}\p{Lm}]" );