Skip to content

Commit fdc4c07

Browse files
author
Steve Salas
committed
Squashed 'dotnet-symbol-service/' changes from 3db2eb5..9e78cc4
9e78cc4 Switch target framework to netcoreapp3.1 c8c7a71 Update library to version GitHub recommends febf7fd Update to include method end line as tree node data and change ASD match 218ac4f Pull changes from dotnet-symbol-service a7fa6d7 Initial scroll-to-method capability for source viewer a41e345 Adds % of traced source locations to source viewer be09cf6 Store source location count for Java and .NET 07c3fa1 Handles methods having no sequence points 8318a74 Add source file info to Symbol Service git-subtree-dir: dotnet-symbol-service git-subtree-split: 9e78cc4e45eb280a51e392ef3395e5c90320f1a3
1 parent f25af34 commit fdc4c07

File tree

7 files changed

+73
-39
lines changed

7 files changed

+73
-39
lines changed

SymbolService/Controllers/MethodsController.cs

+35-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
namespace SymbolService.Controllers
2929
{
30+
[ApiController]
3031
[Produces("application/json")]
3132
[Route("api/Methods")]
3233
public class MethodsController : Controller
@@ -157,15 +158,22 @@ private IEnumerable<MethodDefinition> GetMethodDefinitions(TypeDefinition typeDe
157158

158159
private MethodInfo GetMethodInfo(MethodDefinition method)
159160
{
160-
return new MethodInfo
161+
var sequencePoints = method.DebugInformation.HasSequencePoints ? method.DebugInformation.SequencePoints : null;
162+
var visibleSequencePoints = sequencePoints?.Count(x => !x.IsHidden) ?? 0;
163+
164+
return new MethodInfo
161165
{
162166
FullyQualifiedName = method.Name,
163167
ContainingClass = method.DeclaringType?.FullName,
168+
File = sequencePoints?.First().Document.Url,
164169
AccessModifiers = GetAccessModifiers(method),
165170
Parameters = GetParameters(method),
166171
ReturnType = method.ReturnType.FullName,
167-
Instructions = method.Body?.Instructions?.Count ?? 0
168-
};
172+
Instructions = method.Body?.Instructions?.Count ?? 0,
173+
SequencePointCount = visibleSequencePoints,
174+
MethodStartLine = GetMethodStartLine(method),
175+
MethodEndLine = GetMethodEndLine(method)
176+
};
169177
}
170178

171179
static readonly Dictionary<Modifier, Func<MethodDefinition, Modifier>> AccessModiferQueries = new Dictionary<Modifier, Func<MethodDefinition, Modifier>>()
@@ -189,5 +197,29 @@ private List<String> GetParameters(MethodDefinition method)
189197
{
190198
return method.Parameters.Select(parameter => parameter.ParameterType.FullName).ToList();
191199
}
200+
201+
private int GetMethodStartLine(MethodDefinition method)
202+
{
203+
var methodStartLine = -1;
204+
205+
if(method.DebugInformation.HasSequencePoints)
206+
{
207+
methodStartLine = method.DebugInformation.SequencePoints.OrderBy(t => t.StartLine).First().StartLine;
208+
}
209+
210+
return methodStartLine;
211+
}
212+
213+
private int GetMethodEndLine(MethodDefinition method)
214+
{
215+
var methodEndLine = -1;
216+
217+
if (method.DebugInformation.HasSequencePoints)
218+
{
219+
methodEndLine = method.DebugInformation.SequencePoints.OrderBy(t => t.StartLine).Where(t => !t.IsHidden).Last().EndLine;
220+
}
221+
222+
return methodEndLine;
223+
}
192224
}
193225
}

SymbolService/Model/MethodInfo.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class MethodInfo
2727

2828
public String ContainingClass { get; set; }
2929

30+
public String File { get; set; }
31+
3032
public int AccessModifiers { get; set; }
3133

3234
public IEnumerable<String> Parameters { get; set; }
@@ -37,7 +39,14 @@ public class MethodInfo
3739

3840
public Guid SurrogateFor { get; set; }
3941

40-
public MethodInfo()
42+
public int SequencePointCount { get; set; }
43+
44+
public int MethodStartLine { get; set; }
45+
46+
public int MethodEndLine { get; set; }
47+
48+
49+
public MethodInfo()
4150
{
4251
Id = Guid.NewGuid();
4352
}

SymbolService/Program.cs

+8-6
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616

17-
using Microsoft.AspNetCore;
1817
using Microsoft.AspNetCore.Hosting;
18+
using Microsoft.Extensions.Hosting;
1919

2020
namespace SymbolService
2121
{
2222
public class Program
2323
{
2424
public static void Main(string[] args)
2525
{
26-
BuildWebHost(args).Run();
26+
CreateHostBuilder(args).Build().Run();
2727
}
2828

29-
public static IWebHost BuildWebHost(string[] args) =>
30-
WebHost.CreateDefaultBuilder(args)
31-
.UseStartup<Startup>()
32-
.Build();
29+
public static IHostBuilder CreateHostBuilder(string[] args) =>
30+
Host.CreateDefaultBuilder(args)
31+
.ConfigureWebHostDefaults(webBuilder =>
32+
{
33+
webBuilder.UseStartup<Startup>();
34+
});
3335
}
3436
}

SymbolService/Startup.cs

+9-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using Microsoft.AspNetCore.Hosting;
1919
using Microsoft.Extensions.Configuration;
2020
using Microsoft.Extensions.DependencyInjection;
21-
using Microsoft.Extensions.Logging;
21+
using Microsoft.Extensions.Hosting;
2222

2323
namespace SymbolService
2424
{
@@ -34,21 +34,23 @@ public Startup(IConfiguration configuration)
3434
// This method gets called by the runtime. Use this method to add services to the container.
3535
public void ConfigureServices(IServiceCollection services)
3636
{
37-
services.AddMvc();
37+
services.AddControllers();
3838
}
3939

4040
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
41-
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
41+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4242
{
43-
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
44-
loggerFactory.AddDebug();
45-
4643
if (env.IsDevelopment())
4744
{
4845
app.UseDeveloperExceptionPage();
4946
}
5047

51-
app.UseMvc();
48+
app.UseRouting();
49+
50+
app.UseEndpoints(endpoints =>
51+
{
52+
endpoints.MapControllers();
53+
});
5254
}
5355
}
5456
}

SymbolService/SymbolService.csproj

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<AssemblyName>SymbolService</AssemblyName>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.2" />
10-
</ItemGroup>
11-
12-
<ItemGroup>
13-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
149
<PackageReference Include="Mono.Cecil" Version="0.10.0-beta7" />
1510
</ItemGroup>
1611

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"Logging": {
3-
"IncludeScopes": false,
43
"LogLevel": {
5-
"Default": "Debug",
6-
"System": "Information",
7-
"Microsoft": "Information"
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
87
}
98
}
10-
}
9+
}

SymbolService/appsettings.json

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
{
22
"Logging": {
3-
"IncludeScopes": false,
4-
"Debug": {
5-
"LogLevel": {
6-
"Default": "Warning"
7-
}
8-
},
9-
"Console": {
10-
"LogLevel": {
11-
"Default": "Warning"
12-
}
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
137
}
14-
}
8+
},
9+
"AllowedHosts": "*"
1510
}

0 commit comments

Comments
 (0)