Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving out all PInvoke Methods to its Independent Hi3Helper.Win32 assembly #606

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

neon-nyan
Copy link
Member

@neon-nyan neon-nyan commented Nov 17, 2024

Main Goal

As you might already know, Collapse heavily relies on native invocation for some libraries, especially when it is communicating with Win32 APIs. For more than two years, we have been using the [DllImport] attribute to define the external method to call the native functions of certain libraries (especially when it comes to Win32 calls).

In .NET 7, [LibraryImport] was introduced, which is the [DllImport] alternative that provides the source-generated invocation to native functions, instead of using a JIT-ed approach. The [LibraryImport] brings some invocation features which aren't available for NativeAOT compilations, for example: GetLastWin32Error(), which is useful when diagnosing what's wrong when a Win32 function is getting called.

Read more about [LibraryImport] here:
https://learn.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke-source-generation
https://learn.microsoft.com/en-us/dotnet/standard/native-interop/best-practices

Another reason for these changes are for maintainability and to share some of the same functionality between our projects. This changes can improve the work time efficiency and reusability of the functions between methods without making or implementing the same methods with the same functionality between modules.

PR Status :

  • Overall Status : In Progress
  • Commits : In Progress
  • Synced to base (Collapse:main) : Yes
  • Build status : OK
  • Crashing : No
  • Bug found caused by PR : Unsure

Templates

Changelog Prefixes
  **[New]**
  **[Imp]**
  **[Fix]**
  **[Loc]**
  **[Doc]**

@neon-nyan neon-nyan added Enhancement New feature or request Area: Mirror/API Server Issue labeled for Mirror/API Server issue releated Area: Runtime Issue labeled for runtime, Hi3Helper.Core and other libraries used by Collapse Priority: Medium labels Nov 17, 2024
@neon-nyan neon-nyan self-assigned this Nov 17, 2024
Copy link

github-actions bot commented Nov 17, 2024

Qodana for .NET

15 new problems were found

Inspection name Severity Problems
Redundant cast 🔶 Warning 6
Redundant using directive 🔶 Warning 6
Heuristically unreachable code 🔶 Warning 2
Code is unreachable 🔶 Warning 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@neon-nyan neon-nyan removed the Area: Mirror/API Server Issue labeled for Mirror/API Server issue releated label Nov 18, 2024
Copy link

Qodana for .NET

15 new problems were found

Inspection name Severity Problems
Redundant cast 🔶 Warning 6
Redundant using directive 🔶 Warning 6
Heuristically unreachable code 🔶 Warning 2
Code is unreachable 🔶 Warning 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Runtime Issue labeled for runtime, Hi3Helper.Core and other libraries used by Collapse Enhancement New feature or request Priority: Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants