Skip to content

Commit

Permalink
Corrected return type MagickNET.GetEnvironmentVariable to a nullable …
Browse files Browse the repository at this point in the history
…string.
  • Loading branch information
dlemstra committed Nov 12, 2023
1 parent 9f47216 commit 4dabd6d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Magick.NET/Helpers/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void Initialize()
}
}

public static string GetEnv(string name)
public static string? GetEnv(string name)
=> NativeEnvironment.GetEnv(name);

public static void SetEnv(string name, string value)
Expand Down
2 changes: 1 addition & 1 deletion src/Magick.NET/MagickNET.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ string IMagickNET.Version
/// </summary>
/// <param name="name">The name of the environment variable.</param>
/// <returns>The environment variable with the specified name.</returns>
public static string GetEnvironmentVariable(string name)
public static string? GetEnvironmentVariable(string name)
{
Throw.IfNullOrEmpty(nameof(name), name);
return Environment.GetEnv(name);
Expand Down
4 changes: 2 additions & 2 deletions src/Magick.NET/Native/Helpers/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void Initialize()
NativeMethods.X86.Environment_Initialize();
#endif
}
public static string GetEnv(string name)
public static string? GetEnv(string name)
{
using var nameNative = UTF8Marshaler.CreateInstance(name);
IntPtr result;
Expand All @@ -93,7 +93,7 @@ public static string GetEnv(string name)
#if PLATFORM_x86 || PLATFORM_AnyCPU
result = NativeMethods.X86.Environment_GetEnv(nameNative.Instance);
#endif
return UTF8Marshaler.NativeToManaged(result);
return UTF8Marshaler.NativeToManagedAndRelinquish(result);
}
public static void SetEnv(string name, string value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Magick.NET/Native/Helpers/Environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
{
"name": "GetEnv",
"type": "string",
"type": "nativeString?",
"arguments": [
{
"name": "name",
Expand Down

0 comments on commit 4dabd6d

Please sign in to comment.