Commit 7357e1ef authored by Martin Finkel's avatar Martin Finkel

Review

parent 2b8acca6
<Project>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>$(DefineConstants);PORTABLE;NETSTANDARD2_0</DefineConstants>
<DefineConstants>$(DefineConstants);PORTABLE;NETSTANDARD2_0;NETSTANDARD</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.1'">
<DefineConstants>$(DefineConstants);NETSTANDARD1_1</DefineConstants>
<DefineConstants>$(DefineConstants);NETSTANDARD1_1;NETSTANDARD</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
<DefineConstants>$(DefineConstants);NET40</DefineConstants>
......
......@@ -22,9 +22,6 @@
<DefineConstants>$(DefineConstants);UNITY_ANDROID</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' != 'net40'"
Include="System.Runtime.InteropServices.RuntimeInformation"
Version="4.3.0" />
<Compile Include="Shared\**\*.cs" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid'))">
......
......@@ -56,7 +56,8 @@ namespace LibVLCSharp.Shared
if(appExecutionDirectory == null)
{
#if NETSTANDARD1_1
throw new ArgumentNullException($"{nameof(appExecutionDirectory)} cannot be null for netstandard1.1 target. Please provide a path to Initialize.");
throw new ArgumentNullException(nameof(appExecutionDirectory),
$"{nameof(appExecutionDirectory)} cannot be null for netstandard1.1 target. Please provide a path to Initialize.");
#else
var myPath = typeof(LibVLC).Assembly.Location;
appExecutionDirectory = Path.GetDirectoryName(myPath);
......@@ -105,27 +106,20 @@ namespace LibVLCSharp.Shared
static bool IsWindows
{
get
{
#if NET40
return Environment.OSVersion.Platform != PlatformID.MacOSX
&& Environment.OSVersion.Platform != PlatformID.Unix;
get => Environment.OSVersion.Platform == PlatformID.Win32NT;
#else
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
get => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#endif
}
}
static bool IsX64BitProcess
{
get
{
#if NET40
return Environment.Is64BitProcess;
get => Environment.Is64BitProcess;
#else
return RuntimeInformation.OSArchitecture == Architecture.X64;
get => RuntimeInformation.OSArchitecture == Architecture.X64;
#endif
}
}
}
......@@ -151,9 +145,9 @@ namespace LibVLCSharp.Shared
/// </summary>
internal const string LibrariesRepositoryFolderName = "libvlc";
internal const string Windows = "msvcrt";
internal const string Linux = "libc";
internal const string Mac = "libSystem";
internal const string Msvcrt = "msvcrt";
internal const string Libc = "libc";
internal const string libSystem = "libSystem";
}
internal static class ArchitectureNames
......
......@@ -147,7 +147,7 @@ namespace LibVLCSharp.Shared
/// <param name="format"></param>
/// <param name="ptr"></param>
/// <returns></returns>
[DllImport(Constants.Windows, CallingConvention = CallingConvention.Cdecl)]
[DllImport(Constants.Msvcrt, CallingConvention = CallingConvention.Cdecl)]
public static extern int _vscprintf(string format, IntPtr ptr);
/// <summary>
......@@ -160,7 +160,7 @@ namespace LibVLCSharp.Shared
/// <param name="format">The message format</param>
/// <param name="args">The variable arguments list pointer. We do not know what it is, but the pointer must be given as-is from C back to sprintf.</param>
/// <returns>A negative value on failure, the number of characters written otherwise.</returns>
[DllImport(Constants.Windows, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
[DllImport(Constants.Msvcrt, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern int vsprintf(
IntPtr buffer,
string format,
......
......@@ -11,30 +11,30 @@ namespace LibVLCSharp.Shared
{
#region Windows
[DllImport(Constants.Windows, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, SetLastError = true)]
[DllImport(Constants.Msvcrt, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int _wfopen_s(out IntPtr pFile, string filename, string mode = Write);
[DllImport(Constants.Windows, CallingConvention = CallingConvention.Cdecl, EntryPoint = "fclose", SetLastError = true)]
[DllImport(Constants.Msvcrt, CallingConvention = CallingConvention.Cdecl, EntryPoint = "fclose", SetLastError = true)]
public static extern int fcloseWindows(IntPtr stream);
#endregion
#region Linux
[DllImport(Constants.Linux, CallingConvention = CallingConvention.Cdecl, EntryPoint = "fopen", CharSet = CharSet.Ansi, SetLastError = true)]
[DllImport(Constants.Libc, CallingConvention = CallingConvention.Cdecl, EntryPoint = "fopen", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr fopenLinux(string filename, string mode = Write);
[DllImport(Constants.Linux, CallingConvention = CallingConvention.Cdecl, EntryPoint = "fclose", CharSet = CharSet.Ansi, SetLastError = true)]
[DllImport(Constants.Libc, CallingConvention = CallingConvention.Cdecl, EntryPoint = "fclose", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern int fcloseLinux(IntPtr file);
#endregion
#region Mac
[DllImport(Constants.Mac, CallingConvention = CallingConvention.Cdecl, EntryPoint = "fopen", SetLastError = true)]
[DllImport(Constants.libSystem, CallingConvention = CallingConvention.Cdecl, EntryPoint = "fopen", SetLastError = true)]
public static extern IntPtr fopenMac(string path, string mode = Write);
[DllImport(Constants.Mac, CallingConvention = CallingConvention.Cdecl, EntryPoint = "fclose", SetLastError = true)]
[DllImport(Constants.libSystem, CallingConvention = CallingConvention.Cdecl, EntryPoint = "fclose", SetLastError = true)]
public static extern int fcloseMac(IntPtr file);
#endregion
......
......@@ -83,7 +83,7 @@ namespace LibVLCSharp.Shared
EntryPoint = "libvlc_media_player_get_xwindow")]
internal static extern uint LibVLCMediaPlayerGetXwindow(IntPtr mediaPlayer);
#if NETSTANDARD2_0 || NET40
#if NETSTANDARD || NET40
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_hwnd")]
internal static extern void LibVLCMediaPlayerSetHwnd(IntPtr mediaPlayer, IntPtr drawable);
......@@ -755,7 +755,7 @@ namespace LibVLCSharp.Shared
}
#endif
#if NETSTANDARD2_0 || NET40
#if NETSTANDARD || NET40
/// <summary>
/// Set an X Window System drawable where the media player should render its video output.
/// The call takes effect when the playback starts. If it is already started, it might need to be stopped before changes apply.
......
......@@ -76,11 +76,8 @@ namespace LibVLCSharp.Shared
{
const int VideoRenderer = 0x0002;
const int AudioRenderer = 0x0001;
#if NETSTANDARD1_1
readonly Utf8StringMarshaler _utf8Marshaler = Utf8StringMarshaler.GetInstance();
#else
readonly ICustomMarshaler _utf8Marshaler = Utf8StringMarshaler.GetInstance();
#endif
struct Native
{
......
......@@ -62,11 +62,8 @@ namespace LibVLCSharp.Shared
{
return -1;
}
#if !NETSTANDARD1_1
public static ICustomMarshaler GetInstance(string cookie = null)
#else
public static Utf8StringMarshaler GetInstance()
#endif
{
return _instance;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment