What are some of the strategies that are used when implementing FxCop / static analysis on existing code bases with existing violations? How can one most effectively reduce the static analysis violations?
...
Hi,
In a project I'm working on FxCop shows me lots of (and I mean more than 400) errors on the InitializeComponent() methods generated by the Windows Forms designer. Most of those errors are just the assignment of the Text property of labels.
I'd like to suppress those methods in source, so I copied the suppression code generated by F...
In Kathleen Dollard's recent blog post, she presents an interesting reason to use nested classes in .net. However, she also mentions that FxCop doesn't like nested classes. I'm assuming that the people writing FxCop rules aren't stupid, so there must be reasoning behind that position, but I haven't been able to find it.
...
I just tried FxCop. It does detect unused private methods, but not unused public. Is there a custom rule that I can download, plug-in that will detect public methods that aren't called from within the same assembly?
...
I am taking on a maintenance team and would like to introduce tools like FxCop and StyleCop to help improve the code and introduce the developers to better programming techniques and standards. Since we are maintaining code and not making significant enhancements, we will probably only deal with a couple of methods/routines at a time whe...
I'm planning to start using FxCop in one of our ongoing project. But, when i tried it with selecting all available rules, it looks like I have to make lots of changes in my code. Being a "team member" I can't right away start making these changes, like naming convention change etc. anyway i would like to start using FxCop with a minimal ...
I must implement a web service which expose a list of values (integers, custom classes etc).
My working solution returns a List<T>, and according to FxCop it is better to return a Collection<T> or ReadOnlyCollection<T>.
If I choose to return a ReadOnlyCollection<T>, the web service shows an error like:
To be XML serializable, types ...
FxCop has the CollectionPropertiesShouldBeReadOnly rule that complains if your class has some kind of collection property that clients can set. Instead, it suggests making the property read-only and supplying a Clear() method and Add() or AddRange() methods for changing the contents of the collection.
I agree that makes for a cleaner an...
I'm using 3.5 SP1 on my machine, while our customers currently use 3.5 without SP1.
I don't know any way in VS2008 to target the solution or project to 3.5 without SP1, only the 3.5 with SP1 I have installed.
If we use functions or constructors not available in 3.5 w/o SP1 the code will not work properly.
That is, I want to detect at c...
I personally don't use FxCop yet. We want to work out the unit testing first before going with code analysis. However, which rules would you permanantly deactivate? Which rules would you deactivate temporarily and in which situation?
...
Pretty simple question: When i have a persistable object, it usually has a property called ID (for abstract classes).
So .. is the naming convention ID or Id?
eg.
public int ID { get; set; }
or
public int Id { get; set; }
cheers :)
PS. This is for .NET btw. FXCop conformat would be a bonus.
...
I am using FxCop and I would like to find all the methods or variables without an access modifier explicitly defined. For example:
class MyClass
{
int myInt = 0;
internal MyClass()
{
}
}
I would like FxCop to warn me that I didn't specify what access modifier will be applied to the variable "myInt" or the class "MyClass"....
1 Dim x as Integer? = Nothing
2 If x = Nothing Then
3 'this is what I think will happen
4 Else
5 'this is what really happens
6 End If
The proper way to write that is "If x Is Nothing".
Is there a FXCop rule that checks for this? Or better yet, can someone show me how to write my own?
Jonathan
...
I wonder if people (meaning the company/developers) really care about having [SuppressMessage] attributes lying around in the shipping assemblies.
Creating separate configs in the Project files that include CODE_ANALYSIS in Release mode and then yanking it off in the final build seems kind of an avoidable overhead to me.
What'll be the...
I'm trying to adhere to the VS2005 code analysis rules for a new project. I have this method:
public void Dispose()
{
Console.WriteLine("Dispose() called");
Dispose( true );
GC.SuppressFinalize(this);
}
(The console call will become a log4net call at some point, and we're always interested in logging dispose for some of o...
I am looking for an example of a FxCop Rule that inspects the properties of controls created.
Has anyone seen one? Or know how to respond to a property set in the FxCop SDK?
Rich.
...
When using FxCop 1.36 for a WPF application with a single window that has yet to be modified, I get the InterfaceMethodsShouldBeCallableByChildTypes error with the following details:
Target : #System.Windows.Markup.IComponentConnector.Connect(System.Int32,System.Object) (IntrospectionTargetMember)
Resolution : "Make 'Ma...
Is it possible to exclude a complete namespace from all FxCop analysis while still analyzing the rest of the assembly using the SuppressMessageAttribute?
In my current case, I have a bunch of classes generated by LINQ to SQL which cause a lot of FxCop issues, and obviously, I will not modify all of those to match FxCop standards, as a l...
How is it possible to get the FxCop custom dictionary to work correctly?
I have tried adding words to be recognised to the file 'CustomDictionary.xml', which is kept in the same folder as the FxCop project file. This does not seem to work, as I still get the 'Identifiers should be spelled correctly' FxCop message, even after reloading ...
I want to create extra rules in FXCop. Custom Rules to help ensure specific best practices like checking against inline sql.
I'm really looking for good resources and examples. Thanks!
...