Skip to content

Port #3399 to release/5.1 #3409

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

Open
wants to merge 1 commit into
base: release/5.1
Choose a base branch
from
Open

Conversation

apoorvdeshmukh
Copy link
Contributor

Description

Ports #3399 to release/5.1

Issues

#3397

Testing

Port contains the testcase to validate the fix

@Copilot Copilot AI review requested due to automatic review settings June 11, 2025 06:30
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Ports the UTF-8 bulk copy fix (#3399) to the 5.1 release branch and adds a manual test to verify UTF-8 behavior during SqlBulkCopy.

  • Introduces a s_utf8EncodingWithoutBom static field in TdsParser and replaces all Encoding.UTF8 usages for UTF-8 collations to prevent emitting a BOM.
  • Adds a new CreateTable helper in DataTestUtility and a manual test TestBulkCopyWithUTF8.cs to validate that UTF-8 data round-trips correctly.
  • Updates the manual tests project file to include the new test.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

File Description
src/*/SqlBulkCopyTest/TestBulkCopyWithUTF8.cs New manual test class for UTF-8 bulk copy
src/*/ManualTesting.Tests.csproj Includes the new test file in the test project
src/*/DataCommon/DataTestUtility.cs Adds CreateTable helper for manual tests
src/*/netfx/src/*/TdsParser.cs and netcore/src/*/TdsParser.cs Introduces s_utf8EncodingWithoutBom and updates encoding logic
Comments suppressed due to low confidence (3)

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/TestBulkCopyWithUTF8.cs:2

  • This using directive is unused in the test. Consider removing it to keep the imports clean.
using Microsoft.Extensions.Options;

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/TestBulkCopyWithUTF8.cs:13

  • [nitpick] The class name casing (Utf8) does not match the file name (UTF8). Rename either the file to TestBulkCopyWithUtf8.cs or the class to TestBulkCopyWithUTF8 for consistency.
public sealed class TestBulkCopyWithUtf8 : IDisposable

src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs:473

  • The new helper method CreateTable lacks XML documentation. Consider adding a <summary> and parameter descriptions to match the style of the existing utility methods.
public static void CreateTable(SqlConnection sqlConnection, string tableName, string createBody)

catch (Exception ex)
{
// If bulk copy fails, fail the test with the exception message
Assert.Fail($"Bulk copy failed: {ex.Message}");
Copy link
Preview

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xunit does not provide Assert.Fail. Replace with Assert.True(false, ...) or another Xunit-friendly assertion to fail the test with the exception message.

Suggested change
Assert.Fail($"Bulk copy failed: {ex.Message}");
Assert.True(false, $"Bulk copy failed: {ex.Message}");

Copilot uses AI. Check for mistakes.

catch (Exception ex)
{
// If bulk copy fails, fail the test with the exception message
Assert.Fail($"Bulk copy failed: {ex.Message}");
Copy link
Preview

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xunit does not provide Assert.Fail. Replace with Assert.True(false, ...) or another Xunit-friendly assertion to fail the test with the exception message.

Suggested change
Assert.Fail($"Bulk copy failed: {ex.Message}");
Assert.True(false, $"Bulk copy failed: {ex.Message}");

Copilot uses AI. Check for mistakes.

public static void CreateTable(SqlConnection sqlConnection, string tableName, string createBody)
{
DropTable(sqlConnection, tableName);
string tableCreate = "CREATE TABLE " + tableName + createBody;
Copy link
Preview

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] It may be clearer to interpolate or explicitly include a space before the column definition, e.g.: var tableCreate = $"CREATE TABLE {tableName} {createBody}".

Suggested change
string tableCreate = "CREATE TABLE " + tableName + createBody;
string tableCreate = $"CREATE TABLE {tableName} {createBody}";

Copilot uses AI. Check for mistakes.

Copy link

codecov bot commented Jun 11, 2025

Codecov Report

Attention: Patch coverage is 60.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 55.77%. Comparing base (6af24bc) to head (1ccd0fa).

Files with missing lines Patch % Lines
.../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs 60.00% 2 Missing ⚠️
...nt/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs 60.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (6af24bc) and HEAD (1ccd0fa). Click for more details.

HEAD has 9 uploads less than BASE
Flag BASE (6af24bc) HEAD (1ccd0fa)
netfx 4 1
netcore 4 1
addons 4 1
Additional details and impacted files
@@               Coverage Diff                @@
##           release/5.1    #3409       +/-   ##
================================================
- Coverage        71.78%   55.77%   -16.02%     
================================================
  Files              293      293               
  Lines            61647    61649        +2     
================================================
- Hits             44255    34385     -9870     
- Misses           17392    27264     +9872     
Flag Coverage Δ
addons 0.00% <ø> (-92.39%) ⬇️
netcore 58.98% <60.00%> (-16.90%) ⬇️
netfx 53.20% <60.00%> (-16.32%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants