ericmend / oracleClientCore-2.0

Unofficial Oracle Client for .Net Core
MIT License
31 stars 6 forks source link

Identification MacOSX #9

Open dubo opened 6 years ago

dubo commented 6 years ago

Hi Eric, I have problem run your library at MacOSX Darwin. Code in OciCalls.cs evaluate MacOSX and Ubuntu as Unix, platform ID 4 . I found solution atr https://stackoverflow.com/questions/38790802/determine-operating-system-in-net-core , see code below.

Problematic code in OciCalls.cs:
...

if ((int)Environment.OSVersion.Platform == 4 || (int)Environment.OSVersion.Platform == 128)
{
  mOciNativeCalls = new OciNativeCallsLinux();
}
else if ((int)Environment.OSVersion.Platform == 6)
{
  mOciNativeCalls = new OciNativeCallsMacOSX();
}
else
{
  mOciNativeCalls = new OciNativeCallsWindows();
}

...

I run simple test for OS envirement variables at MacOSX an Linux:

// -- I think, that this is better test as use Environment.OSVersion.Platform value
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) 
    osplatform = "Windows";
else if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX)) 
    osplatform = "OSX";
else if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux)) 
    osplatform = "Linux";
else
    osplatform = "Unknown";
Console.WriteLine("Enviroment OS: " + Environment.OSVersion.Platform + ", platform ID " + (int)Environment.OSVersion.Platform );
Console.WriteLine("OsPlatform   : " + osplatform);
Console.WriteLine("Architecture : " + System.Runtime.InteropServices.RuntimeInformation.OSArchitecture);
Console.WriteLine("OsDescription: " + System.Runtime.InteropServices.RuntimeInformation.OSDescription);

Output

* MacOSX Darwin ** Enviroment OS: Unix, platform ID 4 OsPlatform : OSX Architecture : X64 OsDescription: Darwin 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64

Linux Mit 18 Enviroment OS: Unix, platform ID 4 OsPlatform : Linux Architecture : X64 OsDescription: Linux 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec 4 15:57:59 UTC 2017

ericmend commented 6 years ago

Olá @dubo , sinceramente não consigo realizar testes em MacOS. Vou realizar a alteração e testar em Windows e Linux e gerar um novo nuget.