#544 target framework changes
This commit is contained in:
parent
09418e53a1
commit
63f61cb309
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net471;netcoreapp2.0;</TargetFrameworks>
|
||||
<TargetFrameworks>net461;netcoreapp2.0;</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
<ProjectReference Include="..\..\src\Flurl.Http\Flurl.Http.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
</ItemGroup>
|
||||
|
@ -1,33 +1,10 @@
|
||||
using System.IO;
|
||||
#if NETSTANDARD1_1
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flurl.Http
|
||||
{
|
||||
internal static class FileUtil
|
||||
{
|
||||
#if NETSTANDARD1_1
|
||||
internal static string GetFileName(string path) {
|
||||
return path?.Split(PCLStorage.PortablePath.DirectorySeparatorChar).Last();
|
||||
}
|
||||
|
||||
internal static string CombinePath(params string[] paths) {
|
||||
return PCLStorage.PortablePath.Combine(paths);
|
||||
}
|
||||
|
||||
internal static async Task<Stream> OpenReadAsync(string path, int bufferSize) {
|
||||
var file = await PCLStorage.FileSystem.Current.GetFileFromPathAsync(path).ConfigureAwait(false);
|
||||
return await file.OpenAsync(PCLStorage.FileAccess.Read).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
internal static async Task<Stream> OpenWriteAsync(string folderPath, string fileName, int bufferSize) {
|
||||
var folder = await PCLStorage.FileSystem.Current.LocalStorage.CreateFolderAsync(folderPath, PCLStorage.CreationCollisionOption.OpenIfExists).ConfigureAwait(false);
|
||||
var file = await folder.CreateFileAsync(fileName, PCLStorage.CreationCollisionOption.ReplaceExisting).ConfigureAwait(false);
|
||||
return await file.OpenAsync(PCLStorage.FileAccess.ReadAndWrite).ConfigureAwait(false);
|
||||
}
|
||||
#else
|
||||
internal static string GetFileName(string path) {
|
||||
return Path.GetFileName(path);
|
||||
}
|
||||
@ -45,7 +22,7 @@ namespace Flurl.Http
|
||||
var filePath = Path.Combine(folderPath, fileName);
|
||||
return Task.FromResult<Stream>(new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize, useAsync: true));
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Replaces invalid path characters with underscores.
|
||||
/// </summary>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net45;net46;netstandard1.1;netstandard1.3;netstandard2.0;</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard1.1;netstandard1.3;netstandard2.0;</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<PackageId>Flurl.Http</PackageId>
|
||||
<Version>3.0.0-pre4</Version>
|
||||
@ -14,7 +12,7 @@
|
||||
<RepositoryUrl>https://github.com/tmenier/Flurl.git</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageTags>httpclient rest json http fluent url uri tdd assert async</PackageTags>
|
||||
<PackageTags>rest http httpclient json url uri tdd</PackageTags>
|
||||
<PackageReleaseNotes>https://github.com/tmenier/Flurl/releases</PackageReleaseNotes>
|
||||
<IncludeProjectPriFile>false</IncludeProjectPriFile>
|
||||
</PropertyGroup>
|
||||
@ -26,7 +24,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DocumentationFile>bin\Release\Flurl.Http.xml</DocumentationFile>
|
||||
<DocumentationFile>bin\Release\Flurl.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>bin\Debug\Flurl.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -36,39 +38,11 @@
|
||||
<None Include="..\..\icon.png" Pack="true" PackagePath="\"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
|
||||
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.1'">
|
||||
<PackageReference Include="PCLStorage" Version="1.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageTargetFallback Condition="'$(TargetFramework)'=='netstandard1.1'">portable-net45+win8+wp8</PackageTargetFallback>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net45|AnyCPU'">
|
||||
<DocumentationFile>bin\Debug\Flurl.Http.xml</DocumentationFile>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net45|AnyCPU'">
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -190,7 +190,7 @@ namespace Flurl.Http
|
||||
_capturedBody?.ToString();
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_3 || NETSTANDARD2_0
|
||||
#if NETSTANDARD2_0
|
||||
// https://stackoverflow.com/questions/46119872/encoding-issues-with-net-core-2 (#86)
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
#endif
|
||||
|
@ -12,9 +12,7 @@ namespace Flurl.Http.Testing
|
||||
/// An object whose existence puts Flurl.Http into test mode where actual HTTP calls are faked. Provides a response
|
||||
/// queue, call log, and assertion helpers for use in Arrange/Act/Assert style tests.
|
||||
/// </summary>
|
||||
#if NET45
|
||||
[Serializable]
|
||||
#endif
|
||||
public class HttpTest : HttpTestSetup, IDisposable
|
||||
{
|
||||
private readonly ConcurrentQueue<FlurlCall> _calls = new ConcurrentQueue<FlurlCall>();
|
||||
@ -106,17 +104,8 @@ namespace Flurl.Http.Testing
|
||||
SetCurrentTest(null);
|
||||
}
|
||||
|
||||
#if NET45
|
||||
private static void SetCurrentTest(HttpTest test) => System.Runtime.Remoting.Messaging.CallContext.LogicalSetData("FlurlHttpTest", test);
|
||||
private static HttpTest GetCurrentTest() => System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("FlurlHttpTest") as HttpTest;
|
||||
#elif NETSTANDARD1_1
|
||||
private static HttpTest _test;
|
||||
private static void SetCurrentTest(HttpTest test) => _test = test;
|
||||
private static HttpTest GetCurrentTest() => _test;
|
||||
#else
|
||||
private static readonly System.Threading.AsyncLocal<HttpTest> _test = new System.Threading.AsyncLocal<HttpTest>();
|
||||
private static void SetCurrentTest(HttpTest test) => _test.Value = test;
|
||||
private static HttpTest GetCurrentTest() => _test.Value;
|
||||
#endif
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net40;netstandard1.0;netstandard1.3;netstandard2.0;</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard1.0;netstandard1.3;netstandard2.0;</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<PackageId>Flurl</PackageId>
|
||||
<Version>3.0.0-pre4</Version>
|
||||
@ -29,36 +27,19 @@
|
||||
<DocumentationFile>bin\Release\Flurl.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net40|AnyCPU'">
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>bin\Debug\Flurl.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net40|AnyCPU'">
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\..\icon.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.0'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
|
||||
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.4.0" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -42,9 +42,7 @@ namespace Flurl.Util
|
||||
obj == null ? null :
|
||||
obj is DateTime dt ? dt.ToString("o", CultureInfo.InvariantCulture) :
|
||||
obj is DateTimeOffset dto ? dto.ToString("o", CultureInfo.InvariantCulture) :
|
||||
#if !NETSTANDARD1_0
|
||||
obj is IConvertible c ? c.ToString(CultureInfo.InvariantCulture) :
|
||||
#endif
|
||||
obj is IFormattable f ? f.ToString(null, CultureInfo.InvariantCulture) :
|
||||
obj.ToString();
|
||||
}
|
||||
@ -70,31 +68,18 @@ namespace Flurl.Util
|
||||
return Url.ParseQueryParams(s).Select(p => new KeyValuePair<string, object>(p.Name, p.Value));
|
||||
}
|
||||
|
||||
private static IEnumerable<KeyValuePair<string, object>> ObjectToKV(object obj) {
|
||||
#if NETSTANDARD1_0
|
||||
return from prop in obj.GetType().GetRuntimeProperties()
|
||||
let getter = prop.GetMethod
|
||||
where getter?.IsPublic == true
|
||||
let val = getter.Invoke(obj, null)
|
||||
select new KeyValuePair<string, object>(prop.Name, val);
|
||||
#else
|
||||
return from prop in obj.GetType().GetProperties()
|
||||
private static IEnumerable<KeyValuePair<string, object>> ObjectToKV(object obj) =>
|
||||
from prop in obj.GetType().GetProperties()
|
||||
let getter = prop.GetGetMethod(false)
|
||||
where getter != null
|
||||
let val = getter.Invoke(obj, null)
|
||||
select new KeyValuePair<string, object>(prop.Name, val);
|
||||
#endif
|
||||
}
|
||||
|
||||
private static IEnumerable<KeyValuePair<string, object>> CollectionToKV(IEnumerable col) {
|
||||
bool TryGetProp(object obj, string name, out object value) {
|
||||
#if NETSTANDARD1_0
|
||||
var prop = obj.GetType().GetRuntimeProperty(name);
|
||||
var field = obj.GetType().GetRuntimeField(name);
|
||||
#else
|
||||
var prop = obj.GetType().GetProperty(name);
|
||||
var field = obj.GetType().GetField(name);
|
||||
#endif
|
||||
|
||||
if (prop != null) {
|
||||
value = prop.GetValue(obj, null);
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user