提交 a67a9c61 编写于 作者: M Manish Vasani

Fix symbol end action not completing for symbols with non-implicit members...

Fix symbol end action not completing for symbols with non-implicit members that have no source location.

In VB, MyApplication type has a Main method which is not marked as IsImplicitlyDeclared but has no source locations (it has a MyTemplateLocation). Due to the latter, VB never generates symbol declared events for such a Main method, causing the symbol end action to never run for it's container.
上级 4bb1ffe5
......@@ -1043,6 +1043,7 @@ private async Task<EventProcessedState> TryProcessSymbolDeclaredAsync(SymbolDecl
// Attempt to execute all analyzer actions.
var processedState = EventProcessedState.Processed;
var symbol = symbolEvent.Symbol;
Debug.Assert(symbol.HasSourceLocation());
var isGeneratedCodeSymbol = IsGeneratedCodeSymbol(symbol);
var skipSymbolAnalysis = AnalysisScope.ShouldSkipSymbolAnalysis(symbolEvent);
......
......@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Microsoft.CodeAnalysis.Diagnostics
......@@ -167,7 +166,7 @@ void processMembers(IEnumerable<ISymbol> members)
{
foreach (var member in members)
{
if (!member.IsImplicitlyDeclared)
if (!member.IsImplicitlyDeclared && member.HasSourceLocation())
{
memberSet = memberSet ?? new HashSet<ISymbol>();
memberSet.Add(member);
......@@ -344,7 +343,7 @@ public void VerifyAllSymbolEndActionsExecuted()
{
lock (_gate)
{
Debug.Assert(_lazyPendingSymbolEndActionsOpt == null || _lazyPendingSymbolEndActionsOpt.Count == 0);
Debug.Assert(_lazyPendingMemberSymbolsMapOpt == null || _lazyPendingMemberSymbolsMapOpt.Count == 0);
Debug.Assert(_lazyPendingSymbolEndActionsOpt == null || _lazyPendingSymbolEndActionsOpt.Count == 0);
}
}
......
......@@ -353,8 +353,7 @@ public void MarkSymbolEndAnalysisComplete(ISymbol symbol, DiagnosticAnalyzer ana
GetAnalyzerExecutionContext(analyzer).MarkSymbolEndAnalysisComplete(symbol);
}
// https://github.com/dotnet/roslyn/issues/30309 tracks enabling the below debug verification.
[Conditional("DEBUG_30309")]
[Conditional("DEBUG")]
public void VerifyAllSymbolEndActionsExecuted()
{
foreach (var analyzerExecutionContext in _analyzerExecutionContextMap.Values)
......
......@@ -96,5 +96,18 @@ internal static INamespaceSymbol GetNestedNamespace(this INamespaceSymbol contai
internal static bool IsNetModule(this IAssemblySymbol assembly) =>
assembly is ISourceAssemblySymbol sourceAssembly && sourceAssembly.Compilation.Options.OutputKind.IsNetModule();
internal static bool HasSourceLocation(this ISymbol symbol)
{
foreach (var location in symbol.Locations)
{
if (location.IsInSource)
{
return true;
}
}
return false;
}
}
}
......@@ -1672,18 +1672,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Sub
Friend Function ShouldAddEvent(symbol As Symbol) As Boolean
If EventQueue Is Nothing Then
Return False
End If
For Each location As Location In symbol.Locations
If location.SourceTree IsNot Nothing Then
Debug.Assert(AllSyntaxTrees.Contains(location.SourceTree))
Return True
End If
Next
Return False
Return EventQueue IsNot Nothing AndAlso symbol.HasSourceLocation()
End Function
Friend Sub SymbolDeclaredEvent(symbol As Symbol)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册