SharpSource
SharpSource copied to clipboard
surfacing defects at compile time and preventing issues that would otherwise go unnoticed
Consider using same approach as in https://github.com/Vannevelj/sensitivity but straight as an analyzer.
```cs new ImmutableArray() ``` creates an empty struct. Correct usage is ```cs ImmutableArray.Create() ``` https://learn.microsoft.com/en-us/dotnet/api/system.collections.immutable.immutablearray.create?view=net-7.0#system-collections-immutable-immutablearray-create-1
```cs if (len is > 2014) { stackalloc int[len] } if (options is { len > 2014 }) { stackalloc int[options.len] } ```
Example: ```cs void DoThing(string a, int b) { DoThing(a, b); } ```
We don't want negative values because they introduce subtle potential bugs. For example, in order to check whether a `[Flags]` enum has a certain flag set we have 3 common...
```diff -Regex.IsMatch("", ""); +Regex.IsMatch("", "", RegexOptions.None, Timeout.InfiniteTimeSpan); ``` This prevents security issues where the combination of pattern and input result in a DoS.
Right now it only suggests `Task`
`.Where()` followed by `.First()`, `.FirstOrDefault()`, `.Single()`, `.SingleOrDefault()`, `.Last()`, `.LastOrDefault()`, `.Sum()` or `.Count()` should just take the selector predicate inside the `Where()` clause
According to [the struct design guidelines](https://msdn.microsoft.com/en-us/library/ms229031%28v=vs.110%29.aspx), a `struct` should always implement `IEquatable`. This complements Vannevelj/VSDiagnostics#182 as well.
Triggered on this: ```cs switch (trivia.Kind()) { case SyntaxKind.SingleLineCommentTrivia: case SyntaxKind.MultiLineCommentTrivia: case SyntaxKind.DocumentationCommentExteriorTrivia: case SyntaxKind.SingleLineDocumentationCommentTrivia: case SyntaxKind.MultiLineDocumentationCommentTrivia: case SyntaxKind.EndOfDocumentationCommentToken: case SyntaxKind.XmlComment: case SyntaxKind.XmlCommentEndToken: case SyntaxKind.XmlCommentStartToken: return true; default: return false;...