Open
Conversation
…oting (#51987) * Add warnings about C long and wchar_t cross-platform type differences The type marshalling table maps C# long to int64_t but does not warn that C long is 32-bit on Windows and 64-bit on 64-bit Unix. Add an Important note cross-referencing the CLong guidance in best-practices.md. Also add a note about wchar_t being UTF-32 on non-Windows platforms, which affects string marshalling decisions for cross-platform P/Invoke. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix ftw samples to use Utf8 instead of Utf16 The C ftw() function takes char* parameters (UTF-8 on Linux/macOS), not wchar_t*. Using StringMarshalling.Utf16 is incorrect and would cause the strings to be marshalled in the wrong encoding. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add guidance on when calling conventions can be omitted Calling conventions only need to be specified on Windows x86, where Stdcall and Cdecl differ. On x64, ARM, and ARM64 there is only one calling convention, making the attribute unnecessary. Add explicit DO/DON'T recommendations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add troubleshooting table, GC.KeepAlive guidance, and header trust note Add three new sections to the native interop best practices: 1. Troubleshooting P/Invoke failures: a symptom-to-cause-to-fix table covering DllNotFoundException, EntryPointNotFoundException, AccessViolationException, silent corruption, intermittent crashes, and heap corruption. 2. Preventing delegate collection with GC.KeepAlive: explains that GetFunctionPointerForDelegate does not root the source delegate, with a code example showing proper GC.KeepAlive usage. 3. Resolving conflicts between documentation and native headers: advises developers to treat native headers as the authoritative source for P/Invoke signatures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update docs/standard/native-interop/type-marshalling.md Co-authored-by: Aaron R Robinson <arobins@microsoft.com> * Update docs/standard/native-interop/best-practices.md Co-authored-by: Aaron R Robinson <arobins@microsoft.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
* Add stubs for the new errors * Additional consolidation Copilot found several new opportunities for consolication * Additional missing error codes. * Add new errors in appropriate sections. * Focus on resolution, not cause Rewrite the sections to focus on hose to fix errors, rather than the cause of the errors, * Final edit pass * Fix build warnings * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * insert xref * remove duplicate key --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please don't squash-merge this PR.
Internal previews
Toggle expand/collapse