diff --git a/src/Microsoft.AspNet.JsonPatch/Adapters/IObjectAdapter.cs b/src/Microsoft.AspNet.JsonPatch/Adapters/IObjectAdapter.cs
index bd381c97cd..724dfe3f79 100644
--- a/src/Microsoft.AspNet.JsonPatch/Adapters/IObjectAdapter.cs
+++ b/src/Microsoft.AspNet.JsonPatch/Adapters/IObjectAdapter.cs
@@ -7,14 +7,13 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
{
///
/// Defines the operations that can be performed on a JSON patch document.
- ///
- /// The type of the model.
- public interface IObjectAdapter where TModel : class
+ ///
+ public interface IObjectAdapter
{
- void Add(Operation operation, TModel objectToApplyTo);
- void Copy(Operation operation, TModel objectToApplyTo);
- void Move(Operation operation, TModel objectToApplyTo);
- void Remove(Operation operation, TModel objectToApplyTo);
- void Replace(Operation operation, TModel objectToApplyTo);
+ void Add(Operation operation, object objectToApplyTo);
+ void Copy(Operation operation, object objectToApplyTo);
+ void Move(Operation operation, object objectToApplyTo);
+ void Remove(Operation operation, object objectToApplyTo);
+ void Replace(Operation operation, object objectToApplyTo);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.JsonPatch/Adapters/ObjectAdapter.cs b/src/Microsoft.AspNet.JsonPatch/Adapters/ObjectAdapter.cs
index 42ae4d7222..32cdc3db35 100644
--- a/src/Microsoft.AspNet.JsonPatch/Adapters/ObjectAdapter.cs
+++ b/src/Microsoft.AspNet.JsonPatch/Adapters/ObjectAdapter.cs
@@ -15,16 +15,16 @@ using Newtonsoft.Json.Serialization;
namespace Microsoft.AspNet.JsonPatch.Adapters
{
///
- public class ObjectAdapter : IObjectAdapter where TModel : class
+ public class ObjectAdapter : IObjectAdapter
{
///
- /// Initializes a new instance of .
+ /// Initializes a new instance of .
///
/// The .
- /// The for logging .
+ /// The for logging .
public ObjectAdapter(
[NotNull] IContractResolver contractResolver,
- Action> logErrorAction)
+ Action logErrorAction)
{
ContractResolver = contractResolver;
LogErrorAction = logErrorAction;
@@ -36,9 +36,9 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
public IContractResolver ContractResolver { get; }
///
- /// Action for logging .
+ /// Action for logging .
///
- public Action> LogErrorAction { get; }
+ public Action LogErrorAction { get; }
///
/// The "add" operation performs one of the following functions,
@@ -100,7 +100,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
/// The add operation.
/// Object to apply the operation to.
- public void Add([NotNull] Operation operation, [NotNull] TModel objectToApplyTo)
+ public void Add([NotNull] Operation operation, [NotNull] object objectToApplyTo)
{
Add(operation.path, operation.value, objectToApplyTo, operation);
}
@@ -112,8 +112,8 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
private void Add(
[NotNull] string path,
object value,
- [NotNull] TModel objectToApplyTo,
- [NotNull] Operation operationToReport)
+ [NotNull] object objectToApplyTo,
+ [NotNull] Operation operationToReport)
{
// add, in this implementation, does not just "add" properties - that's
// technically impossible; It can however be used to add items to arrays,
@@ -184,7 +184,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
}
else
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operationToReport,
Resources.FormatInvalidIndexForArrayProperty(operationToReport.op, path)));
@@ -195,7 +195,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
}
else
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operationToReport,
Resources.FormatInvalidIndexForArrayProperty(operationToReport.op, path)));
@@ -244,7 +244,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
/// The move operation.
/// Object to apply the operation to.
- public void Move([NotNull] Operation operation, [NotNull] TModel objectToApplyTo)
+ public void Move([NotNull] Operation operation, [NotNull] object objectToApplyTo)
{
// get value at from location
object valueAtFromLocation = null;
@@ -281,7 +281,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
if (array.Count <= positionAsInteger)
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operation,
Resources.FormatInvalidIndexForArrayProperty(operation.op, operation.from)));
@@ -293,7 +293,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
}
else
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operation,
Resources.FormatInvalidPathForArrayProperty(operation.op, operation.from)));
@@ -329,7 +329,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
/// The remove operation.
/// Object to apply the operation to.
- public void Remove([NotNull] Operation operation, [NotNull] TModel objectToApplyTo)
+ public void Remove([NotNull] Operation operation, [NotNull] object objectToApplyTo)
{
Remove(operation.path, objectToApplyTo, operation);
}
@@ -340,8 +340,8 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
private void Remove(
[NotNull] string path,
- [NotNull] TModel objectToApplyTo,
- [NotNull] Operation operationToReport)
+ [NotNull] object objectToApplyTo,
+ [NotNull] Operation operationToReport)
{
var removeFromList = false;
var positionAsInteger = -1;
@@ -397,7 +397,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
}
else
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operationToReport,
Resources.FormatInvalidIndexForArrayProperty(operationToReport.op, path)));
@@ -408,7 +408,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
}
else
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operationToReport,
Resources.FormatInvalidPathForArrayProperty(operationToReport.op, path)));
@@ -452,7 +452,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
/// The replace operation.
/// Object to apply the operation to.
- public void Replace([NotNull] Operation operation, [NotNull] TModel objectToApplyTo)
+ public void Replace([NotNull] Operation operation, [NotNull] object objectToApplyTo)
{
Remove(operation.path, objectToApplyTo, operation);
Add(operation.path, operation.value, objectToApplyTo, operation);
@@ -480,7 +480,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
///
/// The copy operation.
/// Object to apply the operation to.
- public void Copy([NotNull] Operation operation, [NotNull] TModel objectToApplyTo)
+ public void Copy([NotNull] Operation operation, [NotNull] object objectToApplyTo)
{
// get value at from location
object valueAtFromLocation = null;
@@ -518,7 +518,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
if (array.Count <= positionAsInteger)
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operation,
Resources.FormatInvalidIndexForArrayProperty(operation.op, operation.from)));
@@ -530,7 +530,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
}
else
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operation,
Resources.FormatInvalidPathForArrayProperty(operation.op, operation.from)));
@@ -551,13 +551,13 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
private bool CheckIfPropertyExists(
JsonPatchProperty patchProperty,
- TModel objectToApplyTo,
- Operation operation,
+ object objectToApplyTo,
+ Operation operation,
string propertyPath)
{
if (patchProperty == null)
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operation,
Resources.FormatPropertyDoesNotExist(propertyPath)));
@@ -567,7 +567,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
if (patchProperty.Property.Ignored)
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operation,
Resources.FormatCannotUpdateProperty(propertyPath)));
@@ -590,13 +590,13 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
private bool CheckIfPropertyCanBeSet(
ConversionResult result,
- TModel objectToApplyTo,
- Operation operation,
+ object objectToApplyTo,
+ Operation operation,
string path)
{
if (!result.CanBeConverted)
{
- LogError(new JsonPatchError(
+ LogError(new JsonPatchError(
objectToApplyTo,
operation,
Resources.FormatInvalidValueForProperty(result.ConvertedInstance, path)));
@@ -607,7 +607,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
return true;
}
- private void LogError(JsonPatchError jsonPatchError)
+ private void LogError(JsonPatchError jsonPatchError)
{
if (LogErrorAction != null)
{
@@ -615,7 +615,7 @@ namespace Microsoft.AspNet.JsonPatch.Adapters
}
else
{
- throw new JsonPatchException(jsonPatchError);
+ throw new JsonPatchException(jsonPatchError);
}
}
diff --git a/src/Microsoft.AspNet.JsonPatch/Converters/TypedJsonPatchDocumentConverter.cs b/src/Microsoft.AspNet.JsonPatch/Converters/TypedJsonPatchDocumentConverter.cs
index 3be0856147..770f629ebf 100644
--- a/src/Microsoft.AspNet.JsonPatch/Converters/TypedJsonPatchDocumentConverter.cs
+++ b/src/Microsoft.AspNet.JsonPatch/Converters/TypedJsonPatchDocumentConverter.cs
@@ -44,7 +44,7 @@ namespace Microsoft.AspNet.JsonPatch.Converters
var targetOperations = Activator.CreateInstance(concreteList);
//Create a new reader for this jObject, and set all properties to match the original reader.
- JsonReader jObjectReader = jObject.CreateReader();
+ var jObjectReader = jObject.CreateReader();
jObjectReader.Culture = reader.Culture;
jObjectReader.DateParseHandling = reader.DateParseHandling;
jObjectReader.DateTimeZoneHandling = reader.DateTimeZoneHandling;
diff --git a/src/Microsoft.AspNet.JsonPatch/Exceptions/JsonPatchException.cs b/src/Microsoft.AspNet.JsonPatch/Exceptions/JsonPatchException.cs
index 8fcf2b3e28..ac5222a2bb 100644
--- a/src/Microsoft.AspNet.JsonPatch/Exceptions/JsonPatchException.cs
+++ b/src/Microsoft.AspNet.JsonPatch/Exceptions/JsonPatchException.cs
@@ -3,42 +3,36 @@
using System;
using Microsoft.AspNet.JsonPatch.Operations;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.JsonPatch.Exceptions
{
- public class JsonPatchException : JsonPatchException where TModel : class
+ public class JsonPatchException : Exception
{
- public Operation FailedOperation { get; private set; }
- public new TModel AffectedObject { get; private set; }
-
- private string _message = string.Empty;
-
- public override string Message
- {
- get
- {
- return _message;
- }
-
- }
+ public Operation FailedOperation { get; private set; }
+ public object AffectedObject { get; private set; }
+
public JsonPatchException()
{
}
- public JsonPatchException([NotNull] JsonPatchError jsonPatchError)
+ public JsonPatchException(JsonPatchError jsonPatchError, Exception innerException)
+ : base(jsonPatchError.ErrorMessage, innerException)
{
FailedOperation = jsonPatchError.Operation;
- _message = jsonPatchError.ErrorMessage;
AffectedObject = jsonPatchError.AffectedObject;
}
- public JsonPatchException([NotNull] JsonPatchError jsonPatchError, Exception innerException)
- : this(jsonPatchError)
+ public JsonPatchException(JsonPatchError jsonPatchError)
+ : this(jsonPatchError, null)
{
- InnerException = innerException;
+ }
+
+ public JsonPatchException(string message, Exception innerException)
+ : base (message, innerException)
+ {
+
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.JsonPatch/Exceptions/JsonPatchExceptionBase.cs b/src/Microsoft.AspNet.JsonPatch/Exceptions/JsonPatchExceptionBase.cs
deleted file mode 100644
index 8891b63cf9..0000000000
--- a/src/Microsoft.AspNet.JsonPatch/Exceptions/JsonPatchExceptionBase.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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.JsonPatch.Exceptions
-{
- public class JsonPatchException : Exception
- {
- public new Exception InnerException { get; internal set; }
-
- public object AffectedObject { get; private set; }
-
- private string _message = string.Empty;
-
- public override string Message
- {
- get
- {
- return _message;
- }
- }
-
- public JsonPatchException()
- {
- }
-
- public JsonPatchException(string message, Exception innerException)
- {
- _message = message;
- InnerException = innerException;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.JsonPatch/JsonPatchDocumentOfT.cs b/src/Microsoft.AspNet.JsonPatch/JsonPatchDocumentOfT.cs
index 0c631461c3..b2ce01708c 100644
--- a/src/Microsoft.AspNet.JsonPatch/JsonPatchDocumentOfT.cs
+++ b/src/Microsoft.AspNet.JsonPatch/JsonPatchDocumentOfT.cs
@@ -32,10 +32,8 @@ namespace Microsoft.AspNet.JsonPatch
ContractResolver = new DefaultContractResolver();
}
- // Create from list of operations.
- public JsonPatchDocument(
- [NotNull] List> operations,
- [NotNull] IContractResolver contractResolver)
+ // Create from list of operations
+ public JsonPatchDocument([NotNull] List> operations, [NotNull] IContractResolver contractResolver)
{
Operations = operations;
ContractResolver = contractResolver;
@@ -45,10 +43,10 @@ namespace Microsoft.AspNet.JsonPatch
/// Add operation. Will result in, for example,
/// { "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] }
///
- /// The value type.
- /// The path of the property to add.
- /// The value to add.
- /// The .
+ /// value type
+ /// path
+ /// value
+ ///
public JsonPatchDocument Add([NotNull] Expression> path, TProp value)
{
Operations.Add(new Operation(
@@ -61,13 +59,13 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Add value to list at given position.
+ /// Add value to list at given position
///
- /// The value type.
- /// The path of the property to add.
- /// The value to add.
+ /// value type
+ /// path
+ /// value
/// position
- /// The .
+ ///
public JsonPatchDocument Add(
[NotNull] Expression>> path,
TProp value,
@@ -83,12 +81,12 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// At value at end of list.
+ /// At value at end of list
///
- /// The value type.
- /// The path of the property to add.
- /// The value to add.
- /// The .
+ /// value type
+ /// path
+ /// value
+ ///
public JsonPatchDocument Add([NotNull] Expression>> path, TProp value)
{
Operations.Add(new Operation(
@@ -104,26 +102,24 @@ namespace Microsoft.AspNet.JsonPatch
/// Remove value at target location. Will result in, for example,
/// { "op": "remove", "path": "/a/b/c" }
///
- /// The path of the property to remove.
- /// The .
+ ///
+ ///
+ ///
public JsonPatchDocument Remove([NotNull] Expression> path)
{
- Operations.Add(
- new Operation("remove", ExpressionHelpers.GetPath(path).ToLowerInvariant(), from: null));
+ Operations.Add(new Operation("remove", ExpressionHelpers.GetPath(path).ToLowerInvariant(), from: null));
return this;
}
///
- /// Remove value from list at given position.
+ /// Remove value from list at given position
///
- /// The value type.
- /// The path of the property to remove.
- /// The position in the list.
- /// The .
- public JsonPatchDocument Remove(
- [NotNull] Expression>> path,
- int position)
+ /// value type
+ /// target location
+ /// position
+ ///
+ public JsonPatchDocument Remove([NotNull] Expression>> path, int position)
{
Operations.Add(new Operation(
"remove",
@@ -134,11 +130,11 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Remove value from end of list.
+ /// Remove value from end of list
///
- /// The value type.
- /// The path of the property to remove.
- /// The .
+ /// value type
+ /// target location
+ ///
public JsonPatchDocument Remove([NotNull] Expression>> path)
{
Operations.Add(new Operation(
@@ -153,9 +149,9 @@ namespace Microsoft.AspNet.JsonPatch
/// Replace value. Will result in, for example,
/// { "op": "replace", "path": "/a/b/c", "value": 42 }
///
- /// The path of the property to replace.
- /// The value to replace.
- /// The .
+ ///
+ ///
+ ///
public JsonPatchDocument Replace([NotNull] Expression> path, TProp value)
{
Operations.Add(new Operation(
@@ -168,16 +164,14 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Replace value in a list at given position.
+ /// Replace value in a list at given position
///
- /// The value type.
- /// The path of the property to replace.
- /// The position in the list.
- /// The .
- public JsonPatchDocument Replace(
- [NotNull] Expression>> path,
- TProp value,
- int position)
+ /// value type
+ /// target location
+ /// position
+ ///
+ public JsonPatchDocument Replace([NotNull] Expression>> path,
+ TProp value, int position)
{
Operations.Add(new Operation(
"replace",
@@ -189,14 +183,12 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Replace value at end of a list.
+ /// Replace value at end of a list
///
- /// The value type.
- /// The path of the property to replace.
- /// The .
- public JsonPatchDocument Replace(
- [NotNull] Expression>> path,
- TProp value)
+ /// value type
+ /// target location
+ ///
+ public JsonPatchDocument Replace([NotNull] Expression>> path, TProp value)
{
Operations.Add(new Operation(
"replace",
@@ -211,9 +203,9 @@ namespace Microsoft.AspNet.JsonPatch
/// Removes value at specified location and add it to the target location. Will result in, for example:
/// { "op": "move", "from": "/a/b/c", "path": "/a/b/d" }
///
- /// The path of the property to remove.
- /// The path of the property to add.
- /// The .
+ ///
+ ///
+ ///
public JsonPatchDocument Move(
[NotNull] Expression> from,
[NotNull] Expression> path)
@@ -227,13 +219,13 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Move from a position in a list to a new location.
+ /// Move from a position in a list to a new location
///
- /// The value type.
- /// The path of the property to remove.
- /// The position in the list to remove.
- /// The path of the property to add.
- /// The .
+ ///
+ ///
+ ///
+ ///
+ ///
public JsonPatchDocument Move(
[NotNull] Expression>> from,
int positionFrom,
@@ -248,13 +240,13 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Move from a property to a location in a list.
+ /// Move from a property to a location in a list
///
- /// The value type.
- /// The path of the property to remove.
- /// The path of the property to add.
- /// The position in the list to add.
- /// The .
+ ///
+ ///
+ ///
+ ///
+ ///
public JsonPatchDocument Move(
[NotNull] Expression> from,
[NotNull] Expression>> path,
@@ -269,14 +261,13 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Move from a position in a list to another location in a list.
+ /// Move from a position in a list to another location in a list
///
- /// The value type.
- /// The path of the property to remove.
- /// The position in the list to remove.
- /// The path of the property to add.
- /// The position in the list to add.
- /// The .
+ ///
+ ///
+ ///
+ ///
+ ///
public JsonPatchDocument Move(
[NotNull] Expression>> from,
int positionFrom,
@@ -292,13 +283,13 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Move from a position in a list to the end of another list.
+ /// Move from a position in a list to the end of another list
///
- /// The value type.
- /// The path of the property to remove.
- /// The position in the list to remove.
- /// The path of the property to add.
- /// The .
+ ///
+ ///
+ ///
+ ///
+ ///
public JsonPatchDocument Move(
[NotNull] Expression>> from,
int positionFrom,
@@ -313,15 +304,16 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Move to the end of a list.
+ /// Move to the end of a list
///
- /// The value type.
- /// The path of the property to remove.
- /// The path of the property to add.
- /// The .
+ ///
+ ///
+ ///
+ ///
+ ///
public JsonPatchDocument Move(
- [NotNull] Expression> from,
- [NotNull] Expression>> path)
+ [NotNull] Expression> from,
+ [NotNull] Expression>> path)
{
Operations.Add(new Operation(
"move",
@@ -332,15 +324,15 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Copy the value at specified location to the target location. Will result in, for example:
+ /// Copy the value at specified location to the target location. Willr esult in, for example:
/// { "op": "copy", "from": "/a/b/c", "path": "/a/b/e" }
///
- /// The path of the property to copy from.
- /// The path of the property to copy to.
- /// The .
+ ///
+ ///
+ ///
public JsonPatchDocument Copy(
- [NotNull] Expression> from,
- [NotNull] Expression> path)
+ [NotNull] Expression> from,
+ [NotNull] Expression> path)
{
Operations.Add(new Operation(
"copy",
@@ -351,17 +343,17 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Copy from a position in a list to a new location.
+ /// Copy from a position in a list to a new location
///
- /// The value type.
- /// The path of the property to copy from.
- /// The position in the list to copy from.
- /// The path of the property to copy to.
- /// The .
+ ///
+ ///
+ ///
+ ///
+ ///
public JsonPatchDocument Copy(
- [NotNull] Expression>> from,
+ [NotNull] Expression>> from,
int positionFrom,
- [NotNull] Expression> path)
+ [NotNull] Expression> path)
{
Operations.Add(new Operation(
"copy",
@@ -372,13 +364,13 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Copy from a property to a location in a list.
+ /// Copy from a property to a location in a list
///
- /// The value type.
- /// The path of the property to copy from.
- /// The path of the property to copy to.
- /// The position in the list to copy to.
- /// The .
+ ///
+ ///
+ ///
+ ///
+ ///
public JsonPatchDocument Copy(
[NotNull] Expression> from,
[NotNull] Expression>> path,
@@ -393,14 +385,13 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Copy from a position in a list to a new location in a list.
+ /// Copy from a position in a list to a new location in a list
///
- /// The value type.
- /// The path of the property to copy from.
- /// The position in the list to copy from.
- /// The path of the property to copy to.
- /// The position in the list to copy to.
- /// The .
+ ///
+ ///
+ ///
+ ///
+ ///
public JsonPatchDocument Copy(
[NotNull] Expression>> from,
int positionFrom,
@@ -416,13 +407,13 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Copy from a position in a list to the end of another list.
+ /// Copy from a position in a list to the end of another list
///
- /// The value type.
- /// The path of the property to copy from.
- /// The position in the list to copy from.
- /// The path of the property to copy to.
- /// The .
+ ///
+ ///
+ ///
+ ///
+ ///
public JsonPatchDocument Copy(
[NotNull] Expression>> from,
int positionFrom,
@@ -437,12 +428,13 @@ namespace Microsoft.AspNet.JsonPatch
}
///
- /// Copy to the end of a list.
+ /// Copy to the end of a list
///
- /// The value type.
- /// The path of the property to copy from.
- /// The path of the property to copy to.
- /// The .
+ ///
+ ///
+ ///
+ ///
+ ///
public JsonPatchDocument Copy(
[NotNull] Expression> from,
[NotNull] Expression>> path)
@@ -455,17 +447,17 @@ namespace Microsoft.AspNet.JsonPatch
return this;
}
- public void ApplyTo([NotNull] TModel objectToApplyTo)
+ public void ApplyTo(TModel objectToApplyTo)
{
- ApplyTo(objectToApplyTo, new ObjectAdapter(ContractResolver, logErrorAction: null));
+ ApplyTo(objectToApplyTo, new ObjectAdapter(ContractResolver, logErrorAction: null));
}
- public void ApplyTo([NotNull] TModel objectToApplyTo, Action> logErrorAction)
+ public void ApplyTo(TModel objectToApplyTo, Action logErrorAction)
{
- ApplyTo(objectToApplyTo, new ObjectAdapter(ContractResolver, logErrorAction));
+ ApplyTo(objectToApplyTo, new ObjectAdapter(ContractResolver, logErrorAction));
}
- public void ApplyTo([NotNull] TModel objectToApplyTo, [NotNull] IObjectAdapter adapter)
+ public void ApplyTo(TModel objectToApplyTo, IObjectAdapter 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 30f8c82d13..36d1f1c688 100644
--- a/src/Microsoft.AspNet.JsonPatch/JsonPatchError.cs
+++ b/src/Microsoft.AspNet.JsonPatch/JsonPatchError.cs
@@ -9,17 +9,17 @@ namespace Microsoft.AspNet.JsonPatch
///
/// Captures error message and the related entity and the operation that caused it.
///
- public class JsonPatchError where TModel : class
+ public class JsonPatchError
{
///
- /// Initializes a new instance of .
+ /// Initializes a new instance of .
///
/// The object that is affected by the error.
- /// The that caused the error.
+ /// The that caused the error.
/// The error message.
public JsonPatchError(
- [NotNull] TModel affectedObject,
- [NotNull] Operation operation,
+ object affectedObject,
+ Operation operation,
[NotNull] string errorMessage)
{
AffectedObject = affectedObject;
@@ -30,12 +30,12 @@ namespace Microsoft.AspNet.JsonPatch
///
/// Gets the object that is affected by the error.
///
- public TModel AffectedObject { get; }
+ public object AffectedObject { get; }
///
- /// Gets the that caused the error.
+ /// Gets the that caused the error.
///
- public Operation Operation { get; }
+ public Operation Operation { get; }
///
/// Gets the error message.
diff --git a/src/Microsoft.AspNet.JsonPatch/Operations/OperationOfT.cs b/src/Microsoft.AspNet.JsonPatch/Operations/OperationOfT.cs
index f28ff7369a..7a72bcc68b 100644
--- a/src/Microsoft.AspNet.JsonPatch/Operations/OperationOfT.cs
+++ b/src/Microsoft.AspNet.JsonPatch/Operations/OperationOfT.cs
@@ -26,7 +26,7 @@ namespace Microsoft.AspNet.JsonPatch.Operations
}
- public void Apply([NotNull] TModel objectToApplyTo, [NotNull] IObjectAdapter adapter)
+ public void Apply([NotNull] TModel objectToApplyTo, [NotNull] IObjectAdapter adapter)
{
switch (OperationType)
{
diff --git a/test/Microsoft.AspNet.JsonPatch.Test/NestedObjectTests.cs b/test/Microsoft.AspNet.JsonPatch.Test/NestedObjectTests.cs
index 6f459280a6..9aadadb16b 100644
--- a/test/Microsoft.AspNet.JsonPatch.Test/NestedObjectTests.cs
+++ b/test/Microsoft.AspNet.JsonPatch.Test/NestedObjectTests.cs
@@ -385,7 +385,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Add(o => o.SimpleDTO.IntegerList, 4, 4);
// Act & Assert
- var exception = Assert.Throws>(() => { patchDoc.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); });
Assert.Equal(
"For operation 'add' on array property at path '/simpledto/integerlist/4', the index is " +
"larger than the array size.",
@@ -413,7 +413,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() =>
+ var exception = Assert.Throws(() =>
{
deserialized.ApplyTo(doc);
});
@@ -441,8 +441,8 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger();
- // Act
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+
//Assert
Assert.Equal(
@@ -469,7 +469,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Add(o => o.SimpleDTO.IntegerList, 4, -1);
// Act & Assert
- var exception = Assert.Throws>(() => { patchDoc.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); });
Assert.Equal("Property does not exist at path '/simpledto/integerlist/-1'.", exception.Message);
}
@@ -493,7 +493,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() =>
+ var exception = Assert.Throws(() =>
{
deserialized.ApplyTo(doc);
});
@@ -518,9 +518,10 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger();
- // Act
- patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+ patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+
+
//Assert
Assert.Equal("Property does not exist at path '/simpledto/integerlist/-1'.", logger.ErrorMessage);
}
@@ -689,7 +690,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Remove(o => o.SimpleDTO.IntegerList, 3);
// Act & Assert
- var exception = Assert.Throws>(() => { patchDoc.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); });
Assert.Equal(
"For operation 'remove' on array property at path '/simpledto/integerlist/3', the index is " +
"larger than the array size.",
@@ -716,7 +717,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() =>
+ var exception = Assert.Throws(() =>
{
deserialized.ApplyTo(doc);
});
@@ -743,10 +744,9 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Remove(o => o.SimpleDTO.IntegerList, 3);
var logger = new TestErrorLogger();
-
- // Act
+
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
-
+
// Assert
Assert.Equal(
"For operation 'remove' on array property at path '/simpledto/integerlist/3', the index is " +
@@ -771,7 +771,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Remove(o => o.SimpleDTO.IntegerList, -1);
// Act & Assert
- var exception = Assert.Throws>(() => { patchDoc.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); });
Assert.Equal("Property does not exist at path '/simpledto/integerlist/-1'.", exception.Message);
}
@@ -795,7 +795,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() =>
+ var exception = Assert.Throws(() =>
{
deserialized.ApplyTo(doc);
});
@@ -820,9 +820,9 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger();
- // Act
- patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+ patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+
// Assert
Assert.Equal("Property does not exist at path '/simpledto/integerlist/-1'.", logger.ErrorMessage);
}
@@ -1232,7 +1232,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Replace(o => o.SimpleDTO.IntegerList, 5, 3);
// Act & Assert
- var exception = Assert.Throws>(() => { patchDoc.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); });
Assert.Equal(
"For operation 'replace' on array property at path '/simpledto/integerlist/3', the index is " +
"larger than the array size.",
@@ -1259,7 +1259,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() =>
+ var exception = Assert.Throws(() =>
{
deserialized.ApplyTo(doc);
});
@@ -1287,8 +1287,9 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger();
- // Act
+
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+
// Assert
Assert.Equal(
@@ -1314,7 +1315,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Replace(o => o.SimpleDTO.IntegerList, 5, -1);
// Act & Assert
- var exception = Assert.Throws>(() => { patchDoc.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); });
Assert.Equal("Property does not exist at path '/simpledto/integerlist/-1'.", exception.Message);
}
@@ -1338,7 +1339,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() => { deserialized.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { deserialized.ApplyTo(doc); });
Assert.Equal("Property does not exist at path '/simpledto/integerlist/-1'.", exception.Message);
}
@@ -1360,8 +1361,9 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger();
- // Act
- patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+
+ patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+
// Assert
Assert.Equal("Property does not exist at path '/simpledto/integerlist/-1'.", logger.ErrorMessage);
diff --git a/test/Microsoft.AspNet.JsonPatch.Test/ObjectAdapterTests.cs b/test/Microsoft.AspNet.JsonPatch.Test/ObjectAdapterTests.cs
index 056357a09a..f6652305e3 100644
--- a/test/Microsoft.AspNet.JsonPatch.Test/ObjectAdapterTests.cs
+++ b/test/Microsoft.AspNet.JsonPatch.Test/ObjectAdapterTests.cs
@@ -155,7 +155,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Add(o => o.IntegerList, 4, 4);
// Act & Assert
- var exception = Assert.Throws>(() => { patchDoc.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); });
Assert.Equal(
"For operation 'add' on array property at path '/integerlist/4', the index is " +
"larger than the array size.",
@@ -179,7 +179,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() => { deserialized.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { deserialized.ApplyTo(doc); });
Assert.Equal(
"For operation 'add' on array property at path '/integerlist/4', the index is " +
"larger than the array size.",
@@ -201,8 +201,8 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger();
- // Act
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+
// Assert
Assert.Equal(
@@ -311,7 +311,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Add(o => o.IntegerList, 4, -1);
// Act & Assert
- var exception = Assert.Throws>(() => { patchDoc.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); });
Assert.Equal("Property does not exist at path '/integerlist/-1'.", exception.Message);
}
@@ -332,7 +332,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() => { deserialized.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { deserialized.ApplyTo(doc); });
Assert.Equal("Property does not exist at path '/integerlist/-1'.", exception.Message);
}
@@ -351,9 +351,8 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger();
- // Act
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
-
+
// Assert
Assert.Equal("Property does not exist at path '/integerlist/-1'.", logger.ErrorMessage);
}
@@ -501,7 +500,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Remove(o => o.IntegerList, 3);
// Act & Assert
- var exception = Assert.Throws>(() => { patchDoc.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); });
Assert.Equal(
"For operation 'remove' on array property at path '/integerlist/3', the index is " +
"larger than the array size.",
@@ -525,7 +524,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() => { deserialized.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { deserialized.ApplyTo(doc); });
Assert.Equal(
"For operation 'remove' on array property at path '/integerlist/3', the index is " +
"larger than the array size.",
@@ -547,8 +546,8 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger();
- // Act
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+
// Assert
Assert.Equal(
@@ -571,7 +570,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Remove(o => o.IntegerList, -1);
// Act & Assert
- var exception = Assert.Throws>(() => { patchDoc.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); });
Assert.Equal("Property does not exist at path '/integerlist/-1'.", exception.Message);
}
@@ -592,7 +591,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() => { deserialized.ApplyTo(doc); });
+ var exception = Assert.Throws(() => { deserialized.ApplyTo(doc); });
Assert.Equal("Property does not exist at path '/integerlist/-1'.", exception.Message);
}
@@ -611,8 +610,9 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger();
- // Act
+
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
+
// Assert
Assert.Equal("Property does not exist at path '/integerlist/-1'.", logger.ErrorMessage);
@@ -1112,7 +1112,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Replace(o => o.IntegerList, 5, 3);
// Act & Assert
- var exception = Assert.Throws>(() =>
+ var exception = Assert.Throws(() =>
{
patchDoc.ApplyTo(doc);
});
@@ -1138,7 +1138,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() =>
+ var exception = Assert.Throws(() =>
{
deserialized.ApplyTo(doc);
});
@@ -1162,7 +1162,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.Replace(o => o.IntegerList, 5, -1);
// Act & Assert
- var exception = Assert.Throws>(() =>
+ var exception = Assert.Throws(() =>
{
patchDoc.ApplyTo(doc);
});
@@ -1186,7 +1186,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var deserialized = JsonConvert.DeserializeObject>(serialized);
// Act & Assert
- var exception = Assert.Throws>(() =>
+ var exception = Assert.Throws(() =>
{
deserialized.ApplyTo(doc);
});
diff --git a/test/Microsoft.AspNet.JsonPatch.Test/TestErrorLogger.cs b/test/Microsoft.AspNet.JsonPatch.Test/TestErrorLogger.cs
index a85688b1c2..c254eab3e3 100644
--- a/test/Microsoft.AspNet.JsonPatch.Test/TestErrorLogger.cs
+++ b/test/Microsoft.AspNet.JsonPatch.Test/TestErrorLogger.cs
@@ -7,7 +7,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
{
public string ErrorMessage { get; set; }
- public void LogErrorMessage(JsonPatchError patchError)
+ public void LogErrorMessage(JsonPatchError patchError)
{
ErrorMessage = patchError.ErrorMessage;
}