Skip to content

Pin stage only accepts FixedStatementSyntaxes #1653

Closed
dotnet/runtime
#61539
@SupinePandora43

Description

@SupinePandora43

Generally, we only pin for cases where we directly pass down the value. That’s why the Pin stage only accepts FixedStatementSyntaxes
I’d honestly recommend keeping the heap allocation or at most adding a stackalloc optimization with the native marshalling APIs
If that’s not high enough perf, then you’d have to file an issue or fork the generator

By @jkoritzinsky in private discord messages.

i'm thinking about implementing IMarshallingGenerator that will output:

    private static void ulConfigSetCachePath(IntPtr config, in string cache_path)
        {
            unsafe
            {
                global::UltralightNet.ULString __cache_path_gen = default;
                global::UltralightNet.ULString* __cache_path_gen_native = default;
                //
                // Pin
                //
                fixed(char* __cache_path_gen_native_pinned = cache_path)
                {
                    __cache_path_gen = new ULString() { data = (ushort*)__cache_path_gen_native_pinned, length = (nuint)cache_path.Length };
                    __cache_path_gen_native = &__cache_path_gen;
                    //
                    // Invoke
                    //
                    ulConfigSetCachePath__PInvoke__(config, __cache_path_gen_native);
                }
            }
        }
     [System.Runtime.InteropServices.DllImportAttribute("Ultralight", EntryPoint = "ulConfigSetCachePath")]
        extern private static unsafe void ulConfigSetCachePath__PInvoke__(global::System.IntPtr config, global::UltralightNet.ULString* cache_path);

So it isn't possible yet?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions