-
Notifications
You must be signed in to change notification settings - Fork 789
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
Tracking: Issues & suggestions solvable with Analyzers SDK #16219
Comments
Meaning of the November assignment: To spent time researching the needs and use cases, not really building it yet. |
Is it only about F# specific issues? Also maybe optional analyzer to remind about |
Some suggestions from my work experience
|
Keep in mind that this issue is not to discuss analyzers which will be (may be) a part of sdk/fcs/compiler, etc. |
The purpose of this is to give an overall idea of the set of tasks desired by F# programmers, in order to correctly judge the necessary "analyzing power" of the F# Analyzers SDK, keeping both performance and easy of use in mind. From that perspective, the ideas from @Lanayx are good, as they cover a broader range of language constructs. That being said, the main purpose of this tracking issue is to guide to an SDK design that will enable people to write such analyzers as 3prd party extensions, NOT making those analyzers as part of this repository. |
Just to clarify, I meant those only as examples of analyzers that some people would want to port to F# SDK, hence they could be explored for SDK better designing. Sorry for bad explanation. For example, analyzer for But maybe I'm missing the point of this issue again or going into too much detail :) |
You got the point right, this is good. |
I would also like to add that The Ionide project has no desire to compete with the official F# 9 integration. It exists as a hands-on way to experiment with analyzers right here right now. I find it immensely valuable to consume and create these analyzers as it gives you great insight into what you can get out of analyzers. There currently are two projects that have implemented some analyzers: That last project has implemented some ideas that were discussed in this thread (UnnamedDiscriminatedUnionFieldAnalyzer, IgnoreFunctionAnalyzer, CopyAndUpdateRecordChangesAllFieldsAnalyzer) and can be used today! I really hope this can encourage people to discuss analyzers hands-on. Once analyzers land in F# 9 (which again will take probably another year), the Ionide SDK can be sunset. But at the very least we can already get accustomed to having analyzers as part of our workflow. |
@Lanayx, this could also apply to any method call that returns an object. Some of the analyzers will require custom settings, I don't know if the C# SDK allows any of this, but it would be good for analyzers to come with a default, and through reflection / metadata and a DSL which binds to it, have the ability to configure the analyzers. @nojaf, the effort on ionide SDK are very good, also, it may be better to consider official analyzer SDK is "cooking" but there is no commitment for the next major release; I'd prefer the stuff that ships to handle all the use cases, and come with the right implementation choices. @vzarytovskii, in a discussion thread, I was wondering if the analyzer SDK could inspect the analyzer's used FCS surface area, and through this and hosting several versions of FCS if needed, handle the binary compatibility issue, does that sound like tractable solution? Given how the ionide SDK is laid out (with visitors and higher level APIs), I'm not sure it is feasible / meaningful though. |
I would like to submit #16259: Warn about the use of non-generic collections for consideration. |
Regarding custom settings, it comes to me that an analyzer referencing another one would possibly be able to export a chunk of settings. Say a blacklisted types analyzer would be able to import new types in the list that are exported by other analyzers referencing it. |
Your idea would be somewhat related to having the analyzers distributed as source (or source-like), so that the compiler could investigate them. It is one of the options to investigate. |
Is this a shared mutable state suggestion, or not? :)) |
The API surface analysis would work for binary shipping of analyzers in context of what came to mind when writing the above. I think there are some complexity related to analyzer dependencies that would make shipping them as code a bit more difficult, would need to be doing like Fable, which embeds the source code in the nuget package.
Isolated, and basically, hosting ALL versions of FCS, with an optimization step based on the signature analysis of the analyzers (+ their dependencies...) to only instanciate the minimum set of FCS version hosts, by default. This incurs work on the host, but comes with no cost in terms of FCS versioning (but we keep conservative with breaking change of established APIs there) from version to version and deprecating old analyzers in recent compiler. I think the compatibility layers in FCS itself will add clutter, while having the host dealing with the subtleties and optimizing for runtime performance, would make more sense to me.
It is a bunch of things:
I think there should be formal way to handle it, such as back & forth serialization to command line arguments and a text file format, a way to surface this as UI to tweak it in IDEs, and also, plain F# types (DU & records) to define those settings. |
fsharp/fslang-suggestions#414 for @baronfel, could you help editing the suggestion:
Thanks! |
related: fsharp/fslang-suggestions#806 & #1019 (comment) |
That is an interesting one - unline all the others, it would be aimed for doing "range arithmetics", and not just operating on the typed/untyped trees. Before I had the opinion of source code (and therefore constructs like |
This issue exists to collect existing painpoints which would be solved if an F# Analyzer solution existed.
Warn on unoptimal APIs:
All below could likely be a single analyzer with a project-defined .txt file listing the APIs to warn on
Ban Assert.AreEqual(obj,obj) #14598
Warn non-generic collections #16259
Warn on combination of API + type arguments
Should be also doable with a single analyzer driven by a text file
Ban
ignore<function>
#15880Warning for equality on structs because of boxing #526
Warn specific language constructs
Likely an easy generalization is not possible, those will need their own logic for traversing the (un)typed tree.
The constructs to target are well specifiable, analyzer could register for kinds of nodes to prune irrelevant code
Ban early return from CEs #15759
Ban unnamed DU fields #15665
The text was updated successfully, but these errors were encountered: