-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInt32ParameterFiller.cs
More file actions
46 lines (40 loc) · 1.53 KB
/
Copy pathInt32ParameterFiller.cs
File metadata and controls
46 lines (40 loc) · 1.53 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
using Microsoft.Extensions.Logging;
using NetStackBeautifier.Core;
namespace NetStackBeautifier.Services.LineBeautifiers;
internal class Int32ParameterFiller<T> : LineBeautifierBase<T>
where T : IBeautifier
{
public Int32ParameterFiller(ILogger<Int32ParameterFiller<T>> logger) : base(logger)
{
}
protected override Task<FrameItem> BeautifyImpAsync(FrameItem line, CancellationToken cancellationToken = default)
{
if (line.Method is null || !line.Method.Parameters.NullAsEmpty().Any())
{
return Task.FromResult(line);
}
List<FrameParameter> newParamList = new List<FrameParameter>();
int order = 1;
foreach (FrameParameter parameter in line.Method.Parameters.NullAsEmpty())
{
if (string.Equals(parameter.ParameterType, "int32", StringComparison.OrdinalIgnoreCase) ||
string.Equals(parameter.ParameterType, "int", StringComparison.OrdinalIgnoreCase))
{
string paramName = parameter.ParameterName;
if (string.IsNullOrEmpty(paramName))
{
paramName = "n" + order++;
}
newParamList.Add(new FrameParameter("int", paramName, parameter.ParameterType, parameter.ParameterName));
continue;
}
newParamList.Add(parameter);
}
return Task.FromResult(line with
{
Method = line.Method with {
Parameters = newParamList,
},
});
}
}