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

Reduce AOT binary size #3091

Merged
merged 3 commits into from
Feb 20, 2025
Merged
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
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
@@ -396,12 +395,12 @@ internal SqlConnectionString(string connectionString) : base(connectionString, G
if (_networkLibrary != null)
{ // MDAC 83525
string networkLibrary = _networkLibrary.Trim().ToLower(CultureInfo.InvariantCulture);
Hashtable netlib = NetlibMapping();
Dictionary<string, string> netlib = NetlibMapping();
if (!netlib.ContainsKey(networkLibrary))
{
throw ADP.InvalidConnectionOptionValue(KEY.Network_Library);
}
_networkLibrary = (string)netlib[networkLibrary];
_networkLibrary = netlib[networkLibrary];
}
else
{
@@ -1101,14 +1100,14 @@ internal SqlConnectionEncryptOption ConvertValueToSqlConnectionEncrypt()
}
}

static internal Hashtable NetlibMapping()
static internal Dictionary<string, string> NetlibMapping()
{
const int NetLibCount = 8;

Hashtable hash = s_netlibMapping;
Dictionary<string, string> hash = s_netlibMapping;
if (hash == null)
{
hash = new Hashtable(NetLibCount)
hash = new Dictionary<string, string>(NetLibCount)
{
{ NETLIB.TCPIP, TdsEnums.TCP },
{ NETLIB.NamedPipes, TdsEnums.NP },
@@ -1150,7 +1149,7 @@ internal static class NETLIB
internal const string VIA = "dbmsgnet";
}

private static Hashtable s_netlibMapping;
private static Dictionary<string, string> s_netlibMapping;

#if NETFRAMEWORK
protected internal override PermissionSet CreatePermissionSet()
Original file line number Diff line number Diff line change
@@ -139,10 +139,14 @@ internal static int GetCurrentProcessIdForTdsLoginOnly()
// Pick up the process Id from the current process instead of randomly generating it.
// This would be helpful while tracing application related issues.
int processId;
#if NET
processId = Environment.ProcessId;
#else
using (System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess())
{
processId = p.Id;
}
#endif
System.Threading.Volatile.Write(ref s_currentProcessId, processId);
}
return s_currentProcessId;
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Runtime.Serialization.Json;
using System.Security.Cryptography.X509Certificates;
using System.Text.Json;
using System.Threading;

namespace Microsoft.Data.SqlClient
@@ -72,8 +72,7 @@ protected override byte[] MakeRequest(string url)

using (Stream stream = s_client.GetStreamAsync(url).ConfigureAwait(false).GetAwaiter().GetResult())
{
var deserializer = new DataContractJsonSerializer(typeof(byte[]));
return (byte[])deserializer.ReadObject(stream);
return JsonSerializer.Deserialize<List<byte>>(stream)?.ToArray();
}
}
catch (Exception e)
Original file line number Diff line number Diff line change
@@ -202,7 +202,7 @@ private X509Certificate2Collection GetSigningCertificate(string attestationUrl,

try
{
var s = new SignedCms();
SignedCms s = new SignedCms();
s.Decode(data);
certificateCollection.AddRange(s.Certificates);
}
Loading