Added comma to the list of replaced characters in assemblyname (#4136)

This commit is contained in:
Tim Curwick
2017-07-06 11:32:54 -07:00
committed by Dongbo Wang
parent 36eaab2809
commit d1e05efbf1
2 changed files with 23 additions and 2 deletions
@@ -1112,13 +1112,14 @@ namespace System.Management.Automation.Language
var definedTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
// First character is a special mark that allows us to cheaply ignore dynamic generated assemblies in ClrFacede.GetAssemblies()
// Two replaces at the end are for not-allowed characters. They are replaced by similar-looking chars.
// First character is a special mark that allows us to cheaply ignore dynamic generated assemblies in ClrFacade.GetAssemblies()
// The replaces at the end are for not-allowed characters. They are replaced by similar-looking chars.
string assemblyName = ClrFacade.FIRST_CHAR_PSASSEMBLY_MARK + (string.IsNullOrWhiteSpace(rootAst.Extent.File)
? "powershell"
: rootAst.Extent.File
.Replace('\\', (char)0x29f9)
.Replace('/', (char)0x29f9)
.Replace(',', (char)0x201a)
.Replace(':', (char)0x0589));
var assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(assemblyName),
@@ -0,0 +1,20 @@
Describe "Script with a class definition run path" -Tags "CI" {
$TestCases = @(
@{ FileName = 'MyTest.ps1'; Name = 'path without a comma' }
@{ FileName = 'My,Test.ps1'; Name = 'path with a comma' }
)
It "Script with a class definition can run from a <Name>" -TestCases $TestCases {
param( $FileName )
$FilePath = Join-Path -Path $TestDrive -ChildPath $FileName
@'
class MyClass { static [string]$MyProperty = 'Some value' }
[MyClass]::MyProperty
'@ | Out-File -FilePath $FilePath
( . $FilePath ) | Should Match 'Some value'
}
}