-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor CommonCompiler.RunCore #23059
Conversation
RunCore previously had a mix of diagnostic reporting methods including lists of Diagnostics, lists of DiagnosticInfos, ConcurrentQueues of Diagnostics, and just printing things directly to the console. This commit tries to simplify things by moving to using Diagnostics and DiagnosticBags wherever possible in the compile+emit phase of RunCore.
ping @dotnet/roslyn-compiler for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨ this looks super good!
@@ -429,6 +429,10 @@ public bool ReportErrors(IEnumerable<Diagnostic> diagnostics, TextWriter console | |||
return hasErrors; | |||
} | |||
|
|||
private bool ReportErrors(DiagnosticBag diagnostics, TextWriter consoleOutput, ErrorLogger errorLoggerOpt) | |||
=> ReportErrors(diagnostics.ToReadOnly(), consoleOutput, errorLoggerOpt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: two empty lines #Closed
@@ -385,7 +385,7 @@ internal static DiagnosticInfo ToFileReadDiagnostics(CommonMessageProvider messa | |||
return diagnosticInfo; | |||
} | |||
|
|||
public bool ReportErrors(IEnumerable<Diagnostic> diagnostics, TextWriter consoleOutput, ErrorLogger errorLoggerOpt) | |||
internal bool ReportErrors(IEnumerable<Diagnostic> diagnostics, TextWriter consoleOutput, ErrorLogger errorLoggerOpt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could IEnumerable be switched to ImmutableArray, or are there callers that still need IEnumerable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They still use IEnumerable
unfortunately.
analyzerCts = null; | ||
reportAnalyzer = false; | ||
analyzerDriver = null; | ||
AnalyzerManager analyzerManager = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think analyzerManager
can be declared at line 660, where it is used.
WithOutputNameOverride(outputName). | ||
WithPdbFilePath(PathUtilities.NormalizePathPrefix(finalPdbFilePath, Arguments.PathMap)); | ||
|
||
// This feature flag is being maintained until our next major release to avoid unnecessary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next major releas [](start = 67, length = 17)
This is not introduced by this PR, but which release is the "next major release". Was it 15.0? Is it 16.0?
Could you file a follow-up issue? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that is this issue: #19592 #Resolved
{ | ||
return GetWin32ResourcesInternal(MessageProvider, arguments, compilation, out errors); | ||
return GetWin32ResourcesInternal(MessageProvider, arguments, compilation, diagnostics); | ||
} | ||
|
||
// internal for testing | ||
internal static Stream GetWin32ResourcesInternal(CommonMessageProvider messageProvider, CommandLineArguments arguments, Compilation compilation, out IEnumerable<DiagnosticInfo> errors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think we could change IEnumerable
to ImmutableArray
in GetWin32ResourcesInternal
and GetWin32Resources
signatures too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with review pass (small suggestions to consider)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks
This is the monolith method for batch compilation in C# and VB.
It is large and confusing. I've tried to make it better by moving to a single
error reporting system for every piece of the pipeline (Diagnostics in DiagnosticBags).
It may be helpful to look at each commit separately.