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:
Jason Shirk
2017-11-02 10:29:10 -07:00
committed by GitHub
parent 237ccbdf6d
commit 71d5439bbe
4 changed files with 42 additions and 24 deletions
@@ -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" {