diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj index 62c2f04ec8..d3d00cf1d2 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -810,9 +810,6 @@ Microsoft\Data\SqlDbTypeExtensions.cs - - Microsoft\Data\SQLTypes\SQLResource.cs - Microsoft\Data\SqlTypes\SqlTypeWorkarounds.cs diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj index 8cf025e182..909ed45ea1 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj @@ -978,9 +978,6 @@ Microsoft\Data\SqlTypes\SqlFileStream.cs - - Microsoft\Data\SqlTypes\SQLResource.cs - Microsoft\Data\SqlTypes\SqlTypeWorkarounds.cs diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs index b37f97ac17..1c5000277e 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs @@ -380,6 +380,9 @@ internal static AuthenticationException SSLCertificateAuthenticationException(st internal static ArgumentOutOfRangeException NotSupportedEnumerationValue(Type type, string value, string method) => ArgumentOutOfRange(StringsHelper.GetString(Strings.ADP_NotSupportedEnumerationValue, type.Name, value, method), type.Name); + internal static ArgumentOutOfRangeException InvalidArraySize(string parameterName) => + ArgumentOutOfRange(StringsHelper.GetString(Strings.SqlMisc_InvalidArraySizeMessage), parameterName); + internal static void CheckArgumentNull(object value, string parameterName) { if (value is null) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs index dc1abf1c9d..c03a1c1d1b 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs @@ -271,11 +271,11 @@ internal decimal Decimal } catch (OverflowException) { - throw new OverflowException(SQLResource.ConversionOverflowMessage); + throw SQL.ConversionOverflow(); } } } - throw new OverflowException(SQLResource.ConversionOverflowMessage); + throw SQL.ConversionOverflow(); } return new decimal(_value._numericInfo._data1, _value._numericInfo._data2, _value._numericInfo._data3, !_value._numericInfo._positive, _value._numericInfo._scale); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs index e13a77bd73..6f0f34798a 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs @@ -859,9 +859,14 @@ internal static Exception UDTUnexpectedResult(string exceptionText) return ADP.TypeLoad(StringsHelper.GetString(Strings.SQLUDT_Unexpected, exceptionText)); } + internal static Exception ConversionOverflow() + { + return new OverflowException(StringsHelper.GetString(Strings.SqlMisc_ConversionOverflowMessage)); + } + internal static Exception DateTimeOverflow() { - return new OverflowException(SqlTypes.SQLResource.DateTimeOverflowMessage); + return new OverflowException(StringsHelper.GetString(Strings.SqlMisc_DateTimeOverflowMessage)); } // @@ -2409,6 +2414,10 @@ internal static string ExRoutingDestination() { return StringsHelper.GetString(Strings.SQL_ExRoutingDestination); } + internal static string NullString() + { + return StringsHelper.GetString(Strings.SqlMisc_NullString); + } } /// diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SQLResource.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SQLResource.cs deleted file mode 100644 index 327d182d03..0000000000 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SQLResource.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Data.SqlTypes -{ - - using System; - using Microsoft.Data; - - internal sealed class SQLResource - { - - private SQLResource() { /* prevent utility class from being instantiated*/ } - - internal static readonly String NullString = StringsHelper.GetString(Strings.SqlMisc_NullString); - - internal static readonly String MessageString = StringsHelper.GetString(Strings.SqlMisc_MessageString); - - internal static readonly String ArithOverflowMessage = StringsHelper.GetString(Strings.SqlMisc_ArithOverflowMessage); - - internal static readonly String DivideByZeroMessage = StringsHelper.GetString(Strings.SqlMisc_DivideByZeroMessage); - - internal static readonly String NullValueMessage = StringsHelper.GetString(Strings.SqlMisc_NullValueMessage); - - internal static readonly String TruncationMessage = StringsHelper.GetString(Strings.SqlMisc_TruncationMessage); - - internal static readonly String DateTimeOverflowMessage = StringsHelper.GetString(Strings.SqlMisc_DateTimeOverflowMessage); - - internal static readonly String ConcatDiffCollationMessage = StringsHelper.GetString(Strings.SqlMisc_ConcatDiffCollationMessage); - - internal static readonly String CompareDiffCollationMessage = StringsHelper.GetString(Strings.SqlMisc_CompareDiffCollationMessage); - - internal static readonly String InvalidFlagMessage = StringsHelper.GetString(Strings.SqlMisc_InvalidFlagMessage); - - internal static readonly String NumeToDecOverflowMessage = StringsHelper.GetString(Strings.SqlMisc_NumeToDecOverflowMessage); - - internal static readonly String ConversionOverflowMessage = StringsHelper.GetString(Strings.SqlMisc_ConversionOverflowMessage); - - internal static readonly String InvalidDateTimeMessage = StringsHelper.GetString(Strings.SqlMisc_InvalidDateTimeMessage); - - internal static readonly String TimeZoneSpecifiedMessage = StringsHelper.GetString(Strings.SqlMisc_TimeZoneSpecifiedMessage); - - internal static readonly String InvalidArraySizeMessage = StringsHelper.GetString(Strings.SqlMisc_InvalidArraySizeMessage); - - internal static readonly String InvalidPrecScaleMessage = StringsHelper.GetString(Strings.SqlMisc_InvalidPrecScaleMessage); - - internal static readonly String FormatMessage = StringsHelper.GetString(Strings.SqlMisc_FormatMessage); - - internal static readonly String NotFilledMessage = StringsHelper.GetString(Strings.SqlMisc_NotFilledMessage); - - internal static readonly String AlreadyFilledMessage = StringsHelper.GetString(Strings.SqlMisc_AlreadyFilledMessage); - - internal static readonly String ClosedXmlReaderMessage = StringsHelper.GetString(Strings.SqlMisc_ClosedXmlReaderMessage); - - internal static String InvalidOpStreamClosed(String method) - { - return StringsHelper.GetString(Strings.SqlMisc_InvalidOpStreamClosed, method); - } - - internal static String InvalidOpStreamNonWritable(String method) - { - return StringsHelper.GetString(Strings.SqlMisc_InvalidOpStreamNonWritable, method); - } - - internal static String InvalidOpStreamNonReadable(String method) - { - return StringsHelper.GetString(Strings.SqlMisc_InvalidOpStreamNonReadable, method); - } - - internal static String InvalidOpStreamNonSeekable(String method) - { - return StringsHelper.GetString(Strings.SqlMisc_InvalidOpStreamNonSeekable, method); - } - } // SqlResource - -} // namespace System diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVector.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVector.cs index cf04ff8636..61889fa61c 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVector.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVector.cs @@ -41,7 +41,7 @@ private SqlVector(int length) { if (length < 0) { - throw ADP.ArgumentOutOfRange(nameof(length), SQLResource.InvalidArraySizeMessage); + throw ADP.InvalidArraySize(nameof(length)); } (_elementType, _elementSize) = GetTypeFieldsOrThrow(); @@ -92,7 +92,7 @@ internal string GetString() { if (IsNull) { - return SQLResource.NullString; + return SQLMessage.NullString(); } return JsonSerializer.Serialize(Memory); } diff --git a/src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlTypes/SqlVectorTest.cs b/src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlTypes/SqlVectorTest.cs index 86c0f3ef6c..8768a7816f 100644 --- a/src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlTypes/SqlVectorTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlTypes/SqlVectorTest.cs @@ -39,7 +39,7 @@ public void Construct_Length() // to the same memory. We want to check memory content equality, so we // compare their arrays instead. Assert.Equal(new ReadOnlyMemory().ToArray(), vec.Memory.ToArray()); - Assert.Equal(SQLResource.NullString, vec.GetString()); + Assert.Equal(SQLMessage.NullString(), vec.GetString()); var ivec = vec as ISqlVector; Assert.Equal(0x00, ivec.ElementType); @@ -59,7 +59,7 @@ public void Construct_WithLengthZero() // to the same memory. We want to check memory content equality, so we // compare their arrays instead. Assert.Equal(new ReadOnlyMemory().ToArray(), vec.Memory.ToArray()); - Assert.Equal(SQLResource.NullString, vec.GetString()); + Assert.Equal(SQLMessage.NullString(), vec.GetString()); var ivec = vec as ISqlVector; Assert.Equal(0x00, ivec.ElementType);