From c2558da11f5d1f83431a5023f83b0fa4833692e6 Mon Sep 17 00:00:00 2001 From: Reiley Yang Date: Tue, 30 Apr 2024 10:03:10 -0700 Subject: [PATCH] [docs-logs] Use struct in the complex type logging demo (#5577) Co-authored-by: Cijo Thomas --- docs/logs/complex-objects/FoodRecallNotice.cs | 2 +- docs/logs/complex-objects/Program.cs | 2 +- docs/logs/complex-objects/README.md | 8 ++------ docs/logs/complex-objects/complex-objects.csproj | 1 + 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/logs/complex-objects/FoodRecallNotice.cs b/docs/logs/complex-objects/FoodRecallNotice.cs index b04c01d7780..40ca59e3b8d 100644 --- a/docs/logs/complex-objects/FoodRecallNotice.cs +++ b/docs/logs/complex-objects/FoodRecallNotice.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -public class FoodRecallNotice +public struct FoodRecallNotice { public string? BrandName { get; set; } diff --git a/docs/logs/complex-objects/Program.cs b/docs/logs/complex-objects/Program.cs index ca6fa891955..c09cfc5c772 100644 --- a/docs/logs/complex-objects/Program.cs +++ b/docs/logs/complex-objects/Program.cs @@ -34,5 +34,5 @@ internal static partial class LoggerExtensions [LoggerMessage(LogLevel.Critical)] public static partial void FoodRecallNotice( this ILogger logger, - [LogProperties(OmitReferenceName = true)] FoodRecallNotice foodRecallNotice); + [LogProperties(OmitReferenceName = true)] in FoodRecallNotice foodRecallNotice); } diff --git a/docs/logs/complex-objects/README.md b/docs/logs/complex-objects/README.md index 7bcc666601a..c784c994879 100644 --- a/docs/logs/complex-objects/README.md +++ b/docs/logs/complex-objects/README.md @@ -30,16 +30,12 @@ dotnet add package Microsoft.Extensions.Telemetry.Abstractions Define a new complex data type, as shown in [FoodRecallNotice.cs](./FoodRecallNotice.cs): ```csharp -public class FoodRecallNotice +public struct FoodRecallNotice { public string? BrandName { get; set; } - public string? ProductDescription { get; set; } - public string? ProductType { get; set; } - public string? RecallReasonDescription { get; set; } - public string? CompanyName { get; set; } } ``` @@ -54,7 +50,7 @@ internal static partial class LoggerExtensions [LoggerMessage(LogLevel.Critical)] public static partial void FoodRecallNotice( this ILogger logger, - [LogProperties(OmitReferenceName = true)] FoodRecallNotice foodRecallNotice); + [LogProperties(OmitReferenceName = true)] in FoodRecallNotice foodRecallNotice); } ``` diff --git a/docs/logs/complex-objects/complex-objects.csproj b/docs/logs/complex-objects/complex-objects.csproj index cb2c93fa1ff..b8b84ddd76a 100644 --- a/docs/logs/complex-objects/complex-objects.csproj +++ b/docs/logs/complex-objects/complex-objects.csproj @@ -1,6 +1,7 @@  true + true