Skip to content

Commit

Permalink
Nullable Examples.AspNet (#1353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek authored Sep 16, 2023
1 parent 2960a9d commit b3c7ae7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
12 changes: 5 additions & 7 deletions examples/AspNet/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,10 @@ public async Task<HttpResponseMessage> PostData()
private static IEnumerable<WeatherForecast> GetWeatherForecast()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)],
})
return Enumerable.Range(1, 5).Select(index => new WeatherForecast(
date: DateTime.Now.AddDays(index),
temperatureC: rng.Next(-20, 55),
summary: Summaries[rng.Next(Summaries.Length)]))
.ToArray();
}

Expand Down Expand Up @@ -218,7 +216,7 @@ private async Task RequestValidThatSpawnsSubSpansViaHttpClient()
response.EnsureSuccessStatusCode();
}

private Uri GenerateContentRequestUri(string path, Func<string, string> transform = null)
private Uri GenerateContentRequestUri(string path, Func<string, string>? transform = null)
{
var rawUri = this.Url.Content(path);

Expand Down
1 change: 0 additions & 1 deletion examples/AspNet/Examples.AspNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<AppConfig>web.config</AppConfig>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Include="DotNetCoreWeb" />
Expand Down
4 changes: 2 additions & 2 deletions examples/AspNet/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace Examples.AspNet;
public class WebApiApplication : HttpApplication
#pragma warning restore SA1649 // File name should match first type name
{
private IDisposable tracerProvider;
private IDisposable meterProvider;
private IDisposable? tracerProvider;
private IDisposable? meterProvider;

protected void Application_Start()
{
Expand Down
13 changes: 9 additions & 4 deletions examples/AspNet/Models/WeatherForecast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ namespace Examples.AspNet.Models;

public class WeatherForecast
{
public DateTime Date { get; set; }
public WeatherForecast(DateTime date, int temperatureC, string summary)
{
this.Date = date;
this.TemperatureC = temperatureC;
this.Summary = summary;
}

public int TemperatureC { get; set; }
public DateTime Date { get; }

public int TemperatureF => 32 + (int)(this.TemperatureC / 0.5556);
public int TemperatureC { get; }

public string Summary { get; set; }
public string Summary { get; }
}
2 changes: 1 addition & 1 deletion examples/AspNet/SuppressInstrumentationHttpModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Examples.AspNet;
/// </summary>
public class SuppressInstrumentationHttpModule : IHttpModule
{
private IDisposable suppressionScope;
private IDisposable? suppressionScope;

public void Init(HttpApplication context)
{
Expand Down

0 comments on commit b3c7ae7

Please sign in to comment.