diff --git a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs index bfadd9ed80..2bfdf5d211 100644 --- a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs @@ -1,8 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using Microsoft.AspNet.Diagnostics; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Builder { @@ -17,8 +17,13 @@ namespace Microsoft.AspNet.Builder /// /// /// - public static IApplicationBuilder UseDeveloperExceptionPage([NotNull] this IApplicationBuilder builder) + public static IApplicationBuilder UseDeveloperExceptionPage(this IApplicationBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + return builder.UseDeveloperExceptionPage(new ErrorPageOptions()); } @@ -29,8 +34,13 @@ namespace Microsoft.AspNet.Builder /// /// /// - public static IApplicationBuilder UseDeveloperExceptionPage([NotNull] this IApplicationBuilder builder, ErrorPageOptions options) + public static IApplicationBuilder UseDeveloperExceptionPage(this IApplicationBuilder builder, ErrorPageOptions options) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + return builder.UseMiddleware(options); } } diff --git a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs index 6372b1b846..96ecafc022 100644 --- a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs @@ -13,10 +13,8 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.Diagnostics.Views; using Microsoft.AspNet.FileProviders; using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Features; using Microsoft.Dnx.Compilation; using Microsoft.Dnx.Runtime; -using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; namespace Microsoft.AspNet.Diagnostics @@ -38,11 +36,21 @@ namespace Microsoft.AspNet.Diagnostics /// /// public DeveloperExceptionPageMiddleware( - [NotNull] RequestDelegate next, - [NotNull] ErrorPageOptions options, + RequestDelegate next, + ErrorPageOptions options, ILoggerFactory loggerFactory, IApplicationEnvironment appEnvironment) { + if (next == null) + { + throw new ArgumentNullException(nameof(next)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + _next = next; _options = options; _logger = loggerFactory.CreateLogger(); diff --git a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageOptions.cs b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageOptions.cs index 75b7a3951a..59813d9d53 100644 --- a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageOptions.cs +++ b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageOptions.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - using Microsoft.AspNet.FileProviders; namespace Microsoft.AspNet.Diagnostics diff --git a/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoExtensions.cs b/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoExtensions.cs index c7fbe5cd77..d7d885ff73 100644 --- a/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoExtensions.cs @@ -1,10 +1,10 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Http; using Microsoft.Dnx.Runtime; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Builder { @@ -21,9 +21,19 @@ namespace Microsoft.AspNet.Builder } public static IApplicationBuilder UseRuntimeInfoPage( - [NotNull] this IApplicationBuilder builder, - [NotNull] RuntimeInfoPageOptions options) + this IApplicationBuilder builder, + RuntimeInfoPageOptions options) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + var libraryManager = builder.ApplicationServices.GetService(typeof(ILibraryManager)) as ILibraryManager; var runtimeEnvironment = builder.ApplicationServices.GetService(typeof(IRuntimeEnvironment)) as IRuntimeEnvironment; return builder.Use(next => new RuntimeInfoMiddleware(next, options, libraryManager, runtimeEnvironment).Invoke); diff --git a/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoMiddleware.cs b/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoMiddleware.cs index 168a943a76..8a748c22f3 100644 --- a/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoMiddleware.cs @@ -1,12 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Diagnostics.Views; using Microsoft.AspNet.Http; using Microsoft.Dnx.Runtime; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Diagnostics { @@ -26,11 +26,31 @@ namespace Microsoft.AspNet.Diagnostics /// /// public RuntimeInfoMiddleware( - [NotNull] RequestDelegate next, - [NotNull] RuntimeInfoPageOptions options, - [NotNull] ILibraryManager libraryManager, - [NotNull] IRuntimeEnvironment runtimeEnvironment) + RequestDelegate next, + RuntimeInfoPageOptions options, + ILibraryManager libraryManager, + IRuntimeEnvironment runtimeEnvironment) { + if (next == null) + { + throw new ArgumentNullException(nameof(next)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + if (libraryManager == null) + { + throw new ArgumentNullException(nameof(libraryManager)); + } + + if (runtimeEnvironment == null) + { + throw new ArgumentNullException(nameof(runtimeEnvironment)); + } + _next = next; _options = options; _libraryManager = libraryManager; diff --git a/src/Microsoft.AspNet.Diagnostics/StatusCodePage/StatusCodePagesExtensions.cs b/src/Microsoft.AspNet.Diagnostics/StatusCodePage/StatusCodePagesExtensions.cs index 33ef114a44..fc3a53feef 100644 --- a/src/Microsoft.AspNet.Diagnostics/StatusCodePage/StatusCodePagesExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics/StatusCodePage/StatusCodePagesExtensions.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Features; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Builder { @@ -20,8 +19,13 @@ namespace Microsoft.AspNet.Builder /// /// /// - public static IApplicationBuilder UseStatusCodePages([NotNull]this IApplicationBuilder app, StatusCodePagesOptions options) + public static IApplicationBuilder UseStatusCodePages(this IApplicationBuilder app, StatusCodePagesOptions options) { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + return app.UseMiddleware(options); } diff --git a/src/Microsoft.AspNet.Diagnostics/Views/BaseView.cs b/src/Microsoft.AspNet.Diagnostics/Views/BaseView.cs index 1704fe57d6..5973288e1a 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/BaseView.cs +++ b/src/Microsoft.AspNet.Diagnostics/Views/BaseView.cs @@ -9,7 +9,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Http; -using Microsoft.Framework.Internal; using Microsoft.Framework.WebEncoders; namespace Microsoft.AspNet.Diagnostics.Views @@ -90,11 +89,26 @@ namespace Microsoft.AspNet.Diagnostics.Views /// The value and position of the suffix /// The s to write. protected void WriteAttribute( - [NotNull] string name, - [NotNull] Tuple leader, - [NotNull] Tuple trailer, + string name, + Tuple leader, + Tuple trailer, params AttributeValue[] values) { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + if (leader == null) + { + throw new ArgumentNullException(nameof(leader)); + } + + if (trailer == null) + { + throw new ArgumentNullException(nameof(trailer)); + } + WriteAttributeTo( Output, name, @@ -112,12 +126,32 @@ namespace Microsoft.AspNet.Diagnostics.Views /// The value and position of the suffix /// The s to write. protected void WriteAttributeTo( - [NotNull] TextWriter writer, - [NotNull] string name, - [NotNull] Tuple leader, - [NotNull] Tuple trailer, + TextWriter writer, + string name, + Tuple leader, + Tuple trailer, params AttributeValue[] values) { + if (writer == null) + { + throw new ArgumentNullException(nameof(writer)); + } + + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + if (leader == null) + { + throw new ArgumentNullException(nameof(leader)); + } + + if (trailer == null) + { + throw new ArgumentNullException(nameof(trailer)); + } + WriteLiteralTo(writer, leader.Item1); foreach (var value in values) diff --git a/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageExtensions.cs b/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageExtensions.cs index efb7ff54e5..43eb166ea6 100644 --- a/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageExtensions.cs @@ -5,7 +5,6 @@ using System; using Microsoft.AspNet.Http; using Microsoft.AspNet.Diagnostics; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Builder { @@ -20,8 +19,13 @@ namespace Microsoft.AspNet.Builder /// /// /// - public static IApplicationBuilder UseWelcomePage([NotNull] this IApplicationBuilder builder, WelcomePageOptions options) + public static IApplicationBuilder UseWelcomePage(this IApplicationBuilder builder, WelcomePageOptions options) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + return builder.Use(next => new WelcomePageMiddleware(next, options).Invoke); } diff --git a/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageMiddleware.cs index cb63792d4f..87407f4a52 100644 --- a/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageMiddleware.cs @@ -3,12 +3,10 @@ using System; -using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNet.Diagnostics.Views; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Diagnostics { @@ -25,8 +23,18 @@ namespace Microsoft.AspNet.Diagnostics /// /// /// - public WelcomePageMiddleware([NotNull] RequestDelegate next, [NotNull] WelcomePageOptions options) + public WelcomePageMiddleware(RequestDelegate next, WelcomePageOptions options) { + if (next == null) + { + throw new ArgumentNullException(nameof(next)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + _next = next; _options = options; } diff --git a/src/Microsoft.AspNet.Diagnostics/project.json b/src/Microsoft.AspNet.Diagnostics/project.json index b1876933e8..e62e834150 100644 --- a/src/Microsoft.AspNet.Diagnostics/project.json +++ b/src/Microsoft.AspNet.Diagnostics/project.json @@ -11,10 +11,6 @@ "Microsoft.AspNet.Http.Extensions": "1.0.0-*", "Microsoft.AspNet.WebUtilities": "1.0.0-*", "Microsoft.Framework.Logging.Abstractions": "1.0.0-*", - "Microsoft.Framework.NotNullAttribute.Sources": { - "type": "build", - "version": "1.0.0-*" - }, "Microsoft.Framework.OptionsModel": "1.0.0-*", "Microsoft.Dnx.Compilation.Abstractions": "1.0.0-*", "Microsoft.Framework.WebEncoders.Core": "1.0.0-*"