FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update README files for native code for migration by adityapatwardhan · Pull Request #7248 · PowerShell/PowerShell · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
57 changes: 3 additions & 54 deletions src/libpsl-native/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,56 +1,5 @@
# libpsl-native

This library provides functionality missing from .NET Core via system calls,
that are called from from the `CorePsPlatform.cs` file of PowerShell. The
method to do this is a Platform Invoke, which is C#'s Foreign Function
Interface to C code (and C++ by way of `extern C`).

## Build

[CMake][] is used to build the project, which results in a `libpsl-native.so`
library on Linux, and `libpsl-native.dylib` on OS X.

```sh
cmake -DCMAKE_BUILD_TYPE=Debug .
make -j
```

[CMake]: https://cmake.org/cmake/help/v2.8.12/cmake.html

## Test

The [Google Test][] framework is used for unit tests.

Use either `make test` or `ctest --verbose` for more output.

[Google Test]: https://github.com/google/googletest/tree/release-1.7.0

## Notes

Marshalling data from native to managed code is much easier on Linux than it is
on Windows. For instance, to return a string, you simply return a copy of it on
the heap. Since only one memory allocator is used on Linux, the .NET runtime
has no problem later freeing the buffer. Additionally, .NET presumes that the
codepage "Ansi" on Linux is always UTF-8. So just marshal the string as
`UnmanagedType.LPStr`.

### C# (Managed)

```c#
[DllImport("libpsl-native", CharSet = CharSet.Ansi)]
[return: MarshalAs(UnmanagedType.LPStr)]
internal static extern string GetSomeString();
```

### C (Native)

```c
char *GetSomeString()
{
return strdup("some string");
}
```

The CoreFX team has an excellent guide for [UNIX Interop][].

[UNIX Interop]: https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/interop-guidelines.md#unix-shims
The code under `powershell-native` is being migrated to [PowerShell-native](https://github.com/PowerShell/PowerShell-native) repository.
Please make PRs to the new repository.
Code under here will be removed once the move is complete.
5 changes: 5 additions & 0 deletions src/powershell-native/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# powershell-native

The code under `powershell-native` is being migrated to [PowerShell-native](https://github.com/PowerShell/PowerShell-native) repository.
Please make PRs to the new repository.
Code under here will be removed once the move is complete.

Back | FazBrowse Home | New Git URL