From 43266ad26877ed8fb4a31c52e782a19030757144 Mon Sep 17 00:00:00 2001 From: Dominik Guhr Date: Wed, 9 Apr 2025 15:08:27 +0200 Subject: [PATCH] =?UTF-8?q?Fixes=20#248=20-=20Add=20CultureInfo.InvariantC?= =?UTF-8?q?ulture=20to=20string=20interpolation=E2=80=A6=20(#249)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixes #248 - Add CultureInfo.InvariantCulture to string interpolation for langitude and longitude so the sample works everywhere. * Update samples/QuickstartWeatherServer/Tools/WeatherTools.cs Co-authored-by: Stephen Toub --------- Co-authored-by: Stephen Toub --- samples/QuickstartWeatherServer/Tools/WeatherTools.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/QuickstartWeatherServer/Tools/WeatherTools.cs b/samples/QuickstartWeatherServer/Tools/WeatherTools.cs index 5554895..563d178 100644 --- a/samples/QuickstartWeatherServer/Tools/WeatherTools.cs +++ b/samples/QuickstartWeatherServer/Tools/WeatherTools.cs @@ -1,6 +1,7 @@ using ModelContextProtocol; using ModelContextProtocol.Server; using System.ComponentModel; +using System.Globalization; using System.Text.Json; namespace QuickstartWeatherServer.Tools; @@ -41,7 +42,8 @@ public sealed class WeatherTools [Description("Latitude of the location.")] double latitude, [Description("Longitude of the location.")] double longitude) { - using var jsonDocument = await client.ReadJsonDocumentAsync($"/points/{latitude},{longitude}"); + var pointUrl = string.Create(CultureInfo.InvariantCulture, $"/points/{latitude},{longitude}"); + using var jsonDocument = await client.ReadJsonDocumentAsync(pointUrl); var forecastUrl = jsonDocument.RootElement.GetProperty("properties").GetProperty("forecast").GetString() ?? throw new Exception($"No forecast URL provided by {client.BaseAddress}points/{latitude},{longitude}");