Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
820a728c
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,发现更多精彩内容 >>
提交
820a728c
编写于
3月 29, 2016
作者:
C
Charles Stoner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix unit tests
上级
7925a348
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
105 addition
and
164 deletion
+105
-164
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
...ompilers/CSharp/Portable/Compilation/CSharpCompilation.cs
+0
-41
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
...rp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
+4
-12
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests.cs
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests.cs
+14
-20
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenExplicitImplementationTests.cs
...p/Test/Emit/CodeGen/CodeGenExplicitImplementationTests.cs
+3
-1
src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticAnalyzerTests.AllInOne.cs
.../Semantic/Diagnostics/DiagnosticAnalyzerTests.AllInOne.cs
+3
-0
src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs
src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs
+2
-1
src/Compilers/CSharp/Test/Syntax/IncrementalParsing/ReplaceOriginalTests.cs
...rp/Test/Syntax/IncrementalParsing/ReplaceOriginalTests.cs
+2
-2
src/Compilers/Core/Portable/CodeGen/CompilationTestData.cs
src/Compilers/Core/Portable/CodeGen/CompilationTestData.cs
+16
-1
src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs
src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs
+12
-10
src/Compilers/Core/Portable/Compilation/Compilation.cs
src/Compilers/Core/Portable/Compilation/Compilation.cs
+45
-4
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerFileReference.cs
...Core/Portable/DiagnosticAnalyzer/AnalyzerFileReference.cs
+0
-39
src/Compilers/VisualBasic/Portable/Compilation/VisualBasicCompilation.vb
...isualBasic/Portable/Compilation/VisualBasicCompilation.vb
+1
-30
src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioWorkspaceHost2.cs
...plementation/ProjectSystem/IVisualStudioWorkspaceHost2.cs
+1
-1
src/VisualStudio/Core/Test/ProjectSystemShim/Framework/TestEnvironment.vb
.../Core/Test/ProjectSystemShim/Framework/TestEnvironment.vb
+2
-2
未找到文件。
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
浏览文件 @
820a728c
...
...
@@ -2048,47 +2048,6 @@ private ImmutableArray<Diagnostic> GetDiagnosticsForMethodBodiesInTree(SyntaxTre
return
diagnostics
.
ToReadOnlyAndFree
();
}
/// <summary>
/// Filter out warnings based on the compiler options (/nowarn, /warn and /warnaserror) and the pragma warning directives.
/// 'incoming' is freed.
/// </summary>
/// <returns>True when there is no error or warning treated as an error.</returns>
internal
override
bool
FilterAndAppendAndFreeDiagnostics
(
DiagnosticBag
accumulator
,
ref
DiagnosticBag
incoming
)
{
bool
result
=
FilterAndAppendDiagnostics
(
accumulator
,
incoming
.
AsEnumerableWithoutResolution
());
incoming
.
Free
();
incoming
=
null
;
return
result
;
}
/// <summary>
/// Filter out warnings based on the compiler options (/nowarn, /warn and /warnaserror) and the pragma warning directives.
/// </summary>
/// <returns>True when there is no error.</returns>
private
bool
FilterAndAppendDiagnostics
(
DiagnosticBag
accumulator
,
IEnumerable
<
Diagnostic
>
incoming
)
{
bool
hasError
=
false
;
bool
reportSuppressedDiagnostics
=
Options
.
ReportSuppressedDiagnostics
;
foreach
(
Diagnostic
d
in
incoming
)
{
var
filtered
=
_options
.
FilterDiagnostic
(
d
);
if
(
filtered
==
null
||
(!
reportSuppressedDiagnostics
&&
filtered
.
IsSuppressed
))
{
continue
;
}
else
if
(
filtered
.
Severity
==
DiagnosticSeverity
.
Error
)
{
hasError
=
true
;
}
accumulator
.
Add
(
filtered
);
}
return
!
hasError
;
}
private
ImmutableArray
<
Diagnostic
>
GetSourceDeclarationDiagnostics
(
SyntaxTree
syntaxTree
=
null
,
TextSpan
?
filterSpanWithinTree
=
null
,
Func
<
IEnumerable
<
Diagnostic
>,
SyntaxTree
,
TextSpan
?,
IEnumerable
<
Diagnostic
>>
locationFilterOpt
=
null
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
{
GlobalImports
.
Complete
(
cancellationToken
);
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
浏览文件 @
820a728c
...
...
@@ -1331,12 +1331,6 @@ private void CheckMemberNameConflicts(DiagnosticBag diagnostics)
{
Dictionary
<
string
,
ImmutableArray
<
Symbol
>>
membersByName
=
GetMembersByName
();
if
(
membersByName
.
Values
.
All
(
m
=>
m
.
Length
==
1
))
{
// No duplicate names.
return
;
}
// Collisions involving indexers are handled specially.
CheckIndexerNameConflicts
(
diagnostics
,
membersByName
);
...
...
@@ -1456,6 +1450,7 @@ private void CheckMemberNameConflicts(DiagnosticBag diagnostics)
// second and third categories as follows:
var
conversion
=
symbol
as
SourceUserDefinedConversionSymbol
;
var
method
=
symbol
as
SourceMethodSymbol
;
// Does this conversion collide with any previously-seen conversion?
if
((
object
)
conversion
!=
null
)
{
...
...
@@ -1465,9 +1460,7 @@ private void CheckMemberNameConflicts(DiagnosticBag diagnostics)
diagnostics
.
Add
(
ErrorCode
.
ERR_DuplicateConversionInClass
,
conversion
.
Locations
[
0
],
this
);
}
}
var
method
=
symbol
as
SourceMethodSymbol
;
if
((
object
)
method
!=
null
)
else
if
((
object
)
method
!=
null
)
{
SourceMethodSymbol
previousMethod
;
if
(
methodsBySignature
.
TryGetValue
(
method
,
out
previousMethod
))
...
...
@@ -1526,16 +1519,15 @@ private void CheckIndexerNameConflicts(DiagnosticBag diagnostics, Dictionary<str
}
}
var
indexersBySignature
=
new
Dictionary
<
PropertySymbol
,
PropertySymbol
>(
MemberSignatureComparer
.
DuplicateSourceComparer
);
// Note: Can't assume that all indexers are called WellKnownMemberNames.Indexer because
// they may be explicit interface implementations.
foreach
(
string
name
in
membersByName
.
Key
s
)
foreach
(
var
members
in
membersByName
.
Value
s
)
{
string
lastIndexerName
=
null
;
indexersBySignature
.
Clear
();
foreach
(
var
symbol
in
members
ByName
[
name
]
)
foreach
(
var
symbol
in
members
)
{
if
(
symbol
.
IsIndexer
())
{
...
...
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests.cs
浏览文件 @
820a728c
...
...
@@ -5221,27 +5221,24 @@ partial class C
var
compilation
=
CreateCompilationWithMscorlib
(
source
,
null
,
options
:
opt
);
compilation
.
VerifyDiagnostics
(
// (25,25): error CS0759: No defining declaration found for implementing declaration of partial method 'C.Foo6<T>()'
// static partial void Foo6<[A][A] T>() { }
Diagnostic
(
ErrorCode
.
ERR_PartialMethodMustHaveLatent
,
"Foo6"
).
WithArguments
(
"C.Foo6<T>()"
),
// (11,17): error CS0111: Type 'C' already defines a member called 'Foo2' with the same parameter types
// static void Foo2<[A] T>() { }
Diagnostic
(
ErrorCode
.
ERR_MemberAlreadyExists
,
"Foo2"
).
WithArguments
(
"Foo2"
,
"C"
),
Diagnostic
(
ErrorCode
.
ERR_MemberAlreadyExists
,
"Foo2"
).
WithArguments
(
"Foo2"
,
"C"
)
.
WithLocation
(
11
,
17
)
,
// (15,17): error CS0102: The type 'C' already contains a definition for 'Foo3'
// private int Foo3;
Diagnostic
(
ErrorCode
.
ERR_DuplicateNameInClass
,
"Foo3"
).
WithArguments
(
"C"
,
"Foo3"
),
Diagnostic
(
ErrorCode
.
ERR_DuplicateNameInClass
,
"Foo3"
).
WithArguments
(
"C"
,
"Foo3"
)
.
WithLocation
(
15
,
17
)
,
// (7,30): error CS0579: Duplicate 'A' attribute
// static partial void Foo<[A] T>() { }
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
),
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
)
.
WithLocation
(
7
,
30
)
,
// (18,34): error CS0579: Duplicate 'A' attribute
// static partial void Foo4<[A][A] T>();
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
),
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
)
.
WithLocation
(
18
,
34
)
,
// (25,34): error CS0579: Duplicate 'A' attribute
// static partial void Foo6<[A][A] T>() { }
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
),
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
)
.
WithLocation
(
25
,
34
)
,
// (15,17): warning CS0169: The field 'C.Foo3' is never used
// private int Foo3;
Diagnostic
(
ErrorCode
.
WRN_UnreferencedField
,
"Foo3"
).
WithArguments
(
"C.Foo3"
));
Diagnostic
(
ErrorCode
.
WRN_UnreferencedField
,
"Foo3"
).
WithArguments
(
"C.Foo3"
)
.
WithLocation
(
15
,
17
)
);
}
[
WorkItem
(
542625
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542625"
)]
...
...
@@ -5280,27 +5277,24 @@ partial class C
var
compilation
=
CreateCompilationWithMscorlib
(
source
,
null
,
options
:
opt
);
compilation
.
VerifyDiagnostics
(
// (25,25): error CS0759: No defining declaration found for implementing declaration of partial method 'C.Foo6(int)'
// static partial void Foo6([A][A] int y) { }
Diagnostic
(
ErrorCode
.
ERR_PartialMethodMustHaveLatent
,
"Foo6"
).
WithArguments
(
"C.Foo6(int)"
),
// (11,17): error CS0111: Type 'C' already defines a member called 'Foo2' with the same parameter types
// static void Foo2([A] int y) { }
Diagnostic
(
ErrorCode
.
ERR_MemberAlreadyExists
,
"Foo2"
).
WithArguments
(
"Foo2"
,
"C"
),
Diagnostic
(
ErrorCode
.
ERR_MemberAlreadyExists
,
"Foo2"
).
WithArguments
(
"Foo2"
,
"C"
)
.
WithLocation
(
11
,
17
)
,
// (15,17): error CS0102: The type 'C' already contains a definition for 'Foo3'
// private int Foo3;
Diagnostic
(
ErrorCode
.
ERR_DuplicateNameInClass
,
"Foo3"
).
WithArguments
(
"C"
,
"Foo3"
),
// (
7,30
): error CS0579: Duplicate 'A' attribute
// static partial void Foo([
A] int y) { }
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
),
Diagnostic
(
ErrorCode
.
ERR_DuplicateNameInClass
,
"Foo3"
).
WithArguments
(
"C"
,
"Foo3"
)
.
WithLocation
(
15
,
17
)
,
// (
6,37
): error CS0579: Duplicate 'A' attribute
// static partial void Foo([
param: A]int y);
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
)
.
WithLocation
(
6
,
37
)
,
// (18,41): error CS0579: Duplicate 'A' attribute
// static partial void Foo4([A][param: A] int y);
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
),
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
)
.
WithLocation
(
18
,
41
)
,
// (25,34): error CS0579: Duplicate 'A' attribute
// static partial void Foo6([A][A] int y) { }
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
),
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"A"
).
WithArguments
(
"A"
)
.
WithLocation
(
25
,
34
)
,
// (15,17): warning CS0169: The field 'C.Foo3' is never used
// private int Foo3;
Diagnostic
(
ErrorCode
.
WRN_UnreferencedField
,
"Foo3"
).
WithArguments
(
"C.Foo3"
));
Diagnostic
(
ErrorCode
.
WRN_UnreferencedField
,
"Foo3"
).
WithArguments
(
"C.Foo3"
)
.
WithLocation
(
15
,
17
)
);
}
[
Fact
]
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenExplicitImplementationTests.cs
浏览文件 @
820a728c
...
...
@@ -1062,7 +1062,9 @@ class C : A::I, B::I
});
// Simple verification that the test infrastructure supports such methods.
verifier2
.
VerifyIL
(
"A$$C.I.M()"
,
@"
var
testData
=
verifier2
.
TestData
;
var
pair
=
testData
.
Methods
.
Single
(
m
=>
m
.
Key
.
Name
==
"A::I.M"
);
pair
.
Value
.
VerifyIL
(
@"
{
// Code size 1 (0x1)
.maxstack 0
...
...
src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticAnalyzerTests.AllInOne.cs
浏览文件 @
820a728c
...
...
@@ -40,6 +40,9 @@ public void DiagnosticAnalyzerAllInOne()
syntaxKindsPatterns
.
Add
(
SyntaxKind
.
LetStatement
);
syntaxKindsPatterns
.
Add
(
SyntaxKind
.
CasePatternSwitchLabel
);
// AllInOneCSharpCode has no replace/original.
syntaxKindsPatterns
.
Add
(
SyntaxKind
.
OriginalExpression
);
var
analyzer
=
new
CSharpTrackingDiagnosticAnalyzer
();
CreateExperimentalCompilationWithMscorlib45
(
source
).
VerifyAnalyzerDiagnostics
(
new
[]
{
analyzer
});
analyzer
.
VerifyAllAnalyzerMembersWereCalled
();
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs
浏览文件 @
820a728c
...
...
@@ -2962,7 +2962,8 @@ public unsafe struct S
Diagnostic
(
ErrorCode
.
ERR_ManagedAddr
,
"Alias*"
).
WithArguments
(
"S"
));
}
[
Fact
]
// PROTOTYPE(generators):
[
Fact
(
Skip
=
"PROTOTYPE(generators)"
)]
public
void
ERR_ManagedAddr_Members
()
{
var
text
=
@"
...
...
src/Compilers/CSharp/Test/Syntax/IncrementalParsing/ReplaceOriginalTests.cs
浏览文件 @
820a728c
...
...
@@ -6,7 +6,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
public
class
ReplaceOriginalTests
{
[
Fact
]
[
Fact
(
Skip
=
"PROTOTYPE(generators): Incremental parsing"
)
]
public
void
AddReplace
()
{
string
oldText
=
...
...
@@ -23,7 +23,7 @@ static void F()
Assert
.
NotEqual
(
default
(
SyntaxNodeOrToken
),
newTree
.
FindNodeOrTokenByKind
(
SyntaxKind
.
OriginalExpression
));
}
[
Fact
]
[
Fact
(
Skip
=
"PROTOTYPE(generators): Incremental parsing"
)
]
public
void
RemoveReplace
()
{
string
oldText
=
...
...
src/Compilers/Core/Portable/CodeGen/CompilationTestData.cs
浏览文件 @
820a728c
...
...
@@ -2,6 +2,7 @@
using
System
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Linq
;
using
System.Threading
;
...
...
@@ -37,11 +38,25 @@ public ILBuilder GetIL(Func<IMethodSymbol, bool> predicate)
private
ImmutableDictionary
<
string
,
MethodData
>
_lazyMethodsByName
;
// Returns map indexed by name for those methods that have a unique name.
public
ImmutableDictionary
<
string
,
MethodData
>
GetMethodsByName
()
{
if
(
_lazyMethodsByName
==
null
)
{
var
methodsByName
=
Methods
.
ToImmutableDictionary
(
p
=>
GetMethodName
(
p
.
Key
),
p
=>
p
.
Value
);
var
map
=
new
Dictionary
<
string
,
MethodData
>();
foreach
(
var
pair
in
Methods
)
{
var
name
=
GetMethodName
(
pair
.
Key
);
if
(
map
.
ContainsKey
(
name
))
{
map
[
name
]
=
default
(
MethodData
);
}
else
{
map
.
Add
(
name
,
pair
.
Value
);
}
}
var
methodsByName
=
map
.
Where
(
p
=>
p
.
Value
.
Method
!=
null
).
ToImmutableDictionary
();
Interlocked
.
CompareExchange
(
ref
_lazyMethodsByName
,
methodsByName
,
null
);
}
return
_lazyMethodsByName
;
...
...
src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs
浏览文件 @
820a728c
...
...
@@ -465,16 +465,6 @@ private int RunCore(TextWriter consoleOutput, ErrorLogger errorLogger, Cancellat
filterOpt
:
null
,
cancellationToken
:
cancellationToken
);
if
(
analyzerDriver
!=
null
)
{
var
hostDiagnostics
=
analyzerDriver
.
GetDiagnosticsAsync
(
compilation
).
Result
;
diagnosticBag
.
AddRange
(
hostDiagnostics
);
if
(
hostDiagnostics
.
Any
(
IsReportedError
))
{
success
=
false
;
}
}
if
(
success
)
{
// NOTE: as native compiler does, we generate the documentation file
...
...
@@ -511,6 +501,18 @@ private int RunCore(TextWriter consoleOutput, ErrorLogger errorLogger, Cancellat
}
}
}
if
(
analyzerDriver
!=
null
)
{
// GetDiagnosticsAsync is called after GenerateResourcesAndDocumentationComments
// since that method calls EventQueue.TryComplete. Without TryComplete, we may miss diagnostics.
var
hostDiagnostics
=
analyzerDriver
.
GetDiagnosticsAsync
(
compilation
).
Result
;
diagnosticBag
.
AddRange
(
hostDiagnostics
);
if
(
hostDiagnostics
.
Any
(
IsReportedError
))
{
success
=
false
;
}
}
}
finally
{
...
...
src/Compilers/Core/Portable/Compilation/Compilation.cs
浏览文件 @
820a728c
...
...
@@ -853,10 +853,48 @@ public INamedTypeSymbol GetTypeByMetadataName(string fullyQualifiedMetadataName)
internal
abstract
CommonMessageProvider
MessageProvider
{
get
;
}
/// <summary>
/// Filter out warnings based on the compiler options (/nowarn, /warn and /warnaserror) and the pragma warning directives.
/// 'incoming' is freed.
/// </summary>
/// <param name="accumulator">Bag to which filtered diagnostics will be added.</param>
/// <param name="incoming">Diagnostics to be filtered.</param>
/// <returns>True if there were no errors or warnings-as-errors.</returns>
internal
abstract
bool
FilterAndAppendAndFreeDiagnostics
(
DiagnosticBag
accumulator
,
ref
DiagnosticBag
incoming
);
internal
bool
FilterAndAppendAndFreeDiagnostics
(
DiagnosticBag
accumulator
,
ref
DiagnosticBag
incoming
)
{
bool
result
=
FilterAndAppendDiagnostics
(
accumulator
,
incoming
.
AsEnumerableWithoutResolution
());
incoming
.
Free
();
incoming
=
null
;
return
result
;
}
/// <summary>
/// Filter out warnings based on the compiler options (/nowarn, /warn and /warnaserror) and the pragma warning directives.
/// </summary>
/// <returns>True when there is no error.</returns>
internal
bool
FilterAndAppendDiagnostics
(
DiagnosticBag
accumulator
,
IEnumerable
<
Diagnostic
>
incoming
)
{
bool
hasError
=
false
;
bool
reportSuppressedDiagnostics
=
Options
.
ReportSuppressedDiagnostics
;
foreach
(
Diagnostic
d
in
incoming
)
{
var
filtered
=
Options
.
FilterDiagnostic
(
d
);
if
(
filtered
==
null
||
(!
reportSuppressedDiagnostics
&&
filtered
.
IsSuppressed
))
{
continue
;
}
else
if
(
filtered
.
Severity
==
DiagnosticSeverity
.
Error
)
{
hasError
=
true
;
}
accumulator
.
Add
(
filtered
);
}
return
!
hasError
;
}
#
endregion
...
...
@@ -1542,14 +1580,17 @@ internal void EnsureAnonymousTypeTemplates(CancellationToken cancellationToken)
filterOpt
:
null
,
cancellationToken
:
cancellationToken
);
if
(
success
)
if
(
!
moduleBeingBuilt
.
EmitOptions
.
EmitMetadataOnly
)
{
success
=
GenerateResourcesAndDocumentationComments
(
if
(!
GenerateResourcesAndDocumentationComments
(
moduleBeingBuilt
,
xmlDocumentationStream
,
win32Resources
,
diagnostics
,
cancellationToken
);
cancellationToken
))
{
success
=
false
;
}
}
}
finally
...
...
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerFileReference.cs
浏览文件 @
820a728c
...
...
@@ -150,45 +150,6 @@ internal void AddAnalyzers(ImmutableDictionary<string, ImmutableArray<Diagnostic
/// </summary>
internal
void
AddAnalyzers
(
ImmutableArray
<
DiagnosticAnalyzer
>.
Builder
builder
,
string
language
)
{
ImmutableDictionary
<
string
,
ImmutableHashSet
<
string
>>
analyzerTypeNameMap
;
Assembly
analyzerAssembly
=
null
;
try
{
analyzerTypeNameMap
=
GetAnalyzerTypeNameMap
();
// If there are no analyzers, don't load the assembly at all.
if
(!
analyzerTypeNameMap
.
ContainsKey
(
language
))
{
return
;
}
analyzerAssembly
=
GetAssembly
();
if
(
analyzerAssembly
==
null
)
{
// This can be null if NoOpAnalyzerAssemblyLoader is used.
return
;
}
}
catch
(
Exception
e
)
{
this
.
AnalyzerLoadFailed
?.
Invoke
(
this
,
new
AnalyzerLoadFailureEventArgs
(
AnalyzerLoadFailureEventArgs
.
FailureErrorCode
.
UnableToLoadAnalyzer
,
e
.
Message
));
return
;
}
var
initialCount
=
builder
.
Count
;
var
reportedError
=
false
;
// Add language specific analyzers.
var
analyzers
=
GetLanguageSpecificAnalyzers
(
analyzerAssembly
,
analyzerTypeNameMap
,
language
,
ref
reportedError
);
builder
.
AddRange
(
analyzers
);
// If there were types with the attribute but weren't an analyzer, generate a diagnostic.
// If we've reported errors already while trying to instantiate types, don't complain that there are no analyzers.
if
(
builder
.
Count
==
initialCount
&&
!
reportedError
)
{
this
.
AnalyzerLoadFailed
?.
Invoke
(
this
,
new
AnalyzerLoadFailureEventArgs
(
AnalyzerLoadFailureEventArgs
.
FailureErrorCode
.
NoAnalyzers
,
CodeAnalysisResources
.
NoAnalyzersFound
));
}
_diagnosticAnalyzers
.
AddExtensions
(
builder
,
language
);
}
...
...
src/Compilers/VisualBasic/Portable/Compilation/VisualBasicCompilation.vb
浏览文件 @
820a728c
...
...
@@ -2046,35 +2046,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
If
End
Sub
Friend
Overrides
Function
FilterAndAppendAndFreeDiagnostics
(
accumulator
As
DiagnosticBag
,
ByRef
incoming
As
DiagnosticBag
)
As
Boolean
Dim
result
As
Boolean
=
FilterAndAppendDiagnostics
(
accumulator
,
incoming
.
AsEnumerableWithoutResolution
())
incoming
.
Free
()
incoming
=
Nothing
Return
result
End
Function
' Filter out some warnings based on the compiler options (/nowarn and /warnaserror).
Friend
Overloads
Function
FilterAndAppendDiagnostics
(
accumulator
As
DiagnosticBag
,
ByRef
incoming
As
IEnumerable
(
Of
Diagnostic
))
As
Boolean
Dim
hasError
As
Boolean
=
False
Dim
reportSuppressedDiagnostics
=
Options
.
ReportSuppressedDiagnostics
For
Each
diagnostic
As
Diagnostic
In
incoming
Dim
filtered
=
Me
.
_options
.
FilterDiagnostic
(
diagnostic
)
If
filtered
Is
Nothing
OrElse
(
Not
reportSuppressedDiagnostics
AndAlso
filtered
.
IsSuppressed
)
Then
Continue
For
End
If
If
filtered
.
Severity
=
DiagnosticSeverity
.
Error
Then
hasError
=
True
End
If
accumulator
.
Add
(
filtered
)
Next
Return
Not
hasError
End
Function
Friend
Overrides
Function
AnalyzerForLanguage
(
analyzers
As
ImmutableArray
(
Of
DiagnosticAnalyzer
),
analyzerManager
As
AnalyzerManager
)
As
AnalyzerDriver
Dim
getKind
As
Func
(
Of
SyntaxNode
,
SyntaxKind
)
=
Function
(
node
As
SyntaxNode
)
node
.
Kind
Dim
isComment
As
Func
(
Of
SyntaxTrivia
,
Boolean
)
=
Function
(
trivia
As
SyntaxTrivia
)
trivia
.
Kind
()
=
SyntaxKind
.
CommentTrivia
...
...
@@ -2264,8 +2235,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Friend
Overrides
Function
GenerateResourcesAndDocumentationComments
(
moduleBuilder
As
CommonPEModuleBuilder
,
win32Resources
As
Stream
,
xmlDocStream
As
Stream
,
win32Resources
As
Stream
,
diagnostics
As
DiagnosticBag
,
cancellationToken
As
CancellationToken
)
As
Boolean
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioWorkspaceHost2.cs
浏览文件 @
820a728c
...
...
@@ -8,6 +8,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
internal
interface
IVisualStudioWorkspaceHost2
{
void
OnHasAllInformation
(
ProjectId
projectId
,
bool
hasAllInformation
);
void
UpdateGeneratedDocumentsIfNecessary
(
ProjectId
projectI
nfo
);
void
UpdateGeneratedDocumentsIfNecessary
(
ProjectId
projectI
d
);
}
}
src/VisualStudio/Core/Test/ProjectSystemShim/Framework/TestEnvironment.vb
浏览文件 @
820a728c
...
...
@@ -245,8 +245,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Fr
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
UpdateGeneratedDocumentsIfNecessary
(
projectI
nfo
As
ProjectId
)
Implements
IVisualStudioWorkspaceHost2
.
UpdateGeneratedDocumentsIfNecessary
Throw
New
NotImplementedException
(
)
Public
Sub
UpdateGeneratedDocumentsIfNecessary
(
projectI
d
As
ProjectId
)
Implements
IVisualStudioWorkspaceHost2
.
UpdateGeneratedDocumentsIfNecessary
_workspace
.
UpdateGeneratedDocumentsIfNecessary
(
projectId
)
End
Sub
Public
Sub
OnMetadataReferenceAdded
(
projectId
As
ProjectId
,
metadataReference
As
PortableExecutableReference
)
Implements
IVisualStudioWorkspaceHost
.
OnMetadataReferenceAdded
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录