Benutomo.AutomaticDisposeImpl.SourceGenerator
0.0.0.8
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Benutomo.AutomaticDisposeImpl.SourceGenerator --version 0.0.0.8
NuGet\Install-Package Benutomo.AutomaticDisposeImpl.SourceGenerator -Version 0.0.0.8
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Benutomo.AutomaticDisposeImpl.SourceGenerator" Version="0.0.0.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Benutomo.AutomaticDisposeImpl.SourceGenerator --version 0.0.0.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Benutomo.AutomaticDisposeImpl.SourceGenerator, 0.0.0.8"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Benutomo.AutomaticDisposeImpl.SourceGenerator as a Cake Addin #addin nuget:?package=Benutomo.AutomaticDisposeImpl.SourceGenerator&version=0.0.0.8 // Install Benutomo.AutomaticDisposeImpl.SourceGenerator as a Cake Tool #tool nuget:?package=Benutomo.AutomaticDisposeImpl.SourceGenerator&version=0.0.0.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
A simple example of use
This is an experimental library, so there is no detailed documentation. Here is a simple example of how to use it.
SampleCode
using System;
using System.Threading.Tasks;
using Benutomo;
namespace SampleCode
{
class ConsoleOutputDisposable : IDisposable
{
public void Dispose()
{
Console.WriteLine(" Called Dispose() of ConsoleOutputDisposable.");
}
}
class ConsoleOutputAsyncDisposable : IDisposable, IAsyncDisposable
{
public void Dispose()
{
Console.WriteLine(" Called Dispose() of ConsoleOutputAsyncDisposable.");
}
public ValueTask DisposeAsync()
{
Console.WriteLine(" Called DisposeAsync() of ConsoleOutputAsyncDisposable.");
return default;
}
}
[AutomaticDisposeImpl]
public partial class DisposeableTest : IDisposable, IAsyncDisposable
{
[EnableAutomaticDispose]
ConsoleOutputDisposable consoleOutputDisposable = new ConsoleOutputDisposable();
[EnableAutomaticDispose]
ConsoleOutputAsyncDisposable consoleOutputAsyncDisposable = new ConsoleOutputAsyncDisposable();
public DisposeableTest()
{
Console.WriteLine("Created new DisposeableTest");
}
[UnmanagedResourceReleaseMethod]
void ReleaseUnmanagedResources()
{
Console.WriteLine(" Called ReleaseUnmanagedResources() of DisposeableTest.");
}
}
class Program
{
public static async Task Main()
{
await DiposeTestAsync();
Console.WriteLine("Begin GC.Collect()");
GC.Collect();
GC.WaitForPendingFinalizers();
Console.WriteLine("End GC.Collect()");
Console.WriteLine();
}
static async Task DiposeTestAsync()
{
var disposeTestInstance = new DisposeableTest();
Console.WriteLine("Begin disposeTestInstance.Dispose()");
disposeTestInstance.Dispose();
Console.WriteLine("End disposeTestInstance.Dispose()");
Console.WriteLine();
var asyncDisposeTestInstance = new DisposeableTest();
Console.WriteLine("Begin disposeTestInstance.DisposeAsync()");
await asyncDisposeTestInstance.DisposeAsync();
Console.WriteLine("End disposeTestInstance.DisposeAsync()");
Console.WriteLine();
var garbegeCollectionTestInstance = new DisposeableTest();
}
}
}
Output example of above
Created new DisposeableTest
Begin disposeTestInstance.Dispose()
Called Dispose() of ConsoleOutputDisposable.
Called Dispose() of ConsoleOutputAsyncDisposable.
Called ReleaseUnmanagedResources() of DisposeableTest.
End disposeTestInstance.Dispose()
Created new DisposeableTest
Begin disposeTestInstance.DisposeAsync()
Called DisposeAsync() of ConsoleOutputAsyncDisposable.
Called Dispose() of ConsoleOutputDisposable.
Called ReleaseUnmanagedResources() of DisposeableTest.
End disposeTestInstance.DisposeAsync()
Created new DisposeableTest
Begin GC.Collect()
Called ReleaseUnmanagedResources() of DisposeableTest. <-- Will be called by the finalizer even if Dispose is missed.
End GC.Collect()
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.3-alpha8 | 544 | 11/4/2022 |
2.1.3-alpha7 | 311 | 10/2/2022 |
2.1.3-alpha4 | 309 | 8/8/2022 |
2.1.3-alpha10 | 104 | 8/4/2024 |
2.0.1 | 688 | 7/12/2022 |
2.0.0 | 437 | 6/4/2022 |
1.0.1 | 421 | 5/20/2022 |
1.0.0 | 452 | 2/12/2022 |
0.0.0.9 | 616 | 12/11/2021 |
0.0.0.8 | 298 | 12/10/2021 |
0.0.0.6 | 360 | 9/3/2021 |
0.0.0.5 | 334 | 9/2/2021 |
0.0.0.4 | 335 | 9/1/2021 |
0.0.0.3 | 339 | 9/1/2021 |
0.0.0.2 | 341 | 8/29/2021 |
0.0.0.1 | 343 | 8/18/2021 |