Skip to content

Commit 8c4e397

Browse files
committed
Refresh stale C# indexes for tuple fields (#4616)
1 parent dbf14b8 commit 8c4e397

4 files changed

Lines changed: 68 additions & 5 deletions

File tree

‎TESTING_GUIDE.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Use `docs/test-doc-maintenance-plan.md` before moving oversized suites or adding
190190
C# query-range collision forms for basic selection, directional ordering, keyword-named members, and object initializers share one indexed source when they assert the same empty inspect reference bundle.
191191
C# inspect brace-range regressions place char-literal, raw-string, and verbatim-string forms in one indexed class and query each following method from that shared fixture.
192192
C# generic query-range selectors share simple and tuple type arguments in one fixture, while generic type-pattern coverage shares designation and no-designation forms in another fixture.
193-
C# field-type grammar coverage shares static readonly tuple, nullable-tuple, generic-tuple-member, const/plain-field controls, and deconstruction negatives in one extractor fixture.
193+
C# field-type grammar coverage shares static readonly tuple, nullable-tuple, generic-tuple-member, const/plain-field controls, and deconstruction negatives in one extractor fixture. The full-scan regression also seeds the previous C# extractor contract against an unchanged file and verifies that incremental indexing restores the tuple field kind and complete return type.
194194
C# switch-expression pattern-variable coverage keeps recursive, declaration, guard, and comment-trivia forms in one extractor fixture when their contract is the set of genuine enum-member references.
195195
C# foreach-shadowing coverage shares embedded, same-line, and dangling-else forms in one source and distinguishes the surviving references by container.
196196
C# lambda-parameter shadowing coverage shares simple, multiline, after-lambda, and same-line boundary forms in one extraction pass.
@@ -889,7 +889,7 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests"
889889
C# query-range collision の basic selection、directional ordering、keyword 名 member、object initializer は、同じ空の inspect reference bundle を検証する場合は1つの indexed source を共有してください。
890890
C# inspect の brace-range regression は char literal、raw string、verbatim string を1つの indexed class に併置し、それぞれの後続 method を共有 fixture から query してください。
891891
C# generic query-range selector は単純型引数と tuple 型引数を1つの fixture で共有し、generic type-pattern coverage は designation 有無を別の1 fixture で共有してください。
892-
C# field 型文法 coverage は static readonly tuple、nullable tuple、generic 内 tuple member、const / 通常 field の control、deconstruction の負例を1つの extractor fixture で共有してください。
892+
C# field 型文法 coverage は static readonly tuple、nullable tuple、generic 内 tuple member、const / 通常 field の control、deconstruction の負例を1つの extractor fixture で共有してください。full-scan regression では未変更 file に以前の C# extractor contract を設定し、incremental index が tuple field の kind と完全な return type を復元することも検証してください。
893893
C# switch-expression pattern-variable coverage は、真の enum-member reference 集合を同じ contract とする recursive、declaration、guard、comment-trivia 形式を1つの extractor fixture で共有してください。
894894
C# foreach shadowing coverage は embedded、same-line、dangling-else 形式を1つの source で共有し、残る reference を container で区別してください。
895895
C# lambda parameter shadowing coverage は simple、multiline、after-lambda、same-line boundary 形式を1回の extraction pass で共有してください。

‎changelog.d/unreleased/4616.fixed.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ issues:
55
affected:
66
- src/CodeIndex/Indexer/Symbols/SymbolExtractor.cs
77
- tests/CodeIndex.Tests/SymbolExtractorCSharpTests.cs
8+
- tests/CodeIndex.Tests/IndexCommandRunnerFullScanTests.cs
89
---
910

1011
## English
1112

12-
- **C# static readonly tuple fields retain complete metadata (#4616)** — static readonly fields now use the shared C# type grammar, so tuple, nullable-tuple, and generic-tuple-member types remain `field` symbols with complete return-type metadata without treating deconstruction locals as fields.
13+
- **C# static readonly tuple fields retain complete metadata (#4616)** — static readonly fields now use the shared C# type grammar, so tuple, nullable-tuple, and generic-tuple-member types remain `field` symbols with complete return-type metadata without treating deconstruction locals as fields. The C# extractor contract was advanced so normal incremental indexing refreshes unchanged source files created by earlier versions.
1314

1415
## 日本語
1516

16-
- **C# の static readonly tuple field で完全なメタデータを保持するようになりました (#4616)** — static readonly field が共有 C# 型文法を使うようになり、tuple、nullable tuple、generic 内の tuple member 型を deconstruction local と誤認せず、完全な return-type metadata を持つ `field` symbol として維持します。
17+
- **C# の static readonly tuple field で完全なメタデータを保持するようになりました (#4616)** — static readonly field が共有 C# 型文法を使うようになり、tuple、nullable tuple、generic 内の tuple member 型を deconstruction local と誤認せず、完全な return-type metadata を持つ `field` symbol として維持します。C# extractor contract も更新したため、通常の incremental index で以前の version が作成した未変更 source file を再抽出します。

‎src/CodeIndex/Indexer/Symbols/SymbolExtractor.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static partial class SymbolExtractor
1515
{
1616
public const int DefaultContractVersion = 1;
1717
public const int ExpandedLanguageContractVersion = 2;
18-
public const int CSharpContractVersion = 3;
18+
public const int CSharpContractVersion = 4;
1919
public const int DockerfileContractVersion = 2;
2020
public const int MakefileContractVersion = 2;
2121
public const int StyleAndXamlContractVersion = 2;

‎tests/CodeIndex.Tests/IndexCommandRunnerFullScanTests.cs‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,68 @@ WHERE kind IN ('route', 'implements', 'attribute', 'layout')
20302030
}
20312031
}
20322032

2033+
[Fact]
2034+
public void Run_FullScan_ReindexesUnchangedCSharpTupleReadonlyFieldWhenExtractorVersionChanged_Issue4616()
2035+
{
2036+
var projectRoot = CreateTempProject();
2037+
try
2038+
{
2039+
File.WriteAllText(
2040+
Path.Combine(projectRoot, "tuple-fields.cs"),
2041+
"""
2042+
public class TupleFields
2043+
{
2044+
public static readonly (int Left, int Right) Pair = (1, 2);
2045+
}
2046+
""");
2047+
2048+
var initialExitCode = IndexCommandRunner.Run([projectRoot, "--json"], _jsonOptions);
2049+
Assert.Equal(CommandExitCodes.Success, initialExitCode);
2050+
2051+
var dbPath = Path.Combine(projectRoot, ".cdidx", "codeindex.db");
2052+
using (var conn = OpenNonPoolingConnection(dbPath))
2053+
{
2054+
conn.Open();
2055+
using var cmd = conn.CreateCommand();
2056+
cmd.CommandText = $"""
2057+
DELETE FROM symbols WHERE name = 'Pair';
2058+
UPDATE codeindex_meta
2059+
SET value = '3'
2060+
WHERE key = '{DbContext.GetSymbolExtractorVersionMetaKey("csharp")}';
2061+
""";
2062+
cmd.ExecuteNonQuery();
2063+
}
2064+
2065+
var (exitCode, json) = RunAndCaptureJson([projectRoot, "--json"]);
2066+
2067+
Assert.Equal(CommandExitCodes.Success, exitCode);
2068+
Assert.Equal("success", json.GetProperty("status").GetString());
2069+
Assert.Equal(0, json.GetProperty("summary").GetProperty("files_skipped").GetInt32());
2070+
2071+
using var verify = OpenNonPoolingConnection(dbPath);
2072+
verify.Open();
2073+
using var symbolCmd = verify.CreateCommand();
2074+
symbolCmd.CommandText = "SELECT kind, return_type FROM symbols WHERE name = 'Pair'";
2075+
using (var reader = symbolCmd.ExecuteReader())
2076+
{
2077+
Assert.True(reader.Read());
2078+
Assert.Equal("field", reader.GetString(0));
2079+
Assert.Equal("(int Left, int Right)", reader.GetString(1));
2080+
Assert.False(reader.Read());
2081+
}
2082+
2083+
using var versionCmd = verify.CreateCommand();
2084+
versionCmd.CommandText = $"SELECT value FROM codeindex_meta WHERE key = '{DbContext.GetSymbolExtractorVersionMetaKey("csharp")}'";
2085+
Assert.Equal(
2086+
SymbolExtractor.CSharpContractVersion.ToString(System.Globalization.CultureInfo.InvariantCulture),
2087+
versionCmd.ExecuteScalar() as string);
2088+
}
2089+
finally
2090+
{
2091+
DeleteDirectory(projectRoot);
2092+
}
2093+
}
2094+
20332095
[ProductionRuntimeFact]
20342096
public void Run_FullScan_DegradedWarningSummarizesRemainingFoldGap()
20352097
{

0 commit comments

Comments
 (0)