mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix dynamic class assembly name (#5292)
Using the assembly name to hint at the source of the classes was
problematic in multiple ways.
This change stores the actual filename in an attribute on the assembly.
So for a given type, one can get the assembly this way:
[SomeType].Assembly.GetCustomAttributes() |
? { $_ -is [System.Management.Automation.DynamicClassImplementationAssemblyAttribute] } |
% { $_.ScriptFile }
This commit is contained in:
@@ -688,6 +688,14 @@ Describe 'Type building' -Tags "CI" {
|
||||
++$a::a | Should Be 2
|
||||
}
|
||||
}
|
||||
|
||||
It 'should get the script from a class type' {
|
||||
class C {}
|
||||
|
||||
$a = [C].Assembly.GetCustomAttributes($false).Where{
|
||||
$_ -is [System.Management.Automation.DynamicClassImplementationAssemblyAttribute]}
|
||||
$a.ScriptFile | Should BeExactly $PSCommandPath
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'RuntimeType created for TypeDefinitionAst' -Tags "CI" {
|
||||
|
||||
Reference in New Issue
Block a user