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
    WG-Engine
    WG-Maintainers-Build
    on Jul 2, 2016
  3. added this to the v0.7.0 milestone on Jul 2, 2016
  4. changed the title [-]ConfirmAttribute seems to be missing from Cmdlet class[/-] [+]GetCustomAttributes fails to retrieve CmdletAttribute with ConfirmImpact property[/+] on Jul 6, 2016
  5. 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.

  6. modified the milestones: , Aug17 on Jul 28, 2016
  7. added
    Blocked
    on Jul 29, 2016
  8. daxian-dbw commented on Jul 29, 2016

    @daxian-dbw
    Member

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

  9. modified the milestones: , on Aug 3, 2016
  10. 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.

  11. added
    Issue-Bug
    on Sep 2, 2016
  12. 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:\>
    
  13. 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

BlockedIssue-BugResolution-FixedWG-EngineWG-Maintainers-Build

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions