Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert class into a record #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions LogRedactionDemo.SimpleWorker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,12 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
}
}

public class User
{
public User(string Id, string Name, string Email)
{
this.Id = Id;
this.Name = Name;
this.Email = Email;
}

public string Id { get; }

[PersonalData] public string Name { get; }

[PersonalData] public string Email { get; }
}
public record User(string Id, [PersonalData] string Name, [PersonalData] string Email);

// logging code that logs the user
public static partial class Log
{
[LoggerMessage(LogLevel.Information, "User {User} logged in")]
[LoggerMessage(LogLevel.Information, "User logged in")]
public static partial void UserLoggedIn(this ILogger logger, [LogProperties] User user);
}

Expand All @@ -78,4 +64,4 @@ public class PersonalDataAttribute : DataClassificationAttribute
public PersonalDataAttribute() : base(new DataClassification("MyTaxonomy", "MyClassification"))
{
}
}
}