From e8792787a3aa94258ceb28af5c46559d4f455792 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 10 Sep 2015 10:53:50 -0700 Subject: [PATCH] Strong name, updated deps, and generalization * GeoIP2 dependency was updated to a version that does not depend on RestSharp. * Some parameters and properties were changed from using concrete classes to interfaces. * The library now has a strong name. --- .../MaxMind.MinFraud.UnitTest.csproj | 25 ++++++++---- MaxMind.MinFraud.UnitTest/packages.config | 6 +-- .../Exception/InvalidRequestException.cs | 4 ++ MaxMind.MinFraud/GlobalSuppressions.cs | Bin 0 -> 43956 bytes MaxMind.MinFraud/MaxMind.MinFraud.csproj | 36 +++++++++++++----- MaxMind.MinFraud/MaxMind.MinFraud.ruleset | 10 +++++ MaxMind.MinFraud/Properties/AssemblyInfo.cs | 16 ++++---- MaxMind.MinFraud/Request/Transaction.cs | 4 +- MaxMind.MinFraud/Response/Score.cs | 2 +- MaxMind.MinFraud/Response/Warning.cs | 3 +- MaxMind.MinFraud/Util/IPAddressConverter.cs | 16 ++++++-- MaxMind.MinFraud/WebServiceClient.cs | 4 +- MaxMind.MinFraud/packages.config | 6 +-- MaxMind.snk | Bin 0 -> 596 bytes README.md | 2 +- releasenotes.md | 11 +++++- 16 files changed, 102 insertions(+), 43 deletions(-) create mode 100644 MaxMind.MinFraud/GlobalSuppressions.cs create mode 100644 MaxMind.MinFraud/MaxMind.MinFraud.ruleset create mode 100644 MaxMind.snk diff --git a/MaxMind.MinFraud.UnitTest/MaxMind.MinFraud.UnitTest.csproj b/MaxMind.MinFraud.UnitTest/MaxMind.MinFraud.UnitTest.csproj index 3dc64aad..7c68164b 100644 --- a/MaxMind.MinFraud.UnitTest/MaxMind.MinFraud.UnitTest.csproj +++ b/MaxMind.MinFraud.UnitTest/MaxMind.MinFraud.UnitTest.csproj @@ -38,15 +38,27 @@ 4 - - ..\packages\MaxMind.Db.1.1.0\lib\net40\MaxMind.Db.dll + + ..\packages\MaxMind.Db.1.2.0-beta1\lib\net40\MaxMind.Db.dll True - - ..\packages\MaxMind.GeoIP2.2.3.1\lib\net40\MaxMind.GeoIP2.dll + + ..\packages\MaxMind.GeoIP2.2.4.0-beta1\lib\net40\MaxMind.GeoIP2.dll True + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + True + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + True + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + True + ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll @@ -56,15 +68,12 @@ ..\packages\NUnit.2.6.4\lib\nunit.framework.dll True - - ..\packages\RestSharp.105.1.0\lib\net452\RestSharp.dll - True - ..\packages\RichardSzalay.MockHttp.1.2.1\lib\net45\RichardSzalay.MockHttp.dll True + ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll diff --git a/MaxMind.MinFraud.UnitTest/packages.config b/MaxMind.MinFraud.UnitTest/packages.config index ec5ab3fd..4ec8b222 100644 --- a/MaxMind.MinFraud.UnitTest/packages.config +++ b/MaxMind.MinFraud.UnitTest/packages.config @@ -1,12 +1,12 @@  - - + + + - \ No newline at end of file diff --git a/MaxMind.MinFraud/Exception/InvalidRequestException.cs b/MaxMind.MinFraud/Exception/InvalidRequestException.cs index 9bf5185b..6203555a 100644 --- a/MaxMind.MinFraud/Exception/InvalidRequestException.cs +++ b/MaxMind.MinFraud/Exception/InvalidRequestException.cs @@ -97,6 +97,10 @@ protected InvalidRequestException(SerializationInfo info, StreamingContext conte [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { + if (info == null) + { + throw new ArgumentNullException(nameof(info)); + } info.AddValue("Code", Code); info.AddValue("Uri", this.Uri); base.GetObjectData(info, context); diff --git a/MaxMind.MinFraud/GlobalSuppressions.cs b/MaxMind.MinFraud/Glob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l z9X%aS%#*TWhxruLc7c?+BV0>8l%JE*XcyQH>U^+tAG9#_KGQiH1Lc!FX5sWu8cNAWrODvvU_`|7$#Rms_v3icWZ`Qn8j>r5f#oe+tc|kgy}HwGVI+mnyf^RMV?#+1k9dtkj}Y SJ)3-8s0^Fud3{qlxc>(Q2`)7N literal 0 HcmV?d00001 diff --git a/MaxMind.MinFraud/MaxMind.MinFraud.csproj b/MaxMind.MinFraud/MaxMind.MinFraud.csproj index 437a021b..43207f00 100644 --- a/MaxMind.MinFraud/MaxMind.MinFraud.csproj +++ b/MaxMind.MinFraud/MaxMind.MinFraud.csproj @@ -23,6 +23,7 @@ prompt 4 true + MaxMind.MinFraud.ruleset pdbonly @@ -33,27 +34,42 @@ 4 bin\Release\MaxMind.MinFraud.xml true - ExtendedCorrectnessRules.ruleset + MaxMind.MinFraud.ruleset + + + true + + + ..\MaxMind.snk - - ..\packages\MaxMind.Db.1.1.0\lib\net40\MaxMind.Db.dll + + ..\packages\MaxMind.Db.1.2.0-beta1\lib\net40\MaxMind.Db.dll True - - ..\packages\MaxMind.GeoIP2.2.3.1\lib\net40\MaxMind.GeoIP2.dll + + ..\packages\MaxMind.GeoIP2.2.4.0-beta1\lib\net40\MaxMind.GeoIP2.dll True - - ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll True - - ..\packages\RestSharp.105.1.0\lib\net452\RestSharp.dll + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + True + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + True + + + ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll True + ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll True @@ -77,6 +93,7 @@ + @@ -107,6 +124,7 @@ + diff --git a/MaxMind.MinFraud/MaxMind.MinFraud.ruleset b/MaxMind.MinFraud/MaxMind.MinFraud.ruleset new file mode 100644 index 00000000..11519a70 --- /dev/null +++ b/MaxMind.MinFraud/MaxMind.MinFraud.ruleset @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/MaxMind.MinFraud/Properties/AssemblyInfo.cs b/MaxMind.MinFraud/Properties/AssemblyInfo.cs index b14b831d..5e4f34a0 100644 --- a/MaxMind.MinFraud/Properties/AssemblyInfo.cs +++ b/MaxMind.MinFraud/Properties/AssemblyInfo.cs @@ -1,7 +1,8 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. @@ -14,8 +15,8 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -23,18 +24,19 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("7208d9c8-f862-4675-80e5-77a2f8901b96")] +[assembly: CLSCompliant(true)] // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("0.1.0.0")] [assembly: AssemblyFileVersion("0.1.1")] -[assembly: AssemblyInformationalVersion("0.1.1-beta1")] \ No newline at end of file +[assembly: AssemblyInformationalVersion("0.2.0-beta1")] \ No newline at end of file diff --git a/MaxMind.MinFraud/Request/Transaction.cs b/MaxMind.MinFraud/Request/Transaction.cs index 4f7dddfa..0ff690b9 100644 --- a/MaxMind.MinFraud/Request/Transaction.cs +++ b/MaxMind.MinFraud/Request/Transaction.cs @@ -33,7 +33,7 @@ public Transaction( Order order = null, Payment payment = null, Shipping shipping = null, - List shoppingCart = default(List) + IList shoppingCart = default(List) ) { this.Device = device; @@ -106,7 +106,7 @@ public Transaction( /// List of shopping items in the transaction. /// [JsonProperty("shopping_cart")] - public List ShoppingCart { get; } + public IList ShoppingCart { get; } /// /// Returns a string that represents the current object. diff --git a/MaxMind.MinFraud/Response/Score.cs b/MaxMind.MinFraud/Response/Score.cs index cef05f87..5695bb08 100644 --- a/MaxMind.MinFraud/Response/Score.cs +++ b/MaxMind.MinFraud/Response/Score.cs @@ -18,7 +18,7 @@ public class Score /// account. /// [JsonProperty("credits_remaining")] - public ulong? CreditsRemaining { get; internal set; } + public long? CreditsRemaining { get; internal set; } /// /// This is a UUID that identifies the minFraud request. Please use diff --git a/MaxMind.MinFraud/Response/Warning.cs b/MaxMind.MinFraud/Response/Warning.cs index 1c3954f6..a3da0416 100644 --- a/MaxMind.MinFraud/Response/Warning.cs +++ b/MaxMind.MinFraud/Response/Warning.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using System.Collections.Generic; +using System.Collections.ObjectModel; namespace MaxMind.MinFraud.Response { @@ -36,7 +37,7 @@ public sealed class Warning /// number for an array. /// [JsonIgnore] - public List Input => new List(_input); + public ReadOnlyCollection Input => new ReadOnlyCollection(_input); /// /// Returns a string that represents the current object. diff --git a/MaxMind.MinFraud/Util/IPAddressConverter.cs b/MaxMind.MinFraud/Util/IPAddressConverter.cs index 5a36d663..994e60ef 100644 --- a/MaxMind.MinFraud/Util/IPAddressConverter.cs +++ b/MaxMind.MinFraud/Util/IPAddressConverter.cs @@ -1,7 +1,11 @@ -using System; -using System.Net; +#region + using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System; +using System.Net; + +#endregion namespace MaxMind.MinFraud.Util { @@ -10,12 +14,16 @@ internal class IPAddressConverter : JsonConverter { public override bool CanConvert(Type objectType) { - return (objectType == typeof (IPAddress)); + return (objectType == typeof(IPAddress)); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - var ip = (IPAddress) value; + if (writer == null) + { + throw new ArgumentNullException(nameof(writer)); + } + var ip = (IPAddress)value; writer.WriteValue(ip.ToString()); } diff --git a/MaxMind.MinFraud/WebServiceClient.cs b/MaxMind.MinFraud/WebServiceClient.cs index 3d778093..0911b968 100644 --- a/MaxMind.MinFraud/WebServiceClient.cs +++ b/MaxMind.MinFraud/WebServiceClient.cs @@ -44,13 +44,13 @@ public sealed class WebServiceClient : IDisposable public WebServiceClient( int userId, string licenseKey, - List locales = null, + IEnumerable locales = null, string host = "minfraud.maxmind.com", TimeSpan? timeout = null, HttpMessageHandler httpMessageHandler = null ) { - _locales = locales ?? new List { "en" }; + _locales = locales == null ? new List { "en" } : new List(locales); _httpClient = new HttpClient(httpMessageHandler ?? new HttpClientHandler()) { BaseAddress = new UriBuilder("https", host, -1, BasePath).Uri, diff --git a/MaxMind.MinFraud/packages.config b/MaxMind.MinFraud/packages.config index fc16101a..bd30172e 100644 --- a/MaxMind.MinFraud/packages.config +++ b/MaxMind.MinFraud/packages.config @@ -1,10 +1,10 @@  - - + + + - \ No newline at end of file diff --git a/MaxMind.snk b/MaxMind.snk new file mode 100644 index 0000000000000000000000000000000000000000..8744a96d6af58d3986fdffba924967842528d087 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50098w3vNo3C9z?D{EOdtfF5U~aryR8+lCFm z-~W=!VheL6=yy-B1qf+JILn8T4Nw`wnRtr;TGmmUjSFqOs*` zJ-_%G4F=UUJzfgU!lMpOTOIFTQ}z!huggM_fg`u{tCc%@WE!~JsN^T5&q{m6Ic+2%2DnqzhVqasYge8WnEh+eMZy$&95CrYFuyAadR4Clta zihw}7)B_kmlr8q!Rgmi;>$N#~Y~FB-AT^Jr4~E=??KKgR!Kn~H+aTt0w0EH1k*d(~ i)~vnuYE~|b%SFc>r_6pKJf_U`E^D|