Skip to content

Refactor Libraryimport/phase 2#7560

Merged
JoonghyunCho merged 9 commits intoSamsung:mainfrom
JoonghyunCho:libraryimport/phase-2
Apr 14, 2026
Merged

Refactor Libraryimport/phase 2#7560
JoonghyunCho merged 9 commits intoSamsung:mainfrom
JoonghyunCho:libraryimport/phase-2

Conversation

@JoonghyunCho
Copy link
Copy Markdown
Member

@JoonghyunCho JoonghyunCho commented Apr 10, 2026

Summary

Migrate DllImport to LibraryImport (source-generated P/Invoke) for medium-risk modules.

This is Phase 2 of 4 in a staged LibraryImport migration. It covers Applications, Security modules while carefully preserving recent features (e.g., Discovery in RPCPort) and handling delegate/SafeHandle constraints.

Modules Changed (57 files)

  • Tizen.Applications: Common (AppControl, ApplicationManager, Bundle, RPCPort, etc.), Cion, ComponentBased (core, ComponentManager, Port), Notification, NotificationEventListener, PackageManager, UIGadget, UnitedService, WatchfaceComplication, WidgetControl
  • Tizen.Security: Core, DevicePolicyManager, PrivacyPrivilegeManager

Changes

  • Safely mapped [DllImport] to [LibraryImport] and updated method signatures to static partial.
  • Mapped string params with StringMarshalling = StringMarshalling.Utf8 only where strictly needed.
  • Enforced safe boolean returns/parameters via [MarshalAs(UnmanagedType.U1)].
  • Fixed partial unsafeunsafe partial keyword order in Bundle.cs.
  • Added StringMarshalling.Utf8 to 14 string-returning methods in AppCommon.cs.
  • Resolved conflicts explicitly to keep newly introduced main features like Interop.LibRPCPort.Discovery unmodified while converting the rest of the file.

What is NOT included

  • Tizen.Applications.ComponentBasedBaseMain, BaseAddFrameComponent, BaseAddServiceComponent remain as DllImport due to ref struct callback parameters.
  • Tizen.Applications.UIui_app_main remains as DllImport due to ref UIAppLifecycleCallbacks struct callback.
  • Phase 1 modules (Alarm, Badge, Preference, etc.) and Phase 3/4 modules (Account, Multimedia, Network) are excluded to ensure zero file overlap between PRs.
  • Delegate bool MarshalAs improvements — extracted for an independent PR.

TCT Verification

SuiteSort Total Passed Failed Blocked Not Executed Ratio
Tizen.Applications.Cion.Tests 75 75 0 0 0 100.00%
Tizen.Applications.EventManager.Tests 126 126 0 0 0 100.00%
Tizen.Applications.MessagePort.Tests 24 24 0 0 0 100.00%
Tizen.Applications.Preference.Tests 24 24 0 0 0 100.00%
Tizen.Applications.Service.Tests 3 3 0 0 0 100.00%
Tizen.Applications.Tests 205 205 0 0 0 100.00%
Tizen.Applications.UI.Tests 4 4 0 0 0 100.00%
Tizen.Common.Tests 39 39 0 0 0 100.00%
Tizen.ComponentBased.Default.Tests 5 5 0 0 0 100.00%
Tizen.ComponentBased.Tests 9 9 0 0 0 100.00%
Tizen.DataControl.Tests 112 112 0 0 0 100.00%
Tizen.Mediacontent.Tests 660 660 0 0 0 100.00%
Tizen.Mime.Tests 4 4 0 0 0 100.00%
Tizen.Multimedia.Tests 282 282 0 0 0 100.00%
Tizen.NotificationEventListener.Tests 85 85 0 0 0 100.00%
Tizen.Notifications.Tests 132 132 0 0 0 100.00%
Tizen.Packagemanager.Tests 75 75 0 0 0 100.00%
Tizen.Privilege.Tests 19 19 0 0 0 100.00%
Tizen.WidgetControl.Tests 23 23 0 0 0 100.00%

@JoonghyunCho JoonghyunCho force-pushed the libraryimport/phase-2 branch from 70179c1 to 341046c Compare April 10, 2026 08:19
@JoonghyunCho JoonghyunCho changed the title Libraryimport/phase 2 Refactor Libraryimport/phase 2 Apr 10, 2026
@github-actions github-actions bot added the API14 Platform : Tizen 11.0 / TFM: net8.0-tizen11.0 label Apr 10, 2026
Jay Cho added 9 commits April 14, 2026 17:55
Convert DllImport declarations to LibraryImport (source-generated P/Invoke)
for the following modules:
- Tizen.Applications: Common, DataControl, PackageManager, Notification, NotificationEventListener, Shortcut, Cion, ComponentBased, WatchfaceComplication, WidgetControl, UIGadget, UnitedService
- Tizen.Content: Download, MediaContent
- Tizen.Security

Changes:
- Apply [LibraryImport] and StringMarshalling.Utf8
- Add [MarshalAs(UnmanagedType.U1)] for bool parameters
- Safely cherry-picked keeping new additions in main (e.g. Discovery)
- Filter.cs excluded due to SafeHandle out parameter generation limits
- Fix double [MarshalAs] on 'out bool' params in RPCPort.cs (3 instances)
- Add StringMarshalling.Utf8 to string-returning methods in AppCommon.cs (SYSLIB1051)
- Fix 'partial unsafe' → 'unsafe partial' keyword order in Bundle.cs (CS0267)
…convert residual DllImport

- Remove 26 redundant StringMarshalling.Utf8 from methods without string params
- Convert DevicePolicyManager.PasswordGetExpires from DllImport to LibraryImport
Reverted to avoid merge conflicts when both PRs land.
Account.* (41 files → Phase 3), Network.* (27 files → Phase 4) modules
were inadvertently included from the source commit. Reverted to main
to ensure zero overlap between all Phase branches.
DllImport uses 4-byte BOOL by default (matching C's int/bool).
Adding [MarshalAs(UnmanagedType.U1)] changes it to 1-byte, causing
ABI mismatch with native Tizen C APIs. MarshalAs(U1) is only needed
for LibraryImport which has no default bool marshalling.
…ope)

Reverted [return: MarshalAs(UnmanagedType.U1)] on delegate bool returns
and [MarshalAs(UnmanagedType.U1)] on delegate bool params across 14 files.
These changes require separate ABI analysis and should be in their own PR.
…tion

CRITICAL: The conversion script removed [DllImport] but failed to add
[LibraryImport] due to [In]/[In,Out] struct parameters, leaving orphan
extern methods without any P/Invoke attribute. This causes
EntryPointNotFoundException at runtime — likely root cause of
Authenticator.MakeCredential() TCT failure.
Reverted: Tizen.Content.Download, Tizen.Security.WebAuthn,
Tizen.Security.SecureRepository, Tizen.Applications.Shortcut
@JoonghyunCho JoonghyunCho merged commit 1ecab11 into Samsung:main Apr 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API14 Platform : Tizen 11.0 / TFM: net8.0-tizen11.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant