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

Fix | Fix Assembly signing issue due to InternalsVisibleTo attribute #773

Merged
merged 2 commits into from Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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