Skip to content

Commit 4a5e725

Browse files
authored
feat: added net40 target framework. (#1011)
1 parent 0bbfc33 commit 4a5e725

File tree

6 files changed

+45
-4
lines changed

6 files changed

+45
-4
lines changed

src/SendGrid/BaseClient.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
using System.Net;
88
using System.Net.Http;
99
using System.Net.Http.Headers;
10-
using System.Reflection;
1110
using System.Text;
1211
using System.Threading;
1312
using System.Threading.Tasks;
13+
#if NET40
14+
using SendGrid.Helpers.Net40;
15+
#else
16+
using System.Reflection;
17+
#endif
1418

1519
namespace SendGrid
1620
{

src/SendGrid/Helpers/Mail/Model/JsonConverters.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
using System;
88
using System.Collections.Generic;
99
using System.Linq;
10+
#if NET40
11+
using SendGrid.Helpers.Net40;
12+
#else
1013
using System.Reflection;
14+
#endif
1115

1216
namespace SendGrid.Helpers.Mail
1317
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
namespace SendGrid.Helpers.Net40
4+
{
5+
internal static class TypeExtensions
6+
{
7+
public static Type GetTypeInfo(this Type type) => type;
8+
}
9+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
5+
namespace SendGrid.Helpers
6+
{
7+
internal static class TaskUtilities
8+
{
9+
public static Task Delay(TimeSpan delay, CancellationToken cancellationToken = default)
10+
{
11+
#if NET40
12+
return TaskEx.Delay(delay, cancellationToken);
13+
#else
14+
return Task.Delay(delay, cancellationToken);
15+
#endif
16+
}
17+
}
18+
}

src/SendGrid/Reliability/RetryDelegatingHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
8383
}
8484

8585
// ReSharper disable once MethodSupportsCancellation, cancel will be indicated on the token
86-
await Task.Delay(waitFor).ConfigureAwait(false);
86+
await TaskUtilities.Delay(waitFor).ConfigureAwait(false);
8787
}
8888
catch (HttpRequestException)
8989
{
@@ -94,7 +94,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
9494
throw;
9595
}
9696

97-
await Task.Delay(waitFor).ConfigureAwait(false);
97+
await TaskUtilities.Delay(waitFor).ConfigureAwait(false);
9898
}
9999
}
100100

src/SendGrid/SendGrid.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<VersionPrefix>9.16.0</VersionPrefix>
5-
<TargetFrameworks>netstandard1.3;netstandard2.0;net452</TargetFrameworks>
5+
<TargetFrameworks>netstandard1.3;netstandard2.0;net452;net40</TargetFrameworks>
66
<PlatformTarget>anycpu</PlatformTarget>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<OutputType>Library</OutputType>
@@ -59,4 +59,10 @@
5959
<Reference Include="Microsoft.CSharp" />
6060
</ItemGroup>
6161

62+
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
63+
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
64+
<PackageReference Include="Microsoft.Bcl.Async" Version="1.0.168" />
65+
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
66+
</ItemGroup>
67+
6268
</Project>

0 commit comments

Comments
 (0)