-
Notifications
You must be signed in to change notification settings - Fork 317
[6.0] Fix xevent and codeql (#3775)(#3819), add global.json #3827
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: release/6.0
Are you sure you want to change the base?
Conversation
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 backports fixes from the main branch (#3775, #3819) to the 6.0 branch, addressing XEvent test failures and adding CodeQL workflow support. The key change involves converting XEventScope from a ref struct to a class to maintain C# v9 compatibility (ref struct interfaces require C# v13).
- Adds comprehensive
XEventScopeutility class to manage XEvent sessions with automatic cleanup - Refactors test infrastructure to use instance methods with
ITestOutputHelperfor proper test name extraction - Implements a type-safe
ServerPropertyenum for querying SQL Server properties - Adds CodeQL security scanning workflow for the repository
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| XEventsTracingTest.cs | New test validating that client-side activity IDs are correctly passed to server-side XEvent sessions |
| DataStreamTest.cs | Converts test class from static to instance-based; refactors XEvent streaming test to use XEventScope utility; contains unresolved merge conflict |
| DataTestUtility.cs | Adds XEventScope helper class, CurrentTestName method, and ServerProperty enum; refactors GetSqlServerProperty for type safety |
| codeql.yml | New GitHub Actions workflow for CodeQL security scanning; configured for 'main' branch instead of '6.0' branch |
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs
Show resolved
Hide resolved
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 5 out of 5 changed files in this pull request and generated 16 comments.
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs
Show resolved
Hide resolved
| // Flush data | ||
| } | ||
|
|
||
| ids = TraceListener.ActivityIDs; |
Copilot
AI
Dec 4, 2025
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 property ActivityIDs does not exist on MDSEventListener or its base class BaseEventListener. The BaseEventListener class only has IDs (of type List<int>) and EventData properties. This code will fail to compile.
Either:
- Add an
ActivityIDsproperty toBaseEventListenerorMDSEventListener, or - Change this line to use the correct property name (likely
IDsif tracking event IDs)
| ids = TraceListener.ActivityIDs; | |
| ids = new HashSet<string>(TraceListener.IDs.ConvertAll(id => id.ToString())); |
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/TracingTests/XEventsTracingTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs
Show resolved
Hide resolved
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 7 out of 8 changed files in this pull request and generated 2 comments.
src/Microsoft.Data.SqlClient/tests/ManualTests/TracingTests/XEventsTracingTest.cs
Show resolved
Hide resolved
* Upgrade / align packages in test projects / * Reference System.ServiceProcess on netfx * Always include System.Transactions as well * Remove references to xunit.runner.console and xunit.runner.utility to enable discovery of netfx tests again. See dotnet/runtime#94183 * Revert nuget.org addition * Upgrade Versions Remove VersionsNet8OrLater, not needed anymore * Force build * Remove dummy * Add back console runners * Remove System.ServiceProcess, should not be needed * I think we do actually still need the net9 versions --------- Co-authored-by: Michel Zehnder <[email protected]>
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 10 out of 11 changed files in this pull request and generated 10 comments.
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/TracingTests/XEventsTracingTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/TracingTests/XEventsTracingTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs
Show resolved
Hide resolved
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 11 out of 12 changed files in this pull request and generated 2 comments.
src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/TracingTests/XEventsTracingTest.cs
Show resolved
Hide resolved
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 11 out of 12 changed files in this pull request and generated 1 comment.
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Show resolved
Hide resolved
| $version = "${{parameters.targetFramework }}".Substring(3, "${{parameters.targetFramework }}".Length-3) | ||
| } | ||
| # Install targetFramework specific .NET runtime (and sdk) |
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.
Like other test tasks, we want to test against specific runtime versions depending on the the target framework.
| .\dotnet-install.ps1 -Channel $version -Architecture x86 -InstallDir "$(dotnetx86RootPath)" | ||
| # Install globally required .NET sdk | ||
| .\dotnet-install.ps1 -Architecture x86 -InstallDir "$(dotnetx86RootPath)" -JSonFile global.json |
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.
This ensures that we have installed the SDK version required by the global.json file.
| </Compile> | ||
| <Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlMetadataFactory.cs"> | ||
| <Link>Microsoft\Data\SqlClient\SqlMetadataFactory.cs</Link> | ||
| <Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlMetaDataFactory.cs"> |
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.
Case change to support building on linux.
| run: | | ||
| mkdir packages | ||
| dotnet build src/ | ||
| dotnet build src/Microsoft.Data.SqlClient.sln |
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 think our solution file on this branch is old and doesn't play nicely with certain .NET versions, so it doesn't get recognized as the default target. Specifying the file explicitly helps dotnet determine what to build when there are multiple targets available.
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 because there is a .dcproj file in src/ too, so dotnet doesn't know which one you want to build.
| @@ -1,4 +1,4 @@ | |||
| <Project Sdk="Microsoft.Net.Sdk"> | |||
| <Project Sdk="Microsoft.NET.Sdk"> | |||
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.
Case change for linux
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </EmbeddedResource> | ||
| </ItemGroup> | ||
| <ItemGroup> |
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.
Following the lead of #3403
| <ErrorReport>None</ErrorReport> | ||
| <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
| <!-- This code analysis ruleset only exists with the .NET Framework toolset. --> | ||
| <CodeAnalysisRuleSet Condition="$(MSBuildRuntimeType) == 'Full'">MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> |
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.
Following the lead of #3754
| <Compile Include="Common\Microsoft\Data\Common\NameValuePermission.cs" /> | ||
| <Compile Include="Microsoft\Data\Common\DbConnectionOptions.cs" /> | ||
| <Compile Include="Microsoft\Data\Common\DbConnectionString.cs" /> | ||
| <Compile Include="Microsoft\Data\Common\DBConnectionString.cs" /> |
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.
Case change for linux
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.
Case change for linux
| <MicrosoftWin32RegistryVersion>5.0.0</MicrosoftWin32RegistryVersion> | ||
| <NewtonsoftJsonVersion>13.0.3</NewtonsoftJsonVersion> | ||
| <SystemDataOdbcVersion>8.0.1</SystemDataOdbcVersion> | ||
| <SystemFormatsAsn1Version>6.0.1</SystemFormatsAsn1Version> |
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.
Accidentally deleted this in the last commit.
| { | ||
| "sdk": { | ||
| "version": "9.0.0", | ||
| "version": "9.0.308", |
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.
Specifying a feature version allows this file to be used by the install-dotnet powershell script to install this version.
|
|
||
| #nullable enable | ||
|
|
||
| public sealed class XEventScope : IDisposable |
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.
Converted XEventScope to a class because ref struct types are only available starting in c# v13 and this branch uses v9.
b666719
Converted XEventScope to a class because ref struct types are only available starting in c# v13 and this branch uses v9.
Includes various fixes to enable compilation on linux.