Nullable enable analyzer driver#46409
Conversation
5419a66 to
fd826a5
Compare
fd826a5 to
b819e2f
Compare
sharwell
left a comment
There was a problem hiding this comment.
I've completed two files so far. It's going to take me a long time to get through the rest of this because there are so many unrelated changes.
Can you please clarify? Removing |
How do we know this? Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs:1153 in b819e2f. [](commit_id = b819e2f, deletion_comment = False) |
This probably should be an assertion (I don't see a related check in this method) #Closed Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs:854 in b819e2f. [](commit_id = b819e2f, deletion_comment = False) |
The only place where the method was being called had a null check for |
Should we prefer a Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs:228 in 21a46d1. [](commit_id = 21a46d1, deletion_comment = False) |
Why is this safe? I would prefer an assert. #Closed Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs:250 in 21a46d1. [](commit_id = 21a46d1, deletion_comment = False) |
We create newCompilation explicitly with an event queue just a couple of lines above: roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs Lines 694 to 701 in 0d3cf92 |
Same as previous comment - this is in a private method with all callers in this file. |
|
Done review pass (commit 2). In future, I'd prefer if nullable enable PRs were a bit smaller: when I review a file that has been |
Thanks, let me add a test. |
| // Verify IsDiagnosticAnalyzerSuppressed does not throw an exception when 'onAnalyzerException' is null. | ||
| var analyzer = new AnalyzerThatThrowsInSupportedDiagnostics(); | ||
| var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); | ||
| _ = CompilationWithAnalyzers.IsDiagnosticAnalyzerSuppressed(analyzer, options, onAnalyzerException: null); |
There was a problem hiding this comment.
@jcouv I added this unit test for null onAnalyzerException value passed down to the analyzer executor, but I could not get the test to fail even on master. NRE seems to be silently swallowed below:
roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs
Lines 1582 to 1589 in 63506f6
At least now we ensure no NRE is thrown in the above code by the analyzer executor for this test. #Closed
There was a problem hiding this comment.
|
Thanks everyone for the reviews! I think I have responded to and/or addressed all feedback, please let me know if I missed anything. |
I was actually thinking In reply to: 672296393 [](ancestors = 672296393) Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs:1926 in 21a46d1. [](commit_id = 21a46d1, deletion_comment = False) |
That doesn't really matter for flow analysis though. We assume exceptions can occur at any time, for any reason. The cancellation token could have already been cancelled, for example, or the source for the cancellation token have been disposed. In reply to: 672244161 [](ancestors = 672244161,672240283,671516788) Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs:417 in b819e2f. [](commit_id = b819e2f, deletion_comment = False) |
My question is not about flow analysis, but whether we can actually get here with a Maybe the answer is "we're want to be defensive to future code changes" (ie. just to be safe), and that's fine. In reply to: 673013938 [](ancestors = 673013938,672244161,672240283,671516788) Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs:417 in b819e2f. [](commit_id = b819e2f, deletion_comment = False) |
If the token is cancelled, it throws. See https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.run?view=netcore-3.1#System_Threading_Tasks_Task_Run_System_Action_System_Threading_CancellationToken_. In reply to: 673016668 [](ancestors = 673016668,673013938,672244161,672240283,671516788) Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs:417 in b819e2f. [](commit_id = b819e2f, deletion_comment = False) |
…be null at analyzer driver dispose for early cancellation.
Thanks for clarifying. That's what I was curious about. In reply to: 673059936 [](ancestors = 673059936,673016668,673013938,672244161,672240283,671516788) Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs:417 in b819e2f. [](commit_id = b819e2f, deletion_comment = False) |
@mavasani I didn't see a resolution In reply to: 671530244 [](ancestors = 671530244) Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs:854 in b819e2f. [](commit_id = b819e2f, deletion_comment = False) |
In reply to: 673108299 [](ancestors = 673108299,671530244) Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs:854 in b819e2f. [](commit_id = b819e2f, deletion_comment = False) |
No description provided.