Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1362c04f
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,发现更多精彩内容 >>
提交
1362c04f
编写于
9月 09, 2014
作者:
M
manishv
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address CR feedback. (changeset 1332543)
上级
0f4eeb5d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
27 deletion
+15
-27
Src/Compilers/Core/Desktop/AnalyzerFileReference.cs
Src/Compilers/Core/Desktop/AnalyzerFileReference.cs
+12
-24
Src/Compilers/Core/Desktop/MetadataCache.cs
Src/Compilers/Core/Desktop/MetadataCache.cs
+1
-1
Src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerReference.cs
...ers/Core/Portable/DiagnosticAnalyzer/AnalyzerReference.cs
+1
-1
Src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs
Src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs
+1
-1
未找到文件。
Src/Compilers/Core/Desktop/AnalyzerFileReference.cs
浏览文件 @
1362c04f
...
...
@@ -8,9 +8,8 @@
using
System.Reflection
;
using
System.Reflection.Metadata
;
using
System.Security
;
using
Roslyn.Utilities
;
using
System.Collections.Concurrent
;
using
System.Threading
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Diagnostics
{
...
...
@@ -32,7 +31,7 @@ public sealed partial class AnalyzerFileReference : AnalyzerReference
private
string
lazyDisplayName
;
private
ImmutableArray
<
IDiagnosticAnalyzer
>
lazyAllAnalyzers
;
private
ImmutableArray
<
IDiagnosticAnalyzer
>
lazyLanguageAgnosticAnalyzers
;
private
Concurrent
Dictionary
<
string
,
ImmutableArray
<
IDiagnosticAnalyzer
>>
lazyAnalyzersPerLanguage
;
private
Immutable
Dictionary
<
string
,
ImmutableArray
<
IDiagnosticAnalyzer
>>
lazyAnalyzersPerLanguage
;
private
Assembly
lazyAssembly
;
private
ImmutableDictionary
<
string
,
HashSet
<
string
>>
lazyAnalyzerTypeNameMap
;
...
...
@@ -79,7 +78,7 @@ public AnalyzerFileReference(string fullPath, Func<string, Assembly> getAssembly
this
.
lazyAllAnalyzers
=
default
(
ImmutableArray
<
IDiagnosticAnalyzer
>);
this
.
lazyLanguageAgnosticAnalyzers
=
default
(
ImmutableArray
<
IDiagnosticAnalyzer
>);
this
.
lazyAnalyzersPerLanguage
=
null
;
this
.
lazyAnalyzersPerLanguage
=
ImmutableDictionary
<
string
,
ImmutableArray
<
IDiagnosticAnalyzer
>>.
Empty
;
this
.
getAssembly
=
getAssembly
;
}
...
...
@@ -88,7 +87,7 @@ public override ImmutableArray<IDiagnosticAnalyzer> GetAnalyzersForAllLanguages(
if
(
lazyAllAnalyzers
.
IsDefault
)
{
var
allAnalyzers
=
MetadataCache
.
GetOrCreateAnalyzersFromFile
(
this
);
ImmutableInterlocked
.
Interlocked
CompareExchange
(
ref
this
.
lazyAllAnalyzers
,
allAnalyzers
,
default
(
ImmutableArray
<
IDiagnosticAnalyzer
>)
);
ImmutableInterlocked
.
Interlocked
Initialize
(
ref
this
.
lazyAllAnalyzers
,
allAnalyzers
);
}
return
lazyAllAnalyzers
;
...
...
@@ -101,23 +100,12 @@ public override ImmutableArray<IDiagnosticAnalyzer> GetAnalyzers(string language
throw
new
ArgumentException
(
"language"
);
}
ImmutableArray
<
IDiagnosticAnalyzer
>
analyzers
;
if
(
this
.
lazyAnalyzersPerLanguage
==
null
)
{
Interlocked
.
CompareExchange
(
ref
this
.
lazyAnalyzersPerLanguage
,
new
ConcurrentDictionary
<
string
,
ImmutableArray
<
IDiagnosticAnalyzer
>>(),
null
);
}
else
if
(
this
.
lazyAnalyzersPerLanguage
.
TryGetValue
(
language
,
out
analyzers
))
{
return
analyzers
;
}
analyzers
=
MetadataCache
.
GetOrCreateAnalyzersFromFile
(
this
,
language
);
if
(!
this
.
lazyAnalyzersPerLanguage
.
TryAdd
(
language
,
analyzers
))
{
return
this
.
lazyAnalyzersPerLanguage
[
language
];
}
return
ImmutableInterlocked
.
GetOrAdd
(
ref
this
.
lazyAnalyzersPerLanguage
,
language
,
CreateLanguageSpecificAnalyzers
,
this
);
}
return
analyzers
;
private
static
ImmutableArray
<
IDiagnosticAnalyzer
>
CreateLanguageSpecificAnalyzers
(
string
language
,
AnalyzerFileReference
@this
)
{
return
MetadataCache
.
GetOrCreateAnalyzersFromFile
(
@this
,
language
);
}
public
override
string
FullPath
...
...
@@ -173,7 +161,7 @@ private ImmutableArray<IDiagnosticAnalyzer> GetLanguageAgnosticAnalyzers(Immutab
analyzers
=
GetAnalyzersForTypeNames
(
analyzerAssembly
,
analyzerTypeNames
).
ToImmutableArrayOrEmpty
();
}
ImmutableInterlocked
.
Interlocked
CompareExchange
(
ref
this
.
lazyLanguageAgnosticAnalyzers
,
analyzers
,
default
(
ImmutableArray
<
IDiagnosticAnalyzer
>)
);
ImmutableInterlocked
.
Interlocked
Initialize
(
ref
this
.
lazyLanguageAgnosticAnalyzers
,
analyzers
);
}
return
this
.
lazyLanguageAgnosticAnalyzers
;
...
...
@@ -299,7 +287,7 @@ private IEnumerable<IDiagnosticAnalyzer> GetAnalyzersForTypeNames(Assembly analy
/// </summary>
private
static
ImmutableDictionary
<
string
,
HashSet
<
string
>>
GetAnalyzerTypeNameMap
(
string
fullPath
)
{
var
typeNameMap
=
new
Dictionary
<
string
,
HashSet
<
string
>>();
var
typeNameMap
=
ImmutableDictionary
.
CreateBuilder
<
string
,
HashSet
<
string
>>();
var
diagnosticNamespaceName
=
string
.
Format
(
"{0}.{1}.{2}"
,
nameof
(
Microsoft
),
nameof
(
CodeAnalysis
),
nameof
(
Diagnostics
));
var
supportedLanguageNames
=
new
HashSet
<
string
>();
...
...
@@ -367,7 +355,7 @@ private IEnumerable<IDiagnosticAnalyzer> GetAnalyzersForTypeNames(Assembly analy
}
}
return
typeNameMap
.
ToImmutable
Dictionary
();
return
typeNameMap
.
ToImmutable
();
}
private
static
string
GetFullyQualifiedTypeName
(
TypeDefinition
typeDef
,
PEModule
peModule
)
...
...
Src/Compilers/Core/Desktop/MetadataCache.cs
浏览文件 @
1362c04f
...
...
@@ -122,7 +122,7 @@ internal struct CachedAnalyzers
public
readonly
WeakReference
Analyzers
;
public
readonly
string
Language
;
public
CachedAnalyzers
(
ImmutableArray
<
IDiagnosticAnalyzer
>
analyzers
,
string
language
)
public
CachedAnalyzers
(
object
analyzers
,
string
language
)
{
Debug
.
Assert
(
analyzers
!=
null
);
...
...
Src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerReference.cs
浏览文件 @
1362c04f
...
...
@@ -44,12 +44,12 @@ public virtual bool IsUnresolved
/// In most instances, either the analyzer reference is associated with a project or is being queried for analyzers in a particular language context.
/// If so, use <see cref="GetAnalyzers(string)"/> method.
/// </summary>
/// <returns></returns>
public
abstract
ImmutableArray
<
IDiagnosticAnalyzer
>
GetAnalyzersForAllLanguages
();
/// <summary>
/// Gets all the diagnostic analyzers defined in this assembly reference for the given <paramref name="language"/>.
/// </summary>
/// <param name="language">Language name.</param>
public
abstract
ImmutableArray
<
IDiagnosticAnalyzer
>
GetAnalyzers
(
string
language
);
}
}
\ No newline at end of file
Src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs
浏览文件 @
1362c04f
...
...
@@ -369,7 +369,7 @@ public void TestProjectDiagnosticAnalyzers()
var
actualAnalyzerReferences
=
newSolution
.
Projects
.
Single
().
AnalyzerReferences
;
Assert
.
Equal
(
1
,
actualAnalyzerReferences
.
Count
);
Assert
.
Equal
(
analyzerReference
,
actualAnalyzerReferences
[
0
]);
var
actualAnalyzers
=
actualAnalyzerReferences
[
0
].
GetAnalyzersForAllLanguages
()
.
ToImmutableArray
()
;
var
actualAnalyzers
=
actualAnalyzerReferences
[
0
].
GetAnalyzersForAllLanguages
();
Assert
.
Equal
(
1
,
actualAnalyzers
.
Length
);
Assert
.
Equal
(
analyzer
,
actualAnalyzers
[
0
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录