From 2849359effd859574576b233713987c0cfd091a6 Mon Sep 17 00:00:00 2001 From: Broderick T Date: Fri, 20 Oct 2023 23:27:46 -0400 Subject: [PATCH] Remove extra lines, remove extra unused imports across all files --- src/JsonPatch.Common/Constants.cs | 9 +-------- src/JsonPatch.Common/Extensions/StringExtensions.cs | 1 - src/JsonPatch.Common/JsonPatchException.cs | 4 ---- src/JsonPatch.Common/JsonPatchOperationType.cs | 8 +------- src/JsonPatch.Common/JsonPatchParseException.cs | 4 ---- src/JsonPatch.Common/Model/PatchOperation.cs | 8 +------- src/JsonPatch.Common/Paths/IValueConverter.cs | 2 -- .../Paths/Resolvers/AttributePropertyPathResolver.cs | 6 ++---- src/JsonPatch.Common/Paths/Resolvers/BaseResolver.cs | 1 - .../Resolvers/CaseInsensitivePropertyPathResolver.cs | 4 ++-- .../Paths/Resolvers/ExactCasePropertyPathResolver.cs | 4 ++-- .../Paths/Resolvers/FlexiblePathResolver.cs | 4 ---- src/JsonPatch.Common/Paths/Resolvers/IPathResolver.cs | 1 - src/JsonPatch.Tests/AttributePathHelperTests.cs | 11 ++++------- src/JsonPatch.Tests/CaseInsensitivePathHelperTests.cs | 10 ++++------ src/JsonPatch.Tests/Entitys/ArrayEntity.cs | 8 +------- src/JsonPatch.Tests/Entitys/ComplexEntity.cs | 10 +++++----- src/JsonPatch.Tests/Entitys/DictionaryEntity.cs | 6 +----- src/JsonPatch.Tests/Entitys/EnumEntity.cs | 8 +------- src/JsonPatch.Tests/Entitys/ListEntity.cs | 6 +----- src/JsonPatch.Tests/Entitys/SimpleEntity.cs | 9 +++------ src/JsonPatch.Tests/FlexiblePathHelperTests.cs | 11 ++++------- src/JsonPatch.Tests/JsonPatchDocumentTests.cs | 10 +++------- src/JsonPatch.Tests/PathHelperTests.cs | 11 ++++------- src/JsonPatch/Formatting/JsonPatchFormatter.cs | 8 +------- src/JsonPatch/IJsonPatchDocument.cs | 8 +------- src/JsonPatch/JsonPatchDocument.cs | 1 - src/JsonPatch/JsonPatchOperation.cs | 8 ++++++-- src/JsonPatch/JsonValueConverter.cs | 5 ----- src/JsonPatchCore/JsonPatchOptions.cs | 3 --- src/JsonPatchCore/JsonValueConverter.cs | 8 ++------ 31 files changed, 50 insertions(+), 147 deletions(-) diff --git a/src/JsonPatch.Common/Constants.cs b/src/JsonPatch.Common/Constants.cs index 5d6fb76..6d39401 100644 --- a/src/JsonPatch.Common/Constants.cs +++ b/src/JsonPatch.Common/Constants.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace JsonPatch +namespace JsonPatch { /// /// Constants @@ -35,7 +29,6 @@ public static class Operations /// Moves a value from one location to the other. /// public const string MOVE = "move"; - } } } diff --git a/src/JsonPatch.Common/Extensions/StringExtensions.cs b/src/JsonPatch.Common/Extensions/StringExtensions.cs index 204fbdb..cc7cbb4 100644 --- a/src/JsonPatch.Common/Extensions/StringExtensions.cs +++ b/src/JsonPatch.Common/Extensions/StringExtensions.cs @@ -6,7 +6,6 @@ internal static class StringExtensions { internal static bool IsPositiveInteger(this string @string) { - bool isInteger = Int32.TryParse(@string, out int n); if (!isInteger) diff --git a/src/JsonPatch.Common/JsonPatchException.cs b/src/JsonPatch.Common/JsonPatchException.cs index 763c5d7..c07b1ee 100644 --- a/src/JsonPatch.Common/JsonPatchException.cs +++ b/src/JsonPatch.Common/JsonPatchException.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace JsonPatch { diff --git a/src/JsonPatch.Common/JsonPatchOperationType.cs b/src/JsonPatch.Common/JsonPatchOperationType.cs index 9343055..b65fd67 100644 --- a/src/JsonPatch.Common/JsonPatchOperationType.cs +++ b/src/JsonPatch.Common/JsonPatchOperationType.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace JsonPatch +namespace JsonPatch { /// /// Json Patch Operation Type diff --git a/src/JsonPatch.Common/JsonPatchParseException.cs b/src/JsonPatch.Common/JsonPatchParseException.cs index 58529e6..5e19810 100644 --- a/src/JsonPatch.Common/JsonPatchParseException.cs +++ b/src/JsonPatch.Common/JsonPatchParseException.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace JsonPatch { diff --git a/src/JsonPatch.Common/Model/PatchOperation.cs b/src/JsonPatch.Common/Model/PatchOperation.cs index bf2764f..12e33e0 100644 --- a/src/JsonPatch.Common/Model/PatchOperation.cs +++ b/src/JsonPatch.Common/Model/PatchOperation.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace JsonPatch.Model +namespace JsonPatch.Model { /// /// JSON Patch Operation diff --git a/src/JsonPatch.Common/Paths/IValueConverter.cs b/src/JsonPatch.Common/Paths/IValueConverter.cs index de8ab9d..df1823c 100644 --- a/src/JsonPatch.Common/Paths/IValueConverter.cs +++ b/src/JsonPatch.Common/Paths/IValueConverter.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace JsonPatch.Paths { diff --git a/src/JsonPatch.Common/Paths/Resolvers/AttributePropertyPathResolver.cs b/src/JsonPatch.Common/Paths/Resolvers/AttributePropertyPathResolver.cs index 8cd7c4e..6dc1a81 100644 --- a/src/JsonPatch.Common/Paths/Resolvers/AttributePropertyPathResolver.cs +++ b/src/JsonPatch.Common/Paths/Resolvers/AttributePropertyPathResolver.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace JsonPatch.Paths.Resolvers { @@ -18,7 +15,8 @@ public class AttributePropertyPathResolver : BaseResolver /// /// public AttributePropertyPathResolver(IValueConverter converter) : base(converter) - { } + { + } /// /// Get the property based on the component name diff --git a/src/JsonPatch.Common/Paths/Resolvers/BaseResolver.cs b/src/JsonPatch.Common/Paths/Resolvers/BaseResolver.cs index 613e413..9c322c2 100644 --- a/src/JsonPatch.Common/Paths/Resolvers/BaseResolver.cs +++ b/src/JsonPatch.Common/Paths/Resolvers/BaseResolver.cs @@ -13,7 +13,6 @@ namespace JsonPatch.Paths.Resolvers /// public abstract class BaseResolver : IPathResolver { - private readonly IValueConverter converter; /// diff --git a/src/JsonPatch.Common/Paths/Resolvers/CaseInsensitivePropertyPathResolver.cs b/src/JsonPatch.Common/Paths/Resolvers/CaseInsensitivePropertyPathResolver.cs index 28c6578..67d66d0 100644 --- a/src/JsonPatch.Common/Paths/Resolvers/CaseInsensitivePropertyPathResolver.cs +++ b/src/JsonPatch.Common/Paths/Resolvers/CaseInsensitivePropertyPathResolver.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Reflection; namespace JsonPatch.Paths.Resolvers @@ -14,7 +13,8 @@ public class CaseInsensitivePropertyPathResolver : BaseResolver /// /// public CaseInsensitivePropertyPathResolver(IValueConverter converter) : base(converter) - { } + { + } /// /// Get property info from parent type (case insensitive) diff --git a/src/JsonPatch.Common/Paths/Resolvers/ExactCasePropertyPathResolver.cs b/src/JsonPatch.Common/Paths/Resolvers/ExactCasePropertyPathResolver.cs index 3a8194d..25bd310 100644 --- a/src/JsonPatch.Common/Paths/Resolvers/ExactCasePropertyPathResolver.cs +++ b/src/JsonPatch.Common/Paths/Resolvers/ExactCasePropertyPathResolver.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Reflection; namespace JsonPatch.Paths.Resolvers @@ -14,7 +13,8 @@ public class ExactCasePropertyPathResolver : BaseResolver /// /// public ExactCasePropertyPathResolver(IValueConverter converter) : base(converter) - { } + { + } /// /// Returns the property info for the given component (case sensitive) diff --git a/src/JsonPatch.Common/Paths/Resolvers/FlexiblePathResolver.cs b/src/JsonPatch.Common/Paths/Resolvers/FlexiblePathResolver.cs index f05f3e1..e487699 100644 --- a/src/JsonPatch.Common/Paths/Resolvers/FlexiblePathResolver.cs +++ b/src/JsonPatch.Common/Paths/Resolvers/FlexiblePathResolver.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace JsonPatch.Paths.Resolvers { diff --git a/src/JsonPatch.Common/Paths/Resolvers/IPathResolver.cs b/src/JsonPatch.Common/Paths/Resolvers/IPathResolver.cs index cf1f27b..aec4260 100644 --- a/src/JsonPatch.Common/Paths/Resolvers/IPathResolver.cs +++ b/src/JsonPatch.Common/Paths/Resolvers/IPathResolver.cs @@ -1,7 +1,6 @@ using JsonPatch.Paths.Components; using System; - namespace JsonPatch.Paths.Resolvers { /// diff --git a/src/JsonPatch.Tests/AttributePathHelperTests.cs b/src/JsonPatch.Tests/AttributePathHelperTests.cs index 59388de..4c3f47c 100644 --- a/src/JsonPatch.Tests/AttributePathHelperTests.cs +++ b/src/JsonPatch.Tests/AttributePathHelperTests.cs @@ -1,17 +1,14 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using JsonPatch.Tests.Entities; -using JsonPatch.Formatting; +using JsonPatch.Paths.Components; using JsonPatch.Paths.Resolvers; -using JsonPatch.Paths.Components; +using JsonPatch.Tests.Entities; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace JsonPatch.Tests { [TestClass] public class AttributePathHelperTests { - - private IPathResolver resolver = new AttributePropertyPathResolver(new JsonValueConverter()); + private readonly IPathResolver resolver = new AttributePropertyPathResolver(new JsonValueConverter()); [TestMethod] public void ParsePath_DataMember_ParsesSuccessfully() diff --git a/src/JsonPatch.Tests/CaseInsensitivePathHelperTests.cs b/src/JsonPatch.Tests/CaseInsensitivePathHelperTests.cs index 7440516..658b013 100644 --- a/src/JsonPatch.Tests/CaseInsensitivePathHelperTests.cs +++ b/src/JsonPatch.Tests/CaseInsensitivePathHelperTests.cs @@ -1,10 +1,8 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using JsonPatch.Tests.Entities; -using JsonPatch.Paths.Resolvers; +using JsonPatch.Paths; using JsonPatch.Paths.Components; -using JsonPatch; -using JsonPatch.Paths; +using JsonPatch.Paths.Resolvers; +using JsonPatch.Tests.Entities; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Collections.Generic; using System.Text.Json; diff --git a/src/JsonPatch.Tests/Entitys/ArrayEntity.cs b/src/JsonPatch.Tests/Entitys/ArrayEntity.cs index b1850c7..076b1d3 100644 --- a/src/JsonPatch.Tests/Entitys/ArrayEntity.cs +++ b/src/JsonPatch.Tests/Entitys/ArrayEntity.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace JsonPatch.Tests.Entities +namespace JsonPatch.Tests.Entities { public class ArrayEntity { diff --git a/src/JsonPatch.Tests/Entitys/ComplexEntity.cs b/src/JsonPatch.Tests/Entitys/ComplexEntity.cs index 365659e..5592bbf 100644 --- a/src/JsonPatch.Tests/Entitys/ComplexEntity.cs +++ b/src/JsonPatch.Tests/Entitys/ComplexEntity.cs @@ -1,17 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace JsonPatch.Tests.Entities { public class ComplexEntity { public ArrayEntity Foo { get; set; } + public SimpleEntity Bar { get; set; } + public SimpleEntity[] Baz { get; set; } + public List Qux { get; set; } + public List Norf { get; set; } } } diff --git a/src/JsonPatch.Tests/Entitys/DictionaryEntity.cs b/src/JsonPatch.Tests/Entitys/DictionaryEntity.cs index 35d06ac..44b9872 100644 --- a/src/JsonPatch.Tests/Entitys/DictionaryEntity.cs +++ b/src/JsonPatch.Tests/Entitys/DictionaryEntity.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace JsonPatch.Tests.Entities { diff --git a/src/JsonPatch.Tests/Entitys/EnumEntity.cs b/src/JsonPatch.Tests/Entitys/EnumEntity.cs index 70c6740..2151ca5 100644 --- a/src/JsonPatch.Tests/Entitys/EnumEntity.cs +++ b/src/JsonPatch.Tests/Entitys/EnumEntity.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace JsonPatch.Tests.Entities +namespace JsonPatch.Tests.Entities { public class EnumEntity { diff --git a/src/JsonPatch.Tests/Entitys/ListEntity.cs b/src/JsonPatch.Tests/Entitys/ListEntity.cs index 23deafd..b615539 100644 --- a/src/JsonPatch.Tests/Entitys/ListEntity.cs +++ b/src/JsonPatch.Tests/Entitys/ListEntity.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace JsonPatch.Tests.Entities { diff --git a/src/JsonPatch.Tests/Entitys/SimpleEntity.cs b/src/JsonPatch.Tests/Entitys/SimpleEntity.cs index 8b87b5c..f3f2072 100644 --- a/src/JsonPatch.Tests/Entitys/SimpleEntity.cs +++ b/src/JsonPatch.Tests/Entitys/SimpleEntity.cs @@ -1,17 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; +using System.Runtime.Serialization; using System.Text.Json.Serialization; -using System.Threading.Tasks; namespace JsonPatch.Tests.Entities { public class SimpleEntity { public string Foo { get; set; } + public int Bar { get; set; } + public string Baz { get; set; } [DataMember(Name = "pId")] diff --git a/src/JsonPatch.Tests/FlexiblePathHelperTests.cs b/src/JsonPatch.Tests/FlexiblePathHelperTests.cs index 609dacc..7c71345 100644 --- a/src/JsonPatch.Tests/FlexiblePathHelperTests.cs +++ b/src/JsonPatch.Tests/FlexiblePathHelperTests.cs @@ -1,17 +1,14 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using JsonPatch.Tests.Entities; -using JsonPatch.Formatting; +using JsonPatch.Paths.Components; using JsonPatch.Paths.Resolvers; -using JsonPatch.Paths.Components; +using JsonPatch.Tests.Entities; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace JsonPatch.Tests { [TestClass] public class FlexiblePathHelperTests { - - private FlexiblePathResolver resolver = new FlexiblePathResolver(new JsonValueConverter()); + private readonly FlexiblePathResolver resolver = new FlexiblePathResolver(new JsonValueConverter()); [TestMethod] public void ParsePath_DataMember_ParsesSuccessfully() diff --git a/src/JsonPatch.Tests/JsonPatchDocumentTests.cs b/src/JsonPatch.Tests/JsonPatchDocumentTests.cs index aa8d2b4..145260b 100644 --- a/src/JsonPatch.Tests/JsonPatchDocumentTests.cs +++ b/src/JsonPatch.Tests/JsonPatchDocumentTests.cs @@ -1,11 +1,7 @@ -using System.Collections.Generic; -using System.Linq; +using JsonPatch.Tests.Entities; using Microsoft.VisualStudio.TestTools.UnitTesting; -using JsonPatch.Tests.Entities; -using JsonPatch; -using System.Runtime; -using System.Text.Json.Serialization; -using System; +using System.Collections.Generic; +using System.Linq; namespace JsonPatch.Tests { diff --git a/src/JsonPatch.Tests/PathHelperTests.cs b/src/JsonPatch.Tests/PathHelperTests.cs index 6510653..6043808 100644 --- a/src/JsonPatch.Tests/PathHelperTests.cs +++ b/src/JsonPatch.Tests/PathHelperTests.cs @@ -1,18 +1,15 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using JsonPatch.Paths; +using JsonPatch.Paths.Components; +using JsonPatch.Paths.Resolvers; using JsonPatch.Tests.Entities; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Collections.Generic; -using JsonPatch.Paths.Resolvers; -using JsonPatch.Paths; -using JsonPatch; -using JsonPatch.Paths.Components; namespace JsonPatch.Tests { [TestClass] public class PathHelperTests { - private readonly IPathResolver _resolver = new ExactCasePropertyPathResolver(new JsonValueConverter()); #region ParsePath diff --git a/src/JsonPatch/Formatting/JsonPatchFormatter.cs b/src/JsonPatch/Formatting/JsonPatchFormatter.cs index 206e2e2..81bd25d 100644 --- a/src/JsonPatch/Formatting/JsonPatchFormatter.cs +++ b/src/JsonPatch/Formatting/JsonPatchFormatter.cs @@ -1,13 +1,9 @@ using JsonPatch.Model; using Newtonsoft.Json; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net.Http.Formatting; using System.Net.Http.Headers; -using System.Text; -using System.Threading.Tasks; namespace JsonPatch.Formatting { @@ -15,8 +11,7 @@ public class JsonPatchFormatter : BufferedMediaTypeFormatter { internal static JsonPatchSettings Settings { get; private set; } public JsonPatchFormatter() : this(JsonPatchSettings.DefaultPatchSettings()) - { - + { } public JsonPatchFormatter(JsonPatchSettings settings) @@ -81,7 +76,6 @@ public override object ReadFromStream(Type type, System.IO.Stream readStream, Sy } return jsonPatchDocument; - } } } diff --git a/src/JsonPatch/IJsonPatchDocument.cs b/src/JsonPatch/IJsonPatchDocument.cs index dc30b39..7d616d3 100644 --- a/src/JsonPatch/IJsonPatchDocument.cs +++ b/src/JsonPatch/IJsonPatchDocument.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace JsonPatch +namespace JsonPatch { public interface IJsonPatchDocument { diff --git a/src/JsonPatch/JsonPatchDocument.cs b/src/JsonPatch/JsonPatchDocument.cs index fdec11f..b9dc76c 100644 --- a/src/JsonPatch/JsonPatchDocument.cs +++ b/src/JsonPatch/JsonPatchDocument.cs @@ -13,7 +13,6 @@ namespace JsonPatch { public class JsonPatchDocument : IJsonPatchDocument where TEntity : class, new() { - private IPathResolver Resolver { get diff --git a/src/JsonPatch/JsonPatchOperation.cs b/src/JsonPatch/JsonPatchOperation.cs index 46a1ce4..604839c 100644 --- a/src/JsonPatch/JsonPatchOperation.cs +++ b/src/JsonPatch/JsonPatchOperation.cs @@ -1,15 +1,19 @@ -using JsonPatch; -using JsonPatch.Paths.Components; +using JsonPatch.Paths.Components; namespace JsonPatch { public class JsonPatchOperation { public JsonPatchOperationType Operation { get; set; } + public string FromPath { get; set; } + public PathComponent[] ParsedFromPath { get; set; } + public string Path { get; set; } + public PathComponent[] ParsedPath { get; set; } + public object Value { get; set; } } } diff --git a/src/JsonPatch/JsonValueConverter.cs b/src/JsonPatch/JsonValueConverter.cs index 371c7dd..b2afa97 100644 --- a/src/JsonPatch/JsonValueConverter.cs +++ b/src/JsonPatch/JsonValueConverter.cs @@ -1,12 +1,7 @@ using JsonPatch.Paths; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace JsonPatch { diff --git a/src/JsonPatchCore/JsonPatchOptions.cs b/src/JsonPatchCore/JsonPatchOptions.cs index 5b6f4f7..be01071 100644 --- a/src/JsonPatchCore/JsonPatchOptions.cs +++ b/src/JsonPatchCore/JsonPatchOptions.cs @@ -1,5 +1,4 @@ using JsonPatch.Paths.Resolvers; -using JsonPatch.Infrastructure; namespace JsonPatch; @@ -17,7 +16,6 @@ public record JsonPatchOptions /// Weather or not to require the Content-Type header to be application/json-patch+json /// public bool RequireJsonPatchContentType { get; set; } = true; - } /// @@ -30,4 +28,3 @@ public class JsonPatchSettings /// public static JsonPatchOptions Options { get; set; } = new JsonPatchOptions(); } - diff --git a/src/JsonPatchCore/JsonValueConverter.cs b/src/JsonPatchCore/JsonValueConverter.cs index c4f5d65..169ce4f 100644 --- a/src/JsonPatchCore/JsonValueConverter.cs +++ b/src/JsonPatchCore/JsonValueConverter.cs @@ -1,13 +1,9 @@ using JsonPatch.Paths; -using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; using System.Text.Json; -using System.Threading.Tasks; -namespace JsonPatch { +namespace JsonPatch +{ /// /// Converts a value from one type to another using Json serialisation as a fallback