-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add static analyzers #126
Add static analyzers #126
Conversation
Add source analyzers that could find issues with the code at build time through static analysis.
Disable warnings that do not apply to tests or benchmarks.
Remove redundant methods that are no longer used since the interface was changed to remove a number of methods.
Make methods and class static where instance members are not used.
Fix warnings in the integration tests related to string comparisons and case sensitivity.
Fix unused instance warnings by using Assert.Throws() that takes a Func<T> instead of an Action.
Fix warnings about unused members/parameters.
Fix warning for the way IDisposable is implemented by making the internal timer type sealed.
Fix exception being thrown with the wrong type and parameter name.
Use Array.Empty<T>() in target frameworks that support it.
Specify ConfigureAwait(false) when awaiting the tasks in the async timer extensions.
} | ||
|
||
[Fact] | ||
public static void InvalidSocketProtocolThrowsInConstructor() | ||
{ | ||
Should.Throw<ArgumentOutOfRangeException>( | ||
() => new SocketTransport(LocalStatsEndpoint(), (SocketProtocol)42)); | ||
SocketProtocol socketProtocol = (SocketProtocol)42; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use var
here? and name it invalidSocketProtocol
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var
is fine, but I prefer to have the variable and argument names match for simple tests scenarios like this. Happy to change it if we really want the name like that though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming comments are minor, the rest looks good.
This PR adds Roslyn code analyzers (a bit like FxCop of old) that run at build time. It also fixes various issues identified by them including:
IStatsDPublisher
over time.DisposableTimer
class sealed.Array.Empty<T>()
to save an allocation in target frameworks that support it.ConfigureAwait(false)
when awaiting tasks.