[Mono-bugs] [Bug 669192] New: New Rule - Detect Misuse of EventHandler field without preceding 'event' keyword to have compiler emit thread-safe add/remove
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Feb 3 08:24:37 EST 2011
https://bugzilla.novell.com/show_bug.cgi?id=669192
https://bugzilla.novell.com/show_bug.cgi?id=669192#c0
Summary: New Rule - Detect Misuse of EventHandler field without
preceding 'event' keyword to have compiler emit
thread-safe add/remove
Classification: Mono
Product: Mono: Tools
Version: 2.10.x
Platform: 64bit
OS/Version: Windows 7
Status: NEW
Severity: Enhancement
Priority: P5 - None
Component: Gendarme
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: ethan_j_brown at hotmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.11 Safari/534.16
This relates to a previous submission -- 665179. There was a bug in my test
code as you'll recall.
https://bugzilla.novell.com/show_bug.cgi?id=665179
When writing code like:
public static event EventHandler<T> MyEvent;
The compiler emits a default add / remove handler that is thread-safe.
If you make a mistake and instead write this code (like I did):
public static EventHandler<T> MyEvent;
The intent of the code is entirely different. No default add/remove is
emitted, and instead there's just a static field on the class, which is bad --
a scenario I can't ever see as intentional.
So I'd like to see AvoidVisibleFieldsRule either be beefed up a bit to include
a message identifying this particular sub-issue, OR perhaps another more
general purpose rule that detects this kind of misuse -- i.e. no add / remove
in the class == some sort of error.
This would apply to public/protected/internal static and instance fields I
would think.
Reproducible: Always
Steps to Reproduce:
1.
2.
3.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list