[Mono-bugs] [Bug 665171] New: AvoidVisibleFieldsRule only looks at [SuppressMessage] metadata at get / set or add / remove
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Jan 18 11:01:34 EST 2011
https://bugzilla.novell.com/show_bug.cgi?id=665171
https://bugzilla.novell.com/show_bug.cgi?id=665171#c0
Summary: AvoidVisibleFieldsRule only looks at [SuppressMessage]
metadata at get / set or add / remove
Classification: Mono
Product: Mono: Tools
Version: 2.10.x
Platform: 64bit
OS/Version: Windows 7
Status: NEW
Severity: Normal
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.634.0 Safari/534.16
FxCop allows a suppression for NonConstantFieldsShouldNotBeVisible to be setup
like this:
[SuppressMessage("Microsoft.Usage",
"CA2211:NonConstantFieldsShouldNotBeVisible", Justification="Add/remove is
thread-safe for events in .NET.")]
public static EventHandler<SimpleAuthenticationFailureEventArgs>
AuthenticationFailure;
However, Gendarme fails to look at this metadata. It expects a suppression to
occur at the add/remove or get/set level.
public static EventHandler<SimpleAuthenticationFailureEventArgs>
AuthenticationFailure
{
[SuppressMessage("Microsoft.Usage",
"CA2211:NonConstantFieldsShouldNotBeVisible", Justification="Add/remove is
thread-safe for events in .NET.")]
add {}
[SuppressMessage("Microsoft.Usage",
"CA2211:NonConstantFieldsShouldNotBeVisible", Justification="Add/remove is
thread-safe for events in .NET.")]
remove {}
}
Reproducible: Always
Steps to Reproduce:
1.Run Gendarme on attached assembly with ruleset EPS
2.
3.
Actual Results:
2. AvoidVisibleFieldsRule
Problem: This type contains visible instance fields. A field should be an
implementation detail and encapsulated within a property or method.
* Severity: Medium, Confidence: Total
* Target: EPS.Web.Authentication.SimpleAuthenticationFailureHandler
* Location:
System.EventHandler`1<EPS.Web.Authentication.SimpleAuthenticationFailureEventArgs>
EPS.Web.Authentication.SimpleAuthenticationFailureHandler::AuthenticationFailure
* Source:
C:\Source\Common\source\EPS.Web.Authentication\SimpleAuthenticationFailureHandler.cs(≈18)
* Details: Field 'AuthenticationFailure' should be private or internal and
itsvalue accessed through a property.
Solution: Use a property or method instead.
More info available at:
https://github.com/spouliot/gendarme/wiki/Gendarme.Rules.Design.AvoidVisibleFieldsRule(2.10)
Expected Results:
No defect.
--
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