-
Notifications
You must be signed in to change notification settings - Fork 311
Port#3399 to release/5.2 #3407
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/5.2
Are you sure you want to change the base?
Port#3399 to release/5.2 #3407
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 ports the BOM-free UTF-8 fix (#3399) into both .NET Framework and .NET Core parsers, and adds a manual test to validate UTF-8 bulk copy behavior.
- Introduces
s_utf8EncodingWithoutBom
inTdsParser
for netfx and netcore and replaces allEncoding.UTF8
uses. - Adds
TestBulkCopyWithUTF8
manual test and includes it in the test project. - Introduces
DataTestUtility.CreateTable
helper for table setup in tests.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/.../SqlBulkCopyTest/TestBulkCopyWithUTF8.cs | New manual test for UTF-8 behavior |
src/.../ManualTesting.Tests.csproj | Included the new test in the project file |
src/.../DataCommon/DataTestUtility.cs | Added CreateTable helper |
src/.../netfx/src/.../TdsParser.cs | Introduced non-BOM UTF8 encoding and replaced uses |
src/.../netcore/src/.../TdsParser.cs | Introduced non-BOM UTF8 encoding and replaced uses |
Comments suppressed due to low confidence (4)
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/TestBulkCopyWithUTF8.cs:12
- [nitpick] Class name casing is inconsistent with the file name (
TestBulkCopyWithUTF8.cs
). Consider renaming toTestBulkCopyWithUTF8
for clarity and consistency.
public sealed class TestBulkCopyWithUtf8 : IDisposable
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/TestBulkCopyWithUTF8.cs:112
- xUnit does not provide
Assert.Fail
. To explicitly fail, useAssert.True(false, message)
or throw aXunitException
with the failure message.
Assert.Fail($"Bulk copy failed: {ex.Message}");
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/TestBulkCopyWithUTF8.cs:176
- xUnit does not provide
Assert.Fail
. To explicitly fail, useAssert.True(false, message)
or throw aXunitException
with the failure message.
Assert.Fail($"Bulk copy failed: {ex.Message}");
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs:593
- Building SQL with raw
tableName
concatenation can risk SQL injection or invalid identifiers. Consider wrappingtableName
inQUOTENAME
or otherwise quoting it safely.
public static void CreateTable(SqlConnection sqlConnection, string tableName, string createBody)
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
Show resolved
Hide resolved
949fda2
to
c808346
Compare
c808346
to
334a636
Compare
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.
CI build failures.
@@ -0,0 +1,196 @@ | |||
using System; |
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.
Missing license preamble.
DataTestUtility.CreateTable(connection, destinationTable, columnDefinition); | ||
using SqlCommand insertCommand = connection.CreateCommand(); | ||
insertCommand.CommandText = insertQuery; | ||
Helpers.TryExecute(insertCommand, insertQuery); |
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.
CI says Helpers
is not found for some builds.
Description
This is a port of #3399 for release/5.2
Issues
#3397
Testing
This port also contains the testcase to validate the fix.
Additional Notes
For local validation on 5.2,
Have net 6.0 installed. Build all targets (BuildAllConfigurations, buildtestsnetcore) with -p:TF=net60 so that ManualTesting.dll is correctly generated.