Lindhart.Analyser.MissingAwaitWarning
2.0.0-beta2
See the version list below for details.
dotnet add package Lindhart.Analyser.MissingAwaitWarning --version 2.0.0-beta2
NuGet\Install-Package Lindhart.Analyser.MissingAwaitWarning -Version 2.0.0-beta2
<PackageReference Include="Lindhart.Analyser.MissingAwaitWarning" Version="2.0.0-beta2" />
paket add Lindhart.Analyser.MissingAwaitWarning --version 2.0.0-beta2
#r "nuget: Lindhart.Analyser.MissingAwaitWarning, 2.0.0-beta2"
// Install Lindhart.Analyser.MissingAwaitWarning as a Cake Addin #addin nuget:?package=Lindhart.Analyser.MissingAwaitWarning&version=2.0.0-beta2&prerelease // Install Lindhart.Analyser.MissingAwaitWarning as a Cake Tool #tool nuget:?package=Lindhart.Analyser.MissingAwaitWarning&version=2.0.0-beta2&prerelease
unused-task-warning
When using dependency injection and async-await pattern it is possible to end up with an interface with a method that returns a Task. If this interface method is used in a synchronous method there is a likelihood that it will erroneously be run as a fire and forget method (which will not trigger inbuilt warning CS4014). In this situation this analyser generates a warning.
Can both be used as a Visual Studio extension or preferably as a project analyser available from NuGet.
Example:
using System.Threading.Tasks;
namespace AsyncAwaitProblem
{
public interface ICallee
{
bool ProblemSolved { get; }
Task SolveProblemAsync();
}
public class Callee : ICallee
{
public bool ProblemSolved { get; set; }
public async Task SolveProblemAsync()
{
await Task.Delay(10);
ProblemSolved = true;
}
}
public class Caller
{
public bool DoCall()
{
ICallee xxx = new Callee();
// This analyser will give a warning at the following line
xxx.SolveProblemAsync(); // This is most likely an undesired fire and forget.
return xxx.ProblemSolved; // Will return false - we expected it to return true
}
}
}
Note that this analyser currently only checks for the currently known awaitable types. If another 'Awaitable' type is returned this analyser will not give the warning. This might be fixed in a future version.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (82)
Showing the top 5 NuGet packages that depend on Lindhart.Analyser.MissingAwaitWarning:
Package | Downloads |
---|---|
DogmaSolutions.Contracts
Package Description |
|
DogmaSolutions.Log4NetExtensions
Package Description |
|
DogmaSolutions.PrimitiveTypes
Package Description |
|
DogmaSolutions.Csv
Package Description |
|
DogmaSolutions.FileSystem
Package Description |
GitHub repositories (5)
Showing the top 5 popular GitHub repositories that depend on Lindhart.Analyser.MissingAwaitWarning:
Repository | Stars |
---|---|
RayTale/Ray
项目停止更新,新项目:https://github.com/RayTale/Vertex
|
|
RayTale/Vertex
Vertex is a distributed, ultimately consistent, event traceable cross platform framework based on Orleans, which is used to build high-performance, high throughput, low latency, scalable distributed applications
|
|
MrCMS/MrCMS
Mr CMS is an open source C# MVC CMS Framework
|
|
veldtech/miki-bot
Miki Discord Bot
|
|
nullpainter/sanchez
False-colour geostationary satellite image compositor
|
Version | Downloads | Last updated | |
---|---|---|---|
3.1.0-beta | 17,107 | 6/7/2024 | |
3.0.0-beta | 115,993 | 8/9/2022 | |
2.0.0 | 4,477,350 | 12/7/2020 | |
2.0.0-beta2 | 636 | 10/26/2020 | |
2.0.0-beta | 429 | 10/26/2020 | |
1.2.1 | 49,600 | 9/28/2020 | |
1.2.1-beta | 713 | 5/8/2020 | |
1.2.0 | 435,721 | 6/6/2019 | |
1.2.0-beta | 651 | 4/16/2019 | |
1.0.1 | 171,400 | 8/10/2018 | |
1.0.0 | 53,238 | 1/6/2018 |
Package is no longer signed. Upgraded target framework from .net Standard 1.3 -> 2.0. Changed from license file to license expression (still MIT license). Added more types.