diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props
index 0f45264e4068..778772adb36e 100644
--- a/dotnet/Directory.Packages.props
+++ b/dotnet/Directory.Packages.props
@@ -34,7 +34,7 @@
-
+
diff --git a/dotnet/src/Connectors/Connectors.AzureAISearch.UnitTests/Connectors.AzureAISearch.UnitTests.csproj b/dotnet/src/Connectors/Connectors.AzureAISearch.UnitTests/Connectors.AzureAISearch.UnitTests.csproj
index 8583008891e7..9c1e99f7b21a 100644
--- a/dotnet/src/Connectors/Connectors.AzureAISearch.UnitTests/Connectors.AzureAISearch.UnitTests.csproj
+++ b/dotnet/src/Connectors/Connectors.AzureAISearch.UnitTests/Connectors.AzureAISearch.UnitTests.csproj
@@ -3,7 +3,7 @@
SemanticKernel.Connectors.AzureAISearch.UnitTests
SemanticKernel.Connectors.AzureAISearch.UnitTests
- net8.0
+ net8.0;net462
true
enable
disable
diff --git a/dotnet/src/Connectors/Connectors.Google.UnitTests/Connectors.Google.UnitTests.csproj b/dotnet/src/Connectors/Connectors.Google.UnitTests/Connectors.Google.UnitTests.csproj
index adff4d81e1b0..1219c2fdfc45 100644
--- a/dotnet/src/Connectors/Connectors.Google.UnitTests/Connectors.Google.UnitTests.csproj
+++ b/dotnet/src/Connectors/Connectors.Google.UnitTests/Connectors.Google.UnitTests.csproj
@@ -3,7 +3,7 @@
SemanticKernel.Connectors.GoogleVertexAI.UnitTests
SemanticKernel.Connectors.GoogleVertexAI.UnitTests
- net8.0
+ net8.0;net462
true
enable
disable
diff --git a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/AuthorRoleConverterTests.cs b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/AuthorRoleConverterTests.cs
index 03005b4fd01f..2502024715bc 100644
--- a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/AuthorRoleConverterTests.cs
+++ b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/AuthorRoleConverterTests.cs
@@ -2,6 +2,7 @@
using System;
using System.Buffers;
+using System.IO;
using System.Text.Json;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.Google.Core;
@@ -94,14 +95,15 @@ public void WriteWhenRoleIsUserReturnsUser()
{
// Arrange
var converter = new AuthorRoleConverter();
- var bufferWriter = new ArrayBufferWriter();
- using var writer = new Utf8JsonWriter(bufferWriter);
+ var stream = new MemoryStream();
+ using var writer = new Utf8JsonWriter(stream);
// Act
converter.Write(writer, AuthorRole.User, JsonSerializerOptions.Default);
+ writer.Flush();
// Assert
- Assert.Equal("\"user\""u8, bufferWriter.GetSpan().Trim((byte)'\0'));
+ Assert.Equal("\"user\""u8.ToArray(), stream.ToArray());
}
[Fact]
@@ -109,14 +111,15 @@ public void WriteWhenRoleIsAssistantReturnsModel()
{
// Arrange
var converter = new AuthorRoleConverter();
- var bufferWriter = new ArrayBufferWriter();
- using var writer = new Utf8JsonWriter(bufferWriter);
+ var stream = new MemoryStream();
+ using var writer = new Utf8JsonWriter(stream);
// Act
converter.Write(writer, AuthorRole.Assistant, JsonSerializerOptions.Default);
+ writer.Flush();
// Assert
- Assert.Equal("\"model\""u8, bufferWriter.GetSpan().Trim((byte)'\0'));
+ Assert.Equal("\"model\""u8.ToArray(), stream.ToArray());
}
[Fact]
@@ -124,14 +127,15 @@ public void WriteWhenRoleIsToolReturnsFunction()
{
// Arrange
var converter = new AuthorRoleConverter();
- var bufferWriter = new ArrayBufferWriter();
- using var writer = new Utf8JsonWriter(bufferWriter);
+ var stream = new MemoryStream();
+ using var writer = new Utf8JsonWriter(stream);
// Act
converter.Write(writer, AuthorRole.Tool, JsonSerializerOptions.Default);
+ writer.Flush();
// Assert
- Assert.Equal("\"function\""u8, bufferWriter.GetSpan().Trim((byte)'\0'));
+ Assert.Equal("\"function\""u8.ToArray(), stream.ToArray());
}
[Fact]
@@ -139,14 +143,15 @@ public void WriteWhenRoleIsNullReturnsNull()
{
// Arrange
var converter = new AuthorRoleConverter();
- var bufferWriter = new ArrayBufferWriter();
- using var writer = new Utf8JsonWriter(bufferWriter);
+ var stream = new MemoryStream();
+ using var writer = new Utf8JsonWriter(stream);
// Act
converter.Write(writer, null, JsonSerializerOptions.Default);
+ writer.Flush();
// Assert
- Assert.Equal("null"u8, bufferWriter.GetSpan().Trim((byte)'\0'));
+ Assert.Equal("null"u8.ToArray(), stream.ToArray());
}
[Fact]
@@ -154,7 +159,8 @@ public void WriteWhenRoleIsNotUserOrAssistantOrToolThrows()
{
// Arrange
var converter = new AuthorRoleConverter();
- using var writer = new Utf8JsonWriter(new ArrayBufferWriter());
+ var stream = new MemoryStream();
+ using var writer = new Utf8JsonWriter(stream);
// Act
void Act()
diff --git a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatGenerationFunctionCallingTests.cs b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatGenerationFunctionCallingTests.cs
index fdf70b8182bf..0d0abf19effc 100644
--- a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatGenerationFunctionCallingTests.cs
+++ b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatGenerationFunctionCallingTests.cs
@@ -32,7 +32,7 @@ public GeminiChatGenerationFunctionCallingTests()
{
this._responseContent = File.ReadAllText(ChatTestDataFilePath);
this._responseContentWithFunction = File.ReadAllText(ChatTestDataWithFunctionFilePath)
- .Replace("%nameSeparator%", GeminiFunction.NameSeparator, StringComparison.Ordinal);
+ .Replace("%nameSeparator%", GeminiFunction.NameSeparator);
this._messageHandlerStub = new HttpMessageHandlerStub();
this._messageHandlerStub.ResponseToReturn.Content = new StringContent(
this._responseContent);
diff --git a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatGenerationTests.cs b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatGenerationTests.cs
index c8ede07ebb5d..d4f54304f801 100644
--- a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatGenerationTests.cs
+++ b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatGenerationTests.cs
@@ -71,7 +71,7 @@ public async Task ShouldContainRolesInRequestAsync()
{
// Arrange
this._messageHandlerStub.ResponseToReturn.Content = new StringContent(
- await File.ReadAllTextAsync(ChatTestDataFilePath));
+ File.ReadAllText(ChatTestDataFilePath));
var client = this.CreateChatCompletionClient();
var chatHistory = CreateSampleChatHistory();
@@ -115,7 +115,7 @@ public async Task ShouldReturnValidGeminiMetadataAsync()
// Assert
GeminiResponse testDataResponse = JsonSerializer.Deserialize(
- await File.ReadAllTextAsync(ChatTestDataFilePath))!;
+ File.ReadAllText(ChatTestDataFilePath))!;
var testDataCandidate = testDataResponse.Candidates![0];
var textContent = chatMessageContents.SingleOrDefault();
Assert.NotNull(textContent);
@@ -160,7 +160,7 @@ public async Task ShouldReturnValidDictionaryMetadataAsync()
// Assert
GeminiResponse testDataResponse = JsonSerializer.Deserialize(
- await File.ReadAllTextAsync(ChatTestDataFilePath))!;
+ File.ReadAllText(ChatTestDataFilePath))!;
var testDataCandidate = testDataResponse.Candidates![0];
var textContent = chatMessageContents.SingleOrDefault();
Assert.NotNull(textContent);
diff --git a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatStreamingFunctionCallingTests.cs b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatStreamingFunctionCallingTests.cs
index 71e6ebc41a23..782049a980fb 100644
--- a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatStreamingFunctionCallingTests.cs
+++ b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatStreamingFunctionCallingTests.cs
@@ -32,7 +32,7 @@ public GeminiChatStreamingFunctionCallingTests()
{
this._responseContent = File.ReadAllText(ChatTestDataFilePath);
this._responseContentWithFunction = File.ReadAllText(ChatTestDataWithFunctionFilePath)
- .Replace("%nameSeparator%", GeminiFunction.NameSeparator, StringComparison.Ordinal);
+ .Replace("%nameSeparator%", GeminiFunction.NameSeparator);
this._messageHandlerStub = new HttpMessageHandlerStub();
this._messageHandlerStub.ResponseToReturn.Content = new StringContent(
this._responseContent);
diff --git a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatStreamingTests.cs b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatStreamingTests.cs
index c8802dd58c83..ef72bbc8e947 100644
--- a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatStreamingTests.cs
+++ b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatStreamingTests.cs
@@ -100,7 +100,7 @@ public async Task ShouldReturnValidChatResponseAsync()
// Assert
List testDataResponse = JsonSerializer.Deserialize>(
- await File.ReadAllTextAsync(StreamTestDataFilePath))!;
+ File.ReadAllText(StreamTestDataFilePath))!;
Assert.NotEmpty(chatMessageContents);
Assert.Equal(testDataResponse.Count, chatMessageContents.Count);
@@ -128,7 +128,7 @@ public async Task ShouldReturnValidGeminiMetadataAsync()
// Assert
GeminiResponse testDataResponse = JsonSerializer.Deserialize>(
- await File.ReadAllTextAsync(StreamTestDataFilePath))![0];
+ File.ReadAllText(StreamTestDataFilePath))![0];
var testDataCandidate = testDataResponse.Candidates![0];
var textContent = chatMessageContents.FirstOrDefault();
Assert.NotNull(textContent);
@@ -174,7 +174,7 @@ public async Task ShouldReturnValidDictionaryMetadataAsync()
// Assert
GeminiResponse testDataResponse = JsonSerializer.Deserialize>(
- await File.ReadAllTextAsync(StreamTestDataFilePath))![0];
+ File.ReadAllText(StreamTestDataFilePath))![0];
var testDataCandidate = testDataResponse.Candidates![0];
var textContent = chatMessageContents.FirstOrDefault();
Assert.NotNull(textContent);
diff --git a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/GeminiRequestTests.cs b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/GeminiRequestTests.cs
index daeac8d69f1b..cacad61d262c 100644
--- a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/GeminiRequestTests.cs
+++ b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/GeminiRequestTests.cs
@@ -215,7 +215,7 @@ public void FromChatHistoryCalledToolNotNullAddsFunctionResponse()
{
// Arrange
ChatHistory chatHistory = [];
- var kvp = KeyValuePair.Create("sampleKey", "sampleValue");
+ var kvp = new KeyValuePair("sampleKey", "sampleValue");
var expectedArgs = new JsonObject { [kvp.Key] = kvp.Value };
var kernelFunction = KernelFunctionFactory.CreateFromMethod(() => "");
var toolCall = new GeminiFunctionToolCall(new GeminiPart.FunctionCallPart { FunctionName = "function-name" });
@@ -242,7 +242,7 @@ public void FromChatHistoryToolCallsNotNullAddsFunctionCalls()
{
// Arrange
ChatHistory chatHistory = [];
- var kvp = KeyValuePair.Create("sampleKey", "sampleValue");
+ var kvp = new KeyValuePair("sampleKey", "sampleValue");
var expectedArgs = new JsonObject { [kvp.Key] = kvp.Value };
var toolCallPart = new GeminiPart.FunctionCallPart
{ FunctionName = "function-name", Arguments = expectedArgs };
diff --git a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/GeminiStreamResponseTests.cs b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/GeminiStreamResponseTests.cs
index 52310c29139a..974cda3a9a87 100644
--- a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/GeminiStreamResponseTests.cs
+++ b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/GeminiStreamResponseTests.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.SemanticKernel.Connectors.Google.Core;
@@ -27,7 +28,7 @@ public async Task SerializationShouldPopulateAllPropertiesAsync()
// Arrange
var parser = new StreamJsonParser();
var stream = new MemoryStream();
- var streamExample = await File.ReadAllTextAsync(StreamTestDataFilePath);
+ var streamExample = File.ReadAllText(StreamTestDataFilePath);
var sampleResponses = JsonSerializer.Deserialize>(streamExample)!;
WriteToStream(stream, streamExample);
@@ -43,7 +44,7 @@ public async Task SerializationShouldPopulateAllPropertiesAsync()
private static void WriteToStream(Stream stream, string input)
{
- using var writer = new StreamWriter(stream, leaveOpen: true);
+ using var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 0x1000, leaveOpen: true);
writer.Write(input);
writer.Flush();
stream.Position = 0;
diff --git a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/GoogleAI/GoogleAIClientEmbeddingsGenerationTests.cs b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/GoogleAI/GoogleAIClientEmbeddingsGenerationTests.cs
index 36b91707641a..a5555eda191b 100644
--- a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/GoogleAI/GoogleAIClientEmbeddingsGenerationTests.cs
+++ b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/GoogleAI/GoogleAIClientEmbeddingsGenerationTests.cs
@@ -87,12 +87,11 @@ public async Task ShouldReturnValidEmbeddingsResponseAsync()
var embeddings = await client.GenerateEmbeddingsAsync(dataToEmbed);
// Assert
- GoogleAIEmbeddingResponse testDataResponse = JsonSerializer.Deserialize(
- await File.ReadAllTextAsync(TestDataFilePath))!;
+ GoogleAIEmbeddingResponse testDataResponse = JsonSerializer.Deserialize(File.ReadAllText(TestDataFilePath))!;
Assert.NotNull(embeddings);
Assert.Collection(embeddings,
- values => Assert.Equal(testDataResponse.Embeddings[0].Values, values),
- values => Assert.Equal(testDataResponse.Embeddings[1].Values, values));
+ values => Assert.Equal(testDataResponse.Embeddings[0].Values.ToArray(), values.ToArray()),
+ values => Assert.Equal(testDataResponse.Embeddings[1].Values.ToArray(), values.ToArray()));
}
[Fact]
diff --git a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/VertexAI/VertexAIClientEmbeddingsGenerationTests.cs b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/VertexAI/VertexAIClientEmbeddingsGenerationTests.cs
index b30e80bf2f05..4faf3fe0eb24 100644
--- a/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/VertexAI/VertexAIClientEmbeddingsGenerationTests.cs
+++ b/dotnet/src/Connectors/Connectors.Google.UnitTests/Core/VertexAI/VertexAIClientEmbeddingsGenerationTests.cs
@@ -64,12 +64,11 @@ public async Task ShouldReturnValidEmbeddingsResponseAsync()
var embeddings = await client.GenerateEmbeddingsAsync(dataToEmbed);
// Assert
- VertexAIEmbeddingResponse testDataResponse = JsonSerializer.Deserialize(
- await File.ReadAllTextAsync(TestDataFilePath))!;
+ VertexAIEmbeddingResponse testDataResponse = JsonSerializer.Deserialize(File.ReadAllText(TestDataFilePath))!;
Assert.NotNull(embeddings);
Assert.Collection(embeddings,
- values => Assert.Equal(testDataResponse.Predictions[0].Embeddings.Values, values),
- values => Assert.Equal(testDataResponse.Predictions[1].Embeddings.Values, values));
+ values => Assert.Equal(testDataResponse.Predictions[0].Embeddings.Values.ToArray(), values.ToArray()),
+ values => Assert.Equal(testDataResponse.Predictions[1].Embeddings.Values.ToArray(), values.ToArray()));
}
[Fact]
diff --git a/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/Connectors.HuggingFace.UnitTests.csproj b/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/Connectors.HuggingFace.UnitTests.csproj
index e18ab809dacc..a1649fdaef89 100644
--- a/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/Connectors.HuggingFace.UnitTests.csproj
+++ b/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/Connectors.HuggingFace.UnitTests.csproj
@@ -3,7 +3,7 @@
SemanticKernel.Connectors.HuggingFace.UnitTests
SemanticKernel.Connectors.HuggingFace.UnitTests
- net8.0
+ net8.0;net462
true
enable
disable
diff --git a/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/MultipleHttpMessageHandlerStub.cs b/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/MultipleHttpMessageHandlerStub.cs
index db17392da423..004425b274d2 100644
--- a/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/MultipleHttpMessageHandlerStub.cs
+++ b/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/MultipleHttpMessageHandlerStub.cs
@@ -9,7 +9,7 @@
namespace SemanticKernel.Connectors.HuggingFace.UnitTests;
-#pragma warning disable CA1812
+#pragma warning disable CA1812, CA2016
internal sealed class MultipleHttpMessageHandlerStub : DelegatingHandler
{
@@ -36,7 +36,7 @@ protected override async Task SendAsync(HttpRequestMessage
this.RequestHeaders.Add(request.Headers);
this.ContentHeaders.Add(request.Content?.Headers);
- var content = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync(cancellationToken);
+ var content = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync();
this.RequestContents.Add(content);
diff --git a/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/Services/HuggingFaceImageToTextTests.cs b/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/Services/HuggingFaceImageToTextTests.cs
index 2fe5b5b34d77..ff869f6192a8 100644
--- a/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/Services/HuggingFaceImageToTextTests.cs
+++ b/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/Services/HuggingFaceImageToTextTests.cs
@@ -163,7 +163,7 @@ public async Task ShouldSendPromptToServiceAsync()
var requestPayload = this._messageHandlerStub.RequestContent;
Assert.NotNull(requestPayload);
- Assert.Equal(this._imageContentInput.Data!.Value.Span, requestPayload);
+ Assert.Equal(this._imageContentInput.Data!.Value.ToArray(), requestPayload);
}
[Fact]
diff --git a/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/TextGeneration/TextGenerationStreamResponseTests.cs b/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/TextGeneration/TextGenerationStreamResponseTests.cs
index 8fc076af9f9c..389cdb04fb17 100644
--- a/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/TextGeneration/TextGenerationStreamResponseTests.cs
+++ b/dotnet/src/Connectors/Connectors.HuggingFace.UnitTests/TextGeneration/TextGenerationStreamResponseTests.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
+using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.SemanticKernel.Connectors.HuggingFace.Core;
@@ -75,7 +76,7 @@ public async Task SerializationShouldPopulateAllPropertiesAsync()
private static void WriteToStream(Stream stream, string input)
{
- using var writer = new StreamWriter(stream, leaveOpen: true);
+ using var writer = new StreamWriter(stream, Encoding.UTF8, 0x1000, leaveOpen: true);
writer.Write(input);
writer.Flush();
stream.Position = 0;
diff --git a/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/Client/MistralClientTests.cs b/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/Client/MistralClientTests.cs
index cbafeddc3f4e..a832e9f86cc2 100644
--- a/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/Client/MistralClientTests.cs
+++ b/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/Client/MistralClientTests.cs
@@ -477,7 +477,7 @@ public class WidgetFactory
[Description("Creates a new widget of the specified type and colors")]
public string CreateWidget([Description("The colors of the widget to be created")] WidgetColor[] widgetColors)
{
- var colors = string.Join('-', widgetColors.Select(c => c.GetDisplayName()).ToArray());
+ var colors = string.Join("-", widgetColors.Select(c => c.GetDisplayName()).ToArray());
return $"Widget created with colors: {colors}";
}
}
diff --git a/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/Connectors.MistralAI.UnitTests.csproj b/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/Connectors.MistralAI.UnitTests.csproj
index 945210beed7e..2e950a8a6e2f 100644
--- a/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/Connectors.MistralAI.UnitTests.csproj
+++ b/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/Connectors.MistralAI.UnitTests.csproj
@@ -3,7 +3,7 @@
SemanticKernel.Connectors.MistralAI.UnitTests
SemanticKernel.Connectors.MistralAI.UnitTests
- net8.0
+ net8.0;net462
12
LatestMajor
true
diff --git a/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/MistralTestBase.cs b/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/MistralTestBase.cs
index d29adbe59ac6..f3cc94eff662 100644
--- a/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/MistralTestBase.cs
+++ b/dotnet/src/Connectors/Connectors.MistralAI.UnitTests/MistralTestBase.cs
@@ -11,6 +11,9 @@
using Xunit;
namespace SemanticKernel.Connectors.MistralAI.UnitTests;
+
+#pragma warning disable CA2016
+
public abstract class MistralTestBase : IDisposable
{
protected AssertingDelegatingHandler? DelegatingHandler { get; set; }
@@ -94,7 +97,7 @@ protected override async Task SendAsync(HttpRequestMessage
Assert.Equal(this.Method, request.Method);
Assert.Equal(this.RequestHeaders, request.Headers);
- this.RequestContent = await request.Content!.ReadAsStringAsync(cancellationToken);
+ this.RequestContent = await request.Content!.ReadAsStringAsync();
if (this._responseStringArray is not null)
{
diff --git a/dotnet/src/Connectors/Connectors.Onnx.UnitTests/Connectors.Onnx.UnitTests.csproj b/dotnet/src/Connectors/Connectors.Onnx.UnitTests/Connectors.Onnx.UnitTests.csproj
index 6333d7dd4322..6531794a0c81 100644
--- a/dotnet/src/Connectors/Connectors.Onnx.UnitTests/Connectors.Onnx.UnitTests.csproj
+++ b/dotnet/src/Connectors/Connectors.Onnx.UnitTests/Connectors.Onnx.UnitTests.csproj
@@ -3,7 +3,7 @@
SemanticKernel.Connectors.Onnx.UnitTests
SemanticKernel.Connectors.Onnx.UnitTests
- net8.0
+ net8.0;net462
true
enable
false
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/Connectors.UnitTests.csproj b/dotnet/src/Connectors/Connectors.UnitTests/Connectors.UnitTests.csproj
index 455206f5ce04..5c2f20e2f358 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/Connectors.UnitTests.csproj
+++ b/dotnet/src/Connectors/Connectors.UnitTests/Connectors.UnitTests.csproj
@@ -3,7 +3,7 @@
SemanticKernel.Connectors.UnitTests
SemanticKernel.Connectors.UnitTests
- net8.0
+ net8.0;net462
true
enable
disable
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/Memory/DuckDB/DuckDBMemoryStoreTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/Memory/DuckDB/DuckDBMemoryStoreTests.cs
index d7d33ed00001..a55dfe063232 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/Memory/DuckDB/DuckDBMemoryStoreTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/Memory/DuckDB/DuckDBMemoryStoreTests.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+#if NET // TODO: Tests fail with "Unable to load DLL 'duckdb': The specified module could not be found." on .NET Framework
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
@@ -38,7 +39,7 @@ private IEnumerable CreateBatchRecords(int numRecords)
text: "text" + i,
description: "description" + i,
embedding: new float[] { 1, 1, 1 });
- records = records.Append(testRecord);
+ records = records.Concat([testRecord]);
}
for (int i = numRecords / 2; i < numRecords; i++)
@@ -48,7 +49,7 @@ private IEnumerable CreateBatchRecords(int numRecords)
sourceName: "sourceName" + i,
description: "description" + i,
embedding: new float[] { 1, 2, 3 });
- records = records.Append(testRecord);
+ records = records.Concat([testRecord]);
}
return records;
@@ -650,3 +651,4 @@ public async Task DeletingNonExistentCollectionDoesNothingAsync()
await db.DeleteCollectionAsync(collection);
}
}
+#endif
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Pinecone/PineconeMemoryBuilderExtensionsTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Pinecone/PineconeMemoryBuilderExtensionsTests.cs
index d8e5b0ceb8fb..2815a1608fbf 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Pinecone/PineconeMemoryBuilderExtensionsTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Pinecone/PineconeMemoryBuilderExtensionsTests.cs
@@ -31,7 +31,7 @@ public async Task PineconeMemoryStoreShouldBeProperlyInitializedAsync()
{
// Arrange
var embeddingGenerationMock = Mock.Of();
- this._messageHandlerStub.ResponseToReturn.Content = new StringContent("""["fake-index1"]""", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._messageHandlerStub.ResponseToReturn.Content = new StringContent("""["fake-index1"]""", Encoding.UTF8, "application/json");
var builder = new MemoryBuilder();
builder.WithPineconeMemoryStore("fake-environment", "fake-api-key", this._httpClient);
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Qdrant/QdrantMemoryBuilderExtensionsTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Qdrant/QdrantMemoryBuilderExtensionsTests.cs
index 8d43f12d8983..445ebf0315ee 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Qdrant/QdrantMemoryBuilderExtensionsTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Qdrant/QdrantMemoryBuilderExtensionsTests.cs
@@ -32,7 +32,7 @@ public async Task QdrantMemoryStoreShouldBeProperlyInitializedAsync()
var embeddingGenerationMock = Mock.Of();
this._httpClient.BaseAddress = new Uri("https://fake-random-qdrant-host");
- this._messageHandlerStub.ResponseToReturn.Content = new StringContent("""{"result":{"collections":[]}}""", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._messageHandlerStub.ResponseToReturn.Content = new StringContent("""{"result":{"collections":[]}}""", Encoding.UTF8, "application/json");
var builder = new MemoryBuilder();
builder.WithQdrantMemoryStore(this._httpClient, 123);
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Redis/RedisMemoryStoreTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Redis/RedisMemoryStoreTests.cs
index 53f41384171d..7e65f5c183e7 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Redis/RedisMemoryStoreTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Redis/RedisMemoryStoreTests.cs
@@ -771,7 +771,10 @@ private void MockCreateIndex(string collection, Action? callback = null)
.ReturnsAsync(RedisResult.Create("OK", ResultType.SimpleString))
.Callback(() =>
{
- this._collections.TryAdd(collection, []);
+ if (!this._collections.ContainsKey(collection))
+ {
+ this._collections.Add(collection, []);
+ }
this._mockDatabase
.Setup>(x => x.ExecuteAsync(
@@ -972,7 +975,7 @@ private IEnumerable CreateBatchRecords(int numRecords)
text: "text" + i,
description: "description" + i,
embedding: new float[] { 1, 1, 1 });
- records = records.Append(testRecord);
+ records = records.Concat([testRecord]);
}
for (int i = numRecords / 2; i < numRecords; i++)
@@ -982,7 +985,7 @@ private IEnumerable CreateBatchRecords(int numRecords)
sourceName: "sourceName" + i,
description: "description" + i,
embedding: new float[] { 1, 2, 3 });
- records = records.Append(testRecord);
+ records = records.Concat([testRecord]);
}
return records;
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Sqlite/SqliteMemoryStoreTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Sqlite/SqliteMemoryStoreTests.cs
index e91a1794d2a8..0589c263c0b4 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Sqlite/SqliteMemoryStoreTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Sqlite/SqliteMemoryStoreTests.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+#if NET // TODO: Tests fail with "Library e_sqlite3 not found" on .NET Framework
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
@@ -56,7 +57,7 @@ private IEnumerable CreateBatchRecords(int numRecords)
text: "text" + i,
description: "description" + i,
embedding: new float[] { 1, 1, 1 });
- records = records.Append(testRecord);
+ records = records.Concat([testRecord]);
}
for (int i = numRecords / 2; i < numRecords; i++)
@@ -66,7 +67,7 @@ private IEnumerable CreateBatchRecords(int numRecords)
sourceName: "sourceName" + i,
description: "description" + i,
embedding: new float[] { 1, 2, 3 });
- records = records.Append(testRecord);
+ records = records.Concat([testRecord]);
}
return records;
@@ -678,3 +679,4 @@ public async Task DeletingNonExistentCollectionDoesNothingAsync()
await db.DeleteCollectionAsync(collection);
}
}
+#endif
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Weaviate/WeaviateMemoryBuilderExtensionsTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Weaviate/WeaviateMemoryBuilderExtensionsTests.cs
index 58fb5c23ee08..9f2067efeaa0 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Weaviate/WeaviateMemoryBuilderExtensionsTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Weaviate/WeaviateMemoryBuilderExtensionsTests.cs
@@ -46,7 +46,7 @@ public async Task WeaviateMemoryStoreShouldBeProperlyInitializedAsync(string? ap
}
};
- this._messageHandlerStub.ResponseToReturn.Content = new StringContent(JsonSerializer.Serialize(getResponse, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }), Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._messageHandlerStub.ResponseToReturn.Content = new StringContent(JsonSerializer.Serialize(getResponse, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }), Encoding.UTF8, "application/json");
var builder = new MemoryBuilder();
builder.WithWeaviateMemoryStore(this._httpClient, "https://fake-random-test-weaviate-host", "fake-api-key", apiVersion);
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Weaviate/WeaviateMemoryStoreTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Weaviate/WeaviateMemoryStoreTests.cs
index a19a7df73192..e40c889da954 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/Memory/Weaviate/WeaviateMemoryStoreTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/Memory/Weaviate/WeaviateMemoryStoreTests.cs
@@ -35,7 +35,7 @@ public WeaviateMemoryStoreTests()
}
};
- this._messageHandlerStub.ResponseToReturn.Content = new StringContent(JsonSerializer.Serialize(getResponse, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }), Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._messageHandlerStub.ResponseToReturn.Content = new StringContent(JsonSerializer.Serialize(getResponse, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }), Encoding.UTF8, "application/json");
this._httpClient = new HttpClient(this._messageHandlerStub, false);
}
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/MultipleHttpMessageHandlerStub.cs b/dotnet/src/Connectors/Connectors.UnitTests/MultipleHttpMessageHandlerStub.cs
index d7e81f129c9c..2c5af22fd540 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/MultipleHttpMessageHandlerStub.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/MultipleHttpMessageHandlerStub.cs
@@ -9,6 +9,8 @@
namespace SemanticKernel.Connectors.UnitTests;
+#pragma warning disable CA2016
+
internal sealed class MultipleHttpMessageHandlerStub : DelegatingHandler
{
private int _callIteration = 0;
@@ -44,7 +46,7 @@ protected override async Task SendAsync(HttpRequestMessage
this.RequestHeaders.Add(request.Headers);
this.ContentHeaders.Add(request.Content?.Headers);
- var content = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync(cancellationToken);
+ var content = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync();
this.RequestContents.Add(content);
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/AzureSdk/OpenAIChatMessageContentTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/AzureSdk/OpenAIChatMessageContentTests.cs
index cf2d32d3b52e..cc09e6702552 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/AzureSdk/OpenAIChatMessageContentTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/AzureSdk/OpenAIChatMessageContentTests.cs
@@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
using Azure.AI.OpenAI;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
@@ -119,7 +118,7 @@ private sealed class CustomReadOnlyDictionary(IDictionary dictionary.Count;
public bool ContainsKey(TKey key) => dictionary.ContainsKey(key);
public IEnumerator> GetEnumerator() => dictionary.GetEnumerator();
- public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) => dictionary.TryGetValue(key, out value);
+ public bool TryGetValue(TKey key, out TValue value) => dictionary.TryGetValue(key, out value!);
IEnumerator IEnumerable.GetEnumerator() => dictionary.GetEnumerator();
}
}
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/ChatCompletion/AzureOpenAIChatCompletionServiceTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/ChatCompletion/AzureOpenAIChatCompletionServiceTests.cs
index c8d6c0de5f40..e2b56fe70b3c 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/ChatCompletion/AzureOpenAIChatCompletionServiceTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/ChatCompletion/AzureOpenAIChatCompletionServiceTests.cs
@@ -210,10 +210,10 @@ public async Task GetChatMessageContentsHandlesSettingsCorrectlyAsync()
Assert.Equal("Assistant Message", assistantMessage.GetProperty("content").GetString());
Assert.Equal(123, content.GetProperty("max_tokens").GetInt32());
- Assert.Equal(0.6, content.GetProperty("temperature").GetDouble());
- Assert.Equal(0.5, content.GetProperty("top_p").GetDouble());
- Assert.Equal(1.6, content.GetProperty("frequency_penalty").GetDouble());
- Assert.Equal(1.2, content.GetProperty("presence_penalty").GetDouble());
+ Assert.Equal(0.6, content.GetProperty("temperature").GetDouble(), 0.0001);
+ Assert.Equal(0.5, content.GetProperty("top_p").GetDouble(), 0.0001);
+ Assert.Equal(1.6, content.GetProperty("frequency_penalty").GetDouble(), 0.0001);
+ Assert.Equal(1.2, content.GetProperty("presence_penalty").GetDouble(), 0.0001);
Assert.Equal(5, content.GetProperty("n").GetInt32());
Assert.Equal(567, content.GetProperty("seed").GetInt32());
Assert.Equal(3, content.GetProperty("logit_bias").GetProperty("2").GetInt32());
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/Files/OpenAIFileServiceTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/Files/OpenAIFileServiceTests.cs
index b2a3f8b7b6c2..86f871f944e0 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/Files/OpenAIFileServiceTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/Files/OpenAIFileServiceTests.cs
@@ -227,8 +227,8 @@ public async Task UploadContentWorksCorrectlyAsync(bool isAzure, bool isFailedRe
var settings = new OpenAIFileUploadExecutionSettings("test.txt", OpenAIFilePurpose.Assistants);
- await using var stream = new MemoryStream();
- await using (var writer = new StreamWriter(stream, leaveOpen: true))
+ using var stream = new MemoryStream();
+ using (var writer = new StreamWriter(stream, Encoding.UTF8, 0x1000, leaveOpen: true))
{
await writer.WriteLineAsync("test");
await writer.FlushAsync();
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/FunctionCalling/AutoFunctionInvocationFilterTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/FunctionCalling/AutoFunctionInvocationFilterTests.cs
index b16bf02b6cb0..a04869a877f5 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/FunctionCalling/AutoFunctionInvocationFilterTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/FunctionCalling/AutoFunctionInvocationFilterTests.cs
@@ -316,8 +316,8 @@ public async Task FilterCanHandleExceptionAsync()
// Act
var result = await chatCompletion.GetChatMessageContentsAsync(chatHistory, executionSettings, kernel);
- var firstFunctionResult = chatHistory[^2].Content;
- var secondFunctionResult = chatHistory[^1].Content;
+ var firstFunctionResult = chatHistory[chatHistory.Count - 2].Content;
+ var secondFunctionResult = chatHistory[chatHistory.Count - 1].Content;
// Assert
Assert.Equal("Result from filter", firstFunctionResult);
@@ -354,8 +354,8 @@ public async Task FilterCanHandleExceptionOnStreamingAsync()
await foreach (var item in chatCompletion.GetStreamingChatMessageContentsAsync(chatHistory, executionSettings, kernel))
{ }
- var firstFunctionResult = chatHistory[^2].Content;
- var secondFunctionResult = chatHistory[^1].Content;
+ var firstFunctionResult = chatHistory[chatHistory.Count - 2].Content;
+ var secondFunctionResult = chatHistory[chatHistory.Count - 1].Content;
// Assert
Assert.Equal("Result from filter", firstFunctionResult);
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextGeneration/AzureOpenAITextGenerationServiceTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextGeneration/AzureOpenAITextGenerationServiceTests.cs
index 87f5526d5f83..2757e3291f0c 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextGeneration/AzureOpenAITextGenerationServiceTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextGeneration/AzureOpenAITextGenerationServiceTests.cs
@@ -146,10 +146,10 @@ public async Task GetTextContentsHandlesSettingsCorrectlyAsync()
Assert.Equal("Prompt", content.GetProperty("prompt")[0].GetString());
Assert.Equal(123, content.GetProperty("max_tokens").GetInt32());
- Assert.Equal(0.6, content.GetProperty("temperature").GetDouble());
- Assert.Equal(0.5, content.GetProperty("top_p").GetDouble());
- Assert.Equal(1.6, content.GetProperty("frequency_penalty").GetDouble());
- Assert.Equal(1.2, content.GetProperty("presence_penalty").GetDouble());
+ Assert.Equal(0.6, content.GetProperty("temperature").GetDouble(), 0.0001);
+ Assert.Equal(0.5, content.GetProperty("top_p").GetDouble(), 0.0001);
+ Assert.Equal(1.6, content.GetProperty("frequency_penalty").GetDouble(), 0.0001);
+ Assert.Equal(1.2, content.GetProperty("presence_penalty").GetDouble(), 0.0001);
Assert.Equal(5, content.GetProperty("n").GetInt32());
Assert.Equal(5, content.GetProperty("best_of").GetInt32());
Assert.Equal(3, content.GetProperty("logit_bias").GetProperty("2").GetInt32());
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextToAudio/AzureOpenAITextToAudioServiceTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextToAudio/AzureOpenAITextToAudioServiceTests.cs
index 518cfbaaadde..a61605f338de 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextToAudio/AzureOpenAITextToAudioServiceTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextToAudio/AzureOpenAITextToAudioServiceTests.cs
@@ -51,7 +51,7 @@ public async Task GetAudioContentWithInvalidSettingsThrowsExceptionAsync(OpenAIT
{
// Arrange
var service = new AzureOpenAITextToAudioService("deployment-name", "https://endpoint", "api-key", "model-id", this._httpClient);
- await using var stream = new MemoryStream(new byte[] { 0x00, 0x00, 0xFF, 0x7F });
+ using var stream = new MemoryStream(new byte[] { 0x00, 0x00, 0xFF, 0x7F });
this._messageHandlerStub.ResponseToReturn = new HttpResponseMessage(HttpStatusCode.OK)
{
@@ -73,7 +73,7 @@ public async Task GetAudioContentByDefaultWorksCorrectlyAsync()
var expectedByteArray = new byte[] { 0x00, 0x00, 0xFF, 0x7F };
var service = new AzureOpenAITextToAudioService("deployment-name", "https://endpoint", "api-key", "model-id", this._httpClient);
- await using var stream = new MemoryStream(expectedByteArray);
+ using var stream = new MemoryStream(expectedByteArray);
this._messageHandlerStub.ResponseToReturn = new HttpResponseMessage(HttpStatusCode.OK)
{
@@ -102,7 +102,7 @@ public async Task GetAudioContentUsesValidBaseUrlAsync(bool useHttpClientBaseAdd
}
var service = new AzureOpenAITextToAudioService("deployment-name", "https://endpoint", "api-key", "model-id", this._httpClient);
- await using var stream = new MemoryStream(expectedByteArray);
+ using var stream = new MemoryStream(expectedByteArray);
this._messageHandlerStub.ResponseToReturn = new HttpResponseMessage(HttpStatusCode.OK)
{
diff --git a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextToAudio/OpenAITextToAudioServiceTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextToAudio/OpenAITextToAudioServiceTests.cs
index 6c3c6746f511..f7c1ac2aad6e 100644
--- a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextToAudio/OpenAITextToAudioServiceTests.cs
+++ b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/TextToAudio/OpenAITextToAudioServiceTests.cs
@@ -50,7 +50,7 @@ public async Task GetAudioContentWithInvalidSettingsThrowsExceptionAsync(OpenAIT
{
// Arrange
var service = new OpenAITextToAudioService("model-id", "api-key", "organization", this._httpClient);
- await using var stream = new MemoryStream(new byte[] { 0x00, 0x00, 0xFF, 0x7F });
+ using var stream = new MemoryStream(new byte[] { 0x00, 0x00, 0xFF, 0x7F });
this._messageHandlerStub.ResponseToReturn = new HttpResponseMessage(HttpStatusCode.OK)
{
@@ -72,7 +72,7 @@ public async Task GetAudioContentByDefaultWorksCorrectlyAsync()
var expectedByteArray = new byte[] { 0x00, 0x00, 0xFF, 0x7F };
var service = new OpenAITextToAudioService("model-id", "api-key", "organization", this._httpClient);
- await using var stream = new MemoryStream(expectedByteArray);
+ using var stream = new MemoryStream(expectedByteArray);
this._messageHandlerStub.ResponseToReturn = new HttpResponseMessage(HttpStatusCode.OK)
{
@@ -101,7 +101,7 @@ public async Task GetAudioContentUsesValidBaseUrlAsync(bool useHttpClientBaseAdd
}
var service = new OpenAITextToAudioService("model-id", "api-key", "organization", this._httpClient);
- await using var stream = new MemoryStream(expectedByteArray);
+ using var stream = new MemoryStream(expectedByteArray);
this._messageHandlerStub.ResponseToReturn = new HttpResponseMessage(HttpStatusCode.OK)
{
diff --git a/dotnet/src/Experimental/Agents.UnitTests/Experimental.Agents.UnitTests.csproj b/dotnet/src/Experimental/Agents.UnitTests/Experimental.Agents.UnitTests.csproj
index 8d29367fae3b..176b73918033 100644
--- a/dotnet/src/Experimental/Agents.UnitTests/Experimental.Agents.UnitTests.csproj
+++ b/dotnet/src/Experimental/Agents.UnitTests/Experimental.Agents.UnitTests.csproj
@@ -2,7 +2,7 @@
SemanticKernel.Experimental.Agents.UnitTests
SemanticKernel.Experimental.Agents.UnitTests
- net8.0
+ net8.0;net462
true
enable
disable
diff --git a/dotnet/src/Experimental/Agents.UnitTests/Integration/AgentHarness.cs b/dotnet/src/Experimental/Agents.UnitTests/Integration/AgentHarness.cs
index 6513b1edfa25..268be8805cb8 100644
--- a/dotnet/src/Experimental/Agents.UnitTests/Integration/AgentHarness.cs
+++ b/dotnet/src/Experimental/Agents.UnitTests/Integration/AgentHarness.cs
@@ -113,7 +113,7 @@ public async Task VerifyAgentDeleteAsync()
var agents = await context.ListAssistantModelsAsync().ConfigureAwait(true);
foreach (var agent in agents)
{
- if (!string.IsNullOrWhiteSpace(agent.Name) && names.Contains(agent.Name))
+ if (!string.IsNullOrWhiteSpace(agent.Name) && names.Contains(agent.Name!))
{
this._output.WriteLine($"Removing: {agent.Name} - {agent.Id}");
await context.DeleteAssistantModelAsync(agent.Id).ConfigureAwait(true);
diff --git a/dotnet/src/Experimental/Orchestration.Flow.IntegrationTests/Experimental.Orchestration.Flow.IntegrationTests.csproj b/dotnet/src/Experimental/Orchestration.Flow.IntegrationTests/Experimental.Orchestration.Flow.IntegrationTests.csproj
index a3f5a93a7013..cedc5b3276cf 100644
--- a/dotnet/src/Experimental/Orchestration.Flow.IntegrationTests/Experimental.Orchestration.Flow.IntegrationTests.csproj
+++ b/dotnet/src/Experimental/Orchestration.Flow.IntegrationTests/Experimental.Orchestration.Flow.IntegrationTests.csproj
@@ -2,7 +2,7 @@
SemanticKernel.Experimental.Orchestration.Flow.IntegrationTests
SemanticKernel.Experimental.Orchestration.Flow.IntegrationTests
- net8.0
+ net8.0;net462
true
false
$(NoWarn);CA2007,VSTHRD111,SKEXP0101,SKEXP0050
diff --git a/dotnet/src/Experimental/Orchestration.Flow.UnitTests/Experimental.Orchestration.Flow.UnitTests.csproj b/dotnet/src/Experimental/Orchestration.Flow.UnitTests/Experimental.Orchestration.Flow.UnitTests.csproj
index bf6fd4c4ee8d..b76bc709d69d 100644
--- a/dotnet/src/Experimental/Orchestration.Flow.UnitTests/Experimental.Orchestration.Flow.UnitTests.csproj
+++ b/dotnet/src/Experimental/Orchestration.Flow.UnitTests/Experimental.Orchestration.Flow.UnitTests.csproj
@@ -2,7 +2,7 @@
SemanticKernel.Experimental.Orchestration.Flow.UnitTests
SemanticKernel.Experimental.Orchestration.Flow.UnitTests
- net8.0
+ net8.0;net462
true
enable
disable
diff --git a/dotnet/src/Extensions/Extensions.UnitTests/Extensions.UnitTests.csproj b/dotnet/src/Extensions/Extensions.UnitTests/Extensions.UnitTests.csproj
index fcde0b8da174..020b5de5bc79 100644
--- a/dotnet/src/Extensions/Extensions.UnitTests/Extensions.UnitTests.csproj
+++ b/dotnet/src/Extensions/Extensions.UnitTests/Extensions.UnitTests.csproj
@@ -2,7 +2,7 @@
SemanticKernel.Extensions.UnitTests
SemanticKernel.Extensions.UnitTests
- net8.0
+ net8.0;net462
true
enable
disable
diff --git a/dotnet/src/Extensions/Extensions.UnitTests/PromptTemplates/Handlebars/Helpers/KernelSystemHelpersTests.cs b/dotnet/src/Extensions/Extensions.UnitTests/PromptTemplates/Handlebars/Helpers/KernelSystemHelpersTests.cs
index 130eaabe9cbc..6973c13812e1 100644
--- a/dotnet/src/Extensions/Extensions.UnitTests/PromptTemplates/Handlebars/Helpers/KernelSystemHelpersTests.cs
+++ b/dotnet/src/Extensions/Extensions.UnitTests/PromptTemplates/Handlebars/Helpers/KernelSystemHelpersTests.cs
@@ -3,7 +3,7 @@
using System;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
-using System.Web;
+using System.Net;
using HandlebarsDotNet;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.PromptTemplates.Handlebars;
@@ -64,7 +64,7 @@ public async Task ItRendersTemplateWithJsonHelperAsync(object json)
var result = await this.RenderPromptTemplateAsync(template, arguments);
// Assert
- Assert.Equal("""{"name":"Alice","age":25}""", HttpUtility.HtmlDecode(result));
+ Assert.Equal("""{"name":"Alice","age":25}""", WebUtility.HtmlDecode(result));
}
[Fact]
diff --git a/dotnet/src/Extensions/PromptTemplates.Liquid.UnitTests/LiquidTemplateTest.cs b/dotnet/src/Extensions/PromptTemplates.Liquid.UnitTests/LiquidTemplateTest.cs
index fe5eb297ffdf..9e070041be58 100644
--- a/dotnet/src/Extensions/PromptTemplates.Liquid.UnitTests/LiquidTemplateTest.cs
+++ b/dotnet/src/Extensions/PromptTemplates.Liquid.UnitTests/LiquidTemplateTest.cs
@@ -719,7 +719,7 @@ private string SerializeChatHistory(ChatHistory chatHistory)
{
var chatObject = chatHistory.Select(chat => new { Role = chat.Role.ToString(), Content = chat.Content });
- return JsonSerializer.Serialize(chatObject, this._jsonSerializerOptions).Replace(Environment.NewLine, "\n", StringComparison.InvariantCulture);
+ return JsonSerializer.Serialize(chatObject, this._jsonSerializerOptions).Replace(Environment.NewLine, "\n");
}
#endregion Private
}
diff --git a/dotnet/src/Extensions/PromptTemplates.Liquid.UnitTests/PromptTemplates.Liquid.UnitTests.csproj b/dotnet/src/Extensions/PromptTemplates.Liquid.UnitTests/PromptTemplates.Liquid.UnitTests.csproj
index e8be2cf0d171..4e6c07683106 100644
--- a/dotnet/src/Extensions/PromptTemplates.Liquid.UnitTests/PromptTemplates.Liquid.UnitTests.csproj
+++ b/dotnet/src/Extensions/PromptTemplates.Liquid.UnitTests/PromptTemplates.Liquid.UnitTests.csproj
@@ -2,7 +2,7 @@
SemanticKernel.Extensions.PromptTemplates.Liquid.UnitTests
$(AssemblyName)
- net8.0
+ net8.0;net462
true
enable
disable
diff --git a/dotnet/src/Functions/Functions.Prompty.UnitTests/Functions.Prompty.UnitTests.csproj b/dotnet/src/Functions/Functions.Prompty.UnitTests/Functions.Prompty.UnitTests.csproj
index b730d1c27025..341c76a08fb6 100644
--- a/dotnet/src/Functions/Functions.Prompty.UnitTests/Functions.Prompty.UnitTests.csproj
+++ b/dotnet/src/Functions/Functions.Prompty.UnitTests/Functions.Prompty.UnitTests.csproj
@@ -2,7 +2,7 @@
SemanticKernel.Functions.Prompty.UnitTests
$(AssemblyName)
- net8.0
+ net8.0;net462
true
enable
disable
diff --git a/dotnet/src/Functions/Functions.UnitTests/Functions.UnitTests.csproj b/dotnet/src/Functions/Functions.UnitTests/Functions.UnitTests.csproj
index 50f58e947499..1f192b1a8daf 100644
--- a/dotnet/src/Functions/Functions.UnitTests/Functions.UnitTests.csproj
+++ b/dotnet/src/Functions/Functions.UnitTests/Functions.UnitTests.csproj
@@ -2,7 +2,7 @@
SemanticKernel.Functions.UnitTests
SemanticKernel.Functions.UnitTests
- net8.0
+ net8.0;net462
true
enable
disable
diff --git a/dotnet/src/Functions/Functions.UnitTests/Grpc/GrpcRunnerTests.cs b/dotnet/src/Functions/Functions.UnitTests/Grpc/GrpcRunnerTests.cs
index 756ab5ce22fe..16a92f315c78 100644
--- a/dotnet/src/Functions/Functions.UnitTests/Grpc/GrpcRunnerTests.cs
+++ b/dotnet/src/Functions/Functions.UnitTests/Grpc/GrpcRunnerTests.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+#if NET // TODO: gRPC unavailable by default on .NET Framework
using System;
using System.Net.Http;
using System.Net.Http.Headers;
@@ -203,3 +204,4 @@ protected override async Task SendAsync(HttpRequestMessage
}
}
}
+#endif
diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenApi/Extensions/OpenApiKernelExtensionsTests.cs b/dotnet/src/Functions/Functions.UnitTests/OpenApi/Extensions/OpenApiKernelExtensionsTests.cs
index 2f1983ec4382..b69b7bd0dcd2 100644
--- a/dotnet/src/Functions/Functions.UnitTests/OpenApi/Extensions/OpenApiKernelExtensionsTests.cs
+++ b/dotnet/src/Functions/Functions.UnitTests/OpenApi/Extensions/OpenApiKernelExtensionsTests.cs
@@ -1,12 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
+#if NET // TODO https://github.com/microsoft/OpenAPI.NET/issues/1635: Enable for .NET Framework when issues is addressed
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Net.Http;
-using System.Net.Mime;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SemanticKernel;
@@ -191,7 +191,7 @@ public async Task ItShouldRespectRunAsyncCancellationTokenOnExecutionAsync()
{
// Arrange
using var messageHandlerStub = new HttpMessageHandlerStub();
- messageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ messageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
using var httpClient = new HttpClient(messageHandlerStub, false);
@@ -339,3 +339,4 @@ public void DoFakeAction(string parameter)
#endregion
}
+#endif
diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenApi/HttpMessageHandlerStub.cs b/dotnet/src/Functions/Functions.UnitTests/OpenApi/HttpMessageHandlerStub.cs
index 32b89ab11a0b..18a1d12ea611 100644
--- a/dotnet/src/Functions/Functions.UnitTests/OpenApi/HttpMessageHandlerStub.cs
+++ b/dotnet/src/Functions/Functions.UnitTests/OpenApi/HttpMessageHandlerStub.cs
@@ -4,13 +4,14 @@
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
-using System.Net.Mime;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace SemanticKernel.Functions.UnitTests.OpenApi;
+#pragma warning disable CA1812, CA2016
+
internal sealed class HttpMessageHandlerStub : DelegatingHandler
{
public HttpRequestHeaders? RequestHeaders { get; private set; }
@@ -29,7 +30,7 @@ public HttpMessageHandlerStub()
{
this.ResponseToReturn = new HttpResponseMessage(System.Net.HttpStatusCode.OK)
{
- Content = new StringContent("{}", Encoding.UTF8, MediaTypeNames.Application.Json)
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
};
}
@@ -45,7 +46,7 @@ public void ResetResponse()
{
this.ResponseToReturn = new HttpResponseMessage(System.Net.HttpStatusCode.OK)
{
- Content = new StringContent("{}", Encoding.UTF8, MediaTypeNames.Application.Json)
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
};
}
@@ -54,7 +55,7 @@ protected override async Task SendAsync(HttpRequestMessage
this.Method = request.Method;
this.RequestUri = request.RequestUri;
this.RequestHeaders = request.Headers;
- this.RequestContent = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync(cancellationToken);
+ this.RequestContent = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync();
this.ContentHeaders = request.Content?.Headers;
return await Task.FromResult(this.ResponseToReturn);
diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenAI/KernelOpenAIPluginExtensionsTests.cs b/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenAI/KernelOpenAIPluginExtensionsTests.cs
index 36f7601dd02e..0a341e5a5cb0 100644
--- a/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenAI/KernelOpenAIPluginExtensionsTests.cs
+++ b/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenAI/KernelOpenAIPluginExtensionsTests.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+#if NET // TODO https://github.com/microsoft/OpenAPI.NET/issues/1635: Enable for .NET Framework when issues is addressed
using System;
using System.IO;
using System.Net.Http;
@@ -92,3 +93,4 @@ public void Dispose()
this._openApiDocument.Dispose();
}
}
+#endif
diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserExtensionsTests.cs b/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserExtensionsTests.cs
index a3b9c8908135..da362ad51897 100644
--- a/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserExtensionsTests.cs
+++ b/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserExtensionsTests.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+#if NET // TODO https://github.com/microsoft/OpenAPI.NET/issues/1635: Enable for .NET Framework when issues is addressed
using System;
using System.Globalization;
using System.Linq;
@@ -78,3 +79,4 @@ public async Task ItCanExtractExtensionsOfAllTypesAsync(string documentName)
Assert.Equal("{\"key1\":\"value1\",\"key2\":\"value2\"}", objectValue);
}
}
+#endif
diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV20Tests.cs b/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV20Tests.cs
index 5b7e14326e8e..09282d7a6ab7 100644
--- a/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV20Tests.cs
+++ b/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV20Tests.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+#if NET // TODO https://github.com/microsoft/OpenAPI.NET/issues/1635: Enable for .NET Framework when issues is addressed
using System;
using System.Collections.Generic;
using System.IO;
@@ -374,3 +375,4 @@ public void Dispose()
this._openApiDocument.Dispose();
}
}
+#endif
diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV30Tests.cs b/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV30Tests.cs
index 2250de836548..3b37c3ffa182 100644
--- a/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV30Tests.cs
+++ b/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV30Tests.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+#if NET // TODO https://github.com/microsoft/OpenAPI.NET/issues/1635: Enable for .NET Framework when issues is addressed
using System;
using System.Collections.Generic;
using System.IO;
@@ -462,3 +463,4 @@ public void Dispose()
this._openApiDocument.Dispose();
}
}
+#endif
diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV31Tests.cs b/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV31Tests.cs
index fdc4af06702c..2b4622260696 100644
--- a/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV31Tests.cs
+++ b/dotnet/src/Functions/Functions.UnitTests/OpenApi/OpenApiDocumentParserV31Tests.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+#if NET // TODO https://github.com/microsoft/OpenAPI.NET/issues/1635: Enable for .NET Framework when issues is addressed
using System;
using System.Collections.Generic;
using System.Dynamic;
@@ -443,3 +444,4 @@ public void Dispose()
this._openApiDocument.Dispose();
}
}
+#endif
diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenApi/RestApiOperationRunnerTests.cs b/dotnet/src/Functions/Functions.UnitTests/OpenApi/RestApiOperationRunnerTests.cs
index cb9e9b977749..13dad64682d7 100644
--- a/dotnet/src/Functions/Functions.UnitTests/OpenApi/RestApiOperationRunnerTests.cs
+++ b/dotnet/src/Functions/Functions.UnitTests/OpenApi/RestApiOperationRunnerTests.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+#if NET // TODO https://github.com/microsoft/OpenAPI.NET/issues/1635: Enable for .NET Framework when issues is addressed
using System;
using System.Collections;
using System.Collections.Generic;
@@ -22,6 +23,8 @@
namespace SemanticKernel.Functions.UnitTests.OpenApi;
+#pragma warning disable CA2016
+
public sealed class RestApiOperationRunnerTests : IDisposable
{
///
@@ -60,7 +63,7 @@ public RestApiOperationRunnerTests()
public async Task ItCanRunCreateAndUpdateOperationsWithJsonPayloadSuccessfullyAsync(string method)
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
var httpMethod = new HttpMethod(method);
@@ -305,7 +308,7 @@ public async Task ItShouldAddUserAgentHeaderToHttpRequestIfConfiguredAsync()
public async Task ItShouldBuildJsonPayloadDynamicallyAsync()
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
List payloadProperties =
[
@@ -316,7 +319,7 @@ public async Task ItShouldBuildJsonPayloadDynamicallyAsync()
])
];
- var payload = new RestApiOperationPayload(MediaTypeNames.Application.Json, payloadProperties);
+ var payload = new RestApiOperationPayload("application/json", payloadProperties);
var operation = new RestApiOperation(
"fake-id",
@@ -365,7 +368,7 @@ public async Task ItShouldBuildJsonPayloadDynamicallyAsync()
public async Task ItShouldBuildJsonPayloadDynamicallyUsingPayloadMetadataDataTypesAsync()
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
List payloadProperties =
[
@@ -380,7 +383,7 @@ public async Task ItShouldBuildJsonPayloadDynamicallyUsingPayloadMetadataDataTyp
])
];
- var payload = new RestApiOperationPayload(MediaTypeNames.Application.Json, payloadProperties);
+ var payload = new RestApiOperationPayload("application/json", payloadProperties);
var operation = new RestApiOperation(
"fake-id",
@@ -450,7 +453,7 @@ public async Task ItShouldBuildJsonPayloadDynamicallyUsingPayloadMetadataDataTyp
public async Task ItShouldBuildJsonPayloadDynamicallyResolvingArgumentsByFullNamesAsync()
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
List payloadProperties =
[
@@ -469,7 +472,7 @@ public async Task ItShouldBuildJsonPayloadDynamicallyResolvingArgumentsByFullNam
])
];
- var payload = new RestApiOperationPayload(MediaTypeNames.Application.Json, payloadProperties);
+ var payload = new RestApiOperationPayload("application/json", payloadProperties);
var operation = new RestApiOperation(
"fake-id",
@@ -632,12 +635,12 @@ public async Task ItShouldUsePayloadArgumentForPlainTextContentTypeWhenBuildingP
}
[Theory]
- [InlineData(MediaTypeNames.Text.Plain)]
- [InlineData(MediaTypeNames.Application.Json)]
+ [InlineData("text/plain")]
+ [InlineData("application/json")]
public async Task ItShouldUsePayloadAndContentTypeArgumentsIfDynamicPayloadBuildingIsNotRequiredAsync(string contentType)
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Text.Plain);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "text/plain");
var operation = new RestApiOperation(
"fake-id",
@@ -676,14 +679,14 @@ public async Task ItShouldUsePayloadAndContentTypeArgumentsIfDynamicPayloadBuild
public async Task ItShouldBuildJsonPayloadDynamicallyExcludingOptionalParametersIfTheirArgumentsNotProvidedAsync()
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
List payloadProperties =
[
new("upn", "string", false, []),
];
- var payload = new RestApiOperationPayload(MediaTypeNames.Application.Json, payloadProperties);
+ var payload = new RestApiOperationPayload("application/json", payloadProperties);
var operation = new RestApiOperation(
"fake-id",
@@ -722,14 +725,14 @@ public async Task ItShouldBuildJsonPayloadDynamicallyExcludingOptionalParameters
public async Task ItShouldBuildJsonPayloadDynamicallyIncludingOptionalParametersIfTheirArgumentsProvidedAsync()
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
List payloadProperties =
[
new("upn", "string", false, []),
];
- var payload = new RestApiOperationPayload(MediaTypeNames.Application.Json, payloadProperties);
+ var payload = new RestApiOperationPayload("application/json", payloadProperties);
var operation = new RestApiOperation(
"fake-id",
@@ -768,7 +771,7 @@ public async Task ItShouldBuildJsonPayloadDynamicallyIncludingOptionalParameters
public async Task ItShouldAddRequiredQueryStringParametersIfTheirArgumentsProvidedAsync()
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
var firstParameter = new RestApiOperationParameter(
"p1",
@@ -816,7 +819,7 @@ public async Task ItShouldAddRequiredQueryStringParametersIfTheirArgumentsProvid
public async Task ItShouldAddNotRequiredQueryStringParametersIfTheirArgumentsProvidedAsync()
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
var firstParameter = new RestApiOperationParameter(
"p1",
@@ -864,7 +867,7 @@ public async Task ItShouldAddNotRequiredQueryStringParametersIfTheirArgumentsPro
public async Task ItShouldSkipNotRequiredQueryStringParametersIfNoArgumentsProvidedAsync()
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
var firstParameter = new RestApiOperationParameter(
"p1",
@@ -911,7 +914,7 @@ public async Task ItShouldSkipNotRequiredQueryStringParametersIfNoArgumentsProvi
public async Task ItShouldThrowExceptionIfNoArgumentProvidedForRequiredQueryStringParameterAsync()
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
var parameter = new RestApiOperationParameter(
"p1",
@@ -940,8 +943,8 @@ public async Task ItShouldThrowExceptionIfNoArgumentProvidedForRequiredQueryStri
}
[Theory]
- [InlineData(MediaTypeNames.Application.Json)]
- [InlineData(MediaTypeNames.Application.Xml)]
+ [InlineData("application/json")]
+ [InlineData("application/xml")]
[InlineData(MediaTypeNames.Text.Plain)]
[InlineData(MediaTypeNames.Text.Html)]
[InlineData(MediaTypeNames.Text.Xml)]
@@ -1055,7 +1058,7 @@ public async Task ItShouldThrowExceptionForUnsupportedContentTypeAsync()
public async Task ItShouldReturnRequestUriAndContentAsync()
{
// Arrange
- this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, MediaTypeNames.Application.Json);
+ this._httpMessageHandlerStub.ResponseToReturn.Content = new StringContent("fake-content", Encoding.UTF8, "application/json");
List payloadProperties =
[
@@ -1066,7 +1069,7 @@ public async Task ItShouldReturnRequestUriAndContentAsync()
])
];
- var payload = new RestApiOperationPayload(MediaTypeNames.Application.Json, payloadProperties);
+ var payload = new RestApiOperationPayload("application/json", payloadProperties);
var operation = new RestApiOperation(
"fake-id",
@@ -1197,7 +1200,7 @@ public HttpMessageHandlerStub()
{
this.ResponseToReturn = new HttpResponseMessage(System.Net.HttpStatusCode.OK)
{
- Content = new StringContent("{}", Encoding.UTF8, MediaTypeNames.Application.Json)
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
};
}
@@ -1206,10 +1209,11 @@ protected override async Task SendAsync(HttpRequestMessage
this.Method = request.Method;
this.RequestUri = request.RequestUri;
this.RequestHeaders = request.Headers;
- this.RequestContent = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync(cancellationToken);
+ this.RequestContent = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync();
this.ContentHeaders = request.Content?.Headers;
return await Task.FromResult(this.ResponseToReturn);
}
}
}
+#endif
diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenApi/Serialization/OpenApiTypeConverterTests.cs b/dotnet/src/Functions/Functions.UnitTests/OpenApi/Serialization/OpenApiTypeConverterTests.cs
index 9331bb0b55a2..63ad668fdd40 100644
--- a/dotnet/src/Functions/Functions.UnitTests/OpenApi/Serialization/OpenApiTypeConverterTests.cs
+++ b/dotnet/src/Functions/Functions.UnitTests/OpenApi/Serialization/OpenApiTypeConverterTests.cs
@@ -2,9 +2,9 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Globalization;
using Microsoft.SemanticKernel.Plugins.OpenApi;
-using Microsoft.VisualBasic;
using Xunit;
namespace SemanticKernel.Functions.UnitTests.OpenApi.Serialization;
@@ -108,7 +108,7 @@ public void ItShouldConvertCollections()
Assert.Equal("[1,2,3]", OpenApiTypeConverter.Convert("id", "array", new List { 1, 2, 3 }).ToJsonString());
- Assert.Equal("[1,2,3]", OpenApiTypeConverter.Convert("id", "array", new Collection() { 1, 2, 3 }).ToJsonString());
+ Assert.Equal("[1,2,3]", OpenApiTypeConverter.Convert("id", "array", new Collection() { 1, 2, 3 }).ToJsonString());
Assert.Equal("[1,2,3]", OpenApiTypeConverter.Convert("id", "array", "[1, 2, 3]").ToJsonString());
}
diff --git a/dotnet/src/IntegrationTests/BaseIntegrationTest.cs b/dotnet/src/IntegrationTests/BaseIntegrationTest.cs
index c4fda5081e39..4afd655d01b6 100644
--- a/dotnet/src/IntegrationTests/BaseIntegrationTest.cs
+++ b/dotnet/src/IntegrationTests/BaseIntegrationTest.cs
@@ -19,7 +19,7 @@ protected IKernelBuilder CreateKernelBuilder()
c.AddStandardResilienceHandler().Configure(o =>
{
o.Retry.ShouldRetryAfterHeader = true;
- o.Retry.ShouldHandle = args => ValueTask.FromResult(args.Outcome.Result?.StatusCode is HttpStatusCode.TooManyRequests);
+ o.Retry.ShouldHandle = args => new ValueTask(args.Outcome.Result?.StatusCode is (HttpStatusCode)429 /*TooManyRequests*/);
o.CircuitBreaker = new HttpCircuitBreakerStrategyOptions
{
SamplingDuration = TimeSpan.FromSeconds(40.0), // The duration should be least double of an attempt timeout
diff --git a/dotnet/src/IntegrationTests/Connectors/Google/Gemini/GeminiChatCompletionTests.cs b/dotnet/src/IntegrationTests/Connectors/Google/Gemini/GeminiChatCompletionTests.cs
index afd579c6bc45..57478b225768 100644
--- a/dotnet/src/IntegrationTests/Connectors/Google/Gemini/GeminiChatCompletionTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Google/Gemini/GeminiChatCompletionTests.cs
@@ -70,7 +70,7 @@ public async Task ChatStreamingReturnsValidResponseAsync(ServiceType serviceType
public async Task ChatGenerationVisionBinaryDataAsync(ServiceType serviceType)
{
// Arrange
- Memory image = await File.ReadAllBytesAsync("./TestData/test_image_001.jpg");
+ Memory image = File.ReadAllBytes("./TestData/test_image_001.jpg");
var chatHistory = new ChatHistory();
var messageContent = new ChatMessageContent(AuthorRole.User, items:
[
@@ -96,7 +96,7 @@ public async Task ChatGenerationVisionBinaryDataAsync(ServiceType serviceType)
public async Task ChatStreamingVisionBinaryDataAsync(ServiceType serviceType)
{
// Arrange
- Memory image = await File.ReadAllBytesAsync("./TestData/test_image_001.jpg");
+ Memory image = File.ReadAllBytes("./TestData/test_image_001.jpg");
var chatHistory = new ChatHistory();
var messageContent = new ChatMessageContent(AuthorRole.User, items:
[
@@ -191,9 +191,9 @@ public async Task ChatGenerationReturnsUsedTokensAsync(ServiceType serviceType)
// Assert
var geminiMetadata = response.Metadata as GeminiMetadata;
Assert.NotNull(geminiMetadata);
- foreach ((string? key, object? value) in geminiMetadata)
+ foreach (var entry in geminiMetadata)
{
- this.Output.WriteLine($"{key}: {JsonSerializer.Serialize(value)}");
+ this.Output.WriteLine($"{entry.Key}: {JsonSerializer.Serialize(entry.Value)}");
}
Assert.True(geminiMetadata.TotalTokenCount > 0);
diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTestsFixture.cs b/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTestsFixture.cs
index 1b1255c46b68..f7992435ab79 100644
--- a/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTestsFixture.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTestsFixture.cs
@@ -60,6 +60,6 @@ private static string GetSetting(IConfigurationRoot configuration, string settin
throw new ArgumentNullException($"{settingValue} string is not configured");
}
- return settingValue;
+ return settingValue!;
}
}
diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/MongoDB/MongoDBMemoryStoreTestsFixture.cs b/dotnet/src/IntegrationTests/Connectors/Memory/MongoDB/MongoDBMemoryStoreTestsFixture.cs
index f96acb8fd77b..a681f50638ea 100644
--- a/dotnet/src/IntegrationTests/Connectors/Memory/MongoDB/MongoDBMemoryStoreTestsFixture.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Memory/MongoDB/MongoDBMemoryStoreTestsFixture.cs
@@ -91,7 +91,7 @@ private static string GetSetting(IConfigurationRoot configuration, string settin
throw new ArgumentNullException($"{settingValue} string is not configured");
}
- return settingValue;
+ return settingValue!;
}
private static string GetRandomName() => $"test_{Guid.NewGuid():N}";
diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/Postgres/PostgresMemoryStoreTests.cs b/dotnet/src/IntegrationTests/Connectors/Memory/Postgres/PostgresMemoryStoreTests.cs
index 19126a090874..ae9644d2319f 100644
--- a/dotnet/src/IntegrationTests/Connectors/Memory/Postgres/PostgresMemoryStoreTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Memory/Postgres/PostgresMemoryStoreTests.cs
@@ -38,7 +38,7 @@ public async Task InitializeAsync()
throw new ArgumentNullException("Postgres memory connection string is not configured");
}
- this._connectionString = connectionString;
+ this._connectionString = connectionString!;
this._databaseName = $"sk_it_{Guid.NewGuid():N}";
NpgsqlConnectionStringBuilder connectionStringBuilder = new(this._connectionString)
@@ -636,13 +636,13 @@ private async Task CreateDatabaseAsync()
using NpgsqlDataSource dataSource = NpgsqlDataSource.Create(this._connectionString);
await using (NpgsqlConnection conn = await dataSource.OpenConnectionAsync())
{
- await using NpgsqlCommand command = new($"CREATE DATABASE \"{this._databaseName}\"", conn);
+ using NpgsqlCommand command = new($"CREATE DATABASE \"{this._databaseName}\"", conn);
await command.ExecuteNonQueryAsync();
}
await using (NpgsqlConnection conn = await this._dataSource.OpenConnectionAsync())
{
- await using (NpgsqlCommand command = new("CREATE EXTENSION vector", conn))
+ using (NpgsqlCommand command = new("CREATE EXTENSION vector", conn))
{
await command.ExecuteNonQueryAsync();
}
@@ -655,7 +655,7 @@ private async Task DropDatabaseAsync()
{
using NpgsqlDataSource dataSource = NpgsqlDataSource.Create(this._connectionString);
await using NpgsqlConnection conn = await dataSource.OpenConnectionAsync();
- await using NpgsqlCommand command = new($"DROP DATABASE IF EXISTS \"{this._databaseName}\"", conn);
+ using NpgsqlCommand command = new($"DROP DATABASE IF EXISTS \"{this._databaseName}\"", conn);
await command.ExecuteNonQueryAsync();
}
@@ -677,7 +677,7 @@ private IEnumerable CreateBatchRecords(int numRecords)
text: "text" + i,
description: "description" + i,
embedding: new float[] { 1, 1, 1 });
- records = records.Append(testRecord);
+ records = records.Concat([testRecord]);
}
for (int i = numRecords / 2; i < numRecords; i++)
@@ -687,7 +687,7 @@ private IEnumerable CreateBatchRecords(int numRecords)
sourceName: "sourceName" + i,
description: "description" + i,
embedding: new float[] { 1, 2, 3 });
- records = records.Append(testRecord);
+ records = records.Concat([testRecord]);
}
return records;
diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/SqlServer/SqlServerMemoryStoreTests.cs b/dotnet/src/IntegrationTests/Connectors/Memory/SqlServer/SqlServerMemoryStoreTests.cs
index ccbf900dba5a..a87e4515ac69 100644
--- a/dotnet/src/IntegrationTests/Connectors/Memory/SqlServer/SqlServerMemoryStoreTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Memory/SqlServer/SqlServerMemoryStoreTests.cs
@@ -42,12 +42,12 @@ public async Task InitializeAsync()
throw new ArgumentException("SqlServer memory connection string is not configured.");
}
- this._connectionString = connectionString;
+ this._connectionString = connectionString!;
await this.CleanupDatabaseAsync();
await this.InitializeDatabaseAsync();
- this.Store = new SqlServerMemoryStore(this._connectionString, SchemaName);
+ this.Store = new SqlServerMemoryStore(this._connectionString!, SchemaName);
}
public async Task DisposeAsync()
@@ -323,18 +323,18 @@ private async Task> InsertSampleDataAsync()
private async Task InitializeDatabaseAsync()
{
- await using var connection = new SqlConnection(this._connectionString);
+ using var connection = new SqlConnection(this._connectionString);
await connection.OpenAsync();
- await using var cmd = connection.CreateCommand();
+ using var cmd = connection.CreateCommand();
cmd.CommandText = $"CREATE SCHEMA {SchemaName}";
await cmd.ExecuteNonQueryAsync();
}
private async Task CleanupDatabaseAsync()
{
- await using var connection = new SqlConnection(this._connectionString);
+ using var connection = new SqlConnection(this._connectionString);
await connection.OpenAsync();
- await using var cmd = connection.CreateCommand();
+ using var cmd = connection.CreateCommand();
cmd.CommandText = $"""
DECLARE tables_cursor CURSOR FOR
SELECT table_name
diff --git a/dotnet/src/IntegrationTests/Connectors/Onnx/BertOnnxTextEmbeddingGenerationServiceTests.cs b/dotnet/src/IntegrationTests/Connectors/Onnx/BertOnnxTextEmbeddingGenerationServiceTests.cs
index e2f7f006202c..a77c1fddee7a 100644
--- a/dotnet/src/IntegrationTests/Connectors/Onnx/BertOnnxTextEmbeddingGenerationServiceTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Onnx/BertOnnxTextEmbeddingGenerationServiceTests.cs
@@ -16,6 +16,8 @@
namespace SemanticKernel.IntegrationTests.Connectors.Onnx;
+#pragma warning disable CA1850
+
public class BertOnnxTextEmbeddingGenerationServiceTests
{
private static readonly HttpClient s_client = new();
@@ -176,9 +178,9 @@ public async Task ValidateSimilarityScoresOrderedForBgeMicroV2Async()
examples.Select(s => upper ? s.ToUpperInvariant() : s).ToList());
string[] sortedExamples = examples
- .Zip(examplesResults)
- .OrderByDescending(p => TensorPrimitives.CosineSimilarity(inputResults[0].Span, p.Second.Span))
- .Select(p => p.First)
+ .Zip(examplesResults, (x, y) => (x, y))
+ .OrderByDescending(p => TensorPrimitives.CosineSimilarity(inputResults[0].Span, p.y.Span))
+ .Select(p => p.x)
.ToArray();
Assert.Equal(
@@ -234,9 +236,9 @@ public async Task ValidateServiceMayBeUsedConcurrentlyAsync()
(await Task.WhenAll(examples.Select(e => service.GenerateEmbeddingsAsync([e])))).SelectMany(e => e).ToList();
string[] sortedExamples = examples
- .Zip(examplesResults)
- .OrderByDescending(p => TensorPrimitives.CosineSimilarity(inputResults[0].Span, p.Second.Span))
- .Select(p => p.First)
+ .Zip(examplesResults, (x,y) => (x,y))
+ .OrderByDescending(p => TensorPrimitives.CosineSimilarity(inputResults[0].Span, p.y.Span))
+ .Select(p => p.x)
.ToArray();
Assert.Equal(
@@ -284,15 +286,19 @@ private static async Task GetTestFilePathAsync(string url)
// Rather than downloading each model on each use, try to cache it into a temporary file.
// The file's name is computed as a hash of the url.
- string name = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(url))) + ".cachedtestfile";
- string path = Path.Join(Path.GetTempPath(), name);
+ string name;
+ using (SHA256 sha256 = SHA256.Create())
+ {
+ name = BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(url))).Replace("-", string.Empty) + ".cachedtestfile";
+ }
+ string path = Path.Combine(Path.GetTempPath(), name);
if (!File.Exists(path))
{
- await using Stream responseStream = await s_client.GetStreamAsync(new Uri(url));
+ using Stream responseStream = await s_client.GetStreamAsync(new Uri(url));
try
{
- await using FileStream dest = File.OpenWrite(path);
+ using FileStream dest = File.OpenWrite(path);
await responseStream.CopyToAsync(dest);
}
catch
diff --git a/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAIAudioToTextTests.cs b/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAIAudioToTextTests.cs
index 219b5d009dbe..dd3181b9e776 100644
--- a/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAIAudioToTextTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAIAudioToTextTests.cs
@@ -36,7 +36,7 @@ public async Task OpenAIAudioToTextTestAsync()
var service = kernel.GetRequiredService();
- await using Stream audio = File.OpenRead($"./TestData/{Filename}");
+ using Stream audio = File.OpenRead($"./TestData/{Filename}");
var audioData = await BinaryData.FromStreamAsync(audio);
// Act
@@ -64,7 +64,7 @@ public async Task AzureOpenAIAudioToTextTestAsync()
var service = kernel.GetRequiredService();
- await using Stream audio = File.OpenRead($"./TestData/{Filename}");
+ using Stream audio = File.OpenRead($"./TestData/{Filename}");
var audioData = await BinaryData.FromStreamAsync(audio);
// Act
diff --git a/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAICompletionTests.cs b/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAICompletionTests.cs
index 6b07e9b7b7ba..66ec59fc653d 100644
--- a/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAICompletionTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAICompletionTests.cs
@@ -182,7 +182,7 @@ public async Task OpenAIHttpRetryPolicyTestAsync(string prompt, string expectedO
// Use a standard resiliency policy, augmented to retry on 401 Unauthorized for this example
c.AddStandardResilienceHandler().Configure(o =>
{
- o.Retry.ShouldHandle = args => ValueTask.FromResult(args.Outcome.Result?.StatusCode is HttpStatusCode.Unauthorized);
+ o.Retry.ShouldHandle = args => new ValueTask(args.Outcome.Result?.StatusCode is HttpStatusCode.Unauthorized);
});
});
Kernel target = this._kernelBuilder.Build();
@@ -219,7 +219,7 @@ public async Task AzureOpenAIHttpRetryPolicyTestAsync(string prompt, string expe
// Use a standard resiliency policy, augmented to retry on 401 Unauthorized for this example
c.AddStandardResilienceHandler().Configure(o =>
{
- o.Retry.ShouldHandle = args => ValueTask.FromResult(args.Outcome.Result?.StatusCode is HttpStatusCode.Unauthorized);
+ o.Retry.ShouldHandle = args => new ValueTask(args.Outcome.Result?.StatusCode is HttpStatusCode.Unauthorized);
});
});
@@ -348,7 +348,7 @@ public async Task AzureOpenAIHttpExceededMaxTokensShouldReturnErrorDetailAsync()
// Act
// Assert
- await Assert.ThrowsAsync(() => plugins["SummarizePlugin"]["Summarize"].InvokeAsync(target, new() { [InputParameterName] = string.Join('.', Enumerable.Range(1, 40000)) }));
+ await Assert.ThrowsAsync(() => plugins["SummarizePlugin"]["Summarize"].InvokeAsync(target, new() { [InputParameterName] = string.Join(".", Enumerable.Range(1, 40000)) }));
}
[Theory(Skip = "This test is for manual verification.")]
diff --git a/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAIToolsTests.cs b/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAIToolsTests.cs
index 7df3c32648a9..29eea5b2a100 100644
--- a/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAIToolsTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAIToolsTests.cs
@@ -547,7 +547,10 @@ public Task ConvertTemperatureAsync(double temperatureInFahrenheit)
}
}
- public record WeatherParameters(City City);
+ public class WeatherParameters(City city)
+ {
+ public City City { get; } = city;
+ }
public class City
{
diff --git a/dotnet/src/IntegrationTests/IntegrationTests.csproj b/dotnet/src/IntegrationTests/IntegrationTests.csproj
index ac04125bc9fa..adb073dfd35f 100644
--- a/dotnet/src/IntegrationTests/IntegrationTests.csproj
+++ b/dotnet/src/IntegrationTests/IntegrationTests.csproj
@@ -2,11 +2,12 @@
IntegrationTests
SemanticKernel.IntegrationTests
- net8.0
+ net8.0;net462
true
false
$(NoWarn);CA2007,CA1861,VSTHRD111,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0110
b7762d10-e29b-4bb1-8b74-b6d69a667dd4
+ annotations
diff --git a/dotnet/src/IntegrationTests/Planners/Handlebars/HandlebarsPlanTests.cs b/dotnet/src/IntegrationTests/Planners/Handlebars/HandlebarsPlanTests.cs
index f775282c69b0..f48ba4c13f39 100644
--- a/dotnet/src/IntegrationTests/Planners/Handlebars/HandlebarsPlanTests.cs
+++ b/dotnet/src/IntegrationTests/Planners/Handlebars/HandlebarsPlanTests.cs
@@ -50,7 +50,7 @@ public async Task InvokeValidPlanAsync()
public async Task InvokePlanWithHallucinatedFunctionAsync()
{
// Arrange
- var planWithInvalidHelper = PlanTemplate1.Replace("Foo-Combine", "Foo-HallucinatedHelper", StringComparison.CurrentCulture);
+ var planWithInvalidHelper = PlanTemplate1.Replace("Foo-Combine", "Foo-HallucinatedHelper");
// Act & Assert
var exception = await Assert.ThrowsAsync(async () => await this.InvokePlanAsync(planWithInvalidHelper));
diff --git a/dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs
index 1848734b6218..27c383f16e12 100644
--- a/dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs
+++ b/dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs
@@ -1,9 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
+
using System.Reflection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
+#pragma warning disable CA2016
+
public abstract class BaseTest
{
///
@@ -106,7 +109,7 @@ protected override async Task SendAsync(HttpRequestMessage
// Log the request details
if (request.Content is not null)
{
- var content = await request.Content.ReadAsStringAsync(cancellationToken);
+ var content = await request.Content.ReadAsStringAsync();
this._output.WriteLine(content);
}
@@ -116,7 +119,7 @@ protected override async Task SendAsync(HttpRequestMessage
if (response.Content is not null)
{
// Log the response details
- var responseContent = await response.Content.ReadAsStringAsync(cancellationToken);
+ var responseContent = await response.Content.ReadAsStringAsync();
this._output.WriteLine(responseContent);
}
diff --git a/dotnet/src/InternalUtilities/test/HttpMessageHandlerStub.cs b/dotnet/src/InternalUtilities/test/HttpMessageHandlerStub.cs
index 150580082a74..d41afc3680b3 100644
--- a/dotnet/src/InternalUtilities/test/HttpMessageHandlerStub.cs
+++ b/dotnet/src/InternalUtilities/test/HttpMessageHandlerStub.cs
@@ -5,12 +5,12 @@
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
-using System.Net.Mime;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-#pragma warning disable CA1812 // Internal class that is apparently never instantiated; this class is compiled in tests projects
+#pragma warning disable CA1812, CA2016
+
internal sealed class HttpMessageHandlerStub : DelegatingHandler
#pragma warning restore CA1812 // Internal class that is apparently never instantiated
{
@@ -33,7 +33,7 @@ public HttpMessageHandlerStub()
{
this.ResponseToReturn = new HttpResponseMessage(System.Net.HttpStatusCode.OK)
{
- Content = new StringContent("{}", Encoding.UTF8, MediaTypeNames.Application.Json),
+ Content = new StringContent("{}", Encoding.UTF8, "application/json"),
};
}
@@ -42,11 +42,11 @@ protected override async Task SendAsync(HttpRequestMessage
this.Method = request.Method;
this.RequestUri = request.RequestUri;
this.RequestHeaders = request.Headers;
- this.RequestContent = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync(cancellationToken);
+ this.RequestContent = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync();
if (request.Content is MultipartContent multipartContent)
{
- this.FirstMultipartContent = await multipartContent.First().ReadAsByteArrayAsync(cancellationToken);
+ this.FirstMultipartContent = await multipartContent.First().ReadAsByteArrayAsync();
}
this.ContentHeaders = request.Content?.Headers;
diff --git a/dotnet/src/InternalUtilities/test/MultipleHttpMessageHandlerStub.cs b/dotnet/src/InternalUtilities/test/MultipleHttpMessageHandlerStub.cs
index 9b8d3b9f8369..ca53fd28a68c 100644
--- a/dotnet/src/InternalUtilities/test/MultipleHttpMessageHandlerStub.cs
+++ b/dotnet/src/InternalUtilities/test/MultipleHttpMessageHandlerStub.cs
@@ -4,12 +4,11 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
-using System.Net.Mime;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-#pragma warning disable CA1812
+#pragma warning disable CA1812, CA2016
internal sealed class MultipleHttpMessageHandlerStub : DelegatingHandler
{
@@ -33,7 +32,7 @@ internal void AddJsonResponse(string json)
{
this.ResponsesToReturn.Add(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
{
- Content = new StringContent(json, Encoding.UTF8, MediaTypeNames.Application.Json)
+ Content = new StringContent(json, Encoding.UTF8, "application/json")
});
}
@@ -46,7 +45,7 @@ protected override async Task SendAsync(HttpRequestMessage
this.RequestHeaders.Add(request.Headers);
this.ContentHeaders.Add(request.Content?.Headers);
- var content = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync(cancellationToken);
+ var content = request.Content is null ? null : await request.Content.ReadAsByteArrayAsync();
this.RequestContents.Add(content);
diff --git a/dotnet/src/Planners/Planners.Handlebars.UnitTests/Handlebars/HandlebarsPlannerTests.cs b/dotnet/src/Planners/Planners.Handlebars.UnitTests/Handlebars/HandlebarsPlannerTests.cs
index 6e9d3b8aace1..deafb0fe32db 100644
--- a/dotnet/src/Planners/Planners.Handlebars.UnitTests/Handlebars/HandlebarsPlannerTests.cs
+++ b/dotnet/src/Planners/Planners.Handlebars.UnitTests/Handlebars/HandlebarsPlannerTests.cs
@@ -71,8 +71,8 @@ public async Task InvalidHandlebarsTemplateThrowsAsync()
// Act & Assert
var exception = await Assert.ThrowsAsync(async () => await planner.CreatePlanAsync(kernel, "goal"));
- Assert.True(exception?.Message?.Contains("CreatePlan failed. See inner exception for details.", StringComparison.InvariantCulture));
- Assert.True(exception?.InnerException?.Message?.Contains("Could not find the plan in the results", StringComparison.InvariantCulture));
+ Assert.True(exception?.Message?.Contains("CreatePlan failed. See inner exception for details."));
+ Assert.True(exception?.InnerException?.Message?.Contains("Could not find the plan in the results"));
Assert.Equal(exception?.ModelResults?.Content, invalidPlan);
Assert.NotNull(exception?.CreatePlanPrompt);
}
@@ -86,8 +86,7 @@ public void ItDefinesAllPartialsInlinePrompt()
var promptName = "CreatePlan";
var actualPartialsNamespace = $"{planner.GetType().Namespace}.{promptName}PromptPartials";
- var resourceNames = assemply.GetManifestResourceNames()
- .Where(name => name.Contains($"{promptName}PromptPartials", StringComparison.CurrentCulture));
+ var resourceNames = assemply.GetManifestResourceNames().Where(name => name.Contains($"{promptName}PromptPartials"));
// Act
var actualContent = planner.ReadAllPromptPartials(promptName);
@@ -227,7 +226,7 @@ public async Task ItThrowsIfStrictlyOnePlanCantBeIdentifiedAsync()
// Act & Assert
var exception = await Assert.ThrowsAsync(async () => await planner.CreatePlanAsync(kernel, "goal"));
- Assert.True(exception?.InnerException?.Message?.Contains("Identified multiple Handlebars templates in model response", StringComparison.InvariantCulture));
+ Assert.True(exception?.InnerException?.Message?.Contains("Identified multiple Handlebars templates in model response"));
}
private Kernel CreateKernelWithMockCompletionResult(string testPlanString, KernelPluginCollection? plugins = null)
diff --git a/dotnet/src/Planners/Planners.Handlebars.UnitTests/Handlebars/KernelParameterMetadataExtensionsTests.cs b/dotnet/src/Planners/Planners.Handlebars.UnitTests/Handlebars/KernelParameterMetadataExtensionsTests.cs
index b5386e0ac1dc..aa4b0756aef4 100644
--- a/dotnet/src/Planners/Planners.Handlebars.UnitTests/Handlebars/KernelParameterMetadataExtensionsTests.cs
+++ b/dotnet/src/Planners/Planners.Handlebars.UnitTests/Handlebars/KernelParameterMetadataExtensionsTests.cs
@@ -249,7 +249,7 @@ public void ReturnsIndentedJsonStringForJsonElement()
var result = jsonProperties.ToJsonString();
// Ensure that the line endings are consistent across different dotnet versions
- result = result.Replace("\r\n", "\n", StringComparison.InvariantCulture);
+ result = result.Replace("\r\n", "\n");
// Assert
var expected = "{\n \"name\": \"Alice\",\n \"age\": 25\n}";
diff --git a/dotnet/src/Planners/Planners.Handlebars.UnitTests/Planners.Handlebars.UnitTests.csproj b/dotnet/src/Planners/Planners.Handlebars.UnitTests/Planners.Handlebars.UnitTests.csproj
index 448a5c2c60ff..c6f42dca179a 100644
--- a/dotnet/src/Planners/Planners.Handlebars.UnitTests/Planners.Handlebars.UnitTests.csproj
+++ b/dotnet/src/Planners/Planners.Handlebars.UnitTests/Planners.Handlebars.UnitTests.csproj
@@ -3,7 +3,7 @@
Microsoft.SemanticKernel.Planners.Handlebars.UnitTests
Microsoft.SemanticKernel.Planners.UnitTests
- net8.0
+ net8.0;net462
true
enable
enable
diff --git a/dotnet/src/Plugins/Plugins.UnitTests/Core/FileIOPluginTests.cs b/dotnet/src/Plugins/Plugins.UnitTests/Core/FileIOPluginTests.cs
index 70b7aac4a4fc..e28af97147cc 100644
--- a/dotnet/src/Plugins/Plugins.UnitTests/Core/FileIOPluginTests.cs
+++ b/dotnet/src/Plugins/Plugins.UnitTests/Core/FileIOPluginTests.cs
@@ -31,7 +31,7 @@ public async Task ItCanReadAsync()
// Arrange
var plugin = new FileIOPlugin();
var path = Path.GetTempFileName();
- await File.WriteAllTextAsync(path, "hello world");
+ File.WriteAllText(path, "hello world");
// Act
var result = await plugin.ReadAsync(path);
@@ -69,7 +69,7 @@ public async Task ItCanWriteAsync()
await plugin.WriteAsync(path, "hello world");
// Assert
- Assert.Equal("hello world", await File.ReadAllTextAsync(path));
+ Assert.Equal("hello world", File.ReadAllText(path));
}
[Fact]
diff --git a/dotnet/src/Plugins/Plugins.UnitTests/Core/SessionsPythonPluginTests.cs b/dotnet/src/Plugins/Plugins.UnitTests/Core/SessionsPythonPluginTests.cs
index 37bb2aa4a029..508235bf13fa 100644
--- a/dotnet/src/Plugins/Plugins.UnitTests/Core/SessionsPythonPluginTests.cs
+++ b/dotnet/src/Plugins/Plugins.UnitTests/Core/SessionsPythonPluginTests.cs
@@ -207,8 +207,8 @@ public async Task ItShouldListFilesAsync()
public async Task ItShouldUploadFileAsync()
{
// Arrange
- var responseContent = await File.ReadAllTextAsync(UpdaloadFileTestDataFilePath);
- var requestPayload = await File.ReadAllBytesAsync(FileTestDataFilePath);
+ var responseContent = File.ReadAllText(UpdaloadFileTestDataFilePath);
+ var requestPayload = File.ReadAllBytes(FileTestDataFilePath);
var expectedResponse = new SessionsRemoteFileMetadata("test.txt", 680)
{
@@ -236,7 +236,7 @@ public async Task ItShouldUploadFileAsync()
public async Task ItShouldDownloadFileWithoutSavingInDiskAsync()
{
// Arrange
- var responseContent = await File.ReadAllBytesAsync(FileTestDataFilePath);
+ var responseContent = File.ReadAllBytes(FileTestDataFilePath);
this._messageHandlerStub.ResponseToReturn = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ByteArrayContent(responseContent),
@@ -255,8 +255,8 @@ public async Task ItShouldDownloadFileWithoutSavingInDiskAsync()
public async Task ItShouldDownloadFileSavingInDiskAsync()
{
// Arrange
- var responseContent = await File.ReadAllBytesAsync(FileTestDataFilePath);
- var downloadDiskPath = FileTestDataFilePath.Replace(".txt", "_download.txt", StringComparison.InvariantCultureIgnoreCase);
+ var responseContent = File.ReadAllBytes(FileTestDataFilePath);
+ var downloadDiskPath = FileTestDataFilePath.Replace(".txt", "_download.txt");
if (File.Exists(downloadDiskPath))
{
File.Delete(downloadDiskPath);
@@ -275,7 +275,7 @@ public async Task ItShouldDownloadFileSavingInDiskAsync()
// Assert
Assert.Equal(responseContent, result);
Assert.True(File.Exists(downloadDiskPath));
- Assert.Equal(responseContent, await File.ReadAllBytesAsync(downloadDiskPath));
+ Assert.Equal(responseContent, File.ReadAllBytes(downloadDiskPath));
}
public void Dispose()
diff --git a/dotnet/src/Plugins/Plugins.UnitTests/Core/TextPluginTests.cs b/dotnet/src/Plugins/Plugins.UnitTests/Core/TextPluginTests.cs
index e162750e2cf8..059f36b20246 100644
--- a/dotnet/src/Plugins/Plugins.UnitTests/Core/TextPluginTests.cs
+++ b/dotnet/src/Plugins/Plugins.UnitTests/Core/TextPluginTests.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+using System.Globalization;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.Core;
using Xunit;
diff --git a/dotnet/src/Plugins/Plugins.UnitTests/Core/TimePluginTests.cs b/dotnet/src/Plugins/Plugins.UnitTests/Core/TimePluginTests.cs
index 3df8f6d2636e..492904254074 100644
--- a/dotnet/src/Plugins/Plugins.UnitTests/Core/TimePluginTests.cs
+++ b/dotnet/src/Plugins/Plugins.UnitTests/Core/TimePluginTests.cs
@@ -85,7 +85,7 @@ public void LastMatchingDay(DayOfWeek dayName)
public static IEnumerable