Philiprehberger.ChangeTracker 0.1.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package Philiprehberger.ChangeTracker --version 0.1.5
                    
NuGet\Install-Package Philiprehberger.ChangeTracker -Version 0.1.5
                    
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="Philiprehberger.ChangeTracker" Version="0.1.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Philiprehberger.ChangeTracker" Version="0.1.5" />
                    
Directory.Packages.props
<PackageReference Include="Philiprehberger.ChangeTracker" />
                    
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 Philiprehberger.ChangeTracker --version 0.1.5
                    
#r "nuget: Philiprehberger.ChangeTracker, 0.1.5"
                    
#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 Philiprehberger.ChangeTracker@0.1.5
                    
#: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=Philiprehberger.ChangeTracker&version=0.1.5
                    
Install as a Cake Addin
#tool nuget:?package=Philiprehberger.ChangeTracker&version=0.1.5
                    
Install as a Cake Tool

Philiprehberger.ChangeTracker

CI NuGet License

Track and diff property changes on objects over time for audit logging.

Installation

dotnet add package Philiprehberger.ChangeTracker

Usage

Mark your class with [TrackChanges], then create a tracker and inspect changes:

using Philiprehberger.ChangeTracker;

[TrackChanges]
public class User
{
    public string Name { get; set; } = "";
    public string Email { get; set; } = "";

    [IgnoreChanges]
    public DateTime LastLogin { get; set; }

    [SensitiveProperty]
    public string Password { get; set; } = "";
}

var user = new User { Name = "Alice", Email = "alice@example.com", Password = "secret" };
var tracker = ChangeTracker.For(user);

user.Name = "Bob";
user.Email = "bob@example.com";
user.Password = "new-secret";
user.LastLogin = DateTime.UtcNow; // ignored

IReadOnlyList<PropertyChange> changes = tracker.GetChanges();
// [
//   PropertyChange { PropertyName = "Name", OldValue = "Alice", NewValue = "Bob", ... },
//   PropertyChange { PropertyName = "Email", OldValue = "alice@example.com", NewValue = "bob@example.com", ... },
//   PropertyChange { PropertyName = "Password", OldValue = "***", NewValue = "***", ... }
// ]

JSON Serialization

ChangeSet changeSet = tracker.GetChangeSet();
string json = changeSet.ToJson();

ChangeSet restored = ChangeSet.FromJson(json);

API

ChangeTracker

Method Description
For<T>(T target) Creates a new ChangeTracker<T> that snapshots the target's current state

ChangeTracker<T>

Method Description
GetChanges() Returns an IReadOnlyList<PropertyChange> of properties that differ from the snapshot
GetChangeSet() Returns a ChangeSet wrapping all changes with type metadata and timestamp

PropertyChange

Property Type Description
PropertyName string Name of the changed property
OldValue object? Original value (masked as "***" for sensitive properties)
NewValue object? Current value (masked as "***" for sensitive properties)
Timestamp DateTimeOffset When the change was detected

ChangeSet

Member Description
TypeName Full name of the tracked type
Changes IReadOnlyList<PropertyChange> of detected changes
TrackedAt Timestamp when tracking began
ToJson() Serializes the change set to JSON
FromJson(string) Deserializes a change set from JSON

Attributes

Attribute Target Description
[TrackChanges] Class Required. Opts a class into change tracking
[IgnoreChanges] Property Excludes the property from tracking
[SensitiveProperty] Property Masks old/new values with "***" in change records

Development

dotnet build src/Philiprehberger.ChangeTracker.csproj --configuration Release

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.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
0.2.0 125 4/1/2026
0.1.6 114 3/25/2026
0.1.5 110 3/23/2026
0.1.4 106 3/23/2026
0.1.3 113 3/17/2026
0.1.2 125 3/16/2026
0.1.1 123 3/16/2026
0.1.0 113 3/16/2026