From 3835d23230b3824c7dc273afec34f563d32ac567 Mon Sep 17 00:00:00 2001 From: Caleb Lloyd Date: Sat, 26 Jan 2019 10:57:16 -0500 Subject: [PATCH] bump to 2.2; remove static operator overrides --- .gitignore | 3 + Directory.Build.targets | 3 +- build/dependencies.props | 2 +- global.json | 12 +- korebuild-lock.txt | 4 +- korebuild.json | 6 +- .../Pomelo.JsonObject.csproj | 1 - src/Pomelo.JsonObject/System/JsonObject`1.cs | 348 +++++++++--------- test/Directory.Build.props | 4 +- version.props | 4 +- 10 files changed, 189 insertions(+), 198 deletions(-) diff --git a/.gitignore b/.gitignore index fd33106..3cc8780 100644 --- a/.gitignore +++ b/.gitignore @@ -251,3 +251,6 @@ paket-files/ # JetBrains Rider .idea/ *.sln.iml + +# VSCode +.vscode diff --git a/Directory.Build.targets b/Directory.Build.targets index 3171481..7b740e6 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,9 +1,8 @@  - $(MicrosoftNETCoreApp11PackageVersion) $(MicrosoftNETCoreApp20PackageVersion) - $(MicrosoftNETCoreApp21PackageVersion) + $(MicrosoftNETCoreApp22PackageVersion) $(NETStandardLibrary20PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index ef9570c..1a80e07 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -11,7 +11,7 @@ 15.6.1 2.3.1 2.3.1 - 2.4.0-beta.1.build3958 + 2.4.0 \ No newline at end of file diff --git a/global.json b/global.json index 60736fe..da54912 100644 --- a/global.json +++ b/global.json @@ -1,8 +1,8 @@ { - "sdk": { - "version": "2.1.301" - }, - "msbuild-sdks": { - "Microsoft.DotNet.GlobalTools.Sdk": "2.1.3-rtm-15802" - } + "sdk": { + "version": "2.2.102" + }, + "msbuild-sdks": { + "Internal.AspNetCore.Sdk": "2.2.1-build-20190117.5" } +} diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1dfc352..7f84ed2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.3-rtm-15802 -commithash:a7c08b45b440a7d2058a0aa1eaa3eb6ba811976a +version:2.2.1-build-20190117.5 +commithash:28bc5808b442f2a068bf3bff362f0aed3c5f163e diff --git a/korebuild.json b/korebuild.json index 678d8bb..538988d 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", - "channel": "release/2.1" -} + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.2/tools/korebuild.schema.json", + "channel": "release/2.2" +} \ No newline at end of file diff --git a/src/Pomelo.JsonObject/Pomelo.JsonObject.csproj b/src/Pomelo.JsonObject/Pomelo.JsonObject.csproj index 531fdcc..1f031e2 100644 --- a/src/Pomelo.JsonObject/Pomelo.JsonObject.csproj +++ b/src/Pomelo.JsonObject/Pomelo.JsonObject.csproj @@ -9,7 +9,6 @@ JSON;Entity Framework Core;entity-framework-core;MySQL;EF;ORM http://www.1234.sh/assets/Shared/pomelofoundation.png https://github.com/PomeloFoundation/Pomelo.JsonObject - https://github.com/PomeloFoundation/Pomelo.JsonObject/blob/master/LICENSE git git://github.com/PomeloFoundation/Pomelo.JsonObject.git diff --git a/src/Pomelo.JsonObject/System/JsonObject`1.cs b/src/Pomelo.JsonObject/System/JsonObject`1.cs index 2c4aad7..fc031df 100644 --- a/src/Pomelo.JsonObject/System/JsonObject`1.cs +++ b/src/Pomelo.JsonObject/System/JsonObject`1.cs @@ -3,221 +3,211 @@ // ReSharper disable once CheckNamespace namespace System { - public class JsonObject : IEquatable>, IEquatable, IEquatable - where T : class - { - private string _originalValue { get; set; } - private T _originalObject { get; set; } - private Type _internalType { get; set; } - - public JsonObject() + public class JsonObject : IEquatable>, IEquatable, IEquatable + where T : class { - _internalType = typeof(T); - } - - public JsonObject(T instance) - : this() - { - Object = instance; - } + private string _originalValue { get; set; } + private T _originalObject { get; set; } + private Type _internalType { get; set; } - public JsonObject(string json) - : this() - { - Json = json; - Object = Object; - } - - public JsonObject(byte[] json) - : this() - { - Json = Text.Encoding.UTF8.GetString(json); - Object = Object; - } - - public T Object - { - get { return _originalObject; } - set - { - _originalObject = value; - - _originalValue = _originalObject != null - ? SerializeObject(Object) - : string.Empty; - } - } + public JsonObject() + { + _internalType = typeof(T); + } - public string Json - { - get { return _originalValue; } - set - { - try + public JsonObject(T instance) + : this() { - Object = string.IsNullOrWhiteSpace(value) - ? default(T) - : DeserializeObject(value); + Object = instance; + } - _originalValue = value; + public JsonObject(string json) + : this() + { + Json = json; + Object = Object; } - catch + + public JsonObject(byte[] json) + : this() { - Object = null; - _originalValue = string.Empty; + Json = Text.Encoding.UTF8.GetString(json); + Object = Object; } - } - } - public override string ToString() - { - return Json; - } + public T Object + { + get { return _originalObject; } + set + { + _originalObject = value; + + _originalValue = _originalObject != null + ? SerializeObject(Object) + : string.Empty; + } + } - public override bool Equals(object obj) - { - if (obj == null && Json == Null) - return true; - - if (obj.GetType().Name == "String") - { - var objString = obj as string; - if (objString == NaN && Json == NaN) - return false; - - return Equals(objString); - } - - try - { - dynamic o = obj; - return Equals((string) o.Json); - } - catch - { - return base.Equals(obj); - } - } + public string Json + { + get { return _originalValue; } + set + { + try + { + Object = string.IsNullOrWhiteSpace(value) + ? default(T) + : DeserializeObject(value); + + _originalValue = value; + } + catch + { + Object = null; + _originalValue = string.Empty; + } + } + } - public bool Equals(JsonObject other) - { - if (other == null && Json == Null) - return true; + public override string ToString() + { + return Json; + } - return Equals(other.Json); - } + public override bool Equals(object obj) + { + if (obj == null && Json == Null) + return true; + + if (obj.GetType().Name == "String") + { + var objString = obj as string; + if (objString == NaN && Json == NaN) + return false; + + return Equals(objString); + } + + try + { + dynamic o = obj; + return Equals((string)o.Json); + } + catch + { + return base.Equals(obj); + } + } - public bool Equals(JsonObject other) - { - if (other == null && Json == Null) - return true; + public bool Equals(JsonObject other) + { + if (other == null && Json == Null) + return true; - return Equals(other.Json); - } + return Equals(other.Json); + } - public bool Equals(string other) - { - if (other == NaN && Json == NaN) - return false; + public bool Equals(JsonObject other) + { + if (other == null && Json == Null) + return true; - if (string.IsNullOrWhiteSpace(other) || IsJsonConstant(other)) - return string.CompareOrdinal(other, Json) == 0; + return Equals(other.Json); + } - if (!IsSameType(Json, other)) - return false; + public bool Equals(string other) + { + if (other == NaN && Json == NaN) + return false; - var tempJsonObject = new JsonObject(other); - return GetHashCode() == tempJsonObject.GetHashCode(); - } + if (string.IsNullOrWhiteSpace(other) || IsJsonConstant(other)) + return string.CompareOrdinal(other, Json) == 0; - private Type GetInternalObjectType() - { - return _internalType; - } + if (!IsSameType(Json, other)) + return false; - public static implicit operator JsonObject(byte[] json) - { - return new JsonObject(json); - } + var tempJsonObject = new JsonObject(other); + return GetHashCode() == tempJsonObject.GetHashCode(); + } - public static implicit operator JsonObject(string json) - { - return new JsonObject(json); - } + private Type GetInternalObjectType() + { + return _internalType; + } - public static implicit operator JsonObject(T obj) - { - return new JsonObject(obj); - } + public static implicit operator JsonObject(byte[] json) + { + return new JsonObject(json); + } - public static implicit operator JsonObject(JsonObject obj) - { - return new JsonObject(obj.Json); - } + public static implicit operator JsonObject(string json) + { + return new JsonObject(json); + } - private static bool IsObject(string json) - { - JsonObject jsonObject; - return IsObject(json, out jsonObject); - } + public static implicit operator JsonObject(T obj) + { + return new JsonObject(obj); + } - private static bool IsObject(string json, out JsonObject jsonObject) - { - jsonObject = null; + public static implicit operator JsonObject(JsonObject obj) + { + return new JsonObject(obj.Json); + } - if (string.IsNullOrWhiteSpace(json) || IsJsonConstant(json)) - return false; + private static bool IsObject(string json) + { + JsonObject jsonObject; + return IsObject(json, out jsonObject); + } - if (string.CompareOrdinal(json, Null) == 0) - return true; + private static bool IsObject(string json, out JsonObject jsonObject) + { + jsonObject = null; - jsonObject = new JsonObject(json); + if (string.IsNullOrWhiteSpace(json) || IsJsonConstant(json)) + return false; - return jsonObject.Object != null; - } + if (string.CompareOrdinal(json, Null) == 0) + return true; - private static bool IsJsonConstant(string json) - { - if (string.CompareOrdinal(json, NaN) == 0 || - string.CompareOrdinal(json, Undefined) == 0 || - string.CompareOrdinal(json, True) == 0 || - string.CompareOrdinal(json, False) == 0 || - string.CompareOrdinal(json, NegativeInfinity) == 0 || - string.CompareOrdinal(json, PositiveInfinity) == 0) - return true; - - return false; - } + jsonObject = new JsonObject(json); - private static bool IsSameType(string json1, string json2) - { - if (string.IsNullOrWhiteSpace(json1) && string.IsNullOrWhiteSpace(json2) - || json1 == Null && json2 == Null) - return true; + return jsonObject.Object != null; + } - if (IsJsonConstant(json1) && IsJsonConstant(json2)) - return json1 == json2; + private static bool IsJsonConstant(string json) + { + if (string.CompareOrdinal(json, NaN) == 0 || + string.CompareOrdinal(json, Undefined) == 0 || + string.CompareOrdinal(json, True) == 0 || + string.CompareOrdinal(json, False) == 0 || + string.CompareOrdinal(json, NegativeInfinity) == 0 || + string.CompareOrdinal(json, PositiveInfinity) == 0) + return true; + + return false; + } - JsonObject left, right; - if (!IsObject(json1, out left) || !IsObject(json2, out right)) - return false; + private static bool IsSameType(string json1, string json2) + { + if (string.IsNullOrWhiteSpace(json1) && string.IsNullOrWhiteSpace(json2) + || json1 == Null && json2 == Null) + return true; - return left.GetInternalObjectType().FullName == right.GetInternalObjectType().FullName; - } + if (IsJsonConstant(json1) && IsJsonConstant(json2)) + return json1 == json2; - public static bool operator ==(JsonObject a, JsonObject b) - { - return a.Equals(b); - } + JsonObject left, right; + if (!IsObject(json1, out left) || !IsObject(json2, out right)) + return false; - public static bool operator !=(JsonObject a, JsonObject b) - { - return !a.Equals(b); - } + return left.GetInternalObjectType().FullName == right.GetInternalObjectType().FullName; + } - public override int GetHashCode() - { - return Json?.GetHashCode() ?? 0; + public override int GetHashCode() + { + return Json?.GetHashCode() ?? 0; + } } - } } diff --git a/test/Directory.Build.props b/test/Directory.Build.props index e5cae96..c98b997 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,9 +2,9 @@ - netcoreapp2.1 + netcoreapp2.2 $(DeveloperBuildTestTfms) - netcoreapp2.0;netcoreapp2.1 + $(StandardTestTfms);netcoreapp2.0 net461;$(StandardTestTfms) diff --git a/version.props b/version.props index 15bc138..0c6de4b 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 2.0.0 - rtm + 2.2.0 + preview1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000