locked
Can I disable the BC30668 compiler error resulted in ObsoletedAttribute? RRS feed

  • Question

  • Hi, forums

    I do know invoking a methods labeled by ObsoletedAttribute should bring out a compiler error. 

    But how about the following codes? The caller aslo haved been obsoleted with true as the error parameter. How come it still produces the error?
    It's not a problem in C# codes.

    So how can I disable this annoyying error?

     
     
        <Obsolete("This procedure has been obsoleted"True)> _     
        Public Sub Foo()     
            Foo(0) ' HERE!! error BC30668: 'Public Sub Foo(arg1 As Integer)' is obsolete: 'This procedure has been obsoleted'.     
        End Sub    
        
        <Obsolete("This procedure has been obsoleted"True)> _     
        Public Sub Foo(ByVal arg1 As Integer)     
        
        End Sub    
     


    Thanks a lot.

    Friday, July 18, 2008 4:23 AM

Answers

  • Hi Jinglecat,

    I have made the feedback about this intelligence difference to VB product team. They confirm that "this is a feature request that we’d have to prioritize among other user requests.  It’s something we’ll think about for the next version."  Currently we need to manually modify the code in this scenario. Finally thanks for your advice.

    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Xiaofeng Wang Thursday, July 31, 2008 5:15 PM
    • Unmarked as answer by Xiaofeng Wang Thursday, July 31, 2008 5:15 PM
    • Marked as answer by Xiaofeng Wang Thursday, July 31, 2008 5:15 PM
    Tuesday, July 29, 2008 3:37 PM
    Moderator
  • Hey folks, just want to let you know that we've gone ahead and made this fix and it should appear in Visual Studio 2010 Beta2.

    Thanks,

    Jonathan Aneja
    Program Manager, VB Team
    Program Manager - Visual Basic
    Wednesday, August 19, 2009 2:04 AM
    Moderator

All replies

  • Hi Jinglecat,

    Based on the introduction of the ObsoletedAttribute construtor, the boolean parameter indicates whether the obsolete element usage is considered an error. VB.NET compiler treat this usage as an error, but C# compiler doesn't treat it. It is by design. I don't think that we can disable this feature in VB.NET.

    Best regards,
    Riquel

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, July 21, 2008 1:52 PM
    Moderator
  • Hi, Riquel

    Thanks for your response. I think what you say is right.  But maybe we donot touch the same point.

    When I have deprecated a Foo(ByVal arg1 As Integer method as following:

        <Obsolete("This procedure has been obsoleted"True)> _           
        Public Sub Foo(ByVal arg1 As Integer)           
              
        End Sub    
     

    It makes sense in these codes below.

        Public Sub Bar()           
            Foo(0) ' OK! It is doing its right thing to bring out an error BC30668.     
        End Sub        
     

    Howerver, I dont indeedly want to see the error BC30668 in these codes below:

         
        <Obsolete("This procedure has been obsoleted"True)> _        
        Public Sub Foo()        
            Foo(0) ' HERE!! error BC30668: 'Public Sub Foo(arg1 As Integer)' is obsolete: 'This procedure has been obsoleted'.        
                   ' My method has been obsoleted.  
        End Sub    
     

    You can see I have aslo deprecated the caller.  So I dont think it should produce the error in the calling hierarchy. The C# compiler have been doing the right thing.  It' right?

    Thanks.

    Wednesday, July 23, 2008 4:39 AM
  • Especially, how can I do if I want to just obsolete some members but not to remove them from my library when upgrading a legacy system?

    In my scenario above, if I both obsolete the Sub Foo(ByVal arg1 As Integer) procedure and its override version, Sub Foo() with the identicial constructors of ObsoleteAttribute in the same time, the VB.NET compiler should been smart to resolve this calling hierarchy.

    This feature which C# complier supports is cool? Isn't it?
    Wednesday, July 23, 2008 5:40 AM
  • Hi Jinglecat,

    I have made the feedback about this intelligence difference to VB product team. They confirm that "this is a feature request that we’d have to prioritize among other user requests.  It’s something we’ll think about for the next version."  Currently we need to manually modify the code in this scenario. Finally thanks for your advice.

    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Xiaofeng Wang Thursday, July 31, 2008 5:15 PM
    • Unmarked as answer by Xiaofeng Wang Thursday, July 31, 2008 5:15 PM
    • Marked as answer by Xiaofeng Wang Thursday, July 31, 2008 5:15 PM
    Tuesday, July 29, 2008 3:37 PM
    Moderator
  • Hi Riquel,

    Thanks for your helps.

    I think most of VB.NET folks are looking forward to this feature.
    Thursday, July 31, 2008 5:15 PM
  • Hey folks, just want to let you know that we've gone ahead and made this fix and it should appear in Visual Studio 2010 Beta2.

    Thanks,

    Jonathan Aneja
    Program Manager, VB Team
    Program Manager - Visual Basic
    Wednesday, August 19, 2009 2:04 AM
    Moderator
  • Good news. I would see it later on my VS 2010 at home.


    ---------

    A great job. It has really been fixed in Beta2.


    Xiaofeng Wang | Be live with Coding | Beijing P.R.C
    • Edited by Xiaofeng Wang Sunday, August 23, 2009 4:38 AM Added Text
    Wednesday, August 19, 2009 2:11 AM