-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Annotate unsupported APIs in System.Reflection #50529
Comments
Notes need to consider: If the API has an issue associated with future support we are not suggesting to add [Obsolete], we need to make sure that we are not gonna support the API ever and related issue should be closed, then we can add [Obsolete] |
While annotating APIs in Please let me know if you have any issue/comment with Obsoleting |
Have we been obsoleting types, as opposed to just their ctors (and specific methods, when needed)? I thought we generally didn't like putting the marker on the type itself. |
We did obsolete some types in .NET 5, particularly in CAS. |
|
So long as we're not doing something new, seems fine with me. Someone who has a utility method for working with one that wants it to stick around in both netstandard and net(core) compiles (to avoid surface area reduction problems) can just suppress it. They'd have to anyways, if all the members are also Obsolete. In my head, the "nicest" thing is to obsolete the ctors (after making them throw) (and any property/method that returns one), and leave the type and methods as unannotated. You'll never get one in Core, so it doesn't matter that the member would throw, but it avoids cross-compile noise. But then it's annoying to us because the tool needs to understand that pattern, or except types on a one-off basis. Since it's not (to my knowledge) a type with any significant usage, the noise to the handful using it is probably fine. |
Yeah, that could be less breaking change, then probably leave |
Spoke with Buyaa offline. We may need to revert the change to the internal AssemblyName ctor since it has ripple effects throughout the native reflection stack. But that's doesn't impact the larger goal of getting these annotations visible to our users, and we can always do this cleanup later when we have some free cycles. |
We didn't used to because types can be very noisy. Since we can now provide diagnostic IDs, I don't see an issue with obsoleting types. In fact, I much prefer that over obsoleting .ctors because it expresses the intent more clearly. |
@terrajobst I might be misunderstood, but didn't we checked in the last meeting that Obsoleting with diagnostic ID was also a warning at the same level? Which makes me think it still will be very noisy. Anyway, in case we Obsolete the type with ID what diagnostic ID i should use? |
The PR for obsoleting the API should include adding the API to the table in the list of obsoletions document. And you can just claim the next |
Thanks, Jeff, so noise will be reduced not by the warning count/level, but because it can be suppressed by the custom diagnostic ID without affecting other Obsoletions. I have got another question, should we also suggest adding |
Not sure I understand. Obsoleting a type can cause multiple warnings because it basically warns whenever the type is used, even if passthrough. Before, the user could either #pragma suppress each occurrence (not practical) or disable obsoletion in its entirety (which we don't want). Now we can give the type (or family of types) as single diagnostic ID which makes a single, targeted suppression possible. |
If we not obsolete the entire type I will not need to touch the references in the AssemblyName type, it doesn't make sense to disable warnings for all those references as they are not really used. If we want to do a clean up of unused |
As part of #47228 i am running an analyzer to detect APIs throwing PNSE but not annotated with Obsolete/SupportedOSPlatform/UnsupportedOSPlatform attributes, we need to annotate them so that developers get warnings when they use them unexpectedly
For now, I have results only cross-platform and .Net 5.0 or higher builds, analysis of targeted builds or lower env are coming soon where more APIs could be detected
Note: We are suggesting to add [Obsolete] with the corresponding message for APIs supported in .Net framework but not supported in .NetCore, if it is only supported on a specific platform(s) consider adding [SupportedOSPlatform("platformName")] or if it is unsupported on a specific platform(s) [UnsupportedOSPlatform("platformName")] attribute instead
Suggestions for changing the exception is optional
cc @jeffhandley @terrajobst @GrabYourPitchforks
The text was updated successfully, but these errors were encountered: