Morphir.IR.Pipeline.Plugins
0.5.0-alpha.4
Prefix Reserved
dotnet add package Morphir.IR.Pipeline.Plugins --version 0.5.0-alpha.4
NuGet\Install-Package Morphir.IR.Pipeline.Plugins -Version 0.5.0-alpha.4
<PackageReference Include="Morphir.IR.Pipeline.Plugins" Version="0.5.0-alpha.4" />
<PackageVersion Include="Morphir.IR.Pipeline.Plugins" Version="0.5.0-alpha.4" />
<PackageReference Include="Morphir.IR.Pipeline.Plugins" />
paket add Morphir.IR.Pipeline.Plugins --version 0.5.0-alpha.4
#r "nuget: Morphir.IR.Pipeline.Plugins, 0.5.0-alpha.4"
#:package Morphir.IR.Pipeline.Plugins@0.5.0-alpha.4
#addin nuget:?package=Morphir.IR.Pipeline.Plugins&version=0.5.0-alpha.4&prerelease
#tool nuget:?package=Morphir.IR.Pipeline.Plugins&version=0.5.0-alpha.4&prerelease
<img src="https://github.com/finos/branding/blob/master/project-logos/active-project-logos/Morphir%20Logo/Horizontal/2020_Morphir_Logo_Horizontal.png?raw=true" width="450">
Morphir
Morphir is a library of tools that works to capture business logic as data.
For the first time, business logic can be shared, stored, translated and visualised, all with the reliability of standardisation ensured in the Morphir framework.
What is it?
A set of tools for integrating technologies. Morphir is composed of a library of tools that facilitate the digitisation of business logic into multiple different languages & platforms. The Morphir framework is unique too in that facilities elements of automation and conversion that were previously unavailable in the field of finance-tech.
Why is it important?
Makes business logic portable. Business logic digitised provides distinct advantages: capacity for movement across departments and fields & the ability to be converted to new languages and applications.
How does it work?
Defines a standard format for storing and sharing business logic. A clear set of standards and format is in-place from the input/output, allowing for coherent structure.
What are the benefits?
✔️ Eliminates technical debt risk
Refactoring code libraries is often a harmful and time-sensitive issue for businesses, Morphir ensure the standards introduced from input eliminate delays at deployment.
✔️ Increases agility
Adaptability and usability are key concepts of the Morphir framework, business logic can now move with the code, be easily understood and adopted, in an ever-developing eco-system.
✔️ Ensures correctness
Certifying that specified functions behave as intended from input to output is assured through the Morphir library / tool chain.
✔️ Disseminates information through automation
Morphir’s automated processing helps disseminate information which otherwise may not be understood or shared at all, a useful tool when brining elements of business logic to conversation outside of its immediate audience (i.e developers).
Morphir .NET
Provides tooling for the Morphir ecosystem and .NET libraries that can be used to help you work with Morphir.
The additive shared configuration libraries
provide typed TOML, YAML, JSON/JSON5 documents, pure source resolution, named
profiles, validation and winning origins without constructing the CLI.
Morphir.Configuration.IO reads explicit files or supplied text and exposes
bounded project/workspace discovery through native and in-memory trees. See the
discovery guide for
ProjectSystem.Discover, per-root/member ProjectSystem.Load, membership/selection,
host boundaries and explicitly authorized machine sources.
Existing Git-first artifact discovery, cache-only tooling and CI overlays keep
their compatibility behavior. Shared inspection APIs
and morphir config get/list/show/path/explain expose typed values, source reports,
scoped queries and redacted explanations. The optional
Microsoft adapter projects one
resolved document with explicit/source-generated Options binding. See the
CLI reference for read controls, JSON schema
and exit codes. Shared editing services
and morphir config set/unset provide typed, scoped TOML previews and writes,
source-preserving changes, optimistic conflicts and explicit recovery ownership.
Shared classic project migration
and morphir project migrate provide loss-checked previews and guarded TOML
adoption while retaining classic bytes. Shared workspace migration
adds bounded inventory, verified membership and recoverable batch application through
morphir workspace migrate [directory]. See the
reader profile for syntax and provenance.
Get started
Install morphirup, the Morphir toolchain manager. It is one file and needs nothing else installed.
# macOS (Apple silicon) and Linux (x64, ARM64)
curl -fsSL https://raw.githubusercontent.com/finos/morphir-dotnet/main/scripts/install-morphirup.sh | sh
# Windows (x64, ARM64), in PowerShell
irm https://raw.githubusercontent.com/finos/morphir-dotnet/main/scripts/install-morphirup.ps1 | iex
# Or with mise
mise use -g 'github:finos/morphir[matching=morphirup,version_prefix=v,prerelease=true]'
The script installs morphirup from the newest Morphir release that has
it, and verifies the download first. morphirup then sets up the toolchain from the same releases. Open a new
terminal and run morphirup --version; it prints the version you installed.
| Platform | Install morphirup | Set up, compile and generate |
|---|---|---|
| macOS on Apple silicon | Yes | Yes |
| Windows x64 and ARM64 | Yes | Yes |
| Linux x64 and ARM64 | Yes | Not yet: morphirup setup does not support Linux yet |
| macOS on Intel | No | No |
Next, build your first model. The
installation guide covers script options, a given release,
manual download and the standalone morphir CLI. If something goes wrong, see
Troubleshooting.
SDK libraries
Morphir.SDK.CSharp is an independent net11.0 and net10.0 runtime package with immutable
C#/.NET public types. See the C# SDK guide
for its bounded operation contract and package usage.
The in-memory C# generator lowers typed classic/v4 libraries as C# 15 (Roslyn syntax trees), immutable values, executable functions/patterns/record operations and public SDK bindings. Original business fixtures and the bounded modern package-host/trimming checks are verified under #474. Implementation #478 landed. The main specification and archived acceptance evidence landed in archive follow-up #480. Coordinator cleanup remains pending.
Generate C# through the existing CLI, with numeric profiles and a validated optional namespace:
morphir generate --input model.json --target csharp --output generated --option language-version=14 --option namespace=Example.Generated --json
The C# walkthrough builds and runs a fresh consumer against the immutable runtime. CLI implementation #482 landed; its main specification and archived evidence are synchronized in this follow-up. Archive PR landing and root-verified cleanup remain pending.
Build from source and other installs
Building from source
The repository builds with the .NET 11 SDK and C# 15. Applications, .NET tools and tests target net11.0.
Packable libraries target net11.0 and net10.0 (.NET 10 LTS), so .NET 10 applications can use them.
.NET 8 and .NET 9 reached the end of support on 2026-11-10, so .NET 10 is the lowest target.
MSBuild tasks and Myriad plugins target net10.0, so the .NET 10 SDK can load them.
The netstandard2.0 attribute packages keep that target. The properties
MorphirCurrentTargetFramework, MorphirLibraryTargetFrameworks and MorphirHostedTargetFramework in
Directory.Build.props set these targets.
Install the SDK pinned in global.json, for example with dotnetup sdk install or
dotnet-install --jsonfile global.json. CI uses the same SDK pin. mise.toml pins the other
development tools (OpenSpec, Node, PowerShell), not the .NET SDK.
VS Code users can run Dev Containers: Reopen in Container to use the
Microsoft .NET SDK image in .devcontainer/Dockerfile.
The SDK includes the C# and F# compilers. Renovate groups the container and global.json
SDK updates together and keeps them on the .NET 11 SDK. Moving to the next SDK
major version requires an explicit baseline update.
./build.sh --target Test
./build.sh --target PackAll
./build.sh --target TestBuild
To compile classic Morphir model JSON into F#, see the Myriad getting-started article, plugin reference, and car rental tutorial. The runnable example covers inventory, reservation, pickup, return and billing with one generated F# file per module.
Other ways to install the standalone morphir CLI
To install with morphirup, see Get started. These routes install the morphir command line
itself:
Using proto (Recommended for multi-language toolchains):
# Install proto (if not already installed)
curl -fsSL https://moonrepo.dev/install/proto.sh | bash # Linux/macOS
# or: irm https://moonrepo.dev/install/proto.ps1 | iex # Windows
# Add Morphir plugin and install
proto plugin add morphir "source:https://github.com/finos/morphir-dotnet/releases/latest/download/morphir_plugin.wasm"
proto install morphir
Using Platform-Specific Install Scripts:
# Linux
curl -fsSL https://raw.githubusercontent.com/finos/morphir-dotnet/main/scripts/install-linux.sh | bash
# macOS
curl -fsSL https://raw.githubusercontent.com/finos/morphir-dotnet/main/scripts/install-macos.sh | bash
# Windows (PowerShell)
irm https://raw.githubusercontent.com/finos/morphir-dotnet/main/scripts/install-windows.ps1 | iex
Using .NET Tool (requires .NET SDK):
dotnet tool install --global Morphir.Tool --prerelease
Verify Installation:
morphir --version # native executable
dotnet-morphir --version # .NET tool
Compile F# to Morphir IR: follow the five-minute Compile F# guide.
For detailed installation instructions and troubleshooting, see the Installation Guide.
Documentation
Building
This project uses Nuke for build orchestration, providing a strongly-typed, cross-platform build system written in C#.
Requirements
- .NET SDK 11.0.100 or a later patch in the same feature band, as specified in
global.json
Basic Commands
# First-time setup: Restore tools and dependencies
dotnet tool restore
./build.sh --target Restore
# Build the solution (default target)
./build.sh
# Run tests
./build.sh --target Test
# Run linting/formatting checks
./build.sh --target Lint
# Format code
./build.sh --target Format
# Run full CI pipeline (restore, build, test, lint)
./build.sh --target CI
# Show all available targets
./build.sh --help
Windows users: Use build.cmd or build.ps1 instead of ./build.sh
Configuration
You can set the build configuration using the --configuration parameter:
# Build in Debug mode
./build.sh --configuration Debug
# Run tests in Debug mode
./build.sh --target Test --configuration Debug
By default, commands use Release configuration.
Build system
The build runs on Fallout 10.5.0, the successor to Nuke. ./build.sh, build.ps1, and build.cmd are the entry points. Target names are unchanged from the earlier Just-to-Nuke move, which is recorded in NUKE_MIGRATION.md.
Developing
The shared .NET SDK contract freezes the bounded operation signatures, scalar limits and independent expectations used by both SDK deliveries. See the fixture guide for the build command, schema and provenance. After building its test project, run the offline validator with:
dotnet exec tests/Morphir.SDK.Conformance.Tests/bin/Debug/net11.0/Morphir.SDK.Conformance.Tests.dll --maximum-parallel-tests 2
F# runtime consumers use Morphir.SDK.FSharp. Its namespace and runtime assembly
remain Morphir.SDK, so existing generated source and runtime type identities
remain valid. The legacy Morphir.SDK package depends on the canonical package
and ships no runtime assembly. See the F# runtime migration guide
for dependency selection and covered behavior corrections.
Project Structure
morphir-dotnet/
├── src/
│ ├── Morphir.Core/ # Core IR types and utilities
│ ├── Morphir.Tooling/ # Tooling infrastructure
│ └── Morphir/ # CLI application
├── tests/
│ ├── Morphir.Core.Tests/ # Unit tests for Core
│ ├── Morphir.Tooling.Tests/ # Unit tests for Tooling
│ └── Morphir.BlackBox.Tests/ # Black-box tests of the built artifacts (BDD/Gherkin)
├── build/
│ ├── _build.csproj # Nuke build project
│ └── Build.cs # Build orchestration (strongly-typed)
├── scripts/ # Build and utility scripts (C# scripts)
├── build.sh/cmd/ps1 # Nuke bootstrap scripts
└── justfile # Legacy build commands (preserved for reference)
Development Workflow
Restore dependencies:
./build.sh --target RestoreBuild the solution:
./build.sh --target CompileRun tests:
./build.sh --target TestCheck code formatting:
./build.sh --target LintFormat code (if needed):
# Unix/macOS ./build.sh --target Format # Windows build.cmd --target Format # or ./build.ps1 --target Format
Scripts
The project uses C# scripts (.cs files) for build automation, leveraging the direct C# file execution of the .NET SDK. These scripts are located in the scripts/ directory:
run-tests.cs- Runs unit testsrun-e2e-tests.cs- Runs end-to-end testsgenerate-wolverine-code.cs- Generates Wolverine code
Note: The deprecated build-tool-dll.cs, pack-tool-platform.cs, publish-single-file.cs and publish-single-file-untrimmed.cs scripts have been removed. Use the Nuke build targets (PackTool, PublishTool, PackRelease, PublishSingleFile, PublishSingleFileUntrimmed) instead.
Build Commands
All Nuke build commands support both Unix/macOS (./build.sh) and Windows (build.cmd or ./build.ps1) bootstrap scripts. Examples below show both formats.
Building Libraries
# Unix/macOS: Pack library projects as NuGet packages
./build.sh --target PackLibs
# Windows
build.cmd --target PackLibs
# or
./build.ps1 --target PackLibs
# Pack all projects (libraries and tool)
./build.sh --target PackAll # Unix/macOS
build.cmd --target PackAll # Windows
# Specify configuration and version
./build.sh --target PackLibs --configuration Debug --version 1.2.3
build.cmd --target PackLibs --configuration Debug --version 1.2.3
# Custom output directory
./build.sh --target PackLibs --output-dir ./my-packages
build.cmd --target PackLibs --output-dir ./my-packages
Building Release Profiles
The four .NET deployment offerings each have a named release profile. PackRelease publishes one profile for one platform and packs it into an archive named morphir-dotnet-<release>-<deployment>-<rid>.<zip|tar.gz> (zip on Windows, tar.gz elsewhere, files at the archive root), or for dotnet-tool the Morphir.Tool.<release>.nupkg package. The release comes from CHANGELOG.md. Output goes to artifacts/release/; the publish folders are in artifacts/release/publish/<deployment>/<rid>/.
# Native AOT morphir (src/Morphir). Build on the operating system of the RID.
./build.sh --target PackRelease --deployment native-aot --rid linux-x64
build.cmd --target PackRelease --deployment native-aot --rid win-arm64
# Managed morphir with the in-process F# frontend (src/Morphir.Managed), untrimmed folder archives
./build.sh --target PackRelease --deployment self-contained --rid osx-arm64
./build.sh --target PackRelease --deployment framework-dependent --rid linux-arm64
# The Morphir.Tool package (dotnet-morphir). Portable, so no --rid.
./build.sh --target PackRelease --deployment dotnet-tool
# Publish only, without the archive
./build.sh --target PublishRelease --deployment self-contained --rid win-x64
Platforms: win-x64, win-arm64, osx-x64, osx-arm64, linux-x64, linux-arm64. Any other RID is refused. Beside each archive, <archive>.build-launch.json records its launch path, execution mode, layout (single-file, folder or tool-package), bundled runtime, required runtime or SDK, F# frontend, prerequisites and SHA-256. The operating-system prerequisites are not declared yet; qualifying the artifact on each platform establishes them. It is a build output, not a public contract. PackRelease fails when the publish folder contradicts it, for example a framework-dependent folder that carries coreclr. Building a profile does not qualify a platform: no platform is release-qualified yet. Checking the release profiles from packaged artifacts runs the E2E suite against the packaged archives and lists what has been run on each platform; nothing is qualified by it. PackRelease also writes <archive>.build-contents.json and artifacts/release/size-report.md, which list every file each artifact contains with its size.
The same publish folder always gives the same archive bytes. A publish for one RID writes its NuGet lock files under obj/publish-lock/<rid>/, so it leaves the committed packages.lock.json files alone. To check, run git status --short before and after PackRelease: it should list nothing new outside artifacts/, which is ignored.
On Windows, the Native AOT link needs the Visual Studio C++ build tools for the target architecture, and the ILCompiler targets call vswhere.exe. If the link fails with "'vswhere.exe' is not recognized", put %ProgramFiles(x86)%\Microsoft Visual Studio\Installer on PATH in that shell.
Building Executables
These targets keep the layouts that the workflows and E2E tests use. PublishSingleFile builds the legacy release asset that releases ship as morphir-<rid>[.exe] and morphir-<rid>-v<version>.tar.gz.
# Build a trimmed single-file executable for a specific platform
./build.sh --target PublishSingleFile --rid linux-x64 # Unix/macOS
build.cmd --target PublishSingleFile --rid linux-x64 # Windows
# Build an AOT (ahead-of-time compiled) executable
./build.sh --target PublishExecutable --rid linux-x64
build.cmd --target PublishExecutable --rid linux-x64
# Build an untrimmed executable (larger, better for debugging)
./build.sh --target PublishSingleFileUntrimmed --rid win-x64
build.cmd --target PublishSingleFileUntrimmed --rid win-x64
# Common RIDs: linux-x64, linux-arm64, win-x64, osx-x64, osx-arm64
# With custom configuration and output directory
./build.sh --target PublishSingleFile --rid linux-x64 --configuration Debug --single-file-dir ./bin
build.cmd --target PublishSingleFile --rid linux-x64 --configuration Debug --single-file-dir ./bin
Building the Dotnet Tool
# Pack the Morphir CLI as a dotnet tool
./build.sh --target PackTool # Unix/macOS
build.cmd --target PackTool # Windows
# With version and output directory
./build.sh --target PackTool --version 2.0.0 --output-dir ./packages
build.cmd --target PackTool --version 2.0.0 --output-dir ./packages
Testing
# Run unit tests
./build.sh --target Test # Unix/macOS
build.cmd --target Test # Windows
# Run tests in Debug configuration
./build.sh --target Test --configuration Debug
build.cmd --target Test --configuration Debug
# Build the black-box test project for the published targets
./build.sh --target BuildE2ETests
build.cmd --target BuildE2ETests
# Run end-to-end tests
./build.sh --target TestE2E # Unix/macOS
build.cmd --target TestE2E # Windows
# Run the black-box tests on one target (a value of MORPHIR_TEST_TARGET, or tool, all or offerings)
./build.sh --target TestE2E --executable-type trimmed
build.cmd --target TestE2E --executable-type trimmed
Publishing to NuGet
# Publish library packages to NuGet.org
./build.sh --target PublishLibs --api-key YOUR_API_KEY # Unix/macOS
build.cmd --target PublishLibs --api-key YOUR_API_KEY # Windows
# Publish the Morphir CLI tool package to NuGet.org
./build.sh --target PublishTool --api-key YOUR_API_KEY
build.cmd --target PublishTool --api-key YOUR_API_KEY
# Publish all packages
./build.sh --target PublishAll --api-key YOUR_API_KEY
build.cmd --target PublishAll --api-key YOUR_API_KEY
# Publish to custom NuGet source
./build.sh --target PublishLibs --nuget-source https://custom-feed.com --api-key YOUR_KEY
build.cmd --target PublishLibs --nuget-source https://custom-feed.com --api-key YOUR_KEY
# Publish to local NuGet feed (for testing)
./build.sh --target PublishLocalLibs # Unix/macOS
build.cmd --target PublishLocalLibs # Windows
# With custom local source
./build.sh --target PublishLocalLibs --local-source ./my-local-feed
build.cmd --target PublishLocalLibs --local-source ./my-local-feed
# Install tool locally from package
./build.sh --target PublishLocalTool
build.cmd --target PublishLocalTool
# Install globally
./build.sh --target PublishLocalTool --global true
build.cmd --target PublishLocalTool --global true
Available Nuke Targets
Run ./build.sh --help (Unix/macOS) or build.cmd --help (Windows) to see all available targets with descriptions and parameters.
Key targets:
Restore- Restore .NET dependenciesCompile- Build the solution (default target)Test- Run unit testsLint- Check code formattingFormat- Format codeCI- Run full CI pipeline (restore, build, test, lint)PackLibs- Pack library projects as NuGet packagesPackTool- Pack the Morphir CLI as a dotnet toolPackAll- Pack all projects (libraries and tool)PublishRelease- Publish one release profile (requires--deployment, and--ridexcept fordotnet-tool)PackRelease- Pack one release profile into its named archive and launch metadataPublishSingleFile- Publish the legacy trimmed single-file release asset (requires--rid)PublishExecutable- Publish AOT executable (requires--rid)PublishSingleFileUntrimmed- Publish untrimmed single-file executable (requires--rid)TestE2E- Run each group of the black-box tests against a published or packaged targetPublishLibs- Publish library packages to NuGetPublishTool- Publish tool package to NuGetPublishAll- Publish all packages to NuGetPublishLocalLibs- Publish libraries to local feedPublishLocalTool- Install tool locally from packagePublishLocalAll- Publish all to local feed
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Links
SDK runtime delivery and archival evidence is recorded in the runtime delivery record. The canonical C# runtime spec, F# package spec, and stable C# API handoff describe the landed runtimes. SDK archive #472 landed; source SDK worktrees and their owned artifacts were removed. Empty shared archive directory cleanup remains pending with the recorded permission/policy limitations.
OpenSpec change proposals
The extension installation library documents the implemented distribution parsers, platform mappings and MEP eligibility checks, along with the remaining installer work tracked by #558. Extension installation commands are not implemented yet.
The Morphir Compatibility Kit seed contains portable F# frontend cases, a closed step vocabulary and the deterministic library runner. Its reader/runner tests and Native AOT smoke check are independent of the production F# frontend, which is still being implemented.
This repository uses the shared html-design OpenSpec workflow. New proposals
produce capability specs, a standalone design.html, and implementation tasks.
See the OpenSpec guide for setup, verification and updates.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- FSharp.Core (>= 10.1.403)
- Morphir.IR.Pipeline (>= 0.5.0-alpha.4)
- Morphir.Models (>= 0.5.0-alpha.4)
-
net11.0
- FSharp.Core (>= 10.1.403)
- Morphir.IR.Pipeline (>= 0.5.0-alpha.4)
- Morphir.Models (>= 0.5.0-alpha.4)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Morphir.IR.Pipeline.Plugins:
| Package | Downloads |
|---|---|
|
Morphir.CodeGeneration.FSharp
Morphir classic and v4 IR to F# code generation |
|
|
Morphir.Analyzers
Built-in Morphir model analyzers, such as the type validator, and their extension entries |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.0-alpha.4 | 51 | 11/16/2026 |
| 0.5.0-alpha.3 | 63 | 11/14/2026 |
| 0.5.0-alpha.2 | 64 | 11/13/2026 |
| 0.5.0-alpha.1 | 68 | 11/13/2026 |
| 0.4.0-alpha.5 | 66 | 11/13/2026 |
| 0.4.0-alpha.4 | 79 | 11/10/2026 |
| 0.4.0-alpha.3 | 74 | 11/9/2026 |
| 0.4.0-alpha.2 | 69 | 11/8/2026 |
| 0.4.0-alpha.1 | 72 | 11/7/2026 |
### Added
- The C# frontend of `morphir compile`: `morphir-dotnet.csharp` reads C# 15 source files in process, with Roslyn, in every offering. It lowers the C# dialect of the model (static classes and namespaces as modules, records and closed records as types, switch expressions as matches) to the current IR, and refuses code outside the subset with located diagnostics (`csharp.unsupported_*`).
- Passes: `transform` extensions that change a model between a frontend and a backend. `morphir extension list` shows them with their stage; `morphir generate` and `morphir compile` run them and report the applications under `passes` with `--json`. The first built-in pass, `morphir-dotnet.csharp.admission`, runs the checks of the C# backend before it. See [the middle end](docs/content/docs/pipeline/middle-end.md).
- `morphir generate` upgrades a classic model to the current IR when the backend reads the current IR only. The C# backend reads the current IR only, so `--target csharp` upgrades a classic model and runs the admission pass on it. `morphir extension list` shows the IR versions `4` and `4.0.0` for `morphir.csharp`.
- The C# backend writes local recursion: a tail call becomes a `while` loop, and any other recursive binding a local function. `List.filter`, `List.filterMap` and `List.foldl` map to `Morphir.SDK.CSharp`.
- `Morphir.SDK.CSharp` accepts plain C# records and plain C# unions in `Basics.Equal`, hashing and its collections. Equality and hashing use no reflection, so they work under Native AOT: a value outside the SDK kinds uses its own `Equals` and `GetHashCode`, and a delegate in code that people write compares by reference, as in .NET.
- `Morphir.SDK.CSharp` has generic `Basics` overloads for `T : INumber<T>` (`Add`, `Subtract`, `Multiply`, `Negate`, `Abs`, `Clamp`, `Power`) with checked arithmetic, and `List<T>` implements `IComparable<List<T>>` with the Morphir order.
- The C# backend writes generic functions over `comparable` (`where T : IComparable<T>`) and `number` (`where T : INumber<T>`), and checks the type at each call. The class of a type variable comes from the IR carrier, the `extensions` of its type attributes (`{"morphir-dotnet": {"classes": [...]}}`), else from the first word of its name. See [C# generation](docs/content/docs/backends/csharp/_index.md#generic-functions).
- The C# frontend writes the class of a type parameter in that carrier, from its .NET constraints (`IEquatable<T>`, `IEqualityOperators<T, T, bool>`, `IComparable<T>`, `IComparisonOperators<T, T, bool>`, `INumber<T>`) or from its uses in the body. On values of a type parameter, `a.Equals(b)` and `EqualityComparer<T>.Default.Equals(a, b)` become `Basics.equal`, and `a.CompareTo(b)` and `Comparer<T>.Default.Compare(a, b)` become `Basics.compare` matched to `-1`, `0` and `1`, with the ordinal order of the SDK.
- The C# frontend reads C# 15 unions. `union Shape(Circle, Rect)` is a custom type with the constructors `Circle` and `Rect`, each with the case type as its one argument `value`. A conversion to the union, `new Shape(circle)` and a cast apply the constructor; `Circle c`, `Circle(var r)` and `Rect { W: var w }` on a union are constructor patterns; `s is Circle` is a match that gives a `Bool`; `a.Equals(b)` on two unions is `Basics.equal`. A union that cannot convert is refused: a case with no name (`csharp.unsupported_union_case`), a member (`csharp.unsupported_union_member`), a case that another union of the module also has (`csharp.name_collision`), and code that reaches the state with no case: `default` (`csharp.unsupported_union_default`), a `null` arm (`csharp.unsupported_union_null`), `Value` (`csharp.unsupported_union_value`) and `IUnion` (`csharp.unsupported_union_interface`).
- The C# analyzer rule `MORPHIR1009` (`csharp.unsupported_abstract_record`) reports an older encoding of a sum type: an `abstract record` that is not `closed`, such as one with a private constructor and nested `sealed record` cases. `morphir compile` refuses it with the same code, message and range. A `closed record` and a union are not reported.
- `Morphir.Lang.CSharp.CodeFixes`: a Roslyn code fix for `MORPHIR1009` that changes an older sum type encoding to a `closed record` with the same cases and fields ("Change to a closed record"). It uses the Workspaces layer of Roslyn, so only an IDE loads it: no host, `Morphir.Lang.CSharp` or `Morphir.Tooling` references it, and a build test checks the restored closure of each host. The fix never changes a union. The page of the C# frontend documents the two sum type forms, the older encoding and the fix, and tests compile its examples.
- C# handling options in code: `[MorphirEquality(FloatEquality.Ieee)]` (assembly, type, property or positional parameter), `[MorphirEmit(Traversal = ..., TailRecursion = ...)]` and `[MorphirLoop(...)]` (assembly, class or method), and `[MorphirValueClass(...)]` on a type parameter, in the attribute assembly of `Morphir.Lang.CSharp`. A project needs no `morphir.toml` for them. The nearest attribute wins, and the command line wins over each attribute. The C# frontend writes a backend option into the model, in the `extensions` of type attributes under `morphir-dotnet.options`, so `morphir generate` on the model file applies it and writes the attribute back. A field with plain equality in a type with IEEE equality compares as plain C# does.
- The `[codegen.csharp]` table of `morphir.toml` has the keys of the C# backend: `extension`, `namespace`, `language_version`, `profile`, `traversal`, `tail_recursion` and `float_equality`. `morphir generate` and `morphir compile --target` give each key except `extension` to the backend, below the attributes of the model, and `--option` wins over each key. The C# backend accepts `--option traversal=loopfunctional`, `tail-recursion=looplocal-function` and `float-equality=clrieee`. A malformed value fails with exit code 2 before any file is written.
- `[frontend.csharp]` in `morphir.toml` has the key `loop_lowering` (`traversal`, `recursion`), the configuration carrier of `[MorphirLoop]`. An attribute on the method, the type or the assembly wins over the key. The table is closed, so a key that the C# frontend does not know, or a bad value, fails when the configuration loads, with exit code 2. `morphir compile` gives the scalar keys of the `[frontend.<language>]` table of the selected frontend (except `extension` and `project_file`, with `-` for `_`) to the frontend as extra members of the MEP `CompileOptions`; `CompileRequest.ExtraOptions` carries them, and the MEP frontend adapter writes them to a guest. See [C# handling options](docs/content/docs/backends/csharp/options.md#frontend-options-in-morphirtoml).
- The C# admission rule `MORPHIR1010` (`csharp.unsupported_non_partial_equality`) refuses a record or a union with IEEE equality from an attribute that is not `partial`.
- Packages `Morphir.Lang.CSharp` and `Morphir.MiddleEnd`. `Morphir.Lang.CSharp` has the C# frontend, the C# passes and the C# backend, with its analyzer and attribute assemblies in `lib/`. `Morphir.MiddleEnd` has the IR upgrade steps, the semantic node addresses and the transform contract. `Morphir.Tooling` depends on both. The package also has the build integration: see the entries of the source generator and the MSBuild target.
- `CSharpPipeline.Generate` in `Morphir.Lang.CSharp`: the pipeline function of C# generation. It reads the bytes of a model, upgrades a classic model, runs the C# passes and the backend, and has no file or process access. It gives the paths and bytes of `morphir generate --target csharp`, and diagnostics with no files for a model that is not valid. `Morphir.Lang.CSharp` also targets `netstandard2.0` for it.
- The Roslyn source generator `Morphir.Lang.CSharp.Generator` (`netstandard2.0`): it runs the pipeline function on each `*.morphir.json` additional file of a project and adds the C# to the compilation. A model that is not valid gives the error `MORPHIR2001` with the model file and the reason; two models that write one file with different text give `MORPHIR2003`. `MorphirCSharpNamespace` sets the namespace. It compiles against Roslyn 5.12.0, the compiler of .NET SDK 11.0.100.
- The build integration of the package `Morphir.Lang.CSharp`: `analyzers/dotnet/cs` has the source generator and the admission analyzers with their closure, and `build/` has the props and targets. A project with `<MorphirGenerateCSharpFiles>true</MorphirGenerateCSharpFiles>` gets the opt-in MSBuild target: it writes the generated files into `$(IntermediateOutputPath)morphir/csharp/` before the compilation and compiles them, and the source generator does nothing. The package sets `LangVersion` 15, and a build with a .NET SDK older than 11.0.100 stops with the error `MORPHIR2010`, which names the SDK that it needs. The project can still target a lower framework.
- The source generator and the MSBuild target write the polyfill file `Morphir.Polyfill.g.cs` only for a target framework below `net11.0`. A library and an application that each have their own polyfill file build with no warning, and a `switch` in the application on a `union` or a `closed record` of the library is exhaustive.
- `scripts/csharp-sdk-matrix.sh`, a check in the `test` job of the Development workflow: a consumer of the packed `Morphir.Lang.CSharp` generates with .NET SDK 11.0.100, and SDK 10.0.100 and 10.0.403 stop with `MORPHIR2010`. The generator compiles against Roslyn 5.12.0, so it does not load in the compiler of SDK 10 (`CS9057`).
- The page [C# generation in a build](docs/content/docs/backends/csharp/build-integration.md): the source generator, the MSBuild target, their settings and diagnostics, the package layout and the support matrix. Visual Studio, Rider and VS Code are not tested. A packages-lane scenario runs the commands of the page as written.
- The C# frontend lowers loops (LOP-1). A `foreach` that adds to an empty `List<T>` becomes `List.map`, `List.filter` or `List.filterMap`; a `foreach` that changes locals becomes `List.foldl`, with a tuple state for two or more locals; a `while`, `do` or `for` loop, and a `foreach` with `break`, `return` or `continue`, becomes a `LetRecursion` whose parameters are the changed locals. One loop recognizer in `Morphir.Lang.CSharp.Analyzers` decides for the analyzer and the frontend, so the IDE and `morphir compile` accept and refuse the same loops.
- `Morphir.SDK.CSharp` `List<T>` has `Select`, `Where` and `Aggregate`, the functional forms of `List.map`, `List.filter` and `List.foldl`, beside `FilterMap`. They come before the methods of LINQ, so each call on an SDK list gives an SDK value.
- The C# frontend reads the functional forms as the IR of the loop forms: `Select` is `List.map`, `Where` is `List.filter`, `Aggregate` is `List.foldl` and `FilterMap` is `List.filterMap`, on LINQ and on an SDK list. `Where` then `Select` is `List.map` over `List.filter`. A lambda that only applies a function to its parameter is that function: `o => Notional(o)` is `notional`. Local functions next to each other are one `LetRecursion`. `Maybe<T>.Just` and `Maybe<T>.Nothing` are the constructors of `Maybe`.
- The C# backend has two profiles for the rows of the transform table, with the handling option `profile` (`--option profile=imperative`, the default, or `--option profile=functional`, or the key `profile` of `[codegen.csharp]`). The imperative profile writes a `foreach` that adds to a list for `List.map`, `List.filter` and `List.filterMap`, and a `foreach` with accumulator locals for `List.foldl`. The functional profile writes `Select`, `Where`, `FilterMap` and `Aggregate`. A tail-recursive `LetRecursion` that the code after it calls once is a `while` loop with state locals in each profile. The frontend reads the C# of each profile back to the same IR. See [C# generation](docs/content/docs/backends/csharp/_index.md#profiles).
- The loop options apply to loops: `[MorphirLoop(LoopLowering.Recursion)]` makes a fold a `LetRecursion` over the list, and `--option tail-recursion=local-function` (or `[MorphirEmit(TailRecursion = TailRecursionForm.LocalFunction)]`) writes a tail call as a call of a local recursive function. `--option traversal` selects the loop form or the functional form of one profile rule.
### Changed
- **BREAKING:** the C# backend is written on Roslyn and writes C# 15 only. `language-version=14` now fails with `unsupported-language`, and `language-version=15` is the default.
- **BREAKING:** the package `Morphir.CodeGeneration.CSharp` is removed. The package `Morphir.Lang.CSharp` replaces it: the API of the backend is `CSharpBackend.Generate` in `Morphir.Lang.CSharp.Emit`.
- **BREAKING:** the shape of the generated C# changed. A module with only types is a namespace, and a module with values is a `static class` named after the module (no `...Module` suffix), with its types nested in it. A custom type is a `closed record` with `sealed record` cases, or a `union` of wrapper cases (no `abstract class` with nested cases). Records have the equality of plain C#: `NaN` is equal to `NaN`. The Morphir members (`MorphirEquals` and the others) are written only when you ask for IEEE equality. A file `Morphir.Polyfill.g.cs` carries the runtime types that `closed` and `union` need below .NET 11. See [C# generation](docs/content/docs/backends/csharp/_index.md).
- The Native AOT `morphir` links Roslyn for the C# frontend and backend.
- The C# backend refuses equality on a type that holds a function at generation time with `unsupported-equality`, also through a type variable, a field of a case or the record of a union case, and the message gives the path to the function type. A generic function over `appendable` or `compappend` is refused with `unsupported-appendable`.
- `MORPHIR1001` (`csharp.unsupported_loop`) refuses only a loop with no Morphir form, and its message gives the reason: the loop writes a field, a property or an array element, reads a field that can change, changes no local and builds no list, or builds a list in a form that has no list function. A change of a local in a loop is the state of the loop, so `MORPHIR1002` does not report it.
- The C# admission rules (`MORPHIR1001` and the others) cannot be suppressed: `#pragma warning disable`, `.editorconfig` and `NoWarn` do not hide them, and the new rule `MORPHIR1008` (`csharp.unsupported_suppression`) refuses a `SuppressMessage` attribute that names a rule. A refused construct cannot become a model, so `morphir compile` refuses it in every case.
### Fixed
- The C# frontend gives the model that the C# means, or it refuses the C#. Named arguments bind to their parameters; a record value gets each field by name, and an object initializer sets a field again; a switch on an enum gives constructor patterns; the variable of a case field does not capture a parameter; a generic call has the types of the call. `switch` statements whose sections return and tuple deconstruction declarations are lowered. A record value that leaves out a field, an abstract record, record inheritance, a record member that is not a field and a static member that is not a method or a constant are refused. Two constructors of one module with one Morphir name give `csharp.name_collision`. The compilation has the implicit usings of an SDK project.
- The C# analyzer refuses a symbol from an assembly outside the fixed reference set, including NuGet packages with a `System` name, and no longer reports a deconstruction declaration as a mutation. `morphir compile` reports an analyzer failure (`AD0001`) as an error, gives a missing return a location in the document, and puts diagnostics in the same order on each run.
- The C# backend writes only the switch arms that can match, so a match on `True` and `False`, a repeated arm and a covered arm compile. A negative literal given to a wrapper case compiles. Two record aliases that share one C# record keep their field values. Functions of one `LetRecursion` that call each other only as their last step become one `while` loop with a state, so deep mutual recursion does not overflow the stack. The layout re-parse uses C# 15.
- The C# backend writes `Morphir.Polyfill.g.cs` into each output, with `IsExternalInit` (below .NET 5), `CompilerFeatureRequiredAttribute` (below .NET 7) and `UnionAttribute`, `IUnion` and `IsClosedTypeAttribute` (below .NET 11).
- The C# backend refuses with `name-collision`, and names both owners, when a case, a type, a value or a module class has the name of another in one namespace or static class. A value or a type with a name that ends in `Module` now generates. A wrapper custom type with private constructors, or with two constructors of the same C# type, is a `closed record` with sealed cases, not a `union`. A public module below a module with no module of its own between them is reachable.
- The C# backend generates a module that has a record alias and a wrapper case of the same name, such as the record `Circle` and the case `Circle Circle` of the union `Shape`. Before, a construction or a match of the case failed with `ambiguous-constructor`. A wrapper type (`union`) and a mixed type (`closed record`) come back from the generated C# through the C# frontend with the same IR.
- `generate --target csharp` stops before the backend with `transform.feature_remains` when an extensible record, a hole or a body that is not an expression remains after the passes. `compile --target` reports the passes before the backend in `generation.passes`, with their diagnostics, and one application list from the frontend output. An IR upgrade error names the address of the node that the current IR cannot hold. The application list names a node of the input for a rule that rewrites inside an earlier replacement, an upgrade chain pins each kept record to its output, and the passes report keeps the upgrade records when no pass ran.
- The C# frontend reads the C# that the C# backend writes: a call of `Morphir.SDK.CSharp.Decimal`, such as `Decimal.Mul(a, b)`, is the SDK function of the module `Decimal`, and `List<T>.FromEnumerable(new T[] { ... })` is a list value. Before, the frontend refused both with `csharp.unsupported_reference`, so a model with a decimal operation or a list did not come back from its generated C#.