Architect.AmbientContexts 2.0.0-preview-20220731.1

.NET Core 3.1 .NET Standard 2.0
This is a prerelease version of Architect.AmbientContexts.
NuGet\Install-Package Architect.AmbientContexts -Version 2.0.0-preview-20220731.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Architect.AmbientContexts --version 2.0.0-preview-20220731.1
<PackageReference Include="Architect.AmbientContexts" Version="2.0.0-preview-20220731.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Architect.AmbientContexts --version 2.0.0-preview-20220731.1
#r "nuget: Architect.AmbientContexts, 2.0.0-preview-20220731.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Architect.AmbientContexts as a Cake Addin
#addin nuget:?package=Architect.AmbientContexts&version=2.0.0-preview-20220731.1&prerelease

// Install Architect.AmbientContexts as a Cake Tool
#tool nuget:?package=Architect.AmbientContexts&version=2.0.0-preview-20220731.1&prerelease

Provides the basis for implementing the Ambient Context pattern. Includes a Clock implementation based on it.

The Ambient Context pattern is an Inversion of Control (IoC) pattern that provides static access to a dependency while controlling the dependency from the outside.
The pattern optimizes code reachability at the cost of reduced transparency, making it suitable for obvious, ubiquitous, rarely-changing dependencies.
For example, an entity's constructor can access Clock.UtcNow, avoiding the need to inject the creation datetime or a dependency, at the cost of hiding the fact that a unit test could control the timestamp from the outside.

An example from .NET is System.Transactions.TransactionScope. Any code (such as the database connector) can access the static Transaction.Current, yet outer code in the current execution flow controls it, through TransactionScopes.

Release notes:

- BREAKING: ClockScope no longer has a configurable default scope. (See also next item).
- BREAKING: Removed explicit support for "configured default scopes", i.e. scopes configured on startup. They posed too many concurrency risks, such as in test runs. (Default scopes without any configuration are still supported.)
- BREAKING: Removed the RemoveAmbientScope() method. Deactivate() should be used instead.
- Added support for netstandard2.0.
- ClockScope's constructor now prefers UTC datetimes, to avoid lossy conversions (due to DST).

- Manually disposing scopes from a deeper async level (such as a DisposeAsync() method with the async keyword) now properly affects methods up the call stack and no longer breaks scope nesting.
- Improved the protections against race conditions.
- Parent properties are no longer unset on disposal (although implementations should not rely on this detail).
- Performance improvement: A scope now avoids even instantiating its AsyncLocal as long as only its default scope is used, as is common in production for certain scopes.
- Performance improvement: The JIT can now inline more code, since exceptions have been moved into helper methods.

- Introduced non-generic AmbientScope base class.
- Performance improvement: A scope now avoids touching its AsyncLocal as long as only its default scope is used, as is common in production for certain scopes.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Architect.AmbientContexts:

Package Downloads

Reliable unique ID generation and management for distributed applications. Auto-increment IDs reveal sensitive information. UUIDs (also known as GUIDs) are inefficient as primary keys in a database. Having two different IDs is cumbersome and counterintuitive. We can do better. - For a 93-bit UUID replacement that is efficient as a primary key, use the DistributedId. - To expose IDs externally in a sensitive environment where zero metadata must be leaked, transform them with PublicIdentities. Release notes: 2.0.0: - BREAKING: Removed Fluid. Configured ambient scopes are considered undesirable. - BREAKING: Removed ApplicationInstanceId. Configured ambient scopes are considered undesirable. - BREAKING: Removed ambient access to IPublicIdentityConverter. Configured ambient scopes are considered undesirable. - BREAKING: IPublicIdentityConverter now throws on big-endian architectures, instead of risking silent portability issues between architectures. - BREAKING: Now using AmbientContexts 2.0.0. - Semi-breaking: DistributedIds are now always 28 digits, to avoid a change from 27 to 28 digits in the future. Migrating will cause a one-time skip to greater ID values. - DistributedIds can now burst-generate ~128K IDs at once before the 128 IDs per millisecond throttling kicks in. This makes it less likely that throttling is encountered. - IPublicIdentityConverter now comes with a TestPublicIdentityConverter implementation for unit tests. 1.0.2: - Now using AmbientContexts 1.1.1, which fixes extremely rare bugs and improves performance. 1.0.1: - Now using AmbientContexts 1.1.0, for a performance improvement.


Manage your DbContexts the right way. The persistence or infrastructure layer uses the DbContext (e.g. from a repository). Controlling its scope and transaction lifetime, however, is ideally the reponsibility of the orchestrating layer (e.g. from an application service). This package adds that ability to Entity Framework Core 5.0.0 and up. Release notes: 2.0.0: - BREAKING: Now using AmbientContexts 2.0.0. 1.0.1: - Now using AmbientContexts 1.1.1, which fixes extremely rare bugs and improves performance.


Contains objects and helpers to help the calculation of objects in space and time: -Point with a generic integral value; -Size with a generic integral value; -Directions: strict and free; -Movements: deterministic (dynamic and static) and non-deterministic (free); -Timing: stopwatch scope;

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0-preview-20220731.1 57 7/31/2022
2.0.0-preview-20220426.1 323 4/26/2022
1.1.1 4,432 1/1/2022
1.1.0 2,312 9/12/2021
1.0.0 4,738 12/7/2020