Skip to content

Commit

Permalink
fix: adding support for net35 net462 and netstandard2.1 (#738)
Browse files Browse the repository at this point in the history
* fix: adding support for net35 net462 and netstandard2.1
  • Loading branch information
sbansla authored Mar 11, 2024
1 parent 66d46bd commit 31dc0e3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
21 changes: 3 additions & 18 deletions src/Twilio/Http/SystemNetHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace Twilio.Http
/// </summary>
public class SystemNetHttpClient : HttpClient
{
#if NET451
private string PlatVersion = ".NET Framework 4.5.1+";
#if NET462
private string PlatVersion = ".NET Framework 4.6.2+";
#else
private string PlatVersion = RuntimeInformation.FrameworkDescription;
#endif
Expand Down Expand Up @@ -107,25 +107,10 @@ private HttpRequestMessage BuildHttpRequest(Request request)
string helperLibVersion = AssemblyInfomation.AssemblyInformationalVersion;

string osName = "Unknown";
#if !NETSTANDARD1_4
osName = Environment.OSVersion.Platform.ToString();
#else
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
osName = "Windows";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
osName = "MacOS";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
osName = "Linux";
}
#endif

string osArch;
#if !NET451
#if !NET462
osArch = RuntimeInformation.OSArchitecture.ToString();
#else
osArch = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") ?? "Unknown";
Expand Down
38 changes: 32 additions & 6 deletions src/Twilio/Twilio.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="NuGet">
<TargetFramework>net6.0</TargetFramework>
<OutputPath>bin/Release</OutputPath>
<Nullable>enable</Nullable>
<TargetFrameworks>net6.0;netstandard2.1;net462;net35</TargetFrameworks>
<IsPackable>true</IsPackable>
<PackageId>Twilio</PackageId>
<Description>Twilio REST API helper library</Description>
Expand All @@ -24,12 +22,40 @@
<RepositoryUrl>http://github.com/twilio/twilio-csharp</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard2.1' ">2.1.0</NetStandardImplicitPackageVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="6.15.0" />
<Reference Include="System.Xml.Linq" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.19.0" />
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.19.0" />
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net35' ">
<Reference Include="System" />
<Reference Include="System.Web" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="JWT" Version="1.3.4" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.19.0" />
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Condition="($(TargetFramework.StartsWith('net3')) OR $(TargetFramework.StartsWith('net4'))) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="jnm2.ReferenceAssemblies.net35" Version="1.0.1" PrivateAssets="All" />
</ItemGroup>
</Project>

0 comments on commit 31dc0e3

Please sign in to comment.