Skip to content
CAI
Software that uses CAICheck a score

eiriktsarpalis/TypeShape

50.3

Weak · 13 November 2026

7.5k

lines of production code

F#

primary language

8

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

TypeShape is a .NET library that provides structural type analysis and code generation capabilities for both F\# and C\#. It enables generic programming by allowing users to inspect, clone, map, and serialize arbitrary object graphs and union types at runtime. The system supports advanced features such as deep cloning, size calculation, and the construction of generic programs through higher-kinded type abstractions.

Features

Add new samples for serialization, cloning, and functional programming patterns

The samples directory now includes new examples for CBOR and JSON serialization, a generic structural disposer, an equality comparer generator, a pretty printer, a pickler, and functional programming abstractions (Functor, Applicative, Monad) via Typeclassopedia. Additionally, a BufferDictionary helper for efficient ReadOnlySpan lookups and Net6-specific type builders for DateOnly/TimeOnly are added to the samples.

samples · high confidence

Add structural utilities for cloning, mapping, empty values, size calculation, and union contracts

Introduced new modules in the TypeShape library to support advanced type-shape operations. The Clone module provides a generic deep-cloning mechanism that handles cyclic object graphs and supports F\# records, unions, and POCOs. The Combinators module adds generic iteration and mapping capabilities for traversing and transforming type shapes. The Empty module enables generating structural 'empty' values for any type, useful for default initialization. The Sizeof module offers a generic size calculator for arbitrary object graphs. Additionally, the UnionContract module implements a pattern for serializing F\# union types to a flat, schemaless format, including an encoder/decoder abstraction and a BoxEncoder implementation.

src/TypeShape/Applications · high confidence

Added HKT builder interfaces and folding logic for generic program construction

The TypeShape library now includes a new HKT (Higher-Kinded Types) module that provides builder interfaces for constructing generic programs. This adds support for a wide range of .NET and F\# types, including primitives (bool, int, string, etc.), generic types (Nullable, Array, Dictionary), and F\#-specific types (Option, List, Map, Tuple2). The implementation introduces a folding context that recursively resolves type shapes and supports caching for performance. This change enables users to build generic programs that can handle arbitrary subsets of supported types through composable builder interfaces.

src/TypeShape/HKT · high confidence

Initial project structure and build infrastructure

The repository was initialized with a complete project structure, including a .NET 8.0 SDK configuration, FAKE 5 build scripts, and solution files for the main library, tests, and samples. This adds the foundational build and configuration files necessary to compile and test the TypeShape library.

(repo-wide) · high confidence

Introduce staged expression helpers and subtype shape utilities

The library now provides a new set of tools for working with F\# quotations (expressions) and type relationships. In \StagingExtensions.fs\, a \TypeShape.Core.StagingExtensions\ module is added, exposing functions like \Expr.bind\, \Expr.lam\, \Expr.unlambda\, and \Expr.unlet\ to manipulate and simplify expression trees. Additionally, \SubtypeExtensions.fs\ introduces \Shape.tryCreateSubtypeShape\ and related active patterns to match types against base types or interfaces. These changes expand the library's capabilities for code generation and runtime type analysis.

src/TypeShape · high confidence

Introduces C\# support for generic subtype relationships

A new file, ShapeSubtype.cs, is added to the TypeShape.CSharp library, providing C\# implementations for generic subtype relationships that were previously difficult to express in F\#. This includes a SubtypeWitness class to encapsulate subtype relationships, along with ISubtypeVisitor and ISubtypeWitnessVisitor interfaces to support visiting these relationships. The implementation allows for safe and unsafe downcasting and upcasting between base and subtype types. Additionally, the library now references Microsoft.SourceLink.GitHub to enable source link support.

src/TypeShape.CSharp · high confidence

Test coverage

Add performance benchmarks for core TypeShape operations; Added C\# record test fixtures; Added comprehensive test coverage for TypeShape's core type system and cloning capabilities.

Dependencies

Upgrade to .NET 8 and modernize build infrastructure

The project has been upgraded to target .NET 8 for all test, benchmark, and sample projects, while the core library and C\# interop layer continue to target .NET Standard 2.0 and .NET Core 3.1. This update includes a comprehensive refresh of the dependency graph, introducing FSharp.Core 8.0.100, xUnit 2.4.2, FsCheck 3.0.0-alpha4, and BenchmarkDotNet 0.13.10, alongside the adoption of the .NET 8 SDK for the test and benchmarking infrastructure.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 50 → 50 (+0.4)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.3) — scores are not directly comparable.

Lenses

  • Code Health 69 → 95 (+26.5)
  • Architecture 100 → 100 (+0.0)
  • Maturity 37 → 30 (-6.6)
  • Readiness 46 → 50 (+4.0)
  • Security 79 → 77 (-1.4)

Resolved (13)

  • Ambiguous factory methods. 'Create' is overloaded with no arguments and a Type argument, which is confusing. 'FromValue' suggests creating a shape from an instance, but the return type is TypeShape (static shape), implying it extracts the type. The naming 'Create' vs 'FromValue' is inconsistent with standard .NET patterns (e.g., 'Of' or 'From').
  • Coverage not measured — no coverage collector is wired up
  • High CVE: System.Net.Http 4.3.0
  • High CVE: System.Text.RegularExpressions 4.3.0
  • Inconsistent access pattern for the same property. ICell exposes 'Type' as a property, while Cell exposes 'Type()' as a method. This breaks interface consistency and forces callers to use different syntax depending on the concrete type.
  • Inconsistent and redundant lookup patterns. The API exposes both TryGetValue (bool/out) and TryFind (option) for the same intent. Furthermore, ContainsKey is exposed with a parameterless overload which is likely a bug or confusing, and the distinction between TryFind and TryGetValue is not clearly justified by different return types in a way that prevents duplication.
  • Inconsistent cache API. ObjectCache has HasValue/GetValue (int64 key) but TryGetValue has no key parameter (likely a bug or incomplete signature in the dump). This makes the API unusable for standard cache lookups.
  • Inconsistent return type handling. Cell.Value() returns obj, while Cell.Value(t) likely returns a typed value. This is a common pattern but inconsistent with ICell.Value which is always obj. It forces users to know the type at compile time to use the typed version, while the interface hides this.
  • Low XML-doc coverage: Helpers (samples/Helpers/Helpers.csproj)
  • Medium CVE: Microsoft.Build.Tasks.Git 8.0.0
  • Vulnerable: Microsoft.Build.Tasks.Git
  • XML-doc coverage: TypeShape.CSharp (src/TypeShape.CSharp/TypeShape.CSharp.csproj)
  • redundant comment (samples/Helpers/BufferDictionary.cs)

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

eiriktsarpalis/TypeShape was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 13 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 7c982924e1800bc4a6961eed8f94e66f855b5ac9 — the exact code this score is about.
  • Scored under rubric-2026.11.3 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.61+preprod-b8b1a43ae4c3.