From 970c846e3826e04be517c61558a3152bbcd488a4 Mon Sep 17 00:00:00 2001 From: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> Date: Sat, 9 Dec 2023 03:10:54 -0500 Subject: [PATCH 1/8] Fix string marshalling on Windows --- .../Program.cs | 10 +- .../Program.cs | 12 +- .../Program.cs | 4 +- .../Program.cs | 10 +- .../NativeFileDialogs.AutoGen-symbols.cpp | 11 +- .../NativeFileDialogs.AutoGen.csproj | 4 +- NativeFileDialogs.AutoGen/Std.cs | 30 +- NativeFileDialogs.AutoGen/nfd.cs | 1341 ++++++++++------- ...NativeFileDialogs.CppSharpGenerator.csproj | 2 +- .../NativeFileDialogsLibrary.cs | 14 +- .../NativeFileDialogs.Net.csproj | 2 +- NativeFileDialogs.Net/Nfd.cs | 24 +- 12 files changed, 847 insertions(+), 617 deletions(-) diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/Program.cs b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/Program.cs index f4024d5..097ec9f 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/Program.cs +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) Speykious +// Copyright (c) Speykious // This file is part of NativeFileDialogs.NET. // NativeFileDialogs.NET is licensed under the Zlib License. See LICENSE for details. @@ -9,14 +9,14 @@ unsafe { nfd.NFD_Init(); - NfdnfilteritemT[] filterItem = new[] + Nfdu8filteritemT[] filterItem = new[] { - new NfdnfilteritemT + new Nfdu8filteritemT { Name = "Source code", Spec = "c,cpp,cc", }, - new NfdnfilteritemT + new Nfdu8filteritemT { Name = "Headers", Spec = "h,hpp", @@ -24,7 +24,7 @@ unsafe }; sbyte* outPathPtr; - NfdresultT result = nfd.NFD_OpenDialogN(&outPathPtr, filterItem, (uint)filterItem.Length, null); + NfdresultT result = nfd.NFD_OpenDialogU8(&outPathPtr, filterItem, (uint)filterItem.Length, null); switch (result) { case NfdresultT.NFD_OKAY: diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/Program.cs b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/Program.cs index a58066b..40dc1ea 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/Program.cs +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) Speykious +// Copyright (c) Speykious // This file is part of NativeFileDialogs.NET. // NativeFileDialogs.NET is licensed under the Zlib License. See LICENSE for details. @@ -9,14 +9,14 @@ unsafe { nfd.NFD_Init(); - NfdnfilteritemT[] filterItems = new[] + Nfdu8filteritemT[] filterItems = new[] { - new NfdnfilteritemT + new Nfdu8filteritemT { Name = "Source code", Spec = "c,cpp,cc", }, - new NfdnfilteritemT + new Nfdu8filteritemT { Name = "Headers", Spec = "h,hpp", @@ -24,7 +24,7 @@ unsafe }; IntPtr pathSet; - NfdresultT result = nfd.NFD_OpenDialogMultipleN(&pathSet, filterItems, (uint)filterItems.Length, null); + NfdresultT result = nfd.NFD_OpenDialogMultipleU8(&pathSet, filterItems, (uint)filterItems.Length, null); switch (result) { case NfdresultT.NFD_OKAY: @@ -36,7 +36,7 @@ unsafe for (uint i = 0; i < count; i++) { sbyte* pathPtr; - nfd.NFD_PathSetGetPathN(pathSet, i, &pathPtr); + nfd.NFD_PathSetGetPathU8(pathSet, i, &pathPtr); outPaths[i] = new string(pathPtr); } diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/Program.cs b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/Program.cs index 7edb79f..7a928ac 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/Program.cs +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) Speykious +// Copyright (c) Speykious // This file is part of NativeFileDialogs.NET. // NativeFileDialogs.NET is licensed under the Zlib License. See LICENSE for details. @@ -10,7 +10,7 @@ unsafe nfd.NFD_Init(); sbyte* outPathPtr; - NfdresultT result = nfd.NFD_PickFolderN(&outPathPtr, null); + NfdresultT result = nfd.NFD_PickFolderU8(&outPathPtr, null); switch (result) { case NfdresultT.NFD_OKAY: diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/Program.cs b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/Program.cs index 7cf8722..e5840e0 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/Program.cs +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) Speykious +// Copyright (c) Speykious // This file is part of NativeFileDialogs.NET. // NativeFileDialogs.NET is licensed under the Zlib License. See LICENSE for details. @@ -9,14 +9,14 @@ unsafe { nfd.NFD_Init(); - NfdnfilteritemT[] filterItem = new[] + Nfdu8filteritemT[] filterItem = new[] { - new NfdnfilteritemT + new Nfdu8filteritemT { Name = "Source code", Spec = "c,cpp,cc", }, - new NfdnfilteritemT + new Nfdu8filteritemT { Name = "Headers", Spec = "h,hpp", @@ -24,7 +24,7 @@ unsafe }; sbyte* savePathPtr; - NfdresultT result = nfd.NFD_SaveDialogN(&savePathPtr, filterItem, (uint)filterItem.Length, null, "Untitled.c"); + NfdresultT result = nfd.NFD_SaveDialogU8(&savePathPtr, filterItem, (uint)filterItem.Length, null, "Untitled.c"); switch (result) { case NfdresultT.NFD_OKAY: diff --git a/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp b/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp index ce32330..6138872 100644 --- a/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp +++ b/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp @@ -1,5 +1,6 @@ -#include -#include - -nfdpathsetenum_t& (nfdpathsetenum_t::*_0)(nfdpathsetenum_t&&) = &nfdpathsetenum_t::operator=; -nfdnfilteritem_t& (nfdnfilteritem_t::*_1)(nfdnfilteritem_t&&) = &nfdnfilteritem_t::operator=; +#include +#include + +nfdpathsetenum_t& (nfdpathsetenum_t::*_0)(nfdpathsetenum_t&&) = &nfdpathsetenum_t::operator=; +nfdnfilteritem_t& (nfdnfilteritem_t::*_1)(nfdnfilteritem_t&&) = &nfdnfilteritem_t::operator=; +nfdu8filteritem_t& (nfdu8filteritem_t::*_2)(nfdu8filteritem_t&&) = &nfdu8filteritem_t::operator=; diff --git a/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen.csproj b/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen.csproj index 9777848..efe2301 100644 --- a/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen.csproj +++ b/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen.csproj @@ -22,8 +22,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/NativeFileDialogs.AutoGen/Std.cs b/NativeFileDialogs.AutoGen/Std.cs index 745ca0f..36fa03d 100644 --- a/NativeFileDialogs.AutoGen/Std.cs +++ b/NativeFileDialogs.AutoGen/Std.cs @@ -1,14 +1,16 @@ -// ---------------------------------------------------------------------------- -// -// This is autogenerated code by CppSharp. -// Do not edit this file or all your changes will be lost after re-generation. -// -// ---------------------------------------------------------------------------- -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security; -using __CallingConvention = global::System.Runtime.InteropServices.CallingConvention; -using __IntPtr = global::System.IntPtr; -[assembly:InternalsVisibleTo("nfd")] - +// ---------------------------------------------------------------------------- +// +// This is autogenerated code by CppSharp. +// Do not edit this file or all your changes will be lost after re-generation. +// +// ---------------------------------------------------------------------------- +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using __CallingConvention = global::System.Runtime.InteropServices.CallingConvention; +using __IntPtr = global::System.IntPtr; +[assembly:InternalsVisibleTo("nfd")] + +#pragma warning disable CS0109 // Member does not hide an inherited member; new keyword is not required + diff --git a/NativeFileDialogs.AutoGen/nfd.cs b/NativeFileDialogs.AutoGen/nfd.cs index 4cbab62..575edb4 100644 --- a/NativeFileDialogs.AutoGen/nfd.cs +++ b/NativeFileDialogs.AutoGen/nfd.cs @@ -1,563 +1,778 @@ -// ---------------------------------------------------------------------------- -// -// This is autogenerated code by CppSharp. -// Do not edit this file or all your changes will be lost after re-generation. -// -// ---------------------------------------------------------------------------- -using System; -using System.Runtime.InteropServices; -using System.Security; -using __CallingConvention = global::System.Runtime.InteropServices.CallingConvention; -using __IntPtr = global::System.IntPtr; - -namespace NativeFileDialogs.AutoGen -{ - public enum NfdresultT : uint - { - NFD_ERROR = 0, - NFD_OKAY = 1, - NFD_CANCEL = 2 - } - - public unsafe partial class MaxAlignT : IDisposable - { - [StructLayout(LayoutKind.Sequential, Size = 32)] - public partial struct __Internal - { - internal long __clang_max_align_nonce1; - internal fixed byte __clang_max_align_nonce2[128]; - } - - public __IntPtr __Instance { get; protected set; } - - internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary(); - - protected bool __ownsNativeInstance; - - internal static MaxAlignT __CreateInstance(__IntPtr native, bool skipVTables = false) - { - return new MaxAlignT(native.ToPointer(), skipVTables); - } - - internal static MaxAlignT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - if (NativeToManagedMap.TryGetValue(native, out var managed)) - return (MaxAlignT)managed; - var result = __CreateInstance(native, skipVTables); - if (saveInstance) - NativeToManagedMap[native] = result; - return result; - } - - internal static MaxAlignT __CreateInstance(__Internal native, bool skipVTables = false) - { - return new MaxAlignT(native, skipVTables); - } - - private static void* __CopyValue(__Internal native) - { - var ret = Marshal.AllocHGlobal(sizeof(__Internal)); - *(__Internal*) ret = native; - return ret.ToPointer(); - } - - private MaxAlignT(__Internal native, bool skipVTables = false) - : this(__CopyValue(native), skipVTables) - { - __ownsNativeInstance = true; - NativeToManagedMap[__Instance] = this; - } - - protected MaxAlignT(void* native, bool skipVTables = false) - { - if (native == null) - return; - __Instance = new __IntPtr(native); - } - - public void Dispose() - { - Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); - } - - partial void DisposePartial(bool disposing); - - internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) - { - if (__Instance == IntPtr.Zero) - return; - NativeToManagedMap.TryRemove(__Instance, out _); - DisposePartial(disposing); - if (__ownsNativeInstance) - Marshal.FreeHGlobal(__Instance); - __Instance = IntPtr.Zero; - } - - public long ClangMaxAlignNonce1 - { - get - { - return ((__Internal*)__Instance)->__clang_max_align_nonce1; - } - - set - { - ((__Internal*)__Instance)->__clang_max_align_nonce1 = value; - } - } - } - - public unsafe partial class NfdpathsetenumT : IDisposable - { - [StructLayout(LayoutKind.Sequential, Size = 8)] - public partial struct __Internal - { - internal __IntPtr ptr; - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "_ZN16nfdpathsetenum_tC2ERKS_", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void cctor(__IntPtr __instance, __IntPtr __0); - } - - public __IntPtr __Instance { get; protected set; } - - internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary(); - - protected bool __ownsNativeInstance; - - internal static NfdpathsetenumT __CreateInstance(__IntPtr native, bool skipVTables = false) - { - return new NfdpathsetenumT(native.ToPointer(), skipVTables); - } - - internal static NfdpathsetenumT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - if (NativeToManagedMap.TryGetValue(native, out var managed)) - return (NfdpathsetenumT)managed; - var result = __CreateInstance(native, skipVTables); - if (saveInstance) - NativeToManagedMap[native] = result; - return result; - } - - internal static NfdpathsetenumT __CreateInstance(__Internal native, bool skipVTables = false) - { - return new NfdpathsetenumT(native, skipVTables); - } - - private static void* __CopyValue(__Internal native) - { - var ret = Marshal.AllocHGlobal(sizeof(__Internal)); - *(__Internal*) ret = native; - return ret.ToPointer(); - } - - private NfdpathsetenumT(__Internal native, bool skipVTables = false) - : this(__CopyValue(native), skipVTables) - { - __ownsNativeInstance = true; - NativeToManagedMap[__Instance] = this; - } - - protected NfdpathsetenumT(void* native, bool skipVTables = false) - { - if (native == null) - return; - __Instance = new __IntPtr(native); - } - - public NfdpathsetenumT() - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal)); - __ownsNativeInstance = true; - NativeToManagedMap[__Instance] = this; - } - - public NfdpathsetenumT(global::NativeFileDialogs.AutoGen.NfdpathsetenumT __0) - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal)); - __ownsNativeInstance = true; - NativeToManagedMap[__Instance] = this; - *((global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal*) __0.__Instance); - } - - public void Dispose() - { - Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); - } - - partial void DisposePartial(bool disposing); - - internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) - { - if (__Instance == IntPtr.Zero) - return; - NativeToManagedMap.TryRemove(__Instance, out _); - DisposePartial(disposing); - if (__ownsNativeInstance) - Marshal.FreeHGlobal(__Instance); - __Instance = IntPtr.Zero; - } - - public __IntPtr Ptr - { - get - { - return ((__Internal*)__Instance)->ptr; - } - - set - { - ((__Internal*)__Instance)->ptr = (__IntPtr) value; - } - } - } - - public unsafe partial class NfdnfilteritemT : IDisposable - { - [StructLayout(LayoutKind.Sequential, Size = 16)] - public partial struct __Internal - { - internal __IntPtr name; - internal __IntPtr spec; - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "_ZN16nfdnfilteritem_tC2ERKS_", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void cctor(__IntPtr __instance, __IntPtr __0); - } - - public __IntPtr __Instance { get; protected set; } - - internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary(); - - private bool __name_OwnsNativeMemory = false; - private bool __spec_OwnsNativeMemory = false; - protected bool __ownsNativeInstance; - - internal static NfdnfilteritemT __CreateInstance(__IntPtr native, bool skipVTables = false) - { - return new NfdnfilteritemT(native.ToPointer(), skipVTables); - } - - internal static NfdnfilteritemT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - if (NativeToManagedMap.TryGetValue(native, out var managed)) - return (NfdnfilteritemT)managed; - var result = __CreateInstance(native, skipVTables); - if (saveInstance) - NativeToManagedMap[native] = result; - return result; - } - - internal static NfdnfilteritemT __CreateInstance(__Internal native, bool skipVTables = false) - { - return new NfdnfilteritemT(native, skipVTables); - } - - private static void* __CopyValue(__Internal native) - { - var ret = Marshal.AllocHGlobal(sizeof(__Internal)); - *(__Internal*) ret = native; - return ret.ToPointer(); - } - - private NfdnfilteritemT(__Internal native, bool skipVTables = false) - : this(__CopyValue(native), skipVTables) - { - __ownsNativeInstance = true; - NativeToManagedMap[__Instance] = this; - } - - protected NfdnfilteritemT(void* native, bool skipVTables = false) - { - if (native == null) - return; - __Instance = new __IntPtr(native); - } - - public NfdnfilteritemT() - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); - __ownsNativeInstance = true; - NativeToManagedMap[__Instance] = this; - } - - public NfdnfilteritemT(global::NativeFileDialogs.AutoGen.NfdnfilteritemT __0) - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); - __ownsNativeInstance = true; - NativeToManagedMap[__Instance] = this; - *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __0.__Instance); - if (__0.__name_OwnsNativeMemory) - this.Name = __0.Name; - if (__0.__spec_OwnsNativeMemory) - this.Spec = __0.Spec; - } - - public void Dispose() - { - Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); - } - - partial void DisposePartial(bool disposing); - - internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) - { - if (__Instance == IntPtr.Zero) - return; - NativeToManagedMap.TryRemove(__Instance, out _); - DisposePartial(disposing); - if (__name_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->name); - if (__spec_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); - if (__ownsNativeInstance) - Marshal.FreeHGlobal(__Instance); - __Instance = IntPtr.Zero; - } - - public string Name - { - get - { - return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ((__Internal*)__Instance)->name); - } - - set - { - if (__name_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->name); - __name_OwnsNativeMemory = true; - if (value == null) - { - ((__Internal*)__Instance)->name = global::System.IntPtr.Zero; - return; - } - var __bytes0 = global::System.Text.Encoding.UTF8.GetBytes(value); - var __bytePtr0 = Marshal.AllocHGlobal(__bytes0.Length + 1); - Marshal.Copy(__bytes0, 0, __bytePtr0, __bytes0.Length); - Marshal.WriteByte(__bytePtr0 + __bytes0.Length, 0); - ((__Internal*)__Instance)->name = (__IntPtr) __bytePtr0; - } - } - - public string Spec - { - get - { - return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ((__Internal*)__Instance)->spec); - } - - set - { - if (__spec_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); - __spec_OwnsNativeMemory = true; - if (value == null) - { - ((__Internal*)__Instance)->spec = global::System.IntPtr.Zero; - return; - } - var __bytes0 = global::System.Text.Encoding.UTF8.GetBytes(value); - var __bytePtr0 = Marshal.AllocHGlobal(__bytes0.Length + 1); - Marshal.Copy(__bytes0, 0, __bytePtr0, __bytes0.Length); - Marshal.WriteByte(__bytePtr0 + __bytes0.Length, 0); - ((__Internal*)__Instance)->spec = (__IntPtr) __bytePtr0; - } - } - } - - public unsafe partial class nfd - { - public partial struct __Internal - { - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_FreePathN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_FreePathN(sbyte* filePath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_Init", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_Init(); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_Quit", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_Quit(); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogN(sbyte** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[] filterList, uint filterCount, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogMultipleN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleN(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[] filterList, uint filterCount, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_SaveDialogN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogN(sbyte** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[] filterList, uint filterCount, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultName); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PickFolderN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderN(sbyte** outPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_GetError", CallingConvention = __CallingConvention.Cdecl)] - internal static extern __IntPtr NFD_GetError(); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_ClearError", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_ClearError(); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetCount", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetCount(__IntPtr pathSet, uint* count); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetPathN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathN(__IntPtr pathSet, uint index, sbyte** outPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_FreePathN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_PathSetFreePathN([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string filePath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetEnum", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetEnum(__IntPtr pathSet, __IntPtr outEnumerator); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_FreeEnum", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_PathSetFreeEnum(__IntPtr enumerator); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_EnumNextN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextN(__IntPtr enumerator, sbyte** outPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_Free", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_PathSetFree(__IntPtr pathSet); - } - - public static void NFD_FreePathN(sbyte* filePath) - { - __Internal.NFD_FreePathN(filePath); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_Init() - { - var __ret = __Internal.NFD_Init(); - return __ret; - } - - public static void NFD_Quit() - { - __Internal.NFD_Quit(); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogN(sbyte** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT[] filterList, uint filterCount, string defaultPath) - { - global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[] __filterList; - if (filterList is null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; - } - } - var __arg1 = __filterList; - var __ret = __Internal.NFD_OpenDialogN(outPath, __arg1, filterCount, defaultPath); - return __ret; - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleN(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.NfdnfilteritemT[] filterList, uint filterCount, string defaultPath) - { - global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[] __filterList; - if (filterList is null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; - } - } - var __arg1 = __filterList; - var __ret = __Internal.NFD_OpenDialogMultipleN(outPaths, __arg1, filterCount, defaultPath); - return __ret; - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogN(sbyte** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT[] filterList, uint filterCount, string defaultPath, string defaultName) - { - global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[] __filterList; - if (filterList is null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; - } - } - var __arg1 = __filterList; - var __ret = __Internal.NFD_SaveDialogN(outPath, __arg1, filterCount, defaultPath, defaultName); - return __ret; - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderN(sbyte** outPath, string defaultPath) - { - var __ret = __Internal.NFD_PickFolderN(outPath, defaultPath); - return __ret; - } - - public static string NFD_GetError() - { - var __ret = __Internal.NFD_GetError(); - return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, __ret); - } - - public static void NFD_ClearError() - { - __Internal.NFD_ClearError(); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetCount(__IntPtr pathSet, ref uint count) - { - fixed (uint* __count1 = &count) - { - var __arg1 = __count1; - var __ret = __Internal.NFD_PathSetGetCount(pathSet, __arg1); - return __ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathN(__IntPtr pathSet, uint index, sbyte** outPath) - { - var __ret = __Internal.NFD_PathSetGetPathN(pathSet, index, outPath); - return __ret; - } - - public static void NFD_PathSetFreePathN(string filePath) - { - __Internal.NFD_PathSetFreePathN(filePath); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetEnum(__IntPtr pathSet, global::NativeFileDialogs.AutoGen.NfdpathsetenumT outEnumerator) - { - var __arg1 = outEnumerator is null ? __IntPtr.Zero : outEnumerator.__Instance; - var __ret = __Internal.NFD_PathSetGetEnum(pathSet, __arg1); - return __ret; - } - - public static void NFD_PathSetFreeEnum(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator) - { - var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; - __Internal.NFD_PathSetFreeEnum(__arg0); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextN(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator, sbyte** outPath) - { - var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; - var __ret = __Internal.NFD_PathSetEnumNextN(__arg0, outPath); - return __ret; - } - - public static void NFD_PathSetFree(__IntPtr pathSet) - { - __Internal.NFD_PathSetFree(pathSet); - } - } -} +// ---------------------------------------------------------------------------- +// +// This is autogenerated code by CppSharp. +// Do not edit this file or all your changes will be lost after re-generation. +// +// ---------------------------------------------------------------------------- +using System; +using System.Runtime.InteropServices; +using System.Security; +using __CallingConvention = global::System.Runtime.InteropServices.CallingConvention; +using __IntPtr = global::System.IntPtr; + +#pragma warning disable CS0109 // Member does not hide an inherited member; new keyword is not required + +namespace NativeFileDialogs.AutoGen +{ + public enum NfdresultT + { + NFD_ERROR = 0, + NFD_OKAY = 1, + NFD_CANCEL = 2 + } + + public unsafe partial class NfdpathsetenumT : IDisposable + { + [StructLayout(LayoutKind.Sequential, Size = 8)] + public partial struct __Internal + { + internal __IntPtr ptr; + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdpathsetenum_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); + } + + public __IntPtr __Instance { get; protected set; } + + internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = + new global::System.Collections.Concurrent.ConcurrentDictionary(); + + internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.NfdpathsetenumT managed) + { + NativeToManagedMap[native] = managed; + } + + internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.NfdpathsetenumT managed) + { + + return NativeToManagedMap.TryGetValue(native, out managed); + } + + protected bool __ownsNativeInstance; + + internal static NfdpathsetenumT __CreateInstance(__IntPtr native, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + return new NfdpathsetenumT(native.ToPointer(), skipVTables); + } + + internal static NfdpathsetenumT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + if (__TryGetNativeToManagedMapping(native, out var managed)) + return (NfdpathsetenumT)managed; + var result = __CreateInstance(native, skipVTables); + if (saveInstance) + __RecordNativeToManagedMapping(native, result); + return result; + } + + internal static NfdpathsetenumT __CreateInstance(__Internal native, bool skipVTables = false) + { + return new NfdpathsetenumT(native, skipVTables); + } + + private static void* __CopyValue(__Internal native) + { + var ret = Marshal.AllocHGlobal(sizeof(__Internal)); + *(__Internal*) ret = native; + return ret.ToPointer(); + } + + private NfdpathsetenumT(__Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + protected NfdpathsetenumT(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new __IntPtr(native); + } + + public NfdpathsetenumT() + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + public NfdpathsetenumT(global::NativeFileDialogs.AutoGen.NfdpathsetenumT _0) + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + *((global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal*) _0.__Instance); + } + + public void Dispose() + { + Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); + } + + partial void DisposePartial(bool disposing); + + internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) + { + if (__Instance == IntPtr.Zero) + return; + NativeToManagedMap.TryRemove(__Instance, out _); + DisposePartial(disposing); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + __Instance = IntPtr.Zero; + } + + public __IntPtr Ptr + { + get + { + return ((__Internal*)__Instance)->ptr; + } + + set + { + ((__Internal*)__Instance)->ptr = (__IntPtr) value; + } + } + } + + public unsafe partial class NfdnfilteritemT : IDisposable + { + [StructLayout(LayoutKind.Sequential, Size = 16)] + public partial struct __Internal + { + internal __IntPtr name; + internal __IntPtr spec; + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdnfilteritem_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); + } + + public __IntPtr __Instance { get; protected set; } + + internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = + new global::System.Collections.Concurrent.ConcurrentDictionary(); + + internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.NfdnfilteritemT managed) + { + NativeToManagedMap[native] = managed; + } + + internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.NfdnfilteritemT managed) + { + + return NativeToManagedMap.TryGetValue(native, out managed); + } + + private bool __name_OwnsNativeMemory = false; + private bool __spec_OwnsNativeMemory = false; + protected bool __ownsNativeInstance; + + internal static NfdnfilteritemT __CreateInstance(__IntPtr native, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + return new NfdnfilteritemT(native.ToPointer(), skipVTables); + } + + internal static NfdnfilteritemT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + if (__TryGetNativeToManagedMapping(native, out var managed)) + return (NfdnfilteritemT)managed; + var result = __CreateInstance(native, skipVTables); + if (saveInstance) + __RecordNativeToManagedMapping(native, result); + return result; + } + + internal static NfdnfilteritemT __CreateInstance(__Internal native, bool skipVTables = false) + { + return new NfdnfilteritemT(native, skipVTables); + } + + private static void* __CopyValue(__Internal native) + { + var ret = Marshal.AllocHGlobal(sizeof(__Internal)); + *(__Internal*) ret = native; + return ret.ToPointer(); + } + + private NfdnfilteritemT(__Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + protected NfdnfilteritemT(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new __IntPtr(native); + } + + public NfdnfilteritemT() + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + public NfdnfilteritemT(global::NativeFileDialogs.AutoGen.NfdnfilteritemT _0) + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) _0.__Instance); + if (_0.__name_OwnsNativeMemory) + this.Name = _0.Name; + if (_0.__spec_OwnsNativeMemory) + this.Spec = _0.Spec; + } + + public void Dispose() + { + Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); + } + + partial void DisposePartial(bool disposing); + + internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) + { + if (__Instance == IntPtr.Zero) + return; + NativeToManagedMap.TryRemove(__Instance, out _); + DisposePartial(disposing); + if (__name_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->name); + if (__spec_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + __Instance = IntPtr.Zero; + } + + public string Name + { + get + { + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.Unicode, ((__Internal*)__Instance)->name); + } + + set + { + if (__name_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->name); + __name_OwnsNativeMemory = true; + if (value == null) + { + ((__Internal*)__Instance)->name = global::System.IntPtr.Zero; + return; + } + var __bytePtr0 = Marshal.StringToHGlobalUni(value); + ((__Internal*)__Instance)->name = (__IntPtr) __bytePtr0; + } + } + + public string Spec + { + get + { + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.Unicode, ((__Internal*)__Instance)->spec); + } + + set + { + if (__spec_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); + __spec_OwnsNativeMemory = true; + if (value == null) + { + ((__Internal*)__Instance)->spec = global::System.IntPtr.Zero; + return; + } + var __bytePtr0 = Marshal.StringToHGlobalUni(value); + ((__Internal*)__Instance)->spec = (__IntPtr) __bytePtr0; + } + } + } + + public unsafe partial class Nfdu8filteritemT : IDisposable + { + [StructLayout(LayoutKind.Sequential, Size = 16)] + public partial struct __Internal + { + internal __IntPtr name; + internal __IntPtr spec; + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdu8filteritem_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); + } + + public __IntPtr __Instance { get; protected set; } + + internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = + new global::System.Collections.Concurrent.ConcurrentDictionary(); + + internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT managed) + { + NativeToManagedMap[native] = managed; + } + + internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.Nfdu8filteritemT managed) + { + + return NativeToManagedMap.TryGetValue(native, out managed); + } + + private bool __name_OwnsNativeMemory = false; + private bool __spec_OwnsNativeMemory = false; + protected bool __ownsNativeInstance; + + internal static Nfdu8filteritemT __CreateInstance(__IntPtr native, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + return new Nfdu8filteritemT(native.ToPointer(), skipVTables); + } + + internal static Nfdu8filteritemT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + if (__TryGetNativeToManagedMapping(native, out var managed)) + return (Nfdu8filteritemT)managed; + var result = __CreateInstance(native, skipVTables); + if (saveInstance) + __RecordNativeToManagedMapping(native, result); + return result; + } + + internal static Nfdu8filteritemT __CreateInstance(__Internal native, bool skipVTables = false) + { + return new Nfdu8filteritemT(native, skipVTables); + } + + private static void* __CopyValue(__Internal native) + { + var ret = Marshal.AllocHGlobal(sizeof(__Internal)); + *(__Internal*) ret = native; + return ret.ToPointer(); + } + + private Nfdu8filteritemT(__Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + protected Nfdu8filteritemT(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new __IntPtr(native); + } + + public Nfdu8filteritemT() + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + public Nfdu8filteritemT(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT _0) + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + *((global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) _0.__Instance); + if (_0.__name_OwnsNativeMemory) + this.Name = _0.Name; + if (_0.__spec_OwnsNativeMemory) + this.Spec = _0.Spec; + } + + public void Dispose() + { + Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); + } + + partial void DisposePartial(bool disposing); + + internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) + { + if (__Instance == IntPtr.Zero) + return; + NativeToManagedMap.TryRemove(__Instance, out _); + DisposePartial(disposing); + if (__name_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->name); + if (__spec_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + __Instance = IntPtr.Zero; + } + + public string Name + { + get + { + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ((__Internal*)__Instance)->name); + } + + set + { + if (__name_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->name); + __name_OwnsNativeMemory = true; + if (value == null) + { + ((__Internal*)__Instance)->name = global::System.IntPtr.Zero; + return; + } + var __bytes0 = global::System.Text.Encoding.UTF8.GetBytes(value); + var __bytePtr0 = Marshal.AllocHGlobal(__bytes0.Length + 1); + Marshal.Copy(__bytes0, 0, __bytePtr0, __bytes0.Length); + Marshal.WriteByte(__bytePtr0 + __bytes0.Length, 0); + ((__Internal*)__Instance)->name = (__IntPtr) __bytePtr0; + } + } + + public string Spec + { + get + { + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ((__Internal*)__Instance)->spec); + } + + set + { + if (__spec_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); + __spec_OwnsNativeMemory = true; + if (value == null) + { + ((__Internal*)__Instance)->spec = global::System.IntPtr.Zero; + return; + } + var __bytes0 = global::System.Text.Encoding.UTF8.GetBytes(value); + var __bytePtr0 = Marshal.AllocHGlobal(__bytes0.Length + 1); + Marshal.Copy(__bytes0, 0, __bytePtr0, __bytes0.Length); + Marshal.WriteByte(__bytePtr0 + __bytes0.Length, 0); + ((__Internal*)__Instance)->spec = (__IntPtr) __bytePtr0; + } + } + } + + public unsafe partial class nfd + { + public partial struct __Internal + { + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_FreePathN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_FreePathN(char* filePath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_Init", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_Init(); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_Quit", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_Quit(); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogN(char** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogMultipleN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleN(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_SaveDialogN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogN(char** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath, [MarshalAs(UnmanagedType.LPWStr)] string defaultName); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PickFolderN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderN(char** outPath, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_GetError", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr NFD_GetError(); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_ClearError", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_ClearError(); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetCount", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetCount(__IntPtr pathSet, uint* count); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetPathN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathN(__IntPtr pathSet, uint index, char** outPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetEnum", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetEnum(__IntPtr pathSet, __IntPtr outEnumerator); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_FreeEnum", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_PathSetFreeEnum(__IntPtr enumerator); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_EnumNextN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextN(__IntPtr enumerator, char** outPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_Free", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_PathSetFree(__IntPtr pathSet); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_FreePathU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_FreePathU8(sbyte* outPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogU8(sbyte** outPath, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogMultipleU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleU8(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_SaveDialogU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogU8(sbyte** outPath, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultName); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PickFolderU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderU8(sbyte** outPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetPathU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathU8(__IntPtr pathSet, uint index, sbyte** outPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_EnumNextU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextU8(__IntPtr enumerator, sbyte** outPath); + } + + public static void NFD_FreePathN(char* filePath) + { + __Internal.NFD_FreePathN(filePath); + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_Init() + { + var ___ret = __Internal.NFD_Init(); + return ___ret; + } + + public static void NFD_Quit() + { + __Internal.NFD_Quit(); + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogN(char** outPath, Span filterList, uint filterCount, string defaultPath) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_OpenDialogN(outPath, __arg1, filterCount, defaultPath); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleN(__IntPtr* outPaths, Span filterList, uint filterCount, string defaultPath) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_OpenDialogMultipleN(outPaths, __arg1, filterCount, defaultPath); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogN(char** outPath, Span filterList, uint filterCount, string defaultPath, string defaultName) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_SaveDialogN(outPath, __arg1, filterCount, defaultPath, defaultName); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderN(char** outPath, string defaultPath) + { + var ___ret = __Internal.NFD_PickFolderN(outPath, defaultPath); + return ___ret; + } + + public static string NFD_GetError() + { + var ___ret = __Internal.NFD_GetError(); + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ___ret); + } + + public static void NFD_ClearError() + { + __Internal.NFD_ClearError(); + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetCount(__IntPtr pathSet, ref uint count) + { + fixed (uint* __count1 = &count) + { + var __arg1 = __count1; + var ___ret = __Internal.NFD_PathSetGetCount(pathSet, __arg1); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathN(__IntPtr pathSet, uint index, char** outPath) + { + var ___ret = __Internal.NFD_PathSetGetPathN(pathSet, index, outPath); + return ___ret; + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetEnum(__IntPtr pathSet, global::NativeFileDialogs.AutoGen.NfdpathsetenumT outEnumerator) + { + var __arg1 = outEnumerator is null ? __IntPtr.Zero : outEnumerator.__Instance; + var ___ret = __Internal.NFD_PathSetGetEnum(pathSet, __arg1); + return ___ret; + } + + public static void NFD_PathSetFreeEnum(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator) + { + var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; + __Internal.NFD_PathSetFreeEnum(__arg0); + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextN(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator, char** outPath) + { + var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; + var ___ret = __Internal.NFD_PathSetEnumNextN(__arg0, outPath); + return ___ret; + } + + public static void NFD_PathSetFree(__IntPtr pathSet) + { + __Internal.NFD_PathSetFree(pathSet); + } + + public static void NFD_FreePathU8(sbyte* outPath) + { + __Internal.NFD_FreePathU8(outPath); + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogU8(sbyte** outPath, Span filterList, uint count, string defaultPath) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_OpenDialogU8(outPath, __arg1, count, defaultPath); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleU8(__IntPtr* outPaths, Span filterList, uint count, string defaultPath) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_OpenDialogMultipleU8(outPaths, __arg1, count, defaultPath); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogU8(sbyte** outPath, Span filterList, uint count, string defaultPath, string defaultName) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_SaveDialogU8(outPath, __arg1, count, defaultPath, defaultName); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderU8(sbyte** outPath, string defaultPath) + { + var ___ret = __Internal.NFD_PickFolderU8(outPath, defaultPath); + return ___ret; + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathU8(__IntPtr pathSet, uint index, sbyte** outPath) + { + var ___ret = __Internal.NFD_PathSetGetPathU8(pathSet, index, outPath); + return ___ret; + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextU8(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator, sbyte** outPath) + { + var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; + var ___ret = __Internal.NFD_PathSetEnumNextU8(__arg0, outPath); + return ___ret; + } + } +} diff --git a/NativeFileDialogs.CppSharpGenerator/NativeFileDialogs.CppSharpGenerator.csproj b/NativeFileDialogs.CppSharpGenerator/NativeFileDialogs.CppSharpGenerator.csproj index 5b824fd..9924e45 100644 --- a/NativeFileDialogs.CppSharpGenerator/NativeFileDialogs.CppSharpGenerator.csproj +++ b/NativeFileDialogs.CppSharpGenerator/NativeFileDialogs.CppSharpGenerator.csproj @@ -8,7 +8,7 @@ - + diff --git a/NativeFileDialogs.CppSharpGenerator/NativeFileDialogsLibrary.cs b/NativeFileDialogs.CppSharpGenerator/NativeFileDialogsLibrary.cs index ea5317d..dda100c 100644 --- a/NativeFileDialogs.CppSharpGenerator/NativeFileDialogsLibrary.cs +++ b/NativeFileDialogs.CppSharpGenerator/NativeFileDialogsLibrary.cs @@ -6,20 +6,32 @@ using CppSharp; using CppSharp.AST; using CppSharp.Generators; using CppSharp.Passes; +using System.IO; namespace NativeFileDialogs.CppSharpGenerator; public class NativeFileDialogsLibrary : ILibrary { private const string lib_name = "NativeFileDialogs"; + private const string include_directory = "./include"; public void Setup(Driver driver) { + Directory.CreateDirectory(include_directory); + + string fileText = File.ReadAllText(@"../nativefiledialog-extended/src/include/nfd.h") + .Replace("const nfdnfilteritem_t* filterList,", "const nfdnfilteritem_t filterList[],") + .Replace("const nfdu8filteritem_t* filterList,", "const nfdu8filteritem_t filterList[],"); + //These replacements are necessary because CppSharp incorrectly generates the former as an object reference. + + File.WriteAllText(include_directory + "/nfd.h", fileText); + DriverOptions options = driver.Options; options.GeneratorKind = GeneratorKind.CSharp; options.OutputDir = $"../{lib_name}.AutoGen"; + options.UseSpan = true; var module = options.AddModule("nfd"); - module.IncludeDirs.Add(@"../nativefiledialog-extended/src/include"); + module.IncludeDirs.Add(include_directory); module.Headers.Add("nfd.h"); module.OutputNamespace = $"{lib_name}.AutoGen"; } diff --git a/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj b/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj index 5b92052..5816652 100644 --- a/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj +++ b/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj @@ -22,7 +22,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/NativeFileDialogs.Net/Nfd.cs b/NativeFileDialogs.Net/Nfd.cs index 5ed6526..b78b34b 100644 --- a/NativeFileDialogs.Net/Nfd.cs +++ b/NativeFileDialogs.Net/Nfd.cs @@ -15,13 +15,13 @@ public static class Nfd public static NfdStatus OpenDialog(out string? outPath, IDictionary? filters = null, string? defaultPath = null) { manager.PushDialog(); - NfdnfilteritemT[] filterItems = ToFilterItems(filters); + Nfdu8filteritemT[] filterItems = ToFilterItems(filters); NfdStatus status; unsafe { sbyte* outPathPtr; - status = nfd.NFD_OpenDialogN(&outPathPtr, filterItems, (uint)filterItems.Length, defaultPath).ToNfdStatus(); + status = nfd.NFD_OpenDialogU8(&outPathPtr, filterItems, (uint)filterItems.Length, defaultPath).ToNfdStatus(); outPath = status == NfdStatus.Cancelled ? null : new string(outPathPtr); } @@ -32,13 +32,13 @@ public static class Nfd public static NfdStatus OpenDialogMultiple(out string[]? outPaths, IDictionary? filters = null, string? defaultPath = null) { manager.PushDialog(); - NfdnfilteritemT[] filterItems = ToFilterItems(filters); + Nfdu8filteritemT[] filterItems = ToFilterItems(filters); NfdStatus status; unsafe { IntPtr pathSet; - status = nfd.NFD_OpenDialogMultipleN(&pathSet, filterItems, (uint)filterItems.Length, defaultPath).ToNfdStatus(); + status = nfd.NFD_OpenDialogMultipleU8(&pathSet, filterItems, (uint)filterItems.Length, defaultPath).ToNfdStatus(); if (status == NfdStatus.Ok) { @@ -49,7 +49,7 @@ public static class Nfd for (uint i = 0; i < count; i++) { sbyte* pathPtr; - nfd.NFD_PathSetGetPathN(pathSet, i, &pathPtr); + nfd.NFD_PathSetGetPathU8(pathSet, i, &pathPtr); outPaths[i] = new string(pathPtr); } @@ -73,7 +73,7 @@ public static class Nfd unsafe { sbyte* outPathPtr; - status = nfd.NFD_PickFolderN(&outPathPtr, defaultPath).ToNfdStatus(); + status = nfd.NFD_PickFolderU8(&outPathPtr, defaultPath).ToNfdStatus(); outPath = status == NfdStatus.Cancelled ? null : new string(outPathPtr); } @@ -84,13 +84,13 @@ public static class Nfd public static NfdStatus SaveDialog(out string? savePath, IDictionary? filters = null, string defaultName = "Untitled", string? defaultPath = null) { manager.PushDialog(); - NfdnfilteritemT[] filterItems = ToFilterItems(filters); + Nfdu8filteritemT[] filterItems = ToFilterItems(filters); NfdStatus status; unsafe { sbyte* savePathPtr; - status = nfd.NFD_SaveDialogN(&savePathPtr, filterItems, (uint)filterItems.Length, defaultPath, defaultName).ToNfdStatus(); + status = nfd.NFD_SaveDialogU8(&savePathPtr, filterItems, (uint)filterItems.Length, defaultPath, defaultName).ToNfdStatus(); savePath = status == NfdStatus.Cancelled ? null : new string(savePathPtr); } @@ -98,16 +98,16 @@ public static class Nfd return status; } - internal static NfdnfilteritemT[] ToFilterItems(IDictionary? filters) + internal static Nfdu8filteritemT[] ToFilterItems(IDictionary? filters) { if (filters == null) - return Array.Empty(); + return Array.Empty(); - NfdnfilteritemT[] filterItems = new NfdnfilteritemT[filters.Count]; + Nfdu8filteritemT[] filterItems = new Nfdu8filteritemT[filters.Count]; int i = 0; foreach ((string key, string value) in filters) { - filterItems[i++] = new NfdnfilteritemT + filterItems[i++] = new Nfdu8filteritemT { Name = key, Spec = value, From 3672cd2dddc1afabf59fd8e3e2ea17afef7f64cb Mon Sep 17 00:00:00 2001 From: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> Date: Sat, 9 Dec 2023 03:16:47 -0500 Subject: [PATCH 2/8] Line feed --- NativeFileDialogs.AutoGen/nfd.cs | 1556 +++++++++++++++--------------- 1 file changed, 778 insertions(+), 778 deletions(-) diff --git a/NativeFileDialogs.AutoGen/nfd.cs b/NativeFileDialogs.AutoGen/nfd.cs index 575edb4..360a157 100644 --- a/NativeFileDialogs.AutoGen/nfd.cs +++ b/NativeFileDialogs.AutoGen/nfd.cs @@ -1,778 +1,778 @@ -// ---------------------------------------------------------------------------- -// -// This is autogenerated code by CppSharp. -// Do not edit this file or all your changes will be lost after re-generation. -// -// ---------------------------------------------------------------------------- -using System; -using System.Runtime.InteropServices; -using System.Security; -using __CallingConvention = global::System.Runtime.InteropServices.CallingConvention; -using __IntPtr = global::System.IntPtr; - -#pragma warning disable CS0109 // Member does not hide an inherited member; new keyword is not required - -namespace NativeFileDialogs.AutoGen -{ - public enum NfdresultT - { - NFD_ERROR = 0, - NFD_OKAY = 1, - NFD_CANCEL = 2 - } - - public unsafe partial class NfdpathsetenumT : IDisposable - { - [StructLayout(LayoutKind.Sequential, Size = 8)] - public partial struct __Internal - { - internal __IntPtr ptr; - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdpathsetenum_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] - internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); - } - - public __IntPtr __Instance { get; protected set; } - - internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = - new global::System.Collections.Concurrent.ConcurrentDictionary(); - - internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.NfdpathsetenumT managed) - { - NativeToManagedMap[native] = managed; - } - - internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.NfdpathsetenumT managed) - { - - return NativeToManagedMap.TryGetValue(native, out managed); - } - - protected bool __ownsNativeInstance; - - internal static NfdpathsetenumT __CreateInstance(__IntPtr native, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - return new NfdpathsetenumT(native.ToPointer(), skipVTables); - } - - internal static NfdpathsetenumT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - if (__TryGetNativeToManagedMapping(native, out var managed)) - return (NfdpathsetenumT)managed; - var result = __CreateInstance(native, skipVTables); - if (saveInstance) - __RecordNativeToManagedMapping(native, result); - return result; - } - - internal static NfdpathsetenumT __CreateInstance(__Internal native, bool skipVTables = false) - { - return new NfdpathsetenumT(native, skipVTables); - } - - private static void* __CopyValue(__Internal native) - { - var ret = Marshal.AllocHGlobal(sizeof(__Internal)); - *(__Internal*) ret = native; - return ret.ToPointer(); - } - - private NfdpathsetenumT(__Internal native, bool skipVTables = false) - : this(__CopyValue(native), skipVTables) - { - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - } - - protected NfdpathsetenumT(void* native, bool skipVTables = false) - { - if (native == null) - return; - __Instance = new __IntPtr(native); - } - - public NfdpathsetenumT() - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal)); - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - } - - public NfdpathsetenumT(global::NativeFileDialogs.AutoGen.NfdpathsetenumT _0) - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal)); - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - *((global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal*) _0.__Instance); - } - - public void Dispose() - { - Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); - } - - partial void DisposePartial(bool disposing); - - internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) - { - if (__Instance == IntPtr.Zero) - return; - NativeToManagedMap.TryRemove(__Instance, out _); - DisposePartial(disposing); - if (__ownsNativeInstance) - Marshal.FreeHGlobal(__Instance); - __Instance = IntPtr.Zero; - } - - public __IntPtr Ptr - { - get - { - return ((__Internal*)__Instance)->ptr; - } - - set - { - ((__Internal*)__Instance)->ptr = (__IntPtr) value; - } - } - } - - public unsafe partial class NfdnfilteritemT : IDisposable - { - [StructLayout(LayoutKind.Sequential, Size = 16)] - public partial struct __Internal - { - internal __IntPtr name; - internal __IntPtr spec; - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdnfilteritem_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] - internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); - } - - public __IntPtr __Instance { get; protected set; } - - internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = - new global::System.Collections.Concurrent.ConcurrentDictionary(); - - internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.NfdnfilteritemT managed) - { - NativeToManagedMap[native] = managed; - } - - internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.NfdnfilteritemT managed) - { - - return NativeToManagedMap.TryGetValue(native, out managed); - } - - private bool __name_OwnsNativeMemory = false; - private bool __spec_OwnsNativeMemory = false; - protected bool __ownsNativeInstance; - - internal static NfdnfilteritemT __CreateInstance(__IntPtr native, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - return new NfdnfilteritemT(native.ToPointer(), skipVTables); - } - - internal static NfdnfilteritemT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - if (__TryGetNativeToManagedMapping(native, out var managed)) - return (NfdnfilteritemT)managed; - var result = __CreateInstance(native, skipVTables); - if (saveInstance) - __RecordNativeToManagedMapping(native, result); - return result; - } - - internal static NfdnfilteritemT __CreateInstance(__Internal native, bool skipVTables = false) - { - return new NfdnfilteritemT(native, skipVTables); - } - - private static void* __CopyValue(__Internal native) - { - var ret = Marshal.AllocHGlobal(sizeof(__Internal)); - *(__Internal*) ret = native; - return ret.ToPointer(); - } - - private NfdnfilteritemT(__Internal native, bool skipVTables = false) - : this(__CopyValue(native), skipVTables) - { - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - } - - protected NfdnfilteritemT(void* native, bool skipVTables = false) - { - if (native == null) - return; - __Instance = new __IntPtr(native); - } - - public NfdnfilteritemT() - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - } - - public NfdnfilteritemT(global::NativeFileDialogs.AutoGen.NfdnfilteritemT _0) - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) _0.__Instance); - if (_0.__name_OwnsNativeMemory) - this.Name = _0.Name; - if (_0.__spec_OwnsNativeMemory) - this.Spec = _0.Spec; - } - - public void Dispose() - { - Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); - } - - partial void DisposePartial(bool disposing); - - internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) - { - if (__Instance == IntPtr.Zero) - return; - NativeToManagedMap.TryRemove(__Instance, out _); - DisposePartial(disposing); - if (__name_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->name); - if (__spec_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); - if (__ownsNativeInstance) - Marshal.FreeHGlobal(__Instance); - __Instance = IntPtr.Zero; - } - - public string Name - { - get - { - return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.Unicode, ((__Internal*)__Instance)->name); - } - - set - { - if (__name_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->name); - __name_OwnsNativeMemory = true; - if (value == null) - { - ((__Internal*)__Instance)->name = global::System.IntPtr.Zero; - return; - } - var __bytePtr0 = Marshal.StringToHGlobalUni(value); - ((__Internal*)__Instance)->name = (__IntPtr) __bytePtr0; - } - } - - public string Spec - { - get - { - return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.Unicode, ((__Internal*)__Instance)->spec); - } - - set - { - if (__spec_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); - __spec_OwnsNativeMemory = true; - if (value == null) - { - ((__Internal*)__Instance)->spec = global::System.IntPtr.Zero; - return; - } - var __bytePtr0 = Marshal.StringToHGlobalUni(value); - ((__Internal*)__Instance)->spec = (__IntPtr) __bytePtr0; - } - } - } - - public unsafe partial class Nfdu8filteritemT : IDisposable - { - [StructLayout(LayoutKind.Sequential, Size = 16)] - public partial struct __Internal - { - internal __IntPtr name; - internal __IntPtr spec; - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdu8filteritem_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] - internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); - } - - public __IntPtr __Instance { get; protected set; } - - internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = - new global::System.Collections.Concurrent.ConcurrentDictionary(); - - internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT managed) - { - NativeToManagedMap[native] = managed; - } - - internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.Nfdu8filteritemT managed) - { - - return NativeToManagedMap.TryGetValue(native, out managed); - } - - private bool __name_OwnsNativeMemory = false; - private bool __spec_OwnsNativeMemory = false; - protected bool __ownsNativeInstance; - - internal static Nfdu8filteritemT __CreateInstance(__IntPtr native, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - return new Nfdu8filteritemT(native.ToPointer(), skipVTables); - } - - internal static Nfdu8filteritemT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - if (__TryGetNativeToManagedMapping(native, out var managed)) - return (Nfdu8filteritemT)managed; - var result = __CreateInstance(native, skipVTables); - if (saveInstance) - __RecordNativeToManagedMapping(native, result); - return result; - } - - internal static Nfdu8filteritemT __CreateInstance(__Internal native, bool skipVTables = false) - { - return new Nfdu8filteritemT(native, skipVTables); - } - - private static void* __CopyValue(__Internal native) - { - var ret = Marshal.AllocHGlobal(sizeof(__Internal)); - *(__Internal*) ret = native; - return ret.ToPointer(); - } - - private Nfdu8filteritemT(__Internal native, bool skipVTables = false) - : this(__CopyValue(native), skipVTables) - { - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - } - - protected Nfdu8filteritemT(void* native, bool skipVTables = false) - { - if (native == null) - return; - __Instance = new __IntPtr(native); - } - - public Nfdu8filteritemT() - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal)); - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - } - - public Nfdu8filteritemT(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT _0) - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal)); - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - *((global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) _0.__Instance); - if (_0.__name_OwnsNativeMemory) - this.Name = _0.Name; - if (_0.__spec_OwnsNativeMemory) - this.Spec = _0.Spec; - } - - public void Dispose() - { - Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); - } - - partial void DisposePartial(bool disposing); - - internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) - { - if (__Instance == IntPtr.Zero) - return; - NativeToManagedMap.TryRemove(__Instance, out _); - DisposePartial(disposing); - if (__name_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->name); - if (__spec_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); - if (__ownsNativeInstance) - Marshal.FreeHGlobal(__Instance); - __Instance = IntPtr.Zero; - } - - public string Name - { - get - { - return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ((__Internal*)__Instance)->name); - } - - set - { - if (__name_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->name); - __name_OwnsNativeMemory = true; - if (value == null) - { - ((__Internal*)__Instance)->name = global::System.IntPtr.Zero; - return; - } - var __bytes0 = global::System.Text.Encoding.UTF8.GetBytes(value); - var __bytePtr0 = Marshal.AllocHGlobal(__bytes0.Length + 1); - Marshal.Copy(__bytes0, 0, __bytePtr0, __bytes0.Length); - Marshal.WriteByte(__bytePtr0 + __bytes0.Length, 0); - ((__Internal*)__Instance)->name = (__IntPtr) __bytePtr0; - } - } - - public string Spec - { - get - { - return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ((__Internal*)__Instance)->spec); - } - - set - { - if (__spec_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); - __spec_OwnsNativeMemory = true; - if (value == null) - { - ((__Internal*)__Instance)->spec = global::System.IntPtr.Zero; - return; - } - var __bytes0 = global::System.Text.Encoding.UTF8.GetBytes(value); - var __bytePtr0 = Marshal.AllocHGlobal(__bytes0.Length + 1); - Marshal.Copy(__bytes0, 0, __bytePtr0, __bytes0.Length); - Marshal.WriteByte(__bytePtr0 + __bytes0.Length, 0); - ((__Internal*)__Instance)->spec = (__IntPtr) __bytePtr0; - } - } - } - - public unsafe partial class nfd - { - public partial struct __Internal - { - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_FreePathN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_FreePathN(char* filePath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_Init", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_Init(); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_Quit", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_Quit(); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogN(char** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogMultipleN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleN(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_SaveDialogN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogN(char** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath, [MarshalAs(UnmanagedType.LPWStr)] string defaultName); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PickFolderN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderN(char** outPath, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_GetError", CallingConvention = __CallingConvention.Cdecl)] - internal static extern __IntPtr NFD_GetError(); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_ClearError", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_ClearError(); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetCount", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetCount(__IntPtr pathSet, uint* count); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetPathN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathN(__IntPtr pathSet, uint index, char** outPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetEnum", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetEnum(__IntPtr pathSet, __IntPtr outEnumerator); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_FreeEnum", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_PathSetFreeEnum(__IntPtr enumerator); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_EnumNextN", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextN(__IntPtr enumerator, char** outPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_Free", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_PathSetFree(__IntPtr pathSet); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_FreePathU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_FreePathU8(sbyte* outPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogU8(sbyte** outPath, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogMultipleU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleU8(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_SaveDialogU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogU8(sbyte** outPath, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultName); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PickFolderU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderU8(sbyte** outPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetPathU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathU8(__IntPtr pathSet, uint index, sbyte** outPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_EnumNextU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextU8(__IntPtr enumerator, sbyte** outPath); - } - - public static void NFD_FreePathN(char* filePath) - { - __Internal.NFD_FreePathN(filePath); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_Init() - { - var ___ret = __Internal.NFD_Init(); - return ___ret; - } - - public static void NFD_Quit() - { - __Internal.NFD_Quit(); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogN(char** outPath, Span filterList, uint filterCount, string defaultPath) - { - Span __filterList; - if (filterList == null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; - } - } - fixed (global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) - { - var __arg1 = ____filterList1; - var ___ret = __Internal.NFD_OpenDialogN(outPath, __arg1, filterCount, defaultPath); - return ___ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleN(__IntPtr* outPaths, Span filterList, uint filterCount, string defaultPath) - { - Span __filterList; - if (filterList == null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; - } - } - fixed (global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) - { - var __arg1 = ____filterList1; - var ___ret = __Internal.NFD_OpenDialogMultipleN(outPaths, __arg1, filterCount, defaultPath); - return ___ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogN(char** outPath, Span filterList, uint filterCount, string defaultPath, string defaultName) - { - Span __filterList; - if (filterList == null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; - } - } - fixed (global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) - { - var __arg1 = ____filterList1; - var ___ret = __Internal.NFD_SaveDialogN(outPath, __arg1, filterCount, defaultPath, defaultName); - return ___ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderN(char** outPath, string defaultPath) - { - var ___ret = __Internal.NFD_PickFolderN(outPath, defaultPath); - return ___ret; - } - - public static string NFD_GetError() - { - var ___ret = __Internal.NFD_GetError(); - return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ___ret); - } - - public static void NFD_ClearError() - { - __Internal.NFD_ClearError(); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetCount(__IntPtr pathSet, ref uint count) - { - fixed (uint* __count1 = &count) - { - var __arg1 = __count1; - var ___ret = __Internal.NFD_PathSetGetCount(pathSet, __arg1); - return ___ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathN(__IntPtr pathSet, uint index, char** outPath) - { - var ___ret = __Internal.NFD_PathSetGetPathN(pathSet, index, outPath); - return ___ret; - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetEnum(__IntPtr pathSet, global::NativeFileDialogs.AutoGen.NfdpathsetenumT outEnumerator) - { - var __arg1 = outEnumerator is null ? __IntPtr.Zero : outEnumerator.__Instance; - var ___ret = __Internal.NFD_PathSetGetEnum(pathSet, __arg1); - return ___ret; - } - - public static void NFD_PathSetFreeEnum(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator) - { - var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; - __Internal.NFD_PathSetFreeEnum(__arg0); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextN(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator, char** outPath) - { - var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; - var ___ret = __Internal.NFD_PathSetEnumNextN(__arg0, outPath); - return ___ret; - } - - public static void NFD_PathSetFree(__IntPtr pathSet) - { - __Internal.NFD_PathSetFree(pathSet); - } - - public static void NFD_FreePathU8(sbyte* outPath) - { - __Internal.NFD_FreePathU8(outPath); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogU8(sbyte** outPath, Span filterList, uint count, string defaultPath) - { - Span __filterList; - if (filterList == null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; - } - } - fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) - { - var __arg1 = ____filterList1; - var ___ret = __Internal.NFD_OpenDialogU8(outPath, __arg1, count, defaultPath); - return ___ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleU8(__IntPtr* outPaths, Span filterList, uint count, string defaultPath) - { - Span __filterList; - if (filterList == null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; - } - } - fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) - { - var __arg1 = ____filterList1; - var ___ret = __Internal.NFD_OpenDialogMultipleU8(outPaths, __arg1, count, defaultPath); - return ___ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogU8(sbyte** outPath, Span filterList, uint count, string defaultPath, string defaultName) - { - Span __filterList; - if (filterList == null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; - } - } - fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) - { - var __arg1 = ____filterList1; - var ___ret = __Internal.NFD_SaveDialogU8(outPath, __arg1, count, defaultPath, defaultName); - return ___ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderU8(sbyte** outPath, string defaultPath) - { - var ___ret = __Internal.NFD_PickFolderU8(outPath, defaultPath); - return ___ret; - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathU8(__IntPtr pathSet, uint index, sbyte** outPath) - { - var ___ret = __Internal.NFD_PathSetGetPathU8(pathSet, index, outPath); - return ___ret; - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextU8(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator, sbyte** outPath) - { - var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; - var ___ret = __Internal.NFD_PathSetEnumNextU8(__arg0, outPath); - return ___ret; - } - } -} +// ---------------------------------------------------------------------------- +// +// This is autogenerated code by CppSharp. +// Do not edit this file or all your changes will be lost after re-generation. +// +// ---------------------------------------------------------------------------- +using System; +using System.Runtime.InteropServices; +using System.Security; +using __CallingConvention = global::System.Runtime.InteropServices.CallingConvention; +using __IntPtr = global::System.IntPtr; + +#pragma warning disable CS0109 // Member does not hide an inherited member; new keyword is not required + +namespace NativeFileDialogs.AutoGen +{ + public enum NfdresultT + { + NFD_ERROR = 0, + NFD_OKAY = 1, + NFD_CANCEL = 2 + } + + public unsafe partial class NfdpathsetenumT : IDisposable + { + [StructLayout(LayoutKind.Sequential, Size = 8)] + public partial struct __Internal + { + internal __IntPtr ptr; + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdpathsetenum_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); + } + + public __IntPtr __Instance { get; protected set; } + + internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = + new global::System.Collections.Concurrent.ConcurrentDictionary(); + + internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.NfdpathsetenumT managed) + { + NativeToManagedMap[native] = managed; + } + + internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.NfdpathsetenumT managed) + { + + return NativeToManagedMap.TryGetValue(native, out managed); + } + + protected bool __ownsNativeInstance; + + internal static NfdpathsetenumT __CreateInstance(__IntPtr native, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + return new NfdpathsetenumT(native.ToPointer(), skipVTables); + } + + internal static NfdpathsetenumT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + if (__TryGetNativeToManagedMapping(native, out var managed)) + return (NfdpathsetenumT)managed; + var result = __CreateInstance(native, skipVTables); + if (saveInstance) + __RecordNativeToManagedMapping(native, result); + return result; + } + + internal static NfdpathsetenumT __CreateInstance(__Internal native, bool skipVTables = false) + { + return new NfdpathsetenumT(native, skipVTables); + } + + private static void* __CopyValue(__Internal native) + { + var ret = Marshal.AllocHGlobal(sizeof(__Internal)); + *(__Internal*) ret = native; + return ret.ToPointer(); + } + + private NfdpathsetenumT(__Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + protected NfdpathsetenumT(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new __IntPtr(native); + } + + public NfdpathsetenumT() + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + public NfdpathsetenumT(global::NativeFileDialogs.AutoGen.NfdpathsetenumT _0) + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + *((global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.NfdpathsetenumT.__Internal*) _0.__Instance); + } + + public void Dispose() + { + Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); + } + + partial void DisposePartial(bool disposing); + + internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) + { + if (__Instance == IntPtr.Zero) + return; + NativeToManagedMap.TryRemove(__Instance, out _); + DisposePartial(disposing); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + __Instance = IntPtr.Zero; + } + + public __IntPtr Ptr + { + get + { + return ((__Internal*)__Instance)->ptr; + } + + set + { + ((__Internal*)__Instance)->ptr = (__IntPtr) value; + } + } + } + + public unsafe partial class NfdnfilteritemT : IDisposable + { + [StructLayout(LayoutKind.Sequential, Size = 16)] + public partial struct __Internal + { + internal __IntPtr name; + internal __IntPtr spec; + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdnfilteritem_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); + } + + public __IntPtr __Instance { get; protected set; } + + internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = + new global::System.Collections.Concurrent.ConcurrentDictionary(); + + internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.NfdnfilteritemT managed) + { + NativeToManagedMap[native] = managed; + } + + internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.NfdnfilteritemT managed) + { + + return NativeToManagedMap.TryGetValue(native, out managed); + } + + private bool __name_OwnsNativeMemory = false; + private bool __spec_OwnsNativeMemory = false; + protected bool __ownsNativeInstance; + + internal static NfdnfilteritemT __CreateInstance(__IntPtr native, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + return new NfdnfilteritemT(native.ToPointer(), skipVTables); + } + + internal static NfdnfilteritemT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + if (__TryGetNativeToManagedMapping(native, out var managed)) + return (NfdnfilteritemT)managed; + var result = __CreateInstance(native, skipVTables); + if (saveInstance) + __RecordNativeToManagedMapping(native, result); + return result; + } + + internal static NfdnfilteritemT __CreateInstance(__Internal native, bool skipVTables = false) + { + return new NfdnfilteritemT(native, skipVTables); + } + + private static void* __CopyValue(__Internal native) + { + var ret = Marshal.AllocHGlobal(sizeof(__Internal)); + *(__Internal*) ret = native; + return ret.ToPointer(); + } + + private NfdnfilteritemT(__Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + protected NfdnfilteritemT(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new __IntPtr(native); + } + + public NfdnfilteritemT() + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + public NfdnfilteritemT(global::NativeFileDialogs.AutoGen.NfdnfilteritemT _0) + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) _0.__Instance); + if (_0.__name_OwnsNativeMemory) + this.Name = _0.Name; + if (_0.__spec_OwnsNativeMemory) + this.Spec = _0.Spec; + } + + public void Dispose() + { + Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); + } + + partial void DisposePartial(bool disposing); + + internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) + { + if (__Instance == IntPtr.Zero) + return; + NativeToManagedMap.TryRemove(__Instance, out _); + DisposePartial(disposing); + if (__name_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->name); + if (__spec_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + __Instance = IntPtr.Zero; + } + + public string Name + { + get + { + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.Unicode, ((__Internal*)__Instance)->name); + } + + set + { + if (__name_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->name); + __name_OwnsNativeMemory = true; + if (value == null) + { + ((__Internal*)__Instance)->name = global::System.IntPtr.Zero; + return; + } + var __bytePtr0 = Marshal.StringToHGlobalUni(value); + ((__Internal*)__Instance)->name = (__IntPtr) __bytePtr0; + } + } + + public string Spec + { + get + { + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.Unicode, ((__Internal*)__Instance)->spec); + } + + set + { + if (__spec_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); + __spec_OwnsNativeMemory = true; + if (value == null) + { + ((__Internal*)__Instance)->spec = global::System.IntPtr.Zero; + return; + } + var __bytePtr0 = Marshal.StringToHGlobalUni(value); + ((__Internal*)__Instance)->spec = (__IntPtr) __bytePtr0; + } + } + } + + public unsafe partial class Nfdu8filteritemT : IDisposable + { + [StructLayout(LayoutKind.Sequential, Size = 16)] + public partial struct __Internal + { + internal __IntPtr name; + internal __IntPtr spec; + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdu8filteritem_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); + } + + public __IntPtr __Instance { get; protected set; } + + internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = + new global::System.Collections.Concurrent.ConcurrentDictionary(); + + internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT managed) + { + NativeToManagedMap[native] = managed; + } + + internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.Nfdu8filteritemT managed) + { + + return NativeToManagedMap.TryGetValue(native, out managed); + } + + private bool __name_OwnsNativeMemory = false; + private bool __spec_OwnsNativeMemory = false; + protected bool __ownsNativeInstance; + + internal static Nfdu8filteritemT __CreateInstance(__IntPtr native, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + return new Nfdu8filteritemT(native.ToPointer(), skipVTables); + } + + internal static Nfdu8filteritemT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + if (__TryGetNativeToManagedMapping(native, out var managed)) + return (Nfdu8filteritemT)managed; + var result = __CreateInstance(native, skipVTables); + if (saveInstance) + __RecordNativeToManagedMapping(native, result); + return result; + } + + internal static Nfdu8filteritemT __CreateInstance(__Internal native, bool skipVTables = false) + { + return new Nfdu8filteritemT(native, skipVTables); + } + + private static void* __CopyValue(__Internal native) + { + var ret = Marshal.AllocHGlobal(sizeof(__Internal)); + *(__Internal*) ret = native; + return ret.ToPointer(); + } + + private Nfdu8filteritemT(__Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + protected Nfdu8filteritemT(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new __IntPtr(native); + } + + public Nfdu8filteritemT() + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + public Nfdu8filteritemT(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT _0) + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + *((global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) _0.__Instance); + if (_0.__name_OwnsNativeMemory) + this.Name = _0.Name; + if (_0.__spec_OwnsNativeMemory) + this.Spec = _0.Spec; + } + + public void Dispose() + { + Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); + } + + partial void DisposePartial(bool disposing); + + internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) + { + if (__Instance == IntPtr.Zero) + return; + NativeToManagedMap.TryRemove(__Instance, out _); + DisposePartial(disposing); + if (__name_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->name); + if (__spec_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + __Instance = IntPtr.Zero; + } + + public string Name + { + get + { + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ((__Internal*)__Instance)->name); + } + + set + { + if (__name_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->name); + __name_OwnsNativeMemory = true; + if (value == null) + { + ((__Internal*)__Instance)->name = global::System.IntPtr.Zero; + return; + } + var __bytes0 = global::System.Text.Encoding.UTF8.GetBytes(value); + var __bytePtr0 = Marshal.AllocHGlobal(__bytes0.Length + 1); + Marshal.Copy(__bytes0, 0, __bytePtr0, __bytes0.Length); + Marshal.WriteByte(__bytePtr0 + __bytes0.Length, 0); + ((__Internal*)__Instance)->name = (__IntPtr) __bytePtr0; + } + } + + public string Spec + { + get + { + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ((__Internal*)__Instance)->spec); + } + + set + { + if (__spec_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); + __spec_OwnsNativeMemory = true; + if (value == null) + { + ((__Internal*)__Instance)->spec = global::System.IntPtr.Zero; + return; + } + var __bytes0 = global::System.Text.Encoding.UTF8.GetBytes(value); + var __bytePtr0 = Marshal.AllocHGlobal(__bytes0.Length + 1); + Marshal.Copy(__bytes0, 0, __bytePtr0, __bytes0.Length); + Marshal.WriteByte(__bytePtr0 + __bytes0.Length, 0); + ((__Internal*)__Instance)->spec = (__IntPtr) __bytePtr0; + } + } + } + + public unsafe partial class nfd + { + public partial struct __Internal + { + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_FreePathN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_FreePathN(char* filePath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_Init", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_Init(); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_Quit", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_Quit(); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogN(char** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogMultipleN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleN(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_SaveDialogN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogN(char** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath, [MarshalAs(UnmanagedType.LPWStr)] string defaultName); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PickFolderN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderN(char** outPath, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_GetError", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr NFD_GetError(); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_ClearError", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_ClearError(); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetCount", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetCount(__IntPtr pathSet, uint* count); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetPathN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathN(__IntPtr pathSet, uint index, char** outPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetEnum", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetEnum(__IntPtr pathSet, __IntPtr outEnumerator); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_FreeEnum", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_PathSetFreeEnum(__IntPtr enumerator); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_EnumNextN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextN(__IntPtr enumerator, char** outPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_Free", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_PathSetFree(__IntPtr pathSet); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_FreePathU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_FreePathU8(sbyte* outPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogU8(sbyte** outPath, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogMultipleU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleU8(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_SaveDialogU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogU8(sbyte** outPath, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultName); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PickFolderU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderU8(sbyte** outPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetPathU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathU8(__IntPtr pathSet, uint index, sbyte** outPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_EnumNextU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextU8(__IntPtr enumerator, sbyte** outPath); + } + + public static void NFD_FreePathN(char* filePath) + { + __Internal.NFD_FreePathN(filePath); + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_Init() + { + var ___ret = __Internal.NFD_Init(); + return ___ret; + } + + public static void NFD_Quit() + { + __Internal.NFD_Quit(); + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogN(char** outPath, Span filterList, uint filterCount, string defaultPath) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_OpenDialogN(outPath, __arg1, filterCount, defaultPath); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleN(__IntPtr* outPaths, Span filterList, uint filterCount, string defaultPath) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_OpenDialogMultipleN(outPaths, __arg1, filterCount, defaultPath); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogN(char** outPath, Span filterList, uint filterCount, string defaultPath, string defaultName) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_SaveDialogN(outPath, __arg1, filterCount, defaultPath, defaultName); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderN(char** outPath, string defaultPath) + { + var ___ret = __Internal.NFD_PickFolderN(outPath, defaultPath); + return ___ret; + } + + public static string NFD_GetError() + { + var ___ret = __Internal.NFD_GetError(); + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ___ret); + } + + public static void NFD_ClearError() + { + __Internal.NFD_ClearError(); + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetCount(__IntPtr pathSet, ref uint count) + { + fixed (uint* __count1 = &count) + { + var __arg1 = __count1; + var ___ret = __Internal.NFD_PathSetGetCount(pathSet, __arg1); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathN(__IntPtr pathSet, uint index, char** outPath) + { + var ___ret = __Internal.NFD_PathSetGetPathN(pathSet, index, outPath); + return ___ret; + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetEnum(__IntPtr pathSet, global::NativeFileDialogs.AutoGen.NfdpathsetenumT outEnumerator) + { + var __arg1 = outEnumerator is null ? __IntPtr.Zero : outEnumerator.__Instance; + var ___ret = __Internal.NFD_PathSetGetEnum(pathSet, __arg1); + return ___ret; + } + + public static void NFD_PathSetFreeEnum(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator) + { + var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; + __Internal.NFD_PathSetFreeEnum(__arg0); + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextN(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator, char** outPath) + { + var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; + var ___ret = __Internal.NFD_PathSetEnumNextN(__arg0, outPath); + return ___ret; + } + + public static void NFD_PathSetFree(__IntPtr pathSet) + { + __Internal.NFD_PathSetFree(pathSet); + } + + public static void NFD_FreePathU8(sbyte* outPath) + { + __Internal.NFD_FreePathU8(outPath); + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogU8(sbyte** outPath, Span filterList, uint count, string defaultPath) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_OpenDialogU8(outPath, __arg1, count, defaultPath); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleU8(__IntPtr* outPaths, Span filterList, uint count, string defaultPath) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_OpenDialogMultipleU8(outPaths, __arg1, count, defaultPath); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogU8(sbyte** outPath, Span filterList, uint count, string defaultPath, string defaultName) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_SaveDialogU8(outPath, __arg1, count, defaultPath, defaultName); + return ___ret; + } + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderU8(sbyte** outPath, string defaultPath) + { + var ___ret = __Internal.NFD_PickFolderU8(outPath, defaultPath); + return ___ret; + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathU8(__IntPtr pathSet, uint index, sbyte** outPath) + { + var ___ret = __Internal.NFD_PathSetGetPathU8(pathSet, index, outPath); + return ___ret; + } + + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextU8(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator, sbyte** outPath) + { + var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; + var ___ret = __Internal.NFD_PathSetEnumNextU8(__arg0, outPath); + return ___ret; + } + } +} From caf98b92f7b342bde634b18aba5180d24775c311 Mon Sep 17 00:00:00 2001 From: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> Date: Sat, 9 Dec 2023 15:41:36 -0500 Subject: [PATCH 3/8] Bump to .NET 8 --- ...eDialogs.AutoGen.Example.OpenDialog.csproj | 2 +- ....AutoGen.Example.OpenDialogMultiple.csproj | 2 +- ...eDialogs.AutoGen.Example.PickFolder.csproj | 2 +- ...eDialogs.AutoGen.Example.SaveDialog.csproj | 2 +- ...eFileDialogs.Net.Example.OpenDialog.csproj | 2 +- ...logs.Net.Example.OpenDialogMultiple.csproj | 2 +- ...eFileDialogs.Net.Example.PickFolder.csproj | 2 +- ...eFileDialogs.Net.Example.SaveDialog.csproj | 2 +- .../NativeFileDialogs.AutoGen-symbols.cpp | 12 +++---- .../NativeFileDialogs.AutoGen.csproj | 7 ++-- NativeFileDialogs.AutoGen/Std.cs | 32 +++++++++---------- ...NativeFileDialogs.CppSharpGenerator.csproj | 2 +- .../NativeFileDialogs.Net.Runtime.csproj | 3 +- .../NativeFileDialogs.Net.csproj | 7 ++-- 14 files changed, 37 insertions(+), 42 deletions(-) diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/NativeFileDialogs.AutoGen.Example.OpenDialog.csproj b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/NativeFileDialogs.AutoGen.Example.OpenDialog.csproj index 3e30fa4..e144ec4 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/NativeFileDialogs.AutoGen.Example.OpenDialog.csproj +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/NativeFileDialogs.AutoGen.Example.OpenDialog.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 true disable enable diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple.csproj b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple.csproj index 3e30fa4..e144ec4 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple.csproj +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 true disable enable diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/NativeFileDialogs.AutoGen.Example.PickFolder.csproj b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/NativeFileDialogs.AutoGen.Example.PickFolder.csproj index 3e30fa4..e144ec4 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/NativeFileDialogs.AutoGen.Example.PickFolder.csproj +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/NativeFileDialogs.AutoGen.Example.PickFolder.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 true disable enable diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/NativeFileDialogs.AutoGen.Example.SaveDialog.csproj b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/NativeFileDialogs.AutoGen.Example.SaveDialog.csproj index 3e30fa4..e144ec4 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/NativeFileDialogs.AutoGen.Example.SaveDialog.csproj +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/NativeFileDialogs.AutoGen.Example.SaveDialog.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 true disable enable diff --git a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj index a765f79..3883f95 100644 --- a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj +++ b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 disable enable diff --git a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj index a765f79..3883f95 100644 --- a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj +++ b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 disable enable diff --git a/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj b/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj index a765f79..3883f95 100644 --- a/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj +++ b/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 disable enable diff --git a/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj b/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj index a765f79..3883f95 100644 --- a/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj +++ b/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 disable enable diff --git a/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp b/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp index 6138872..26a29e8 100644 --- a/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp +++ b/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp @@ -1,6 +1,6 @@ -#include -#include - -nfdpathsetenum_t& (nfdpathsetenum_t::*_0)(nfdpathsetenum_t&&) = &nfdpathsetenum_t::operator=; -nfdnfilteritem_t& (nfdnfilteritem_t::*_1)(nfdnfilteritem_t&&) = &nfdnfilteritem_t::operator=; -nfdu8filteritem_t& (nfdu8filteritem_t::*_2)(nfdu8filteritem_t&&) = &nfdu8filteritem_t::operator=; +#include +#include + +nfdpathsetenum_t& (nfdpathsetenum_t::*_0)(nfdpathsetenum_t&&) = &nfdpathsetenum_t::operator=; +nfdnfilteritem_t& (nfdnfilteritem_t::*_1)(nfdnfilteritem_t&&) = &nfdnfilteritem_t::operator=; +nfdu8filteritem_t& (nfdu8filteritem_t::*_2)(nfdu8filteritem_t&&) = &nfdu8filteritem_t::operator=; diff --git a/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen.csproj b/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen.csproj index efe2301..4d6fe5b 100644 --- a/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen.csproj +++ b/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true disable enable @@ -17,16 +17,13 @@ NativeFileDialogs.AutoGen Auto-generated .NET bindings for NativeFileDialogs (Extended) 2022 Speykious + https://github.com/Speykious/NativeFileDialogs.NET https://github.com/Speykious/NativeFileDialogs.NET LICENSE - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/NativeFileDialogs.AutoGen/Std.cs b/NativeFileDialogs.AutoGen/Std.cs index 36fa03d..5ad81bc 100644 --- a/NativeFileDialogs.AutoGen/Std.cs +++ b/NativeFileDialogs.AutoGen/Std.cs @@ -1,16 +1,16 @@ -// ---------------------------------------------------------------------------- -// -// This is autogenerated code by CppSharp. -// Do not edit this file or all your changes will be lost after re-generation. -// -// ---------------------------------------------------------------------------- -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security; -using __CallingConvention = global::System.Runtime.InteropServices.CallingConvention; -using __IntPtr = global::System.IntPtr; -[assembly:InternalsVisibleTo("nfd")] - -#pragma warning disable CS0109 // Member does not hide an inherited member; new keyword is not required - +// ---------------------------------------------------------------------------- +// +// This is autogenerated code by CppSharp. +// Do not edit this file or all your changes will be lost after re-generation. +// +// ---------------------------------------------------------------------------- +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using __CallingConvention = global::System.Runtime.InteropServices.CallingConvention; +using __IntPtr = global::System.IntPtr; +[assembly:InternalsVisibleTo("nfd")] + +#pragma warning disable CS0109 // Member does not hide an inherited member; new keyword is not required + diff --git a/NativeFileDialogs.CppSharpGenerator/NativeFileDialogs.CppSharpGenerator.csproj b/NativeFileDialogs.CppSharpGenerator/NativeFileDialogs.CppSharpGenerator.csproj index 9924e45..b167e36 100644 --- a/NativeFileDialogs.CppSharpGenerator/NativeFileDialogs.CppSharpGenerator.csproj +++ b/NativeFileDialogs.CppSharpGenerator/NativeFileDialogs.CppSharpGenerator.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 disable enable diff --git a/NativeFileDialogs.Net.Runtime/NativeFileDialogs.Net.Runtime.csproj b/NativeFileDialogs.Net.Runtime/NativeFileDialogs.Net.Runtime.csproj index f225658..5db19cf 100644 --- a/NativeFileDialogs.Net.Runtime/NativeFileDialogs.Net.Runtime.csproj +++ b/NativeFileDialogs.Net.Runtime/NativeFileDialogs.Net.Runtime.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 Library NativeFileDialogs.Net.Runtime NativeFileDialogs.Net.Runtime @@ -16,6 +16,7 @@ NativeFileDialogs.Net.Runtime Native runtime libraries for NativeFileDialogs.NET 2022 Speykious + https://github.com/Speykious/NativeFileDialogs.NET https://github.com/Speykious/NativeFileDialogs.NET LICENSE false diff --git a/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj b/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj index 5816652..51a1369 100644 --- a/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj +++ b/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true disable enable @@ -17,15 +17,12 @@ NativeFileDialogs.Net Full .NET wrapper for NativeFileDialogs (Extended) 2022 Speykious + https://github.com/Speykious/NativeFileDialogs.NET https://github.com/Speykious/NativeFileDialogs.NET LICENSE - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - From ca2d7f7147b545c0902e4035e2f26fe701bd0be8 Mon Sep 17 00:00:00 2001 From: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> Date: Sat, 23 Dec 2023 17:12:03 -0500 Subject: [PATCH 4/8] Generate new bindings --- .../NativeFileDialogs.AutoGen-symbols.cpp | 4 +- NativeFileDialogs.AutoGen/nfd.cs | 680 +++++++++++------- .../NativeFileDialogsLibrary.cs | 17 + 3 files changed, 427 insertions(+), 274 deletions(-) diff --git a/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp b/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp index 26a29e8..d5ef979 100644 --- a/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp +++ b/NativeFileDialogs.AutoGen/NativeFileDialogs.AutoGen-symbols.cpp @@ -2,5 +2,5 @@ #include nfdpathsetenum_t& (nfdpathsetenum_t::*_0)(nfdpathsetenum_t&&) = &nfdpathsetenum_t::operator=; -nfdnfilteritem_t& (nfdnfilteritem_t::*_1)(nfdnfilteritem_t&&) = &nfdnfilteritem_t::operator=; -nfdu8filteritem_t& (nfdu8filteritem_t::*_2)(nfdu8filteritem_t&&) = &nfdu8filteritem_t::operator=; +nfdu8filteritem_t& (nfdu8filteritem_t::*_1)(nfdu8filteritem_t&&) = &nfdu8filteritem_t::operator=; +nfdnfilteritem_t& (nfdnfilteritem_t::*_2)(nfdnfilteritem_t&&) = &nfdnfilteritem_t::operator=; diff --git a/NativeFileDialogs.AutoGen/nfd.cs b/NativeFileDialogs.AutoGen/nfd.cs index 360a157..58ec745 100644 --- a/NativeFileDialogs.AutoGen/nfd.cs +++ b/NativeFileDialogs.AutoGen/nfd.cs @@ -16,8 +16,11 @@ namespace NativeFileDialogs.AutoGen { public enum NfdresultT { + /// Programmatic error NFD_ERROR = 0, + /// User pressed okay, or successful return NFD_OKAY = 1, + /// User pressed cancel NFD_CANCEL = 2 } @@ -142,169 +145,6 @@ namespace NativeFileDialogs.AutoGen } } - public unsafe partial class NfdnfilteritemT : IDisposable - { - [StructLayout(LayoutKind.Sequential, Size = 16)] - public partial struct __Internal - { - internal __IntPtr name; - internal __IntPtr spec; - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdnfilteritem_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] - internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); - } - - public __IntPtr __Instance { get; protected set; } - - internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = - new global::System.Collections.Concurrent.ConcurrentDictionary(); - - internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.NfdnfilteritemT managed) - { - NativeToManagedMap[native] = managed; - } - - internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.NfdnfilteritemT managed) - { - - return NativeToManagedMap.TryGetValue(native, out managed); - } - - private bool __name_OwnsNativeMemory = false; - private bool __spec_OwnsNativeMemory = false; - protected bool __ownsNativeInstance; - - internal static NfdnfilteritemT __CreateInstance(__IntPtr native, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - return new NfdnfilteritemT(native.ToPointer(), skipVTables); - } - - internal static NfdnfilteritemT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) - { - if (native == __IntPtr.Zero) - return null; - if (__TryGetNativeToManagedMapping(native, out var managed)) - return (NfdnfilteritemT)managed; - var result = __CreateInstance(native, skipVTables); - if (saveInstance) - __RecordNativeToManagedMapping(native, result); - return result; - } - - internal static NfdnfilteritemT __CreateInstance(__Internal native, bool skipVTables = false) - { - return new NfdnfilteritemT(native, skipVTables); - } - - private static void* __CopyValue(__Internal native) - { - var ret = Marshal.AllocHGlobal(sizeof(__Internal)); - *(__Internal*) ret = native; - return ret.ToPointer(); - } - - private NfdnfilteritemT(__Internal native, bool skipVTables = false) - : this(__CopyValue(native), skipVTables) - { - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - } - - protected NfdnfilteritemT(void* native, bool skipVTables = false) - { - if (native == null) - return; - __Instance = new __IntPtr(native); - } - - public NfdnfilteritemT() - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - } - - public NfdnfilteritemT(global::NativeFileDialogs.AutoGen.NfdnfilteritemT _0) - { - __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); - __ownsNativeInstance = true; - __RecordNativeToManagedMapping(__Instance, this); - *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) _0.__Instance); - if (_0.__name_OwnsNativeMemory) - this.Name = _0.Name; - if (_0.__spec_OwnsNativeMemory) - this.Spec = _0.Spec; - } - - public void Dispose() - { - Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); - } - - partial void DisposePartial(bool disposing); - - internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) - { - if (__Instance == IntPtr.Zero) - return; - NativeToManagedMap.TryRemove(__Instance, out _); - DisposePartial(disposing); - if (__name_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->name); - if (__spec_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); - if (__ownsNativeInstance) - Marshal.FreeHGlobal(__Instance); - __Instance = IntPtr.Zero; - } - - public string Name - { - get - { - return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.Unicode, ((__Internal*)__Instance)->name); - } - - set - { - if (__name_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->name); - __name_OwnsNativeMemory = true; - if (value == null) - { - ((__Internal*)__Instance)->name = global::System.IntPtr.Zero; - return; - } - var __bytePtr0 = Marshal.StringToHGlobalUni(value); - ((__Internal*)__Instance)->name = (__IntPtr) __bytePtr0; - } - } - - public string Spec - { - get - { - return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.Unicode, ((__Internal*)__Instance)->spec); - } - - set - { - if (__spec_OwnsNativeMemory) - Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); - __spec_OwnsNativeMemory = true; - if (value == null) - { - ((__Internal*)__Instance)->spec = global::System.IntPtr.Zero; - return; - } - var __bytePtr0 = Marshal.StringToHGlobalUni(value); - ((__Internal*)__Instance)->spec = (__IntPtr) __bytePtr0; - } - } - } - public unsafe partial class Nfdu8filteritemT : IDisposable { [StructLayout(LayoutKind.Sequential, Size = 16)] @@ -474,6 +314,170 @@ namespace NativeFileDialogs.AutoGen } } + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] + public unsafe partial class NfdnfilteritemT : IDisposable + { + [StructLayout(LayoutKind.Sequential, Size = 16)] + public partial struct __Internal + { + internal __IntPtr name; + internal __IntPtr spec; + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "??0nfdnfilteritem_t@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); + } + + public __IntPtr __Instance { get; protected set; } + + internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = + new global::System.Collections.Concurrent.ConcurrentDictionary(); + + internal static void __RecordNativeToManagedMapping(IntPtr native, global::NativeFileDialogs.AutoGen.NfdnfilteritemT managed) + { + NativeToManagedMap[native] = managed; + } + + internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::NativeFileDialogs.AutoGen.NfdnfilteritemT managed) + { + + return NativeToManagedMap.TryGetValue(native, out managed); + } + + private bool __name_OwnsNativeMemory = false; + private bool __spec_OwnsNativeMemory = false; + protected bool __ownsNativeInstance; + + internal static NfdnfilteritemT __CreateInstance(__IntPtr native, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + return new NfdnfilteritemT(native.ToPointer(), skipVTables); + } + + internal static NfdnfilteritemT __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false) + { + if (native == __IntPtr.Zero) + return null; + if (__TryGetNativeToManagedMapping(native, out var managed)) + return (NfdnfilteritemT)managed; + var result = __CreateInstance(native, skipVTables); + if (saveInstance) + __RecordNativeToManagedMapping(native, result); + return result; + } + + internal static NfdnfilteritemT __CreateInstance(__Internal native, bool skipVTables = false) + { + return new NfdnfilteritemT(native, skipVTables); + } + + private static void* __CopyValue(__Internal native) + { + var ret = Marshal.AllocHGlobal(sizeof(__Internal)); + *(__Internal*) ret = native; + return ret.ToPointer(); + } + + private NfdnfilteritemT(__Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + protected NfdnfilteritemT(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new __IntPtr(native); + } + + public NfdnfilteritemT() + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + } + + public NfdnfilteritemT(global::NativeFileDialogs.AutoGen.NfdnfilteritemT _0) + { + __Instance = Marshal.AllocHGlobal(sizeof(global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal)); + __ownsNativeInstance = true; + __RecordNativeToManagedMapping(__Instance, this); + *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) __Instance) = *((global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal*) _0.__Instance); + if (_0.__name_OwnsNativeMemory) + this.Name = _0.Name; + if (_0.__spec_OwnsNativeMemory) + this.Spec = _0.Spec; + } + + public void Dispose() + { + Dispose(disposing: true, callNativeDtor : __ownsNativeInstance ); + } + + partial void DisposePartial(bool disposing); + + internal protected virtual void Dispose(bool disposing, bool callNativeDtor ) + { + if (__Instance == IntPtr.Zero) + return; + NativeToManagedMap.TryRemove(__Instance, out _); + DisposePartial(disposing); + if (__name_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->name); + if (__spec_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + __Instance = IntPtr.Zero; + } + + public string Name + { + get + { + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.Unicode, ((__Internal*)__Instance)->name); + } + + set + { + if (__name_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->name); + __name_OwnsNativeMemory = true; + if (value == null) + { + ((__Internal*)__Instance)->name = global::System.IntPtr.Zero; + return; + } + var __bytePtr0 = Marshal.StringToHGlobalUni(value); + ((__Internal*)__Instance)->name = (__IntPtr) __bytePtr0; + } + } + + public string Spec + { + get + { + return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.Unicode, ((__Internal*)__Instance)->spec); + } + + set + { + if (__spec_OwnsNativeMemory) + Marshal.FreeHGlobal(((__Internal*)__Instance)->spec); + __spec_OwnsNativeMemory = true; + if (value == null) + { + ((__Internal*)__Instance)->spec = global::System.IntPtr.Zero; + return; + } + var __bytePtr0 = Marshal.StringToHGlobalUni(value); + ((__Internal*)__Instance)->spec = (__IntPtr) __bytePtr0; + } + } + } + public unsafe partial class nfd { public partial struct __Internal @@ -481,6 +485,9 @@ namespace NativeFileDialogs.AutoGen [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_FreePathN", CallingConvention = __CallingConvention.Cdecl)] internal static extern void NFD_FreePathN(char* filePath); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_FreePathU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_FreePathU8(sbyte* filePath); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_Init", CallingConvention = __CallingConvention.Cdecl)] internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_Init(); @@ -490,15 +497,27 @@ namespace NativeFileDialogs.AutoGen [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogN", CallingConvention = __CallingConvention.Cdecl)] internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogN(char** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogU8(sbyte** outPath, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogMultipleN", CallingConvention = __CallingConvention.Cdecl)] internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleN(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogMultipleU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleU8(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_SaveDialogN", CallingConvention = __CallingConvention.Cdecl)] internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogN(char** outPath, global::NativeFileDialogs.AutoGen.NfdnfilteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath, [MarshalAs(UnmanagedType.LPWStr)] string defaultName); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_SaveDialogU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogU8(sbyte** outPath, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint filterCount, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultName); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PickFolderN", CallingConvention = __CallingConvention.Cdecl)] internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderN(char** outPath, [MarshalAs(UnmanagedType.LPWStr)] string defaultPath); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PickFolderU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderU8(sbyte** outPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_GetError", CallingConvention = __CallingConvention.Cdecl)] internal static extern __IntPtr NFD_GetError(); @@ -511,6 +530,15 @@ namespace NativeFileDialogs.AutoGen [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetPathN", CallingConvention = __CallingConvention.Cdecl)] internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathN(__IntPtr pathSet, uint index, char** outPath); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetPathU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathU8(__IntPtr pathSet, uint index, sbyte** outPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_FreePathN", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_PathSetFreePathN([MarshalAs(UnmanagedType.LPWStr)] string filePath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_FreePathU8", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_PathSetFreePathU8([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string filePath); + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetEnum", CallingConvention = __CallingConvention.Cdecl)] internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetEnum(__IntPtr pathSet, __IntPtr outEnumerator); @@ -520,47 +548,52 @@ namespace NativeFileDialogs.AutoGen [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_EnumNextN", CallingConvention = __CallingConvention.Cdecl)] internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextN(__IntPtr enumerator, char** outPath); - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_Free", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_PathSetFree(__IntPtr pathSet); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_FreePathU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void NFD_FreePathU8(sbyte* outPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogU8(sbyte** outPath, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_OpenDialogMultipleU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleU8(__IntPtr* outPaths, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_SaveDialogU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogU8(sbyte** outPath, global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* filterList, uint count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultName); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PickFolderU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderU8(sbyte** outPath, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string defaultPath); - - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_GetPathU8", CallingConvention = __CallingConvention.Cdecl)] - internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathU8(__IntPtr pathSet, uint index, sbyte** outPath); - [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_EnumNextU8", CallingConvention = __CallingConvention.Cdecl)] internal static extern global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextU8(__IntPtr enumerator, sbyte** outPath); + + [SuppressUnmanagedCodeSecurity, DllImport("nfd", EntryPoint = "NFD_PathSet_Free", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void NFD_PathSetFree(__IntPtr pathSet); } + /// Free a file path that was returned by the dialogs. + /// Note: use NFD_PathSet_FreePathN() to free path from pathset instead of this function. + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static void NFD_FreePathN(char* filePath) { __Internal.NFD_FreePathN(filePath); } + /// Free a file path that was returned by the dialogs. + /// Note: use NFD_PathSet_FreePathU8() to free path from pathset instead of this function. + public static void NFD_FreePathU8(sbyte* filePath) + { + __Internal.NFD_FreePathU8(filePath); + } + + /// + /// Initialize NFD. Call this for every thread that might use NFD, before calling any other NFD + /// functions on that thread. + /// public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_Init() { var ___ret = __Internal.NFD_Init(); return ___ret; } + /// Call this to de-initialize NFD, if NFD_Init returned NFD_OKAY. public static void NFD_Quit() { __Internal.NFD_Quit(); } + /// Single file open dialog + /// If zero, filterList is ignored (you can use null). + /// If null, the operating system will decide. + /// + /// It's the caller's responsibility to free `outPath` via NFD_FreePathN() if this function returns + /// NFD_OKAY. + /// + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogN(char** outPath, Span filterList, uint filterCount, string defaultPath) { Span __filterList; @@ -583,6 +616,43 @@ namespace NativeFileDialogs.AutoGen } } + /// Single file open dialog + /// If zero, filterList is ignored (you can use null). + /// If null, the operating system will decide. + /// + /// It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function + /// returns NFD_OKAY. + /// + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogU8(sbyte** outPath, Span filterList, uint filterCount, string defaultPath) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_OpenDialogU8(outPath, __arg1, filterCount, defaultPath); + return ___ret; + } + } + + /// Multiple file open dialog + /// If zero, filterList is ignored (you can use null). + /// If null, the operating system will decide. + /// + /// It is the caller's responsibility to free `outPaths` via NFD_PathSet_FreeN() if this function + /// returns NFD_OKAY. + /// + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleN(__IntPtr* outPaths, Span filterList, uint filterCount, string defaultPath) { Span __filterList; @@ -605,6 +675,43 @@ namespace NativeFileDialogs.AutoGen } } + /// Multiple file open dialog + /// If zero, filterList is ignored (you can use null). + /// If null, the operating system will decide. + /// + /// It is the caller's responsibility to free `outPaths` via NFD_PathSet_FreeU8() if this function + /// returns NFD_OKAY. + /// + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleU8(__IntPtr* outPaths, Span filterList, uint filterCount, string defaultPath) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_OpenDialogMultipleU8(outPaths, __arg1, filterCount, defaultPath); + return ___ret; + } + } + + /// Save dialog + /// If zero, filterList is ignored (you can use null). + /// If null, the operating system will decide. + /// + /// It is the caller's responsibility to free `outPath` via NFD_FreePathN() if this function returns + /// NFD_OKAY. + /// + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogN(char** outPath, Span filterList, uint filterCount, string defaultPath, string defaultName) { Span __filterList; @@ -627,23 +734,85 @@ namespace NativeFileDialogs.AutoGen } } + /// Save dialog + /// If zero, filterList is ignored (you can use null). + /// If null, the operating system will decide. + /// + /// It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function + /// returns NFD_OKAY. + /// + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogU8(sbyte** outPath, Span filterList, uint filterCount, string defaultPath, string defaultName) + { + Span __filterList; + if (filterList == null) + __filterList = null; + else + { + __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; + for (int i = 0; i < __filterList.Length; i++) + { + var __element = filterList[i]; + __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; + } + } + fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) + { + var __arg1 = ____filterList1; + var ___ret = __Internal.NFD_SaveDialogU8(outPath, __arg1, filterCount, defaultPath, defaultName); + return ___ret; + } + } + + /// Select folder dialog + /// If null, the operating system will decide. + /// + /// It is the caller's responsibility to free `outPath` via NFD_FreePathN() if this function returns + /// NFD_OKAY. + /// + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderN(char** outPath, string defaultPath) { var ___ret = __Internal.NFD_PickFolderN(outPath, defaultPath); return ___ret; } + /// Select folder dialog + /// If null, the operating system will decide. + /// + /// It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function + /// returns NFD_OKAY. + /// + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderU8(sbyte** outPath, string defaultPath) + { + var ___ret = __Internal.NFD_PickFolderU8(outPath, defaultPath); + return ___ret; + } + + /// Get the last error + /// The last error that was set, or null if there is no error. + /// + /// This is set when a function returns NFD_ERROR. + /// The memory is owned by NFD and should not be freed by user code. + /// This is *always* ASCII printable characters, so it can be interpreted as UTF-8 without any + /// conversion. + /// public static string NFD_GetError() { var ___ret = __Internal.NFD_GetError(); return CppSharp.Runtime.MarshalUtil.GetString(global::System.Text.Encoding.UTF8, ___ret); } + /// Clear the error. public static void NFD_ClearError() { __Internal.NFD_ClearError(); } + /// Get the number of entries stored in pathSet. + /// + /// Note: some paths might be invalid (NFD_ERROR will be returned by NFD_PathSet_GetPath), + /// so we might not actually have this number of usable paths. + /// public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetCount(__IntPtr pathSet, ref uint count) { fixed (uint* __count1 = &count) @@ -654,12 +823,47 @@ namespace NativeFileDialogs.AutoGen } } + /// Get the UTF-8 path at offset index. + /// + /// It is the caller's responsibility to free `outPath` via NFD_PathSet_FreePathN() if this function + /// returns NFD_OKAY. + /// + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathN(__IntPtr pathSet, uint index, char** outPath) { var ___ret = __Internal.NFD_PathSetGetPathN(pathSet, index, outPath); return ___ret; } + /// Get the native path at offset index. + /// + /// It is the caller's responsibility to free `outPath` via NFD_PathSet_FreePathU8() if this + /// function returns NFD_OKAY. + /// + public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathU8(__IntPtr pathSet, uint index, sbyte** outPath) + { + var ___ret = __Internal.NFD_PathSetGetPathU8(pathSet, index, outPath); + return ___ret; + } + + /// Free the path gotten by NFD_PathSet_GetPathN(). + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] + public static void NFD_PathSetFreePathN(string filePath) + { + __Internal.NFD_PathSetFreePathN(filePath); + } + + /// Free the path gotten by NFD_PathSet_GetPathU8(). + public static void NFD_PathSetFreePathU8(string filePath) + { + __Internal.NFD_PathSetFreePathU8(filePath); + } + + /// Gets an enumerator of the path set. + /// + /// It is the caller's responsibility to free `enumerator` via NFD_PathSet_FreeEnum() + /// if this function returns NFD_OKAY, and it should be freed before freeing the pathset. + /// public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetEnum(__IntPtr pathSet, global::NativeFileDialogs.AutoGen.NfdpathsetenumT outEnumerator) { var __arg1 = outEnumerator is null ? __IntPtr.Zero : outEnumerator.__Instance; @@ -667,12 +871,20 @@ namespace NativeFileDialogs.AutoGen return ___ret; } + /// Frees an enumerator of the path set. public static void NFD_PathSetFreeEnum(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator) { var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; __Internal.NFD_PathSetFreeEnum(__arg0); } + /// Gets the next item from the path set enumerator. + /// + /// If there are no more items, then *outPaths will be set to null. + /// It is the caller's responsibility to free `*outPath` via NFD_PathSet_FreePathN() + /// if this function returns NFD_OKAY and `*outPath` is not null. + /// + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextN(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator, char** outPath) { var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; @@ -680,99 +892,23 @@ namespace NativeFileDialogs.AutoGen return ___ret; } - public static void NFD_PathSetFree(__IntPtr pathSet) - { - __Internal.NFD_PathSetFree(pathSet); - } - - public static void NFD_FreePathU8(sbyte* outPath) - { - __Internal.NFD_FreePathU8(outPath); - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogU8(sbyte** outPath, Span filterList, uint count, string defaultPath) - { - Span __filterList; - if (filterList == null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; - } - } - fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) - { - var __arg1 = ____filterList1; - var ___ret = __Internal.NFD_OpenDialogU8(outPath, __arg1, count, defaultPath); - return ___ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_OpenDialogMultipleU8(__IntPtr* outPaths, Span filterList, uint count, string defaultPath) - { - Span __filterList; - if (filterList == null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; - } - } - fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) - { - var __arg1 = ____filterList1; - var ___ret = __Internal.NFD_OpenDialogMultipleU8(outPaths, __arg1, count, defaultPath); - return ___ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_SaveDialogU8(sbyte** outPath, Span filterList, uint count, string defaultPath, string defaultName) - { - Span __filterList; - if (filterList == null) - __filterList = null; - else - { - __filterList = new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal[filterList.Length]; - for (int i = 0; i < __filterList.Length; i++) - { - var __element = filterList[i]; - __filterList[i] = __element is null ? new global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal() : *(global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal*) __element.__Instance; - } - } - fixed (global::NativeFileDialogs.AutoGen.Nfdu8filteritemT.__Internal* ____filterList1 = &MemoryMarshal.GetReference(__filterList)) - { - var __arg1 = ____filterList1; - var ___ret = __Internal.NFD_SaveDialogU8(outPath, __arg1, count, defaultPath, defaultName); - return ___ret; - } - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PickFolderU8(sbyte** outPath, string defaultPath) - { - var ___ret = __Internal.NFD_PickFolderU8(outPath, defaultPath); - return ___ret; - } - - public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetGetPathU8(__IntPtr pathSet, uint index, sbyte** outPath) - { - var ___ret = __Internal.NFD_PathSetGetPathU8(pathSet, index, outPath); - return ___ret; - } - + /// Gets the next item from the path set enumerator. + /// + /// If there are no more items, then *outPaths will be set to null. + /// It is the caller's responsibility to free `*outPath` via NFD_PathSet_FreePathU8() + /// if this function returns NFD_OKAY and `*outPath` is not null. + /// public static global::NativeFileDialogs.AutoGen.NfdresultT NFD_PathSetEnumNextU8(global::NativeFileDialogs.AutoGen.NfdpathsetenumT enumerator, sbyte** outPath) { var __arg0 = enumerator is null ? __IntPtr.Zero : enumerator.__Instance; var ___ret = __Internal.NFD_PathSetEnumNextU8(__arg0, outPath); return ___ret; } + + /// Free the pathSet + public static void NFD_PathSetFree(__IntPtr pathSet) + { + __Internal.NFD_PathSetFree(pathSet); + } } } diff --git a/NativeFileDialogs.CppSharpGenerator/NativeFileDialogsLibrary.cs b/NativeFileDialogs.CppSharpGenerator/NativeFileDialogsLibrary.cs index dda100c..646145e 100644 --- a/NativeFileDialogs.CppSharpGenerator/NativeFileDialogsLibrary.cs +++ b/NativeFileDialogs.CppSharpGenerator/NativeFileDialogsLibrary.cs @@ -6,7 +6,10 @@ using CppSharp; using CppSharp.AST; using CppSharp.Generators; using CppSharp.Passes; +using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Runtime.Versioning; namespace NativeFileDialogs.CppSharpGenerator; @@ -47,5 +50,19 @@ public class NativeFileDialogsLibrary : ILibrary public void Postprocess(Driver driver, ASTContext ctx) { + foreach (var function in ctx.TranslationUnits.SelectMany(t => t.Functions).Where(f => f.Name.EndsWith('N'))) + { + AddWindowsOnlyAttribute(function); + } + AddWindowsOnlyAttribute(ctx.FindClass("NfdnfilteritemT").First()); + } + + public void GenerateCode(Driver driver, List outputs) + { + } + + private static void AddWindowsOnlyAttribute(Declaration declaration) + { + declaration.Attributes.Add(new Attribute() { Type = typeof(SupportedOSPlatformAttribute), Value = "\"windows\"" }); } } From 5b14a8c5c93e32c1bab12ef9dba5f802b64654a1 Mon Sep 17 00:00:00 2001 From: Speykious Date: Mon, 25 Dec 2023 15:21:57 +0100 Subject: [PATCH 5/8] Update submodule: just use upstream directly --- .gitmodules | 4 ++-- nativefiledialog-extended | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 2abbc08..fbc2f6a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "nativefiledialog-extended"] path = nativefiledialog-extended - url = ssh://git@github.com/Speykious/nativefiledialog-extended - branch = dynamic + url = ssh://git@github.com/btzy/nativefiledialog-extended.git + branch = master diff --git a/nativefiledialog-extended b/nativefiledialog-extended index ab1e78e..b73cf4c 160000 --- a/nativefiledialog-extended +++ b/nativefiledialog-extended @@ -1 +1 @@ -Subproject commit ab1e78eb5462f153d247bad309760d0bd67a6d57 +Subproject commit b73cf4cdfc644deda95ceffb355a84b28a34bb88 From b4268f082765ad1271728c66870575b27fa587b2 Mon Sep 17 00:00:00 2001 From: Speykious Date: Mon, 25 Dec 2023 15:27:37 +0100 Subject: [PATCH 6/8] Update NativeFileDialogs.Net.Runtime version --- .../NativeFileDialogs.Net.Runtime.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NativeFileDialogs.Net.Runtime/NativeFileDialogs.Net.Runtime.csproj b/NativeFileDialogs.Net.Runtime/NativeFileDialogs.Net.Runtime.csproj index 5db19cf..03e0a11 100644 --- a/NativeFileDialogs.Net.Runtime/NativeFileDialogs.Net.Runtime.csproj +++ b/NativeFileDialogs.Net.Runtime/NativeFileDialogs.Net.Runtime.csproj @@ -10,7 +10,7 @@ true NativeFileDialogs.Net.Runtime - 1.0.0 + 1.1.0 Speykious Native;File;Dialogs;Portal;Gtk NativeFileDialogs.Net.Runtime From b3452cfbdad7ad496c32de10458a7f4de630c7d1 Mon Sep 17 00:00:00 2001 From: Speykious Date: Mon, 25 Dec 2023 15:46:22 +0100 Subject: [PATCH 7/8] Use new runtime package --- .../NativeFileDialogs.AutoGen.Example.OpenDialog.csproj | 2 +- .../NativeFileDialogs.AutoGen.Example.OpenDialogMultiple.csproj | 2 +- .../NativeFileDialogs.AutoGen.Example.PickFolder.csproj | 2 +- .../NativeFileDialogs.AutoGen.Example.SaveDialog.csproj | 2 +- .../NativeFileDialogs.Net.Example.OpenDialog.csproj | 2 +- .../NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj | 2 +- .../NativeFileDialogs.Net.Example.PickFolder.csproj | 2 +- .../NativeFileDialogs.Net.Example.SaveDialog.csproj | 2 +- NativeFileDialogs.Net/NativeFileDialogs.Net.csproj | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/NativeFileDialogs.AutoGen.Example.OpenDialog.csproj b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/NativeFileDialogs.AutoGen.Example.OpenDialog.csproj index e144ec4..9b05d36 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/NativeFileDialogs.AutoGen.Example.OpenDialog.csproj +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialog/NativeFileDialogs.AutoGen.Example.OpenDialog.csproj @@ -13,7 +13,7 @@ - + diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple.csproj b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple.csproj index e144ec4..9b05d36 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple.csproj +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple/NativeFileDialogs.AutoGen.Example.OpenDialogMultiple.csproj @@ -13,7 +13,7 @@ - + diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/NativeFileDialogs.AutoGen.Example.PickFolder.csproj b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/NativeFileDialogs.AutoGen.Example.PickFolder.csproj index e144ec4..9b05d36 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/NativeFileDialogs.AutoGen.Example.PickFolder.csproj +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.PickFolder/NativeFileDialogs.AutoGen.Example.PickFolder.csproj @@ -13,7 +13,7 @@ - + diff --git a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/NativeFileDialogs.AutoGen.Example.SaveDialog.csproj b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/NativeFileDialogs.AutoGen.Example.SaveDialog.csproj index e144ec4..9b05d36 100644 --- a/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/NativeFileDialogs.AutoGen.Example.SaveDialog.csproj +++ b/Examples/AutoGen/NativeFileDialogs.AutoGen.Example.SaveDialog/NativeFileDialogs.AutoGen.Example.SaveDialog.csproj @@ -13,7 +13,7 @@ - + diff --git a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj index 3883f95..ade6a50 100644 --- a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj +++ b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj @@ -12,7 +12,7 @@ - + diff --git a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj index 3883f95..ade6a50 100644 --- a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj +++ b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj @@ -12,7 +12,7 @@ - + diff --git a/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj b/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj index 3883f95..ade6a50 100644 --- a/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj +++ b/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj @@ -12,7 +12,7 @@ - + diff --git a/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj b/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj index 3883f95..ade6a50 100644 --- a/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj +++ b/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj @@ -12,7 +12,7 @@ - + diff --git a/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj b/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj index 51a1369..b1a3d0a 100644 --- a/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj +++ b/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj @@ -24,7 +24,7 @@ - + From 613358ec52f5ddebaf6474fcd3a7c20518c3f530 Mon Sep 17 00:00:00 2001 From: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> Date: Mon, 25 Dec 2023 10:33:14 -0500 Subject: [PATCH 8/8] Project reference instead of package reference --- NativeFileDialogs.Net/NativeFileDialogs.Net.csproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj b/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj index b1a3d0a..913a604 100644 --- a/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj +++ b/NativeFileDialogs.Net/NativeFileDialogs.Net.csproj @@ -23,7 +23,6 @@ - @@ -31,4 +30,8 @@ + + + +