Skip to content

Commit

Permalink
Verifies support for SqlHierarchyId and Spatial for .NET Core (#1848)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikEJ committed Feb 1, 2023
1 parent 518869e commit 1d7e01d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 32 deletions.
Expand Up @@ -323,6 +323,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="$(SystemIdentityModelTokensJwtVersion)" />
<PackageReference Condition="'$(TargetGroup)'=='netfx'" Include="Microsoft.SqlServer.Types" Version="$(MicrosoftSqlServerTypesVersion)" />
<PackageReference Condition="'$(TargetGroup)'=='netcoreapp'" Include="Microsoft.SqlServer.Types" Version="$(MicrosoftSqlServerTypesVersionNet)" />
<PackageReference Condition="'$(TargetGroup)'=='netcoreapp'" Include="Microsoft.DotNet.RemoteExecutor" Version="$(MicrosoftDotnetRemoteExecutorVersion)" />
<PackageReference Condition="'$(TargetGroup)'!='netfx'" Include="System.ServiceProcess.ServiceController" Version="$(SystemServiceProcessServiceControllerVersion)" />
</ItemGroup>
Expand Down
Expand Up @@ -2,20 +2,17 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if NETFRAMEWORK
using System;
using System.Globalization;
using Microsoft.SqlServer.Types;
#else
using System.Collections.ObjectModel;
using System.Data.Common;
#endif
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.Common;
using System.Data.SqlTypes;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Types;
using Xunit;

namespace Microsoft.Data.SqlClient.ManualTesting.Tests
Expand Down Expand Up @@ -49,27 +46,6 @@ public static void GetSchemaTableTest()
}

// Synapse: Parse error at line: 1, column: 48: Incorrect syntax near 'hierarchyid'.
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static void GetValueTestThrowsExceptionOnNetCore()
{
using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString))
using (SqlCommand cmd = new SqlCommand("select hierarchyid::Parse('/1/') as col0", conn))
{
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
Assert.True(reader.Read());

// SqlHierarchyId is part of Microsoft.SqlServer.Types, which is not supported in Core
Assert.Throws<FileNotFoundException>(() => reader.GetValue(0));
Assert.Throws<FileNotFoundException>(() => reader.GetSqlValue(0));
}
}
}

// Synapse: Parse error at line: 1, column: 48: Incorrect syntax near 'hierarchyid'.
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp)]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static void GetValueTest()
{
Expand Down Expand Up @@ -274,7 +250,7 @@ private static void TestUdtSqlDataReaderGetStream(CommandBehavior behavior)
}
}
}
#if NETCOREAPP

// Synapse: Parse error at line: 1, column: 41: Incorrect syntax near 'hierarchyid'.
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static void TestUdtSchemaMetadata()
Expand Down Expand Up @@ -313,7 +289,7 @@ public static void TestUdtSchemaMetadata()
}
}
}
#endif

// Synapse: Parse error at line: 1, column: 8: Incorrect syntax near 'geometry'.
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static void TestUdtParameterSetSqlByteValue()
Expand Down Expand Up @@ -411,7 +387,6 @@ private static string ToHexString(byte[] bytes)
return hex.ToString();
}

#if NETFRAMEWORK
private static string GetUdtName(Type udtClrType)
{
if (typeof(SqlHierarchyId) == udtClrType)
Expand Down Expand Up @@ -518,6 +493,5 @@ public static void TestSqlServerTypesInsertAndRead()
DataTestUtility.DropTable(conn, tableName);
}
}
#endif
}
}
1 change: 1 addition & 0 deletions tools/props/Versions.props
Expand Up @@ -71,6 +71,7 @@
<MicrosoftNETCoreRuntimeCoreCLRVersion>2.0.8</MicrosoftNETCoreRuntimeCoreCLRVersion>
<MicrosoftSqlServerSqlManagementObjectsVersion>170.8.0</MicrosoftSqlServerSqlManagementObjectsVersion>
<MicrosoftSqlServerTypesVersion>10.50.1600.1</MicrosoftSqlServerTypesVersion>
<MicrosoftSqlServerTypesVersionNet>160.1000.6</MicrosoftSqlServerTypesVersionNet>
<BenchmarkDotNetVersion>0.13.2</BenchmarkDotNetVersion>
<SystemServiceProcessServiceControllerVersion>6.0.0</SystemServiceProcessServiceControllerVersion>
</PropertyGroup>
Expand Down

0 comments on commit 1d7e01d

Please sign in to comment.