Skip to content

Commit b358945

Browse files
committed
Downgrade to .NET Standard 2.0 and fix string marshaling
- Change target framework from netstandard2.1 to netstandard2.0 - Replace LPUTF8Str with LPStr marshaling for broader compatibility
1 parent 9b88ee9 commit b358945

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

TypeScriptParser/TypeScriptParser.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
<PropertyGroup>
5-
<TargetFramework>netstandard2.1</TargetFramework>
5+
<TargetFramework>netstandard2.0</TargetFramework>
66
<ImplicitUsings>disable</ImplicitUsings>
77
<Nullable>disable</Nullable>
88
<PackageId>TypeScriptParser</PackageId>

TypeScriptParser/src/binding.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private struct _TSLoggerData
170170
}
171171

172172
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
173-
private delegate void TSLogCallback(IntPtr payload, TSLogType logType, [MarshalAs(UnmanagedType.LPUTF8Str)] string message);
173+
private delegate void TSLogCallback(IntPtr payload, TSLogType logType, [MarshalAs(UnmanagedType.LPStr)] string message);
174174

175175
private class _TSLoggerCode
176176
{
@@ -273,7 +273,7 @@ internal void LogCallback(IntPtr payload, TSLogType logType, string message)
273273
* length in bytes.
274274
*/
275275
[DllImport("tree-sitter", CallingConvention = CallingConvention.Cdecl)]
276-
private static extern IntPtr ts_parser_parse_string(IntPtr parser, IntPtr oldTree, [MarshalAs(UnmanagedType.LPUTF8Str)] string input, uint length);
276+
private static extern IntPtr ts_parser_parse_string(IntPtr parser, IntPtr oldTree, [MarshalAs(UnmanagedType.LPStr)] string input, uint length);
277277

278278
/**
279279
* Use the parser to parse some source code stored in one contiguous buffer.
@@ -643,7 +643,7 @@ public string text(string data) {
643643
* `ts_language_field_id_for_name` function.
644644
*/
645645
[DllImport("tree-sitter", CallingConvention = CallingConvention.Cdecl)]
646-
private static extern TSNode ts_node_child_by_field_name(TSNode self, [MarshalAs(UnmanagedType.LPUTF8Str)] string field_name, uint field_name_length);
646+
private static extern TSNode ts_node_child_by_field_name(TSNode self, [MarshalAs(UnmanagedType.LPStr)] string field_name, uint field_name_length);
647647

648648
/**
649649
* Get the node's child with the given numerical field id.
@@ -933,7 +933,7 @@ public void Dispose()
933933
private static extern IntPtr ts_query_string_value_for_id(IntPtr query, uint id, out uint length);
934934

935935
[DllImport("tree-sitter", CallingConvention = CallingConvention.Cdecl)]
936-
private static extern void ts_query_disable_capture(IntPtr query, [MarshalAs(UnmanagedType.LPUTF8Str)] string captureName, uint captureNameLength);
936+
private static extern void ts_query_disable_capture(IntPtr query, [MarshalAs(UnmanagedType.LPStr)] string captureName, uint captureNameLength);
937937

938938
[DllImport("tree-sitter", CallingConvention = CallingConvention.Cdecl)]
939939
private static extern void ts_query_disable_pattern(IntPtr query, uint patternIndex);
@@ -1102,7 +1102,7 @@ public TSQuery query_new(string source, out uint error_offset, out TSQueryError
11021102
* 2. The type of error is written to the `error_type` parameter.
11031103
*/
11041104
[DllImport("tree-sitter", CallingConvention = CallingConvention.Cdecl)]
1105-
private static extern IntPtr ts_query_new(IntPtr language, [MarshalAs(UnmanagedType.LPUTF8Str)] string source, uint source_len, out uint error_offset, out TSQueryError error_type);
1105+
private static extern IntPtr ts_query_new(IntPtr language, [MarshalAs(UnmanagedType.LPStr)] string source, uint source_len, out uint error_offset, out TSQueryError error_type);
11061106

11071107
/**
11081108
* Get the number of distinct node types in the language.
@@ -1120,7 +1120,7 @@ public TSQuery query_new(string source, out uint error_offset, out TSQueryError
11201120
* Get the numerical id for the given node type string.
11211121
*/
11221122
[DllImport("tree-sitter", CallingConvention = CallingConvention.Cdecl)]
1123-
private static extern ushort ts_language_symbol_for_name(IntPtr language, [MarshalAs(UnmanagedType.LPUTF8Str)] string str, uint length, bool is_named);
1123+
private static extern ushort ts_language_symbol_for_name(IntPtr language, [MarshalAs(UnmanagedType.LPStr)] string str, uint length, bool is_named);
11241124

11251125
/**
11261126
* Get the number of distinct field names in the language.
@@ -1138,7 +1138,7 @@ public TSQuery query_new(string source, out uint error_offset, out TSQueryError
11381138
* Get the numerical id for the given field name string.
11391139
*/
11401140
[DllImport("tree-sitter", CallingConvention = CallingConvention.Cdecl)]
1141-
private static extern ushort ts_language_field_id_for_name(IntPtr language, [MarshalAs(UnmanagedType.LPUTF8Str)] string str, uint length);
1141+
private static extern ushort ts_language_field_id_for_name(IntPtr language, [MarshalAs(UnmanagedType.LPStr)] string str, uint length);
11421142

11431143
/**
11441144
* Check whether the given node type id belongs to named nodes, anonymous nodes,

0 commit comments

Comments
 (0)