Skip to content

Normalize TDS UDT and XML metadata types - #4677

Open
benrr101 wants to merge 8 commits into
dev/russellben/tokens/tdstypeinfofrom
dev/russellben/tokens/tdsudttypeinfo
Open

benrr101 wants to merge 8 commits into
dev/russellben/tokens/tdstypeinfofrom
dev/russellben/tokens/tdsudttypeinfo

Conversation

@benrr101

Copy link
Copy Markdown
Contributor

Description

Applies the normalized TDS metadata model to user-defined type and XML schema metadata.

  • Renames SqlMetaDataUdt and SqlMetaDataXmlSchemaCollection to TdsUdtTypeInfo and TdsXmlTypeInfo.
  • Converts eligible fields to documented properties.
  • Replaces the bespoke CopyFrom pattern with conventional clone methods and copy constructors across UDT, XML, column, and general type metadata.
  • Updates parser, connection, reader, parameter, and column call sites.
  • Adds focused unit coverage for cloning the affected metadata types.

This is layer 3 of 3 in the TDS parser organization stack. It targets dev/russellben/tokens/tdstypeinfo, so review should focus on UDT/XML metadata and clone semantics.

Issues

No linked issue; this is an internal naming and maintainability refactor.

Testing

Adds focused unit tests for TdsTypeInfo, TdsUdtTypeInfo, and TdsXmlTypeInfo clone behavior. CI will run the complete dependent branch across the supported target frameworks.

Guidelines

Copilot AI balanced review requested due to automatic review settings September 10, 2026 23:54
@benrr101
benrr101 requested a review from a team as a code owner September 10, 2026 23:54
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Sep 10, 2026
@benrr101
benrr101 added this pull request to stack #4678 September 10, 2026 23:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 11, 2026 16:48
@benrr101
benrr101 force-pushed the dev/russellben/tokens/tdsudttypeinfo branch from 765cf97 to 1271ba3 Compare September 11, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The UDT Type annotation no longer preserves the trimming contract through property accessors.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 15/15 changed files
  • Comments generated: 6
  • Review effort level: Balanced

Comment on lines +15 to +20
var udtTypeInfo = new TdsXmlTypeInfo();

// Assert
Assert.Null(udtTypeInfo.Database);
Assert.Null(udtTypeInfo.Name);
Assert.Null(udtTypeInfo.OwningSchema);
Copilot AI review requested due to automatic review settings September 11, 2026 18:06
@benrr101
benrr101 force-pushed the dev/russellben/tokens/tdsudttypeinfo branch from 1271ba3 to b857e34 Compare September 11, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The UDT Type property loses its trimming data-flow contract, and the new tests omit required XML documentation.

Review details

Suppressed comments (5)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/TdsUdtTypeInfo.cs:45

  • Apply DynamicallyAccessedMembers to the property, not only its compiler-generated backing field. The getter currently exposes an unannotated Type, so calls such as SerializationHelperSql9.Deserialize lose the trimming contract and may emit linker warnings or allow required UDT members to be removed.
    [field: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsXmlTypeInfoTests.cs:9

  • The repository's testing guide requires behavior-focused XML summaries on every test class and every test method (.github/instructions/testing.instructions.md:176-192). Add summaries for this class and both [Fact] methods.
public class TdsXmlTypeInfoTests

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsUdtTypeInfoTests.cs:10

  • The repository's testing guide requires behavior-focused XML summaries on every test class and every test method (.github/instructions/testing.instructions.md:176-192). Add summaries for this class and all three [Fact] methods.
public class TdsUdtTypeInfoTests

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsTypeInfoTests.cs:11

  • The repository's testing guide requires behavior-focused XML summaries on every test class and every test method (.github/instructions/testing.instructions.md:176-192). Add summaries for this class and all three [Fact] methods.
public class TdsTypeInfoTests

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsXmlTypeInfoTests.cs:15

  • This variable holds XML type information, so the UDT-oriented name is misleading in this test.
        var udtTypeInfo = new TdsXmlTypeInfo();
  • Files reviewed: 15/15 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI review requested due to automatic review settings September 11, 2026 18:23
@benrr101
benrr101 force-pushed the dev/russellben/tokens/tdsudttypeinfo branch from b857e34 to 4212169 Compare September 11, 2026 18:23
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The trimming annotation and hidden clone method introduce correctness risks, while the new tests also violate repository documentation requirements.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (5)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/TdsUdtTypeInfo.cs:47

  • The [field:] target annotates only the generated backing field, so the generated property getter does not expose a Type carrying the required member guarantees. Call sites that pass Type to the UDT serializers can therefore trigger trimming diagnostics or lose the intended preservation. Apply the annotation to the property itself, preserving the semantics of the former annotated field.
    [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
    #endif
    internal Type Type { get; set; }

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsXmlTypeInfoTests.cs:9

  • This new test class and its [Fact] methods lack the required behavior-focused XML summaries. .github/instructions/testing.instructions.md:181-190 requires summaries at both class and test-method level; please document each declaration.
public class TdsXmlTypeInfoTests

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsUdtTypeInfoTests.cs:10

  • This new test class and its [Fact] methods lack the required behavior-focused XML summaries. .github/instructions/testing.instructions.md:181-190 requires summaries at both class and test-method level; please document each declaration.
public class TdsUdtTypeInfoTests

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsTypeInfoTests.cs:11

  • This new test class and its [Fact] methods lack the required behavior-focused XML summaries. .github/instructions/testing.instructions.md:181-190 requires summaries at both class and test-method level; please document each declaration.
public class TdsTypeInfoTests

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsXmlTypeInfoTests.cs:15

  • This XML metadata test names the subject udtTypeInfo, which makes the assertions appear to cover the wrong metadata kind. Rename it to xmlTypeInfo so the test's intent is unambiguous.
        var udtTypeInfo = new TdsXmlTypeInfo();
  • Files reviewed: 15/15 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment on lines +204 to +205
internal new TdsColumnMetadata Clone() =>
new TdsColumnMetadata(this);
var clone = original.Clone();

// Assert
Assert.Equal(original.AssemblyQualifiedName, clone.AssemblyQualifiedName);
var cloned = original.Clone();

// Assert
Assert.Equal(original.Database, cloned.Database);
Copilot AI review requested due to automatic review settings September 11, 2026 18:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The new tests violate the repository’s mandatory XML documentation convention, and one XML test uses misleading UDT terminology.

Review details

Suppressed comments (4)

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsXmlTypeInfoTests.cs:12

  • This new test class and its [Fact] methods omit the behavior-focused XML summaries required by .github/instructions/testing.instructions.md:181-192. Please document the class and each test method, including why the clone/default-value behavior matters.
public class TdsXmlTypeInfoTests
{
    [Fact]
    public void Constructor_InitializesPropertiesWithDefaultValues()

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsTypeInfoTests.cs:14

  • This new test class and its [Fact] methods omit the behavior-focused XML summaries required by .github/instructions/testing.instructions.md:181-192. Please document the class and each test method, including why each clone scenario matters.
public class TdsTypeInfoTests
{
    [Fact]
    public void Clone_CopiesAllUnclonedProperties()

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsXmlTypeInfoTests.cs:15

  • This variable contains TdsXmlTypeInfo, so the UDT-oriented name is misleading in an XML metadata test. Rename it to xmlTypeInfo to keep the test terminology aligned with the type under test.
        var udtTypeInfo = new TdsXmlTypeInfo();

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Parser/Tokens/TdsUdtTypeInfoTests.cs:13

  • This new test class and its [Fact] methods omit the behavior-focused XML summaries required by .github/instructions/testing.instructions.md:181-192. Please document the class and each test method, including why the clone/default-value behavior matters.
public class TdsUdtTypeInfoTests
{
    [Fact]
    public void Constructor_InitializesPropertiesWithDefaultValues()
  • Files reviewed: 15/15 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

2 participants