Skaar.Flyweight.CodeGeneration
2.0.0
dotnet add package Skaar.Flyweight.CodeGeneration --version 2.0.0
NuGet\Install-Package Skaar.Flyweight.CodeGeneration -Version 2.0.0
<PackageReference Include="Skaar.Flyweight.CodeGeneration" Version="2.0.0" />
<PackageVersion Include="Skaar.Flyweight.CodeGeneration" Version="2.0.0" />
<PackageReference Include="Skaar.Flyweight.CodeGeneration" />
paket add Skaar.Flyweight.CodeGeneration --version 2.0.0
#r "nuget: Skaar.Flyweight.CodeGeneration, 2.0.0"
#:package Skaar.Flyweight.CodeGeneration@2.0.0
#addin nuget:?package=Skaar.Flyweight.CodeGeneration&version=2.0.0
#tool nuget:?package=Skaar.Flyweight.CodeGeneration&version=2.0.0
Flyweight model code generator
This project generates code for the Flyweight design pattern, which is used to minimize memory usage by sharing common data among multiple objects.
It is used with the Skaar.Flyweight library to create efficient, memory-conscious applications.
Installation
In the .csproj file, add the following:
<ItemGroup>
<PackageReference Include="Skaar.Flyweight.CodeGeneration" Version="*" />
<PackageReference Include="Skaar.Flyweight" Version="*" />
</ItemGroup>
Usage
Add the Flyweight attribute to a partial class that you want to use as a flyweight.
using Skaar.Flyweight;
[Flyweight]
partial class MyStringBasedFlyweight;
[Flyweight<DataType>]
partial class MyDataTypeBasedFlyweight;
public record DataType(int Value);
Or use the GenerateFlyweightClassAttribute to generate a new flyweight class;
[assembly: GenerateFlyweightClass("MyNamespace.MyStringBasedFlyweight")]
//or
[assembly: GenerateFlyweightClass<DataType>("MyNamespace.MyDataTypeBasedFlyweight")]
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.
-
1.0.0: Initial.
1.1.0: Get with predicate and factory.
1.2.0: Generate IComparable
1.3.0: Using scope. Generate IFormattable. Generate IEnumerable.
1.3.1: Thread safe scope. Optimizations.
1.3.2: Nullability annotations
2.0.0: The Flyweight and GenerateFlyweightClass attributes moved to the Skaar.Flyweight library instead of being generated into each assembly (fixes CS0436). Skaar.Flyweight.CodeGeneration 2.x requires Skaar.Flyweight 2.x. Generated code no longer requires implicit usings.