Skip to content

Commit

Permalink
Strong name, updated deps, and generalization
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
oschwald committed Sep 10, 2015
1 parent 60a1f08 commit e879278
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 43 deletions.
25 changes: 17 additions & 8 deletions MaxMind.MinFraud.UnitTest/MaxMind.MinFraud.UnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,27 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MaxMind.Db, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.Db.1.1.0\lib\net40\MaxMind.Db.dll</HintPath>
<Reference Include="MaxMind.Db, Version=1.0.1.0, Culture=neutral, PublicKeyToken=66afa4cc5ae853ac, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.Db.1.2.0-beta1\lib\net40\MaxMind.Db.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MaxMind.GeoIP2, Version=2.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.GeoIP2.2.3.1\lib\net40\MaxMind.GeoIP2.dll</HintPath>
<Reference Include="MaxMind.GeoIP2, Version=2.3.0.0, Culture=neutral, PublicKeyToken=66afa4cc5ae853ac, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.GeoIP2.2.4.0-beta1\lib\net40\MaxMind.GeoIP2.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand All @@ -56,15 +68,12 @@
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="RestSharp, Version=105.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.105.1.0\lib\net452\RestSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="RichardSzalay.MockHttp, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RichardSzalay.MockHttp.1.2.1\lib\net45\RichardSzalay.MockHttp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
Expand Down
6 changes: 3 additions & 3 deletions MaxMind.MinFraud.UnitTest/packages.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MaxMind.Db" version="1.1.0" targetFramework="net452" />
<package id="MaxMind.GeoIP2" version="2.3.1" targetFramework="net452" />
<package id="MaxMind.Db" version="1.2.0-beta1" targetFramework="net452" />
<package id="MaxMind.GeoIP2" version="2.4.0-beta1" targetFramework="net452" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net452" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net452" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net452" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net452" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
<package id="NUnit" version="2.6.4" targetFramework="net452" />
<package id="RestSharp" version="105.1.0" targetFramework="net452" />
<package id="RichardSzalay.MockHttp" version="1.2.1" targetFramework="net452" />
</packages>
4 changes: 4 additions & 0 deletions MaxMind.MinFraud/Exception/InvalidRequestException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Binary file added MaxMind.MinFraud/GlobalSuppressions.cs
Binary file not shown.
36 changes: 27 additions & 9 deletions MaxMind.MinFraud/MaxMind.MinFraud.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>MaxMind.MinFraud.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -33,27 +34,42 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\MaxMind.MinFraud.xml</DocumentationFile>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>ExtendedCorrectnessRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>MaxMind.MinFraud.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\MaxMind.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="MaxMind.Db, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.Db.1.1.0\lib\net40\MaxMind.Db.dll</HintPath>
<Reference Include="MaxMind.Db, Version=1.0.1.0, Culture=neutral, PublicKeyToken=66afa4cc5ae853ac, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.Db.1.2.0-beta1\lib\net40\MaxMind.Db.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MaxMind.GeoIP2, Version=2.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.GeoIP2.2.3.1\lib\net40\MaxMind.GeoIP2.dll</HintPath>
<Reference Include="MaxMind.GeoIP2, Version=2.3.0.0, Culture=neutral, PublicKeyToken=66afa4cc5ae853ac, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.GeoIP2.2.4.0-beta1\lib\net40\MaxMind.GeoIP2.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="RestSharp, Version=105.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.105.1.0\lib\net452\RestSharp.dll</HintPath>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
<Private>True</Private>
Expand All @@ -77,6 +93,7 @@
<Compile Include="Exception\InsufficientFundsException.cs" />
<Compile Include="Exception\InvalidRequestException.cs" />
<Compile Include="Exception\MinFraudException.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Request\Account.cs" />
<Compile Include="Request\Billing.cs" />
<Compile Include="Request\CreditCard.cs" />
Expand Down Expand Up @@ -107,6 +124,7 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="MaxMind.MinFraud.ruleset" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
10 changes: 10 additions & 0 deletions MaxMind.MinFraud/MaxMind.MinFraud.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for MaxMind.MinFraud" Description="Code analysis rules for MaxMind.MinFraud.csproj." ToolsVersion="14.0">
<IncludeAll Action="Warning" />
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1020" Action="None" />
<Rule Id="CA1026" Action="None" />
<Rule Id="CA1304" Action="None" />
<Rule Id="CA1305" Action="None" />
</Rules>
</RuleSet>
16 changes: 9 additions & 7 deletions MaxMind.MinFraud/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -14,27 +15,28 @@
[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)]

// 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")]
[assembly: AssemblyInformationalVersion("0.2.0-beta1")]
4 changes: 2 additions & 2 deletions MaxMind.MinFraud/Request/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Transaction(
Order order = null,
Payment payment = null,
Shipping shipping = null,
List<ShoppingCartItem> shoppingCart = default(List<ShoppingCartItem>)
IList<ShoppingCartItem> shoppingCart = default(List<ShoppingCartItem>)
)
{
this.Device = device;
Expand Down Expand Up @@ -106,7 +106,7 @@ public Transaction(
/// List of shopping items in the transaction.
/// </summary>
[JsonProperty("shopping_cart")]
public List<ShoppingCartItem> ShoppingCart { get; }
public IList<ShoppingCartItem> ShoppingCart { get; }

/// <summary>
/// Returns a string that represents the current object.
Expand Down
2 changes: 1 addition & 1 deletion MaxMind.MinFraud/Response/Score.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Score
/// account.
/// </summary>
[JsonProperty("credits_remaining")]
public ulong? CreditsRemaining { get; internal set; }
public long? CreditsRemaining { get; internal set; }

/// <summary>
/// This is a UUID that identifies the minFraud request. Please use
Expand Down
3 changes: 2 additions & 1 deletion MaxMind.MinFraud/Response/Warning.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace MaxMind.MinFraud.Response
{
Expand Down Expand Up @@ -36,7 +37,7 @@ public sealed class Warning
/// number for an array.
/// </summary>
[JsonIgnore]
public List<string> Input => new List<string>(_input);
public ReadOnlyCollection<string> Input => new ReadOnlyCollection<string>(_input);

/// <summary>
/// Returns a string that represents the current object.
Expand Down
16 changes: 12 additions & 4 deletions MaxMind.MinFraud/Util/IPAddressConverter.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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());
}

Expand Down
4 changes: 2 additions & 2 deletions MaxMind.MinFraud/WebServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public sealed class WebServiceClient : IDisposable
public WebServiceClient(
int userId,
string licenseKey,
List<string> locales = null,
IEnumerable<string> locales = null,
string host = "minfraud.maxmind.com",
TimeSpan? timeout = null,
HttpMessageHandler httpMessageHandler = null
)
{
_locales = locales ?? new List<string> { "en" };
_locales = locales == null ? new List<string> { "en" } : new List<string>(locales);
_httpClient = new HttpClient(httpMessageHandler ?? new HttpClientHandler())
{
BaseAddress = new UriBuilder("https", host, -1, BasePath).Uri,
Expand Down
6 changes: 3 additions & 3 deletions MaxMind.MinFraud/packages.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MaxMind.Db" version="1.1.0" targetFramework="net452" />
<package id="MaxMind.GeoIP2" version="2.3.1" targetFramework="net452" />
<package id="MaxMind.Db" version="1.2.0-beta1" targetFramework="net452" />
<package id="MaxMind.GeoIP2" version="2.4.0-beta1" targetFramework="net452" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net452" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net452" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net452" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net452" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
<package id="RestSharp" version="105.1.0" targetFramework="net452" />
</packages>
Binary file added MaxMind.snk
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ marked as async:
var score = await client.ScoreAsync(transaction);
```

Or a minFRaud Insights request by calling `InsightsAsynce` method:
Or a minFraud Insights request by calling `InsightsAsynce` method:

```csharp
var score = await client.ScoreAsync(transaction);
Expand Down
11 changes: 9 additions & 2 deletions releasenotes.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Release Notes
=============

0.2.0 (2015-XX-XX)
------------------
0.2.0-beta1 (2015-09-10)
------------------------

* Add `is_gift` and `has_gift_message` order inputs.
* Upgrade to the latest GeoIP2 release.
* `Score.CreditsRemaining` was change from a `ulong?` to `long?` in order to
be more CLS compliant.
* 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.

0.1.1-beta1 (2015-06-30)
------------------------
Expand Down

0 comments on commit e879278

Please sign in to comment.