-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVSCode_Repository_Analysis.html
More file actions
109 lines (103 loc) · 5.18 KB
/
Copy pathVSCode_Repository_Analysis.html
File metadata and controls
109 lines (103 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Whole-Repository Analysis in VS Code</title>
<style>
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; color: #1f2937; background: #f7f9fb; line-height: 1.65; }
main { max-width: 960px; margin: 0 auto; padding: 44px 24px 64px; }
h1 { margin: 0 0 12px; font-size: 34px; letter-spacing: 0; }
h2 { margin: 34px 0 12px; font-size: 24px; letter-spacing: 0; }
p { margin: 0 0 12px; }
a { color: #156f6b; }
code, pre { font-family: Consolas, "Cascadia Mono", monospace; }
pre { overflow: auto; padding: 16px; border: 1px solid #d8e0ea; border-radius: 8px; background: #ffffff; }
table { width: 100%; border-collapse: collapse; background: #ffffff; }
th, td { padding: 11px 12px; border: 1px solid #d8e0ea; vertical-align: top; }
th { background: #edf5f4; text-align: left; }
.lead { color: #64748b; max-width: 820px; }
.note { padding: 14px 16px; border: 1px solid #d8e0ea; border-radius: 8px; background: #ffffff; }
.back { display: inline-block; margin-bottom: 20px; text-decoration: none; }
</style>
</head>
<body>
<main>
<a class="back" href="index.html">← Document index</a>
<h1>Whole-Repository Analysis in VS Code</h1>
<p class="lead">
How to get the VS Code C# language server to load the root unified solution
<code>SuperSocketLite2.slnx</code>. That solution registers 33 C# projects, including the library,
templates, tests, and tutorials.
</p>
<h2>1. Why this setting is needed</h2>
<p>
In standalone mode, the C# extension picks a default solution by searching for <code>.sln</code> files.
This repository's unified solution is the root's <code>.slnx</code>, and several subdirectories each
have their own <code>.sln</code> — so without pinning a default solution, the extension may not pick the
unified one automatically.
</p>
<p>
If you open a C# file with no solution selected, Roslyn analyzes it inside a throwaway
<code>Canonical.csproj</code>. That's fine for editing a single file, but it doesn't give you the
repository's project relationships or its full set of source files.
</p>
<h2>2. Configuring the workspace</h2>
<p>Create <code>.vscode/settings.json</code> at the repository root with this content.</p>
<pre><code>{
"dotnet.defaultSolution": "SuperSocketLite2.slnx"
}</code></pre>
<div class="note">
<code>.vscode/</code> is currently gitignored, so this setting has to be created locally on every
machine that uses the repository. To analyze just the core library instead of the whole repository, use
<code>SuperSocketLite/SuperSocketLite.sln</code> as the value instead.
</div>
<h2>3. Applying the setting</h2>
<ol>
<li>Open the repository root as a workspace in VS Code (e.g. <code>C:\github_dev\SuperSocketLite2</code>).</li>
<li>Make sure the workspace is trusted — in restricted mode, the C# extension runs in limited mode.</li>
<li>Run <code>Developer: Reload Window</code> from the command palette.</li>
<li>Wait for the solution and NuGet restore to finish, then try F12 again.</li>
</ol>
<h2>4. Confirming it loaded correctly</h2>
<p>Switch the output channel to <code>C#</code> under <code>View → Output</code> and check the load message.</p>
<table>
<thead>
<tr><th>Log state</th><th>Meaning</th></tr>
</thead>
<tbody>
<tr><td>Loads <code>SuperSocketLite2.slnx</code> and multiple projects</td><td>Correct — whole-repository analysis is active.</td></tr>
<tr><td>Only <code>Canonical.csproj</code> loads</td><td>The unified solution wasn't selected; only the files you've opened are being analyzed.</td></tr>
<tr><td><code>limited mode</code></td><td>Workspace trust wasn't granted.</td></tr>
</tbody>
</table>
<h2>5. When F12 only works for some symbols</h2>
<table>
<thead>
<tr><th>Symptom</th><th>Likely cause</th><th>How to check</th></tr>
</thead>
<tbody>
<tr>
<td>Go-to-definition works within the same file but not across files</td>
<td>The throwaway <code>Canonical.csproj</code> only knows about the files you've opened.</td>
<td>Check the C# output log to see whether the real unified solution actually loaded.</td>
</tr>
<tr>
<td><code>Task</code>, <code>Socket</code>, and similar work, but repository types fail</td>
<td>The .NET reference assemblies loaded, but the repository's own projects didn't.</td>
<td>Check <code>dotnet.defaultSolution</code> and whether you reloaded the window.</td>
</tr>
<tr>
<td>Go-to-definition only lands on an interface method's declaration</td>
<td>F12 returns the statically-typed definition.</td>
<td>Use VS Code's Go to Implementation to find the actual implementing candidates.</td>
</tr>
</tbody>
</table>
<h2>6. Verifying the solution's project list</h2>
<p>Run this in a terminal to see which projects the unified solution includes.</p>
<pre><code>dotnet sln SuperSocketLite2.slnx list</code></pre>
<p>The unified solution currently registers 33 C# projects.</p>
</main>
</body>
</html>