Skip to content

Commit 87c6b87

Browse files
authored
Updated OpenAI dependency. (#38)
* Update dependencies. * Update OpenAI to 2.4.0 and refresh vector store extensions (#33) * Update dependencies. * Update OpenAI package and vector store extensions * Updated test AGENTS.md * Removed compiler directives. * Remove obsolete NET conditional directives (#34) * Update OpenAI extensions for 2.5.0 (#35) * Add conversation extensions for OpenAI 2.6 (#36) * Upgrade OpenAI dependency (#37) * Updated OpenAI version.
1 parent 6d339a8 commit 87c6b87

File tree

23 files changed

+935
-2148
lines changed

23 files changed

+935
-2148
lines changed

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Always verify your changes by running the same steps as CI:
2222
dotnet build --configuration Release --no-restore
2323

2424
# Run tests (targeting .NET 8)
25-
dotnet test --configuration Release --no-build --verbosity normal --framework net8.0
25+
dotnet test --configuration Release --no-build --verbosity normal --framework net10.0
2626
```
2727

2828
The solution targets multiple frameworks (net8.0–net10.0). Make sure all target frameworks compile.

docfx/docs/openai.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# OpenAI
22

3-
4-
Provides a extension methods that wrap all OpenAI operations using LightResults.
3+
Provides extension methods that wrap all OpenAI operations using LightResults.
54

65
### Chat Completions example
76

src/LightResults.Extensions.EntityFrameworkCore/LightResults.Extensions.EntityFrameworkCore.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
<!-- References -->
1919
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
20-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.18"/>
20+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.22"/>
2121
</ItemGroup>
2222

2323
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
24-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7"/>
24+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11"/>
2525
</ItemGroup>
2626

2727
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">

src/LightResults.Extensions.ExceptionHandling/EnumerableExtensions.cs

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
1-
#if NET7_0_OR_GREATER
21
using System.Diagnostics;
3-
#endif
4-
#if NET6_0_OR_GREATER
52
using System.Runtime.CompilerServices;
6-
#endif
73

84
namespace LightResults.Extensions.ExceptionHandling;
95

10-
11-
#if NET6_0_OR_GREATER
126
/// <summary>
137
/// Provides extension methods for <see cref="IEnumerable{T}"/> and <see cref="IAsyncEnumerable{T}"/>
148
/// that wrap enumeration in <see cref="Result{T}"/> to capture exceptions as failed results.
159
/// </summary>
16-
#else
17-
/// <summary>
18-
/// Provides extension methods for <see cref="IEnumerable{T}"/>
19-
/// that wrap enumeration in <see cref="Result{T}"/> to capture exceptions as failed results.
20-
/// </summary>
21-
#endif
2210
public static class EnumerableExtensions
2311
{
24-
#if NET7_0_OR_GREATER
2512
/// <summary>
2613
/// Enumerates the elements of the sequence, wrapping each element in a <see cref="Result{T}"/>.
2714
/// If an exception occurs during enumeration, yields a failed <see cref="Result{T}"/> containing the exception.
@@ -34,28 +21,9 @@ public static class EnumerableExtensions
3421
/// </returns>
3522
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <c>null</c>.</exception>
3623
/// <exception cref="UnreachableException">The enumerator could not be obtained from <paramref name="source"/>.</exception>
37-
#else
38-
/// <summary>
39-
/// Enumerates the elements of the sequence, wrapping each element in a <see cref="Result{T}"/>.
40-
/// If an exception occurs during enumeration, yields a failed <see cref="Result{T}"/> containing the exception.
41-
/// </summary>
42-
/// <typeparam name="T">The type of the elements of <paramref name="source"/>.</typeparam>
43-
/// <param name="source">The sequence to enumerate.</param>
44-
/// <returns>
45-
/// An <see cref="IEnumerable{T}"/> of <see cref="Result{T}"/> objects, where each successful result contains
46-
/// an item from <paramref name="source"/>, or a failure result contains the exception thrown during enumeration.
47-
/// </returns>
48-
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <c>null</c>.</exception>
49-
/// <exception cref="InvalidOperationException">The enumerator could not be obtained from <paramref name="source"/>.</exception>
50-
#endif
5124
public static IEnumerable<Result<T>> AsEnumerableResult<T>(this IEnumerable<T> source)
5225
{
53-
#if NET6_0_OR_GREATER
5426
ArgumentNullException.ThrowIfNull(source);
55-
#else
56-
if (source is null)
57-
throw new ArgumentNullException(nameof(source));
58-
#endif
5927

6028
Exception? exception = null;
6129

@@ -77,11 +45,7 @@ public static IEnumerable<Result<T>> AsEnumerableResult<T>(this IEnumerable<T> s
7745
}
7846

7947
if (enumerator is null)
80-
#if NET7_0_OR_GREATER
8148
throw new UnreachableException("The enumerator was unexpectedly null.");
82-
#else
83-
throw new InvalidOperationException("The enumerator was unexpectedly null.");
84-
#endif
8549

8650
var hasMoreItems = true;
8751

@@ -129,8 +93,6 @@ public static IEnumerable<Result<T>> AsEnumerableResult<T>(this IEnumerable<T> s
12993
}
13094
}
13195

132-
#if NET6_0_OR_GREATER
133-
#if NET7_0_OR_GREATER
13496
/// <summary>
13597
/// Asynchronously enumerates the elements of the sequence, wrapping each element in a <see cref="Result{T}"/>.
13698
/// If an exception occurs during asynchronous enumeration, yields a failed <see cref="Result{T}"/> containing the exception.
@@ -144,21 +106,6 @@ public static IEnumerable<Result<T>> AsEnumerableResult<T>(this IEnumerable<T> s
144106
/// </returns>
145107
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <c>null</c>.</exception>
146108
/// <exception cref="UnreachableException">The asynchronous enumerator could not be obtained from <paramref name="source"/>.</exception>
147-
#else
148-
/// <summary>
149-
/// Asynchronously enumerates the elements of the sequence, wrapping each element in a <see cref="Result{T}"/>.
150-
/// If an exception occurs during asynchronous enumeration, yields a failed <see cref="Result{T}"/> containing the exception.
151-
/// </summary>
152-
/// <typeparam name="T">The type of the elements of <paramref name="source"/>.</typeparam>
153-
/// <param name="source">The asynchronous sequence to enumerate.</param>
154-
/// <param name="cancellationToken">A cancellation token that can be used to cancel the asynchronous enumeration.</param>
155-
/// <returns>
156-
/// An <see cref="IAsyncEnumerable{T}"/> of <see cref="Result{T}"/> objects, where each successful result contains
157-
/// an item from <paramref name="source"/>, or a failure result contains the exception thrown during asynchronous enumeration.
158-
/// </returns>
159-
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <c>null</c>.</exception>
160-
/// <exception cref="InvalidOperationException">The asynchronous enumerator could not be obtained from <paramref name="source"/>.</exception>
161-
#endif
162109
public static async IAsyncEnumerable<Result<T>> AsAsyncEnumerableResult<T>(
163110
this IAsyncEnumerable<T> source,
164111
[EnumeratorCancellation] CancellationToken cancellationToken = default
@@ -188,11 +135,7 @@ await enumerator.DisposeAsync()
188135
}
189136

190137
if (enumerator is null)
191-
#if NET7_0_OR_GREATER
192138
throw new UnreachableException("The enumerator was unexpectedly null.");
193-
#else
194-
throw new InvalidOperationException("The enumerator was unexpectedly null.");
195-
#endif
196139

197140
var hasMoreItems = true;
198141

@@ -242,5 +185,4 @@ await enumerator.DisposeAsync()
242185
yield return Result.Success(current);
243186
}
244187
}
245-
#endif
246188
}

src/LightResults.Extensions.Json/ResultJsonConverterFactory.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
#if NET7_0_OR_GREATER
21
using System.Diagnostics.CodeAnalysis;
3-
#endif
42
using System.Text.Json;
53
using System.Text.Json.Serialization;
64

75
namespace LightResults.Extensions.Json;
86

97
/// <summary>JsonConverterFactory for converting Result types to and from JSON.</summary>
10-
#if NET7_0_OR_GREATER
118
[RequiresDynamicCode("The native code for this instantiation might not be available at runtime.")]
12-
[RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can\'t validate that the requirements of those annotations are met.")]
13-
#endif
9+
[RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")]
1410
public class ResultJsonConverterFactory : JsonConverterFactory
1511
{
1612
/// <inheritdoc/>

0 commit comments

Comments
 (0)