SharpSource
SharpSource copied to clipboard
surfacing defects at compile time and preventing issues that would otherwise go unnoticed
Replace ```cs private Task DoThing() { return someTask; } ``` with ```cs private async Task DoThing() { return await someTask; } ```
https://twitter.com/STeplyakov/status/1727016474211176784?t=ow01Oe6GWAZtKvE843MR6Q&s=19
The .NET ES/OS library does not throw an exception. Instead, it returns an object that may contain error information. This analyzer would verify that we're using the response object instead...
https://learn.microsoft.com/en-us/dotnet/core/diagnostics/distributed-tracing-instrumentation-walkthroughs#activity Either use `activity.stop()` or `using activity`. No `using` and no `stop()` means the activity will get lost (presumably?)
```cs file record Range(int Lower, int Upper) { public int Distance => Upper - Lower; private bool Intersects(Range other) => other.Lower = Lower; public static IEnumerable operator -(Range minuend, Range...
> DO NOT pass null as the event data parameter when raising an event. You should pass EventArgs.Empty if you don’t want to pass any data to the event handling...
https://learn.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-7.0#automatic-http-400-responses
https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.valuetask-1?view=net-7.0#remarks ```cs ValueTask Method() => ValueTask.CompletedTask; var task = Method(); await task; await task; ```