Skip to content

Generate code from SqlMetaData.xml #3372

Open

Description

@paulmedynski

Today we are reading in the SqlMetaData.xml file and parsing it into data structures at runtime. See if we can do that work at compile time and generate some static code or data structures instead to avoid runtime overhead and possible errors.

Activity

  1. added
    Up-for-Grabs 🙌
    Performance 📈
    on May 22, 2025
  2. edwardneal commented on May 22, 2025

    @edwardneal
    Contributor

    It might also be useful to account for where SqlClient stores its records of various types. At present, we've got a number of sources:

    Having a single place to add new types and to "hydrate" them with a precision/length where necessary would be convenient. In the long term, it might also help to lift some of the parsing logic out of TdsParser (although hopefully SqlClientX will pre-empt that.)

  3. moved this from To triage to Backlog in SqlClient Boardon Nov 21, 2025
  4. tetolv commented on Jun 2, 2026

    @tetolv
    Contributor

    Hello,
    I would like to try tackling this task using source generators, but while studying metadata handling in SqlClient I'm wondering why it is being kept in .xml file in the first place, instead of being hardcoded in C#?

  5. edwardneal commented on Jun 2, 2026

    @edwardneal
    Contributor

    It's largely historical. This is used to support output for DbConnection.GetSchema, and in .NET Framework System.Data.SqlClient made heavy use of shared underlying ADO.NET components. In this situation, it made sense for multiple ADO.NET providers to share an implementation which returned a DataTable, to have that implementation clone a "reference DataSet" and to load that reference DataSet from an embedded resource.

    When the library was split out into Microsoft.Data.SqlClient, the relevant shared ADO.NET components were split with it. Since then, we've had some movement:

    There's one piece of intersecting work to add the json and the vector types to the DataTypes table and fix bug #3833, but this depends upon #3862.

    It's a fairly self-contained part of the codebase to start work in, but will often lead to very large PRs! There are three tables left untouched by PRs at the moment: MetaDataCollections, Restrictions and DataSourceInformation.

  6. tetolv commented on Jun 3, 2026

    @tetolv
    Contributor

    @edwardneal Thanks for info,
    but would you still suggest to try to parse SqlMetaData.xml at compile time, or to bring remaining metadata tables : MetaDataCollections, Restrictions and DataSourceInformation inside? I have noticed, that your work on ReservedWords and DataTypes is rather recent, so wouldn't my work interfere with yours?

  7. edwardneal commented on Jun 3, 2026

    @edwardneal
    Contributor

    No problem. Unless the SqlClient team wants to use a source generator instead, I'd suggest maintaining the same approach as we currently use.

    I think our work would only overlap when it touches ReservedWords, and that's a fairly recent, unmerged, PR. With that said, if there's an issue avoiding that specific table and your PR ends up landing first then I've not got a problem rebasing or closing mine.

  8. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  9. github-actions commented on Sep 17, 2026

    @github-actions

    🔍 Triage Summary (on-demand re-triage)

    Check Result
    Issue type Task
    Environment Not applicable (engineering/refactoring task, not a bug report)
    Area Area\Engineering
    Duplicates None found as a duplicate; related/overlapping in-progress work: #3369, #3818, #3858, #4328 (partial migrations of individual SqlMetaData.xml-backed tables to code)
    Regression Not applicable

    Analysis

    This is a long-standing engineering task to move SqlMetaData.xml (and related runtime-parsed metadata used by SqlConnection.GetSchema) from an embedded XML resource parsed at runtime into compile-time-generated code/data, reducing runtime overhead, trimming friction, and parsing errors. Per the issue discussion, several of the constituent tables (DataTypes, ReservedWords) have already been converted incrementally in separate PRs, and three tables remain untouched (MetaDataCollections, Restrictions, DataSourceInformation). This is a Area\Engineering / performance-adjacent task, low severity (P3) since it's non-functional/internal refactoring with no user-facing bug, but valuable for maintainability and startup performance.

    Next Steps

    • Coordinate with @edwardneal and @tetolv (active contributors in the thread) to avoid duplicate effort on the remaining tables (MetaDataCollections, Restrictions, DataSourceInformation).
    • Confirm whether a source generator approach (raised by @tetolv) is preferred over continuing the current manual "port table to code" pattern used in Fix | Build DataTypes table in code, add json data type #3858/Fix | Build ReservedWords table in code #4328, since this affects how new contributions should be structured.
    • Given the issue is already labeled Up-for-Grabs, this is best handled by a community contributor or, if unassigned for a while, could be assigned to Copilot coding agent to draft the conversion for one of the three remaining tables (starting with DataSourceInformation, the smallest) following the pattern established in Fix | Build DataTypes table in code, add json data type #3858.

    Note: This triage summary is auto-generated by an AI agent. The analysis and suggestions above have not been verified by a human maintainer. Please treat as preliminary guidance only.

    Generated by SqlClient Issue Auto-Triage for #3372 · copilot · auto · 26.5 AIC · ⌖ 14 AIC · ⊞ 13.5K · ◷

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Performance 📈Up-for-Grabs 🙌

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions