Skip to content

Migrate DllImport to LibraryImport in core modules#7489

Open
JoonghyunCho wants to merge 1 commit intoSamsung:mainfrom
JoonghyunCho:apply-libraryimport
Open

Migrate DllImport to LibraryImport in core modules#7489
JoonghyunCho wants to merge 1 commit intoSamsung:mainfrom
JoonghyunCho:apply-libraryimport

Conversation

@JoonghyunCho
Copy link
Member

@JoonghyunCho JoonghyunCho commented Feb 26, 2026

Description of Change

This draft PR is about to migrate our P/Invoke declaration from [DllImport] to the modern [LibraryImport] source generator.

The main goal of this refactoring is to:

  1. Reduce Marshalling Overhead: Shift runtime marshalling work to compile-time generated C# code.
  2. NativeAOT Compatibility: Future-proof our core modules to be compatible with .NET Native AOT.

What is included in the PR?

  • Applied [LibraryImport] with partial modifiers to safe, core platform modules.
  • Explicitly defined StringMarshalling = StringMarshalling.Utf8 for generated interoperability.

What is excluded in the PR and Why?

  1. Tizen.NUI (and related sub-modules)
    Reason for Exclusion: Lack of support for HandleRef marshaling and the constraints of the SWIG auto-generated structure.
  2. Certain Callback/Delegate Methods (Specific files in Tizen.Multimedia, etc.)
    While most of the Tizen.Multimedia namespace has been successfully converted, some methods in specific files such as Interop.Volume.cs and Interop.Device.cs still utilize [DllImport].
    Reason for Exclusion: Requirements for CallingConvention.Cdecl and the inherent complexity of delegate marshaling.
  3. Other Domain Projects (Excluding Core Modules)
    Reason for Omission: Projects including Tizen.Uix.* (Voice Index, TTS models), Tizen.Telephony.*, and Tizen.Pims.Contacts are currently out of scope due to the priority.

@TizenAPI-Bot
Copy link
Collaborator

Build Error:

src/Tizen.Multimedia.MediaCodec/Interop/Interop.MediaCodec.cs(117,105): error SYSLIB1051: Marshalling bool without explicit marshalling information is not supported. Specify either 'MarshalUsingAttribute' or 'MarshalAsAttribute'. The generated source will not handle marshalling of parameter 'isEncoder'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.csproj]
src/Tizen.Multimedia.Metadata/Interop/Interop.MetadataExtractor.cs(54,18): error SYSLIB1051: Marshalling bool without explicit marshalling information is not supported. Specify either 'MarshalUsingAttribute' or 'MarshalAsAttribute'. The generated source will not handle marshalling of parameter 'isAccurate'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Metadata/Tizen.Multimedia.Metadata.csproj]
src/Tizen.Multimedia.Util/Interop/Interop.ImageUtil.Decode.cs(33,80): error SYSLIB1051: The specified parameter needs to be marshalled from unmanaged to managed, but the marshaller type 'global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Interop.ImageDecoderHandle>' does not support it. The generated source will not handle marshalling of parameter 'handle'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Util/Tizen.Multimedia.Util.csproj]
src/Tizen.Multimedia.Util/Interop/Interop.ImageUtil.Encode.cs(37,100): error SYSLIB1051: The specified parameter needs to be marshalled from unmanaged to managed, but the marshaller type 'global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Interop.ImageEncoderHandle>' does not support it. The generated source will not handle marshalling of parameter 'handle'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Util/Tizen.Multimedia.Util.csproj]
src/Tizen.Multimedia.Util/Interop/Interop.ImageUtil.Encode.cs(52,96): error SYSLIB1051: Marshalling bool without explicit marshalling information is not supported. Specify either 'MarshalUsingAttribute' or 'MarshalAsAttribute'. The generated source will not handle marshalling of parameter 'lossless'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Util/Tizen.Multimedia.Util.csproj]
src/Tizen.Multimedia.Util/Interop/Interop.ImageUtil.Encode.cs(64,97): error SYSLIB1051: Marshalling bool without explicit marshalling information is not supported. Specify either 'MarshalUsingAttribute' or 'MarshalAsAttribute'. The generated source will not handle marshalling of parameter 'isLossless'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Util/Tizen.Multimedia.Util.csproj]
src/Tizen.Multimedia.Util/Interop/Interop.ImageUtil.Transform.cs(38,79): error SYSLIB1051: The specified parameter needs to be marshalled from unmanaged to managed, but the marshaller type 'global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Interop.TransformHandle>' does not support it. The generated source will not handle marshalling of parameter 'handle'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Util/Tizen.Multimedia.Util.csproj]
src/Tizen.Multimedia.Vision/Interop/Interop.MediaVision.Common.cs(196,95): error SYSLIB1051: Marshalling bool without explicit marshalling information is not supported. Specify either 'MarshalUsingAttribute' or 'MarshalAsAttribute'. The generated source will not handle marshalling of parameter 'value'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Vision/Tizen.Multimedia.Vision.csproj]
src/Tizen.Multimedia.Vision/Interop/Interop.MediaVision.Face.cs(51,49): error SYSLIB1051: Marshalling bool without explicit marshalling information is not supported. Specify either 'MarshalUsingAttribute' or 'MarshalAsAttribute'. The generated source will not handle marshalling of parameter 'doLearn'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Vision/Tizen.Multimedia.Vision.csproj]
src/Tizen.Multimedia.Vision/Interop/Interop.MediaVision.Face.cs(138,47): error SYSLIB1051: The type 'Interop.MediaVision.Quadrangle' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of parameter 'location'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Vision/Tizen.Multimedia.Vision.csproj]
src/Tizen.Multimedia.Recorder/Interop/Interop.Recorder.cs(27,77): error SYSLIB1051: The specified parameter needs to be marshalled from unmanaged to managed, but the marshaller type 'global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Interop.RecorderHandle>' does not support it. The generated source will not handle marshalling of parameter 'handle'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Recorder/Tizen.Multimedia.Recorder.csproj]
src/Tizen.Multimedia.Recorder/Interop/Interop.Recorder.cs(30,103): error SYSLIB1051: The specified parameter needs to be marshalled from unmanaged to managed, but the marshaller type 'global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Interop.RecorderHandle>' does not support it. The generated source will not handle marshalling of parameter 'handle'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Recorder/Tizen.Multimedia.Recorder.csproj]
src/Tizen.Multimedia.Recorder/Interop/Interop.Recorder.Settings.cs(97,18): error SYSLIB1052: The specified marshalling configuration is not supported by source-generated P/Invokes. Multiple marshalling attributes per element per indirection level is unsupported, but duplicate information was provided for indirection level 0. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1052) [src/Tizen.Multimedia.Recorder/Tizen.Multimedia.Recorder.csproj]
src/Tizen.Multimedia.Recorder/Interop/Interop.Recorder.Settings.cs(101,87): error SYSLIB1051: Marshalling bool without explicit marshalling information is not supported. Specify either 'MarshalUsingAttribute' or 'MarshalAsAttribute'. The generated source will not handle marshalling of parameter 'enable'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051) [src/Tizen.Multimedia.Recorder/Tizen.Multimedia.Recorder.csproj]
src/Tizen.Multimedia.Recorder/Interop/Interop.Recorder.Settings.cs(97,18): error CS0579: Duplicate 'MarshalAs' attribute [src/Tizen.Multimedia.Recorder/Tizen.Multimedia.Recorder.csproj]

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.

2 participants