This is a migrated thread and some comments may be shown as answers.

VB.NET - ReadOnly and WithEvents

1 Answer 108 Views
Quick Fixes
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Timothy
Top achievements
Rank 1
Timothy asked on 03 May 2012, 09:46 PM
Problem:
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:
Declaration:
Private WithEvents MyTimer As ProcessSolutions.Timers.Timer

The MyTimer field is set in the constructor

Solutions:
Don't show the "can be readonly" fix if WithEvents is used.
or
Maybe have a quick fix that removes the WithEvents and Handles keywords and creates AddHandler statements in the constructor.

1 Answer, 1 is accepted

Sort by
0
Stefan Avramov
Telerik team
answered on 04 May 2012, 03:07 PM
Hi,

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 >>

Tags
Quick Fixes
Asked by
Timothy
Top achievements
Rank 1
Answers by
Stefan Avramov
Telerik team
Share this question
or