Skip to content

Commit 393762a

Browse files
SNOW-798828: Target .NET Standard 2.0 (#867)
### Description Change the target framework to .NET Standard 2.0 ### Checklist - [ ] Code compiles correctly - [ ] Code is formatted according to [Coding Conventions](../CodingConventions.md) - [ ] Created tests which fail without the change (if possible) - [ ] All tests passing (`dotnet test`) - [ ] Extended the README / documentation, if necessary - [ ] Provide JIRA issue id (if possible) or GitHub issue id in PR name
1 parent 1465bda commit 393762a

File tree

12 files changed

+85
-53
lines changed

12 files changed

+85
-53
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ concurrency:
2222
cancel-in-progress: true
2323

2424
# uncomment to run the tests sequentially
25-
#SEQUENTIAL_ENV: SEQUENTIAL_TEST_RUN
25+
# SEQUENTIAL_ENV: SEQUENTIAL_TEST_RUN
2626

2727
jobs:
2828
test-windows:
@@ -31,7 +31,7 @@ jobs:
3131
strategy:
3232
fail-fast: false
3333
matrix:
34-
dotnet: ['net8.0','net6.0', 'net472', 'net471']
34+
dotnet: ['net6.0', 'net7.0', 'net8.0', 'net462', 'net471', 'net472', 'net48', 'net481']
3535
cloud_env: ['AZURE', 'GCP', 'AWS']
3636
steps:
3737
- name: Checkout code
@@ -92,7 +92,7 @@ jobs:
9292
strategy:
9393
fail-fast: false
9494
matrix:
95-
dotnet: ['net6.0', 'net8.0']
95+
dotnet: ['net6.0', 'net7.0', 'net8.0']
9696
cloud_env: ['AZURE', 'GCP', 'AWS']
9797
steps:
9898
- uses: actions/checkout@v3
@@ -151,7 +151,7 @@ jobs:
151151
strategy:
152152
fail-fast: false
153153
matrix:
154-
dotnet: ['net6.0', 'net8.0']
154+
dotnet: ['net6.0', 'net7.0', 'net8.0']
155155
cloud_env: ['AZURE', 'GCP', 'AWS']
156156
steps:
157157
- uses: actions/checkout@v4

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@
66

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

9+
- .NET Framework 4.6.2
910
- .NET Framework 4.7.1
1011
- .NET Framework 4.7.2
12+
- .NET Framework 4.8
13+
- .NET Framework 4.8.1
1114
- .NET 6.0
15+
- .NET 7.0
1216
- .NET 8.0
1317

18+
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
19+
1420
Please refer to the [Notice](#notice) section below for information about safe usage of the .NET Driver
1521

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

147-
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.
153+
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.
148154

149155
See more:
150156
* [Security Policy](SECURITY.md)

Snowflake.Data.Tests/Snowflake.Data.Tests.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net8.0;net6.0;net471;net472</TargetFrameworks>
4-
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net6.0;net8.0</TargetFrameworks>
5-
<RuntimeFrameworkVersion>6.0.0</RuntimeFrameworkVersion>
6-
<RuntimeFrameworkVersion Condition="'$(TargetFramework)' == 'net8.0'">8.0.0</RuntimeFrameworkVersion>
3+
<TargetFrameworks>net6.0;net7.0;net8.0;net462;net471;net472;net48;net481</TargetFrameworks>
4+
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net6.0;net7.0;net8.0;</TargetFrameworks>
75
<Title>Snowflake.Data.Tests</Title>
86
<Description>Snowflake Connector for .NET</Description>
97
<Company>Snowflake Computing, Inc</Company>

Snowflake.Data.Tests/UnitTests/ArrowResultChunkTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
33
*/
44

Snowflake.Data.Tests/UnitTests/ArrowResultSetTest.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,18 @@ public void TestGetText()
275275
[Test]
276276
public void TestGetTextWithOneChar()
277277
{
278-
var testValues =
279-
TestDataGenarator.AsciiCodes.ToCharArray()
280-
.Append(TestDataGenarator.SnowflakeUnicode)
281-
.ToArray();
278+
char[] testValues;
279+
280+
#if NET462
281+
var charArr = TestDataGenarator.AsciiCodes.ToList();
282+
charArr.Add(TestDataGenarator.SnowflakeUnicode);
283+
testValues = charArr.ToArray();
284+
#else
285+
testValues =
286+
TestDataGenarator.AsciiCodes.ToCharArray()
287+
.Append(TestDataGenarator.SnowflakeUnicode)
288+
.ToArray();
289+
#endif
282290

283291
PrepareTestCase(SFDataType.TEXT, 0, testValues);
284292

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using NUnit.Framework;
2+
using Snowflake.Data.Core;
3+
4+
namespace Snowflake.Data.Tests.UnitTests
5+
{
6+
[TestFixture]
7+
class SFEnvironmentTest
8+
{
9+
[Test]
10+
public void TestRuntimeExtraction()
11+
{
12+
// Arrange
13+
string expectedRuntime = ".NET";
14+
string expectedVersion;
15+
16+
#if NETFRAMEWORK
17+
expectedRuntime += "Framework";
18+
expectedVersion = "4.8";
19+
#elif NET6_0
20+
expectedVersion = "6.0";
21+
#elif NET7_0
22+
expectedVersion = "7.0";
23+
#elif NET8_0
24+
expectedVersion = "8.0";
25+
#endif
26+
27+
// Act
28+
var actualRuntime = SFEnvironment.ExtractRuntime();
29+
var actualVersion = SFEnvironment.ExtractVersion();
30+
31+
// Assert
32+
Assert.AreEqual(expectedRuntime, actualRuntime);
33+
Assert.AreEqual(expectedVersion, actualVersion);
34+
}
35+
}
36+
}

Snowflake.Data.Tests/Util/SnowflakeDbExceptionAssert.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ public static void HasHttpErrorCodeInExceptionChain(Exception exception, HttpSta
4141
case SnowflakeDbException se:
4242
return se.ErrorCode == (int)expected;
4343
case HttpRequestException he:
44-
#if NETFRAMEWORK
4544
return he.Message.Contains(((int)expected).ToString());
46-
#else
47-
return he.StatusCode == expected;
48-
#endif
4945
default:
5046
return false;
5147
}

Snowflake.Data/Core/ArrowResultChunk.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ public override UTF8Buffer ExtractCell(int rowIndex, int columnIndex)
138138
throw new NotSupportedException();
139139
}
140140

141-
[Obsolete("ExtractCell with columnIndex is deprecated", false)]
142141
public override UTF8Buffer ExtractCell(int columnIndex)
143142
{
144143
throw new NotSupportedException();

Snowflake.Data/Core/Authenticator/ExternalBrowserAuthenticator.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,6 @@ private static void StartBrowser(string url)
204204
}
205205

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

232227
private static string ValidateAndExtractToken(HttpListenerRequest request)

Snowflake.Data/Core/Authenticator/OktaAuthenticator.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
33
*/
44

@@ -82,11 +82,7 @@ async Task IAuthenticator.AuthenticateAsync(CancellationToken cancellationToken)
8282
s_logger.Debug("step 4: Get SAML response from SSO");
8383
var samlRestRequest = BuildSamlRestRequest(ssoUrl, onetimeToken);
8484
samlRawResponse = await session.restRequester.GetAsync(samlRestRequest, cancellationToken).ConfigureAwait(false);
85-
#if NETFRAMEWORK
8685
_rawSamlTokenHtmlString = await samlRawResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
87-
#else
88-
_rawSamlTokenHtmlString = await samlRawResponse.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
89-
#endif
9086
s_logger.Debug("step 5: Verify postback URL in SAML response");
9187
VerifyPostbackUrl();
9288

0 commit comments

Comments
 (0)