Feature request: Expose original source text for TSqlFragment (Debugger & API usability)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
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 / LastTokenIndexScriptTokenStream- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/SqlScriptDOM
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
microsoft/SqlScriptDOM#228 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/SqlScriptDOM#183 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 56/100
microsoft/SqlScriptDOM#226 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
microsoft/SqlScriptDOM#225 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
microsoft/SqlScriptDOM#224 ·
All issues in microsoft/SqlScriptDOM
Similar issues
-
bug customer-eng Durable Agents Inngest status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
integration: elevenlabs
Difficulty 1/5 Under an hour Newbie friendliness 88/100
home-assistant/core#182944 · 1 comment ·
-
ai-observability bug team/ai-observability
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vicharanashala/fln#563 ·