Preliminary support for .NET 8

- Native compatibility
- Parser can now be consumed from non-.NET programming languages
This commit is contained in:
Tony Bark 2023-08-12 19:05:45 -04:00
parent 5f6e6c1935
commit df7197609d
3 changed files with 25 additions and 7 deletions

View file

@ -1,5 +1,8 @@
// This project is licensed under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
#if NET8_0
using System.Runtime.InteropServices;
#endif
namespace CSTNet;
@ -30,6 +33,16 @@ public class CST
return GetEntry(entries, key);
}
#if NET8_0
[UnmanagedCallersOnly(EntryPoint = "parse")]
public static IntPtr Parse(IntPtr content, IntPtr key)
{
// => Parse(Marshal.PtrToStringAnsi(content), Marshal.PtrToStringAnsi(key));
var entries = NormalizeEntries(Marshal.PtrToStringAnsi(content));
return Marshal.StringToHGlobalAnsi(GetEntry(entries, Marshal.PtrToStringAnsi(key)));
}
#endif
/// <summary>
/// Replaces the document's line endings with the native system line endings.
/// </summary>