Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
cbe6b108
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,发现更多精彩内容 >>
提交
cbe6b108
编写于
4月 14, 2015
作者:
H
Heejae Chang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed issue where $RootFolder$ and $ShellFolder$ wasn't resolved correctly
上级
4d691acd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
86 addition
and
6 deletion
+86
-6
src/Features/Core/Diagnostics/HostAnalyzerManager.cs
src/Features/Core/Diagnostics/HostAnalyzerManager.cs
+5
-0
src/VisualStudio/Core/Def/Implementation/Diagnostics/VisualStudioWorkspaceDiagnosticAnalyzerProviderService.cs
...VisualStudioWorkspaceDiagnosticAnalyzerProviderService.cs
+81
-6
未找到文件。
src/Features/Core/Diagnostics/HostAnalyzerManager.cs
浏览文件 @
cbe6b108
...
...
@@ -311,6 +311,11 @@ public string GetDiagnosticAnalyzerPackageName(string language, DiagnosticAnalyz
var
builder
=
ImmutableDictionary
.
CreateBuilder
<
string
,
string
>(
StringComparer
.
OrdinalIgnoreCase
);
foreach
(
var
package
in
_hostDiagnosticAnalyzerPackages
)
{
if
(
string
.
IsNullOrEmpty
(
package
.
Name
))
{
continue
;
}
foreach
(
var
assembly
in
package
.
Assemblies
)
{
if
(!
builder
.
ContainsKey
(
assembly
))
...
...
src/VisualStudio/Core/Def/Implementation/Diagnostics/VisualStudioWorkspaceDiagnosticAnalyzerProviderService.cs
浏览文件 @
cbe6b108
...
...
@@ -6,9 +6,11 @@
using
System.ComponentModel.Composition
;
using
System.IO
;
using
System.Linq
;
using
System.Reflection
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.VisualStudio.ExtensionManager
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
;
using
Roslyn.Utilities
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.Diagnostics
{
...
...
@@ -29,16 +31,39 @@ public VisualStudioWorkspaceDiagnosticAnalyzerProviderService(VisualStudioWorksp
// Get the analyzer assets for installed VSIX extensions through the VSIX extension manager.
var
extensionManager
=
workspace
.
GetVsService
<
SVsExtensionManager
,
IVsExtensionManager
>();
var
builder
=
ImmutableArray
.
CreateBuilder
<
HostDiagnosticAnalyzerPackage
>();
foreach
(
var
extension
in
extensionManager
.
GetEnabledExtensions
(
AnalyzerContentTypeName
))
// get rootfolder and shellfolder location
string
rootFolder
;
string
shellFolder
;
if
(
TryGetRootAndShellFolder
(
extensionManager
,
out
shellFolder
,
out
rootFolder
))
{
var
name
=
extension
.
Header
.
LocalizedName
;
var
assemblies
=
extension
.
Content
.
Where
(
ShouldInclude
).
Select
(
c
=>
Path
.
Combine
(
extension
.
InstallPath
,
c
.
RelativePath
));
var
builder
=
ImmutableArray
.
CreateBuilder
<
HostDiagnosticAnalyzerPackage
>();
foreach
(
var
extension
in
extensionManager
.
GetEnabledExtensions
(
AnalyzerContentTypeName
))
{
var
name
=
extension
.
Header
.
LocalizedName
;
var
assemblies
=
extension
.
Content
.
Where
(
ShouldInclude
)
.
Select
(
c
=>
GetContentLocation
(
shellFolder
,
rootFolder
,
extension
.
InstallPath
,
c
.
RelativePath
))
.
WhereNotNull
();
builder
.
Add
(
new
HostDiagnosticAnalyzerPackage
(
name
,
assemblies
.
ToImmutableArray
()));
builder
.
Add
(
new
HostDiagnosticAnalyzerPackage
(
name
,
assemblies
.
ToImmutableArray
()));
}
_hostDiagnosticAnalyzerInfo
=
builder
.
ToImmutable
();
return
;
}
// if we can't get package name, use old style.
var
references
=
ImmutableArray
.
CreateBuilder
<
string
>();
foreach
(
var
reference
in
extensionManager
.
GetEnabledExtensionContentLocations
(
AnalyzerContentTypeName
))
{
if
(
string
.
IsNullOrEmpty
(
reference
))
{
continue
;
}
references
.
Add
(
reference
);
}
_hostDiagnosticAnalyzerInfo
=
builder
.
ToImmutable
(
);
_hostDiagnosticAnalyzerInfo
=
ImmutableArray
.
Create
(
new
HostDiagnosticAnalyzerPackage
(
name
:
null
,
assemblies
:
references
.
ToImmutable
())
);
}
public
IEnumerable
<
HostDiagnosticAnalyzerPackage
>
GetHostDiagnosticAnalyzerPackages
()
...
...
@@ -46,6 +71,56 @@ public IEnumerable<HostDiagnosticAnalyzerPackage> GetHostDiagnosticAnalyzerPacka
return
_hostDiagnosticAnalyzerInfo
;
}
private
bool
TryGetRootAndShellFolder
(
IVsExtensionManager
extensionManager
,
out
string
shellFolder
,
out
string
rootFolder
)
{
// use reflection to get this information. currently there is no other way to get this information
shellFolder
=
GetProperty
(
extensionManager
,
"ShellFolder"
);
rootFolder
=
GetProperty
(
extensionManager
,
"RootFolder"
);
return
!
string
.
IsNullOrEmpty
(
rootFolder
)
&&
!
string
.
IsNullOrEmpty
(
shellFolder
);
}
private
string
GetContentLocation
(
string
shellFolder
,
string
rootFolder
,
string
installPath
,
string
relativePath
)
{
// extension manager should expose an API that doesnt require this.
const
string
ShellFolderToken
=
"$ShellFolder$"
;
const
string
RootFolderToken
=
"$RootFolder$"
;
if
(
relativePath
.
StartsWith
(
ShellFolderToken
))
{
return
relativePath
.
Replace
(
ShellFolderToken
,
shellFolder
);
}
else
if
(
relativePath
.
StartsWith
(
RootFolderToken
))
{
return
relativePath
.
Replace
(
RootFolderToken
,
rootFolder
);
}
string
contentLocation
=
null
;
try
{
contentLocation
=
Path
.
Combine
(
installPath
,
relativePath
);
}
//Path.Combine will throw an ArgumentException if either of the two path arguments contain illegal characters.
//We'll just catch this exception here and ignore the paths with illegal characters.
catch
(
ArgumentException
)
{
}
return
contentLocation
;
}
private
string
GetProperty
(
IVsExtensionManager
extensionManager
,
string
propertyName
)
{
try
{
return
(
string
)
extensionManager
.
GetType
().
GetProperty
(
propertyName
,
BindingFlags
.
NonPublic
|
BindingFlags
.
Instance
).
GetValue
(
extensionManager
);
}
catch
{
return
null
;
}
}
private
bool
ShouldInclude
(
IExtensionContent
content
)
{
return
string
.
Equals
(
content
.
ContentTypeName
,
AnalyzerContentTypeName
,
StringComparison
.
InvariantCultureIgnoreCase
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录