Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Feature request: Expose original source text for TSqlFragment (Debugger & API usability)

Open
#203 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp
Domain
api, databases

Research direction

Start with the TSqlFragment API and its existing FirstTokenIndex, LastTokenIndex, ScriptTokenStream, StartOffset, and FragmentLength members. Review how fragments represent their source span and determine the expected exposed text behavior, including debugging and consumer usability. Done means a fragment can provide its original source text without each consumer rebuilding it manually, with corresponding coverage where the repository supports tests.

Written by the indexing model from the issue text.

Description

Problem

Working with Microsoft.SqlServer.TransactSql.ScriptDom is unnecessarily hard in practice,
especially during debugging.

TSqlFragment objects do not expose the original source text they represent.
Instead, consumers must manually reconstruct the SQL text via:

  • FirstTokenIndex / LastTokenIndex
  • ScriptTokenStream
  • or StartOffset / FragmentLength

This makes debugging extremely cumbersome:
in Visual Studio, inspecting a fragment does not show the SQL code,
only a large object graph with token indices.

This significantly affects developer productivity and discoverability of the AST.

Current workaround (non-trivial)

Every consumer needs to implement helper code such as:

    extension(TSqlFragment node)
    {
        public string SourcePart => string.Join("",
            node
                .ScriptTokenStream
                .Skip(node.FirstTokenIndex)
                .Take(node.LastTokenIndex - node.FirstTokenIndex + 1)
                .Select(i => i.Text)
                );
    }
Dominant language
GAP
Stars
277
Forks
43
Avg merge
6d 17h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/SqlScriptDOM

All issues in microsoft/SqlScriptDOM

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.