Skip to content
Merged
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
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.Data;
using System;
using System.Runtime.InteropServices;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.Data;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.Net.Security;
using System.Runtime.InteropServices;
using Microsoft.Data;

namespace System.Net
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.Net.Security;
using System.Runtime.InteropServices;
using Microsoft.Data;

namespace System.Net
{
Expand Down Expand Up @@ -129,7 +130,7 @@ public unsafe int QueryContextAttributes(SafeDeleteContext phContext, Interop.Ss
}
else
{
throw new ArgumentException(System.StringsHelper.Format(Strings.SSPIInvalidHandleType, handleType.FullName), nameof(handleType));
throw new ArgumentException(StringsHelper.Format(Strings.SSPIInvalidHandleType, handleType.FullName), nameof(handleType));
}
}
fixed (byte* bufferPtr = buffer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Globalization;
using System.Net.Security;
using System.Runtime.InteropServices;
using Microsoft.Data;

namespace System.Net
{
Expand Down Expand Up @@ -101,7 +102,7 @@ public static SafeFreeCredentials AcquireDefaultCredential(SSPIInterface secModu
if (errorCode != 0)
{
if (NetEventSource.IsEnabled)
NetEventSource.Error(null, System.StringsHelper.Format(Strings.net_log_operation_failed_with_error, nameof(AcquireDefaultCredential), $"0x{errorCode:X}"));
NetEventSource.Error(null, StringsHelper.Format(Strings.net_log_operation_failed_with_error, nameof(AcquireDefaultCredential), $"0x{errorCode:X}"));
throw new Win32Exception(errorCode);
}
return outCredential;
Expand All @@ -118,7 +119,7 @@ public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface secModu
if (errorCode != 0)
{
if (NetEventSource.IsEnabled)
NetEventSource.Error(null, System.StringsHelper.Format(Strings.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}"));
NetEventSource.Error(null, StringsHelper.Format(Strings.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}"));
throw new Win32Exception(errorCode);
}

Expand All @@ -143,7 +144,7 @@ public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface secModu
if (errorCode != 0)
{
if (NetEventSource.IsEnabled)
NetEventSource.Error(null, System.StringsHelper.Format(Strings.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}"));
NetEventSource.Error(null, StringsHelper.Format(Strings.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}"));
throw new Win32Exception(errorCode);
}

Expand Down Expand Up @@ -359,11 +360,11 @@ private static unsafe int EncryptDecryptHelper(OP op, SSPIInterface secModule, S
{
if (errorCode == Interop.SspiCli.SEC_I_RENEGOTIATE)
{
NetEventSource.Error(null, System.StringsHelper.Format(Strings.event_OperationReturnedSomething, op, "SEC_I_RENEGOTIATE"));
NetEventSource.Error(null, StringsHelper.Format(Strings.event_OperationReturnedSomething, op, "SEC_I_RENEGOTIATE"));
}
else
{
NetEventSource.Error(null, System.StringsHelper.Format(Strings.net_log_operation_failed_with_error, op, $"0x{0:X}"));
NetEventSource.Error(null, StringsHelper.Format(Strings.net_log_operation_failed_with_error, op, $"0x{0:X}"));
}
}

Expand Down Expand Up @@ -466,7 +467,7 @@ public static object QueryContextAttributes(SSPIInterface secModule, SafeDeleteC
break;

default:
throw new ArgumentException(System.StringsHelper.Format(Strings.net_invalid_enum, nameof(contextAttribute)), nameof(contextAttribute));
throw new ArgumentException(StringsHelper.Format(Strings.net_invalid_enum, nameof(contextAttribute)), nameof(contextAttribute));
}

SafeHandle sspiHandle = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ internal static bool RemoveStringQuotes(string quotePrefix, string quoteSuffix,

internal static ArgumentOutOfRangeException NotSupportedEnumerationValue(Type type, string value, string method)
{
return ArgumentOutOfRange(System.StringsHelper.Format(Strings.ADP_NotSupportedEnumerationValue, type.Name, value, method), type.Name);
return ArgumentOutOfRange(StringsHelper.Format(Strings.ADP_NotSupportedEnumerationValue, type.Name, value, method), type.Name);
}

internal static InvalidOperationException DataAdapter(string error)
Expand All @@ -215,21 +215,21 @@ private static InvalidOperationException Provider(string error)

internal static ArgumentException InvalidMultipartName(string property, string value)
{
ArgumentException e = new ArgumentException(System.StringsHelper.Format(Strings.ADP_InvalidMultipartName, property, value));
ArgumentException e = new ArgumentException(StringsHelper.Format(Strings.ADP_InvalidMultipartName, property, value));
TraceExceptionAsReturnValue(e);
return e;
}

internal static ArgumentException InvalidMultipartNameIncorrectUsageOfQuotes(string property, string value)
{
ArgumentException e = new ArgumentException(System.StringsHelper.Format(Strings.ADP_InvalidMultipartNameQuoteUsage, property, value));
ArgumentException e = new ArgumentException(StringsHelper.Format(Strings.ADP_InvalidMultipartNameQuoteUsage, property, value));
TraceExceptionAsReturnValue(e);
return e;
}

internal static ArgumentException InvalidMultipartNameToManyParts(string property, string value, int limit)
{
ArgumentException e = new ArgumentException(System.StringsHelper.Format(Strings.ADP_InvalidMultipartNameToManyParts, property, value, limit));
ArgumentException e = new ArgumentException(StringsHelper.Format(Strings.ADP_InvalidMultipartNameToManyParts, property, value, limit));
TraceExceptionAsReturnValue(e);
return e;
}
Expand Down Expand Up @@ -286,23 +286,23 @@ internal static bool IsCatchableOrSecurityExceptionType(Exception e)
// Invalid Enumeration
internal static ArgumentOutOfRangeException InvalidEnumerationValue(Type type, int value)
{
return ArgumentOutOfRange(System.StringsHelper.Format(Strings.ADP_InvalidEnumerationValue, type.Name, value.ToString(CultureInfo.InvariantCulture)), type.Name);
return ArgumentOutOfRange(StringsHelper.Format(Strings.ADP_InvalidEnumerationValue, type.Name, value.ToString(CultureInfo.InvariantCulture)), type.Name);
}

//
// DbConnectionOptions, DataAccess
//
internal static ArgumentException ConnectionStringSyntax(int index)
{
return Argument(System.StringsHelper.Format(Strings.ADP_ConnectionStringSyntax, index));
return Argument(StringsHelper.Format(Strings.ADP_ConnectionStringSyntax, index));
}
internal static ArgumentException KeywordNotSupported(string keyword)
{
return Argument(System.StringsHelper.Format(Strings.ADP_KeywordNotSupported, keyword));
return Argument(StringsHelper.Format(Strings.ADP_KeywordNotSupported, keyword));
}
internal static ArgumentException ConvertFailed(Type fromType, Type toType, Exception innerException)
{
return ADP.Argument(System.StringsHelper.Format(Strings.SqlConvert_ConvertFailed, fromType.FullName, toType.FullName), innerException);
return ADP.Argument(StringsHelper.Format(Strings.SqlConvert_ConvertFailed, fromType.FullName, toType.FullName), innerException);
}

//
Expand All @@ -314,7 +314,7 @@ internal static Exception InvalidConnectionOptionValue(string key)
}
internal static Exception InvalidConnectionOptionValue(string key, Exception inner)
{
return Argument(System.StringsHelper.Format(Strings.ADP_InvalidConnectionOptionValue, key), inner);
return Argument(StringsHelper.Format(Strings.ADP_InvalidConnectionOptionValue, key), inner);
}
static internal InvalidOperationException InvalidDataDirectory()
{
Expand All @@ -327,23 +327,23 @@ static internal InvalidOperationException InvalidDataDirectory()
//
internal static ArgumentException CollectionRemoveInvalidObject(Type itemType, ICollection collection)
{
return Argument(System.StringsHelper.Format(Strings.ADP_CollectionRemoveInvalidObject, itemType.Name, collection.GetType().Name));
return Argument(StringsHelper.Format(Strings.ADP_CollectionRemoveInvalidObject, itemType.Name, collection.GetType().Name));
}
internal static ArgumentNullException CollectionNullValue(string parameter, Type collection, Type itemType)
{
return ArgumentNull(parameter, System.StringsHelper.Format(Strings.ADP_CollectionNullValue, collection.Name, itemType.Name));
return ArgumentNull(parameter, StringsHelper.Format(Strings.ADP_CollectionNullValue, collection.Name, itemType.Name));
}
internal static IndexOutOfRangeException CollectionIndexInt32(int index, Type collection, int count)
{
return IndexOutOfRange(System.StringsHelper.Format(Strings.ADP_CollectionIndexInt32, index.ToString(CultureInfo.InvariantCulture), collection.Name, count.ToString(CultureInfo.InvariantCulture)));
return IndexOutOfRange(StringsHelper.Format(Strings.ADP_CollectionIndexInt32, index.ToString(CultureInfo.InvariantCulture), collection.Name, count.ToString(CultureInfo.InvariantCulture)));
}
internal static IndexOutOfRangeException CollectionIndexString(Type itemType, string propertyName, string propertyValue, Type collection)
{
return IndexOutOfRange(System.StringsHelper.Format(Strings.ADP_CollectionIndexString, itemType.Name, propertyName, propertyValue, collection.Name));
return IndexOutOfRange(StringsHelper.Format(Strings.ADP_CollectionIndexString, itemType.Name, propertyName, propertyValue, collection.Name));
}
internal static InvalidCastException CollectionInvalidType(Type collection, Type itemType, object invalidValue)
{
return InvalidCast(System.StringsHelper.Format(Strings.ADP_CollectionInvalidType, collection.Name, itemType.Name, invalidValue.GetType().Name));
return InvalidCast(StringsHelper.Format(Strings.ADP_CollectionInvalidType, collection.Name, itemType.Name, invalidValue.GetType().Name));
}

//
Expand All @@ -365,7 +365,7 @@ private static string ConnectionStateMsg(ConnectionState state)
case (ConnectionState.Open | ConnectionState.Fetching):
return Strings.ADP_ConnectionStateMsg_OpenFetching;
default:
return System.StringsHelper.Format(Strings.ADP_ConnectionStateMsg, state.ToString());
return StringsHelper.Format(Strings.ADP_ConnectionStateMsg, state.ToString());
}
}

Expand All @@ -374,7 +374,7 @@ private static string ConnectionStateMsg(ConnectionState state)
//
internal static Exception StreamClosed([CallerMemberName] string method = "")
{
return InvalidOperation(System.StringsHelper.Format(Strings.ADP_StreamClosed, method));
return InvalidOperation(StringsHelper.Format(Strings.ADP_StreamClosed, method));
}

internal static string BuildQuotedString(string quotePrefix, string quoteSuffix, string unQuotedString)
Expand Down Expand Up @@ -433,11 +433,11 @@ static internal string BuildMultiPartName(string[] strings)
//
internal static ArgumentException ParametersIsNotParent(Type parameterType, ICollection collection)
{
return Argument(System.StringsHelper.Format(Strings.ADP_CollectionIsNotParent, parameterType.Name, collection.GetType().Name));
return Argument(StringsHelper.Format(Strings.ADP_CollectionIsNotParent, parameterType.Name, collection.GetType().Name));
}
internal static ArgumentException ParametersIsParent(Type parameterType, ICollection collection)
{
return Argument(System.StringsHelper.Format(Strings.ADP_CollectionIsNotParent, parameterType.Name, collection.GetType().Name));
return Argument(StringsHelper.Format(Strings.ADP_CollectionIsNotParent, parameterType.Name, collection.GetType().Name));
}


Expand Down Expand Up @@ -483,31 +483,31 @@ internal enum InternalErrorCode

internal static Exception InternalError(InternalErrorCode internalError)
{
return InvalidOperation(System.StringsHelper.Format(Strings.ADP_InternalProviderError, (int)internalError));
return InvalidOperation(StringsHelper.Format(Strings.ADP_InternalProviderError, (int)internalError));
}

//
// : DbDataReader
//
internal static Exception DataReaderClosed([CallerMemberName] string method = "")
{
return InvalidOperation(System.StringsHelper.Format(Strings.ADP_DataReaderClosed, method));
return InvalidOperation(StringsHelper.Format(Strings.ADP_DataReaderClosed, method));
}
internal static ArgumentOutOfRangeException InvalidSourceBufferIndex(int maxLen, long srcOffset, string parameterName)
{
return ArgumentOutOfRange(System.StringsHelper.Format(Strings.ADP_InvalidSourceBufferIndex, maxLen.ToString(CultureInfo.InvariantCulture), srcOffset.ToString(CultureInfo.InvariantCulture)), parameterName);
return ArgumentOutOfRange(StringsHelper.Format(Strings.ADP_InvalidSourceBufferIndex, maxLen.ToString(CultureInfo.InvariantCulture), srcOffset.ToString(CultureInfo.InvariantCulture)), parameterName);
}
internal static ArgumentOutOfRangeException InvalidDestinationBufferIndex(int maxLen, int dstOffset, string parameterName)
{
return ArgumentOutOfRange(System.StringsHelper.Format(Strings.ADP_InvalidDestinationBufferIndex, maxLen.ToString(CultureInfo.InvariantCulture), dstOffset.ToString(CultureInfo.InvariantCulture)), parameterName);
return ArgumentOutOfRange(StringsHelper.Format(Strings.ADP_InvalidDestinationBufferIndex, maxLen.ToString(CultureInfo.InvariantCulture), dstOffset.ToString(CultureInfo.InvariantCulture)), parameterName);
}
internal static IndexOutOfRangeException InvalidBufferSizeOrIndex(int numBytes, int bufferIndex)
{
return IndexOutOfRange(System.StringsHelper.Format(Strings.SQL_InvalidBufferSizeOrIndex, numBytes.ToString(CultureInfo.InvariantCulture), bufferIndex.ToString(CultureInfo.InvariantCulture)));
return IndexOutOfRange(StringsHelper.Format(Strings.SQL_InvalidBufferSizeOrIndex, numBytes.ToString(CultureInfo.InvariantCulture), bufferIndex.ToString(CultureInfo.InvariantCulture)));
}
internal static Exception InvalidDataLength(long length)
{
return IndexOutOfRange(System.StringsHelper.Format(Strings.SQL_InvalidDataLength, length.ToString(CultureInfo.InvariantCulture)));
return IndexOutOfRange(StringsHelper.Format(Strings.SQL_InvalidDataLength, length.ToString(CultureInfo.InvariantCulture)));
}

internal static bool CompareInsensitiveInvariant(string strvalue, string strconst) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ internal static class SQLResource

internal static string InvalidOpStreamClosed(string method)
{
return System.StringsHelper.Format(Strings.SqlMisc_InvalidOpStreamClosed, method);
return StringsHelper.Format(Strings.SqlMisc_InvalidOpStreamClosed, method);
}

internal static string InvalidOpStreamNonWritable(string method)
{
return System.StringsHelper.Format(Strings.SqlMisc_InvalidOpStreamNonWritable, method);
return StringsHelper.Format(Strings.SqlMisc_InvalidOpStreamNonWritable, method);
}

internal static string InvalidOpStreamNonReadable(string method)
{
return System.StringsHelper.Format(Strings.SqlMisc_InvalidOpStreamNonReadable, method);
return StringsHelper.Format(Strings.SqlMisc_InvalidOpStreamNonReadable, method);
}

internal static string InvalidOpStreamNonSeekable(string method)
{
return System.StringsHelper.Format(Strings.SqlMisc_InvalidOpStreamNonSeekable, method);
return StringsHelper.Format(Strings.SqlMisc_InvalidOpStreamNonSeekable, method);
}
} // SqlResource
} // namespace System
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.Globalization;
using System.ComponentModel;
using Microsoft.Data;

namespace System.Net.Security
{
Expand Down Expand Up @@ -40,7 +41,7 @@ internal static unsafe SafeFreeCredentials AcquireCredentialsHandle(string packa
if (result != Interop.SECURITY_STATUS.OK)
{
if (NetEventSource.IsEnabled)
NetEventSource.Error(null, System.StringsHelper.Format(Strings.net_log_operation_failed_with_error, nameof(Interop.SspiCli.SspiEncodeStringsAsAuthIdentity), $"0x{(int)result:X}"));
NetEventSource.Error(null, StringsHelper.Format(Strings.net_log_operation_failed_with_error, nameof(Interop.SspiCli.SspiEncodeStringsAsAuthIdentity), $"0x{(int)result:X}"));
throw new Win32Exception((int)result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@
<Compile Include="..\..\src\Resources\ResDescriptionAttribute.cs">
<Link>Resources\ResDescriptionAttribute.cs</Link>
</Compile>
<Compile Include="..\..\src\Resources\StringsHelper.cs">
<Link>Resources\StringsHelper.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard' OR '$(TargetGroup)' == 'netcoreapp' OR '$(IsUAPAssembly)' == 'true'">
<Compile Include="Microsoft.Data.SqlClient.TypeForwards.cs" />
Expand Down Expand Up @@ -402,7 +405,9 @@
<Compile Include="Microsoft\Data\SqlClient\SimulatorEnclaveProvider.NetCoreApp.cs" />
</ItemGroup>
<ItemGroup Condition="'$(OSGroup)' != 'AnyOS'">
<Compile Include="Resources\StringsHelper.cs" />
<Compile Include="Resources\StringsHelper.cs">
<Link>Resources\StringsHelper.NetCore.cs</Link>
</Compile>
<Compile Include="Resources\Strings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand Down
Loading