![]() |
VOOZH | about |
dotnet add package Raycynix.Extensions.Contracts --version 1.0.1
NuGet\Install-Package Raycynix.Extensions.Contracts -Version 1.0.1
<PackageReference Include="Raycynix.Extensions.Contracts" Version="1.0.1" />
<PackageVersion Include="Raycynix.Extensions.Contracts" Version="1.0.1" />Directory.Packages.props
<PackageReference Include="Raycynix.Extensions.Contracts" />Project file
paket add Raycynix.Extensions.Contracts --version 1.0.1
#r "nuget: Raycynix.Extensions.Contracts, 1.0.1"
#:package Raycynix.Extensions.Contracts@1.0.1
#addin nuget:?package=Raycynix.Extensions.Contracts&version=1.0.1Install as a Cake Addin
#tool nuget:?package=Raycynix.Extensions.Contracts&version=1.0.1Install as a Cake Tool
Raycynix.Extensions.Contracts contains reusable contract models and versioning conventions for shared .NET APIs.
MoneyQuantityUoMPagingRequestPageInfoPagedResult<TItem>ErrorContractValidationErrorContractVersionContractMetadataVersionedContract<TContract>ContractHeadersContractIntroducedAttributeContractDeprecatedAttributemaster data sourcesMajor changes are breaking changesMinor changes are additive, backward-compatible changesPatch changes are non-breaking fixes that do not alter the contract shapevar price = new Money
{
Amount = 149.99m,
Currency = "USD"
};
var quantity = new Quantity
{
Value = 12.5m,
UoM = new UoM
{
Code = "kg",
Name = "Kilogram"
}
};
var result = new PagedResult<Money>
{
Items = new[] { price },
PageInfo = new PageInfo
{
Page = 1,
PageSize = 20,
TotalCount = 1,
TotalPages = 1,
HasPreviousPage = false,
HasNextPage = false
}
};
var versioned = new VersionedContract<PagedResult<Money>>
{
Metadata = new ContractMetadata
{
Name = "catalog.prices",
Version = new ContractVersion
{
Major = 1,
Minor = 0,
Patch = 0
}
},
Payload = result
};
Use the shared header names when contracts cross transport boundaries explicitly:
var headers = new Dictionary<string, string?>
{
[ContractHeaders.ContractName] = "catalog.prices",
[ContractHeaders.ContractVersion] = "1.2.0"
};
Use ContractVersion to express the current shared contract version:
var version = new ContractVersion
{
Major = 1,
Minor = 2,
Patch = 0
};
var parsed = ContractVersion.Parse("1.2.0");
var isCompatibleLine = parsed >= version;
When contract metadata must cross process boundaries explicitly, use:
ContractHeaders.ContractNameContractHeaders.ContractVersionThis package only defines the common contract model and conventions. It does not enforce transport-specific version negotiation by itself.
ContractVersion also supports parsing, comparison, and equality to help consumers implement consistent compatibility checks in their own services.
Use ErrorContract as the shared transport shape for failures:
var error = new ErrorContract
{
Code = "validation_failed",
Message = "One or more validation errors occurred.",
TraceId = "00-7d9f6f8f53fd8a8ce6d4cfd21483ca5f-b9d0f6f6bd2f5f61-01",
ValidationErrors =
[
new ValidationError
{
Field = "pageSize",
Code = "out_of_range",
Message = "Page size must be greater than zero."
}
]
};
This package intentionally keeps the error contract generic so it can be reused in HTTP APIs, messaging, and internal service boundaries.
The built-in contract models expose System.ComponentModel.DataAnnotations attributes and lightweight IsValid() checks so consumers can use them with ASP.NET Core, manual validation flows, or custom guards without introducing transport-specific behavior into the contracts themselves.
If you want HTTP header integration, endpoint metadata, controller/minimal API helpers, or ModelState conversion helpers, use the companion package Raycynix.Extensions.Contracts.AspNetCore.
In that package:
.WithContract(...)[Contract(...)]UseRaycynixContracts() so the declared contract is written to HTTP headershttpContext.VersionedContract(...) or this.VersionedContract(...) when you want the response body wrapped into VersionedContract<T> without duplicating metadata inside the handlerUse the attributes in this package to mark contract evolution directly on shared DTOs:
public class CatalogPriceDto
{
[ContractIntroduced("1.0.0")]
public string ProductId { get; set; } = string.Empty;
[ContractIntroduced("1.2.0")]
public Money? DiscountPrice { get; set; }
[ContractDeprecated("1.3.0", RemovalVersion = "2.0.0", Reason = "Use DiscountPrice instead.")]
public decimal? DiscountAmount { get; set; }
}
Recommended evolution flow:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 3 NuGet packages that depend on Raycynix.Extensions.Contracts:
| Package | Downloads |
|---|---|
|
Raycynix.Extensions.Messaging.Abstractions
Transport-agnostic messaging contracts, codecs, handlers, outbox abstractions, and direct communication primitives for Raycynix applications. |
|
|
Raycynix.Extensions.Messaging
Transport-agnostic messaging registration, dispatch, direct requests, observability, scoped envelope factories, and outbox/inbox reliability foundations for Raycynix applications. |
|
|
Raycynix.Extensions.Contracts.AspNetCore
ASP.NET Core integration for Raycynix contracts, including endpoint metadata, contract headers, and contract-aware result helpers. |
This package is not used by any popular GitHub repositories.
See the package-local CHANGELOG.md for the full change history. Override PackageReleaseNotes in the package project file for major release-specific notes.