mirror of
https://github.com/tonytins/cstdotnet.git
synced 2026-02-10 12:14:47 -05:00
Update CST class for nullability and debug interop
- Changed preprocessor conditions to use DEBUG instead of NET8_0 for interop methods. - Updated NormalizeEntries and GetEntry methods to accept nullable string parameters. - Bumped project version to 2.1.101-alpha and updated changelog.
This commit is contained in:
parent
89383db3c3
commit
2789562abd
3 changed files with 29 additions and 18 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// This project is licensed under the BSD 3-Clause license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
#if NET8_0
|
||||
#if DEBUG
|
||||
using System.Runtime.InteropServices;
|
||||
#endif
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ public static class CST
|
|||
return GetEntry(entries, key);
|
||||
}
|
||||
|
||||
#if (NET8_0 && DEBUG)
|
||||
#if DEBUG
|
||||
[UnmanagedCallersOnly(EntryPoint = "parse")]
|
||||
public static IntPtr Parse(IntPtr content, IntPtr key)
|
||||
{
|
||||
|
|
@ -39,12 +39,13 @@ public static class CST
|
|||
return Marshal.StringToHGlobalAnsi(GetEntry(entries, Marshal.PtrToStringAnsi(key)));
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Normalizes the content by replacing various newline characters with Environment.NewLine and filters out comments.
|
||||
/// </summary>
|
||||
/// <param name="content">The content to normalize.</param>
|
||||
/// <returns>An enumerable of normalized lines.</returns>
|
||||
public static IEnumerable<string> NormalizeEntries(string content)
|
||||
static IEnumerable<string> NormalizeEntries(string? content)
|
||||
{
|
||||
var newLines = new[] { LF, CR, CRLF, LS };
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ public static class CST
|
|||
/// <param name="entries">The entries to search through.</param>
|
||||
/// <param name="key">The key to search for.</param>
|
||||
/// <returns>The value for the specified key, or a default string if not found.</returns>
|
||||
static string GetEntry(IEnumerable<string> entries, string key)
|
||||
static string GetEntry(IEnumerable<string> entries, string? key)
|
||||
{
|
||||
// Iterate through the entries.
|
||||
foreach (var entry in entries)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
||||
<Version>2.2.100-alpha</Version>
|
||||
<Version>2.1.101-alpha</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue