Skip to content

Commit d9c433e

Browse files
authored
Improve EnC log messages (#73919)
1 parent b4dc2a1 commit d9c433e

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

src/Features/Core/Portable/EditAndContinue/EditSession.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ private static ProjectAnalysisSummary GetProjectAnalysisSummary(ImmutableArray<D
566566
// rude edit detection wasn't completed due to errors that prevent us from analyzing the document:
567567
if (analysis.HasChangesAndSyntaxErrors)
568568
{
569-
return ProjectAnalysisSummary.CompilationErrors;
569+
return ProjectAnalysisSummary.SyntaxErrors;
570570
}
571571

572572
// rude edits detected:
@@ -807,14 +807,14 @@ public async ValueTask<SolutionUpdate> EmitSolutionUpdateAsync(Solution solution
807807
{
808808
if (newProject.FilePath == null)
809809
{
810-
log.Write("Skipping project '{0}' without a file path", newProject.Id);
810+
log.Write("Skipping project '{0}' without a file path", newProject.Name);
811811
continue;
812812
}
813813

814814
var oldProject = oldSolution.GetProject(newProject.Id);
815815
if (oldProject == null)
816816
{
817-
log.Write("EnC state of '{0}' queried: project not loaded", newProject.Id);
817+
log.Write("EnC state of {0} '{1}' queried: project not loaded", newProject.Name, newProject.FilePath);
818818

819819
// TODO (https://github.com/dotnet/roslyn/issues/1204):
820820
//
@@ -836,7 +836,7 @@ public async ValueTask<SolutionUpdate> EmitSolutionUpdateAsync(Solution solution
836836
continue;
837837
}
838838

839-
log.Write("Found {0} potentially changed document(s) in project '{1}'", changedOrAddedDocuments.Count, newProject.Id);
839+
log.Write("Found {0} potentially changed document(s) in project {1} '{2}'", changedOrAddedDocuments.Count, newProject.Name, newProject.FilePath);
840840

841841
var (mvid, mvidReadError) = await DebuggingSession.GetProjectModuleIdAsync(newProject, cancellationToken).ConfigureAwait(false);
842842
if (mvidReadError != null)
@@ -853,7 +853,7 @@ public async ValueTask<SolutionUpdate> EmitSolutionUpdateAsync(Solution solution
853853

854854
if (mvid == Guid.Empty)
855855
{
856-
log.Write("Emitting update of '{0}': project not built", newProject.Id);
856+
log.Write("Emitting update of {0} '{1}': project not built", newProject.Name, newProject.FilePath);
857857
continue;
858858
}
859859

@@ -884,7 +884,14 @@ public async ValueTask<SolutionUpdate> EmitSolutionUpdateAsync(Solution solution
884884

885885
foreach (var changedDocumentAnalysis in changedDocumentAnalyses)
886886
{
887-
if (changedDocumentAnalysis.HasChanges)
887+
if (changedDocumentAnalysis.SyntaxError != null)
888+
{
889+
// only remember the first syntax error we encounter:
890+
syntaxError ??= changedDocumentAnalysis.SyntaxError;
891+
892+
log.Write("Changed document '{0}' has syntax error: {1}", changedDocumentAnalysis.FilePath, changedDocumentAnalysis.SyntaxError);
893+
}
894+
else if (changedDocumentAnalysis.HasChanges)
888895
{
889896
log.Write("Document changed, added, or deleted: '{0}'", changedDocumentAnalysis.FilePath);
890897
}
@@ -893,7 +900,7 @@ public async ValueTask<SolutionUpdate> EmitSolutionUpdateAsync(Solution solution
893900
}
894901

895902
var projectSummary = GetProjectAnalysisSummary(changedDocumentAnalyses);
896-
log.Write("Project summary for '{0}': {1}", newProject.Id, projectSummary);
903+
log.Write("Project summary for {0} '{1}': {2}", newProject.Name, newProject.FilePath, projectSummary);
897904

898905
if (projectSummary == ProjectAnalysisSummary.NoChanges)
899906
{
@@ -912,13 +919,7 @@ public async ValueTask<SolutionUpdate> EmitSolutionUpdateAsync(Solution solution
912919
isBlocked = true;
913920
}
914921

915-
if (projectSummary == ProjectAnalysisSummary.CompilationErrors)
916-
{
917-
// only remember the first syntax error we encounter:
918-
syntaxError ??= changedDocumentAnalyses.FirstOrDefault(a => a.SyntaxError != null)?.SyntaxError;
919-
isBlocked = true;
920-
}
921-
else if (projectSummary == ProjectAnalysisSummary.RudeEdits)
922+
if (projectSummary is ProjectAnalysisSummary.SyntaxErrors or ProjectAnalysisSummary.RudeEdits)
922923
{
923924
isBlocked = true;
924925
}
@@ -977,7 +978,7 @@ async ValueTask LogDocumentChangesAsync(int? generation, CancellationToken cance
977978
}
978979
}
979980

980-
log.Write("Emitting update of '{0}'", newProject.Id);
981+
log.Write("Emitting update of '{0}' {1}", newProject.Name, newProject.FilePath);
981982

982983
var newCompilation = await newProject.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
983984
Contract.ThrowIfNull(newCompilation);

src/Features/Core/Portable/EditAndContinue/EditSessionTelemetry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void LogProjectAnalysisSummary(ProjectAnalysisSummary summary, Guid proje
9292
case ProjectAnalysisSummary.NoChanges:
9393
break;
9494

95-
case ProjectAnalysisSummary.CompilationErrors:
95+
case ProjectAnalysisSummary.SyntaxErrors:
9696
_hadCompilationErrors = true;
9797
break;
9898

src/Features/Core/Portable/EditAndContinue/ProjectAnalysisSummary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ internal enum ProjectAnalysisSummary
1212
NoChanges,
1313

1414
/// <summary>
15-
/// Project contains compilation errors that block EnC analysis.
15+
/// Project contains syntax errors that block EnC analysis.
1616
/// </summary>
17-
CompilationErrors,
17+
SyntaxErrors,
1818

1919
/// <summary>
2020
/// Project contains rude edits.

0 commit comments

Comments
 (0)