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

Merged
merged 16 commits into from
Nov 22, 2024

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 : Completed
  • Commits : Completed
  • 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

github-actions bot commented Nov 18, 2024

Qodana for .NET

22 new problems were found

Inspection name Severity Problems
Redundant using directive 🔶 Warning 8
Redundant cast 🔶 Warning 6
Possible loss of fraction 🔶 Warning 3
Code is unreachable 🔶 Warning 2
Heuristically unreachable code 🔶 Warning 2
RoslynAnalyzers Enums should have zero value 🔶 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

Copy link
Member

@bagusnl bagusnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the changes within this scope of PR is mostly just moving stuff around, after a bit of review there doesn't seem to be anything wrong with it. All good to me! approbed

@neon-nyan neon-nyan merged commit 8c3e282 into main Nov 22, 2024
8 checks passed
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