From 8213645375686585492cf93b7e269422c8e4a923 Mon Sep 17 00:00:00 2001 From: Weihan Li Date: Tue, 26 Sep 2023 22:12:39 +0800 Subject: [PATCH] style: apply dotnet-format changes --- dotnet/samples/ApplicationInsightsExample/Program.cs | 6 +++--- .../KernelSyntaxExamples/Example48_GroundednessChecks.cs | 6 +++--- dotnet/samples/KernelSyntaxExamples/TestConfiguration.cs | 2 +- .../Connectors.AI.OpenAI/AzureSdk/ClientBase.cs | 8 ++++---- .../Connectors.Memory.Kusto/KustoMemoryStore.cs | 6 +++--- .../Connectors.Memory.Weaviate/WeaviateMemoryStore.cs | 2 +- .../TextCompletion/OobaboogaTextCompletionTests.cs | 8 ++++---- .../AzureChatCompletionWithDataTests.cs | 6 +++--- .../Connectors.UnitTests/WebSocketTestServer.cs | 4 ++-- .../Builders/Query/QueryStringBuilder.cs | 2 +- .../OpenAPI/Extensions/KernelAIPluginExtensionsTests.cs | 2 +- .../Connectors/Oobabooga/OobaboogaTextCompletionTests.cs | 4 ++-- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/dotnet/samples/ApplicationInsightsExample/Program.cs b/dotnet/samples/ApplicationInsightsExample/Program.cs index be2b9eec62b9..0432ef34cb83 100644 --- a/dotnet/samples/ApplicationInsightsExample/Program.cs +++ b/dotnet/samples/ApplicationInsightsExample/Program.cs @@ -31,7 +31,7 @@ public sealed class Program /// is set by default. /// will enable logging with more detailed information, including sensitive data. Should not be used in production. /// - private static LogLevel s_logLevel = LogLevel.Information; + private const LogLevel MinLogLevel = LogLevel.Information; /// /// The main entry point for the application. @@ -94,8 +94,8 @@ private static void ConfigureApplicationInsightsTelemetry(ServiceCollection serv services.AddLogging(loggingBuilder => { - loggingBuilder.AddFilter(logLevel => logLevel == s_logLevel); - loggingBuilder.SetMinimumLevel(s_logLevel); + loggingBuilder.AddFilter(logLevel => logLevel == MinLogLevel); + loggingBuilder.SetMinimumLevel(MinLogLevel); }); services.AddApplicationInsightsTelemetryWorkerService(options => diff --git a/dotnet/samples/KernelSyntaxExamples/Example48_GroundednessChecks.cs b/dotnet/samples/KernelSyntaxExamples/Example48_GroundednessChecks.cs index f006e526db02..80603a5d2fd1 100644 --- a/dotnet/samples/KernelSyntaxExamples/Example48_GroundednessChecks.cs +++ b/dotnet/samples/KernelSyntaxExamples/Example48_GroundednessChecks.cs @@ -11,7 +11,7 @@ // ReSharper disable once InconsistentNaming internal static class Example48_GroundednessChecks { - private static string s_groundingText = @"""I am by birth a Genevese, and my family is one of the most distinguished of that republic. + private const string GroundingText = @"""I am by birth a Genevese, and my family is one of the most distinguished of that republic. My ancestors had been for many years counsellors and syndics, and my father had filled several public situations with honour and reputation.He was respected by all who knew him for his integrity and indefatigable attention to public business.He passed his younger days perpetually occupied by the affairs of his country; a variety @@ -94,7 +94,7 @@ public static async Task GroundednessCheckingAsync() Console.WriteLine(extractionResult); context.Variables.Update(extractionResult); - context.Variables.Set("reference_context", s_groundingText); + context.Variables.Set("reference_context", GroundingText); var groundingResult = (await kernel.RunAsync(context.Variables, reference_check)).GetValue(); @@ -141,7 +141,7 @@ public static async Task PlanningWithGroundednessAsync() var plan = await planner.CreatePlanAsync(ask); Console.WriteLine(plan.ToPlanWithGoalString()); - var results = await kernel.RunAsync(s_groundingText, plan); + var results = await kernel.RunAsync(GroundingText, plan); Console.WriteLine(results.GetValue()); } } diff --git a/dotnet/samples/KernelSyntaxExamples/TestConfiguration.cs b/dotnet/samples/KernelSyntaxExamples/TestConfiguration.cs index f6f9a426d79d..d4f0c3b854e5 100644 --- a/dotnet/samples/KernelSyntaxExamples/TestConfiguration.cs +++ b/dotnet/samples/KernelSyntaxExamples/TestConfiguration.cs @@ -7,7 +7,7 @@ public sealed class TestConfiguration { - private IConfigurationRoot _configRoot; + private readonly IConfigurationRoot _configRoot; private static TestConfiguration? s_instance; private TestConfiguration(IConfigurationRoot configRoot) diff --git a/dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/ClientBase.cs b/dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/ClientBase.cs index dc522a78eead..84aa009b15c3 100644 --- a/dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/ClientBase.cs +++ b/dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/ClientBase.cs @@ -53,12 +53,12 @@ private protected ClientBase(ILoggerFactory? loggerFactory = null) /// /// Instance of for metrics. /// - private static Meter s_meter = new(typeof(ClientBase).Assembly.GetName().Name); + private static readonly Meter s_meter = new(typeof(ClientBase).Assembly.GetName().Name); /// /// Instance of to keep track of the number of prompt tokens used. /// - private static Counter s_promptTokensCounter = + private static readonly Counter s_promptTokensCounter = s_meter.CreateCounter( name: "SK.Connectors.OpenAI.PromptTokens", description: "Number of prompt tokens used"); @@ -66,7 +66,7 @@ private protected ClientBase(ILoggerFactory? loggerFactory = null) /// /// Instance of to keep track of the number of completion tokens used. /// - private static Counter s_completionTokensCounter = + private static readonly Counter s_completionTokensCounter = s_meter.CreateCounter( name: "SK.Connectors.OpenAI.CompletionTokens", description: "Number of completion tokens used"); @@ -74,7 +74,7 @@ private protected ClientBase(ILoggerFactory? loggerFactory = null) /// /// Instance of to keep track of the total number of tokens used. /// - private static Counter s_totalTokensCounter = + private static readonly Counter s_totalTokensCounter = s_meter.CreateCounter( name: "SK.Connectors.OpenAI.TotalTokens", description: "Total number of tokens used"); diff --git a/dotnet/src/Connectors/Connectors.Memory.Kusto/KustoMemoryStore.cs b/dotnet/src/Connectors/Connectors.Memory.Kusto/KustoMemoryStore.cs index ae9a4a314115..bab93a542d99 100644 --- a/dotnet/src/Connectors/Connectors.Memory.Kusto/KustoMemoryStore.cs +++ b/dotnet/src/Connectors/Connectors.Memory.Kusto/KustoMemoryStore.cs @@ -320,10 +320,10 @@ protected virtual void Dispose(bool disposing) #region private ================================================================================ - private Disposer _disposer; - private object _lock = new(); + private readonly Disposer _disposer; + private readonly object _lock = new(); - private string _database; + private readonly string _database; private static ClientRequestProperties GetClientRequestProperties() => new() { diff --git a/dotnet/src/Connectors/Connectors.Memory.Weaviate/WeaviateMemoryStore.cs b/dotnet/src/Connectors/Connectors.Memory.Weaviate/WeaviateMemoryStore.cs index cfe425ac775a..821200b61968 100644 --- a/dotnet/src/Connectors/Connectors.Memory.Weaviate/WeaviateMemoryStore.cs +++ b/dotnet/src/Connectors/Connectors.Memory.Weaviate/WeaviateMemoryStore.cs @@ -56,7 +56,7 @@ public class WeaviateMemoryStore : IMemoryStore private readonly ILogger _logger; private readonly Uri? _endpoint = null; private readonly string? _apiVersion; - private string? _apiKey; + private readonly string? _apiKey; /// /// Initializes a new instance of the class. diff --git a/dotnet/src/Connectors/Connectors.UnitTests/Oobabooga/TextCompletion/OobaboogaTextCompletionTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/Oobabooga/TextCompletion/OobaboogaTextCompletionTests.cs index b4df6faaee53..acdc0f5d40f5 100644 --- a/dotnet/src/Connectors/Connectors.UnitTests/Oobabooga/TextCompletion/OobaboogaTextCompletionTests.cs +++ b/dotnet/src/Connectors/Connectors.UnitTests/Oobabooga/TextCompletion/OobaboogaTextCompletionTests.cs @@ -31,10 +31,10 @@ public sealed class OobaboogaTextCompletionTests : IDisposable private const string CompletionText = "fake-test"; private const string CompletionMultiText = "Hello, my name is"; - private HttpMessageHandlerStub _messageHandlerStub; - private HttpClient _httpClient; - private Uri _endPointUri; - private string _streamCompletionResponseStub; + private readonly HttpMessageHandlerStub _messageHandlerStub; + private readonly HttpClient _httpClient; + private readonly Uri _endPointUri; + private readonly string _streamCompletionResponseStub; public OobaboogaTextCompletionTests(ITestOutputHelper output) { diff --git a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/ChatCompletionWithData/AzureChatCompletionWithDataTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/ChatCompletionWithData/AzureChatCompletionWithDataTests.cs index 3625470d8749..e3cdc12654e6 100644 --- a/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/ChatCompletionWithData/AzureChatCompletionWithDataTests.cs +++ b/dotnet/src/Connectors/Connectors.UnitTests/OpenAI/ChatCompletionWithData/AzureChatCompletionWithDataTests.cs @@ -15,10 +15,10 @@ namespace SemanticKernel.Connectors.UnitTests.OpenAI.ChatCompletionWithData; /// public sealed class AzureChatCompletionWithDataTests : IDisposable { - private AzureChatCompletionWithDataConfig _config; + private readonly AzureChatCompletionWithDataConfig _config; - private HttpMessageHandlerStub _messageHandlerStub; - private HttpClient _httpClient; + private readonly HttpMessageHandlerStub _messageHandlerStub; + private readonly HttpClient _httpClient; public AzureChatCompletionWithDataTests() { diff --git a/dotnet/src/Connectors/Connectors.UnitTests/WebSocketTestServer.cs b/dotnet/src/Connectors/Connectors.UnitTests/WebSocketTestServer.cs index 7b85d192197a..c833797f3219 100644 --- a/dotnet/src/Connectors/Connectors.UnitTests/WebSocketTestServer.cs +++ b/dotnet/src/Connectors/Connectors.UnitTests/WebSocketTestServer.cs @@ -21,13 +21,13 @@ internal class WebSocketTestServer : IDisposable private readonly CancellationTokenSource _socketCancellationTokenSource; private bool _serverIsRunning; - private Func, List>> _arraySegmentHandler; + private readonly Func, List>> _arraySegmentHandler; private readonly ConcurrentDictionary> _requestContentQueues; private readonly ConcurrentBag _runningTasks = new(); private readonly ConcurrentDictionary _clients = new(); - private Task? _handleRequestTask = null; + private readonly Task? _handleRequestTask = null; public TimeSpan RequestProcessingDelay { get; set; } = TimeSpan.Zero; public TimeSpan SegmentMessageDelay { get; set; } = TimeSpan.Zero; diff --git a/dotnet/src/Functions/Functions.OpenAPI/Builders/Query/QueryStringBuilder.cs b/dotnet/src/Functions/Functions.OpenAPI/Builders/Query/QueryStringBuilder.cs index 25a1f41e1fb4..1729a67970cd 100644 --- a/dotnet/src/Functions/Functions.OpenAPI/Builders/Query/QueryStringBuilder.cs +++ b/dotnet/src/Functions/Functions.OpenAPI/Builders/Query/QueryStringBuilder.cs @@ -17,7 +17,7 @@ internal sealed class QueryStringBuilder : IQueryStringBuilder /// /// Query string parameter serializers. /// - private static Dictionary> s_queryStringParameterSerializers = new() + private static readonly Dictionary> s_queryStringParameterSerializers = new() { { RestApiOperationParameterStyle.Form, FormStyleParameterSerializer.Serialize }, { RestApiOperationParameterStyle.SpaceDelimited, SpaceDelimitedStyleParameterSerializer.Serialize }, diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenAPI/Extensions/KernelAIPluginExtensionsTests.cs b/dotnet/src/Functions/Functions.UnitTests/OpenAPI/Extensions/KernelAIPluginExtensionsTests.cs index c6d189a48b98..8bf214de75d2 100644 --- a/dotnet/src/Functions/Functions.UnitTests/OpenAPI/Extensions/KernelAIPluginExtensionsTests.cs +++ b/dotnet/src/Functions/Functions.UnitTests/OpenAPI/Extensions/KernelAIPluginExtensionsTests.cs @@ -30,7 +30,7 @@ public sealed class KernelAIPluginExtensionsTests : IDisposable /// /// IKernel instance. /// - private IKernel _kernel; + private readonly IKernel _kernel; /// /// Creates an instance of a class. diff --git a/dotnet/src/IntegrationTests/Connectors/Oobabooga/OobaboogaTextCompletionTests.cs b/dotnet/src/IntegrationTests/Connectors/Oobabooga/OobaboogaTextCompletionTests.cs index c37a627d0a41..c6841a2fe5e2 100644 --- a/dotnet/src/IntegrationTests/Connectors/Oobabooga/OobaboogaTextCompletionTests.cs +++ b/dotnet/src/IntegrationTests/Connectors/Oobabooga/OobaboogaTextCompletionTests.cs @@ -23,8 +23,8 @@ public sealed class OobaboogaTextCompletionTests : IDisposable private const int StreamingPort = 5005; private readonly IConfigurationRoot _configuration; - private List _webSockets = new(); - private Func _webSocketFactory; + private readonly List _webSockets = new(); + private readonly Func _webSocketFactory; public OobaboogaTextCompletionTests() {