Skip to content

Commit e0e6fee

Browse files
Revert WebApi-CSharp changes
For some reason I don't understand, this template doesn't see Random.Shared when compiled so this reverts the previous change for this template.
1 parent e0fe9d9 commit e0e6fee

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Controllers/WeatherForecastController.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ public async Task<IEnumerable<WeatherForecast>> Get()
6868
throw new HttpRequestException($"Invalid status code in the HttpResponseMessage: {response.StatusCode}: {error}");
6969
}
7070

71+
var rng = new Random();
7172
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
7273
{
7374
Date = DateTime.Now.AddDays(index),
74-
TemperatureC = Random.Shared.Next(-20, 55),
75-
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
75+
TemperatureC = rng.Next(-20, 55),
76+
Summary = Summaries[rng.Next(Summaries.Length)]
7677
})
7778
.ToArray();
7879
}
@@ -93,11 +94,12 @@ public async Task<IEnumerable<WeatherForecast>> Get()
9394
HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi);
9495
var user = await _graphServiceClient.Me.Request().GetAsync();
9596

97+
var rng = new Random();
9698
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
9799
{
98100
Date = DateTime.Now.AddDays(index),
99-
TemperatureC = Random.Shared.Next(-20, 55),
100-
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
101+
TemperatureC = rng.Next(-20, 55),
102+
Summary = Summaries[rng.Next(Summaries.Length)]
101103
})
102104
.ToArray();
103105
}
@@ -114,11 +116,12 @@ public IEnumerable<WeatherForecast> Get()
114116
HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi);
115117

116118
#endif
119+
var rng = new Random();
117120
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
118121
{
119122
Date = DateTime.Now.AddDays(index),
120-
TemperatureC = Random.Shared.Next(-20, 55),
121-
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
123+
TemperatureC = rng.Next(-20, 55),
124+
Summary = Summaries[rng.Next(Summaries.Length)]
122125
})
123126
.ToArray();
124127
}

0 commit comments

Comments
 (0)