Skip to content

GetCustomAttributes fails to retrieve CmdletAttribute with ConfirmImpact property #1252

Closed

Description

Steps to reproduce

[System.Management.Automation.Cmdlet("Get", "Thing", ConfirmImpact = 'High', SupportsPaging = $true)]class C2{}
$t = [C2].GetCustomAttributes($false)
$t

From Scripting.Classes.Basic.Parsing.Tests.ps1

Expected behavior

NounName                : Thing
VerbName                : Get
DefaultParameterSetName :
SupportsShouldProcess   : False
SupportsPaging          : True
SupportsTransactions    : False
ConfirmImpact           : High
HelpUri                 :
RemotingCapability      : PowerShell
TypeId                  : System.Management.Automation.CmdletAttribute

Actual behavior

Exception calling "GetCustomAttributes" with "1" argument(s): "'ConfirmImpact' property specified was not found."
At line:1 char:9
+         $t = [C2].GetCustomAttributes($false)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : CustomAttributeFormatException

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.10032.0
PSEdition                      Linux
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v0.5.0-217-g9c9161febac5fc433d1987e75d8ba9b18fd286c1
CLRVersion
WSManStackVersion              1.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Activity

  1. self-assigned this
    on Jul 2, 2016
  2. added this to the v0.7.0 milestone on Jul 2, 2016
  3. changed the title [-]ConfirmAttribute seems to be missing from Cmdlet class[/-] [+]GetCustomAttributes fails to retrieve CmdletAttribute with ConfirmImpact property[/+] on Jul 6, 2016
  4. daxian-dbw commented on Jul 14, 2016

    @daxian-dbw
    Member

    This issue has something to do with the new ALC model. I have brought up this to CoreCLR team.

  5. modified the milestones: , Aug17 on Jul 28, 2016
  6. daxian-dbw commented on Jul 29, 2016

    @daxian-dbw
    Member

    This is a reflection bug in CoreCLR. It has been reported to CoreCLR team.

  7. modified the milestones: , on Aug 3, 2016
  8. daxian-dbw commented on Aug 3, 2016

    @daxian-dbw
    Member

    SandeepSutari I think we need to move this issue to future. This is a reflection bug in CoreCLR and it won't be fixed in the near future.

  9. daxian-dbw commented on Oct 14, 2016

    @daxian-dbw
    Member

    Fixed via PR #2472

    This was caused by a bug in AssemblyLoadContext -- dynamic assemblies are not correctly associated with the right load context. This has been fixed in the .NET Core preview packages for Nov. release (1.1.0).

    Now it works fine:

    PS C:\> [System.Management.Automation.Cmdlet("Get", "Thing", ConfirmImpact = 'High', SupportsPaging = $true)]class C2{}
    PS C:\> $t = [C2].GetCustomAttributes($false)
    PS C:\> $t
    
    NounName                : Thing
    VerbName                : Get
    DefaultParameterSetName :
    SupportsShouldProcess   : False
    SupportsPaging          : True
    SupportsTransactions    : False
    ConfirmImpact           : High
    HelpUri                 :
    RemotingCapability      : PowerShell
    TypeId                  : System.Management.Automation.CmdletAttribute
    
    PS C:\>
    PS C:\>
    PS C:\> $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    BuildVersion                   3.0.0.0
    WSManStackVersion              3.0
    PSEdition                      Core
    GitCommitId                    v6.0.0-alpha.10-136-g001f6ecf72481e59e6f81e0f06f59a3e8a6dd587
    SerializationVersion           1.1.0.1
    PSVersion                      6.0.0-alpha
    PSRemotingProtocolVersion      2.3
    CLRVersion
    
    PS C:\>
    
  10. modified the milestones: 6.0.0-alpha.12, on Oct 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Blockedblocked on something external to this repoIssue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimeWG-Maintainers-Buildspecific to affecting the build

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions