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 months ago
JSON representation
A Roslyn analyzer for finding and fixing instances of bitwise operators that should be using short-circuit operators instead.
- Host: GitHub
- URL: https://github.com/electricessence/bitwisetoshortcircuitanalyzer
- Owner: electricessence
- License: mit
- Created: 2021-10-09T15:28:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-19T23:40:25.000Z (over 4 years ago)
- Last Synced: 2025-01-26T08:06:33.261Z (over 1 year ago)
- Topics: analyzer, bitwise, bitwise-operators, short-circuit, short-circuit-operations
- Language: PowerShell
- Homepage:
- Size: 82 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.
[](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;
```