mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Added comma to the list of replaced characters in assemblyname (#4136)
This commit is contained in:
@@ -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'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user