sergeyteplyakov / exceptionanalyzer Goto Github PK
View Code? Open in Web Editor NEWRoslyn-based analyzer for exception handling best practices
License: MIT License
Roslyn-based analyzer for exception handling best practices
License: MIT License
But only for catch {}
and catch(Exception) {}
.
This is a very simple warning with a fix that adds throw;
.
Don't know about quick fix: method should be splitted in two (or switched to Contract.Requires)
Quick fix could be: replace with GetAwaiter().GetResult()
.
On both nuget.org: https://www.nuget.org/packages/ExceptionAnalyzer/
and in the README.md, exception is spelled as "excpetion" in a few places.
Hi Sergey,
I'm started making something like that https://github.com/leotsarev/hardcode-analyzer/tree/master/Tsarev.Analyzer.Exceptions
and after that I stumbled upon your project.
Will you willing to accept some pull requests and package your analyzer for Nuget.org?
Appveyor is free-of-charge solution to CI for open source C#.
Would be nice to have this tool in VS2017.
Tool should not warn for this code:
public int Foo(int n)
{
try
{}
catch(Exception)
{
throw;
return 42; // <----
}
return 42;
}
Especially for generic exceptions such as Exception
, ApplicationException
etc.
Quick fix: replace with System.Exception
.
For this input:
try {}
catch //foo
{}
Current version incorrectly transforms to:
try {}
catch //foo
(Exception ex)
{}
ApplicationException
considered useless.
In most simple form the rule can tell that the method throws, in more advanced form analyzer can deal with current class and suggest attributes for public methods even when private methods throw.
THere is no way to look deeper, but even in those cases the rule could be useful.
void Foo()
{
try { Console.WriteLine();}
catch {Console.WriteLine();}
}
Possible quick fixes:
Quick fix: ex.Message.
Especially true for method that swallow exception.
Quick fix: remove ex;
Consider following scenario:
catch (SomethingException ex) {
log.Error(ex);
return false;
}
Why do you mark this as error? If exception already observed & logged, why this is a smell?
Quick fix should be the same as for iterator blocks.
Don't know is it possible to implement! But would be good to try!
Fix: add exception type name.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.