Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Improve NativeAOT trimming for syntax-only KustoCode.Parse consumers

未关闭
#200 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
csharp, wasm

调研方向

Start with src/Kusto.Language/KustoCode.cs, especially Parse and the shared Create(..., bool analyze, ...) implementation described in the issue. Trace how Binder.TryBind enters the NativeAOT dependency graph for KustoCode.Parse(query).GetDiagnostics(), then compare it with ParseAndAnalyze and Analyze. Done means syntax-only parsing still covers the listed valid and malformed inputs without retaining semantic binding, while explicit semantic analysis continues to work.

由索引模型根据 Issue 内容生成。

描述

Scenario

kusto-cli is a NativeAOT command-line application using Microsoft.Azure.Kusto.Language 12.3.2 for syntax validation. Its validation path calls KustoCode.Parse(query).GetDiagnostics(); it does not call ParseAndAnalyze or Analyze. Semantic name/type validation is left to the server.

During our NativeAOT size investigation, we found that this syntax-only usage retains semantic binding code that the application does not execute.

Retaining path

In KustoCode.cs, Parse passes analyze: false to the shared Create(..., bool analyze, ...) implementation. That implementation also serves semantic-analysis callers and references Binder.TryBind behind if (analyze).

In our NativeAOT publish, the runtime Boolean does not prevent the compiler's dependency analysis from retaining that binding path. The same shared structure is still present at the upstream revision linked above.

Requested improvement

Please make syntax-only parsing and semantic analysis independently reachable for trimming purposes, so consumers that only parse and retrieve syntax diagnostics do not retain otherwise-unused semantic binding implementation.

Possible approaches include separating parsing from the explicitly requested binding operation, or providing a dedicated trim-friendly syntax-only API. The important property is that the syntax-only path does not retain binding through a shared runtime branch; another runtime Boolean alone would not address this.

Evidence and current workaround

Our PR applies a consumer-side ILC substitution that removes the body of Kusto.Language.Binding.Binder.TryBind. The published application's syntax-validation smoke tests continue to pass. This is not an appropriate long-term integration: it depends on an internal member signature and undocumented consumer-side substitution behavior. We would like to remove it in favor of upstream-supported trimming.

The Kusto binding substitution together with an unrelated Hex1b console-construction substitution reduced our Windows x64 executable from 20,682,240 to 19,831,808 bytes (850,432 bytes) using SDK 10.0.401 / runtime 10.0.12, Release. We did not isolate the Kusto-only contribution, so that combined number should not be attributed solely to this library.

Suggested acceptance coverage

  • Native-publish a small application that only calls KustoCode.Parse(...).GetDiagnostics(), without substitutions or suppression-based workarounds.
  • Confirm valid queries and management commands parse, malformed syntax produces diagnostics, and unknown table/column names do not trigger semantic validation.
  • Inspect NativeAOT dependency/size diagnostics to confirm the otherwise-unused semantic-binding path is eliminated.
  • Keep full semantic analysis working for consumers that explicitly use ParseAndAnalyze or Analyze.

Example inputs exercised by our PR include print 1, UnknownTable | where UnknownColumn > 0 | take 5, .show tables, and .show database ['Samples'] schema as json.

This request concerns unnecessary code retention/binary size, not a claim that the parsing API fails at runtime under NativeAOT.

主要语言
C#
星标
684
派生
122
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/Kusto-Query-Language 的其他 Issue

查看 microsoft/Kusto-Query-Language 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。