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

Fix Net7 Support and Microsoft.Data.SqlClient #81

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="MSBuild.Sdk.Extras/3.0.44">

<PropertyGroup>
<TargetFrameworks>net6.0;net461</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;net461</TargetFrameworks>
<IsPackable>false</IsPackable>
<nullable>enable</nullable>
<LangVersion>10.0</LangVersion>
Expand Down
4 changes: 3 additions & 1 deletion src/Microsoft.SqlServer.Types/ISqlSpatialGridIndexable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Microsoft.SqlServer.Types
using Microsoft.SqlServer.Server;

namespace Microsoft.SqlServer.Types
{
/// <summary>
/// <para>This API supports the product infrastructure and is not intended to be used directly from your code.</para>
Expand Down
16 changes: 7 additions & 9 deletions src/Microsoft.SqlServer.Types/Microsoft.SqlServer.Types.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Configurations>Debug;Release;Debug_Legacy;Release_Legacy</Configurations>
<IsLegacyBuild Condition="$(Configuration.Contains(&quot;Legacy&quot;))">true</IsLegacyBuild>
<MinorVersion>5.0</MinorVersion> <!-- Note: Update PackageValidationBaselineVersion when updating this -->
<MinorVersion>6.0</MinorVersion> <!-- Note: Update PackageValidationBaselineVersion when updating this -->
<Version Condition="'$(IsLegacyBuild)'!='true'">2.$(MinorVersion)</Version>
<Version Condition="'$(IsLegacyBuild)'=='true'">1.$(MinorVersion)</Version>
</PropertyGroup>
Expand Down Expand Up @@ -47,7 +47,7 @@

<ItemGroup Condition="'$(IsLegacyBuild)'!='true'">
<PackageReference Include="Microsoft.Data.SqlClient">
<Version>4.0.0</Version>
<Version>5.0.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(IsLegacyBuild)'=='true'">
Expand All @@ -56,9 +56,9 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<None Include="README.md" Pack="true" PackagePath="\"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<Target Name="SignAssemblies" Condition="Exists($(CertificatePath)) AND '$(CertificatePassword)'!=''" BeforeTargets="CopyFilesToOutputDirectory" DependsOnTargets="ComputeIntermediateSatelliteAssemblies">
Expand All @@ -77,10 +77,8 @@
<FilesToSign Include="@(IntermediateSatelliteAssembliesWithTargetPath)" />
<FilesToSignFiltered Include="@(FilesToSign)" Condition="Exists(%(FilesToSign.Identity))" />
</ItemGroup>
<Exec Condition="'@(FilesToSignFiltered->Count())' > 0" Command="&quot;$(SignToolPath)&quot; sign /v /fd SHA1 /f &quot;$(CertificatePath)&quot; /p &quot;$(CertificatePassword)&quot; /tr http://timestamp.digicert.com /td SHA1 &quot;%(FilesToSignFiltered.Identity)&quot;"
WorkingDirectory="$(ProjectDir)" EchoOff="true" />
<Exec Condition="'@(FilesToSignFiltered->Count())' > 0" Command="&quot;$(SignToolPath)&quot; sign /v /as /d &quot;Authorization Summary&quot; /fd SHA256 /f &quot;$(CertificatePath)&quot; /p &quot;$(CertificatePassword)&quot; /tr http://timestamp.digicert.com /td SHA256 &quot;%(FilesToSignFiltered.Identity)&quot;"
WorkingDirectory="$(ProjectDir)" EchoOff="true" />
<Exec Condition="'@(FilesToSignFiltered-&gt;Count())' &gt; 0" Command="&quot;$(SignToolPath)&quot; sign /v /fd SHA1 /f &quot;$(CertificatePath)&quot; /p &quot;$(CertificatePassword)&quot; /tr http://timestamp.digicert.com /td SHA1 &quot;%(FilesToSignFiltered.Identity)&quot;" WorkingDirectory="$(ProjectDir)" EchoOff="true" />
<Exec Condition="'@(FilesToSignFiltered-&gt;Count())' &gt; 0" Command="&quot;$(SignToolPath)&quot; sign /v /as /d &quot;Authorization Summary&quot; /fd SHA256 /f &quot;$(CertificatePath)&quot; /p &quot;$(CertificatePassword)&quot; /tr http://timestamp.digicert.com /td SHA256 &quot;%(FilesToSignFiltered.Identity)&quot;" WorkingDirectory="$(ProjectDir)" EchoOff="true" />
</Target>

</Project>
82 changes: 42 additions & 40 deletions src/Microsoft.SqlServer.Types/SqlGeography.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Microsoft.SqlServer.Server;

namespace Microsoft.SqlServer.Types
{
/// <summary>
Expand All @@ -11,10 +13,10 @@ public class SqlGeography : INullable, IBinarySerialize

internal SqlGeography(bool isNull) { IsNull = isNull; }

internal SqlGeography(ShapeData g, int srid)
{
this.srid = srid;
this._geometry = g;
internal SqlGeography(ShapeData g, int srid)
{
this.srid = srid;
this._geometry = g;
}

/// <summary>
Expand Down Expand Up @@ -170,14 +172,14 @@ public static SqlGeography Null {
/// <para>This method will return NULL if this is not a Polygon instance and will return 0 if the instance is empty.</para>
/// </returns>
/// <remarks>In the SQL Server geography type, external and internal rings are not distinguished, as any ring can be taken to be the external ring.</remarks>
[SqlMethod(IsDeterministic = true, IsPrecise = true)]
public SqlInt32 NumRings()
[SqlMethod(IsDeterministic = true, IsPrecise = true)]
public SqlInt32 NumRings()
{
if (IsNull || (_geometry.Type != OGCGeometryType.Polygon && _geometry.Type != OGCGeometryType.CurvePolygon))
{
return SqlInt32.Null;
}
return this._geometry.NumRings;
{
return SqlInt32.Null;
}
return this._geometry.NumRings;
}

/// <summary>
Expand Down Expand Up @@ -225,19 +227,19 @@ public SqlInt32 STNumCurves()
{
if (IsNull || _geometry.IsEmpty) return SqlInt32.Null;

if (_geometry.Type == OGCGeometryType.LineString)
return _geometry.IsEmpty ? 0 : _geometry.NumPoints - 1;
if (_geometry.Type == OGCGeometryType.LineString)
return _geometry.IsEmpty ? 0 : _geometry.NumPoints - 1;

if (_geometry.Type == OGCGeometryType.CircularString)
if (_geometry.Type == OGCGeometryType.CircularString)
{
if (_geometry.IsEmpty) return 0;
return (_geometry.NumPoints - 1) / 2;
}
if(_geometry.Type == OGCGeometryType.Polygon)
return _geometry.NumRings;
return _geometry.NumRings;
if (_geometry.Type != OGCGeometryType.CompoundCurve)
return SqlInt32.Null;
return _geometry.NumRings;
return _geometry.NumRings;
}

/// <summary>
Expand All @@ -252,7 +254,7 @@ public SqlInt32 STNumCurves()
[SqlMethod(IsDeterministic = true, IsPrecise = true)]
public SqlGeography STGeometryN(int n)
{
if (n < 1)
if (n < 1)
throw new ArgumentOutOfRangeException(nameof(n));

if (IsNull || n > STNumGeometries())
Expand Down Expand Up @@ -291,24 +293,24 @@ public SqlGeography STCurveN(int n)
/// </remarks>
public SqlGeography STPointN(int n)
{
if (n < 1)
throw new ArgumentOutOfRangeException(nameof(n));
if (IsNull)
return SqlGeography.Null;

if (n > this._geometry.NumPoints)
return SqlGeography.Null;

var p = _geometry.GetPointN(n);
if (n < 1)
throw new ArgumentOutOfRangeException(nameof(n));
if (IsNull)
return SqlGeography.Null;
if (n > this._geometry.NumPoints)
return SqlGeography.Null;
var p = _geometry.GetPointN(n);
return new SqlGeography(new ShapeData(p.X, p.Y, HasZ ? (double?)p.Z : null, HasM ? (double?)p.M : null), srid);
}

/// <summary>
/// Returns the start point of a SqlGeography instance.
/// </summary>
/// <returns>A SqlGeography value that represents the start point of the calling SqlGeography.</returns>
/// <remarks>STStartPoint is the equivalent of STPointN(1).</remarks>
[SqlMethod(IsDeterministic = true, IsPrecise = true)]
/// <returns>A SqlGeography value that represents the start point of the calling SqlGeography.</returns>
/// <remarks>STStartPoint is the equivalent of STPointN(1).</remarks>
[SqlMethod(IsDeterministic = true, IsPrecise = true)]
public SqlGeography STStartPoint() => this.STPointN(1);

// public SqlGeography STUnion(SqlGeography sqlGeography)
Expand All @@ -324,8 +326,8 @@ public SqlGeography STPointN(int n)
/// <para>STEndPoint is the equivalent of SqlGeography.STPointN(x.STNumPoints()).</para>
/// <para>This method returns null if called on an empty geography instance.</para>
/// </remarks>
[SqlMethod(IsDeterministic = true, IsPrecise = true)]
public SqlGeography STEndPoint() => STPointN(Math.Max(1, _geometry.NumPoints));
[SqlMethod(IsDeterministic = true, IsPrecise = true)]
public SqlGeography STEndPoint() => STPointN(Math.Max(1, _geometry.NumPoints));

/// <summary>
/// Returns the specified ring of the SqlGeography instance: 1 ≤ n ≤ NumRings().
Expand All @@ -338,14 +340,14 @@ public SqlGeography STPointN(int n)
[SqlMethodAttribute(IsDeterministic = true, IsPrecise = true)]
public SqlGeography RingN(int n)
{
if (n < 1)
if (n < 1)
throw new ArgumentOutOfRangeException(nameof(n));
if (IsNull || (_geometry.Type != OGCGeometryType.Polygon && _geometry.Type != OGCGeometryType.CurvePolygon) || n > this._geometry.NumRings)
{
return SqlGeography.Null;
}
ShapeData ring = _geometry.GetRing(n - 1);
ring.SetIsValid(false);
if (IsNull || (_geometry.Type != OGCGeometryType.Polygon && _geometry.Type != OGCGeometryType.CurvePolygon) || n > this._geometry.NumRings)
{
return SqlGeography.Null;
}
ShapeData ring = _geometry.GetRing(n - 1);
ring.SetIsValid(false);
return new SqlGeography(ring, this.srid);
}

Expand All @@ -356,8 +358,8 @@ public SqlGeography RingN(int n)
[SqlMethodAttribute(IsDeterministic = true, IsPrecise = true)]
public SqlBoolean STIsEmpty()
{
if (this.IsNull)
return SqlBoolean.Null;
if (this.IsNull)
return SqlBoolean.Null;
return _geometry.IsEmpty;
}

Expand Down
10 changes: 6 additions & 4 deletions src/Microsoft.SqlServer.Types/SqlGeometry.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Microsoft.SqlServer.Server;

namespace Microsoft.SqlServer.Types
{
/// <summary>
Expand Down Expand Up @@ -199,10 +201,10 @@ public SqlInt32 STNumCurves()
{
if (IsNull || _geometry.IsEmpty) return SqlInt32.Null;

if (_geometry.Type == OGCGeometryType.LineString)
return _geometry.IsEmpty ? 0 : _geometry.NumPoints - 1;
if (_geometry.Type == OGCGeometryType.LineString)
return _geometry.IsEmpty ? 0 : _geometry.NumPoints - 1;

if (_geometry.Type == OGCGeometryType.CircularString)
if (_geometry.Type == OGCGeometryType.CircularString)
{
if (_geometry.IsEmpty) return 0;
return (_geometry.NumPoints - 1) / 2;
Expand All @@ -211,7 +213,7 @@ public SqlInt32 STNumCurves()
return _geometry.NumRings;
if (_geometry.Type != OGCGeometryType.CompoundCurve)
return SqlInt32.Null;
return _geometry.NumSegments;
return _geometry.NumSegments;
}

/// <summary>
Expand Down
Loading