VB.NET - ReadOnly and WithEvents

Thread is closed for posting
2 posts, 0 answers
  1. Timothy
    Timothy avatar
    1 posts
    Member since:
    May 2012

    Posted 03 May 2012 Link to this post

    JustCode gives a warning that a "Field MyTimer can be made readonly".  However, the VB keywords WithEvents and ReadOnly cannot be used together.  The auto-fix replaces the WithEvents keyword with the ReadOnly keyword.  That isn't what I want.  If I want to use WithEvents then I shouldn't  get this warning.  I don't know why VB won't let you use WithEvents and ReadOnly together, but it won't.  

    Reproduction Plan:
    Private WithEvents MyTimer As ProcessSolutions.Timers.Timer

    The MyTimer field is set in the constructor

    Don't show the "can be readonly" fix if WithEvents is used.
    Maybe have a quick fix that removes the WithEvents and Handles keywords and creates AddHandler statements in the constructor.
  2. Stefan Avramov
    Stefan Avramov avatar
    41 posts

    Posted 04 May 2012 Link to this post


    Thanks for the feedback. We logged this for fixing and I created a PITS item for you to track its progress. You also receive some Telerik Points.

    All the best,
    Stefan Avramov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top