Skip to content

Commit 632256c

Browse files
committed
Add original source resolution and result modes
1 parent 4669b02 commit 632256c

23 files changed

Lines changed: 1232 additions & 67 deletions

DecompilerServer.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<TargetFramework>net10.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<Version>1.0.0</Version>
89
</PropertyGroup>
910

1011
<ItemGroup>
@@ -14,6 +15,7 @@
1415
</ItemGroup>
1516

1617
<ItemGroup>
18+
<Compile Remove="EmbeddedSourceTestLibrary/**" />
1719
<Compile Remove="Tests/**" />
1820
<Compile Remove="TestLibrary/**" />
1921
</ItemGroup>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace EmbeddedSourceTestLibrary;
2+
3+
public class EmbeddedSourceSample
4+
{
5+
// Embedded source marker comment
6+
public string GetValue()
7+
{
8+
const string marker = "EMBEDDED-SOURCE-MARKER";
9+
return marker;
10+
}
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<AssemblyName>embedded-source-test</AssemblyName>
8+
<DebugType>embedded</DebugType>
9+
<EmbedAllSources>true</EmbedAllSources>
10+
</PropertyGroup>
11+
12+
</Project>

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ Most MCP clients expose these tools in `snake_case` even though the underlying C
9191
```text
9292
search_types({
9393
"query": "Player",
94-
"limit": 10
94+
"limit": 10,
95+
"mode": "discovery"
9596
})
9697
```
9798

@@ -141,7 +142,8 @@ load_assembly({
141142
142143
search_types({
143144
"query": "Simple",
144-
"limit": 10
145+
"limit": 10,
146+
"mode": "discovery"
145147
})
146148
147149
get_member_details({
@@ -160,7 +162,8 @@ load_assembly({
160162
search_members({
161163
"query": "Player",
162164
"kind": "method",
163-
"limit": 10
165+
"limit": 10,
166+
"mode": "signatures"
164167
})
165168
166169
generate_harmony_patch_skeleton({
@@ -188,6 +191,21 @@ find_usages({
188191
})
189192
```
190193

194+
### Result modes for high-churn discovery tools
195+
196+
`search_types`, `search_members`, and `get_members_of_type` support output modes so callers can trade detail for context size:
197+
198+
- `ids`: minimal chaining payload (`memberId`, `name`, `kind`)
199+
- `discovery`: candidate selection payload for follow-up inspection
200+
- `signatures`: callable/member surface focused payload
201+
- `full`: legacy rich summary payload
202+
203+
Defaults are tuned for common workflows:
204+
205+
- `search_types`: `discovery`
206+
- `search_members`: `discovery`
207+
- `get_members_of_type`: `signatures`
208+
191209
## 🔧 Development
192210

193211
### Building

Services/AssemblyContextManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class AssemblyContextManager : IDisposable
2323
private CSharpDecompiler? _decompiler;
2424
private UniversalAssemblyResolver? _resolver;
2525
private bool _disposed;
26+
private long _contextVersion;
2627
private readonly ReaderWriterLockSlim _lock = new();
2728

2829
// Lazy indexes - built on-demand and cached
@@ -48,6 +49,7 @@ private void InitializeLazyIndexes()
4849
public string? AssemblyPath { get; private set; }
4950
public string? Mvid { get; private set; }
5051
public DateTime? LoadedAtUtc { get; private set; }
52+
public long ContextVersion => Interlocked.Read(ref _contextVersion);
5153

5254
// Basic statistics with enhanced caching awareness
5355
public int TypeCount => _compilation?.MainModule.TypeDefinitions.Count() ?? 0;
@@ -315,6 +317,7 @@ public void UpdateSettings(DecompilerSettings settings)
315317
{
316318
if (!IsLoaded) return;
317319
_decompiler = new CSharpDecompiler(_peFile!, _resolver!, settings);
320+
Interlocked.Increment(ref _contextVersion);
318321
}
319322
finally
320323
{
@@ -511,6 +514,7 @@ private static PEFile CreatePEFile(string assemblyPath)
511514

512515
private void DisposeContext()
513516
{
517+
Interlocked.Increment(ref _contextVersion);
514518
_decompiler = null;
515519
_compilation = null;
516520
_peFile?.Dispose();

0 commit comments

Comments
 (0)