Skip to content
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 code should be allowed to use Obsolete API without warning #1055

Open
5 tasks done
WhiteBlackGoose opened this issue Aug 4, 2021 · 6 comments
Open
5 tasks done

Comments

@WhiteBlackGoose
Copy link

WhiteBlackGoose commented Aug 4, 2021

For example,

[<Obsolete>]
let someFunc ... =

[<Obsolete>]
let anotherFunc ... =
    ...
    someFunc ...     // FS0044 about using obsolete methods. But I'm proposing to not emit it here
    ...

let anotherFunc ... =
    ...
    someFunc ...     // FS0044 about using obsolete methods. Makes sense, because we didn't mark it as obsolete. The analyzer can suggest "It is not recommended to use Obsolete functions in relevant functions. Mark it as Obsolete or remove Obsolete API from it"
    ...

Pros and Cons

The advantage, clearly, is that now we don't have to rewrite obsolete API's implementation with new functions (since it's anyway obsolete - unsupported).

Extra information

Estimated cost (XS, S, M, L, XL, XXL): S

Related suggestions: this suggestion may let us to nowarn locally, which is not similar to what I'm proposing, but can partially resolve the issue.

Affidavit (please submit!)

Please tick this by placing a cross in the box:

  • This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
  • I have searched both open and closed suggestions on this site and believe this is not a duplicate
  • This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.

Please tick all that apply:

  • This is not a breaking change to the F# language design
  • I or my company would be willing to help implement and/or test this

For Readers

If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.

@dsyme
Copy link
Collaborator

dsyme commented Aug 10, 2021

This seems reasonable - is there any existing practice for this in C# or other languages?

@WhiteBlackGoose
Copy link
Author

C# has something like this.

[Obsolete]
public class C {
    
    // no warning because C is obsolete
    public static void Main() 
        => A();
    
    [Obsolete]
    public static void A() {}
}


public class C1 {
    
    // warning because C1 is not obsolete
    public static void Main() 
        => A();
    
    [Obsolete]
    public static void A() {}
}


public class C2 {
    
    [Obsolete]
    // no warning because Main is obsolete
    public static void Main() 
        => A();
    
    [Obsolete]
    public static void A() {}
}

See Sharplab

@Happypig375
Copy link
Contributor

Also VB.NET

Imports System

<Obsolete>
Public Class C
    
    ' no warning because C is obsolete
    Public Shared Sub Main() 
        A()
    End Sub
    
    <Obsolete>
    Public Shared Sub A()
    End Sub
End Class


public class C1
    
    ' warning because C1 is not obsolete
    Public Shared Sub Main() 
        A()
    End Sub
    
    <Obsolete>
    Public Shared Sub A()
    End Sub
End Class


public class C2
    
    ' no warning because Main is obsolete
    <Obsolete>
    Public Shared Sub Main() 
        A()
    End Sub
    
    <Obsolete>
    Public Shared Sub A()
    End Sub
End Class

Sharplab

@WhiteBlackGoose
Copy link
Author

That's already a design issue, so I guess it should be redirected to the draft PR for this suggestion.

@dsyme
Copy link
Collaborator

dsyme commented Aug 10, 2021

OK will mark as approved

@dsyme dsyme changed the title Methods, marked with Obsolete, should be allowed to use Obsolete API with no warning Obsolete code should be allowed to use Obsolete API without warning Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants