Skip to content
Open
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 @@ -21,13 +21,7 @@
<Compile Include="Microsoft.Data.SqlClient.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Transactions" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
<PropertyGroup Condition="$(Configuration.Contains('Debug'))">
<DefineConstants>$(DefineConstants);DEBUG;DBG;_DEBUG;_LOGGING;RESOURCE_ANNOTATION_WORK;</DefineConstants>
<DefineConstants>$(DefineConstants);DEBUG;DBG;_DEBUG;_LOGGING;</DefineConstants>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
</PropertyGroup>
Expand All @@ -83,15 +83,9 @@
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Transactions" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Transactions" />
</ItemGroup>

<!-- OS Constants ==================================================== -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using Microsoft.Data.Common;
using Microsoft.Win32.SafeHandles;
Expand Down Expand Up @@ -67,7 +66,6 @@ internal static extern bool DeviceIoControl(

#if NETFRAMEWORK
[DllImport(DllName, SetLastError = true, CharSet = CharSet.Unicode)]
[ResourceExposure(ResourceScope.Machine)]
internal static extern int GetFullPathName(
string path,
int numBufferChars,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;

namespace Interop.Windows.Kernel32
Expand All @@ -21,11 +20,9 @@ internal static class Kernel32Safe
private const string Kernel32 = "kernel32.dll";

[DllImport(Kernel32, CharSet = CharSet.Auto)]
[ResourceExposure(ResourceScope.Process)]
internal static extern int GetCurrentProcessId();

[DllImport(Kernel32, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true, SetLastError = true)]
[ResourceExposure(ResourceScope.None)]
internal static extern IntPtr GetProcAddress(IntPtr HModule, [MarshalAs(UnmanagedType.LPStr), In] string funcName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
using Microsoft.Data.SqlClient.Utilities;

#if NETFRAMEWORK
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using Interop.Windows;
#endif

Expand Down Expand Up @@ -66,8 +63,6 @@ internal static uint SniAddProvider(SNIHandle pConn, Provider provNum, ref AuthP
s_nativeMethods.SniAddProvider(pConn, provNum, ref pInfo);

#if NETFRAMEWORK
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
internal static uint SniAddProvider(SNIHandle pConn,
Provider providerEnum,
AuthProviderInfo authInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

namespace Interop.Windows.Sni
{
Expand All @@ -17,8 +16,6 @@ internal class SqlDependencyProcessDispatcherStorage
private static IntPtr s_data;
private static int s_size;

[ResourceExposure(ResourceScope.Process)] // SxS: there is no way to set scope = Instance, using Process which is wider
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
public static byte[] NativeGetData()
{
byte[] result = null;
Expand All @@ -31,8 +28,6 @@ public static byte[] NativeGetData()
return result;
}

[ResourceExposure(ResourceScope.Process)] // SxS: there is no way to set scope = Instance, using Process which is wider
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
internal static void NativeSetData(byte[] data)
{
lock (s_lockObj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#endif

#if _WINDOWS
using System.Runtime.Versioning;
using Microsoft.Win32;
#endif

Expand Down Expand Up @@ -438,8 +437,6 @@ internal static object LocalMachineRegistryValue(string subkey, string queryvalu
}
#endif
#if _WINDOWS
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
internal static object LocalMachineRegistryValue(string subkey, string queryvalue)
{
#if NETFRAMEWORK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using System.Text.RegularExpressions;

#if NETFRAMEWORK
using System.Runtime.Versioning;
using System.Security;
#endif

Expand Down Expand Up @@ -591,10 +590,6 @@ internal NameValuePair ReplacePasswordPwd(out string constr, bool fakePassword)
// * this method queries "DataDirectory" value from the current AppDomain.
// This string is used for to replace "!DataDirectory!" values in the connection string, it is not considered as an "exposed resource".
// * This method uses GetFullPath to validate that root path is valid, the result is not exposed out.
#if NETFRAMEWORK
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
#endif
internal static string ExpandDataDirectory(string keyword, string value)
{
string fullPath = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

using System;

#if NETFRAMEWORK
using System.Runtime.Versioning;
#endif

#if _WINDOWS
using System.Security.Principal;
#endif
Expand Down Expand Up @@ -59,10 +55,6 @@ public override int GetHashCode()
return _hashCode;
}

#if NETFRAMEWORK
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
[ResourceExposure(ResourceScope.None)] // SxS: this method does not create named objects
#endif
internal static DbConnectionPoolIdentity GetCurrent()
{
#if NETFRAMEWORK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using System.Transactions;
Expand Down Expand Up @@ -88,10 +87,6 @@ private sealed class PoolWaitHandles
private readonly WaitHandle[] _handlesWithCreate;
private readonly WaitHandle[] _handlesWithoutCreate;

#if NETFRAMEWORK
[ResourceExposure(ResourceScope.None)] // SxS: this method does not create named objects
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
#endif
internal PoolWaitHandles()
{
_poolSemaphore = new Semaphore(0, MAX_Q_SIZE);
Expand Down Expand Up @@ -934,8 +929,6 @@ public bool TryGetConnection(DbConnection owningObject, TaskCompletionSource<DbC

#if NETFRAMEWORK
[SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")] // copied from Triaged.cs
[ResourceExposure(ResourceScope.None)] // SxS: this method does not expose resources
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
#endif
private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObjectsTimeout, bool allowCreate, bool onlyOneCheckConnection, DbConnectionOptions userOptions, out DbConnectionInternal connection)
{
Expand Down Expand Up @@ -1225,10 +1218,6 @@ private DbConnectionInternal GetFromTransactedPool(out Transaction transaction)
return obj;
}

#if NETFRAMEWORK
[ResourceExposure(ResourceScope.None)] // SxS: this method does not expose resources
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
#endif
private void PoolCreateRequest(object state)
{
// called by pooler to ensure pool requests are currently being satisfied -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

using System.Diagnostics;
using System.Reflection;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using System.Security.Permissions;
#endif

Expand Down Expand Up @@ -456,13 +454,11 @@ private void EnablePerformanceCounters()
}
}

[PrePrepareMethod]
private void ExitOrUnloadEventHandler(object sender, EventArgs e)
{
RemovePerformanceCounters();
}

[PrePrepareMethod]
private void ExceptionEventHandler(object sender, UnhandledExceptionEventArgs e)
{
if (e != null && e.IsTerminating)
Expand Down Expand Up @@ -514,10 +510,6 @@ private void RemovePerformanceCounters()
}
}

// SxS: this method uses GetCurrentProcessId to construct the instance name.
// TODO: VSDD 534795 - remove the Resource* attributes if you do not use GetCurrentProcessId after the fix
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
private static string GetInstanceName()
{
string result;
Expand All @@ -528,7 +520,6 @@ private static string GetInstanceName()
instanceName = AppDomain.CurrentDomain?.FriendlyName;
}

// TODO: If you do not use GetCurrentProcessId after fixing VSDD 534795, please remove Resource* attributes from this method
int pid = Kernel32Safe.GetCurrentProcessId();

// SQLBUDT #366157 -there are several characters which have special meaning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Net;
using System.Net.NetworkInformation;
using System.Threading;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.Data.Common;
Expand Down Expand Up @@ -205,9 +204,6 @@ static SqlConnectionString()
#endif
}

// SxS: reading Software\\Microsoft\\MSSQLServer\\Client\\SuperSocketNetLib\Encrypt value from registry
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
internal SqlConnectionString(string connectionString): base(connectionString, s_keywordMap)
{
#if !NETFRAMEWORK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using System.IO;
using System.Runtime.Remoting;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security.Permissions;
using Interop.Windows.Sni;
using Microsoft.Data.SqlClient.LocalDb;
Expand Down Expand Up @@ -453,10 +452,6 @@ public void AddCommandDependency(SqlCommand command)
#if NETFRAMEWORK
// Method to obtain AppDomain reference and then obtain the reference to the process wide dispatcher for
// Start() and Stop() method calls on the individual SqlDependency instances.
// SxS: this method retrieves the primary AppDomain stored in native library. Since each System.Data.dll has its own copy of native
// library, this call is safe in SxS
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
private static void ObtainProcessDispatcher()
{
byte[] nativeStorage = SqlDependencyProcessDispatcherStorage.NativeGetData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#if NETFRAMEWORK
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Principal;
using Microsoft.Data.SqlClient.LocalDb;
#endif
Expand Down Expand Up @@ -648,12 +647,6 @@ private void ProcessNotificationResults(SqlDataReader reader)
}
}

#if NETFRAMEWORK
// SxS: this method uses WindowsIdentity.Impersonate to impersonate the current thread with the
// credentials used to create this SqlConnectionContainer.
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
#endif
private void Restart(object unused)
{
long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent("<sc.SqlConnectionContainer.Restart|DEP> {0}", ObjectID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;

#if NETFRAMEWORK
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
#endif

namespace Microsoft.Data.SqlClient
{
internal abstract class SqlInternalConnection : DbConnectionInternal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
using System.Transactions;
using Interop.Common.Sni;
using Microsoft.Data.Common;

#if NETFRAMEWORK
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Interop.Windows.Kernel32;
#else
#if NET
using System.Net.Sockets;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Microsoft.Data.Common;

namespace Microsoft.Data.SqlClient
Expand All @@ -18,9 +17,6 @@ private TdsParserStaticMethods() { /* prevent utility class from being insantiat
// Static methods
//

// SxS: this method accesses registry to resolve the alias.
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
static internal void AliasRegistryLookup(ref string host, ref string protocol)
{
if (!string.IsNullOrEmpty(host))
Expand Down Expand Up @@ -168,8 +164,6 @@ internal static int GetCurrentThreadIdForTdsLoginOnly()

private static byte[] s_nicAddress = null;

[ResourceExposure(ResourceScope.None)] // SxS: we use MAC address for TDS login only
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
static internal byte[] GetNetworkPhysicalAddressForTdsLoginOnly()
{
if (s_nicAddress != null)
Expand Down
Loading
Loading