TransientEventId 1.0.0

dotnet add package TransientEventId --version 1.0.0
                    
NuGet\Install-Package TransientEventId -Version 1.0.0
                    
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.
<PackageReference Include="TransientEventId" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TransientEventId" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TransientEventId" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TransientEventId --version 1.0.0
                    
#r "nuget: TransientEventId, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TransientEventId@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TransientEventId&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TransientEventId&version=1.0.0
                    
Install as a Cake Tool

TransientEventId

Minimal, dependency-free struct for logging event identifiers, API-compatible with Microsoft.Extensions.Logging.EventId.

Overview

TransientEventId is a single-file C# library providing a drop-in replacement for Microsoft.Extensions.Logging.EventId without any external dependencies. It targets netstandard2.0 for maximum compatibility and is designed for use in libraries and applications where you want to avoid a dependency on Microsoft.Extensions.Logging.

Features

  • Immutable, readonly struct: TransientEventId
  • API-compatible with Microsoft.Extensions.Logging.EventId
  • Implicit conversion from int and (int, string) tuple
  • Deconstruction support: (id, name) = eventId;
  • Implements IEquatable<TransientEventId> and value semantics
  • No dependencies, no runtime overhead

Usage

using TransientEventId;

// Explicit construction
var eventId1 = new TransientEventId(1001, "UserLogin");

// Implicit from int
TransientEventId eventId2 = 1002;

// Implicit from tuple
TransientEventId eventId3 = (1003, "DataAccess");

// Deconstruction
var (id, name) = eventId1;

Using TransientEventId with Microsoft.Extensions.Logging

Suppose you have installed the TransientEventId package in a project that also references Microsoft.Extensions.Logging. You can define your event identifiers using TransientEventId and convert them to EventId when logging:

using Microsoft.Extensions.Logging;
using TransientEventId;

public static class EventIdExtensions
{
    // Static conversion method
    public static EventId ToEventId(this TransientEventId transient)
        => new EventId(transient.Id, transient.Name);
}

public class MyService
{
    private readonly ILogger<MyService> _logger;

    public MyService(ILogger<MyService> logger)
    {
        _logger = logger;
    }

    // Define your event id using TransientEventId
    private static readonly TransientEventId UserLoginEvent = new(1001, "UserLogin");

    public void Login(string username)
    {
        // Use the static extension method for conversion
        EventId eventId = UserLoginEvent.ToEventId();
        _logger.LogInformation(eventId, "User {Username} logged in.", username);
    }
}

Installation

Add the package from NuGet (coming soon) or reference the single TransientEventId.cs file directly in your project.

Build

Build the library with:

dotnet build

To create a NuGet package:

dotnet pack

Project Metadata

When to Use

  • Library authors who want to expose event IDs without forcing a Microsoft.Extensions.Logging dependency
  • Legacy or portable codebases
  • Any .NET Standard 2.0+ project needing lightweight, structured event identifiers

Extending

  • Keep all logic in TransientEventId.cs for portability
  • Maintain API compatibility with Microsoft.Extensions.Logging.EventId
  • Do not add dependencies
  • For tests, use a separate test project (not included)

License

BSD 3-Clause License — see LICENSE

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 201 10/8/2025

Initial release. API-compatible with Microsoft.Extensions.Logging.EventId.