Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
80a76ea0
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
80a76ea0
编写于
9月 23, 2020
作者:
J
Joey Robichaud
提交者:
GitHub
9月 23, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #47855 from JoeRobich/action-telemetry-builder
Add tool to generate table of hashes for CodeActions
上级
637cb4c8
acca9f9a
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
821 addition
and
0 deletion
+821
-0
Roslyn.sln
Roslyn.sln
+665
-0
src/Tools/BuildActionTelemetryTable/BuildActionTelemetryTable.csproj
...uildActionTelemetryTable/BuildActionTelemetryTable.csproj
+30
-0
src/Tools/BuildActionTelemetryTable/Program.cs
src/Tools/BuildActionTelemetryTable/Program.cs
+109
-0
src/Tools/BuildActionTelemetryTable/readme.md
src/Tools/BuildActionTelemetryTable/readme.md
+17
-0
未找到文件。
Roslyn.sln
浏览文件 @
80a76ea0
此差异已折叠。
点击以展开。
src/Tools/BuildActionTelemetryTable/BuildActionTelemetryTable.csproj
0 → 100644
浏览文件 @
80a76ea0
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!--
Since the old hash function was framework and runtime dependent and VS runs 32-bit, we need to
run FullFramework 32-bit in order to generate the same hashes.
-->
<TargetFrameworks>net472</TargetFrameworks>
<Platforms>x86</Platforms>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
<ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj" />
<ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" />
<ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" />
<ProjectReference Include="..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj" />
<ProjectReference Include="..\..\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj" />
<ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" />
<ProjectReference Include="..\..\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj" />
<ProjectReference Include="..\..\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\Hash.cs" Link="Utilities\Hash.cs" />
<Compile Include="..\..\EditorFeatures\Core\Shared\Extensions\TelemetryExtensions.cs" Link="Utilities\TelemetryExtensions.cs" />
</ItemGroup>
</Project>
src/Tools/BuildActionTelemetryTable/Program.cs
0 → 100644
浏览文件 @
80a76ea0
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.IO
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text
;
using
Microsoft.CodeAnalysis.CodeActions
;
using
Microsoft.CodeAnalysis.Editor.Shared.Extensions
;
using
TelemetryInfo
=
System
.
Tuple
<
string
,
string
,
string
>;
namespace
BuildActionTelemetryTable
{
public
class
Program
{
private
static
readonly
string
s_executingPath
=
Path
.
GetDirectoryName
(
Assembly
.
GetExecutingAssembly
().
Location
);
public
static
void
Main
(
string
[]
args
)
{
Console
.
WriteLine
(
"Loading assemblies and finding CodeActions ..."
);
var
assemblies
=
GetAssemblies
(
args
);
var
codeActionTypes
=
GetCodeActionTypes
(
assemblies
);
Console
.
WriteLine
(
$"Generating Kusto datatable of
{
codeActionTypes
.
Length
}
CodeAction hashes ..."
);
var
telemetryInfos
=
GetTelemetryInfos
(
codeActionTypes
);
var
datatable
=
GenerateKustoDatatable
(
telemetryInfos
);
var
filepath
=
Path
.
GetFullPath
(
".\\ActionTable.txt"
);
Console
.
WriteLine
(
$"Writing datatable to
{
filepath
}
..."
);
File
.
WriteAllText
(
filepath
,
datatable
);
Console
.
WriteLine
(
"Complete."
);
}
internal
static
ImmutableArray
<
Assembly
>
GetAssemblies
(
string
[]
paths
)
{
if
(
paths
.
Length
==
0
)
{
// By default inspect the Roslyn assemblies
paths
=
Directory
.
EnumerateFiles
(
s_executingPath
,
"Microsoft.CodeAnalysis*.dll"
)
.
ToArray
();
}
var
currentDirectory
=
new
Uri
(
Environment
.
CurrentDirectory
+
"\\"
);
return
paths
.
Select
(
path
=>
{
Console
.
WriteLine
(
$"Loading assembly from
{
GetRelativePath
(
path
,
currentDirectory
)}
."
);
return
Assembly
.
LoadFrom
(
path
);
}).
ToImmutableArray
();
static
string
GetRelativePath
(
string
path
,
Uri
baseUri
)
{
var
rootedPath
=
Path
.
IsPathRooted
(
path
)
?
path
:
Path
.
GetFullPath
(
path
);
var
relativePath
=
baseUri
.
MakeRelativeUri
(
new
Uri
(
rootedPath
));
return
relativePath
.
ToString
();
}
}
internal
static
ImmutableArray
<
Type
>
GetCodeActionTypes
(
IEnumerable
<
Assembly
>
assemblies
)
{
var
types
=
assemblies
.
SelectMany
(
assembly
=>
assembly
.
GetTypes
().
Where
(
type
=>
!
type
.
GetTypeInfo
().
IsInterface
&&
!
type
.
GetTypeInfo
().
IsAbstract
));
return
types
.
Where
(
t
=>
typeof
(
CodeAction
).
IsAssignableFrom
(
t
))
.
ToImmutableArray
();
}
internal
static
ImmutableArray
<
TelemetryInfo
>
GetTelemetryInfos
(
ImmutableArray
<
Type
>
codeActionTypes
)
{
return
codeActionTypes
.
Select
(
GetTelemetryInfo
)
.
ToImmutableArray
();
static
TelemetryInfo
GetTelemetryInfo
(
Type
type
)
{
var
telemetryId
=
type
.
GetTelemetryId
().
ToString
();
return
Tuple
.
Create
(
type
.
FullName
,
telemetryId
.
Substring
(
0
,
8
),
telemetryId
.
Substring
(
19
));
}
}
internal
static
string
GenerateKustoDatatable
(
ImmutableArray
<
TelemetryInfo
>
telemetryInfos
)
{
var
table
=
new
StringBuilder
();
table
.
AppendLine
(
"let actions = datatable(ActionName: string, Prefix: string, Suffix: string)"
);
table
.
AppendLine
(
"["
);
foreach
(
var
(
actionTypeName
,
prefix
,
suffix
)
in
telemetryInfos
)
{
table
.
AppendLine
(
@
$" ""{actionTypeName}"", ""{prefix}"", ""{suffix}"","
);
}
table
.
Append
(
"];"
);
return
table
.
ToString
();
}
}
}
src/Tools/BuildActionTelemetryTable/readme.md
0 → 100644
浏览文件 @
80a76ea0
# BuildActionTelemetryTable
This tool generates a Kusto datatable containing CodeAction names and telemetry hashes for analyzing VS LightBulbSessions.
## How to use
By default this tool will generate the table for the Roslyn CodeActions.
```
BuildActionTelemetryTable
```
To generate a table for custom CodeActions you can specify the assembly names to inspect as space separated arguments on the commandline.
```
BuildActionTelemetryTable ./path/StyleCop.Analyzers.dll ./path/StyleCop.Analyzer.CodeFixes.dll
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录