[docs-logs] Use struct in the complex type logging demo (#5577)

Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com>
This commit is contained in:
Reiley Yang 2024-04-30 10:03:10 -07:00 committed by GitHub
parent dffe70c8cc
commit c2558da11f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 8 deletions

View File

@ -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; }

View File

@ -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);
}

View File

@ -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);
}
```

View File

@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Telemetry.Abstractions" />