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 e1ddaa6926..bcf4e3b193 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj @@ -862,7 +862,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs index 3fac23d373..02eff9971d 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -2725,7 +2725,7 @@ internal byte[] GetBytes(object o) internal byte[] GetBytes(object o, out Format format, out int maxSize) { - SqlUdtInfo attr = AssemblyCache.GetInfoFromType(o.GetType()); + SqlUdtInfo attr = GetInfoFromType(o.GetType()); maxSize = attr.MaxByteSize; format = attr.SerializationFormat; @@ -2743,5 +2743,24 @@ internal byte[] GetBytes(object o, out Format format, out int maxSize) } return retval; } + + private SqlUdtInfo GetInfoFromType(Type t) + { + Debug.Assert(t != null, "Type object can't be NULL"); + Type orig = t; + do + { + SqlUdtInfo attr = SqlUdtInfo.TryGetFromType(t); + if (attr != null) + { + return attr; + } + + t = t.BaseType; + } + while (t != null); + + throw SQL.UDTInvalidSqlType(orig.AssemblyQualifiedName); + } } // SqlConnection } // Microsoft.Data.SqlClient namespace diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/assemblycache.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/assemblycache.cs deleted file mode 100644 index d8a877073a..0000000000 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/assemblycache.cs +++ /dev/null @@ -1,64 +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. - -//------------------------------------------------------------------------------ -//ThisAssembly class keeps a map of the following: -//AssemblyName to AssemblyID -//TypeName to TypeID -//AssemblyID to AssemblyRef and State -//TypeID to TypeRef and AssemblyId -// -//Adding an assembly to this class will NOT enable users to create types from that assembly. Users should explicitly add type details and link types to assemblies. -// This class also registers for assembly resolve events so that dependent assemblies can be resolved if they are registered. -//This class does NOT know anything about assembly dependencies. It simply loads assemblies as handed over to it. -//Users can take advantage of connection pooling by tying this instance to a pooling-aware component. -//------------------------------------------------------------------------------ - -using System; -using System.Diagnostics; -using Microsoft.Data.SqlClient.Server; - -namespace Microsoft.Data.SqlClient -{ - - internal sealed class AssemblyCache - { - private AssemblyCache() - { /* prevent utility class from being instantiated*/ - } - - internal static int GetLength(Object inst) - { - //caller should have allocated enough, based on MaxByteSize - return SerializationHelperSql9.SizeInBytes(inst); - } - - //The attribute we are looking for is now moved to an external dll that server provides. If the name is changed. - //then we we have to make corresponding changes here. - //please also change sqludcdatetime.cs, sqltime.cs and sqldate.cs - - internal static SqlUdtInfo GetInfoFromType(Type t) - { - Debug.Assert(t != null, "Type object cant be NULL"); - - Type orig = t; - do - { - SqlUdtInfo attr = SqlUdtInfo.TryGetFromType(t); - - if (attr != null) - { - return attr; - } - else - { - t = t.BaseType; - } - } - while (t != null); - - throw SQL.UDTInvalidSqlType(orig.AssemblyQualifiedName); - } - } -} diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs index 91530e5de6..f0a35b7653 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs @@ -1614,12 +1614,7 @@ internal int GetActualSize() case SqlDbType.Udt: if (!IsNull) { -#if NETFRAMEWORK - //call the static function - coercedSize = AssemblyCache.GetLength(val); -#else coercedSize = SerializationHelperSql9.SizeInBytes(val); -#endif } break; case SqlDbType.Structured: