Skip to content

Commit c2558da

Browse files
reyangcijothomas
andauthored
[docs-logs] Use struct in the complex type logging demo (open-telemetry#5577)
Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com>
1 parent dffe70c commit c2558da

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

docs/logs/complex-objects/FoodRecallNotice.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
public class FoodRecallNotice
4+
public struct FoodRecallNotice
55
{
66
public string? BrandName { get; set; }
77

docs/logs/complex-objects/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ internal static partial class LoggerExtensions
3434
[LoggerMessage(LogLevel.Critical)]
3535
public static partial void FoodRecallNotice(
3636
this ILogger logger,
37-
[LogProperties(OmitReferenceName = true)] FoodRecallNotice foodRecallNotice);
37+
[LogProperties(OmitReferenceName = true)] in FoodRecallNotice foodRecallNotice);
3838
}

docs/logs/complex-objects/README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,12 @@ dotnet add package Microsoft.Extensions.Telemetry.Abstractions
3030
Define a new complex data type, as shown in [FoodRecallNotice.cs](./FoodRecallNotice.cs):
3131

3232
```csharp
33-
public class FoodRecallNotice
33+
public struct FoodRecallNotice
3434
{
3535
public string? BrandName { get; set; }
36-
3736
public string? ProductDescription { get; set; }
38-
3937
public string? ProductType { get; set; }
40-
4138
public string? RecallReasonDescription { get; set; }
42-
4339
public string? CompanyName { get; set; }
4440
}
4541
```
@@ -54,7 +50,7 @@ internal static partial class LoggerExtensions
5450
[LoggerMessage(LogLevel.Critical)]
5551
public static partial void FoodRecallNotice(
5652
this ILogger logger,
57-
[LogProperties(OmitReferenceName = true)] FoodRecallNotice foodRecallNotice);
53+
[LogProperties(OmitReferenceName = true)] in FoodRecallNotice foodRecallNotice);
5854
}
5955
```
6056

docs/logs/complex-objects/complex-objects.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
4+
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
45
</PropertyGroup>
56
<ItemGroup>
67
<PackageReference Include="Microsoft.Extensions.Telemetry.Abstractions" />

0 commit comments

Comments
 (0)