Skip to main content
.NETFramework4.7.2net8.0.NETStandard2.0

Represents the concept of Immutable Type so that it can be used by other packages like Metalama.Patterns.Observability.

Published
Nov 12, 2025
11mo ago
Total Downloads
77.9K
77,928

Install

dotnet add package Metalama.Patterns.Immutability --version 2026.0.5-preview
ProductVersions
.NET
net8.0
.NET Standard
netstandard2.0
Other
.NETFramework4.7.2

README

Metalama Logo

About

The Metalama.Patterns.Immutability implements the concept of immutable type, i.e. types whose value cannot be changed after they have been created. Other packages, such as Metalama.Patterns.Observability, can then rely on this concept to achieve a better understanding of the code.

Key Features

  • You can mark types as immutable using the [Immutable] custom attribute or the ConfigreImmutability fabric extension warning.
  • Concept of shallow or deep immutability.
  • The [Immutable] aspect reports warnings if some fields or properties are not mutable.

Main Types

The primary types in this package are:

  • ImmutabilityKind represents the kind of immutability of a type, i.e. None, Shallow or Deep.
  • ImmutableAttribute is an aspect that marks a type as immutable and reports warnings if some fields or properties are mutable.
  • ImmutabilityExtensions.GetImmutability is an extension of INamedType to get the ImmutabilityKind of a given type.
  • ImmutabilityConfigurationExtensions.ConfigureImmutability is a fabric extension method to programmatically set the ImmutabilityKind of types.
  • IImmutabilityClassifier is an abstraction whose implementations can be passed to ImmutabilityConfigurationExtensions.ConfigureImmutability to dynamically return the ImmutabilityKind of a kind. It is useful when the ImmutabilityKind depends on type arguments.

Additional Documentation

Related Packages

  • Metalama.Patterns.Observability relies on Metalama.Patterns.Immutability to decide which method calls are supported in property getters.

Changes from Previous Version

No structural changes between v2026.0.4-preview and v2026.0.5-preview.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.