Add analyzer to prevent use of blocking synchronous APIs#96
Add analyzer to prevent use of blocking synchronous APIs#96Smaug123 wants to merge 6 commits intoG-Research:mainfrom
Conversation
| @@ -1,41 +1,42 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project Sdk="Microsoft.NET.Sdk"> | |||
| <PropertyGroup> | |||
There was a problem hiding this comment.
The scaffolding script reformatted this file.
| <Compile Include="ImmutableCollectionEqualityAnalyzerTests.fs" /> | ||
| <Compile Include="TypedInterpolatedStringsAnalyzerTests.fs" /> | ||
| <Compile Include="DisposedBeforeAsyncRunAnalyzerTests.fs" /> | ||
| <Compile Include="SyncBlockingAnalyzerTests.fs" /> |
There was a problem hiding this comment.
This is the only actually-changed line, and it's new.
|
Interested in what @G-Research/rqf have to say on this |
Damn, that is quite impressive. This looks good. |
It helps that the analyser is very simple and is similar to existing ones. It duplicated the comment-suppression code which I manually factored out into that other PR, and it took quite a bit of (autonomous) trial and error to write the tests; I told it to mimic the existing tests, but its first attempt was broken in a number of ways (eg it got the wrong names for Async.RunSynchronously) and it took perhaps ten minutes to fix it by iterating on an fsx file. In general I have had pretty poor results from Opus when it comes to actually writing code in F#, although it has a better knowledge of the dotnet runtime than all but the best maintainers, I'd say - its internal knowledge completely eclipses mine, so I generally use it as a vastly better interactive documentation source. |
| let Code = "GRA-SYNCBLOCK-001" | ||
|
|
||
| [<Literal>] | ||
| let SwitchOffComment = "synchronous blocking call allowed" |
There was a problem hiding this comment.
Is the scope of this comment the next line or something broader (or narrower)?
For example, would I have to do?:
foo
bar
// synchronous blocking call allowed
baz.Result
There was a problem hiding this comment.
Yeah, it's currently specific to the line immediately before. We could totally do better.
|
This is cool, I can't think of another case where it would useful to call |
|
I've implemented this in WoofWare.FSharpAnalyzers, which is more opinionated; I'll close this. |
The "Initial implementation" and "Tests" commits were almost entirely produced by Claude Opus.
This PR is something of a request for comment; it's not completely clear to me that it's a desirable analyzer in general. But we've been caught out a couple of times recently by this.