-
Notifications
You must be signed in to change notification settings - Fork 319
Common Project | Unit Tests #3870
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
base: main
Are you sure you want to change the base?
Conversation
…owever, many tests are failing due to runtime issues in common project MDS.
…oject, fix resource issues in unit test project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates the Unit Test project to reference the common (merged) Microsoft.Data.SqlClient project instead of the separate platform-specific projects (netfx/netcore). The changes introduce a temporary parallel Test Common project to avoid breaking existing Functional and Manual test projects during the migration.
Key Changes:
- Updated Unit Test project to reference the unified MDS project and resolve SNI dependencies via package references
- Added InternalsVisibleTo attribute and resource file configurations to the common MDS project
- Created a temporary Microsoft.Data.SqlClient.TestCommon project that references the unified MDS project
- Refactored test code to improve clarity and remove unnecessary try-catch blocks
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| build.proj | Removed redundant project references from UnitTests ItemGroup since the dependencies are now managed by the test project itself |
| src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj | Added InternalsVisibleTo for UnitTests assembly and configured embedded resource handling for Strings.resx files |
| src/Microsoft.Data.SqlClient/tests/Common/Microsoft.Data.SqlClient.TestCommon.csproj | New temporary test common project that references the unified MDS project with necessary test dependencies |
| src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj | Restructured to reference the unified MDS project, use SNI package references instead of copy targets, and separate dependencies by target framework |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionFailoverTests.cs | Improved test code clarity by extracting actions and removing unnecessary try-catch blocks |
| src/Microsoft.Data.SqlClient.sln | Added the new Microsoft.Data.SqlClient.TestCommon project to the solution with build configurations |
| <ItemGroup Condition="'$(TargetFramework)' == 'net462'"> | ||
| <Reference Include="System.Transactions" /> | ||
|
|
||
| <PackageReference Include="Microsoft.Data.SqlClient.SNI" /> | ||
| <PackageReference Include="Microsoft.DotNet.XUnitExtensions" /> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
| <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" | ||
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | ||
| PrivateAssets="all" /> | ||
| <PackageReference Include="Microsoft.SqlServer.Server" /> | ||
| <PackageReference Include="System.Configuration.ConfigurationManager" /> | ||
| <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" /> | ||
| <PackageReference Include="xunit" /> | ||
| <PackageReference Include="xunit.runner.console" | ||
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | ||
| PrivateAssets="all" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" | ||
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | ||
| PrivateAssets="all" /> | ||
|
|
||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS.Servers\TDS.Servers.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS.EndPoint\TDS.EndPoint.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS\TDS.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)Common\Common.csproj" /> | ||
| </ItemGroup> | ||
| <!-- .NET Framework references --> | ||
| <ItemGroup Condition="$(TargetGroup) == 'netfx'"> | ||
| <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" /> | ||
| <ProjectReference Include="$(NetFxSource)src\Microsoft.Data.SqlClient.csproj" /> | ||
| <Reference Include="System.Transactions" /> | ||
| <ProjectReference Include="$(TestsPath)Common\Microsoft.Data.SqlClient.TestCommon.csproj" /> | ||
| </ItemGroup> | ||
| <!-- .NET references --> | ||
| <ItemGroup Condition="'$(TargetGroup)'=='netcoreapp'"> | ||
| <ProjectReference Include="$(NetCoreSource)src\Microsoft.Data.SqlClient.csproj" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ContentWithTargetPath Condition="'$(TargetGroup)'=='netfx'" Include="$(BinFolder)$(Configuration).AnyCPU\Microsoft.Data.SqlClient\netfx\$(TargetFramework)\*SNI*.dll"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| <TargetPath>%(Filename)%(Extension)</TargetPath> | ||
| </ContentWithTargetPath> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ContentWithTargetPath Include="..\tools\Microsoft.Data.SqlClient.TestUtilities\xunit.runner.json"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| <TargetPath>xunit.runner.json</TargetPath> | ||
| </ContentWithTargetPath> | ||
| </ItemGroup> | ||
| <!-- Resources --> | ||
| <ItemGroup> | ||
| <Compile Update="Resources.Designer.cs"> | ||
| <DesignTime>True</DesignTime> | ||
| <AutoGen>True</AutoGen> | ||
| <DependentUpon>Resources.resx</DependentUpon> | ||
| </Compile> | ||
|
|
||
| <EmbeddedResource Update="Resources.resx"> | ||
| <Generator>ResXFileCodeGenerator</Generator> | ||
| <LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
| </EmbeddedResource> | ||
| <!-- References for netcore --> | ||
| <ItemGroup Condition="'$(TargetFramework)' != 'net462'"> | ||
| <PackageReference Include="Microsoft.Data.SqlClient.SNI.runtime" /> | ||
| <PackageReference Include="Microsoft.DotNet.XUnitExtensions" /> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
| <PackageReference Include="Microsoft.SqlServer.Server" /> | ||
| <PackageReference Include="System.Configuration.ConfigurationManager" /> | ||
| <PackageReference Include="xunit" /> | ||
| <PackageReference Include="xunit.runner.console" | ||
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | ||
| PrivateAssets="all" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" | ||
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | ||
| PrivateAssets="all" /> | ||
|
|
||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS.Servers\TDS.Servers.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS.EndPoint\TDS.EndPoint.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS\TDS.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)Common\Microsoft.Data.SqlClient.TestCommon.csproj" /> | ||
| </ItemGroup> |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package reference duplicates are being added across both conditional ItemGroups (netframework and netcore). Consider consolidating common package references (Microsoft.DotNet.XUnitExtensions, Microsoft.NET.Test.Sdk, Microsoft.SqlServer.Server, System.Configuration.ConfigurationManager, xunit, xunit.runner.console, xunit.runner.visualstudio) into a shared ItemGroup to reduce duplication and improve maintainability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"improve maintainability" is arguable, hence why I did it in the first place
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS.Servers\TDS.Servers.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS.EndPoint\TDS.EndPoint.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS\TDS.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)Common\Common.csproj" /> | ||
| </ItemGroup> | ||
| <!-- .NET Framework references --> | ||
| <ItemGroup Condition="$(TargetGroup) == 'netfx'"> | ||
| <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" /> | ||
| <ProjectReference Include="$(NetFxSource)src\Microsoft.Data.SqlClient.csproj" /> | ||
| <Reference Include="System.Transactions" /> | ||
| <ProjectReference Include="$(TestsPath)Common\Microsoft.Data.SqlClient.TestCommon.csproj" /> | ||
| </ItemGroup> | ||
| <!-- .NET references --> | ||
| <ItemGroup Condition="'$(TargetGroup)'=='netcoreapp'"> | ||
| <ProjectReference Include="$(NetCoreSource)src\Microsoft.Data.SqlClient.csproj" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ContentWithTargetPath Condition="'$(TargetGroup)'=='netfx'" Include="$(BinFolder)$(Configuration).AnyCPU\Microsoft.Data.SqlClient\netfx\$(TargetFramework)\*SNI*.dll"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| <TargetPath>%(Filename)%(Extension)</TargetPath> | ||
| </ContentWithTargetPath> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ContentWithTargetPath Include="..\tools\Microsoft.Data.SqlClient.TestUtilities\xunit.runner.json"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| <TargetPath>xunit.runner.json</TargetPath> | ||
| </ContentWithTargetPath> | ||
| </ItemGroup> | ||
| <!-- Resources --> | ||
| <ItemGroup> | ||
| <Compile Update="Resources.Designer.cs"> | ||
| <DesignTime>True</DesignTime> | ||
| <AutoGen>True</AutoGen> | ||
| <DependentUpon>Resources.resx</DependentUpon> | ||
| </Compile> | ||
|
|
||
| <EmbeddedResource Update="Resources.resx"> | ||
| <Generator>ResXFileCodeGenerator</Generator> | ||
| <LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
| </EmbeddedResource> | ||
| <!-- References for netcore --> | ||
| <ItemGroup Condition="'$(TargetFramework)' != 'net462'"> | ||
| <PackageReference Include="Microsoft.Data.SqlClient.SNI.runtime" /> | ||
| <PackageReference Include="Microsoft.DotNet.XUnitExtensions" /> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
| <PackageReference Include="Microsoft.SqlServer.Server" /> | ||
| <PackageReference Include="System.Configuration.ConfigurationManager" /> | ||
| <PackageReference Include="xunit" /> | ||
| <PackageReference Include="xunit.runner.console" | ||
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | ||
| PrivateAssets="all" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" | ||
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | ||
| PrivateAssets="all" /> | ||
|
|
||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS.Servers\TDS.Servers.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS.EndPoint\TDS.EndPoint.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS\TDS.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)Common\Microsoft.Data.SqlClient.TestCommon.csproj" /> |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TDS-related project references (TDS.Servers, TDS.EndPoint, TDS) are duplicated in both the net462 and netcore conditional ItemGroups. These common test dependencies should be moved to a shared ItemGroup to reduce duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these to props file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, at this point I want to reduce the usage of props files - they are difficult to discover and unless we have several projects using them, it's not beneficial to put things in a props file. The TDS projects are only being referenced by the unit test project, so moving those to a props file specifically isn't beneficial.
| <!-- References for netfx --> | ||
| <ItemGroup Condition="'$(TargetFramework)' == 'net462'"> | ||
| <PackageReference Include="Azure.Identity" /> | ||
| <PackageReference Include="Azure.Security.KeyVault.Keys" /> | ||
| <PackageReference Include="Microsoft.DotNet.XUnitExtensions" /> | ||
| <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" | ||
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | ||
| PrivateAssets="all" /> | ||
| <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" /> | ||
| <PackageReference Include="xunit" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- References for netcore --> | ||
| <ItemGroup Condition="'$(TargetFramework)' != 'net462'"> | ||
| <PackageReference Include="Azure.Identity" /> | ||
| <PackageReference Include="Azure.Security.KeyVault.Keys" /> | ||
| <PackageReference Include="Microsoft.DotNet.XUnitExtensions" /> | ||
| <PackageReference Include="xunit" /> | ||
| </ItemGroup> |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, the package references to Azure.Identity, Azure.Security.KeyVault.Keys, Microsoft.DotNet.XUnitExtensions, and xunit are duplicated in both conditional ItemGroups. Consider consolidating these common dependencies into a shared ItemGroup to improve maintainability.
| <!-- References for netfx --> | |
| <ItemGroup Condition="'$(TargetFramework)' == 'net462'"> | |
| <PackageReference Include="Azure.Identity" /> | |
| <PackageReference Include="Azure.Security.KeyVault.Keys" /> | |
| <PackageReference Include="Microsoft.DotNet.XUnitExtensions" /> | |
| <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" | |
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | |
| PrivateAssets="all" /> | |
| <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" /> | |
| <PackageReference Include="xunit" /> | |
| </ItemGroup> | |
| <!-- References for netcore --> | |
| <ItemGroup Condition="'$(TargetFramework)' != 'net462'"> | |
| <PackageReference Include="Azure.Identity" /> | |
| <PackageReference Include="Azure.Security.KeyVault.Keys" /> | |
| <PackageReference Include="Microsoft.DotNet.XUnitExtensions" /> | |
| <PackageReference Include="xunit" /> | |
| </ItemGroup> | |
| <!-- Common test package references --> | |
| <ItemGroup> | |
| <PackageReference Include="Azure.Identity" /> | |
| <PackageReference Include="Azure.Security.KeyVault.Keys" /> | |
| <PackageReference Include="Microsoft.DotNet.XUnitExtensions" /> | |
| <PackageReference Include="xunit" /> | |
| </ItemGroup> | |
| <!-- References for netfx --> | |
| <ItemGroup Condition="'$(TargetFramework)' == 'net462'"> | |
| <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" | |
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | |
| PrivateAssets="all" /> | |
| <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" /> | |
| </ItemGroup> |
| // Act | ||
| connection.Open(); | ||
|
|
||
|
|
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An extra blank line has been added here which is unnecessary. Consider removing it for cleaner code formatting.
| <!-- @TODO: Use full assembly name here --> | ||
| <AssemblyName>UnitTests</AssemblyName> |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TODO comment indicates that the AssemblyName should be changed to use the full assembly name (likely "Microsoft.Data.SqlClient.UnitTests") to match project naming conventions. This should be addressed before merging to ensure consistency with other projects in the solution.
| <!-- @TODO: Use full assembly name here --> | |
| <AssemblyName>UnitTests</AssemblyName> | |
| <AssemblyName>Microsoft.Data.SqlClient.UnitTests</AssemblyName> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TODO Is here for later. Not today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MsBuild system prefers props files more than empty shell projects to architect shared references, and common properties. Props files can be built with the same XML schema so your code wouldn't change much.
You can convert the TestCommon project into a .props file that every test project includes - and make sure it contains shared references, such that project files can stay lightweight and all dependencies/common properties can be pulled into the props file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not an empty shell project, it is the same as the existing Common project, just with a reference to the common MDS project. The files compiled files are included by default as is the norm in modern csproj files.
| <ItemGroup Condition="'$(TargetFramework)' == 'net462'"> | ||
| <Reference Include="System.Transactions" /> | ||
|
|
||
| <PackageReference Include="Microsoft.Data.SqlClient.SNI" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this reference only for Project Reference testing and only for .NET Framework targets, and not for package reference testing or .NET targets as it should flow as a transitive dependency in all other cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure you include the dependency version in Directory.Package.Props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the good news then is that the Unit Test only runs in project reference mode. And the SNI is already in Directory.Package.props because MDS takes a dependency on it.
| </EmbeddedResource> | ||
| <!-- References for netcore --> | ||
| <ItemGroup Condition="'$(TargetFramework)' != 'net462'"> | ||
| <PackageReference Include="Microsoft.Data.SqlClient.SNI.runtime" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not be referenced, allow transitive dependency to include automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't work, though. Does work when referenced.
| <PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
| <PackageReference Include="Microsoft.SqlServer.Server" /> | ||
| <PackageReference Include="System.Configuration.ConfigurationManager" /> | ||
| <PackageReference Include="xunit" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move all repetitive dependencies to the base props file (test common as of now), and include the props file directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described above, TestCommon is not an empty proj just being used for props.
| } | ||
|
|
||
| // Act | ||
| connection.Open(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the try-catch removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Open() throws, it will fail the test anyway. The xUnit diagnostics will look a bit different, but the file/line numbers will be evident.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert.Fail will only report whatever the message is, in this case a little message and the message property of the exception. Letting the uncaught exception will fail the test and emit the entire exception - message, stack trace, inner exceptions (if any). Not only that, but removing the try/catch cleans it up quite a bit.
Was this necessary for this PR? No, but this test was failing in my local testing for the branches, and to debug it better I removed the try/catch as per the reasons above. It's a small change, so I left it in this PR.
| <NetStandardDriver Include="**/netcore/ref/Microsoft.Data.SqlClient*.csproj" /> | ||
| <AKVProvider Include="**/add-ons/**/AzureKeyVaultProvider/*.csproj" /> | ||
|
|
||
| <UnitTests Include="**/Common/Common.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to include these so that the referenced projects are built and available for the proper target when we build the unit tests project. I'd be happy to get rid of them, but try building unit tests after cleaning the project to make sure everything still works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is something I'm working through right now in the failing build. I ignored the "--no-build" on the dotnet command and it tripped me up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <AssemblyName>Microsoft.Data.SqlClient.TestCommon</AssemblyName> | ||
| <RootNamespace>Microsoft.Data.SqlClient.TestCommon</RootNamespace> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Embedded resources and content files =========================== --> | ||
| <ItemGroup> | ||
| <ContentWithTargetPath Include="..\tools\Microsoft.Data.SqlClient.TestUtilities\xunit.runner.json"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| <TargetPath>xunit.runner.json</TargetPath> | ||
| </ContentWithTargetPath> | ||
| </ItemGroup> | ||
|
|
||
| <!-- References ====================================================== --> | ||
| <!-- Test target reference --> | ||
| <ItemGroup> | ||
| <ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- References for netfx --> | ||
| <ItemGroup Condition="'$(TargetFramework)' == 'net462'"> | ||
| <PackageReference Include="Azure.Identity" /> | ||
| <PackageReference Include="Azure.Security.KeyVault.Keys" /> | ||
| <PackageReference Include="Microsoft.DotNet.XUnitExtensions" /> | ||
| <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" | ||
| IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" | ||
| PrivateAssets="all" /> | ||
| <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" /> | ||
| <PackageReference Include="xunit" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- References for netcore --> | ||
| <ItemGroup Condition="'$(TargetFramework)' != 'net462'"> | ||
| <PackageReference Include="Azure.Identity" /> | ||
| <PackageReference Include="Azure.Security.KeyVault.Keys" /> | ||
| <PackageReference Include="Microsoft.DotNet.XUnitExtensions" /> | ||
| <PackageReference Include="xunit" /> | ||
| </ItemGroup> | ||
| </Project> |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new Microsoft.Data.SqlClient.TestCommon project doesn't include any compile files. Looking at the existing Common.csproj in the same directory, it contains files like DisposableArray.cs, LocalAppContextSwitchesHelper.cs, and SqlDataReaderExtensions.cs. These files should be included in the new TestCommon project either through explicit Compile elements or by ensuring EnableDefaultCompileItems is true (which is the default for SDK-style projects). Without including these source files, the TestCommon project will be empty and won't provide the shared test utilities that other test projects depend on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No they should not be included - by default all files in the folder are compiled, there's no need to manually include them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS.Servers\TDS.Servers.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS.EndPoint\TDS.EndPoint.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)tools\TDS\TDS\TDS.csproj" /> | ||
| <ProjectReference Include="$(TestsPath)Common\Common.csproj" /> | ||
| </ItemGroup> | ||
| <!-- .NET Framework references --> | ||
| <ItemGroup Condition="$(TargetGroup) == 'netfx'"> | ||
| <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" /> | ||
| <ProjectReference Include="$(NetFxSource)src\Microsoft.Data.SqlClient.csproj" /> | ||
| <Reference Include="System.Transactions" /> | ||
| <ProjectReference Include="$(TestsPath)Common\Microsoft.Data.SqlClient.TestCommon.csproj" /> |
Copilot
AI
Jan 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TDS project references (TDS.Servers, TDS.EndPoint, TDS) are duplicated in both the net462 and netcore conditional ItemGroups. These references should be moved to a common ItemGroup that applies to all target frameworks to avoid duplication and simplify maintenance.
| <ItemGroup Condition="'$(CDP_BUILD_TYPE)' != 'Official'"> | ||
| <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute"> | ||
| <_Parameter1>UnitTests</_Parameter1> | ||
| </AssemblyAttribute> | ||
| </ItemGroup> |
Copilot
AI
Jan 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The InternalsVisibleTo attribute is only added for non-official builds (when CDP_BUILD_TYPE != 'Official'). This means unit tests won't be able to access internal members in official builds, which could cause test failures in production build pipelines. Consider whether this restriction is intentional or if the tests should always have access to internals.
Description
This PR updates the Unit Test project to point at the common (merged) MDS project. There's some unconventional changes to make this work, though.
How does this impact our pipelines?
No changes were necessary to the CI/PR pipelines. The existing build.proj command for running the Unit Tests continues to work even after changing the MDS target. A small tweak was necessary to ensure that we weren't building unnecessary projects before running the tests, but that's no big issue, afaik. Pipelines should continue to Just Work™️
I considered making new targets in the build2.proj but decided to just get this out first. There's some cruft in the way we call the Unit Tests today, so leaving it as-is isn't making anything worse.
Issues
N/A
Testing
Locally the build.proj targets and running the unit tests inside the IDE still work.