Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-798828: Target .NET Standard 2.0 #867

Merged
merged 61 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
92cd5df
SNOW-798828: Add other supported versions of .netstandard2.0 to the d…
sfc-gh-ext-simba-lf Feb 15, 2024
04d99d1
SNOW-798828: Add target frameworks to test project
sfc-gh-ext-simba-lf Feb 15, 2024
80eb2aa
SNOW-798828: Remove core 2.0
sfc-gh-ext-simba-lf Feb 15, 2024
8742371
SNOW-798828: Test net5.0
sfc-gh-ext-simba-lf Feb 16, 2024
3794f9d
SNOW-798828: Test net7.0 and net8.0
sfc-gh-ext-simba-lf Feb 16, 2024
45a0cc1
SNOW-798828: Test net461
sfc-gh-ext-simba-lf Feb 16, 2024
327d1d0
SNOW-798828: Test net481
sfc-gh-ext-simba-lf Feb 16, 2024
d689f05
SNOW-798828: Add supported versions to Linux and MAC matrix
sfc-gh-ext-simba-lf Feb 16, 2024
8cb73fc
Set dotnet-version to 8
sfc-gh-ext-simba-lf Feb 20, 2024
e1ccb64
Change RuntimeFrameworkVersion from 6.0.0 to 8.0.0
sfc-gh-ext-simba-lf Feb 21, 2024
389d3ac
Comment line to run tests on Linux/MAC for other versions
sfc-gh-ext-simba-lf Feb 21, 2024
419fbe3
Try run tests sequentially
sfc-gh-ext-simba-lf Feb 21, 2024
4e77c5d
Revert target frameworks for Linux/MAC to net only
sfc-gh-ext-simba-lf Feb 21, 2024
027d6ec
Revert target frameworks Linux/MAC tests and revert sequential
sfc-gh-ext-simba-lf Feb 21, 2024
5928318
Add netcoreapp3.1
sfc-gh-ext-simba-lf Feb 21, 2024
c8a728c
Merge branch 'master' of https://github.com/snowflakedb/snowflake-con…
sfc-gh-ext-simba-lf Feb 21, 2024
f10907e
Add netcoreapp to if check
sfc-gh-ext-simba-lf Feb 21, 2024
5a95182
Test netcoreapp2.0
sfc-gh-ext-simba-lf Feb 21, 2024
4535e3c
Remove netcoreapp2.0
sfc-gh-ext-simba-lf Feb 21, 2024
42619e4
Add net462 to target framework
sfc-gh-ext-simba-lf Feb 21, 2024
c2e2fd9
Add NET Framework 4.8
sfc-gh-ext-simba-lf Mar 5, 2024
9a6defc
Merge branch 'master' of https://github.com/snowflakedb/snowflake-con…
sfc-gh-ext-simba-lf Mar 22, 2024
b06c89d
Add extra case for if
sfc-gh-ext-simba-lf Mar 22, 2024
befb2ce
Set compatible GCS package version with netstandard2.0
sfc-gh-ext-simba-lf Mar 23, 2024
3ce0095
Remove ItemGroup for .NET Framework
sfc-gh-ext-simba-lf Mar 23, 2024
ff49fe8
Set ConfigurationManager to 4.5.0
sfc-gh-ext-simba-lf Mar 23, 2024
cc35840
Remove ItemGroup for netstandard2.0
sfc-gh-ext-simba-lf Mar 25, 2024
23189c4
Set GCS package version to 4.10.0
sfc-gh-ext-simba-lf Apr 10, 2024
32d2d68
Delete commented lines
sfc-gh-ext-simba-lf Apr 10, 2024
b713973
Remove if statement for targets
sfc-gh-ext-simba-lf Apr 25, 2024
89864c6
Merge branch 'master' of https://github.com/snowflakedb/snowflake-con…
sfc-gh-ext-simba-lf Apr 25, 2024
0124942
Add indent
sfc-gh-ext-simba-lf Apr 25, 2024
8a3cc94
Remove obsolete ExtractCell
sfc-gh-ext-simba-lf Apr 25, 2024
403b584
Remove if directive for targets
sfc-gh-ext-simba-lf Apr 25, 2024
63b58cb
Use v4 of github actions
sfc-gh-ext-simba-lf Apr 26, 2024
8c4e6f6
Revert v4 back to v3
sfc-gh-ext-simba-lf Apr 28, 2024
552f946
Remove if directive
sfc-gh-ext-simba-lf Apr 29, 2024
6355b08
Use macos-13
sfc-gh-ext-simba-lf Apr 30, 2024
3009dcb
Run only net5.0 on macos-13 and keep other versions on macos-latest
sfc-gh-ext-simba-lf May 2, 2024
1e36fb0
Merge branch 'master' of https://github.com/snowflakedb/snowflake-con…
sfc-gh-ext-simba-lf May 9, 2024
98f3e58
Remove netcoreapp3.1 and net5.0 from tests
sfc-gh-ext-simba-lf May 14, 2024
20216e4
Merge branch 'master' into SNOW-798828-Target-NET-Standard-2.0
sfc-gh-ext-simba-lf May 15, 2024
873f7e5
Re-added assertion and removed Obsolete line
sfc-gh-ext-simba-lf Jun 5, 2024
ec76690
Merge branch 'master' of https://github.com/snowflakedb/snowflake-con…
sfc-gh-ext-simba-lf Jun 5, 2024
8ba4883
Merge branch 'master' of https://github.com/snowflakedb/snowflake-con…
sfc-gh-ext-simba-lf Jun 12, 2024
9eb464c
Use RuntimeInformation for client environment
sfc-gh-ext-simba-lf Jun 14, 2024
353e81f
Check net version from runtime
sfc-gh-ext-simba-lf Jun 14, 2024
a29b818
Change expected version based on github build
sfc-gh-ext-simba-lf Jun 14, 2024
fb76a0c
Set version to netstandard2.0
sfc-gh-ext-simba-lf Jun 15, 2024
606a057
Use assembly for net version
sfc-gh-ext-simba-lf Jun 15, 2024
2777372
Set netversion using runtime
sfc-gh-ext-simba-lf Jun 15, 2024
722de15
Comment out RuntimeFrameworkVersion
sfc-gh-ext-simba-lf Jun 15, 2024
5bbf02f
Remove unused packages and comment
sfc-gh-ext-simba-lf Jun 15, 2024
0193296
Rename index variable
sfc-gh-ext-simba-lf Jun 17, 2024
e5fc18d
Use the executing assembly's location for framework version
sfc-gh-ext-simba-lf Jun 18, 2024
fd08eb8
Change var name
sfc-gh-ext-simba-lf Jun 18, 2024
41981ae
Simplify assignment
sfc-gh-ext-simba-lf Jun 18, 2024
6ca7cec
Change test to use assembly for expected values
sfc-gh-ext-simba-lf Jun 19, 2024
7437435
Revert "Change test to use assembly for expected values"
sfc-gh-ext-simba-lf Jun 19, 2024
08aa918
Use runtime framework description for net version
sfc-gh-ext-simba-lf Jun 19, 2024
f9818cb
Update README.md about the supported .NET versions
sfc-gh-ext-simba-lf Jun 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ concurrency:
cancel-in-progress: true

# uncomment to run the tests sequentially
#SEQUENTIAL_ENV: SEQUENTIAL_TEST_RUN
# SEQUENTIAL_ENV: SEQUENTIAL_TEST_RUN

jobs:
test-windows:
Expand All @@ -31,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
dotnet: ['net8.0','net6.0', 'net472', 'net471']
dotnet: ['net6.0', 'net7.0', 'net8.0', 'net462', 'net471', 'net472', 'net48', 'net481']
cloud_env: ['AZURE', 'GCP', 'AWS']
steps:
- name: Checkout code
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
strategy:
fail-fast: false
matrix:
dotnet: ['net6.0', 'net8.0']
dotnet: ['net6.0', 'net7.0', 'net8.0']
cloud_env: ['AZURE', 'GCP', 'AWS']
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
strategy:
fail-fast: false
matrix:
dotnet: ['net6.0', 'net8.0']
dotnet: ['net6.0', 'net7.0', 'net8.0']
cloud_env: ['AZURE', 'GCP', 'AWS']
steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@

The Snowflake .NET connector supports the the following .NET framework and libraries versions:

- .NET Framework 4.6.2
- .NET Framework 4.7.1
- .NET Framework 4.7.2
- .NET Framework 4.8
- .NET Framework 4.8.1
- .NET 6.0
- .NET 7.0
- .NET 8.0

Disclaimer: While the connector targets netstandard2.0 and may work with versions in its [support matrix](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0#select-net-standard-version), only the versions listed above are supported and tested by the connector

Please refer to the [Notice](#notice) section below for information about safe usage of the .NET Driver

# Coding conventions for the project
Expand Down Expand Up @@ -144,7 +150,7 @@ Logging description and configuration:
were not performed where the insecureMode flag was set to false, which is the default setting.
From version v2.1.5 CRL is working back as intended.

Note that the driver is now targeting .NET 6.0. When upgrading, you might also need to run “Update-Package -reinstall” to update the dependencies.
Note that the driver is now targeting .NET Standard 2.0. When upgrading, you might also need to run “Update-Package -reinstall” to update the dependencies.

See more:
* [Security Policy](SECURITY.md)
Expand Down
8 changes: 3 additions & 5 deletions Snowflake.Data.Tests/Snowflake.Data.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;net471;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net6.0;net8.0</TargetFrameworks>
<RuntimeFrameworkVersion>6.0.0</RuntimeFrameworkVersion>
<RuntimeFrameworkVersion Condition="'$(TargetFramework)' == 'net8.0'">8.0.0</RuntimeFrameworkVersion>
<TargetFrameworks>net6.0;net7.0;net8.0;net462;net471;net472;net48;net481</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net6.0;net7.0;net8.0;</TargetFrameworks>
<Title>Snowflake.Data.Tests</Title>
<Description>Snowflake Connector for .NET</Description>
<Company>Snowflake Computing, Inc</Company>
Expand Down
2 changes: 1 addition & 1 deletion Snowflake.Data.Tests/UnitTests/ArrowResultChunkTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
*/

Expand Down
16 changes: 12 additions & 4 deletions Snowflake.Data.Tests/UnitTests/ArrowResultSetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,18 @@ public void TestGetText()
[Test]
public void TestGetTextWithOneChar()
{
var testValues =
TestDataGenarator.AsciiCodes.ToCharArray()
.Append(TestDataGenarator.SnowflakeUnicode)
.ToArray();
char[] testValues;

#if NET462
var charArr = TestDataGenarator.AsciiCodes.ToList();
charArr.Add(TestDataGenarator.SnowflakeUnicode);
testValues = charArr.ToArray();
#else
testValues =
TestDataGenarator.AsciiCodes.ToCharArray()
.Append(TestDataGenarator.SnowflakeUnicode)
.ToArray();
#endif

PrepareTestCase(SFDataType.TEXT, 0, testValues);

Expand Down
36 changes: 36 additions & 0 deletions Snowflake.Data.Tests/UnitTests/SFEnvironmentTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using NUnit.Framework;
using Snowflake.Data.Core;

namespace Snowflake.Data.Tests.UnitTests
{
[TestFixture]
class SFEnvironmentTest
{
[Test]
public void TestRuntimeExtraction()
{
// Arrange
string expectedRuntime = ".NET";
string expectedVersion;

#if NETFRAMEWORK
expectedRuntime += "Framework";
expectedVersion = "4.8";
#elif NET6_0
expectedVersion = "6.0";
#elif NET7_0
expectedVersion = "7.0";
#elif NET8_0
expectedVersion = "8.0";
#endif

// Act
var actualRuntime = SFEnvironment.ExtractRuntime();
var actualVersion = SFEnvironment.ExtractVersion();

// Assert
Assert.AreEqual(expectedRuntime, actualRuntime);
Assert.AreEqual(expectedVersion, actualVersion);
}
}
}
4 changes: 0 additions & 4 deletions Snowflake.Data.Tests/Util/SnowflakeDbExceptionAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ public static void HasHttpErrorCodeInExceptionChain(Exception exception, HttpSta
case SnowflakeDbException se:
return se.ErrorCode == (int)expected;
case HttpRequestException he:
#if NETFRAMEWORK
return he.Message.Contains(((int)expected).ToString());
#else
return he.StatusCode == expected;
#endif
default:
return false;
}
Expand Down
1 change: 0 additions & 1 deletion Snowflake.Data/Core/ArrowResultChunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public override UTF8Buffer ExtractCell(int rowIndex, int columnIndex)
throw new NotSupportedException();
}

[Obsolete("ExtractCell with columnIndex is deprecated", false)]
public override UTF8Buffer ExtractCell(int columnIndex)
{
throw new NotSupportedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ private static void StartBrowser(string url)
}

// The following code is learnt from https://brockallen.com/2016/09/24/process-start-for-urls-on-net-core/
#if NETFRAMEWORK
// .net standard would pass here
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
#else
// hack because of this: https://github.com/dotnet/corefx/issues/10361
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Expand All @@ -226,7 +222,6 @@ private static void StartBrowser(string url)
{
throw new SnowflakeDbException(SFError.UNSUPPORTED_PLATFORM);
}
#endif
}

private static string ValidateAndExtractToken(HttpListenerRequest request)
Expand Down
6 changes: 1 addition & 5 deletions Snowflake.Data/Core/Authenticator/OktaAuthenticator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
*/

Expand Down Expand Up @@ -82,11 +82,7 @@ async Task IAuthenticator.AuthenticateAsync(CancellationToken cancellationToken)
s_logger.Debug("step 4: Get SAML response from SSO");
var samlRestRequest = BuildSamlRestRequest(ssoUrl, onetimeToken);
samlRawResponse = await session.restRequester.GetAsync(samlRestRequest, cancellationToken).ConfigureAwait(false);
#if NETFRAMEWORK
_rawSamlTokenHtmlString = await samlRawResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
#else
_rawSamlTokenHtmlString = await samlRawResponse.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
#endif
s_logger.Debug("step 5: Verify postback URL in SAML response");
VerifyPostbackUrl();

Expand Down
31 changes: 19 additions & 12 deletions Snowflake.Data/Core/RestParams.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System;
using System.Reflection;
using System.Runtime.InteropServices;

namespace Snowflake.Data.Core
{
Expand Down Expand Up @@ -59,23 +59,30 @@ static SFEnvironment()
ClientEnv = new LoginRequestClientEnv()
{
application = System.Diagnostics.Process.GetCurrentProcess().ProcessName,
osVersion = System.Environment.OSVersion.VersionString,
#if NETFRAMEWORK
netRuntime = "NETFramework",
netVersion = "4.7.1",
sfc-gh-knozderko marked this conversation as resolved.
Show resolved Hide resolved
#else
netRuntime = "NETCore",
netVersion ="2.0",
#endif
osVersion = Environment.OSVersion.VersionString,
netRuntime = ExtractRuntime(),
netVersion = ExtractVersion(),
};

DriverVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
DriverVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
DriverName = ".NET";
}

//temporary change for pretend as ODBC
internal static string DriverName { get; set; }
internal static string DriverVersion { get; set; }
internal static LoginRequestClientEnv ClientEnv { get; private set; }

internal static string ExtractRuntime()
{
return RuntimeInformation.FrameworkDescription.Substring(0, RuntimeInformation.FrameworkDescription.LastIndexOf(' ')).Replace(" ", "");
}

internal static string ExtractVersion()
{
var version = RuntimeInformation.FrameworkDescription.Substring(RuntimeInformation.FrameworkDescription.LastIndexOf(' ')).Replace(" ", "");
int secondPeriodIndex = version.IndexOf('.', version.IndexOf('.') + 1);
return version.Substring(0, secondPeriodIndex);
}
}
}
13 changes: 2 additions & 11 deletions Snowflake.Data/Snowflake.Data.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;net471;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net6.0;net8.0</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
sfc-gh-knozderko marked this conversation as resolved.
Show resolved Hide resolved
<Title>Snowflake.Data</Title>
<PackageId>Snowflake.Data</PackageId>
<PackageLicenseUrl>https://github.com/snowflakedb/snowflake-connector-net/blob/master/LICENSE</PackageLicenseUrl>
Expand All @@ -26,7 +25,7 @@
<ItemGroup>
<PackageReference Include="Apache.Arrow" Version="14.0.2" />
<PackageReference Include="AWSSDK.S3" Version="3.7.0.4" />
<PackageReference Include="Google.Cloud.Storage.V1" Version="4.6.0" />
<PackageReference Include="Google.Cloud.Storage.V1" Version="4.10.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
<PackageReference Include="Azure.Storage.Common" Version="12.12.0" />
<PackageReference Include="Mono.Unix" Version="7.1.0-final.1.21458.1" />
Expand All @@ -37,14 +36,6 @@
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net471' Or '$(TargetFramework)' == 'net472'">
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' != 'Release'">
<InternalsVisibleTo Include="Snowflake.Data.Tests" />
<!--needed by Moq to be able to mock internal interfaces-->
Expand Down
Loading