diff --git a/src/Microsoft.AspNet.JsonPatch/Adapters/ObjectAdapter.cs b/src/Microsoft.AspNet.JsonPatch/Adapters/ObjectAdapter.cs
index d9523d3a0b..4640e97039 100644
--- a/src/Microsoft.AspNet.JsonPatch/Adapters/ObjectAdapter.cs
+++ b/src/Microsoft.AspNet.JsonPatch/Adapters/ObjectAdapter.cs
@@ -8,7 +8,6 @@ using System.Reflection;
using Microsoft.AspNet.JsonPatch.Exceptions;
using Microsoft.AspNet.JsonPatch.Helpers;
using Microsoft.AspNet.JsonPatch.Operations;
-using Microsoft.Framework.Internal;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -23,9 +22,14 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
/// The .
/// The for logging .
public ObjectAdapter(
- [NotNull] IContractResolver contractResolver,
+ IContractResolver contractResolver,
Action logErrorAction)
{
+ if (contractResolver == null)
+ {
+ throw new ArgumentNullException(nameof(contractResolver));
+ }
+
ContractResolver = contractResolver;
LogErrorAction = logErrorAction;
}
@@ -100,8 +104,18 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
/// The add operation.
/// Object to apply the operation to.
- public void Add([NotNull] Operation operation, [NotNull] object objectToApplyTo)
+ public void Add(Operation operation, object objectToApplyTo)
{
+ if (operation == null)
+ {
+ throw new ArgumentNullException(nameof(operation));
+ }
+
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
Add(operation.path, operation.value, objectToApplyTo, operation);
}
@@ -110,11 +124,26 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
/// This method allows code reuse yet reporting the correct operation on error
///
private void Add(
- [NotNull] string path,
+ string path,
object value,
- [NotNull] object objectToApplyTo,
- [NotNull] Operation operationToReport)
+ object objectToApplyTo,
+ Operation operationToReport)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
+ if (operationToReport == null)
+ {
+ throw new ArgumentNullException(nameof(operationToReport));
+ }
+
// first up: if the path ends in a numeric value, we're inserting in a list and
// that value represents the position; if the path ends in "-", we're appending
// to the list.
@@ -357,8 +386,18 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
/// The move operation.
/// Object to apply the operation to.
- public void Move([NotNull] Operation operation, [NotNull] object objectToApplyTo)
+ public void Move(Operation operation, object objectToApplyTo)
{
+ if (operation == null)
+ {
+ throw new ArgumentNullException(nameof(operation));
+ }
+
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
var valueAtFromLocationResult = GetValueAtLocation(operation.from, objectToApplyTo, operation);
if (valueAtFromLocationResult.HasError)
@@ -399,8 +438,18 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
/// The remove operation.
/// Object to apply the operation to.
- public void Remove([NotNull] Operation operation, [NotNull] object objectToApplyTo)
+ public void Remove(Operation operation, object objectToApplyTo)
{
+ if (operation == null)
+ {
+ throw new ArgumentNullException(nameof(operation));
+ }
+
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
Remove(operation.path, objectToApplyTo, operation);
}
@@ -661,8 +710,18 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
/// The replace operation.
/// Object to apply the operation to.
- public void Replace([NotNull] Operation operation, [NotNull] object objectToApplyTo)
+ public void Replace(Operation operation, object objectToApplyTo)
{
+ if (operation == null)
+ {
+ throw new ArgumentNullException(nameof(operation));
+ }
+
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
var removeResult = Remove(operation.path, objectToApplyTo, operation);
if (removeResult.HasError)
@@ -672,7 +731,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
}
if (!removeResult.HasError && removeResult.ActualType == null)
- {
+ {
// the remove operation completed succesfully, but we could not determine the type.
LogError(new JsonPatchError(
objectToApplyTo,
@@ -718,8 +777,18 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
/// The copy operation.
/// Object to apply the operation to.
- public void Copy([NotNull] Operation operation, [NotNull] object objectToApplyTo)
+ public void Copy(Operation operation, object objectToApplyTo)
{
+ if (operation == null)
+ {
+ throw new ArgumentNullException(nameof(operation));
+ }
+
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
// get value at from location and add that value to the path location
var valueAtFromLocationResult = GetValueAtLocation(operation.from, objectToApplyTo, operation);
@@ -743,10 +812,25 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
/// Operation to report in case of an error
/// GetValueResult containing value and a bool signifying a possible error
private GetValueResult GetValueAtLocation(
- [NotNull] string location,
- [NotNull] object objectToGetValueFrom,
- [NotNull] Operation operationToReport)
+ string location,
+ object objectToGetValueFrom,
+ Operation operationToReport)
{
+ if (location == null)
+ {
+ throw new ArgumentNullException(nameof(location));
+ }
+
+ if (objectToGetValueFrom == null)
+ {
+ throw new ArgumentNullException(nameof(objectToGetValueFrom));
+ }
+
+ if (operationToReport == null)
+ {
+ throw new ArgumentNullException(nameof(operationToReport));
+ }
+
// get path result
var pathResult = GetActualPropertyPath(
location,
@@ -801,7 +885,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
// get the array
var array = (IList)treeAnalysisResult.Container.GetValueForCaseInsensitiveKey(
treeAnalysisResult.PropertyPathInParent);
-
+
if (positionAsInteger >= array.Count)
{
LogError(new JsonPatchError(
@@ -815,12 +899,12 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
if (getAtEndOfList)
{
- return new GetValueResult(array[array.Count-1], false);
+ return new GetValueResult(array[array.Count - 1], false);
}
else
{
return new GetValueResult(array[positionAsInteger], false);
- }
+ }
}
else
{
@@ -829,7 +913,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
treeAnalysisResult.PropertyPathInParent);
return new GetValueResult(propertyValueAtLocation, false);
- }
+ }
}
else
{
@@ -846,7 +930,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
Resources.FormatInvalidIndexForArrayProperty(operationToReport.op, location)));
return new GetValueResult(null, true);
}
-
+
if (!patchProperty.Property.Readable)
{
LogError(new JsonPatchError(
@@ -877,7 +961,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
else
{
return new GetValueResult(array[positionAsInteger], false);
- }
+ }
}
else
{
@@ -886,9 +970,9 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
LogError(new JsonPatchError(
objectToGetValueFrom,
operationToReport,
- Resources.FormatCannotReadProperty(
+ Resources.FormatCannotReadProperty(
location)));
- return new GetValueResult(null, true);
+ return new GetValueResult(null, true);
}
var propertyValueAtLocation = patchProperty.Property.ValueProvider
@@ -965,10 +1049,25 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
}
private ActualPropertyPathResult GetActualPropertyPath(
- [NotNull] string propertyPath,
- [NotNull] object objectToApplyTo,
- [NotNull] Operation operationToReport)
+ string propertyPath,
+ object objectToApplyTo,
+ Operation operationToReport)
{
+ if (propertyPath == null)
+ {
+ throw new ArgumentNullException(nameof(propertyPath));
+ }
+
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
+ if (operationToReport == null)
+ {
+ throw new ArgumentNullException(nameof(operationToReport));
+ }
+
if (propertyPath.EndsWith("/-"))
{
return new ActualPropertyPathResult(-1, propertyPath.Substring(0, propertyPath.Length - 2), true);
diff --git a/src/Microsoft.AspNet.JsonPatch/Helpers/JsonPatchProperty.cs b/src/Microsoft.AspNet.JsonPatch/Helpers/JsonPatchProperty.cs
index 7ba0c047cc..0539d230a3 100644
--- a/src/Microsoft.AspNet.JsonPatch/Helpers/JsonPatchProperty.cs
+++ b/src/Microsoft.AspNet.JsonPatch/Helpers/JsonPatchProperty.cs
@@ -1,7 +1,7 @@
// 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.Framework.Internal;
+using System;
using Newtonsoft.Json.Serialization;
namespace Microsoft.AspNet.JsonPatch
@@ -14,8 +14,18 @@ namespace Microsoft.AspNet.JsonPatch
///
/// Initializes a new instance.
///
- public JsonPatchProperty([NotNull] JsonProperty property, [NotNull] object parent)
+ public JsonPatchProperty(JsonProperty property, object parent)
{
+ if (property == null)
+ {
+ throw new ArgumentNullException(nameof(property));
+ }
+
+ if (parent == null)
+ {
+ throw new ArgumentNullException(nameof(parent));
+ }
+
Property = property;
Parent = parent;
}
diff --git a/src/Microsoft.AspNet.JsonPatch/JsonPatchDocument.cs b/src/Microsoft.AspNet.JsonPatch/JsonPatchDocument.cs
index 74d4071530..fc2e73030a 100644
--- a/src/Microsoft.AspNet.JsonPatch/JsonPatchDocument.cs
+++ b/src/Microsoft.AspNet.JsonPatch/JsonPatchDocument.cs
@@ -1,14 +1,12 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Collections.Generic;
using Microsoft.AspNet.JsonPatch.Adapters;
using Microsoft.AspNet.JsonPatch.Converters;
-using Microsoft.AspNet.JsonPatch.Exceptions;
using Microsoft.AspNet.JsonPatch.Helpers;
using Microsoft.AspNet.JsonPatch.Operations;
-using Microsoft.Framework.Internal;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -24,15 +22,25 @@ namespace Microsoft.AspNet.JsonPatch
[JsonIgnore]
public IContractResolver ContractResolver { get; set; }
-
+
public JsonPatchDocument()
{
Operations = new List();
- ContractResolver = new DefaultContractResolver();
+ ContractResolver = new DefaultContractResolver();
}
- public JsonPatchDocument([NotNull] List operations, [NotNull] IContractResolver contractResolver)
+ public JsonPatchDocument(List operations, IContractResolver contractResolver)
{
+ if (operations == null)
+ {
+ throw new ArgumentNullException(nameof(operations));
+ }
+
+ if (contractResolver == null)
+ {
+ throw new ArgumentNullException(nameof(contractResolver));
+ }
+
Operations = operations;
ContractResolver = contractResolver;
}
@@ -44,8 +52,13 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
/// value
///
- public JsonPatchDocument Add([NotNull] string path, object value)
+ public JsonPatchDocument Add(string path, object value)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation("add", PathHelpers.NormalizePath(path), null, value));
return this;
}
@@ -56,8 +69,13 @@ namespace Microsoft.AspNet.JsonPatch
///
/// target location
///
- public JsonPatchDocument Remove([NotNull] string path)
+ public JsonPatchDocument Remove(string path)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation("remove", PathHelpers.NormalizePath(path), null, null));
return this;
}
@@ -69,8 +87,13 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
/// value
///
- public JsonPatchDocument Replace([NotNull] string path, object value)
+ public JsonPatchDocument Replace(string path, object value)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation("replace", PathHelpers.NormalizePath(path), null, value));
return this;
}
@@ -82,8 +105,18 @@ namespace Microsoft.AspNet.JsonPatch
/// source location
/// target location
///
- public JsonPatchDocument Move([NotNull] string from, [NotNull] string path)
+ public JsonPatchDocument Move(string from, string path)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation("move", PathHelpers.NormalizePath(path), PathHelpers.NormalizePath(from)));
return this;
}
@@ -95,8 +128,18 @@ namespace Microsoft.AspNet.JsonPatch
/// source location
/// target location
///
- public JsonPatchDocument Copy([NotNull] string from, [NotNull] string path)
+ public JsonPatchDocument Copy(string from, string path)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation("copy", PathHelpers.NormalizePath(path), PathHelpers.NormalizePath(from)));
return this;
}
@@ -105,8 +148,13 @@ namespace Microsoft.AspNet.JsonPatch
/// Apply this JsonPatchDocument
///
/// Object to apply the JsonPatchDocument to
- public void ApplyTo([NotNull] object objectToApplyTo)
+ public void ApplyTo(object objectToApplyTo)
{
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
ApplyTo(objectToApplyTo, new ObjectAdapter(ContractResolver, logErrorAction: null));
}
@@ -115,8 +163,13 @@ namespace Microsoft.AspNet.JsonPatch
///
/// Object to apply the JsonPatchDocument to
/// Action to log errors
- public void ApplyTo([NotNull] object objectToApplyTo, Action logErrorAction)
+ public void ApplyTo(object objectToApplyTo, Action logErrorAction)
{
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
ApplyTo(objectToApplyTo, new ObjectAdapter(ContractResolver, logErrorAction));
}
@@ -125,15 +178,25 @@ namespace Microsoft.AspNet.JsonPatch
///
/// Object to apply the JsonPatchDocument to
/// IObjectAdapter instance to use when applying
- public void ApplyTo([NotNull] object objectToApplyTo, [NotNull] IObjectAdapter adapter)
+ public void ApplyTo(object objectToApplyTo, IObjectAdapter adapter)
{
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
+ if (adapter == null)
+ {
+ throw new ArgumentNullException(nameof(adapter));
+ }
+
// apply each operation in order
foreach (var op in Operations)
{
op.Apply(objectToApplyTo, adapter);
}
}
-
+
IList IJsonPatchDocument.GetOperations()
{
var allOps = new List();
diff --git a/src/Microsoft.AspNet.JsonPatch/JsonPatchDocumentOfT.cs b/src/Microsoft.AspNet.JsonPatch/JsonPatchDocumentOfT.cs
index 75a7508945..7b03f1644c 100644
--- a/src/Microsoft.AspNet.JsonPatch/JsonPatchDocumentOfT.cs
+++ b/src/Microsoft.AspNet.JsonPatch/JsonPatchDocumentOfT.cs
@@ -8,7 +8,6 @@ using Microsoft.AspNet.JsonPatch.Adapters;
using Microsoft.AspNet.JsonPatch.Converters;
using Microsoft.AspNet.JsonPatch.Helpers;
using Microsoft.AspNet.JsonPatch.Operations;
-using Microsoft.Framework.Internal;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -33,8 +32,18 @@ namespace Microsoft.AspNet.JsonPatch
}
// Create from list of operations
- public JsonPatchDocument([NotNull] List> operations, [NotNull] IContractResolver contractResolver)
+ public JsonPatchDocument(List> operations, IContractResolver contractResolver)
{
+ if (operations == null)
+ {
+ throw new ArgumentNullException(nameof(operations));
+ }
+
+ if (contractResolver == null)
+ {
+ throw new ArgumentNullException(nameof(contractResolver));
+ }
+
Operations = operations;
ContractResolver = contractResolver;
}
@@ -47,8 +56,13 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
/// value
///
- public JsonPatchDocument Add([NotNull] Expression> path, TProp value)
+ public JsonPatchDocument Add(Expression> path, TProp value)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"add",
ExpressionHelpers.GetPath(path).ToLowerInvariant(),
@@ -67,10 +81,15 @@ namespace Microsoft.AspNet.JsonPatch
/// position
///
public JsonPatchDocument Add(
- [NotNull] Expression>> path,
+ Expression>> path,
TProp value,
int position)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"add",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/" + position,
@@ -87,8 +106,13 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
/// value
///
- public JsonPatchDocument Add([NotNull] Expression>> path, TProp value)
+ public JsonPatchDocument Add(Expression>> path, TProp value)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"add",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/-",
@@ -104,8 +128,13 @@ namespace Microsoft.AspNet.JsonPatch
///
/// target location
///
- public JsonPatchDocument Remove([NotNull] Expression> path)
+ public JsonPatchDocument Remove(Expression> path)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation("remove", ExpressionHelpers.GetPath(path).ToLowerInvariant(), from: null));
return this;
@@ -118,8 +147,13 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
/// position
///
- public JsonPatchDocument Remove([NotNull] Expression>> path, int position)
+ public JsonPatchDocument Remove(Expression>> path, int position)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"remove",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/" + position,
@@ -134,8 +168,13 @@ namespace Microsoft.AspNet.JsonPatch
/// value type
/// target location
///
- public JsonPatchDocument Remove([NotNull] Expression>> path)
+ public JsonPatchDocument Remove(Expression>> path)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"remove",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/-",
@@ -151,8 +190,13 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
/// value
///
- public JsonPatchDocument Replace([NotNull] Expression> path, TProp value)
+ public JsonPatchDocument Replace(Expression> path, TProp value)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"replace",
ExpressionHelpers.GetPath(path).ToLowerInvariant(),
@@ -170,9 +214,14 @@ namespace Microsoft.AspNet.JsonPatch
/// value
/// position
///
- public JsonPatchDocument Replace([NotNull] Expression>> path,
+ public JsonPatchDocument Replace(Expression>> path,
TProp value, int position)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"replace",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/" + position,
@@ -189,8 +238,13 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
/// value
///
- public JsonPatchDocument Replace([NotNull] Expression>> path, TProp value)
+ public JsonPatchDocument Replace(Expression>> path, TProp value)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"replace",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/-",
@@ -208,9 +262,19 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
///
public JsonPatchDocument Move(
- [NotNull] Expression> from,
- [NotNull] Expression> path)
+ Expression> from,
+ Expression> path)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"move",
ExpressionHelpers.GetPath(path).ToLowerInvariant(),
@@ -228,10 +292,20 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
///
public JsonPatchDocument Move(
- [NotNull] Expression>> from,
+ Expression>> from,
int positionFrom,
- [NotNull] Expression> path)
+ Expression> path)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"move",
ExpressionHelpers.GetPath(path).ToLowerInvariant(),
@@ -249,10 +323,20 @@ namespace Microsoft.AspNet.JsonPatch
/// position
///
public JsonPatchDocument Move(
- [NotNull] Expression> from,
- [NotNull] Expression>> path,
+ Expression> from,
+ Expression>> path,
int positionTo)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"move",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/" + positionTo,
@@ -271,11 +355,21 @@ namespace Microsoft.AspNet.JsonPatch
/// position (target)
///
public JsonPatchDocument Move(
- [NotNull] Expression>> from,
+ Expression>> from,
int positionFrom,
- [NotNull] Expression>> path,
+ Expression>> path,
int positionTo)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"move",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/" + positionTo,
@@ -293,10 +387,20 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
///
public JsonPatchDocument Move(
- [NotNull] Expression>> from,
+ Expression>> from,
int positionFrom,
- [NotNull] Expression>> path)
+ Expression>> path)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"move",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/-",
@@ -313,9 +417,19 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
///
public JsonPatchDocument Move(
- [NotNull] Expression> from,
- [NotNull] Expression>> path)
+ Expression> from,
+ Expression>> path)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"move",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/-",
@@ -332,9 +446,19 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
///
public JsonPatchDocument Copy(
- [NotNull] Expression> from,
- [NotNull] Expression> path)
+ Expression> from,
+ Expression> path)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"copy",
ExpressionHelpers.GetPath(path).ToLowerInvariant()
@@ -352,10 +476,20 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
///
public JsonPatchDocument Copy(
- [NotNull] Expression>> from,
+ Expression>> from,
int positionFrom,
- [NotNull] Expression> path)
+ Expression> path)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"copy",
ExpressionHelpers.GetPath(path).ToLowerInvariant(),
@@ -373,10 +507,20 @@ namespace Microsoft.AspNet.JsonPatch
/// position
///
public JsonPatchDocument Copy(
- [NotNull] Expression> from,
- [NotNull] Expression>> path,
+ Expression> from,
+ Expression>> path,
int positionTo)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"copy",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/" + positionTo,
@@ -395,11 +539,21 @@ namespace Microsoft.AspNet.JsonPatch
/// position (target)
///
public JsonPatchDocument Copy(
- [NotNull] Expression>> from,
+ Expression>> from,
int positionFrom,
- [NotNull] Expression>> path,
+ Expression>> path,
int positionTo)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"copy",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/" + positionTo,
@@ -417,10 +571,20 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
///
public JsonPatchDocument Copy(
- [NotNull] Expression>> from,
+ Expression>> from,
int positionFrom,
- [NotNull] Expression>> path)
+ Expression>> path)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"copy",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/-",
@@ -437,9 +601,19 @@ namespace Microsoft.AspNet.JsonPatch
/// target location
///
public JsonPatchDocument Copy(
- [NotNull] Expression> from,
- [NotNull] Expression>> path)
+ Expression> from,
+ Expression>> path)
{
+ if (from == null)
+ {
+ throw new ArgumentNullException(nameof(from));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
Operations.Add(new Operation(
"copy",
ExpressionHelpers.GetPath(path).ToLowerInvariant() + "/-",
@@ -452,8 +626,13 @@ namespace Microsoft.AspNet.JsonPatch
/// Apply this JsonPatchDocument
///
/// Object to apply the JsonPatchDocument to
- public void ApplyTo([NotNull] TModel objectToApplyTo)
+ public void ApplyTo(TModel objectToApplyTo)
{
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
ApplyTo(objectToApplyTo, new ObjectAdapter(ContractResolver, logErrorAction: null));
}
@@ -462,8 +641,13 @@ namespace Microsoft.AspNet.JsonPatch
///
/// Object to apply the JsonPatchDocument to
/// Action to log errors
- public void ApplyTo([NotNull] TModel objectToApplyTo, Action logErrorAction)
+ public void ApplyTo(TModel objectToApplyTo, Action logErrorAction)
{
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
ApplyTo(objectToApplyTo, new ObjectAdapter(ContractResolver, logErrorAction));
}
@@ -472,8 +656,18 @@ namespace Microsoft.AspNet.JsonPatch
///
/// Object to apply the JsonPatchDocument to
/// IObjectAdapter instance to use when applying
- public void ApplyTo([NotNull] TModel objectToApplyTo, [NotNull] IObjectAdapter adapter)
+ public void ApplyTo(TModel objectToApplyTo, IObjectAdapter adapter)
{
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
+ if (adapter == null)
+ {
+ throw new ArgumentNullException(nameof(adapter));
+ }
+
// apply each operation in order
foreach (var op in Operations)
{
diff --git a/src/Microsoft.AspNet.JsonPatch/JsonPatchError.cs b/src/Microsoft.AspNet.JsonPatch/JsonPatchError.cs
index 36d1f1c688..a140f0d4c1 100644
--- a/src/Microsoft.AspNet.JsonPatch/JsonPatchError.cs
+++ b/src/Microsoft.AspNet.JsonPatch/JsonPatchError.cs
@@ -1,15 +1,15 @@
// 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.JsonPatch.Operations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.JsonPatch
{
///
/// Captures error message and the related entity and the operation that caused it.
///
- public class JsonPatchError
+ public class JsonPatchError
{
///
/// Initializes a new instance of .
@@ -18,10 +18,15 @@ namespace Microsoft.AspNet.JsonPatch
/// The that caused the error.
/// The error message.
public JsonPatchError(
- object affectedObject,
- Operation operation,
- [NotNull] string errorMessage)
+ object affectedObject,
+ Operation operation,
+ string errorMessage)
{
+ if (errorMessage == null)
+ {
+ throw new ArgumentNullException(nameof(errorMessage));
+ }
+
AffectedObject = affectedObject;
Operation = operation;
ErrorMessage = errorMessage;
diff --git a/src/Microsoft.AspNet.JsonPatch/Operations/Operation.cs b/src/Microsoft.AspNet.JsonPatch/Operations/Operation.cs
index b115465fc0..7f056f41bf 100644
--- a/src/Microsoft.AspNet.JsonPatch/Operations/Operation.cs
+++ b/src/Microsoft.AspNet.JsonPatch/Operations/Operation.cs
@@ -3,7 +3,6 @@
using System;
using Microsoft.AspNet.JsonPatch.Adapters;
-using Microsoft.Framework.Internal;
using Newtonsoft.Json;
namespace Microsoft.AspNet.JsonPatch.Operations
@@ -18,20 +17,29 @@ namespace Microsoft.AspNet.JsonPatch.Operations
}
- public Operation([NotNull] string op, [NotNull] string path, string from, object value)
+ public Operation(string op, string path, string from, object value)
: base(op, path, from)
{
this.value = value;
}
- public Operation([NotNull] string op, [NotNull] string path, string from)
+ public Operation(string op, string path, string from)
: base(op, path, from)
{
-
}
- public void Apply([NotNull] object objectToApplyTo, [NotNull] IObjectAdapter adapter)
+ public void Apply(object objectToApplyTo, IObjectAdapter adapter)
{
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
+ if (adapter == null)
+ {
+ throw new ArgumentNullException(nameof(adapter));
+ }
+
switch (OperationType)
{
case OperationType.Add:
diff --git a/src/Microsoft.AspNet.JsonPatch/Operations/OperationBase.cs b/src/Microsoft.AspNet.JsonPatch/Operations/OperationBase.cs
index 05dd590e89..17455f75e8 100644
--- a/src/Microsoft.AspNet.JsonPatch/Operations/OperationBase.cs
+++ b/src/Microsoft.AspNet.JsonPatch/Operations/OperationBase.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Microsoft.Framework.Internal;
using Newtonsoft.Json;
namespace Microsoft.AspNet.JsonPatch.Operations
@@ -32,8 +31,18 @@ namespace Microsoft.AspNet.JsonPatch.Operations
}
- public OperationBase([NotNull] string op, [NotNull] string path, string from)
+ public OperationBase(string op, string path, string from)
{
+ if (op == null)
+ {
+ throw new ArgumentNullException(nameof(op));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
this.op = op;
this.path = path;
this.from = from;
diff --git a/src/Microsoft.AspNet.JsonPatch/Operations/OperationOfT.cs b/src/Microsoft.AspNet.JsonPatch/Operations/OperationOfT.cs
index 9761a269a1..63663f70d9 100644
--- a/src/Microsoft.AspNet.JsonPatch/Operations/OperationOfT.cs
+++ b/src/Microsoft.AspNet.JsonPatch/Operations/OperationOfT.cs
@@ -3,7 +3,6 @@
using System;
using Microsoft.AspNet.JsonPatch.Adapters;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.JsonPatch.Operations
{
@@ -14,20 +13,48 @@ namespace Microsoft.AspNet.JsonPatch.Operations
}
- public Operation([NotNull] string op, [NotNull] string path, string from, object value)
+ public Operation(string op, string path, string from, object value)
: base(op, path, from)
{
+ if (op == null)
+ {
+ throw new ArgumentNullException(nameof(op));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
this.value = value;
}
- public Operation([NotNull] string op, [NotNull] string path, string from)
+ public Operation(string op, string path, string from)
: base(op, path, from)
{
+ if (op == null)
+ {
+ throw new ArgumentNullException(nameof(op));
+ }
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
}
- public void Apply([NotNull] TModel objectToApplyTo, [NotNull] IObjectAdapter adapter)
+ public void Apply(TModel objectToApplyTo, IObjectAdapter adapter)
{
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
+ if (adapter == null)
+ {
+ throw new ArgumentNullException(nameof(adapter));
+ }
+
switch (OperationType)
{
case OperationType.Add:
diff --git a/src/Microsoft.AspNet.JsonPatch/project.json b/src/Microsoft.AspNet.JsonPatch/project.json
index b207c8a696..5e619deea9 100644
--- a/src/Microsoft.AspNet.JsonPatch/project.json
+++ b/src/Microsoft.AspNet.JsonPatch/project.json
@@ -6,7 +6,6 @@
},
"dependencies": {
"Microsoft.AspNet.Http.Extensions": "1.0.0-*",
- "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" },
"Newtonsoft.Json": "6.0.6"
},
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/CompareAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/CompareAttributeAdapter.cs
index 1d51ff3efc..0e8d9eca32 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/CompareAttributeAdapter.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/CompareAttributeAdapter.cs
@@ -1,23 +1,32 @@
// 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.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
public class CompareAttributeAdapter : DataAnnotationsClientModelValidator
{
- public CompareAttributeAdapter([NotNull] CompareAttribute attribute)
+ public CompareAttributeAdapter(CompareAttribute attribute)
: base(new CompareAttributeWrapper(attribute))
{
+ if (attribute == null)
+ {
+ throw new ArgumentNullException(nameof(attribute));
+ }
}
public override IEnumerable GetClientValidationRules(
- [NotNull] ClientModelValidationContext context)
+ ClientModelValidationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var errorMessage = ((CompareAttributeWrapper)Attribute).FormatErrorMessage(context);
var clientRule = new ModelClientValidationEqualToRule(errorMessage,
FormatPropertyForClientValidation(Attribute.OtherProperty));
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorOfTAttribute.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorOfTAttribute.cs
index a6083d347b..c456fb765f 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorOfTAttribute.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorOfTAttribute.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -42,8 +41,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
/// The associated with the model annotated with
/// .
/// Formatted error string.
- protected virtual string GetErrorMessage([NotNull] ModelMetadata modelMetadata)
+ protected virtual string GetErrorMessage(ModelMetadata modelMetadata)
{
+ if (modelMetadata == null)
+ {
+ throw new ArgumentNullException(nameof(modelMetadata));
+ }
+
return Attribute.FormatErrorMessage(modelMetadata.GetDisplayName());
}
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorProvider.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorProvider.cs
index 356fa6c9f6..27bb911bfc 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorProvider.cs
@@ -32,11 +32,16 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
///
public void GetValidators(ClientValidatorProviderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var hasRequiredAttribute = false;
foreach (var attribute in context.ValidatorMetadata.OfType())
{
- hasRequiredAttribute |= attribute is RequiredAttribute;
+ hasRequiredAttribute |= attribute is RequiredAttribute;
DataAnnotationsClientModelValidationFactory factory;
if (_attributeFactories.TryGetValue(attribute.GetType(), out factory))
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsMetadataProvider.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsMetadataProvider.cs
index 52ecc70bac..7e35aaed31 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsMetadataProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsMetadataProvider.cs
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
{
@@ -20,8 +19,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
IValidationMetadataProvider
{
///
- public void GetBindingMetadata([NotNull] BindingMetadataProviderContext context)
+ public void GetBindingMetadata(BindingMetadataProviderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var editableAttribute = context.Attributes.OfType().FirstOrDefault();
if (editableAttribute != null)
{
@@ -30,8 +34,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
}
///
- public void GetDisplayMetadata([NotNull] DisplayMetadataProviderContext context)
+ public void GetDisplayMetadata(DisplayMetadataProviderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var attributes = context.Attributes;
var dataTypeAttribute = attributes.OfType().FirstOrDefault();
var displayAttribute = attributes.OfType().FirstOrDefault();
@@ -205,8 +214,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
}
///
- public void GetValidationMetadata([NotNull] ValidationMetadataProviderContext context)
+ public void GetValidationMetadata(ValidationMetadataProviderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
// RequiredAttribute marks a property as required by validation - this means that it
// must have a non-null value on the model during validation.
var requiredAttribute = context.Attributes.OfType().FirstOrDefault();
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsModelValidator.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsModelValidator.cs
index 349e6e3681..88ba55df68 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsModelValidator.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsModelValidator.cs
@@ -5,14 +5,18 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
public class DataAnnotationsModelValidator : IModelValidator
{
- public DataAnnotationsModelValidator([NotNull] ValidationAttribute attribute)
+ public DataAnnotationsModelValidator(ValidationAttribute attribute)
{
+ if (attribute == null)
+ {
+ throw new ArgumentNullException(nameof(attribute));
+ }
+
Attribute = attribute;
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataTypeAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataTypeAttributeAdapter.cs
index 3967012cfc..5386156b7d 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataTypeAttributeAdapter.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataTypeAttributeAdapter.cs
@@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNet.Mvc.DataAnnotations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -17,9 +16,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
public DataTypeAttributeAdapter(
DataTypeAttribute attribute,
- [NotNull] string ruleName)
+ string ruleName)
: base(attribute)
{
+ if (ruleName == null)
+ {
+ throw new ArgumentNullException(nameof(ruleName));
+ }
+
if (string.IsNullOrEmpty(ruleName))
{
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(ruleName));
@@ -30,8 +34,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
public string RuleName { get; private set; }
public override IEnumerable GetClientValidationRules(
- [NotNull] ClientModelValidationContext context)
+ ClientModelValidationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var errorMessage = GetErrorMessage(context.ModelMetadata);
return new[] { new ModelClientValidationRule(RuleName, errorMessage) };
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/DefaultClientModelValidatorProvider.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/DefaultClientModelValidatorProvider.cs
index fdbf6d7793..b05e8d7047 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/DefaultClientModelValidatorProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/DefaultClientModelValidatorProvider.cs
@@ -1,6 +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;
+// 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.
+
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
///
@@ -15,6 +19,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
///
public void GetValidators(ClientValidatorProviderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
foreach (var metadata in context.ValidatorMetadata)
{
var validator = metadata as IClientModelValidator;
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/DependencyInjection/MvcDataAnnotationsMvcCoreBuilderExtensions.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/DependencyInjection/MvcDataAnnotationsMvcCoreBuilderExtensions.cs
index 74ee9708b8..794c4b3947 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/DependencyInjection/MvcDataAnnotationsMvcCoreBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/DependencyInjection/MvcDataAnnotationsMvcCoreBuilderExtensions.cs
@@ -1,18 +1,23 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Mvc;
using Microsoft.AspNet.Mvc.DataAnnotations.Internal;
using Microsoft.Framework.DependencyInjection.Extensions;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.Framework.DependencyInjection
{
public static class MvcDataAnnotationsMvcCoreBuilderExtensions
{
- public static IMvcCoreBuilder AddDataAnnotations([NotNull] this IMvcCoreBuilder builder)
+ public static IMvcCoreBuilder AddDataAnnotations(this IMvcCoreBuilder builder)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
AddDataAnnotationsServices(builder.Services);
return builder;
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/MaxLengthAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/MaxLengthAttributeAdapter.cs
index dba46334f2..f0027a3135 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/MaxLengthAttributeAdapter.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/MaxLengthAttributeAdapter.cs
@@ -1,9 +1,9 @@
// 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.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -15,8 +15,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
}
public override IEnumerable GetClientValidationRules(
- [NotNull] ClientModelValidationContext context)
+ ClientModelValidationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var message = GetErrorMessage(context.ModelMetadata);
return new[] { new ModelClientValidationMaxLengthRule(message, Attribute.Length) };
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/MinLengthAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/MinLengthAttributeAdapter.cs
index 61e086e7ec..718b67fa5a 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/MinLengthAttributeAdapter.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/MinLengthAttributeAdapter.cs
@@ -1,9 +1,9 @@
// 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.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -15,8 +15,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
}
public override IEnumerable GetClientValidationRules(
- [NotNull] ClientModelValidationContext context)
+ ClientModelValidationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var message = GetErrorMessage(context.ModelMetadata);
return new[] { new ModelClientValidationMinLengthRule(message, Attribute.Length) };
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationEqualToRule.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationEqualToRule.cs
index c3f11d7671..bf79b2f9c9 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationEqualToRule.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationEqualToRule.cs
@@ -1,7 +1,7 @@
// 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.Framework.Internal;
+using System;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -14,10 +14,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
private const string EqualToValidationParameter = "other";
public ModelClientValidationEqualToRule(
- [NotNull] string errorMessage,
- [NotNull] object other)
+ string errorMessage,
+ object other)
: base(EqualToValidationType, errorMessage)
{
+ if (other == null)
+ {
+ throw new ArgumentNullException(nameof(other));
+ }
+
ValidationParameters[EqualToValidationParameter] = other;
}
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationMaxLengthRule.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationMaxLengthRule.cs
index 425cc8a355..5b7a55404f 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationMaxLengthRule.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationMaxLengthRule.cs
@@ -1,8 +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.Framework.Internal;
-
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
public class ModelClientValidationMaxLengthRule : ModelClientValidationRule
@@ -10,7 +8,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
private const string MaxLengthValidationType = "maxlength";
private const string MaxLengthValidationParameter = "max";
- public ModelClientValidationMaxLengthRule([NotNull] string errorMessage, int maximumLength)
+ public ModelClientValidationMaxLengthRule(string errorMessage, int maximumLength)
: base(MaxLengthValidationType, errorMessage)
{
ValidationParameters[MaxLengthValidationParameter] = maximumLength;
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationMinLengthRule.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationMinLengthRule.cs
index ae7a764010..3da7641fd2 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationMinLengthRule.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationMinLengthRule.cs
@@ -1,8 +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.Framework.Internal;
-
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
public class ModelClientValidationMinLengthRule : ModelClientValidationRule
@@ -10,7 +8,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
private const string MinLengthValidationType = "minlength";
private const string MinLengthValidationParameter = "min";
- public ModelClientValidationMinLengthRule([NotNull] string errorMessage, int minimumLength)
+ public ModelClientValidationMinLengthRule(string errorMessage, int minimumLength)
: base(MinLengthValidationType, errorMessage)
{
ValidationParameters[MinLengthValidationParameter] = minimumLength;
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationNumericRule.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationNumericRule.cs
index 02e4819b7b..05df63a743 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationNumericRule.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationNumericRule.cs
@@ -1,8 +1,6 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Framework.Internal;
-
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
///
@@ -17,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
/// with the given .
///
/// The error message to be displayed.
- public ModelClientValidationNumericRule([NotNull] string errorMessage)
+ public ModelClientValidationNumericRule(string errorMessage)
: base(NumericValidationType, errorMessage)
{
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationRangeRule.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationRangeRule.cs
index f8ecdc5a66..4e7a3c699d 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationRangeRule.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/ModelClientValidationRangeRule.cs
@@ -1,7 +1,7 @@
// 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.Framework.Internal;
+using System;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -12,11 +12,21 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
private const string MaxValidationParameter = "max";
public ModelClientValidationRangeRule(
- [NotNull] string errorMessage,
- [NotNull] object minValue,
- [NotNull] object maxValue)
+ string errorMessage,
+ object minValue,
+ object maxValue)
: base(RangeValidationType, errorMessage)
{
+ if (minValue == null)
+ {
+ throw new ArgumentNullException(nameof(minValue));
+ }
+
+ if (maxValue == null)
+ {
+ throw new ArgumentNullException(nameof(maxValue));
+ }
+
ValidationParameters[MinValidationParameter] = minValue;
ValidationParameters[MaxValidationParameter] = maxValue;
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/NumericClientModelValidator.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/NumericClientModelValidator.cs
index e664ad815a..fe31bbf823 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/NumericClientModelValidator.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/NumericClientModelValidator.cs
@@ -1,9 +1,9 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Collections.Generic;
using Microsoft.AspNet.Mvc.DataAnnotations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -16,11 +16,21 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
///
public IEnumerable GetClientValidationRules(ClientModelValidationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
return new[] { new ModelClientValidationNumericRule(GetErrorMessage(context.ModelMetadata)) };
}
- private string GetErrorMessage([NotNull] ModelMetadata modelMetadata)
+ private string GetErrorMessage(ModelMetadata modelMetadata)
{
+ if (modelMetadata == null)
+ {
+ throw new ArgumentNullException(nameof(modelMetadata));
+ }
+
return Resources.FormatNumericClientModelValidator_FieldMustBeNumber(modelMetadata.GetDisplayName());
}
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/NumericClientModelValidatorProvider.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/NumericClientModelValidatorProvider.cs
index fb485aaef0..46572651fc 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/NumericClientModelValidatorProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/NumericClientModelValidatorProvider.cs
@@ -1,6 +1,8 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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;
+
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
///
@@ -12,6 +14,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
///
public void GetValidators(ClientValidatorProviderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var typeToValidate = context.ModelMetadata.UnderlyingOrModelType;
// Check only the numeric types for which we set type='text'.
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/RangeAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/RangeAttributeAdapter.cs
index 9b6d4f82d7..cfe32ce780 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/RangeAttributeAdapter.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/RangeAttributeAdapter.cs
@@ -1,9 +1,9 @@
// 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.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -15,8 +15,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
}
public override IEnumerable GetClientValidationRules(
- [NotNull] ClientModelValidationContext context)
+ ClientModelValidationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var errorMessage = GetErrorMessage(context.ModelMetadata);
return new[] { new ModelClientValidationRangeRule(errorMessage, Attribute.Minimum, Attribute.Maximum) };
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/RegularExpressionAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/RegularExpressionAttributeAdapter.cs
index a012f9c9b2..03d130d2dd 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/RegularExpressionAttributeAdapter.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/RegularExpressionAttributeAdapter.cs
@@ -1,9 +1,9 @@
// 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.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -15,8 +15,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
}
public override IEnumerable GetClientValidationRules(
- [NotNull] ClientModelValidationContext context)
+ ClientModelValidationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var errorMessage = GetErrorMessage(context.ModelMetadata);
return new[] { new ModelClientValidationRegexRule(errorMessage, Attribute.Pattern) };
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/RequiredAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/RequiredAttributeAdapter.cs
index b04917cb19..00aace75cb 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/RequiredAttributeAdapter.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/RequiredAttributeAdapter.cs
@@ -1,9 +1,9 @@
// 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.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -15,8 +15,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
}
public override IEnumerable GetClientValidationRules(
- [NotNull] ClientModelValidationContext context)
+ ClientModelValidationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var errorMessage = GetErrorMessage(context.ModelMetadata);
return new[] { new ModelClientValidationRequiredRule(errorMessage) };
}
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/StringLengthAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/StringLengthAttributeAdapter.cs
index 9bcbd7acb7..319aac5739 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/StringLengthAttributeAdapter.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/StringLengthAttributeAdapter.cs
@@ -1,9 +1,9 @@
// 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.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
@@ -15,8 +15,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
}
public override IEnumerable GetClientValidationRules(
- [NotNull] ClientModelValidationContext context)
+ ClientModelValidationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var errorMessage = GetErrorMessage(context.ModelMetadata);
var rule = new ModelClientValidationStringLengthRule(errorMessage,
Attribute.MinimumLength,
diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/project.json b/src/Microsoft.AspNet.Mvc.DataAnnotations/project.json
index 76b7a6ce72..f2d5c486df 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/project.json
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/project.json
@@ -11,8 +11,7 @@
"dependencies": {
"Microsoft.AspNet.Mvc.Core": "6.0.0-*",
"Microsoft.Framework.ClosedGenericMatcher.Sources": { "version": "1.0.0-*", "type": "build" },
- "Microsoft.Framework.CopyOnWriteDictionary.Sources": { "version": "1.0.0-*", "type": "build" },
- "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" }
+ "Microsoft.Framework.CopyOnWriteDictionary.Sources": { "version": "1.0.0-*", "type": "build" }
},
"frameworks": {
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Json/DependencyInjection/MvcJsonMvcBuilderExtensions.cs b/src/Microsoft.AspNet.Mvc.Formatters.Json/DependencyInjection/MvcJsonMvcBuilderExtensions.cs
index 0347c493a0..0c96259691 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Json/DependencyInjection/MvcJsonMvcBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Json/DependencyInjection/MvcJsonMvcBuilderExtensions.cs
@@ -1,9 +1,8 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Mvc;
-using Microsoft.Framework.Internal;
namespace Microsoft.Framework.DependencyInjection
{
@@ -18,9 +17,19 @@ namespace Microsoft.Framework.DependencyInjection
/// The .
/// The which need to be configured.
public static IMvcBuilder AddJsonOptions(
- [NotNull] this IMvcBuilder builder,
- [NotNull] Action setupAction)
+ this IMvcBuilder builder,
+ Action setupAction)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ if (setupAction == null)
+ {
+ throw new ArgumentNullException(nameof(setupAction));
+ }
+
builder.Services.Configure(setupAction);
return builder;
}
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Json/DependencyInjection/MvcJsonMvcCoreBuilderExtensions.cs b/src/Microsoft.AspNet.Mvc.Formatters.Json/DependencyInjection/MvcJsonMvcCoreBuilderExtensions.cs
index 418c165d0f..8fc0e6d63c 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Json/DependencyInjection/MvcJsonMvcCoreBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Json/DependencyInjection/MvcJsonMvcCoreBuilderExtensions.cs
@@ -1,11 +1,10 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Mvc;
using Microsoft.AspNet.Mvc.Formatters.Json.Internal;
using Microsoft.Framework.DependencyInjection.Extensions;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
using Newtonsoft.Json;
@@ -13,16 +12,31 @@ namespace Microsoft.Framework.DependencyInjection
{
public static class MvcJsonMvcCoreBuilderExtensions
{
- public static IMvcCoreBuilder AddJsonFormatters([NotNull] this IMvcCoreBuilder builder)
+ public static IMvcCoreBuilder AddJsonFormatters(this IMvcCoreBuilder builder)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
AddJsonFormatterServices(builder.Services);
return builder;
}
public static IMvcCoreBuilder AddJsonFormatters(
- [NotNull] this IMvcCoreBuilder builder,
- [NotNull] Action setupAction)
+ this IMvcCoreBuilder builder,
+ Action setupAction)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ if (setupAction == null)
+ {
+ throw new ArgumentNullException(nameof(setupAction));
+ }
+
AddJsonFormatterServices(builder.Services);
if (setupAction != null)
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonInputFormatter.cs b/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonInputFormatter.cs
index aa8d5b452b..f94ef448ef 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonInputFormatter.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonInputFormatter.cs
@@ -6,7 +6,6 @@ using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc.Internal;
-using Microsoft.Framework.Internal;
using Microsoft.Net.Http.Headers;
using Newtonsoft.Json;
@@ -21,8 +20,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
{
}
- public JsonInputFormatter([NotNull] JsonSerializerSettings serializerSettings)
+ public JsonInputFormatter(JsonSerializerSettings serializerSettings)
{
+ if (serializerSettings == null)
+ {
+ throw new ArgumentNullException(nameof(serializerSettings));
+ }
+
_serializerSettings = serializerSettings;
SupportedEncodings.Add(UTF8EncodingWithoutBOM);
@@ -41,16 +45,25 @@ namespace Microsoft.AspNet.Mvc.Formatters
{
return _serializerSettings;
}
- [param: NotNull]
set
{
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
_serializerSettings = value;
}
}
///
- public override Task ReadRequestBodyAsync([NotNull] InputFormatterContext context)
+ public override Task ReadRequestBodyAsync(InputFormatterContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
// Get the character encoding for the content.
var effectiveEncoding = SelectCharacterEncoding(context);
if (effectiveEncoding == null)
@@ -128,10 +141,25 @@ namespace Microsoft.AspNet.Mvc.Formatters
/// The to use when reading.
/// The used during deserialization.
protected virtual JsonReader CreateJsonReader(
- [NotNull] InputFormatterContext context,
- [NotNull] Stream readStream,
- [NotNull] Encoding effectiveEncoding)
+ InputFormatterContext context,
+ Stream readStream,
+ Encoding effectiveEncoding)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (readStream == null)
+ {
+ throw new ArgumentNullException(nameof(readStream));
+ }
+
+ if (effectiveEncoding == null)
+ {
+ throw new ArgumentNullException(nameof(effectiveEncoding));
+ }
+
return new JsonTextReader(new StreamReader(readStream, effectiveEncoding));
}
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonOutputFormatter.cs b/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonOutputFormatter.cs
index d768cb64b8..5983539333 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonOutputFormatter.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonOutputFormatter.cs
@@ -1,11 +1,11 @@
// 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.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc.Internal;
-using Microsoft.Framework.Internal;
using Newtonsoft.Json;
namespace Microsoft.AspNet.Mvc.Formatters
@@ -22,8 +22,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
{
}
- public JsonOutputFormatter([NotNull] JsonSerializerSettings serializerSettings)
+ public JsonOutputFormatter(JsonSerializerSettings serializerSettings)
{
+ if (serializerSettings == null)
+ {
+ throw new ArgumentNullException(nameof(serializerSettings));
+ }
+
_serializerSettings = serializerSettings;
SupportedEncodings.Add(Encoding.UTF8);
@@ -41,15 +46,24 @@ namespace Microsoft.AspNet.Mvc.Formatters
{
return _serializerSettings;
}
- [param: NotNull]
set
{
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
_serializerSettings = value;
}
}
- public void WriteObject([NotNull] TextWriter writer, object value)
+ public void WriteObject(TextWriter writer, object value)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
using (var jsonWriter = CreateJsonWriter(writer))
{
var jsonSerializer = CreateJsonSerializer();
@@ -62,8 +76,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
///
/// The used to write.
/// The used during serialization.
- protected virtual JsonWriter CreateJsonWriter([NotNull] TextWriter writer)
+ protected virtual JsonWriter CreateJsonWriter(TextWriter writer)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
var jsonWriter = new JsonTextWriter(writer);
jsonWriter.CloseOutput = false;
@@ -81,6 +100,11 @@ namespace Microsoft.AspNet.Mvc.Formatters
public override Task WriteResponseBodyAsync(OutputFormatterContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var response = context.HttpContext.Response;
var selectedEncoding = context.SelectedEncoding;
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonPatchExtensions.cs b/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonPatchExtensions.cs
index 911dafae29..98974d9a1c 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonPatchExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonPatchExtensions.cs
@@ -1,9 +1,9 @@
// 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.JsonPatch;
using Microsoft.AspNet.Mvc.ModelBinding;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc
{
@@ -19,10 +19,25 @@ namespace Microsoft.AspNet.Mvc
/// The entity on which is applied.
/// The to add errors.
public static void ApplyTo(
- [NotNull] this JsonPatchDocument patchDoc,
- [NotNull] T objectToApplyTo,
- [NotNull] ModelStateDictionary modelState) where T : class
+ this JsonPatchDocument patchDoc,
+ T objectToApplyTo,
+ ModelStateDictionary modelState) where T : class
{
+ if (patchDoc == null)
+ {
+ throw new ArgumentNullException(nameof(patchDoc));
+ }
+
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
+ if (modelState == null)
+ {
+ throw new ArgumentNullException(nameof(modelState));
+ }
+
patchDoc.ApplyTo(objectToApplyTo, modelState, prefix: string.Empty);
}
@@ -34,11 +49,26 @@ namespace Microsoft.AspNet.Mvc
/// The to add errors.
/// The prefix to use when looking up values in .
public static void ApplyTo(
- [NotNull] this JsonPatchDocument patchDoc,
- [NotNull] T objectToApplyTo,
- [NotNull] ModelStateDictionary modelState,
+ this JsonPatchDocument patchDoc,
+ T objectToApplyTo,
+ ModelStateDictionary modelState,
string prefix) where T : class
{
+ if (patchDoc == null)
+ {
+ throw new ArgumentNullException(nameof(patchDoc));
+ }
+
+ if (objectToApplyTo == null)
+ {
+ throw new ArgumentNullException(nameof(objectToApplyTo));
+ }
+
+ if (modelState == null)
+ {
+ throw new ArgumentNullException(nameof(modelState));
+ }
+
patchDoc.ApplyTo(objectToApplyTo, jsonPatchError =>
{
var affectedObjectName = jsonPatchError.AffectedObject.GetType().Name;
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonPatchInputFormatter.cs b/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonPatchInputFormatter.cs
index 3e9adc9cf6..dd54998e60 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonPatchInputFormatter.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonPatchInputFormatter.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 System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNet.JsonPatch;
-using Microsoft.Framework.Internal;
using Microsoft.AspNet.Mvc.Internal;
using Newtonsoft.Json;
@@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.Formatters
{
}
- public JsonPatchInputFormatter([NotNull] JsonSerializerSettings serializerSettings)
+ public JsonPatchInputFormatter(JsonSerializerSettings serializerSettings)
: base(serializerSettings)
{
// Clear all values and only include json-patch+json value.
@@ -27,8 +27,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
}
///
- public async override Task ReadRequestBodyAsync([NotNull] InputFormatterContext context)
+ public async override Task ReadRequestBodyAsync(InputFormatterContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var result = await base.ReadRequestBodyAsync(context);
if (!result.HasError)
{
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonResult.cs b/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonResult.cs
index 7548f56e9e..fcced61737 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Json/JsonResult.cs
@@ -1,11 +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 System.Text;
using System.Threading.Tasks;
-using Microsoft.AspNet.Mvc.Actions;
using Microsoft.Framework.DependencyInjection;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
using Microsoft.Net.Http.Headers;
using Newtonsoft.Json;
@@ -39,8 +38,13 @@ namespace Microsoft.AspNet.Mvc
/// The value to format as JSON.
/// The to be used by
/// the formatter.
- public JsonResult(object value, [NotNull] JsonSerializerSettings serializerSettings)
+ public JsonResult(object value, JsonSerializerSettings serializerSettings)
{
+ if (serializerSettings == null)
+ {
+ throw new ArgumentNullException(nameof(serializerSettings));
+ }
+
Value = value;
_serializerSettings = serializerSettings;
}
@@ -61,8 +65,13 @@ namespace Microsoft.AspNet.Mvc
public object Value { get; set; }
///
- public override Task ExecuteResultAsync([NotNull] ActionContext context)
+ public override Task ExecuteResultAsync(ActionContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var response = context.HttpContext.Response;
var contentTypeHeader = ContentType;
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Json/project.json b/src/Microsoft.AspNet.Mvc.Formatters.Json/project.json
index f97d8e821c..6ea2caa8f2 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Json/project.json
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Json/project.json
@@ -15,10 +15,6 @@
"version": "1.0.0-*",
"type": "build"
},
- "Microsoft.Framework.NotNullAttribute.Sources": {
- "version": "1.0.0-*",
- "type": "build"
- },
"Newtonsoft.Json": "6.0.6"
},
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/DelegatingEnumerable.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/DelegatingEnumerable.cs
index 5b94782d23..8b91545310 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/DelegatingEnumerable.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/DelegatingEnumerable.cs
@@ -5,7 +5,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Formatters.Xml
{
@@ -39,8 +38,13 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
///
/// The instance to get the enumerator from.
/// The wrapper provider for wrapping individual elements.
- public DelegatingEnumerable([NotNull] IEnumerable source, IWrapperProvider elementWrapperProvider)
+ public DelegatingEnumerable(IEnumerable source, IWrapperProvider elementWrapperProvider)
{
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
_source = source;
_wrapperProvider = elementWrapperProvider;
}
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/DelegatingEnumerator.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/DelegatingEnumerator.cs
index 04866f7397..a831ad9172 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/DelegatingEnumerator.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/DelegatingEnumerator.cs
@@ -1,9 +1,9 @@
// 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.Collections;
using System.Collections.Generic;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Formatters.Xml
{
@@ -25,8 +25,13 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
///
/// The original enumerator.
/// The wrapper provider to wrap individual elements.
- public DelegatingEnumerator([NotNull] IEnumerator inner, IWrapperProvider wrapperProvider)
+ public DelegatingEnumerator(IEnumerator inner, IWrapperProvider wrapperProvider)
{
+ if (inner == null)
+ {
+ throw new ArgumentNullException(nameof(inner));
+ }
+
_inner = inner;
_wrapperProvider = wrapperProvider;
}
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/DependencyInjection/MvcXmlMvcBuilderExtensions.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/DependencyInjection/MvcXmlMvcBuilderExtensions.cs
index 3bc260e7b4..b04e38fa5c 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/DependencyInjection/MvcXmlMvcBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/DependencyInjection/MvcXmlMvcBuilderExtensions.cs
@@ -1,10 +1,10 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Mvc;
using Microsoft.AspNet.Mvc.Formatters.Xml.Internal;
using Microsoft.Framework.DependencyInjection.Extensions;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.Framework.DependencyInjection
@@ -19,8 +19,13 @@ namespace Microsoft.Framework.DependencyInjection
///
/// The .
/// The .
- public static IMvcBuilder AddXmlDataContractSerializerFormatters([NotNull] this IMvcBuilder builder)
+ public static IMvcBuilder AddXmlDataContractSerializerFormatters(this IMvcBuilder builder)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
AddXmlDataContractSerializerFormatterServices(builder.Services);
return builder;
}
@@ -30,8 +35,13 @@ namespace Microsoft.Framework.DependencyInjection
///
/// The .
/// The .
- public static IMvcBuilder AddXmlSerializerFormatters([NotNull] this IMvcBuilder builder)
+ public static IMvcBuilder AddXmlSerializerFormatters(this IMvcBuilder builder)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
AddXmlSerializerFormatterServices(builder.Services);
return builder;
}
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/DependencyInjection/MvcXmlMvcCoreBuilderExtensions.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/DependencyInjection/MvcXmlMvcCoreBuilderExtensions.cs
index f022e52fb9..075ecb2c16 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/DependencyInjection/MvcXmlMvcCoreBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/DependencyInjection/MvcXmlMvcCoreBuilderExtensions.cs
@@ -1,10 +1,10 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Mvc;
using Microsoft.AspNet.Mvc.Formatters.Xml.Internal;
using Microsoft.Framework.DependencyInjection.Extensions;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.Framework.DependencyInjection
@@ -19,8 +19,13 @@ namespace Microsoft.Framework.DependencyInjection
///
/// The .
/// The .
- public static IMvcCoreBuilder AddXmlDataContractSerializerFormatters([NotNull] this IMvcCoreBuilder builder)
+ public static IMvcCoreBuilder AddXmlDataContractSerializerFormatters(this IMvcCoreBuilder builder)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
AddXmlDataContractSerializerFormatterServices(builder.Services);
return builder;
}
@@ -30,8 +35,13 @@ namespace Microsoft.Framework.DependencyInjection
///
/// The .
/// The .
- public static IMvcCoreBuilder AddXmlSerializerFormatters([NotNull] this IMvcCoreBuilder builder)
+ public static IMvcCoreBuilder AddXmlSerializerFormatters(this IMvcCoreBuilder builder)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
AddXmlSerializerFormatterServices(builder.Services);
return builder;
}
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/EnumerableWrapperProvider.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/EnumerableWrapperProvider.cs
index b38d2ca301..795ac62620 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/EnumerableWrapperProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/EnumerableWrapperProvider.cs
@@ -25,9 +25,14 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
/// The for the element type.
/// Can be null.
public EnumerableWrapperProvider(
- [NotNull] Type sourceEnumerableOfT,
+ Type sourceEnumerableOfT,
IWrapperProvider elementWrapperProvider)
{
+ if (sourceEnumerableOfT == null)
+ {
+ throw new ArgumentNullException(nameof(sourceEnumerableOfT));
+ }
+
var enumerableOfT = ClosedGenericMatcher.ExtractGenericInterface(
sourceEnumerableOfT,
typeof(IEnumerable<>));
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/EnumerableWrapperProviderFactory.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/EnumerableWrapperProviderFactory.cs
index 7965756c58..3853f5eac2 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/EnumerableWrapperProviderFactory.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/EnumerableWrapperProviderFactory.cs
@@ -1,6 +1,7 @@
// 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.Collections.Generic;
using System.Reflection;
using Microsoft.Framework.Internal;
@@ -20,8 +21,13 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
/// .
///
/// List of .
- public EnumerableWrapperProviderFactory([NotNull] IEnumerable wrapperProviderFactories)
+ public EnumerableWrapperProviderFactory(IEnumerable wrapperProviderFactories)
{
+ if (wrapperProviderFactories == null)
+ {
+ throw new ArgumentNullException(nameof(wrapperProviderFactories));
+ }
+
_wrapperProviderFactories = wrapperProviderFactories;
}
@@ -31,8 +37,13 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
/// The .
/// An instance of if the declared type is
/// an interface and implements .
- public IWrapperProvider GetProvider([NotNull] WrapperProviderContext context)
+ public IWrapperProvider GetProvider(WrapperProviderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
if (context.IsSerialization)
{
// Example: IEnumerable
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/ModelBinding/DataMemberRequiredBindingMetadataProvider.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/ModelBinding/DataMemberRequiredBindingMetadataProvider.cs
index a9b6884c61..80235a3eb1 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/ModelBinding/DataMemberRequiredBindingMetadataProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/ModelBinding/DataMemberRequiredBindingMetadataProvider.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 System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
{
@@ -14,8 +14,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
public class DataMemberRequiredBindingMetadataProvider : IBindingMetadataProvider
{
///
- public void GetBindingMetadata([NotNull] BindingMetadataProviderContext context)
+ public void GetBindingMetadata(BindingMetadataProviderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
// Types cannot be required; only properties can
if (context.Key.MetadataKind != ModelMetadataKind.Property)
{
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapper.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapper.cs
index af43dff3aa..8c9b738c27 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapper.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapper.cs
@@ -5,7 +5,6 @@ using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Formatters.Xml
{
@@ -25,8 +24,13 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
/// Initializes a new instance of the class.
///
/// The object that needs to be wrapped.
- public SerializableErrorWrapper([NotNull] SerializableError error)
+ public SerializableErrorWrapper(SerializableError error)
{
+ if (error == null)
+ {
+ throw new ArgumentNullException(nameof(error));
+ }
+
SerializableError = error;
}
@@ -88,8 +92,13 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
}
///
- public object Unwrap([NotNull] Type declaredType)
+ public object Unwrap(Type declaredType)
{
+ if (declaredType == null)
+ {
+ throw new ArgumentNullException(nameof(declaredType));
+ }
+
return SerializableError;
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapperProvider.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapperProvider.cs
index 3f265d58ce..11a7a7b935 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapperProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapperProvider.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Formatters.Xml
{
@@ -21,15 +20,20 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
}
///
- public object Wrap([NotNull] object original)
+ public object Wrap(object original)
{
+ if (original == null)
+ {
+ throw new ArgumentNullException(nameof(original));
+ }
+
var error = original as SerializableError;
if (error == null)
{
throw new ArgumentException(
Resources.FormatWrapperProvider_MismatchType(
- typeof(SerializableErrorWrapper).Name,
- original.GetType().Name),
+ typeof(SerializableErrorWrapper).Name,
+ original.GetType().Name),
nameof(original));
}
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapperProviderFactory.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapperProviderFactory.cs
index ab1589c07b..32ccb27688 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapperProviderFactory.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/SerializableErrorWrapperProviderFactory.cs
@@ -1,7 +1,7 @@
// 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.Framework.Internal;
+using System;
namespace Microsoft.AspNet.Mvc.Formatters.Xml
{
@@ -21,8 +21,13 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
/// is
/// ; otherwise null.
///
- public IWrapperProvider GetProvider([NotNull] WrapperProviderContext context)
+ public IWrapperProvider GetProvider(WrapperProviderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
if (context.DeclaredType == typeof(SerializableError))
{
return new SerializableErrorWrapperProvider();
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/WrapperProviderContext.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/WrapperProviderContext.cs
index fa8fec8640..91867e9010 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/WrapperProviderContext.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/WrapperProviderContext.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Formatters.Xml
{
@@ -17,8 +16,13 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
/// The declared type of the object that needs to be wrapped.
/// if the wrapper provider is invoked during
/// serialization, otherwise .
- public WrapperProviderContext([NotNull] Type declaredType, bool isSerialization)
+ public WrapperProviderContext(Type declaredType, bool isSerialization)
{
+ if (declaredType == null)
+ {
+ throw new ArgumentNullException(nameof(declaredType));
+ }
+
DeclaredType = declaredType;
IsSerialization = isSerialization;
}
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/WrapperProviderFactoriesExtensions.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/WrapperProviderFactoriesExtensions.cs
index e9ead0ed29..f9bcd05646 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/WrapperProviderFactoriesExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/WrapperProviderFactoriesExtensions.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Formatters.Xml
{
@@ -21,9 +20,19 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
/// An instance of if there is a wrapping provider for the
/// supplied type, else null.
public static IWrapperProvider GetWrapperProvider(
- [NotNull] this IEnumerable wrapperProviderFactories,
- [NotNull] WrapperProviderContext wrapperProviderContext)
+ this IEnumerable wrapperProviderFactories,
+ WrapperProviderContext wrapperProviderContext)
{
+ if (wrapperProviderFactories == null)
+ {
+ throw new ArgumentNullException(nameof(wrapperProviderFactories));
+ }
+
+ if (wrapperProviderContext == null)
+ {
+ throw new ArgumentNullException(nameof(wrapperProviderContext));
+ }
+
foreach (var wrapperProviderFactory in wrapperProviderFactories)
{
var wrapperProvider = wrapperProviderFactory.GetProvider(wrapperProviderContext);
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlDataContractSerializerInputFormatter.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlDataContractSerializerInputFormatter.cs
index 199dce70b5..d423229d9e 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlDataContractSerializerInputFormatter.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlDataContractSerializerInputFormatter.cs
@@ -12,7 +12,6 @@ using System.Xml;
using Microsoft.AspNet.Mvc.Formatters.Xml;
using Microsoft.AspNet.Mvc.Formatters.Xml.Internal;
using Microsoft.AspNet.Mvc.Internal;
-using Microsoft.Framework.Internal;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNet.Mvc.Formatters
@@ -118,8 +117,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
}
///
- protected override bool CanReadType([NotNull] Type type)
+ protected override bool CanReadType(Type type)
{
+ if (type == null)
+ {
+ throw new ArgumentNullException(nameof(type));
+ }
+
return GetCachedSerializer(GetSerializableType(type)) != null;
}
@@ -129,8 +133,18 @@ namespace Microsoft.AspNet.Mvc.Formatters
/// The from which to read.
/// The used to read the stream.
/// The used during deserialization.
- protected virtual XmlReader CreateXmlReader([NotNull] Stream readStream, [NotNull] Encoding encoding)
+ protected virtual XmlReader CreateXmlReader(Stream readStream, Encoding encoding)
{
+ if (readStream == null)
+ {
+ throw new ArgumentNullException(nameof(readStream));
+ }
+
+ if (encoding == null)
+ {
+ throw new ArgumentNullException(nameof(encoding));
+ }
+
return XmlDictionaryReader.CreateTextReader(readStream, encoding, _readerQuotas, onClose: null);
}
@@ -139,8 +153,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
///
/// The declared type.
/// The type to which the XML will be deserialized.
- protected virtual Type GetSerializableType([NotNull] Type declaredType)
+ protected virtual Type GetSerializableType(Type declaredType)
{
+ if (declaredType == null)
+ {
+ throw new ArgumentNullException(nameof(declaredType));
+ }
+
var wrapperProvider = WrapperProviderFactories.GetWrapperProvider(
new WrapperProviderContext(declaredType, isSerialization: false));
@@ -152,8 +171,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
///
/// The type of object for which the serializer should be created.
/// The used during deserialization.
- protected virtual DataContractSerializer CreateSerializer([NotNull] Type type)
+ protected virtual DataContractSerializer CreateSerializer(Type type)
{
+ if (type == null)
+ {
+ throw new ArgumentNullException(nameof(type));
+ }
+
try
{
// If the serializer does not support this type it will throw an exception.
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlDataContractSerializerOutputFormatter.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlDataContractSerializerOutputFormatter.cs
index d486b74eed..cef971d825 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlDataContractSerializerOutputFormatter.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlDataContractSerializerOutputFormatter.cs
@@ -11,7 +11,6 @@ using System.Threading.Tasks;
using System.Xml;
using Microsoft.AspNet.Mvc.Formatters.Xml;
using Microsoft.AspNet.Mvc.Formatters.Xml.Internal;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Formatters
{
@@ -37,8 +36,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
/// Initializes a new instance of
///
/// The settings to be used by the .
- public XmlDataContractSerializerOutputFormatter([NotNull] XmlWriterSettings writerSettings)
+ public XmlDataContractSerializerOutputFormatter(XmlWriterSettings writerSettings)
{
+ if (writerSettings == null)
+ {
+ throw new ArgumentNullException(nameof(writerSettings));
+ }
+
SupportedEncodings.Add(Encoding.UTF8);
SupportedEncodings.Add(Encoding.Unicode);
@@ -132,8 +136,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
///
/// The type of object for which the serializer should be created.
/// A new instance of
- protected virtual DataContractSerializer CreateSerializer([NotNull] Type type)
+ protected virtual DataContractSerializer CreateSerializer(Type type)
{
+ if (type == null)
+ {
+ throw new ArgumentNullException(nameof(type));
+ }
+
try
{
#if DNX451
@@ -157,17 +166,32 @@ namespace Microsoft.AspNet.Mvc.Formatters
/// The stream on which the XmlWriter should operate on.
/// A new instance of
public virtual XmlWriter CreateXmlWriter(
- [NotNull] Stream writeStream,
- [NotNull] XmlWriterSettings xmlWriterSettings)
+ Stream writeStream,
+ XmlWriterSettings xmlWriterSettings)
{
+ if (writeStream == null)
+ {
+ throw new ArgumentNullException(nameof(writeStream));
+ }
+
+ if (xmlWriterSettings == null)
+ {
+ throw new ArgumentNullException(nameof(xmlWriterSettings));
+ }
+
return XmlWriter.Create(
new HttpResponseStreamWriter(writeStream, xmlWriterSettings.Encoding),
xmlWriterSettings);
}
///
- public override Task WriteResponseBodyAsync([NotNull] OutputFormatterContext context)
+ public override Task WriteResponseBodyAsync(OutputFormatterContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var tempWriterSettings = WriterSettings.Clone();
tempWriterSettings.Encoding = context.SelectedEncoding;
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlSerializerInputFormatter.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlSerializerInputFormatter.cs
index c94902f8e6..2303cef16e 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlSerializerInputFormatter.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlSerializerInputFormatter.cs
@@ -12,7 +12,6 @@ using System.Xml.Serialization;
using Microsoft.AspNet.Mvc.Formatters.Xml;
using Microsoft.AspNet.Mvc.Formatters.Xml.Internal;
using Microsoft.AspNet.Mvc.Internal;
-using Microsoft.Framework.Internal;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNet.Mvc.Formatters
@@ -98,8 +97,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
}
///
- protected override bool CanReadType([NotNull] Type type)
+ protected override bool CanReadType(Type type)
{
+ if (type == null)
+ {
+ throw new ArgumentNullException(nameof(type));
+ }
+
return GetCachedSerializer(GetSerializableType(type)) != null;
}
@@ -108,8 +112,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
///
/// The declared type.
/// The type to which the XML will be deserialized.
- protected virtual Type GetSerializableType([NotNull] Type declaredType)
+ protected virtual Type GetSerializableType(Type declaredType)
{
+ if (declaredType == null)
+ {
+ throw new ArgumentNullException(nameof(declaredType));
+ }
+
var wrapperProvider = WrapperProviderFactories.GetWrapperProvider(
new WrapperProviderContext(declaredType, isSerialization: false));
@@ -122,8 +131,18 @@ namespace Microsoft.AspNet.Mvc.Formatters
/// The from which to read.
/// The used to read the stream.
/// The used during deserialization.
- protected virtual XmlReader CreateXmlReader([NotNull] Stream readStream, [NotNull] Encoding encoding)
+ protected virtual XmlReader CreateXmlReader(Stream readStream, Encoding encoding)
{
+ if (readStream == null)
+ {
+ throw new ArgumentNullException(nameof(readStream));
+ }
+
+ if (encoding == null)
+ {
+ throw new ArgumentNullException(nameof(encoding));
+ }
+
return XmlDictionaryReader.CreateTextReader(readStream, encoding, _readerQuotas, onClose: null);
}
@@ -162,7 +181,7 @@ namespace Microsoft.AspNet.Mvc.Formatters
}
}
- return (XmlSerializer) serializer;
+ return (XmlSerializer)serializer;
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlSerializerOutputFormatter.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlSerializerOutputFormatter.cs
index b200260ae7..a6e822eeb4 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlSerializerOutputFormatter.cs
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/XmlSerializerOutputFormatter.cs
@@ -11,7 +11,6 @@ using System.Xml;
using System.Xml.Serialization;
using Microsoft.AspNet.Mvc.Formatters.Xml;
using Microsoft.AspNet.Mvc.Formatters.Xml.Internal;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Formatters
{
@@ -36,8 +35,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
/// Initializes a new instance of
///
/// The settings to be used by the .
- public XmlSerializerOutputFormatter([NotNull] XmlWriterSettings writerSettings)
+ public XmlSerializerOutputFormatter(XmlWriterSettings writerSettings)
{
+ if (writerSettings == null)
+ {
+ throw new ArgumentNullException(nameof(writerSettings));
+ }
+
SupportedEncodings.Add(Encoding.UTF8);
SupportedEncodings.Add(Encoding.Unicode);
@@ -111,8 +115,13 @@ namespace Microsoft.AspNet.Mvc.Formatters
///
/// The type of object for which the serializer should be created.
/// A new instance of
- protected virtual XmlSerializer CreateSerializer([NotNull] Type type)
+ protected virtual XmlSerializer CreateSerializer(Type type)
{
+ if (type == null)
+ {
+ throw new ArgumentNullException(nameof(type));
+ }
+
try
{
// If the serializer does not support this type it will throw an exception.
@@ -132,17 +141,32 @@ namespace Microsoft.AspNet.Mvc.Formatters
/// The stream on which the XmlWriter should operate on.
/// A new instance of
public virtual XmlWriter CreateXmlWriter(
- [NotNull] Stream writeStream,
- [NotNull] XmlWriterSettings xmlWriterSettings)
+ Stream writeStream,
+ XmlWriterSettings xmlWriterSettings)
{
+ if (writeStream == null)
+ {
+ throw new ArgumentNullException(nameof(writeStream));
+ }
+
+ if (xmlWriterSettings == null)
+ {
+ throw new ArgumentNullException(nameof(xmlWriterSettings));
+ }
+
return XmlWriter.Create(
new HttpResponseStreamWriter(writeStream, xmlWriterSettings.Encoding),
xmlWriterSettings);
}
///
- public override Task WriteResponseBodyAsync([NotNull] OutputFormatterContext context)
+ public override Task WriteResponseBodyAsync(OutputFormatterContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var response = context.HttpContext.Response;
var tempWriterSettings = WriterSettings.Clone();
diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/project.json b/src/Microsoft.AspNet.Mvc.Formatters.Xml/project.json
index 755429c1bd..5eb3c1fd63 100644
--- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/project.json
+++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/project.json
@@ -11,7 +11,6 @@
"dependencies": {
"Microsoft.AspNet.Mvc.Core": "6.0.0-*",
"Microsoft.Framework.ClosedGenericMatcher.Sources": { "version": "1.0.0-*", "type": "build" },
- "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" }
},
"frameworks": {
diff --git a/src/Microsoft.AspNet.Mvc.Localization/DependencyInjection/MvcLocalizationMvcBuilderExtensions.cs b/src/Microsoft.AspNet.Mvc.Localization/DependencyInjection/MvcLocalizationMvcBuilderExtensions.cs
index bcd02cfe3a..bfdc0c2f72 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/DependencyInjection/MvcLocalizationMvcBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/DependencyInjection/MvcLocalizationMvcBuilderExtensions.cs
@@ -1,14 +1,9 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Linq;
-using Microsoft.AspNet.Mvc;
-using Microsoft.AspNet.Mvc.Localization;
+using System;
using Microsoft.AspNet.Mvc.Localization.Internal;
using Microsoft.AspNet.Mvc.Razor;
-using Microsoft.Framework.DependencyInjection.Extensions;
-using Microsoft.Framework.Internal;
-using Microsoft.Framework.WebEncoders;
namespace Microsoft.Framework.DependencyInjection
{
@@ -22,8 +17,13 @@ namespace Microsoft.Framework.DependencyInjection
///
/// The .
/// The .
- public static IMvcBuilder AddViewLocalization([NotNull] this IMvcBuilder builder)
+ public static IMvcBuilder AddViewLocalization(this IMvcBuilder builder)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
return AddViewLocalization(builder, LanguageViewLocationExpanderFormat.Suffix);
}
@@ -34,9 +34,14 @@ namespace Microsoft.Framework.DependencyInjection
/// The view format for localized views.
/// The .
public static IMvcBuilder AddViewLocalization(
- [NotNull] this IMvcBuilder builder,
+ this IMvcBuilder builder,
LanguageViewLocationExpanderFormat format)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
MvcLocalizationServices.AddLocalizationServices(builder.Services, format);
return builder;
}
diff --git a/src/Microsoft.AspNet.Mvc.Localization/DependencyInjection/MvcLocalizationMvcCoreBuilderExtensions.cs b/src/Microsoft.AspNet.Mvc.Localization/DependencyInjection/MvcLocalizationMvcCoreBuilderExtensions.cs
index dc8108c451..7c67737dcc 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/DependencyInjection/MvcLocalizationMvcCoreBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/DependencyInjection/MvcLocalizationMvcCoreBuilderExtensions.cs
@@ -1,9 +1,9 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Mvc.Localization.Internal;
using Microsoft.AspNet.Mvc.Razor;
-using Microsoft.Framework.Internal;
namespace Microsoft.Framework.DependencyInjection
{
@@ -22,8 +22,13 @@ namespace Microsoft.Framework.DependencyInjection
/// and the Razor view engine
/// via .
///
- public static IMvcCoreBuilder AddViewLocalization([NotNull] this IMvcCoreBuilder builder)
+ public static IMvcCoreBuilder AddViewLocalization(this IMvcCoreBuilder builder)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
return AddViewLocalization(builder, LanguageViewLocationExpanderFormat.Suffix);
}
@@ -39,9 +44,14 @@ namespace Microsoft.Framework.DependencyInjection
/// via .
///
public static IMvcCoreBuilder AddViewLocalization(
- [NotNull] this IMvcCoreBuilder builder,
+ this IMvcCoreBuilder builder,
LanguageViewLocationExpanderFormat format)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
builder.AddViews();
builder.AddRazorViewEngine();
diff --git a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs
index 6f2d356031..e30e726ec2 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs
@@ -1,12 +1,10 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Collections.Generic;
-using System.Diagnostics;
using System.Globalization;
using System.Text;
-using Microsoft.AspNet.Mvc.Rendering;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.Localization;
using Microsoft.Framework.WebEncoders;
@@ -27,51 +25,125 @@ namespace Microsoft.AspNet.Mvc.Localization
///
/// The to read strings from.
/// The .
- public HtmlLocalizer([NotNull] IStringLocalizer localizer, [NotNull] IHtmlEncoder encoder)
+ public HtmlLocalizer(IStringLocalizer localizer, IHtmlEncoder encoder)
{
+ if (localizer == null)
+ {
+ throw new ArgumentNullException(nameof(localizer));
+ }
+
+ if (encoder == null)
+ {
+ throw new ArgumentNullException(nameof(encoder));
+ }
+
_localizer = localizer;
_encoder = encoder;
}
///
- public virtual LocalizedString this[[NotNull] string key] => _localizer[key];
+ public virtual LocalizedString this[string key]
+ {
+ get
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer[key];
+ }
+ }
///
- public virtual LocalizedString this[[NotNull] string key, params object[] arguments] =>
- _localizer[key, arguments];
+ public virtual LocalizedString this[string key, params object[] arguments]
+ {
+ get
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer[key, arguments];
+ }
+ }
///
/// Creates a new for a specific .
///
/// The to use.
/// A culture-specific .
- public virtual IHtmlLocalizer WithCulture([NotNull] CultureInfo culture) =>
- new HtmlLocalizer(_localizer.WithCulture(culture), _encoder);
+ public virtual IHtmlLocalizer WithCulture(CultureInfo culture)
+ {
+ if (culture == null)
+ {
+ throw new ArgumentNullException(nameof(culture));
+ }
+
+ return new HtmlLocalizer(_localizer.WithCulture(culture), _encoder);
+ }
///
/// Creates a new for a specific .
///
/// The to use.
/// A culture-specific .
- IStringLocalizer IStringLocalizer.WithCulture([NotNull] CultureInfo culture) => WithCulture(culture);
+ IStringLocalizer IStringLocalizer.WithCulture(CultureInfo culture)
+ {
+ if (culture == null)
+ {
+ throw new ArgumentNullException(nameof(culture));
+ }
+
+ return new HtmlLocalizer(_localizer.WithCulture(culture), _encoder);
+ }
///
- public virtual LocalizedString GetString([NotNull] string key) => _localizer.GetString(key);
+ public virtual LocalizedString GetString(string key)
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer.GetString(key);
+ }
///
- public virtual LocalizedString GetString([NotNull] string key, params object[] arguments) =>
- _localizer.GetString(key, arguments);
+ public virtual LocalizedString GetString(string key, params object[] arguments)
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer.GetString(key, arguments);
+ }
///
public virtual IEnumerable GetAllStrings(bool includeAncestorCultures) =>
_localizer.GetAllStrings(includeAncestorCultures);
///
- public virtual LocalizedHtmlString Html([NotNull] string key) => ToHtmlString(_localizer.GetString(key));
+ public virtual LocalizedHtmlString Html(string key)
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return ToHtmlString(_localizer.GetString(key));
+ }
///
- public virtual LocalizedHtmlString Html([NotNull] string key, params object[] arguments)
+ public virtual LocalizedHtmlString Html(string key, params object[] arguments)
{
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
var stringValue = _localizer[key].Value;
return ToHtmlString(new LocalizedString(key, EncodeArguments(stringValue, arguments)));
@@ -90,8 +162,18 @@ namespace Microsoft.AspNet.Mvc.Localization
/// The resourceString whose arguments need to be encoded.
/// The array of objects to encode.
/// The string with encoded arguments.
- protected virtual string EncodeArguments([NotNull] string resourceString, [NotNull] object[] arguments)
+ protected virtual string EncodeArguments(string resourceString, object[] arguments)
{
+ if (resourceString == null)
+ {
+ throw new ArgumentNullException(nameof(resourceString));
+ }
+
+ if (arguments == null)
+ {
+ throw new ArgumentNullException(nameof(arguments));
+ }
+
var position = 0;
var length = resourceString.Length;
char currentCharacter;
diff --git a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs
index 1193bd8a49..54e99b2920 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs
@@ -1,8 +1,7 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Framework.Internal;
using Microsoft.Framework.Localization;
using Microsoft.Framework.WebEncoders;
@@ -21,8 +20,18 @@ namespace Microsoft.AspNet.Mvc.Localization
///
/// The .
/// The .
- public HtmlLocalizerFactory([NotNull] IStringLocalizerFactory localizerFactory, [NotNull] IHtmlEncoder encoder)
+ public HtmlLocalizerFactory(IStringLocalizerFactory localizerFactory, IHtmlEncoder encoder)
{
+ if (localizerFactory == null)
+ {
+ throw new ArgumentNullException(nameof(localizerFactory));
+ }
+
+ if (encoder == null)
+ {
+ throw new ArgumentNullException(nameof(encoder));
+ }
+
_factory = localizerFactory;
_encoder = encoder;
}
@@ -35,6 +44,11 @@ namespace Microsoft.AspNet.Mvc.Localization
/// The .
public virtual IHtmlLocalizer Create(Type resourceSource)
{
+ if (resourceSource == null)
+ {
+ throw new ArgumentNullException(nameof(resourceSource));
+ }
+
return new HtmlLocalizer(_factory.Create(resourceSource), _encoder);
}
@@ -46,6 +60,16 @@ namespace Microsoft.AspNet.Mvc.Localization
/// The .
public virtual IHtmlLocalizer Create(string baseName, string location)
{
+ if (baseName == null)
+ {
+ throw new ArgumentNullException(nameof(baseName));
+ }
+
+ if (location == null)
+ {
+ throw new ArgumentNullException(nameof(location));
+ }
+
var localizer = _factory.Create(baseName, location);
return new HtmlLocalizer(localizer, _encoder);
}
diff --git a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerOfT.cs b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerOfT.cs
index 682e0a8405..3a4ac75b9a 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerOfT.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerOfT.cs
@@ -1,9 +1,9 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Collections.Generic;
using System.Globalization;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.Localization;
namespace Microsoft.AspNet.Mvc.Localization
@@ -26,32 +26,98 @@ namespace Microsoft.AspNet.Mvc.Localization
}
///
- public virtual LocalizedString this[[NotNull] string key] => _localizer[key];
+ public virtual LocalizedString this[string key]
+ {
+ get
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer[key];
+ }
+ }
///
- public virtual LocalizedString this[[NotNull] string key, params object[] arguments] =>
- _localizer[key, arguments];
+ public virtual LocalizedString this[string key, params object[] arguments]
+ {
+ get
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer[key, arguments];
+ }
+ }
///
- public virtual IHtmlLocalizer WithCulture([NotNull] CultureInfo culture) => _localizer.WithCulture(culture);
+ public virtual IHtmlLocalizer WithCulture(CultureInfo culture)
+ {
+ if (culture == null)
+ {
+ throw new ArgumentNullException(nameof(culture));
+ }
+
+ return _localizer.WithCulture(culture);
+ }
///
- IStringLocalizer IStringLocalizer.WithCulture([NotNull] CultureInfo culture) =>
- _localizer.WithCulture(culture);
+ IStringLocalizer IStringLocalizer.WithCulture(CultureInfo culture)
+ {
+ if (culture == null)
+ {
+ throw new ArgumentNullException(nameof(culture));
+ }
+
+ return _localizer.WithCulture(culture);
+ }
///
- public virtual LocalizedString GetString([NotNull] string key) => _localizer.GetString(key);
+ public virtual LocalizedString GetString(string key)
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer.GetString(key);
+ }
///
- public virtual LocalizedString GetString([NotNull] string key, params object[] arguments) =>
- _localizer.GetString(key, arguments);
+ public virtual LocalizedString GetString(string key, params object[] arguments)
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer.GetString(key, arguments);
+ }
///
- public virtual LocalizedHtmlString Html([NotNull] string key) => _localizer.Html(key);
+ public virtual LocalizedHtmlString Html(string key)
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer.Html(key);
+ }
///
- public virtual LocalizedHtmlString Html([NotNull] string key, params object[] arguments) =>
- _localizer.Html(key, arguments);
+ public virtual LocalizedHtmlString Html(string key, params object[] arguments)
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer.Html(key, arguments);
+ }
///
public virtual IEnumerable GetAllStrings(bool includeAncestorCultures) =>
diff --git a/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizer.cs b/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizer.cs
index bda07a7ec5..a8107d4fed 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizer.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizer.cs
@@ -1,8 +1,7 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Globalization;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.Localization;
namespace Microsoft.AspNet.Mvc.Localization
@@ -18,14 +17,14 @@ namespace Microsoft.AspNet.Mvc.Localization
///
/// The to use.
/// A culture-specific .
- new IHtmlLocalizer WithCulture([NotNull] CultureInfo culture);
+ new IHtmlLocalizer WithCulture(CultureInfo culture);
///
/// Gets the resource for a specific key.
///
/// The key to use.
/// The resource.
- LocalizedHtmlString Html([NotNull] string key);
+ LocalizedHtmlString Html(string key);
///
/// Gets the resource for a specific key.
@@ -33,6 +32,6 @@ namespace Microsoft.AspNet.Mvc.Localization
/// The key to use.
/// The values to format the string with.
/// The resource.
- LocalizedHtmlString Html([NotNull] string key, params object[] arguments);
+ LocalizedHtmlString Html(string key, params object[] arguments);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizerFactory.cs b/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizerFactory.cs
index c68889a485..80557c6cfc 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizerFactory.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizerFactory.cs
@@ -1,8 +1,7 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Localization
{
@@ -17,7 +16,7 @@ namespace Microsoft.AspNet.Mvc.Localization
///
/// The .
/// The .
- IHtmlLocalizer Create([NotNull] Type resourceSource);
+ IHtmlLocalizer Create(Type resourceSource);
///
/// Creates an .
@@ -25,6 +24,6 @@ namespace Microsoft.AspNet.Mvc.Localization
/// The base name of the resource to load strings from.
/// The location to load resources from.
/// The .
- IHtmlLocalizer Create([NotNull] string baseName, [NotNull] string location);
+ IHtmlLocalizer Create(string baseName, string location);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Localization/ViewLocalizer.cs b/src/Microsoft.AspNet.Mvc.Localization/ViewLocalizer.cs
index 0b4447b73b..6bc5512597 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/ViewLocalizer.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/ViewLocalizer.cs
@@ -1,11 +1,11 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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.Collections.Generic;
using System.Globalization;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.Localization;
using Microsoft.Dnx.Runtime;
@@ -26,41 +26,78 @@ namespace Microsoft.AspNet.Mvc.Localization
/// The .
/// The .
public ViewLocalizer(
- [NotNull] IHtmlLocalizerFactory localizerFactory,
- [NotNull] IApplicationEnvironment applicationEnvironment)
+ IHtmlLocalizerFactory localizerFactory,
+ IApplicationEnvironment applicationEnvironment)
{
+ if (localizerFactory == null)
+ {
+ throw new ArgumentNullException(nameof(localizerFactory));
+ }
+
+ if (applicationEnvironment == null)
+ {
+ throw new ArgumentNullException(nameof(applicationEnvironment));
+ }
+
_applicationName = applicationEnvironment.ApplicationName;
_localizerFactory = localizerFactory;
}
///
- public LocalizedString this[[NotNull] string name] => _localizer[name];
+ public virtual LocalizedString this[string key]
+ {
+ get
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer[key];
+ }
+ }
///
- public LocalizedString this[[NotNull] string name, params object[] arguments] => _localizer[name, arguments];
+ public virtual LocalizedString this[string key, params object[] arguments]
+ {
+ get
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ return _localizer[key, arguments];
+ }
+ }
///
- public LocalizedString GetString([NotNull] string name) => _localizer.GetString(name);
+ public LocalizedString GetString(string name) => _localizer.GetString(name);
///
- public LocalizedString GetString([NotNull] string name, params object[] values) =>
+ public LocalizedString GetString(string name, params object[] values) =>
_localizer.GetString(name, values);
///
- public LocalizedHtmlString Html([NotNull] string key) => _localizer.Html(key);
+ public LocalizedHtmlString Html(string key) => _localizer.Html(key);
///
- public LocalizedHtmlString Html([NotNull] string key, params object[] arguments) =>
+ public LocalizedHtmlString Html(string key, params object[] arguments) =>
_localizer.Html(key, arguments);
///
- public IStringLocalizer WithCulture([NotNull] CultureInfo culture) => _localizer.WithCulture(culture);
+ public IStringLocalizer WithCulture(CultureInfo culture) => _localizer.WithCulture(culture);
///
- IHtmlLocalizer IHtmlLocalizer.WithCulture([NotNull] CultureInfo culture) => _localizer.WithCulture(culture);
+ IHtmlLocalizer IHtmlLocalizer.WithCulture(CultureInfo culture) => _localizer.WithCulture(culture);
public void Contextualize(ViewContext viewContext)
{
+ if (viewContext == null)
+ {
+ throw new ArgumentNullException(nameof(viewContext));
+ }
+
var baseName = viewContext.View.Path.Replace('/', '.').Replace('\\', '.');
if (baseName.StartsWith("."))
{
diff --git a/src/Microsoft.AspNet.Mvc.Localization/project.json b/src/Microsoft.AspNet.Mvc.Localization/project.json
index b8e86d6abb..55229dc237 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/project.json
+++ b/src/Microsoft.AspNet.Mvc.Localization/project.json
@@ -9,10 +9,6 @@
"Microsoft.AspNet.Mvc.Razor": "6.0.0-*",
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
"Microsoft.Framework.Localization": "1.0.0-*",
- "Microsoft.Framework.NotNullAttribute.Sources": {
- "version": "1.0.0-*",
- "type": "build"
- },
"Microsoft.Framework.PropertyHelper.Sources": {
"version": "1.0.0-*",
"type": "build"
diff --git a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/ModelMetadataProviderTest.cs b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/ModelMetadataProviderTest.cs
index 30a9d531ff..0ececa2501 100644
--- a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/ModelMetadataProviderTest.cs
+++ b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/ModelMetadataProviderTest.cs
@@ -5,11 +5,8 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
-using System.Reflection;
using System.Runtime.Serialization;
-using System.Threading;
using Microsoft.AspNet.Testing;
-using Microsoft.Framework.Internal;
using Xunit;
namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
@@ -1044,7 +1041,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
new ModelAttributes(_attributes.Concat(entry.ModelAttributes.TypeAttributes).ToArray()));
}
- protected override DefaultMetadataDetails[] CreatePropertyDetails([NotNull] ModelMetadataIdentity key)
+ protected override DefaultMetadataDetails[] CreatePropertyDetails(ModelMetadataIdentity key)
{
var entries = base.CreatePropertyDetails(key);
return entries.Select(e =>
diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
index df6aba60f0..442ee75e1b 100644
--- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
@@ -17,7 +17,7 @@ using Microsoft.AspNet.Mvc.ViewEngines;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.AspNet.Routing;
-using Microsoft.AspNet.Testing.xunit;
+using Microsoft.Framework.Caching;
using Microsoft.Framework.Caching.Memory;
using Microsoft.Framework.WebEncoders.Testing;
using Moq;
@@ -303,6 +303,8 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
.Returns(emptyDirectoryContents.Object);
mockFileProvider.Setup(fp => fp.GetFileInfo(It.IsAny()))
.Returns(mockFile.Object);
+ mockFileProvider.Setup(fp => fp.Watch(It.IsAny()))
+ .Returns(new TestFileTrigger());
var hostingEnvironment = new Mock();
hostingEnvironment.Setup(h => h.WebRootFileProvider).Returns(mockFileProvider.Object);
diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/Internal/FileVersionProviderTest.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/Internal/FileVersionProviderTest.cs
index 96248811c8..b1d22494fe 100644
--- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/Internal/FileVersionProviderTest.cs
+++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/Internal/FileVersionProviderTest.cs
@@ -7,7 +7,6 @@ using System.Text;
using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
-using Microsoft.AspNet.Testing.xunit;
using Microsoft.Framework.Caching;
using Microsoft.Framework.Caching.Memory;
using Moq;
@@ -54,6 +53,8 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
var mockFileProvider = new Mock();
mockFileProvider.Setup(fp => fp.GetFileInfo(It.IsAny()))
.Returns(mockFile.Object);
+ mockFileProvider.Setup(fp => fp.Watch(It.IsAny()))
+ .Returns(new TestFileTrigger());
var hostingEnvironment = new Mock();
hostingEnvironment.Setup(h => h.WebRootFileProvider).Returns(mockFileProvider.Object);
@@ -195,6 +196,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
.Returns(fileDoesNotExist? nonExistingMockFile.Object : existingMockFile.Object);
}
+ mockFileProvider.Setup(fp => fp.Watch(It.IsAny()))
+ .Returns(new TestFileTrigger());
+
var hostingEnvironment = new Mock();
hostingEnvironment.Setup(h => h.WebRootFileProvider).Returns(mockFileProvider.Object);
diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/LinkTagHelperTest.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/LinkTagHelperTest.cs
index 4e0f261f8d..e296c45d55 100644
--- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/LinkTagHelperTest.cs
+++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/LinkTagHelperTest.cs
@@ -18,8 +18,8 @@ using Microsoft.AspNet.Mvc.ViewEngines;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.AspNet.Routing;
-using Microsoft.AspNet.Testing.xunit;
using Microsoft.Dnx.Runtime;
+using Microsoft.Framework.Caching;
using Microsoft.Framework.Caching.Memory;
using Microsoft.Framework.Logging;
using Microsoft.Framework.WebEncoders.Testing;
@@ -870,6 +870,8 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
.Returns(emptyDirectoryContents.Object);
mockFileProvider.Setup(fp => fp.GetFileInfo(It.IsAny()))
.Returns(mockFile.Object);
+ mockFileProvider.Setup(fp => fp.Watch(It.IsAny()))
+ .Returns(new TestFileTrigger());
var hostingEnvironment = new Mock();
hostingEnvironment.Setup(h => h.WebRootFileProvider).Returns(mockFileProvider.Object);
diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ScriptTagHelperTest.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ScriptTagHelperTest.cs
index 06ec01ebd1..4ffc37d4e7 100644
--- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ScriptTagHelperTest.cs
+++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ScriptTagHelperTest.cs
@@ -18,7 +18,6 @@ using Microsoft.AspNet.Mvc.ViewEngines;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.AspNet.Routing;
-using Microsoft.AspNet.Testing.xunit;
using Microsoft.Dnx.Runtime;
using Microsoft.Framework.Caching;
using Microsoft.Framework.Caching.Memory;
@@ -964,6 +963,8 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
.Returns(emptyDirectoryContents.Object);
mockFileProvider.Setup(fp => fp.GetFileInfo(It.IsAny()))
.Returns(mockFile.Object);
+ mockFileProvider.Setup(fp => fp.Watch(It.IsAny()))
+ .Returns(new TestFileTrigger());
var hostingEnvironment = new Mock();
hostingEnvironment.Setup(h => h.WebRootFileProvider).Returns(mockFileProvider.Object);
diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/TestFileTrigger.cs b/test/Microsoft.AspNet.Mvc.TestCommon/TestFileTrigger.cs
index 95ad57151d..469431e581 100644
--- a/test/Microsoft.AspNet.Mvc.TestCommon/TestFileTrigger.cs
+++ b/test/Microsoft.AspNet.Mvc.TestCommon/TestFileTrigger.cs
@@ -2,9 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Microsoft.Framework.Caching;
-namespace Microsoft.AspNet.Mvc.Razor
+namespace Microsoft.Framework.Caching
{
internal class TestFileTrigger : IExpirationTrigger
{
diff --git a/test/WebSites/FiltersWebSite/AuthorizeBasicMiddleware.cs b/test/WebSites/FiltersWebSite/AuthorizeBasicMiddleware.cs
index ac02e3f7db..bfe5b67a87 100644
--- a/test/WebSites/FiltersWebSite/AuthorizeBasicMiddleware.cs
+++ b/test/WebSites/FiltersWebSite/AuthorizeBasicMiddleware.cs
@@ -11,12 +11,14 @@ namespace FiltersWebSite
public class AuthorizeBasicMiddleware : AuthenticationMiddleware
{
public AuthorizeBasicMiddleware(
- RequestDelegate next,
+ RequestDelegate next,
ILoggerFactory loggerFactory,
IUrlEncoder encoder,
- string authScheme) :
- base(next, new BasicOptions { AuthenticationScheme = authScheme }, loggerFactory,
- encoder, configureOptions: null)
+ string authScheme) :
+ base(next,
+ new BasicOptions { AuthenticationScheme = authScheme },
+ loggerFactory,
+ encoder)
{
}