Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/electricessence/bitwisetoshortcircuitanalyzer

A Roslyn analyzer for finding and fixing instances of bitwise operators that should be using short-circuit operators instead.
https://github.com/electricessence/bitwisetoshortcircuitanalyzer

analyzer bitwise bitwise-operators short-circuit short-circuit-operations

Last synced: 8 days ago
JSON representation

A Roslyn analyzer for finding and fixing instances of bitwise operators that should be using short-circuit operators instead.

Awesome Lists containing this project

README

        

# BitwiseToShortCircuitAnalyzer

A Roslyn analyzer for finding and fixing instances of bitwise operators that should be using short-circuit operators instead.

[![NuGet](https://img.shields.io/nuget/v/BitwiseToShortCircuitAnalyzer.svg?style=flat)](https://www.nuget.org/packages/BitwiseToShortCircuitAnalyzer/)

## Examples

### Bitwise And (&)
```cs
// Will be flagged for fix.
bool EvaluateAnd(bool a, bool b) => a & b;

// Are both valid and will be ignored.
bool EvaluateAnd2(bool a, bool b) => a && b;
int EvaluateAnd(int a, int b) => a & b;
```

### Bitwise Or (|)
```cs
// Will be flagged for fix.
bool EvaluateOr(bool a, bool b) => a | b;

// Are both valid and will be ignored.
bool EvaluateOr2(bool a, bool b) => a || b;
int EvaluateOr(int a, int b) => a | b;
```