Skip to content

Commit 635f38b

Browse files
Fix | Fix Assembly signing issue due to InternalsVisibleTo attribute (#773)
1 parent d65173b commit 635f38b

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlUtil.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
using System.Transactions;
1818
using Microsoft.Data.Common;
1919

20-
[assembly: InternalsVisibleTo("FunctionalTests")]
21-
2220
namespace Microsoft.Data.SqlClient
2321
{
2422
internal static class AsyncHelper

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlUtil.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
using System.Threading.Tasks;
1818
using SysTx = System.Transactions;
1919

20-
[assembly: InternalsVisibleTo("FunctionalTests")]
21-
2220
namespace Microsoft.Data.SqlClient
2321
{
2422
using Microsoft.Data.Common;

src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
<Compile Include="SqlCredentialTest.cs" />
4343
<Compile Include="SqlDataRecordTest.cs" />
4444
<Compile Include="SqlExceptionTest.cs" />
45-
<Compile Include="SqlHelperTest.cs" />
4645
<Compile Include="SqlParameterTest.cs" />
4746
<Compile Include="SqlClientFactoryTest.cs" />
4847
<Compile Include="SqlErrorCollectionTest.cs" />
@@ -54,6 +53,7 @@
5453
<Compile Include="SqlConnectionStringBuilderTest.cs" />
5554
<Compile Include="SerializeSqlTypesTest.cs" />
5655
<Compile Include="TestTdsServer.cs" />
56+
<Compile Include="SqlHelperTest.cs" />
5757
</ItemGroup>
5858
<ItemGroup>
5959
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />

src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlHelperTest.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using System.Reflection;
67
using System.Threading;
78
using System.Threading.Tasks;
89
using Xunit;
@@ -13,8 +14,14 @@ public class SqlHelperTest
1314
{
1415
private void TimeOutATask()
1516
{
17+
var sqlClientAssembly = Assembly.GetAssembly(typeof(SqlCommand));
18+
//We're using reflection to avoid exposing the internals
19+
MethodInfo waitForCompletion = sqlClientAssembly.GetType("Microsoft.Data.SqlClient.AsyncHelper")
20+
?.GetMethod("WaitForCompletion", BindingFlags.Static | BindingFlags.NonPublic);
21+
22+
Assert.False(waitForCompletion == null, "Running a test on SqlUtil.WaitForCompletion but could not find this method");
1623
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
17-
AsyncHelper.WaitForCompletion(tcs.Task, 1); //Will time out as task uncompleted
24+
waitForCompletion.Invoke(null, new object[] { tcs.Task, 1, null, true }); //Will time out as task uncompleted
1825
tcs.SetException(new TimeoutException("Dummy timeout exception")); //Our task now completes with an error
1926
}
2027

0 commit comments

Comments
 (0)