Skip to content

Commit d3454af

Browse files
authored
Merge pull request #85 from dex3r/stack_overflow_fix
Fix stack overflow bug in ChatMessageRole
2 parents 166ad6d + 41cc18d commit d3454af

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

OpenAI_API/Chat/ChatMessageRole.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public bool Equals(ChatMessageRole other)
9494
/// Gets the string value for this role to pass to the API
9595
/// </summary>
9696
/// <param name="value">The ChatMessageRole to convert</param>
97-
public static implicit operator String(ChatMessageRole value) { return value; }
97+
public static implicit operator String(ChatMessageRole value) { return value.Value; }
9898

9999
///// <summary>
100100
///// Used during the Json serialization process
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using NUnit.Framework;
2+
using OpenAI_API.Chat;
3+
4+
namespace OpenAI_Tests
5+
{
6+
public class ChatMessageRoleTests
7+
{
8+
[Test]
9+
public void TestImplicitConversionNotThrowing()
10+
{
11+
// ReSharper disable once UnusedVariable
12+
string result = ChatMessageRole.System;
13+
}
14+
15+
[Test]
16+
public void TestImplicitConversionValue()
17+
{
18+
string result = ChatMessageRole.System;
19+
Assert.AreEqual("system", result);
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)