-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Analyzer for methods with PlatformNotSupportedException body but missing platform attributes #42967
Comments
Tagging subscribers to this area: @safern, @ViktorHofer |
Do I understand the following correctly?
|
@jeffhandley correct |
Plus to the @jeffhandley's list:
Suggested Category: Interoperability |
Even the analyzer implementation could be small applying it to runtime repo and fixing the warnings might need a lot more work, increasing size to medium |
Because we don't currently have the ability to mark things as OS-specific based on parameter input, it can only be reliable for methods that are entirely When it is possible to do something more complicated the analyzer should not warn if the method is declared |
@marek-safar @terrajobst Until we get through #44922 and find ways to handle all of the conditional PNSE scenarios, an analyzer warning for PNSE bodies would be too noisy. My understanding is that the APIs we've marked with If we do revisit this analyzer proposal, we would likely want the diagnostic to surface on the line of code throwing the |
That's not correct. We did a manual pass for one platform (and we missed many places) in .net5 and will be doing another one in .net6 for different platforms and another one in the future. Having a reliable tool/way to do that is beneficial over grep for throw and manual edits. I'm also not sure I understand what would be noisy on a one-line throw PNSE body detection. |
The one-line throw PNSE body detection could be done if we also have the analyzer respect Would the value of the analyzer for one-liners be mostly for the existing cases, or to guard against us writing more of the one-liners? I don't know common it's going to be with the mobile platforms for us to introduce new one-liners. |
FWIW: If it makes sense to do as an internal analyzer there's nothing in the API review "no" that impedes that. Once it's done we can then decide that it makes sense as a public analyzer and move the code. |
Right, but the attribute is viral and the leaf nodes are public APIs... |
Most PNSE in runtime are one liners and I think it's going to stay this way. I cannot tell how many are going to be added (wild guess between 10 and 100) but it won't be zero in every upcoming release. |
Related: #47228 |
Also related #44916. |
Describe the problem you are trying to solve
In .NET5 new attributes were introduced to support CA1416 analyzer rule to detect when unsupported APIs are called. To make the analyzer more effective existing libraries need to annotate their code with
UnsupportedOSPlatformAttribute
orSupportedOSPlatformAttribute
for the analyzer to be able to work.Describe suggestions on how to achieve the rule
The implementation could be as simple as check for throw PlatformNotSupportedException body with missing
UnsupportedOSPlatformAttribute
orSupportedOSPlatformAttribute
anywhere in the method hierarchy.@jeffhandley @terrajobst
EDIT: This should also include the work applying the rule to the runtime repo and addressing the warnings that appear.
The text was updated successfully, but these errors were encountered: