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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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 @@ -396,12 +396,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();
edwardneal marked this conversation as resolved.
Show resolved Hide resolved
if (!netlib.ContainsKey(networkLibrary))
{
throw ADP.InvalidConnectionOptionValue(KEY.Network_Library);
}
_networkLibrary = (string)netlib[networkLibrary];
_networkLibrary = netlib[networkLibrary];
}
else
{
Expand Down Expand Up @@ -1101,14 +1101,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 },
Expand Down Expand Up @@ -1150,7 +1150,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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
edwardneal marked this conversation as resolved.
Show resolved Hide resolved
}
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
edwardneal marked this conversation as resolved.
Show resolved Hide resolved
using System.Diagnostics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
Expand Down Expand Up @@ -202,7 +203,7 @@ private X509Certificate2Collection GetSigningCertificate(string attestationUrl,

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