From f2656adfdfa426ca10170f44b73973b9febd696a Mon Sep 17 00:00:00 2001 From: Devis Lucato Date: Mon, 25 Nov 2024 16:03:49 -0800 Subject: [PATCH] Fix build warnings --- .../dotnet-01-echo-bot.csproj | 5 ++-- .../dotnet-02-message-types-demo/MyAgent.cs | 28 +++++++++---------- .../dotnet-02-message-types-demo.csproj | 6 ++-- .../dotnet-03-simple-chatbot/MyAgent.cs | 2 +- .../dotnet-03-simple-chatbot.csproj | 6 ++-- .../dotnet/SemanticWorkbench.sln.DotSettings | 2 ++ .../AgentConfig/AgentConfigBase.cs | 10 +++---- .../WorkbenchConnector/Models/Conversation.cs | 4 +-- .../WorkbenchConnector/Models/ServiceInfo.cs | 2 +- .../WorkbenchConnector/WorkbenchConnector.cs | 8 ++++-- .../WorkbenchConnector.csproj | 6 ++-- 11 files changed, 42 insertions(+), 37 deletions(-) diff --git a/examples/dotnet/dotnet-01-echo-bot/dotnet-01-echo-bot.csproj b/examples/dotnet/dotnet-01-echo-bot/dotnet-01-echo-bot.csproj index d26fe821..aba6760c 100644 --- a/examples/dotnet/dotnet-01-echo-bot/dotnet-01-echo-bot.csproj +++ b/examples/dotnet/dotnet-01-echo-bot/dotnet-01-echo-bot.csproj @@ -6,6 +6,7 @@ enable AgentExample AgentExample + $(NoWarn);CA1515;IDE0290; @@ -27,7 +28,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -35,7 +36,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/examples/dotnet/dotnet-02-message-types-demo/MyAgent.cs b/examples/dotnet/dotnet-02-message-types-demo/MyAgent.cs index cf865fab..218fbd00 100644 --- a/examples/dotnet/dotnet-02-message-types-demo/MyAgent.cs +++ b/examples/dotnet/dotnet-02-message-types-demo/MyAgent.cs @@ -87,20 +87,20 @@ public override Task ReceiveMessageAsync( Message message, CancellationToken cancellationToken = default) { - switch (this.Config.Behavior.ToLowerInvariant()) + return this.Config.Behavior.ToLowerInvariant() switch { - case "echo": return this.EchoExampleAsync(conversationId, message, cancellationToken); - case "reverse": return this.ReverseExampleAsync(conversationId, message, cancellationToken); - case "safety check": return this.SafetyCheckExampleAsync(conversationId, message, cancellationToken); - case "markdown sample": return this.MarkdownExampleAsync(conversationId, message, cancellationToken); - case "html sample": return this.HTMLExampleAsync(conversationId, message, cancellationToken); - case "code sample": return this.CodeExampleAsync(conversationId, message, cancellationToken); - case "json sample": return this.JSONExampleAsync(conversationId, message, cancellationToken); - case "mermaid sample": return this.MermaidExampleAsync(conversationId, message, cancellationToken); - case "music sample": return this.MusicExampleAsync(conversationId, message, cancellationToken); - case "none": return this.NoneExampleAsync(conversationId, message, cancellationToken); - default: return this.NoneExampleAsync(conversationId, message, cancellationToken); - } + "echo" => this.EchoExampleAsync(conversationId, message, cancellationToken), + "reverse" => this.ReverseExampleAsync(conversationId, message, cancellationToken), + "safety check" => this.SafetyCheckExampleAsync(conversationId, message, cancellationToken), + "markdown sample" => this.MarkdownExampleAsync(conversationId, message, cancellationToken), + "html sample" => this.HTMLExampleAsync(conversationId, message, cancellationToken), + "code sample" => this.CodeExampleAsync(conversationId, message, cancellationToken), + "json sample" => this.JSONExampleAsync(conversationId, message, cancellationToken), + "mermaid sample" => this.MermaidExampleAsync(conversationId, message, cancellationToken), + "music sample" => this.MusicExampleAsync(conversationId, message, cancellationToken), + "none" => this.NoneExampleAsync(conversationId, message, cancellationToken), + _ => this.NoneExampleAsync(conversationId, message, cancellationToken) + }; } // Check text with Azure Content Safety @@ -111,7 +111,7 @@ public override Task ReceiveMessageAsync( Response? result = await this._contentSafety.AnalyzeTextAsync(text, cancellationToken).ConfigureAwait(false); bool isSafe = result.HasValue && result.Value.CategoriesAnalysis.All(x => x.Severity is 0); - IEnumerable report = result.HasValue ? result.Value.CategoriesAnalysis.Select(x => $"{x.Category}: {x.Severity}") : Array.Empty(); + IEnumerable report = result.HasValue ? result.Value.CategoriesAnalysis.Select(x => $"{x.Category}: {x.Severity}") : []; return (isSafe, report); } diff --git a/examples/dotnet/dotnet-02-message-types-demo/dotnet-02-message-types-demo.csproj b/examples/dotnet/dotnet-02-message-types-demo/dotnet-02-message-types-demo.csproj index 0610a1df..558bb740 100644 --- a/examples/dotnet/dotnet-02-message-types-demo/dotnet-02-message-types-demo.csproj +++ b/examples/dotnet/dotnet-02-message-types-demo/dotnet-02-message-types-demo.csproj @@ -6,7 +6,7 @@ enable AgentExample AgentExample - $(NoWarn);CA1308;CA1861; + $(NoWarn);CA1308;CA1861;CA1515;IDE0290; @@ -31,7 +31,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -39,7 +39,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/examples/dotnet/dotnet-03-simple-chatbot/MyAgent.cs b/examples/dotnet/dotnet-03-simple-chatbot/MyAgent.cs index a877126d..e8045e2c 100644 --- a/examples/dotnet/dotnet-03-simple-chatbot/MyAgent.cs +++ b/examples/dotnet/dotnet-03-simple-chatbot/MyAgent.cs @@ -326,7 +326,7 @@ private IChatCompletionService GetChatCompletionService() Response? result = await this._contentSafety.AnalyzeTextAsync(text, cancellationToken).ConfigureAwait(false); bool isSafe = result.HasValue && result.Value.CategoriesAnalysis.All(x => x.Severity is 0); - IEnumerable report = result.HasValue ? result.Value.CategoriesAnalysis.Select(x => $"{x.Category}: {x.Severity}") : Array.Empty(); + IEnumerable report = result.HasValue ? result.Value.CategoriesAnalysis.Select(x => $"{x.Category}: {x.Severity}") : []; return (isSafe, report); } diff --git a/examples/dotnet/dotnet-03-simple-chatbot/dotnet-03-simple-chatbot.csproj b/examples/dotnet/dotnet-03-simple-chatbot/dotnet-03-simple-chatbot.csproj index 48153dbb..76de73c4 100644 --- a/examples/dotnet/dotnet-03-simple-chatbot/dotnet-03-simple-chatbot.csproj +++ b/examples/dotnet/dotnet-03-simple-chatbot/dotnet-03-simple-chatbot.csproj @@ -6,7 +6,7 @@ enable AgentExample AgentExample - $(NoWarn);SKEXP0010;CA1861; + $(NoWarn);SKEXP0010;CA1861;CA1515;IDE0290;CA1031;CA1812; @@ -30,7 +30,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -38,7 +38,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/libraries/dotnet/SemanticWorkbench.sln.DotSettings b/libraries/dotnet/SemanticWorkbench.sln.DotSettings index e0cd1b82..cf383862 100644 --- a/libraries/dotnet/SemanticWorkbench.sln.DotSettings +++ b/libraries/dotnet/SemanticWorkbench.sln.DotSettings @@ -88,6 +88,7 @@ 512 True Copyright (c) Microsoft. All rights reserved. + ABC ACS AI AIGPT @@ -106,6 +107,7 @@ IOS JSON JWT + HTML MQ MQTT MS diff --git a/libraries/dotnet/WorkbenchConnector/AgentConfig/AgentConfigBase.cs b/libraries/dotnet/WorkbenchConnector/AgentConfig/AgentConfigBase.cs index 739d0b9b..2cb399f7 100644 --- a/libraries/dotnet/WorkbenchConnector/AgentConfig/AgentConfigBase.cs +++ b/libraries/dotnet/WorkbenchConnector/AgentConfig/AgentConfigBase.cs @@ -10,11 +10,11 @@ public abstract class AgentConfigBase { public object ToWorkbenchFormat() { - Dictionary result = new(); - Dictionary defs = new(); - Dictionary properties = new(); - Dictionary jsonSchema = new(); - Dictionary uiSchema = new(); + Dictionary result = []; + Dictionary defs = []; + Dictionary properties = []; + Dictionary jsonSchema = []; + Dictionary uiSchema = []; foreach (var property in this.GetType().GetProperties()) { diff --git a/libraries/dotnet/WorkbenchConnector/Models/Conversation.cs b/libraries/dotnet/WorkbenchConnector/Models/Conversation.cs index e437ff26..f24bbd91 100644 --- a/libraries/dotnet/WorkbenchConnector/Models/Conversation.cs +++ b/libraries/dotnet/WorkbenchConnector/Models/Conversation.cs @@ -19,11 +19,11 @@ public class Conversation [JsonPropertyName("participants")] [JsonPropertyOrder(2)] - public Dictionary Participants { get; set; } = new(); + public Dictionary Participants { get; set; } = []; [JsonPropertyName("messages")] [JsonPropertyOrder(3)] - public List Messages { get; set; } = new(); + public List Messages { get; set; } = []; public Conversation() { diff --git a/libraries/dotnet/WorkbenchConnector/Models/ServiceInfo.cs b/libraries/dotnet/WorkbenchConnector/Models/ServiceInfo.cs index 9d1e2402..8aa72b3a 100644 --- a/libraries/dotnet/WorkbenchConnector/Models/ServiceInfo.cs +++ b/libraries/dotnet/WorkbenchConnector/Models/ServiceInfo.cs @@ -19,7 +19,7 @@ public class ServiceInfo(TAgentConfig cfg) public string Description { get; set; } = string.Empty; [JsonPropertyName("metadata")] - public Dictionary Metadata { get; set; } = new(); + public Dictionary Metadata { get; set; } = []; [JsonPropertyName("default_config")] public object DefaultConfiguration => cfg.ToWorkbenchFormat() ?? new(); diff --git a/libraries/dotnet/WorkbenchConnector/WorkbenchConnector.cs b/libraries/dotnet/WorkbenchConnector/WorkbenchConnector.cs index 470b28e5..3dd3288c 100644 --- a/libraries/dotnet/WorkbenchConnector/WorkbenchConnector.cs +++ b/libraries/dotnet/WorkbenchConnector/WorkbenchConnector.cs @@ -43,9 +43,11 @@ protected WorkbenchConnector( this.Log = logger; this.Storage = storage; - this.HttpClient = new HttpClient(); - this.HttpClient.BaseAddress = new Uri(this.WorkbenchConfig.WorkbenchEndpoint); - this.Agents = new Dictionary>(); + this.HttpClient = new HttpClient + { + BaseAddress = new Uri(this.WorkbenchConfig.WorkbenchEndpoint) + }; + this.Agents = []; this.Log.LogTrace("Service instance created"); } diff --git a/libraries/dotnet/WorkbenchConnector/WorkbenchConnector.csproj b/libraries/dotnet/WorkbenchConnector/WorkbenchConnector.csproj index b51381ae..9d00bae8 100644 --- a/libraries/dotnet/WorkbenchConnector/WorkbenchConnector.csproj +++ b/libraries/dotnet/WorkbenchConnector/WorkbenchConnector.csproj @@ -9,7 +9,7 @@ enable 12 LatestMajor - $(NoWarn);IDE0130;CA2254;CA1812;CA1813; + $(NoWarn);IDE0130;CA2254;CA1812;CA1813;IDE0290; @@ -31,7 +31,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -39,7 +39,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive