8000 Added comma to the list of replaced characters in assemblyname (#4136) · PowerShell/PowerShell@d1e05ef · GitHub
[go: up one dir, main page]

Skip to content

Commit d1e05ef

Browse files
TimCurwickdaxian-dbw
authored andcommitted
Added comma to the list of replaced characters in assemblyname (#4136)
1 parent 36eaab2 commit d1e05ef

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/System.Management.Automation/engine/parser/PSType.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,13 +1112,14 @@ internal static Assembly DefineTypes(Parser parser, Ast rootAst, TypeDefinitionA
11121112

11131113
var definedTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
11141114

1115-
// First character is a special mark that allows us to cheaply ignore dynamic generated assemblies in ClrFacede.GetAssemblies()
1116-
// Two replaces at the end are for not-allowed characters. They are replaced by similar-looking chars.
1115+
// First character is a special mark that allows us to cheaply ignore dynamic generated assemblies in ClrFacade.GetAssemblies()
1116+
// The replaces at the end are for not-allowed characters. They are replaced by similar-looking chars.
11171117
string assemblyName = ClrFacade.FIRST_CHAR_PSASSEMBLY_MARK + (string.IsNullOrWhiteSpace(rootAst.Extent.File)
11181118
? "powershell"
11191119
: rootAst.Extent.File
11201120
.Replace('\\', (char)0x29f9)
11211121
.Replace('/', (char)0x29f9)
1122+
.Replace(',', (char)0x201a)
11221123
.Replace(':', (char)0x0589));
11231124

11241125
var assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(assemblyName),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Describe "Script with a class definition run path" -Tags "CI" {
2+
3+
$TestCases = @(
4+
@{ FileName = 'MyTest.ps1'; Name = 'path without a comma' }
5+
@{ FileName = 'My,Test.ps1'; Name = 'path with a comma' }
6+
)
7+
8+
It "Script with a class definition can run from a <Name>" -TestCases $TestCases {
9+
param( $FileName )
10+
11+
$FilePath = Join-Path -Path $TestDrive -ChildPath $FileName
12+
13+
@'
14+
class MyClass { static [string]$MyProperty = 'Some value' }
15+
[MyClass]::MyProperty
16+
'@ | Out-File -FilePath $FilePath
17+
18+
( . $FilePath ) | Should Match 'Some value'
19+
}
20+
}

0 commit comments

Comments
 (0)
0