Feature/netcore preparation (#2035)

* Move to use package reference for restoring nuget packages.

* Return a task result for this async method.

* Update to a supported version of the .NET Framework. This also has the side effect of allowing us to automatically generate our binding redirects on build.

* Set the solution to target VS2017

* Update test solution csproj file to support being built through MSBuild 15

* Move to use package reference for restoring nuget packages.

* Return a task result for this async method.

* Update to a supported version of the .NET Framework. This also has the side effect of allowing us to automatically generate our binding redirects on build.

* Set the solution to target VS2017

* Update test solution csproj file to support being built through MSBuild 15

* DateTimeRoutines does not have Nuget packages that support .NET Standard (and therefore .NET Core). We will have to include them for now until we can get rid of this dependency.

* Move the interfaces into their own files. This will be useful when we share them between the .NET Core and .NET Framework WebAPI

* Stage services that need to point to the new interface namespace.

* Update CurlSharp to fix memory leak issue and support better runtime compatibility with OSX and Linux

* Start spliting some interfaces into their own files - this will help by allowing us to split them out in the future into a seperate project so the actual implementations can stay within their respective architectures when required
This commit is contained in:
Nathan Holland
2017-10-29 23:19:09 +13:00
committed by flightlevel
parent 7829643104
commit 8a6b9d4de7
166 changed files with 2093 additions and 975 deletions

View File

@@ -2,7 +2,7 @@
*
* CurlS#arp
*
* Copyright (c) 2013 Dr. Masroor Ehsan (masroore@gmail.com)
* Copyright (c) 2013-2017 Dr. Masroor Ehsan (masroore@gmail.com)
* Portions copyright (c) 2004, 2005 Jeff Phillips (jeff@jeffp.net)
*
* This software is licensed as described in the file LICENSE, which you
@@ -31,19 +31,6 @@ namespace CurlSharp
/// </summary>
public class CurlSlist : IDisposable
{
#if !USE_LIBCURLSHIM
[StructLayout(LayoutKind.Sequential)]
private class curl_slist
{
/// char*
[MarshalAs(UnmanagedType.LPStr)] public string data;
/// curl_slist*
public IntPtr next;
}
#endif
private IntPtr _handle;
/// <summary>
/// Constructor
/// </summary>
@@ -54,12 +41,12 @@ namespace CurlSharp
public CurlSlist()
{
Curl.EnsureCurl();
_handle = IntPtr.Zero;
Handle = IntPtr.Zero;
}
public CurlSlist(IntPtr handle)
{
_handle = handle;
Handle = handle;
}
/// <summary>
@@ -69,13 +56,13 @@ namespace CurlSharp
{
get
{
if (_handle == IntPtr.Zero)
if (Handle == IntPtr.Zero)
return null;
var strings = new List<string>();
#if !USE_LIBCURLSHIM
var slist = new curl_slist();
Marshal.PtrToStructure(_handle, slist);
Marshal.PtrToStructure(Handle, slist);
while (true)
{
@@ -90,6 +77,17 @@ namespace CurlSharp
}
}
internal IntPtr Handle { get; private set; }
/// <summary>
/// Free all internal strings.
/// </summary>
public void Dispose()
{
GC.SuppressFinalize(this);
Dispose(true);
}
/// <summary>
/// Destructor
/// </summary>
@@ -105,40 +103,38 @@ namespace CurlSharp
public void Append(string str)
{
#if USE_LIBCURLSHIM
_handle = NativeMethods.curl_shim_add_string_to_slist(_handle, str);
Handle = NativeMethods.curl_shim_add_string_to_slist(Handle, str);
#else
_handle = NativeMethods.curl_slist_append(_handle, str);
Handle = NativeMethods.curl_slist_append(Handle, str);
#endif
}
/// <summary>
/// Free all internal strings.
/// </summary>
public void Dispose()
{
GC.SuppressFinalize(this);
Dispose(true);
}
internal IntPtr Handle
{
get { return _handle; }
}
private void Dispose(bool disposing)
{
lock (this)
{
if (_handle != IntPtr.Zero)
if (Handle != IntPtr.Zero)
{
#if USE_LIBCURLSHIM
NativeMethods.curl_shim_free_slist(_handle);
NativeMethods.curl_shim_free_slist(Handle);
#else
NativeMethods.curl_slist_free_all(_handle);
NativeMethods.curl_slist_free_all(Handle);
#endif
_handle = IntPtr.Zero;
Handle = IntPtr.Zero;
}
}
}
#if !USE_LIBCURLSHIM
[StructLayout(LayoutKind.Sequential)]
private class curl_slist
{
/// char*
[MarshalAs(UnmanagedType.LPStr)] public string data;
/// curl_slist*
public IntPtr next;
}
#endif
}
}