Covarsky 1.2.0

Covarsky is a tool that provides co(ntra)variance in types written in a .NET language that does not support them, like F#.

Install-Package Covarsky -Version 1.2.0
dotnet add package Covarsky --version 1.2.0
<PackageReference Include="Covarsky" Version="1.2.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Covarsky --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Licensed under the MIT License
NuGet

Covarsky

Covarsky is a tool that brings co(ntra)variant types to F# (or any other language that does not support them). It runs an MSBuild task that modifies assemblies after compilation.

How to install

  1. Add the Covarsky NuGet package to your project.

  2. Create a new source file with two attributes like that (F# example shown):

namespace global

open System

[<AttributeUsage(AttributeTargets.GenericParameter)>]
type internal CovariantOutAttribute() =
    inherit Attribute()

[<AttributeUsage(AttributeTargets.GenericParameter)>]
type internal ContravariantInAttribute() =
    inherit Attribute()

Warning: The attributes must be declared in the global namespace, and must be internal.

  1. Add the following line inside a PropertyGroup in your project file:
<EnableCovarsky>true</EnableCovarsky>
  1. You are good to go! Let's see an example.
type MyType<[<CovariantOut>] 'T> =
    abstract GetObject: unit -> 'T

// [...]

let cast (x: MyType<string>): MyType<obj> =
    unbox x

Notes

These two attributes will be ignored if used anywhere but in the generic parameters of an interface or a delegate.

Using these two attributes in a generic parameter that is already co(ntra)variant will raise a warning but will be ignored as well.

Using both attributes on the same time will raise an error and fail the build (unless something above hasn't already happened).

DISCLAIMER: Using the attributes in any other wrong way (such as a contravariant interface with a method that returns the generic type) will not be checked by Covarsky and may break your assembly.

Maintainer(s)

Licensed under the MIT License
NuGet

Covarsky

Covarsky is a tool that brings co(ntra)variant types to F# (or any other language that does not support them). It runs an MSBuild task that modifies assemblies after compilation.

How to install

  1. Add the Covarsky NuGet package to your project.

  2. Create a new source file with two attributes like that (F# example shown):

namespace global

open System

[<AttributeUsage(AttributeTargets.GenericParameter)>]
type internal CovariantOutAttribute() =
    inherit Attribute()

[<AttributeUsage(AttributeTargets.GenericParameter)>]
type internal ContravariantInAttribute() =
    inherit Attribute()

Warning: The attributes must be declared in the global namespace, and must be internal.

  1. Add the following line inside a PropertyGroup in your project file:
<EnableCovarsky>true</EnableCovarsky>
  1. You are good to go! Let's see an example.
type MyType<[<CovariantOut>] 'T> =
    abstract GetObject: unit -> 'T

// [...]

let cast (x: MyType<string>): MyType<obj> =
    unbox x

Notes

These two attributes will be ignored if used anywhere but in the generic parameters of an interface or a delegate.

Using these two attributes in a generic parameter that is already co(ntra)variant will raise a warning but will be ignored as well.

Using both attributes on the same time will raise an error and fail the build (unless something above hasn't already happened).

DISCLAIMER: Using the attributes in any other wrong way (such as a contravariant interface with a method that returns the generic type) will not be checked by Covarsky and may break your assembly.

Maintainer(s)

Release Notes

Covarsky is functional again.

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.0 128 3/17/2020
1.0.0 128 2/1/2020
0.0.2 204 2/1/2020
0.0.1 187 2/1/2020