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
                    
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="Skaar.Flyweight.CodeGeneration" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Skaar.Flyweight.CodeGeneration" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Skaar.Flyweight.CodeGeneration" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Skaar.Flyweight.CodeGeneration --version 2.0.0
                    
#r "nuget: Skaar.Flyweight.CodeGeneration, 2.0.0"
                    
#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.
#:package Skaar.Flyweight.CodeGeneration@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Skaar.Flyweight.CodeGeneration&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Skaar.Flyweight.CodeGeneration&version=2.0.0
                    
Install as a Cake Tool

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")]

Documentation on GitHub

Icon

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.0.0 98 11/4/2026
1.3.2 11,530 8/15/2025
1.3.1 339 7/18/2025
1.3.0 251 7/15/2025
1.2.0 254 7/14/2025
1.1.0 249 6/25/2025
1.0.0 240 6/23/2025
0.0.5 256 6/23/2025
0.0.4 239 6/22/2025
0.0.3 249 6/22/2025
0.0.2 243 6/22/2025
0.0.1 241 6/22/2025

-
           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.