Git Product home page Git Product logo

wintellect.analyzers's Introduction

Wintellect.Analyzers

At Wintellect, we love anything that will help us write the best code possible. Microsoft's new Roslyn compiler is a huge step in that direction so we had to jump in and start writing analyzers and code fixes we've wanted for years. Feel free to fork and add your own favorites. We'll keep adding these as we think of them.

To add these analyzers to your project easily, use the NuGet package. In the Visual Studio Package Manager Console exeute the following:

Install-Package Wintellect.Analyzers

Design Analyzers

AssembliesHaveCompanyAtrribute

This warning ensures you have the AssemblyCompanyAttribute present and a filled out value in the parameter.

AssembliesHaveCopyrightAtrribute

This warning ensures you have the AssemblyCopyrightAttribute present and a filled out value in the parameter.

AssembliesHaveDescriptionAtrribute

This warning ensures you have the AssemblyDescriptionAttribute present and a filled out value in the parameter.

AssembliesHaveTitleAtrribute

This warning ensures you have the AssemblyTitleAttribute present and a filled out value in the parameter.

CatchBlocksShouldRethrow

This informational analyzer will report when you have a catch block that eats an exception. Because exception handling is so hard to get right, this notification is important to remind you too look at those catch blocks.

Documentation Analyzers

ExceptionDocumentationMissing

If you have a direct throw in your code, you need to document it with an tag in the XML documentation comments. A direct throw is one where you specifically use the throw statement in your code. This analyzer does not apply to private methods, only accessibility levels where calls outside the defining method can take place.

SuppressionMessageMissingJustification

If you are using the SuppressionMessage attribute to suppress Code Analysis items, you need to fill out the Justification property to explicitly state why you are suppressing the report instead of fixing the code.

Formatting Analyzers

IfAndElseMustHaveBraces

If and else statements without braces are reasons for being fired. This analyzer and code fix will help you keep your job. :) The idea for this analyzer was shown by Kevin Pilch-Bisson in his awesome TechEd talk. We just finished it off.

Performance Analyzers

AvoidCallingMethodsWithParamArgsInLoops

This informational level check gives you a hint that you are calling a method using param arrays inside a loop. Because calls to these methods cause memory allocations you should know where these are happening.

Usage Analzyers

AvoidPredefinedTypes

The predefined types, such as int, should not be used. You want to be as explicit about types as possible to avoid confusion.

CallAssertMethodsWithMessageParameter

Calling the one parameter overload of Debug.Assert is a bad idea because they will not show you the expression you are asserting on. This analyzer will find those calls and the code fix will take the asserting expression and convert it into a string as the second parameter to the two parameter overload of Debug.Assert.

ClassesShouldBeSealed

When creating new classes, they should be declared with the the sealed modifier.

ReturningTaskRequiresAsync

If you are returning a Task or Task from a method, that method name must end in Async.

UseDebuggerDisplay

An analyzer and code fix for inserting DebuggerDisplayAttribute onto public classes. The debugger uses the DebuggerDisplayAttribute to display the class in the expression evaluator (watch/autos/locals windows, data tips) so you can see the important information quickly. The code fix will pull in the first two properties (or fields if one or no properties are present). If the class is derived from IEnumerable, it will default to the count of items.

wintellect.analyzers's People

Contributors

johnwintellect avatar mozts2005 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.