Skip to content

Enable native interop with static extern class methods #2876

Closed

Description

It would be really neat if we could to native interop with classes.

class NativeMethods{
  [DllImport("kernel32", SetLastError=$true)]
  hidden static extern [bool] SetConsoleMode([IntPtr] $handle, [int] $mode)
}

How much work would it be to get this working?

Activity

  1. lzybkr commented on Dec 13, 2016

    @lzybkr
    Contributor

    Maybe not a lot of work, but it is a common enough ask that we should do it.

    There is one important language design choice to make, how to declare a struct. Pinvoke would be much less useful without structs.

    A struct is probably not generally useful in PowerShell, we box way too often, so I was thinking of using an attribute like ExplicitLayout to imply struct instead of adding a keyword.

  2. IISResetMe commented on Mar 8, 2019

    @IISResetMe
    Collaborator

    Looks like we may be able to do this as soon as we're clear to move to .NET 3.0 - this already works on 3.0.0-preview2 release of the SDK IISResetMe@4fa5363 (warrants a bit of a cleanup in PSType.cs, I'll keep working on that in the meantime)

  3. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  4. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  5. added
    Resolution-No Activity
    on Nov 16, 2023
  6. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  7. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-No ActivityWG-Language

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions