Skip to content

Commit

Permalink
Fix | Fix Assembly signing issue due to InternalsVisibleTo attribute (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra committed Oct 23, 2020
1 parent d65173b commit 635f38b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Expand Up @@ -17,8 +17,6 @@
using System.Transactions;
using Microsoft.Data.Common;

[assembly: InternalsVisibleTo("FunctionalTests")]

namespace Microsoft.Data.SqlClient
{
internal static class AsyncHelper
Expand Down
Expand Up @@ -17,8 +17,6 @@
using System.Threading.Tasks;
using SysTx = System.Transactions;

[assembly: InternalsVisibleTo("FunctionalTests")]

namespace Microsoft.Data.SqlClient
{
using Microsoft.Data.Common;
Expand Down
Expand Up @@ -42,7 +42,6 @@
<Compile Include="SqlCredentialTest.cs" />
<Compile Include="SqlDataRecordTest.cs" />
<Compile Include="SqlExceptionTest.cs" />
<Compile Include="SqlHelperTest.cs" />
<Compile Include="SqlParameterTest.cs" />
<Compile Include="SqlClientFactoryTest.cs" />
<Compile Include="SqlErrorCollectionTest.cs" />
Expand All @@ -54,6 +53,7 @@
<Compile Include="SqlConnectionStringBuilderTest.cs" />
<Compile Include="SerializeSqlTypesTest.cs" />
<Compile Include="TestTdsServer.cs" />
<Compile Include="SqlHelperTest.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
Expand Down
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
Expand All @@ -13,8 +14,14 @@ public class SqlHelperTest
{
private void TimeOutATask()
{
var sqlClientAssembly = Assembly.GetAssembly(typeof(SqlCommand));
//We're using reflection to avoid exposing the internals
MethodInfo waitForCompletion = sqlClientAssembly.GetType("Microsoft.Data.SqlClient.AsyncHelper")
?.GetMethod("WaitForCompletion", BindingFlags.Static | BindingFlags.NonPublic);

Assert.False(waitForCompletion == null, "Running a test on SqlUtil.WaitForCompletion but could not find this method");
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
AsyncHelper.WaitForCompletion(tcs.Task, 1); //Will time out as task uncompleted
waitForCompletion.Invoke(null, new object[] { tcs.Task, 1, null, true }); //Will time out as task uncompleted
tcs.SetException(new TimeoutException("Dummy timeout exception")); //Our task now completes with an error
}

Expand Down

0 comments on commit 635f38b

Please sign in to comment.