Skip to content

Commit 43266ad

Browse files
DGuhrstephentoub
andauthored
Fixes #248 - Add CultureInfo.InvariantCulture to string interpolation… (#249)
* 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 <[email protected]> --------- Co-authored-by: Stephen Toub <[email protected]>
1 parent 0c502c4 commit 43266ad

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

samples/QuickstartWeatherServer/Tools/WeatherTools.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using ModelContextProtocol;
22
using ModelContextProtocol.Server;
33
using System.ComponentModel;
4+
using System.Globalization;
45
using System.Text.Json;
56

67
namespace QuickstartWeatherServer.Tools;
@@ -41,7 +42,8 @@ public static async Task<string> GetForecast(
4142
[Description("Latitude of the location.")] double latitude,
4243
[Description("Longitude of the location.")] double longitude)
4344
{
44-
using var jsonDocument = await client.ReadJsonDocumentAsync($"/points/{latitude},{longitude}");
45+
var pointUrl = string.Create(CultureInfo.InvariantCulture, $"/points/{latitude},{longitude}");
46+
using var jsonDocument = await client.ReadJsonDocumentAsync(pointUrl);
4547
var forecastUrl = jsonDocument.RootElement.GetProperty("properties").GetProperty("forecast").GetString()
4648
?? throw new Exception($"No forecast URL provided by {client.BaseAddress}points/{latitude},{longitude}");
4749

0 commit comments

Comments
 (0)