Skip to content

Commit 14bbf42

Browse files
authored
Merge SqlType resource methodology, removed unused strings (dotnet#3733)
1 parent 8c88784 commit 14bbf42

8 files changed

Lines changed: 19 additions & 90 deletions

File tree

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,9 +1002,6 @@
10021002
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlJson.cs">
10031003
<Link>Microsoft\Data\SqlTypes\SqlJson.cs</Link>
10041004
</Compile>
1005-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SQLResource.cs">
1006-
<Link>Microsoft\Data\SQLTypes\SQLResource.cs</Link>
1007-
</Compile>
10081005
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlTypeWorkarounds.cs">
10091006
<Link>Microsoft\Data\SqlTypes\SqlTypeWorkarounds.cs</Link>
10101007
</Compile>

src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -979,9 +979,6 @@
979979
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlVector.cs">
980980
<Link>Microsoft\Data\SqlTypes\SqlVector.cs</Link>
981981
</Compile>
982-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SQLResource.cs">
983-
<Link>Microsoft\Data\SqlTypes\SQLResource.cs</Link>
984-
</Compile>
985982
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlTypeWorkarounds.cs">
986983
<Link>Microsoft\Data\SqlTypes\SqlTypeWorkarounds.cs</Link>
987984
</Compile>

src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ internal static AuthenticationException SSLCertificateAuthenticationException(st
378378
internal static ArgumentOutOfRangeException NotSupportedEnumerationValue(Type type, string value, string method)
379379
=> ArgumentOutOfRange(StringsHelper.GetString(Strings.ADP_NotSupportedEnumerationValue, type.Name, value, method), type.Name);
380380

381+
internal static ArgumentOutOfRangeException InvalidArraySize(string parameterName) =>
382+
ArgumentOutOfRange(StringsHelper.GetString(Strings.SqlMisc_InvalidArraySizeMessage), parameterName);
383+
381384
internal static void CheckArgumentNull(object value, string parameterName)
382385
{
383386
if (value is null)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,11 @@ internal decimal Decimal
271271
}
272272
catch (OverflowException)
273273
{
274-
throw new OverflowException(SQLResource.ConversionOverflowMessage);
274+
throw SQL.ConversionOverflow();
275275
}
276276
}
277277
}
278-
throw new OverflowException(SQLResource.ConversionOverflowMessage);
278+
throw SQL.ConversionOverflow();
279279
}
280280
return new decimal(_value._numericInfo._data1, _value._numericInfo._data2, _value._numericInfo._data3, !_value._numericInfo._positive, _value._numericInfo._scale);
281281
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,14 @@ internal static Exception UDTUnexpectedResult(string exceptionText)
830830
return ADP.TypeLoad(StringsHelper.GetString(Strings.SQLUDT_Unexpected, exceptionText));
831831
}
832832

833+
internal static Exception ConversionOverflow()
834+
{
835+
return new OverflowException(StringsHelper.GetString(Strings.SqlMisc_ConversionOverflowMessage));
836+
}
837+
833838
internal static Exception DateTimeOverflow()
834839
{
835-
return new OverflowException(SqlTypes.SQLResource.DateTimeOverflowMessage);
840+
return new OverflowException(StringsHelper.GetString(Strings.SqlMisc_DateTimeOverflowMessage));
836841
}
837842

838843
//
@@ -2285,6 +2290,10 @@ internal static string ExRoutingDestination()
22852290
{
22862291
return StringsHelper.GetString(Strings.SQL_ExRoutingDestination);
22872292
}
2293+
internal static string NullString()
2294+
{
2295+
return StringsHelper.GetString(Strings.SqlMisc_NullString);
2296+
}
22882297
}
22892298

22902299
/// <summary>

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SQLResource.cs

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private SqlVector(int length)
4141
{
4242
if (length < 0)
4343
{
44-
throw ADP.ArgumentOutOfRange(nameof(length), SQLResource.InvalidArraySizeMessage);
44+
throw ADP.InvalidArraySize(nameof(length));
4545
}
4646

4747
(_elementType, _elementSize) = GetTypeFieldsOrThrow();
@@ -92,7 +92,7 @@ internal string GetString()
9292
{
9393
if (IsNull)
9494
{
95-
return SQLResource.NullString;
95+
return SQLMessage.NullString();
9696
}
9797
return JsonSerializer.Serialize(Memory);
9898
}

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlTypes/SqlVectorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void Construct_Length()
3838
// to the same memory. We want to check memory content equality, so we
3939
// compare their arrays instead.
4040
Assert.Equal(new ReadOnlyMemory<float>().ToArray(), vec.Memory.ToArray());
41-
Assert.Equal(SQLResource.NullString, vec.GetString());
41+
Assert.Equal(SQLMessage.NullString(), vec.GetString());
4242

4343
var ivec = vec as ISqlVector;
4444
Assert.Equal(0x00, ivec.ElementType);
@@ -58,7 +58,7 @@ public void Construct_WithLengthZero()
5858
// to the same memory. We want to check memory content equality, so we
5959
// compare their arrays instead.
6060
Assert.Equal(new ReadOnlyMemory<float>().ToArray(), vec.Memory.ToArray());
61-
Assert.Equal(SQLResource.NullString, vec.GetString());
61+
Assert.Equal(SQLMessage.NullString(), vec.GetString());
6262

6363
var ivec = vec as ISqlVector;
6464
Assert.Equal(0x00, ivec.ElementType);

0 commit comments

Comments
 (0)