Downcastly 1.0.1-alpha
This is a prerelease version of Downcastly.
dotnet add package Downcastly --version 1.0.1-alpha
NuGet\Install-Package Downcastly -Version 1.0.1-alpha
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="Downcastly" Version="1.0.1-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Downcastly" Version="1.0.1-alpha" />
<PackageReference Include="Downcastly" />
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 Downcastly --version 1.0.1-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Downcastly, 1.0.1-alpha"
#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 Downcastly@1.0.1-alpha
#: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=Downcastly&version=1.0.1-alpha&prerelease
#tool nuget:?package=Downcastly&version=1.0.1-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Downcastly - A C# Library for Safe Downcasting with Compile-Time Type Checking
Downcastly is a C# library that provides a safe and efficient way to downcast objects with compile-time type checking. It automatically generates downcasting constructors for your classes to copy all the properties from the base class to the derived class, ensuring type safety and reducing boilerplate code.
How to use
public record ParentRecord
{
public int Id { get; init; }
public string Name { get; init; }
}
[Downcast]
public partial record ChildRecord : ParentRecord
{
public string Status { get; init; }
}
public class Program
{
public static void Main()
{
ParentRecord parent = new()
{
Id = 1,
Name = "Parent"
};
// Safe downcasting using Downcastly
ChildRecord child = new (parent) {Status = active};
Console.WriteLine($"Id: {child.Id}, Name: {child.Name}, Status: {child.Status}");
}
}
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
- Downcastly.Attributes (>= 1.0.0)
- Downcastly.Generators (>= 1.0.0)
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1-alpha | 0 | 12/27/2025 |
| 1.0.0 | 0 | 12/27/2025 |