Skip to main content

fsharp-binary-compatibility

Change a published F# library so that apps compiled against the old version still run against the new DLL with no rebuild. Covers new parameters on let-bound functions (no overloads), optional member parameters, inferred type changes, union case order and new cases, record fields, inline and [<Literal>] values, cross-assembly inlining (--nooptimizationdata), renames with CompiledName, curried and tupled parameters, abstract interface members, the FSharp.Core dependency, and automated checks with package validation, apicompat, and an F# signature diff. Use when the user changes the public API of an F# library or NuGet package in a minor or patch release, asks for a non-breaking change, or asks whether an F# change is binary compatible.

v1.0.0New

Unsigned, install at your own risk

Unverified

This skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.

Install this skill

No account required. Pick your tool, or use the command that detects it for you.

Run in your terminal. It detects your AI tool.

npx @skills-hub-ai/cli install fsharp-skills-fsharp-binary-compatibility
Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/fsharp-skills-fsharp-binary-compatibility/SKILL.md

Setup guide →
0Save

Instructions

F# binary compatibility

A change is binary compatible when an app that was compiled against v1 still runs,
with the same results, after you replace the library DLL with v2. The app is not
rebuilt. A successful build of the solution proves only source compatibility,
because the build compiles every consumer again.

F# adds traps that C# does not have. A let function cannot have overloads. The
compiler copies some library code into each consumer. A union match uses case
numbers. The rules below come from the proof runner in scripts/. Each rule
names its proof case in scripts/proof/cases/.

To stop type inference from changing a signature, use
fsharp-signature-files. This skill does not
repeat it.

Rules

  1. Do not add a parameter to a public let function. The compiled static method
    gets a new signature, and an old app gets MissingMethodException. Add a new
    function and keep the old one as a wrapper (module-parameter):

    let parsePriceIn (currency: string) (text: string) = ...
    let parsePrice (text: string) = parsePriceIn "USD" text
    

    A rebuilt caller can still compile after the break: parsePrice text becomes a
    partial application, and %A prints a function value.

  2. On a type member, add an overload. A new optional parameter (?currency)
    keeps source compatibility, but it replaces the old method, and an old app gets
    MissingMethodException (member-optional). Keep the old member and add a
    second static member or method with the new parameter. The new overload must not
    make an existing call ambiguous. Send(Uri) beside Send(string) makes C#
    Send(null) fail with CS0121 and an unannotated F# call fail with FS0041.
    fsharp-library-api-design proves these
    results and gives the call shapes to test.

  3. Write explicit types on each public function, or use a .fsi file. A body
    change can change the inferred signature, for example int to 'a, or seq to
    list. Each one gives MissingMethodException (infer-generic,
    infer-collection).

  4. Add a union case only at the end. A case in the middle changes the tag number
    of each later case. An old app then runs the wrong match branch, with no error
    (union-insert). Package validation and apicompat do not report it. A small
    union with case fields kept working in the proof (union-insert-small), but do
    not depend on that.

  5. Do not return a new union case to an old app. An old app that gets an unknown
    case runs a wrong branch of its match, with no error. A rebuilt app gets warning
    FS0025 and MatchFailureException (union-new-case). When an old app can get the
    new case from an existing function, for example because it already passes the new
    input, keep that function on the old cases and add a new function that can return
    the new case. Otherwise, make a major version. An existing function can return the
    new case only when no old app can get it.

  6. Do not add a field to a public record that callers construct. Record
    construction and copy-and-update ({ r with ... }) call the record constructor,
    and an old app gets MissingMethodException (record-field, record-copy). A record cannot
    keep its old constructor: new in a record gives FS0871. Put the new data in a
    new type, for example { Line: OrderLine; Note: string option }, with new
    functions.

  7. Treat inline bodies and [<Literal>] values as copied into each app. An old
    app keeps the old body or value until it is rebuilt (inline-body,
    literal-value). Use a plain function and a plain let value when the body or
    value can change, and build the library with the rule 8 flag. With default flags,
    a Release app also copies a plain let value and keeps the old value
    (literal-value, plain-default).

  8. Know that Release builds also copy small non-inline functions. The F# compiler
    puts optimization data in the library DLL, and an F# consumer that is built in
    Release copies small public function bodies from it, also through a
    ProjectReference. An old app then keeps the old body (body-inlined). C#
    consumers do not copy bodies. A copied body can also call a changed member: an app
    that only called a small line factory got MissingMethodException for the
    record constructor (record-inlined). A library that must take body changes
    with no consumer rebuild needs --nooptimizationdata from its first release:

    <OtherFlags>$(OtherFlags) --nooptimizationdata</OtherFlags>
    

    The flag does not change apps that were compiled against an earlier DLL that had
    optimization data (body-inlined, safe from v1). It also stops cross-assembly
    inlining, so consumer code can be slower. inline functions are still copied
    with the flag.

  9. Rename with a wrapper. In a minor release, add the new name and keep the old
    name as a plain wrapper (rename). Mark the old name [<Obsolete("Use X.")>] only
    in a major version, and name it in the release notes. A new [<Obsolete>] on an
    existing member is a source break: a rebuilt caller gets warning FS0044, and a
    consumer with TreatWarningsAsErrors fails (rename, variant obsolete). Old
    binaries still run. [<CompiledName("oldName")>] on the renamed function keeps old
    apps working, but each F# caller that is rebuilt gets FS0039.

  10. Do not change between curried and tupled parameters. Both forms compile to
    the same method, so an old app keeps working, but a rebuilt F# caller fails
    (curried-tupled). apicompat does not report it. Add a new function instead.

  11. Do not raise the FSharp.Core dependency in a minor release. By default the
    package depends on the FSharp.Core version of the SDK that packed it, for
    example 10.1.403. A consumer that references a lower FSharp.Core gets only warning
    NU1605. It builds, and then fails at startup with FileNotFoundException for
    FSharp.Core, Version=10.1.0.0. Set the lowest version that the library needs:

    <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
    ...
    <PackageReference Include="FSharp.Core" Version="8.0.400" />
    
  12. Do not add an abstract member to a public interface. An old app that
    implements the interface gets TypeLoadException, and a rebuilt one gets FS0366
    (interface-member). Add a new interface that inherits the old one, and test for
    it with :? where you need the new member.

Read references/RULES.md for each break with its safe form and
its measured result.

Steps

  1. Keep the baseline. Before the change, find the released version: a git tag, a
    release folder, or the published package. Build it and keep its DLL.

  2. Make the change with the rules above. Done when no public let function has a
    new parameter, no union case moved, no constructed record has a new field, and no
    public interface has a new abstract member.

  3. Run package validation or apicompat. Package validation runs in dotnet pack:

    <EnablePackageValidation>true</EnablePackageValidation>
    <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion>
    

    Restore must find the baseline package on a feed. With package source mapping in
    a nuget.config, map the package ID to that feed, or restore gives NU1101. For a
    baseline that is not packed, compare the DLLs with the apicompat tool. The left
    side is the baseline:

    dotnet tool install Microsoft.DotNet.ApiCompat.Tool --create-manifest-if-needed
    dotnet apicompat --left <baseline>/Lib.dll --right <new>/Lib.dll
    

    The skill's scripts/.config/dotnet-tools.json pins version 10.0.403. Run
    dotnet tool restore in scripts/ to use it from there.

    Both tools fail with CP0002 for a removed or changed member. Fix each CP0002.

  4. Run the F# signature diff. It shows the changes that the IL tools do not
    report: union case order, curried and tupled parameters, [<Literal>] values,
    and inferred types. From the skill root:

    pwsh ./scripts/sig-diff.ps1 -Project <path>/Lib.fsproj -BaselineRef v1.0.0
    pwsh ./scripts/sig-diff.ps1 -Project <path>/Lib.fsproj -BaselineProject <baseline>/Lib.fsproj
    

    Exit code 0 means no signature change, 1 means a change (the diff is printed), and
    2 means a build or checkout failure. The script builds the current project in
    place. It checks out -BaselineRef in a temporary folder next to the repository,
    so MSBuild, NuGet, and global.json files above the repository apply to both
    builds. Pass -Framework <tfm> for a multi-target project. Check each changed line
    against the rules.
    An added line is safe only when it adds a function, adds a member to a type that
    old apps do not implement, or adds a union case after the last case.

  5. Run an old app against the new DLL. Build a small consumer against the
    baseline DLL in Release. Copy the new library DLL into its output folder, with no
    rebuild, and run it. It must give the same output for the old cases, with no
    MissingMethodException, TypeLoadException, or MissingFieldException. No
    tool finds copied bodies or behavior changes. Only this run does.

  6. Rebuild the consumers against the new version and test the new features.

  7. For an accepted break, make a major version. A new [<Obsolete>] on an
    existing member also needs a major version, and the release notes must name it.
    Record each binary break in CompatibilitySuppressions.xml.
    dotnet pack -p:ApiCompatGenerateSuppressionFile=true writes the file next to the
    project, and later packs read it. Add an XML comment with the reason above each
    suppression.

Tools

ToolUse itReportsDoes not report
Package validationYes, in the buildRemoved or changed members (CP0002)Union case order, copied bodies. From the apicompat results, also [<Literal>] values and curried and tupled changes
apicompatYes, for DLLs that are not on a feedThe same as package validation. --strict-mode also reports each added member.The same as package validation, also with --enable-rule-attributes-must-match
sig-diff.ps1Yes, after package validationThe F# view: case order, curried and tupled, literals, inferred typesBody changes, also in inline functions
PublicApiGenerator snapshotOptionalEach public change, also the union, literal, and curried-to-tupled changes. Also each addition that does not break.Body changes
Microsoft.CodeAnalysis.PublicApiAnalyzersNoNothing in F#: the F# compiler does not run Roslyn analyzersEverything

Read references/TOOLS.md for the measured result of each tool
on each proof case.

Verify

Run the proof runner from the skill root:

pwsh ./scripts/run.ps1

For each case, the runner builds the library versions and a consumer against the
baseline. It runs the old consumer with the new DLL, rebuilds the consumer, and runs
apicompat, apicompat --strict-mode, the signature diff, and PublicApiGenerator. It
fails when a result differs from the // expect line in the case's Consumer.fs.
It then checks package validation, the FSharp.Core dependency, the Roslyn analyzer
claim, and sig-diff.ps1. Use -Case <name> to run only some cases. With -Case,
the runner does not run these tool proofs.

Two statements in rule 8 are not proofs of this runner. The copy through a
ProjectReference comes from a test with SDK 10.0.404. The C# result comes from the
SmallFunctionBodyChange proof of
fsharp-library-api-design.

This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

Browse all →
fsharp-performance-typesChoose F# collections and types for run time and allocation, and prove the result with a measurement. Use when F# code is slow or allocates too much, when a reviewer asks for fewer passes or allocations, or when you write a hot loop over list, array, seq, Map, Set, Dictionary, option, tuple, or sprintf.0 installsfsharp-nullness-interopHandle F# nullness checking (Nullable enable, FS3261, FS3262 in F# 9 and later) at .NET interop boundaries, and fix FS0041 "A unique overload could not be determined" from new BCL overloads such as TimeSpan.FromSeconds(int64). Covers BCL members that return `| null`, correct null handling with match and Option.ofObj, null leaks that the compiler does not report, and when suppression is acceptable. Use when an F# build reports FS3261, FS3262, or FS0041, when the user turns on nullness checks or TreatWarningsAsErrors, or when F# code calls .NET APIs that can return null.0 installsfsharp-signature-filesAdd F# signature files (.fsi) that expose only the API that callers use, and hide type representations so callers must use constructor functions. Covers generating a starting point with --allsigs or --sig, removing helpers from the .fsi, abstract types, attribute and interface mismatches (FS3888, FS0050, FS1200), signature errors (FS0034, FS0193, FS0238), XML docs, InternalsVisibleTo for tests, and a public-surface check of the built assembly. Use when the user asks for signature files, a smaller public API, encapsulation of an F# library, or hidden constructors.0 installsfsharp-native-aotMake F# code work under .NET Native AOT (PublishAot) and find the failures that publish warnings do not show. Covers which printf, sprintf, failwithf, and interpolated-string forms work, silent data loss from %A and ToString on unions and tuples, logging, System.Text.Json for F# records, option, list, and unions, configuration binding, warnings-as-errors, and JIT-versus-native verification. Use when an F# project sets PublishAot or PublishTrimmed, when the user asks about F# AOT or trimming, when F# output or logs differ in a native build, or when F# JSON fails with "Reflection-based serialization has been disabled".0 installsfsharp-failure-pathsMake failures in F# code explicit instead of crashing or hiding them. Use when writing or reviewing F# that calls partial functions (List.head, Seq.find, Map.find, .Value), uses failwith, falls back with defaultArg or Option.defaultValue, catches exceptions, or combines several validations into one Result.0 installsparse-dont-validatePreserve invariants in types when changing domain models, input boundaries, or state transitions.0 installs

More from F# Skills

View source →
fsharp-iwsam-errorsDesign F# error types as IWSAM leaves (interfaces with static abstract members) so each function declares only its own errors and the caller picks one edge type. Use when adding or composing Result error types across F# functions, when a nested error DU needs Result.mapError at every call, when a new error case must reach every handler, or when the user says IWSAM, error tree, or edge type.0 installsfsharp-library-api-designDesign and change the public API of an F# library without breaking its consumers. Covers F#-specific breaking changes (new union cases, new record fields, curried and tupled forms, generic and inline functions, RequireQualifiedAccess, renamed modules), binary breaks that a clean build does not show (a new optional parameter, a wider parameter type, cross-assembly inlining of a small function body into Release consumers, --nooptimizationdata), safe extension patterns (overloads, new functions), a C#-friendly surface, SemVer for each change type, the lowest FSharp.Core version, and compatibility checks with package validation and old consumers. Use when the user adds to or changes a published F# library, asks whether a change is breaking, picks a version number, or exposes F# code to C#.0 installsfsharp-serializationSerialize F# records, unions, options, and maps to JSON that matches a wire contract, and keep old JSON readable. Use when writing or reviewing F# code that calls System.Text.Json, configures FSharp.SystemTextJson (JsonFSharpConverter, JsonFSharpOptions), writes Thoth.Json encoders or decoders, adds a DTO layer, reads JSON from another service, or adds or renames a union case or record field that is stored or sent as JSON.0 installsfsharp-verify-apiCheck the real signature of a .NET or F# API before F# code uses it, so the build does not loop on FS0039, FS0001, FS0074, or FS0078. Use when writing F# against a NuGet package, a package version that changed its API, an unfamiliar type, or an .fsx script with0 installsoptimize-fsharp-typecheck-graphOptimize an F# project's graph-based type-checking critical path with measured compiler evidence. Use when an F# build spends substantial time in type checking, a `.graph.md` file shows excessive file dependencies, shared namespaces or auto-open modules serialize checking, signature files may unblock parallel work, or a compile-performance refactor needs source- and binary-compatibility validation.0 installsfsharp-env-capabilitiesPass dependencies in F# as one generic env value whose capabilities are small IProvideX interfaces, so the compiler infers each function's dependency set and tests build only what a function needs. Also binds IConfiguration settings to F# types, validates them with Result at startup, and exposes the validated type as a capability instead of IOptions<T>. Use when an F# function list of dependency parameters grows, when wiring IServiceProvider or ASP.NET Core DI into F# functions, when binding or validating appsettings.json or IOptions settings in F#, when a test must substitute one dependency, or when the user says env, capability, IProvide, or environment pattern.0 installs

More Build skills

Browse category →
senior-frontendBuild and review React, Next.js, TypeScript or Tailwind frontends: components, scaffolding, performance and bundle size. Use whenever the user wants a new component or app, a page feels slow, the bundle is too big, or asks for a frontend code review.635 installsui-design-systemUse when building a design system: tokens, component docs, responsive scales or developer handoff. Generates tokens with design_token_generator.py.535 installsfrontend-designGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.346 installssenior-backendBuild and fix backend services: REST or GraphQL APIs, auth, microservices, PostgreSQL queries, migrations and load tests. Use whenever the user's API is slow or broken, needs login or auth added, a schema change, or a new endpoint or service scaffolded.246 installsself-improving-agentCurate what the agent has learned into durable project knowledge. Reviews Claude Code auto-memory (MEMORY.md and its topic files) for learnings worth keeping, promotes proven ones into CLAUDE.md or .claude/rules/, records a correction as a lesson that persists across sessions, prunes stale or duplicate entries, and turns a recurring fix into a reusable skill. Use whenever the user asks what you have learned or saved about the project, which memories should become permanent rules, to remember a lesson or stop repeating a mistake, or to clean up, audit or check memory health.173 installsusing-superpowersUse when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions145 installs

Frequently asked questions about fsharp-binary-compatibility

What does the fsharp-binary-compatibility skill do?

Change a published F# library so that apps compiled against the old version still run against the new DLL with no rebuild. Covers new parameters on let-bound functions (no overloads), optional member parameters, inferred type changes, union case order and new cases, record fields, inline and [<Literal>] values, cross-assembly inlining (--nooptimizationdata), renames with CompiledName, curried and tupled parameters, abstract interface members, the FSharp.Core dependency, and automated checks with package validation, apicompat, and an F# signature diff. Use when the user changes the public API of an F# library or NuGet package in a minor or patch release, asks for a non-breaking change, or asks whether an F# change is binary compatible. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the fsharp-binary-compatibility skill?

Run `npx @skills-hub-ai/cli install fsharp-skills-fsharp-binary-compatibility` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/fsharp-skills-fsharp-binary-compatibility/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does fsharp-binary-compatibility work with?

fsharp-binary-compatibility runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the fsharp-binary-compatibility skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use fsharp-binary-compatibility after installing it?

In Claude Code, type `/fsharp-skills-fsharp-binary-compatibility` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the fsharp-binary-compatibility skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.