{"id":17157000,"url":"https://github.com/teo-tsirpanis/covarsky","last_synced_at":"2025-09-14T04:04:57.401Z","repository":{"id":118838791,"uuid":"237325923","full_name":"teo-tsirpanis/Covarsky","owner":"teo-tsirpanis","description":"Enabling co(ntra)variance in F# types","archived":false,"fork":false,"pushed_at":"2025-03-30T17:14:58.000Z","size":76,"stargazers_count":28,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"mainstream","last_synced_at":"2025-08-22T21:31:41.651Z","etag":null,"topics":["fsharp"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teo-tsirpanis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-01-30T23:29:15.000Z","updated_at":"2025-04-01T13:46:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e095d46-b805-4ac2-8c13-87e984f69488","html_url":"https://github.com/teo-tsirpanis/Covarsky","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/teo-tsirpanis/Covarsky","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teo-tsirpanis%2FCovarsky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teo-tsirpanis%2FCovarsky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teo-tsirpanis%2FCovarsky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teo-tsirpanis%2FCovarsky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teo-tsirpanis","download_url":"https://codeload.github.com/teo-tsirpanis/Covarsky/tar.gz/refs/heads/mainstream","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teo-tsirpanis%2FCovarsky/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275058562,"owners_count":25398174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fsharp"],"created_at":"2024-10-14T22:07:59.187Z","updated_at":"2025-09-14T04:04:57.353Z","avatar_url":"https://github.com/teo-tsirpanis.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Licensed under the MIT License](https://img.shields.io/github/license/teo-tsirpanis/Covarsky.svg)\n[![NuGet](https://img.shields.io/nuget/v/Covarsky.svg)][nuget]\n[![CI build status](https://github.com/teo-tsirpanis/Covarsky/actions/workflows/ci.yml/badge.svg?branch=mainstream\u0026event=push)](https://github.com/teo-tsirpanis/Covarsky/actions/workflows/ci.yml)\n\n# Covarsky\n\nCovarsky is a tool that brings covariant and contravariant generic types to .ΝΕΤ languages that do not natively support them, like F#. Powered by [Sigourney], it runs an MSBuild task that modifies the assembly after compilation.\n\n## How to use\n\n1. Add the [`Covarsky`][nuget] NuGet package to your project.\n\n2. Create a new source file with two (or one, if you only need one kind of variance) attributes like that (F# example shown):\n\n``` fsharp\nnamespace global\n\nopen System\n\n[\u003cAttributeUsage(AttributeTargets.GenericParameter)\u003e]\ntype internal CovariantOutAttribute() =\n    inherit Attribute()\n\n[\u003cAttributeUsage(AttributeTargets.GenericParameter)\u003e]\ntype internal ContravariantInAttribute() =\n    inherit Attribute()\n```\n\n\u003e __Warning:__ The attributes must be declared in the global namespace, directly derive from the `Attribute` class and be internal.\n\n3. You are good to go! Let's see an example.\n\n``` fsharp\ntype MyType\u003c[\u003cCovariantOut\u003e] 'T\u003e =\n    abstract GetObject: unit -\u003e 'T\n\n// [...]\n\nlet cast (x: MyType\u003cstring\u003e): MyType\u003cobj\u003e =\n    unbox x\n```\n\nAs you have seen, we have to perform manual type casts using `unbox` because F# does not recognize that `MyType`'s `'T` is covariant.\n\n## Customizing Covarsky\n\n### Using custom attribute names\n\nIf for any reason you want to customize the attribute names Covarsky will recognize, you can do it by specifying it in your project file:\n\n``` xml\n\u003cPropertyGroup\u003e\n    \u003cCustomInAttributeName\u003eMyLibrary.MakeItContravariantPleaseAttribute\u003c/CustomInAttributeName\u003e\n    \u003cCustomOutAttributeName\u003eMyLibrary.MakeItCovariantPleaseAttribute\u003c/CustomOutAttributeName\u003e\n\u003c/PropertyGroup\u003e\n```\n\nAs you see, fully qualified names are accepted. The attribute classes however still have to be internal and belong to the same assembly.\n\n### Disabling Covarsky\n\nSince version 1.3.0 Covarsky is enabled by default when you install the package. If for any reason you want to disable it you can do it with the following property:\n\n``` xml\n\u003cPropertyGroup\u003e\n    \u003cCovarskyEnable\u003efalse\u003c/CovarskyEnable\u003e\n\u003c/PropertyGroup\u003e\n```\n\n## Caveats\n\n* ~~After Covarsky's execution, the two attributes will _not_ be removed.~~ Since version 1.4.0 the attributes will be removed from the generic parameters, allowing them to be trimmed by the IL Linker. User code should not rely on their existence.\n\n* These two attributes will be ignored if used anywhere but in the generic parameters of an interface or a delegate.\n\n* Using these two attributes in a generic parameter that is already variant will raise a warning but will be ignored as well.\n\n* Using both attributes on the same generic parameter will raise an error and fail the build (unless something above hasn't already happened).\n\n* _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.___\n\n## Documentation\n\n* [Diagnostics](docs/diagnostics.md)\n\n## Maintainer(s)\n\n- [@teo-tsirpanis](https://github.com/teo-tsirpanis)\n\n[nuget]: https://nuget.org/packages/Covarsky\n[sigourney]: https://github.com/teo-tsirpanis/Sigourney\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteo-tsirpanis%2Fcovarsky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteo-tsirpanis%2Fcovarsky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteo-tsirpanis%2Fcovarsky/lists"}