-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Obsolete Regex.CompileToAssembly #50535
Comments
Tagging subscribers to this area: @eerhardt, @pgovind Issue DetailsAs 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 envs are coming soon which could detect more APIs and will be added here
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
cc @jeffhandley @terrajobst @GrabYourPitchforks
|
Sorry, seems we should add [obsolete] into Regex.CompileToAssembly overloads instead |
If we decide to never implement #30153 |
That was my concern not adding |
I hadn't heard any discussions about that, and I'm not sure I've ever seen us do that. @terrajobst, do we obsolete things even if we think we may want to unobsolete them in the future? I would think we'd only want to obsolete things if we firmly believe they shouldn't be used now or any time in the future (obviously we could change our minds, but based on the knowledge we have at that time, we think it's a permanent thing). |
I asked the question of "why not?" which probably came across as "we can." I don't know of us ever doing it. Do we have any other options here?
|
Maybe it is time to say we will not do #30153. Source generators are the new way. |
@stephentoub @terrajobst We have un-obsoleted APIs before (in Full Framework, in fact!) in aspnet. I don't remember offhand what API it was since I'd need to diff all the SDK ref asms, but I think it was something like we wanted people to stop using some specific API, then we realized later that it was still popular in some scenario and we didn't have a good alternative, so we un-obsoleted it. So there's precedent, at least. |
This is the important part. It's one thing to say we made a mistake obsoleting something and then undo that mistake. It's another to say "until we implement xyz, we'll temporarily obsolete it". We shouldn't do the latter. It weakens the meaning of obsolete. |
Makes sense, @stephentoub what you think about @danmoseley's point? If we decide not to do #30153 we can obsolete it. |
FWIW, I think this is what we should do and mark these APIs as obsolete. If we realize down the road that source generators won't get us a like for like replacement of |
[Brief Meeting Note]:
For the APIs in this issue, we are leaving them unannotated until we decide to not support them for sure. @tannergooding will work on that |
I think |
We have talked about a variant of using empty constructor for this too, anyway, |
I assume our plan for 6.0 is
And we should just move this issue to 7.0. Is that a fair assumption? |
namespace System.Text.RegularExpressions
{
public partial class Regex
{
[Obsolete("This API isn't supported anymore. Please use source generated regexes instead.", DiagnosticId = "TBD")]
public static void CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname);
[Obsolete("This API isn't supported anymore. Please use source generated regexes instead.", DiagnosticId = "TBD")]
public static void CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname, CustomAttributeBuilder[]? attributes);
[Obsolete("This API isn't supported anymore. Please use source generated regexes instead.", DiagnosticId = "TBD")]
public static void CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname, CustomAttributeBuilder[]? attributes, string? resourceFile);
}
[Obsolete("This API isn't supported anymore. Please use source generated regexes instead.", DiagnosticId = "TBD")]
public partial class RegexCompilationInfo
{
}
} |
EDIT 9/28/2021 by @stephentoub:
Now that for .NET 7 we have a regex source generator, and as there are no plans to enable CompileToAssembly (which has been and continues to throw PlatformNotSupportedException in Core), we should just obsolete it. This means obsoleting these members:
as well as the whole
RegexCompilationInfo
class: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 builds, analysis of targeted builds are coming soon which could detect more APIs and will be added here
Note: We are suggesting adding [Obsolete] for the APIs only supported in .Net framework but not supported in .NetCore, with the corresponding Message, DiagnosticId, and UrlFormat
runtime/src/libraries/System.Net.Requests/src/System/Net/AuthenticationManager.cs
Line 17 in cecc76a
EDIT: Annotating internal API is useless, we should add [Obsolete] into Regex.CompileToAssembly(...) overloads instead
cc @jeffhandley @terrajobst @GrabYourPitchforks
The text was updated successfully, but these errors were encountered: