Skip to content

Commit e79d740

Browse files
authored
Enable nullable on Diagnostics and Rewrite middleware (#28621)
1 parent 09a036f commit e79d740

File tree

105 files changed

+423
-509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+423
-509
lines changed

src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
#nullable enable
5-
64
using System;
75
using Microsoft.AspNetCore.Diagnostics;
86
using Microsoft.Extensions.Options;

src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
#nullable enable
5-
64
using System;
75
using System.Collections.Generic;
86
using System.Diagnostics;
@@ -165,10 +163,7 @@ private Task DisplayCompilationException(
165163
HttpContext context,
166164
ICompilationException compilationException)
167165
{
168-
var model = new CompilationErrorPageModel
169-
{
170-
Options = _options,
171-
};
166+
var model = new CompilationErrorPageModel(_options);
172167

173168
var errorPage = new CompilationErrorPage
174169
{

src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageOptions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
#nullable enable
5-
64
using Microsoft.AspNetCore.Diagnostics;
75
using Microsoft.Extensions.FileProviders;
86

src/Middleware/Diagnostics/src/DeveloperExceptionPage/Views/CompilationErrorModel.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ namespace Microsoft.AspNetCore.Diagnostics.RazorViews
1212
/// </summary>
1313
internal class CompilationErrorPageModel
1414
{
15+
public CompilationErrorPageModel(DeveloperExceptionPageOptions options)
16+
{
17+
Options = options;
18+
}
19+
1520
/// <summary>
1621
/// Options for what output to display.
1722
/// </summary>
18-
public DeveloperExceptionPageOptions Options { get; set; }
23+
public DeveloperExceptionPageOptions Options { get; }
1924

2025
/// <summary>
2126
/// Detailed information about each parse or compilation error.
@@ -25,6 +30,6 @@ internal class CompilationErrorPageModel
2530
/// <summary>
2631
/// Gets the generated content that produced the corresponding <see cref="ErrorDetails"/>.
2732
/// </summary>
28-
public IList<string> CompiledContent { get; } = new List<string>();
33+
public IList<string?> CompiledContent { get; } = new List<string?>();
2934
}
30-
}
35+
}

src/Middleware/Diagnostics/src/DeveloperExceptionPage/Views/EndpointModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ namespace Microsoft.AspNetCore.Diagnostics.RazorViews
55
{
66
internal class EndpointModel
77
{
8-
public string DisplayName { get; set; }
9-
public string RoutePattern { get; set; }
8+
public string? DisplayName { get; set; }
9+
public string? RoutePattern { get; set; }
1010
public int? Order { get; set; }
11-
public string HttpMethods { get; set; }
11+
public string? HttpMethods { get; set; }
1212
}
1313
}

src/Middleware/Diagnostics/src/DiagnosticsLoggerExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ internal static class DiagnosticsLoggerExtensions
1313
LoggerMessage.Define(LogLevel.Error, new EventId(1, "UnhandledException"), "An unhandled exception has occurred while executing the request.");
1414

1515
// ExceptionHandlerMiddleware
16-
private static readonly Action<ILogger, Exception> _responseStartedErrorHandler =
16+
private static readonly Action<ILogger, Exception?> _responseStartedErrorHandler =
1717
LoggerMessage.Define(LogLevel.Warning, new EventId(2, "ResponseStarted"), "The response has already started, the error handler will not be executed.");
1818

1919
private static readonly Action<ILogger, Exception> _errorHandlerException =
2020
LoggerMessage.Define(LogLevel.Error, new EventId(3, "Exception"), "An exception was thrown attempting to execute the error handler.");
2121

22-
private static readonly Action<ILogger, Exception> _errorHandlerNotFound =
22+
private static readonly Action<ILogger, Exception?> _errorHandlerNotFound =
2323
LoggerMessage.Define(LogLevel.Warning, new EventId(4, "HandlerNotFound"), "No exception handler was found, rethrowing original exception.");
2424

2525
// DeveloperExceptionPageMiddleware
26-
private static readonly Action<ILogger, Exception> _responseStartedErrorPageMiddleware =
26+
private static readonly Action<ILogger, Exception?> _responseStartedErrorPageMiddleware =
2727
LoggerMessage.Define(LogLevel.Warning, new EventId(2, "ResponseStarted"), "The response has already started, the error page middleware will not be executed.");
2828

2929
private static readonly Action<ILogger, Exception> _displayErrorPageException =

src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
#nullable enable
5-
64
using System;
75
using Microsoft.AspNetCore.Diagnostics;
86
using Microsoft.AspNetCore.Http;

src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerFeature.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
#nullable enable
5-
64
using System;
75

86
namespace Microsoft.AspNetCore.Diagnostics

src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerMiddleware.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
#nullable enable
5-
64
using System;
75
using System.Diagnostics;
86
using System.Runtime.ExceptionServices;

src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerOptions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using Microsoft.AspNetCore.Diagnostics;
5-
#nullable enable
6-
75
using Microsoft.AspNetCore.Http;
86

97
namespace Microsoft.AspNetCore.Builder

0 commit comments

Comments
 (0)