Just a thought ...

3 posts, 0 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 15 Jan 2010 Link to this post

    I've just been looking at some code that I've inherited and had this ...
    public partial class MyControl : System.Web.UI.UserControl 
        RadAjaxManager localManager; 
     
        protected void Page_Load(object sender, EventArgs e) 
        { 
            localManager = RadAjaxManager.GetCurrent(Page); 
            ... 
        } 
         
        ... 
         
        void SomeMethod()  
        { 
            ... 
            RadAjaxManager localManager; 
            localManager = RadAjaxManager.GetCurrent(Page); 
            localManager.ResponseScripts.Add(...); 
        } 
     

    Now, OK, it's perfectly legal but I can't imagine it is the sort of thing a professional developer would do on purpose, so I wonder if this kind of hiding an object with a wider scope is something we should expect JC to at least warn us about when it does happen.

    As I say, just a Friday afternoon thought.

    --
    Stuart

  2. Jordan
    Admin
    Jordan avatar
    123 posts

    Posted 19 Jan 2010 Link to this post

    Hello Stuart,

    That's a good idea. I have added to our product backlog list to show warnings as "Local variable VAR hides field FIELD" in such cases.

    All the best,
    Jordan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 19 Jan 2010 Link to this post

    Cool.

    I am a JustCode user and the warning "Local variable VAR hides field FIELD" was my idea. :-)

    --
    Stuart
Back to Top