Merge pull request #25277 from dotnet/prkrishn/nullability-feedback

Address nullability feedback
This commit is contained in:
Artak 2020-08-28 15:30:22 -07:00 committed by GitHub
commit 0ebd5f040b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 47 additions and 47 deletions

View File

@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
return new CircuitId(Base64UrlTextEncoder.Encode(secret), Base64UrlTextEncoder.Encode(id));
}
public bool TryParseCircuitId(string text, out CircuitId circuitId)
public bool TryParseCircuitId(string? text, out CircuitId circuitId)
{
if (text is null)
{

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
/// <summary>
/// Notifies when a rendering exception occurred.
/// </summary>
public event EventHandler<Exception> UnhandledException;
public event EventHandler<Exception>? UnhandledException;
/// <summary>
/// Creates a new <see cref="RemoteRenderer"/>.
@ -171,7 +171,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
pendingRender = new UnacknowledgedRenderBatch(
renderId,
arrayBuilder,
new TaskCompletionSource<object>(),
new TaskCompletionSource(),
ValueStopwatch.StartNew());
// Buffer the rendered batches no matter what. We'll send it down immediately when the client
@ -234,7 +234,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
// disposed.
}
public Task OnRenderCompletedAsync(long incomingBatchId, string errorMessageOrNull)
public Task OnRenderCompletedAsync(long incomingBatchId, string? errorMessageOrNull)
{
if (_disposing)
{
@ -308,7 +308,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
}
}
private void ProcessPendingBatch(string errorMessageOrNull, UnacknowledgedRenderBatch entry)
private void ProcessPendingBatch(string? errorMessageOrNull, UnacknowledgedRenderBatch entry)
{
var elapsedTime = entry.ValueStopwatch.GetElapsedTime();
if (errorMessageOrNull == null)
@ -324,11 +324,11 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
CompleteRender(entry.CompletionSource, errorMessageOrNull);
}
private void CompleteRender(TaskCompletionSource<object> pendingRenderInfo, string errorMessageOrNull)
private void CompleteRender(TaskCompletionSource pendingRenderInfo, string? errorMessageOrNull)
{
if (errorMessageOrNull == null)
{
pendingRenderInfo.TrySetResult(null);
pendingRenderInfo.TrySetResult();
}
else
{
@ -338,7 +338,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
internal readonly struct UnacknowledgedRenderBatch
{
public UnacknowledgedRenderBatch(long batchId, ArrayBuilder<byte> data, TaskCompletionSource<object> completionSource, ValueStopwatch valueStopwatch)
public UnacknowledgedRenderBatch(long batchId, ArrayBuilder<byte> data, TaskCompletionSource completionSource, ValueStopwatch valueStopwatch)
{
BatchId = batchId;
Data = data;
@ -348,7 +348,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
public long BatchId { get; }
public ArrayBuilder<byte> Data { get; }
public TaskCompletionSource<object> CompletionSource { get; }
public TaskCompletionSource CompletionSource { get; }
public ValueStopwatch ValueStopwatch { get; }
}

View File

@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Components.RenderTree
{
/// <summary>
/// Implements a list that uses an array of objects to store the elements.
///
///
/// This differs from a <see cref="System.Collections.Generic.List{T}"/> in that
/// it not only grows as required but also shrinks if cleared with significant
/// excess capacity. This makes it useful for component rendering, because

View File

@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore
/// <param name="app">A delegate that handles requests to the application.</param>
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
public static IWebHost Start(RequestDelegate app) =>
Start(url: null, app: app);
Start(url: null!, app: app);
/// <summary>
/// Initializes and starts a new <see cref="IWebHost"/> with pre-configured defaults.
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore
/// <param name="url">The URL the hosted application will listen on.</param>
/// <param name="app">A delegate that handles requests to the application.</param>
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
public static IWebHost Start(string? url, RequestDelegate app)
public static IWebHost Start(string url, RequestDelegate app)
{
var startupAssemblyName = app.GetMethodInfo().DeclaringType!.GetTypeInfo().Assembly.GetName().Name;
return StartWith(url: url, configureServices: null, app: appBuilder => appBuilder.Run(app), applicationName: startupAssemblyName);
@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore
/// <param name="routeBuilder">A delegate that configures the router for handling requests to the application.</param>
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
public static IWebHost Start(Action<IRouteBuilder> routeBuilder) =>
Start(url: null, routeBuilder: routeBuilder);
Start(url: null!, routeBuilder: routeBuilder);
/// <summary>
/// Initializes and starts a new <see cref="IWebHost"/> with pre-configured defaults.
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore
/// <param name="url">The URL the hosted application will listen on.</param>
/// <param name="routeBuilder">A delegate that configures the router for handling requests to the application.</param>
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
public static IWebHost Start(string? url, Action<IRouteBuilder> routeBuilder)
public static IWebHost Start(string url, Action<IRouteBuilder> routeBuilder)
{
var startupAssemblyName = routeBuilder.GetMethodInfo().DeclaringType!.GetTypeInfo().Assembly.GetName().Name;
return StartWith(url, services => services.AddRouting(), appBuilder => appBuilder.UseRouter(routeBuilder), applicationName: startupAssemblyName);
@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore
/// <param name="app">The delegate that configures the <see cref="IApplicationBuilder"/>.</param>
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
public static IWebHost StartWith(Action<IApplicationBuilder> app) =>
StartWith(url: null, app: app);
StartWith(url: null!, app: app);
/// <summary>
/// Initializes and starts a new <see cref="IWebHost"/> with pre-configured defaults.
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore
/// <param name="url">The URL the hosted application will listen on.</param>
/// <param name="app">The delegate that configures the <see cref="IApplicationBuilder"/>.</param>
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
public static IWebHost StartWith(string? url, Action<IApplicationBuilder> app) =>
public static IWebHost StartWith(string url, Action<IApplicationBuilder> app) =>
StartWith(url: url, configureServices: null, app: app, applicationName: null);
private static IWebHost StartWith(string? url, Action<IServiceCollection>? configureServices, Action<IApplicationBuilder> app, string? applicationName)
@ -132,7 +132,7 @@ namespace Microsoft.AspNetCore
/// </remarks>
/// <returns>The initialized <see cref="IWebHostBuilder"/>.</returns>
public static IWebHostBuilder CreateDefaultBuilder() =>
CreateDefaultBuilder(args: null);
CreateDefaultBuilder(args: null!);
/// <summary>
/// Initializes a new instance of the <see cref="WebHostBuilder"/> class with pre-configured defaults.
@ -153,7 +153,7 @@ namespace Microsoft.AspNetCore
/// </remarks>
/// <param name="args">The command line args.</param>
/// <returns>The initialized <see cref="IWebHostBuilder"/>.</returns>
public static IWebHostBuilder CreateDefaultBuilder(string[]? args)
public static IWebHostBuilder CreateDefaultBuilder(string[] args)
{
var builder = new WebHostBuilder();

View File

@ -16,6 +16,6 @@ namespace Microsoft.AspNetCore.Hosting.Server
/// <summary>
/// The name of the authentication scheme for the server authentication handler.
/// </summary>
string? AuthenticationScheme { get; }
string AuthenticationScheme { get; }
}
}

View File

@ -16,6 +16,6 @@ namespace Microsoft.AspNetCore.Hosting.Server
/// <summary>
/// The name of the authentication scheme for the server authentication handler.
/// </summary>
public string? AuthenticationScheme { get; set; }
public string AuthenticationScheme { get; set; } = default!;
}
}

View File

@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.Authentication
/// </summary>
/// <param name="failure">The failure exception.</param>
/// <returns>The result.</returns>
public static AuthenticateResult Fail(Exception? failure)
public static AuthenticateResult Fail(Exception failure)
{
return new AuthenticateResult() { Failure = failure };
}
@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Authentication
/// <param name="failure">The failure exception.</param>
/// <param name="properties">Additional state values for the authentication session.</param>
/// <returns>The result.</returns>
public static AuthenticateResult Fail(Exception? failure, AuthenticationProperties? properties)
public static AuthenticateResult Fail(Exception failure, AuthenticationProperties? properties)
{
return new AuthenticateResult() { Failure = failure, Properties = properties };
}
@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Authentication
/// </summary>
/// <param name="failureMessage">The failure message.</param>
/// <returns>The result.</returns>
public static AuthenticateResult Fail(string? failureMessage)
public static AuthenticateResult Fail(string failureMessage)
=> Fail(new Exception(failureMessage));
/// <summary>
@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Authentication
/// <param name="failureMessage">The failure message.</param>
/// <param name="properties">Additional state values for the authentication session.</param>
/// <returns>The result.</returns>
public static AuthenticateResult Fail(string? failureMessage, AuthenticationProperties? properties)
public static AuthenticateResult Fail(string failureMessage, AuthenticationProperties? properties)
=> Fail(new Exception(failureMessage), properties);
}
}

View File

@ -12,11 +12,11 @@ namespace Microsoft.AspNetCore.Authentication
/// <summary>
/// Name.
/// </summary>
public string? Name { get; set; }
public string Name { get; set; } = default!;
/// <summary>
/// Value.
/// </summary>
public string? Value { get; set; }
public string Value { get; set; } = default!;
}
}

View File

@ -16,7 +16,7 @@ namespace Microsoft.JSInterop
/// <param name="jsRuntime">The <see cref="IJSInProcessRuntime"/>.</param>
/// <param name="identifier">An identifier for the function to invoke. For example, the value <c>"someScope.someFunction"</c> will invoke the function <c>window.someScope.someFunction</c>.</param>
/// <param name="args">JSON-serializable arguments.</param>
public static void InvokeVoid(this IJSInProcessRuntime jsRuntime, string identifier, params object[] args)
public static void InvokeVoid(this IJSInProcessRuntime jsRuntime, string identifier, params object?[] args)
{
if (jsRuntime == null)
{

View File

@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Mvc
/// your deployment environment.
/// </para>
/// </remarks>
string Action(UrlActionContext actionContext);
string? Action(UrlActionContext actionContext);
/// <summary>
/// Converts a virtual (relative, starting with ~/) path to an application absolute path.
@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Mvc
/// </remarks>
/// <param name="contentPath">The virtual path of the content.</param>
/// <returns>The application absolute path.</returns>
string Content(string contentPath);
string? Content(string? contentPath);
/// <summary>
/// Returns a value that indicates whether the URL is local. A URL is considered local if it does not have a
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Mvc
/// </code>
/// </para>
/// </example>
bool IsLocalUrl(string url);
bool IsLocalUrl(string? url);
/// <summary>
/// Generates a URL with an absolute path, which contains the route name, route values, protocol to use, host
@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.Mvc
/// your deployment environment.
/// </para>
/// </remarks>
string RouteUrl(UrlRouteContext routeContext);
string? RouteUrl(UrlRouteContext routeContext);
/// <summary>
/// Generates an absolute URL for the specified <paramref name="routeName"/> and route
@ -99,11 +99,11 @@ namespace Microsoft.AspNetCore.Mvc
/// <remarks>
/// <para>
/// This method uses the value of <see cref="HttpRequest.Host"/> to populate the host section of the generated URI.
/// Relying on the value of the current request can allow untrusted input to influence the resulting URI unless
/// the <c>Host</c> header has been validated. See the deployment documentation for instructions on how to properly
/// Relying on the value of the current request can allow untrusted input to influence the resulting URI unless
/// the <c>Host</c> header has been validated. See the deployment documentation for instructions on how to properly
/// validate the <c>Host</c> header in your deployment environment.
/// </para>
/// </remarks>
string Link(string routeName, object values);
string? Link(string? routeName, object? values);
}
}

View File

@ -14,6 +14,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
/// </summary>
/// <param name="context">The <see cref="ModelBinderProviderContext"/>.</param>
/// <returns>An <see cref="IModelBinder"/>.</returns>
IModelBinder GetBinder(ModelBinderProviderContext context);
IModelBinder? GetBinder(ModelBinderProviderContext context);
}
}

View File

@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
/// </summary>
/// <param name="model">The model value. May be <c>null.</c></param>
/// <returns>A <see cref="ModelBindingResult"/> representing a successful model bind.</returns>
public static ModelBindingResult Success(object model)
public static ModelBindingResult Success(object? model)
{
return new ModelBindingResult(model, isModelSet: true);
}

View File

@ -290,12 +290,12 @@ Microsoft.AspNetCore.Mvc.Formatters.OutputFormatterWriteContext.OutputFormatterW
Microsoft.AspNetCore.Mvc.IActionResult
Microsoft.AspNetCore.Mvc.IActionResult.ExecuteResultAsync(Microsoft.AspNetCore.Mvc.ActionContext! context) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Mvc.IUrlHelper
Microsoft.AspNetCore.Mvc.IUrlHelper.Action(Microsoft.AspNetCore.Mvc.Routing.UrlActionContext! actionContext) -> string!
Microsoft.AspNetCore.Mvc.IUrlHelper.Action(Microsoft.AspNetCore.Mvc.Routing.UrlActionContext! actionContext) -> string?
Microsoft.AspNetCore.Mvc.IUrlHelper.ActionContext.get -> Microsoft.AspNetCore.Mvc.ActionContext!
Microsoft.AspNetCore.Mvc.IUrlHelper.Content(string! contentPath) -> string!
Microsoft.AspNetCore.Mvc.IUrlHelper.IsLocalUrl(string! url) -> bool
Microsoft.AspNetCore.Mvc.IUrlHelper.Link(string! routeName, object! values) -> string!
Microsoft.AspNetCore.Mvc.IUrlHelper.RouteUrl(Microsoft.AspNetCore.Mvc.Routing.UrlRouteContext! routeContext) -> string!
Microsoft.AspNetCore.Mvc.IUrlHelper.Content(string? contentPath) -> string?
Microsoft.AspNetCore.Mvc.IUrlHelper.IsLocalUrl(string? url) -> bool
Microsoft.AspNetCore.Mvc.IUrlHelper.Link(string? routeName, object? values) -> string?
Microsoft.AspNetCore.Mvc.IUrlHelper.RouteUrl(Microsoft.AspNetCore.Mvc.Routing.UrlRouteContext! routeContext) -> string?
Microsoft.AspNetCore.Mvc.ModelBinding.BindingInfo
Microsoft.AspNetCore.Mvc.ModelBinding.BindingInfo.BinderModelName.get -> string?
Microsoft.AspNetCore.Mvc.ModelBinding.BindingInfo.BinderModelName.set -> void
@ -337,7 +337,7 @@ Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata.BindingSource.get -
Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinder
Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinder.BindModelAsync(Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext! bindingContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinderProvider
Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinderProvider.GetBinder(Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderProviderContext! context) -> Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinder!
Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinderProvider.GetBinder(Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderProviderContext! context) -> Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinder?
Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider
Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider.GetMetadataForProperties(System.Type! modelType) -> System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata!>!
Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider.GetMetadataForType(System.Type! modelType) -> Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata!
@ -742,7 +742,7 @@ static Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity.ForP
static Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity.ForProperty(System.Type! modelType, string! name, System.Type! containerType) -> Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity
static Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity.ForType(System.Type! modelType) -> Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity
static Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult.Failed() -> Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult
static Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult.Success(object! model) -> Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult
static Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult.Success(object? model) -> Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult
static Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult.operator !=(Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult x, Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult y) -> bool
static Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult.operator ==(Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult x, Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult y) -> bool
static Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary.StartsWithPrefix(string! prefix, string! key) -> bool

View File

@ -15,15 +15,15 @@ namespace Microsoft.Extensions.DependencyInjection
=> builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme);
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme)
=> builder.AddCookie(authenticationScheme, configureOptions: null);
=> builder.AddCookie(authenticationScheme, configureOptions: null!);
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, Action<CookieAuthenticationOptions>? configureOptions)
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, Action<CookieAuthenticationOptions> configureOptions)
=> builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions);
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, Action<CookieAuthenticationOptions>? configureOptions)
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, Action<CookieAuthenticationOptions> configureOptions)
=> builder.AddCookie(authenticationScheme, displayName: null, configureOptions: configureOptions);
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, string? displayName, Action<CookieAuthenticationOptions>? configureOptions)
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, string? displayName, Action<CookieAuthenticationOptions> configureOptions)
{
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CookieAuthenticationOptions>, PostConfigureCookieAuthenticationOptions>());
builder.Services.AddOptions<CookieAuthenticationOptions>(authenticationScheme).Validate(o => o.Cookie.Expiration == null, "Cookie.Expiration is ignored, use ExpireTimeSpan instead.");