Overview
NuGet.Services.Contracts is a foundational, interface-only library that defines the abstractions shared across multiple NuGet service projects. It contains no concrete implementations — only interfaces and enumerations that establish the contracts other projects implement and consume. This deliberate design keeps the dependency graph shallow and allows consuming projects to reference a single, lightweight assembly without pulling in any infrastructure-specific code.
The library is organized into three namespaces that reflect the three cross-cutting concerns it addresses: NuGet.Services.Logging for telemetry, NuGet.Services.ServiceBus for Azure Service Bus messaging, and NuGet.Services.Validation for the package validation pipeline. Each namespace defines only what is needed for callers to depend on behavior without knowing the underlying implementation.
The project targets both net472 and netstandard2.0, making it compatible with the full .NET Framework used by legacy services and with .NET Standard-based libraries. Because it carries no NuGet package dependencies of its own, it is a pure contract layer with no transitive dependency risk.
Role in System
NuGet.Services.Contracts sits at the base of the dependency graph. Five concrete projects reference it directly; none of those projects are referenced back by it.
Service Bus Abstractions
Defines
ITopicClient, ISubscriptionClient, IBrokeredMessage, IReceivedBrokeredMessage, and IOnMessageOptions — the full contract for publishing and consuming Azure Service Bus messages without depending on the Azure SDK.Validation Contracts
Defines
IValidationIssue, ValidationIssueCode, ValidationStatus, and ValidationSetStatus — the shared vocabulary for the package validation pipeline used by both the gallery frontend and backend validators.Telemetry Abstraction
Defines
ITelemetryClient with methods for tracking metrics (with and without a timestamp) and exceptions, decoupling callers from Application Insights or any specific telemetry backend.No Dependencies
The project has zero NuGet package references. All types are expressed using only BCL primitives, making this library safe to reference from any tier of the stack.
Key Files and Classes
Dependencies
NuGet Package References
This project has no NuGet package references.Internal Project References
This project has no internal project references. It is a dependency root.Notable Patterns and Implementation Details
The split between
IBrokeredMessage and IReceivedBrokeredMessage reflects the asymmetry between publishing and consuming. Outbound messages are constructed by the caller, so IBrokeredMessage uses mutable setters. Inbound messages are owned by the broker, so IReceivedBrokeredMessage exposes only read-only properties and async settlement methods.ValidationSetStatus.Completed intentionally covers both success and failure at the set level. Callers must inspect the individual ValidationStatus values on each step to determine the actual outcome. The Completed state simply signals that orchestration has finished and no further polling is needed.The
ITelemetryClient.TrackMetric overload that accepts a DateTimeOffset timestamp allows callers to record metrics that occurred at a point in the past, which is useful when processing batch events or messages that were enqueued before processing began.