Skip to content

Commit e033f15

Browse files
committed
Add more nullability to Mvc.Core
1 parent 30e468e commit e033f15

File tree

201 files changed

+1930
-2126
lines changed

Some content is hidden

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

201 files changed

+1930
-2126
lines changed

src/Mvc/Mvc.Abstractions/src/Abstractions/ActionDescriptor.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public ActionDescriptor()
2121
{
2222
Id = Guid.NewGuid().ToString();
2323
Properties = new Dictionary<object, object>();
24-
RouteValues = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
24+
RouteValues = new Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase);
2525
}
2626

2727
/// <summary>
@@ -33,7 +33,7 @@ public ActionDescriptor()
3333
/// Gets or sets the collection of route values that must be provided by routing
3434
/// for the action to be selected.
3535
/// </summary>
36-
public IDictionary<string, string> RouteValues { get; set; }
36+
public IDictionary<string, string?> RouteValues { get; set; }
3737

3838
/// <summary>
3939
/// Gets or sets the <see cref="Routing.AttributeRouteInfo"/>.

src/Mvc/Mvc.Abstractions/src/Abstractions/ParameterDescriptor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public class ParameterDescriptor
2424
/// <summary>
2525
/// Gets or sets the <see cref="ModelBinding.BindingInfo"/> for the parameter.
2626
/// </summary>
27-
public BindingInfo BindingInfo { get; set; } = default!;
27+
public BindingInfo? BindingInfo { get; set; }
2828
}
2929
}

src/Mvc/Mvc.Abstractions/src/ActionConstraints/ActionConstraintItem.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public ActionConstraintItem(IActionConstraintMetadata metadata)
2828
/// <summary>
2929
/// The <see cref="IActionConstraint"/> associated with <see cref="Metadata"/>.
3030
/// </summary>
31-
public IActionConstraint Constraint { get; set; } = default!;
31+
public IActionConstraint? Constraint { get; set; }
3232

3333
/// <summary>
3434
/// The <see cref="IActionConstraintMetadata"/> instance.
@@ -40,4 +40,4 @@ public ActionConstraintItem(IActionConstraintMetadata metadata)
4040
/// </summary>
4141
public bool IsReusable { get; set; }
4242
}
43-
}
43+
}

src/Mvc/Mvc.Abstractions/src/ActionConstraints/ActionSelectorCandidate.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public readonly struct ActionSelectorCandidate
1919
/// <param name="constraints">
2020
/// The list of <see cref="IActionConstraint"/> instances associated with <paramref name="action"/>.
2121
/// </param>
22-
public ActionSelectorCandidate(ActionDescriptor action, IReadOnlyList<IActionConstraint> constraints)
22+
public ActionSelectorCandidate(ActionDescriptor action, IReadOnlyList<IActionConstraint>? constraints)
2323
{
2424
if (action == null)
2525
{
@@ -38,6 +38,6 @@ public ActionSelectorCandidate(ActionDescriptor action, IReadOnlyList<IActionCon
3838
/// <summary>
3939
/// The list of <see cref="IActionConstraint"/> instances associated with <see name="Action"/>.
4040
/// </summary>
41-
public IReadOnlyList<IActionConstraint> Constraints { get; }
41+
public IReadOnlyList<IActionConstraint>? Constraints { get; }
4242
}
43-
}
43+
}

src/Mvc/Mvc.Abstractions/src/Filters/FilterItem.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public FilterItem(FilterDescriptor descriptor, IFilterMetadata filter)
5353
/// <summary>
5454
/// Gets or sets the executable <see cref="IFilterMetadata"/> associated with <see cref="Descriptor"/>.
5555
/// </summary>
56-
public IFilterMetadata Filter { get; set; } = default!;
56+
public IFilterMetadata? Filter { get; set; }
5757

5858
/// <summary>
5959
/// Gets or sets a value indicating whether or not <see cref="Filter"/> can be reused across requests.

src/Mvc/Mvc.Abstractions/src/Formatters/InputFormatterResult.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private InputFormatterResult(bool hasError)
2020
HasError = hasError;
2121
}
2222

23-
private InputFormatterResult(object model)
23+
private InputFormatterResult(object? model)
2424
{
2525
Model = model;
2626
IsModelSet = true;
@@ -79,7 +79,7 @@ public static Task<InputFormatterResult> FailureAsync()
7979
/// An <see cref="InputFormatterResult"/> indicating the <see cref="IInputFormatter.ReadAsync"/>
8080
/// operation succeeded i.e. with <see cref="HasError"/> <c>false</c>.
8181
/// </returns>
82-
public static InputFormatterResult Success(object model)
82+
public static InputFormatterResult Success(object? model)
8383
{
8484
return new InputFormatterResult(model);
8585
}
@@ -93,7 +93,7 @@ public static InputFormatterResult Success(object model)
9393
/// A <see cref="Task"/> that on completion provides an <see cref="InputFormatterResult"/> indicating the
9494
/// <see cref="IInputFormatter.ReadAsync"/> operation succeeded i.e. with <see cref="HasError"/> <c>false</c>.
9595
/// </returns>
96-
public static Task<InputFormatterResult> SuccessAsync(object model)
96+
public static Task<InputFormatterResult> SuccessAsync(object? model)
9797
{
9898
return Task.FromResult(Success(model));
9999
}

src/Mvc/Mvc.Abstractions/src/ModelBinding/IBinderTypeProviderMetadata.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public interface IBinderTypeProviderMetadata : IBindingSourceMetadata
1313
/// <summary>
1414
/// A <see cref="Type"/> which implements either <see cref="IModelBinder"/>.
1515
/// </summary>
16-
Type BinderType { get; }
16+
Type? BinderType { get; }
1717
}
1818
}

src/Mvc/Mvc.Abstractions/src/ModelBinding/IModelNameProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public interface IModelNameProvider
1111
/// <summary>
1212
/// Model name.
1313
/// </summary>
14-
string Name { get; }
14+
string? Name { get; }
1515
}
1616
}

src/Mvc/Mvc.Abstractions/src/PublicAPI.Unshipped.txt

+22
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,27 @@
3939
*REMOVED*virtual Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext.ActionArguments.get -> System.Collections.Generic.IDictionary<string!, object!>!
4040
*REMOVED*virtual Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.BoundConstructorInvoker.get -> System.Func<object![]!, object!>?
4141
*REMOVED*virtual Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ContainerMetadata.get -> Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata!
42+
*REMOVED*Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor.RouteValues.get -> System.Collections.Generic.IDictionary<string!, string!>!
43+
*REMOVED*Microsoft.AspNetCore.Mvc.Abstractions.ParameterDescriptor.BindingInfo.get -> Microsoft.AspNetCore.Mvc.ModelBinding.BindingInfo!
44+
*REMOVED*Microsoft.AspNetCore.Mvc.ActionConstraints.ActionConstraintItem.Constraint.get -> Microsoft.AspNetCore.Mvc.ActionConstraints.IActionConstraint!
45+
*REMOVED*Microsoft.AspNetCore.Mvc.ActionConstraints.ActionSelectorCandidate.ActionSelectorCandidate(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor! action, System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Mvc.ActionConstraints.IActionConstraint!>! constraints) -> void
46+
*REMOVED*Microsoft.AspNetCore.Mvc.ActionConstraints.ActionSelectorCandidate.Constraints.get -> System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Mvc.ActionConstraints.IActionConstraint!>!
47+
*REMOVED*Microsoft.AspNetCore.Mvc.Filters.FilterItem.Filter.get -> Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata!
48+
*REMOVED*Microsoft.AspNetCore.Mvc.ModelBinding.IBinderTypeProviderMetadata.BinderType.get -> System.Type!
49+
*REMOVED*Microsoft.AspNetCore.Mvc.ModelBinding.IModelNameProvider.Name.get -> string!
50+
*REMOVED*Microsoft.AspNetCore.Mvc.Routing.AttributeRouteInfo.Name.get -> string!
51+
*REMOVED*static Microsoft.AspNetCore.Mvc.Formatters.InputFormatterResult.Success(object! model) -> Microsoft.AspNetCore.Mvc.Formatters.InputFormatterResult!
52+
*REMOVED*static Microsoft.AspNetCore.Mvc.Formatters.InputFormatterResult.SuccessAsync(object! model) -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.Formatters.InputFormatterResult!>!
53+
Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor.RouteValues.get -> System.Collections.Generic.IDictionary<string!, string?>!
54+
Microsoft.AspNetCore.Mvc.Abstractions.ParameterDescriptor.BindingInfo.get -> Microsoft.AspNetCore.Mvc.ModelBinding.BindingInfo?
55+
Microsoft.AspNetCore.Mvc.ActionConstraints.ActionConstraintItem.Constraint.get -> Microsoft.AspNetCore.Mvc.ActionConstraints.IActionConstraint?
56+
Microsoft.AspNetCore.Mvc.ActionConstraints.ActionSelectorCandidate.ActionSelectorCandidate(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor! action, System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Mvc.ActionConstraints.IActionConstraint!>? constraints) -> void
57+
Microsoft.AspNetCore.Mvc.ActionConstraints.ActionSelectorCandidate.Constraints.get -> System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Mvc.ActionConstraints.IActionConstraint!>?
4258
Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext.ActionExecutingContext(Microsoft.AspNetCore.Mvc.ActionContext! actionContext, System.Collections.Generic.IList<Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata!>! filters, System.Collections.Generic.IDictionary<string!, object?>! actionArguments, object! controller) -> void
59+
Microsoft.AspNetCore.Mvc.Filters.FilterItem.Filter.get -> Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata?
4360
Microsoft.AspNetCore.Mvc.Formatters.OutputFormatterWriteContext.OutputFormatterWriteContext(Microsoft.AspNetCore.Http.HttpContext! httpContext, System.Func<System.IO.Stream!, System.Text.Encoding!, System.IO.TextWriter!>! writerFactory, System.Type? objectType, object? object) -> void
61+
Microsoft.AspNetCore.Mvc.ModelBinding.IBinderTypeProviderMetadata.BinderType.get -> System.Type?
62+
Microsoft.AspNetCore.Mvc.ModelBinding.IModelNameProvider.Name.get -> string?
4463
Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary.SetModelValue(string! key, object? rawValue, string? attemptedValue) -> void
4564
Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary.this[string! key].get -> Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateEntry?
4665
Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ClientValidatorItem.ClientValidatorItem(object? validatorMetadata) -> void
@@ -53,6 +72,7 @@ Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationEntry.ValidationEntry
5372
Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationEntry.ValidationEntry(Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata! metadata, string! key, object? model) -> void
5473
Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidatorItem.Validator.get -> Microsoft.AspNetCore.Mvc.ModelBinding.Validation.IModelValidator?
5574
Microsoft.AspNetCore.Mvc.ModelBinding.ValueProviderResult.ValueProviderResult(Microsoft.Extensions.Primitives.StringValues values, System.Globalization.CultureInfo? culture) -> void
75+
Microsoft.AspNetCore.Mvc.Routing.AttributeRouteInfo.Name.get -> string?
5676
abstract Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.BinderModelName.get -> string?
5777
abstract Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.BindingSource.get -> Microsoft.AspNetCore.Mvc.ModelBinding.BindingSource?
5878
abstract Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.EnterNestedScope(Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata! modelMetadata, string! fieldName, string! modelName, object? model) -> Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.NestedScope
@@ -75,6 +95,8 @@ abstract Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.PropertyGetter.get
7595
abstract Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.PropertySetter.get -> System.Action<object!, object?>?
7696
abstract Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.SimpleDisplayProperty.get -> string?
7797
abstract Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.TemplateHint.get -> string?
98+
static Microsoft.AspNetCore.Mvc.Formatters.InputFormatterResult.Success(object? model) -> Microsoft.AspNetCore.Mvc.Formatters.InputFormatterResult!
99+
static Microsoft.AspNetCore.Mvc.Formatters.InputFormatterResult.SuccessAsync(object? model) -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.Formatters.InputFormatterResult!>!
78100
virtual Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext.Result.get -> Microsoft.AspNetCore.Mvc.IActionResult?
79101
virtual Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext.ActionArguments.get -> System.Collections.Generic.IDictionary<string!, object?>!
80102
virtual Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.BoundConstructorInvoker.get -> System.Func<object?[]!, object!>?

src/Mvc/Mvc.Abstractions/src/Routing/AttributeRouteInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class AttributeRouteInfo
2727
/// to generate a link by referring to the route by name instead of attempting to match a
2828
/// route by provided route data.
2929
/// </summary>
30-
public string Name { get; set; } = default!;
30+
public string? Name { get; set; }
3131

3232
/// <summary>
3333
/// Gets or sets a value that determines if the route entry associated with this model participates in link generation.

src/Mvc/Mvc.Core/src/AcceptVerbsAttribute.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public AcceptVerbsAttribute(params string[] methods)
4848
/// <summary>
4949
/// The route template. May be null.
5050
/// </summary>
51-
public string Route { get; set; }
51+
public string? Route { get; set; }
5252

5353
/// <inheritdoc />
54-
string IRouteTemplateProvider.Template => Route;
54+
string? IRouteTemplateProvider.Template => Route;
5555

5656
/// <summary>
5757
/// Gets the route order. The order determines the order of route execution. Routes with a lower
@@ -69,6 +69,6 @@ public int Order
6969
int? IRouteTemplateProvider.Order => _order;
7070

7171
/// <inheritdoc />
72-
public string Name { get; set; }
72+
public string? Name { get; set; }
7373
}
7474
}

src/Mvc/Mvc.Core/src/AcceptedAtActionResult.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public class AcceptedAtActionResult : ObjectResult
2929
/// <param name="routeValues">The route data to use for generating the URL.</param>
3030
/// <param name="value">The value to format in the entity body.</param>
3131
public AcceptedAtActionResult(
32-
string actionName,
33-
string controllerName,
34-
object routeValues,
35-
[ActionResultObjectValue] object value)
32+
string? actionName,
33+
string? controllerName,
34+
object? routeValues,
35+
[ActionResultObjectValue] object? value)
3636
: base(value)
3737
{
3838
ActionName = actionName;
@@ -44,22 +44,22 @@ public AcceptedAtActionResult(
4444
/// <summary>
4545
/// Gets or sets the <see cref="IUrlHelper" /> used to generate URLs.
4646
/// </summary>
47-
public IUrlHelper UrlHelper { get; set; }
47+
public IUrlHelper? UrlHelper { get; set; }
4848

4949
/// <summary>
5050
/// Gets or sets the name of the action to use for generating the URL.
5151
/// </summary>
52-
public string ActionName { get; set; }
52+
public string? ActionName { get; set; }
5353

5454
/// <summary>
5555
/// Gets or sets the name of the controller to use for generating the URL.
5656
/// </summary>
57-
public string ControllerName { get; set; }
57+
public string? ControllerName { get; set; }
5858

5959
/// <summary>
6060
/// Gets or sets the route data to use for generating the URL.
6161
/// </summary>
62-
public RouteValueDictionary RouteValues { get; set; }
62+
public RouteValueDictionary? RouteValues { get; set; }
6363

6464
/// <inheritdoc />
6565
public override void OnFormatting(ActionContext context)

src/Mvc/Mvc.Core/src/AcceptedAtRouteResult.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class AcceptedAtRouteResult : ObjectResult
2626
/// </summary>
2727
/// <param name="routeValues">The route data to use for generating the URL.</param>
2828
/// <param name="value">The value to format in the entity body.</param>
29-
public AcceptedAtRouteResult(object routeValues, [ActionResultObjectValue] object value)
29+
public AcceptedAtRouteResult(object? routeValues, [ActionResultObjectValue] object? value)
3030
: this(routeName: null, routeValues: routeValues, value: value)
3131
{
3232
}
@@ -39,9 +39,9 @@ public AcceptedAtRouteResult(object routeValues, [ActionResultObjectValue] objec
3939
/// <param name="routeValues">The route data to use for generating the URL.</param>
4040
/// <param name="value">The value to format in the entity body.</param>
4141
public AcceptedAtRouteResult(
42-
string routeName,
43-
object routeValues,
44-
[ActionResultObjectValue] object value)
42+
string? routeName,
43+
object? routeValues,
44+
[ActionResultObjectValue] object? value)
4545
: base(value)
4646
{
4747
RouteName = routeName;
@@ -52,17 +52,17 @@ public AcceptedAtRouteResult(
5252
/// <summary>
5353
/// Gets or sets the <see cref="IUrlHelper" /> used to generate URLs.
5454
/// </summary>
55-
public IUrlHelper UrlHelper { get; set; }
55+
public IUrlHelper? UrlHelper { get; set; }
5656

5757
/// <summary>
5858
/// Gets or sets the name of the route to use for generating the URL.
5959
/// </summary>
60-
public string RouteName { get; set; }
60+
public string? RouteName { get; set; }
6161

6262
/// <summary>
6363
/// Gets or sets the route data to use for generating the URL.
6464
/// </summary>
65-
public RouteValueDictionary RouteValues { get; set; }
65+
public RouteValueDictionary? RouteValues { get; set; }
6666

6767
/// <inheritdoc />
6868
public override void OnFormatting(ActionContext context)

src/Mvc/Mvc.Core/src/AcceptedResult.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public AcceptedResult()
3232
/// </summary>
3333
/// <param name="location">The location at which the status of requested content can be monitored.</param>
3434
/// <param name="value">The value to format in the entity body.</param>
35-
public AcceptedResult(string location, [ActionResultObjectValue] object value)
35+
public AcceptedResult(string? location, [ActionResultObjectValue] object? value)
3636
: base(value)
3737
{
3838
Location = location;
@@ -43,10 +43,9 @@ public AcceptedResult(string location, [ActionResultObjectValue] object value)
4343
/// Initializes a new instance of the <see cref="AcceptedResult"/> class with the values
4444
/// provided.
4545
/// </summary>
46-
/// <param name="locationUri">The location at which the status of requested content can be monitored
47-
/// It is an optional parameter and may be null</param>
46+
/// <param name="locationUri">The location at which the status of requested content can be monitored.</param>
4847
/// <param name="value">The value to format in the entity body.</param>
49-
public AcceptedResult(Uri locationUri, [ActionResultObjectValue] object value)
48+
public AcceptedResult(Uri locationUri, [ActionResultObjectValue] object? value)
5049
: base(value)
5150
{
5251
if (locationUri == null)
@@ -69,7 +68,7 @@ public AcceptedResult(Uri locationUri, [ActionResultObjectValue] object value)
6968
/// <summary>
7069
/// Gets or sets the location at which the status of the requested content can be monitored.
7170
/// </summary>
72-
public string Location { get; set; }
71+
public string? Location { get; set; }
7372

7473
/// <inheritdoc />
7574
public override void OnFormatting(ActionContext context)

0 commit comments

Comments
 (0)