Skip to content

LifetimeMismatch

NexusLabs.Needlr

NexusLabs.Needlr

LifetimeMismatch Class

Represents a lifetime mismatch where a longer-lived service depends on a shorter-lived service. This is also known as a "captive dependency" and can lead to unexpected behavior.

public sealed record LifetimeMismatch : System.IEquatable<NexusLabs.Needlr.LifetimeMismatch>

Inheritance System.Object 🡒 LifetimeMismatch

Implements System.IEquatable<LifetimeMismatch>

Constructors

LifetimeMismatch(Type, Type, ServiceLifetime, Type, ServiceLifetime) Constructor

Represents a lifetime mismatch where a longer-lived service depends on a shorter-lived service. This is also known as a "captive dependency" and can lead to unexpected behavior.

public LifetimeMismatch(System.Type ConsumerServiceType, System.Type? ConsumerImplementationType, Microsoft.Extensions.DependencyInjection.ServiceLifetime ConsumerLifetime, System.Type DependencyServiceType, Microsoft.Extensions.DependencyInjection.ServiceLifetime DependencyLifetime);

Parameters

ConsumerServiceType System.Type

The service type that has the dependency.

ConsumerImplementationType System.Type

The implementation type that has the dependency.

ConsumerLifetime Microsoft.Extensions.DependencyInjection.ServiceLifetime

The lifetime of the consumer service.

DependencyServiceType System.Type

The service type being depended upon.

DependencyLifetime Microsoft.Extensions.DependencyInjection.ServiceLifetime

The lifetime of the dependency.

Properties

LifetimeMismatch.ConsumerImplementationType Property

The implementation type that has the dependency.

public System.Type? ConsumerImplementationType { get; init; }

Property Value

System.Type

LifetimeMismatch.ConsumerLifetime Property

The lifetime of the consumer service.

public Microsoft.Extensions.DependencyInjection.ServiceLifetime ConsumerLifetime { get; init; }

Property Value

Microsoft.Extensions.DependencyInjection.ServiceLifetime

LifetimeMismatch.ConsumerServiceType Property

The service type that has the dependency.

public System.Type ConsumerServiceType { get; init; }

Property Value

System.Type

LifetimeMismatch.DependencyLifetime Property

The lifetime of the dependency.

public Microsoft.Extensions.DependencyInjection.ServiceLifetime DependencyLifetime { get; init; }

Property Value

Microsoft.Extensions.DependencyInjection.ServiceLifetime

LifetimeMismatch.DependencyServiceType Property

The service type being depended upon.

public System.Type DependencyServiceType { get; init; }

Property Value

System.Type

Methods

LifetimeMismatch.ToDetailedString() Method

Returns a detailed, formatted string representation of this mismatch suitable for debugging and diagnostics.

public string ToDetailedString();

Returns

System.String