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

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

Merged
merged 9 commits into from Apr 30, 2024

Conversation

reyang
Copy link
Member

@reyang reyang commented Apr 26, 2024

Encourage the readers to write performant code.

@reyang reyang requested a review from a team as a code owner April 26, 2024 18:53
Copy link

codecov bot commented Apr 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.69%. Comparing base (6250307) to head (8d84c33).
Report is 202 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5577      +/-   ##
==========================================
+ Coverage   83.38%   85.69%   +2.31%     
==========================================
  Files         297      271      -26     
  Lines       12531    11376    -1155     
==========================================
- Hits        10449     9749     -700     
+ Misses       2082     1627     -455     
Flag Coverage Δ
unittests ?
unittests-Solution-Experimental 85.68% <ø> (?)
unittests-Solution-Stable 85.60% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 100 files with indirect coverage changes

@@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in with mutable structs can be tricky. If the compiler can't determine stuff is readonly it will make defensive copies. I think the auto-properties shown here are fine (IIRC the getters get marked as readonly automatically for auto-properties), but users could run into trouble if they handroll more. If we want to recommend in we may also want to recommend the structs be readonly too? readonly struct + in work always.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build failed, seems it is only available in .NET Core. I'll revert the change.

@reyang reyang force-pushed the reyang/complex-type-logging branch from 67d5d42 to afa7488 Compare April 26, 2024 19:15
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would put the generated source under .\obj\Debug\net8.0\generated\Microsoft.Gen.Logging\Microsoft.Gen.Logging.LoggingGenerator\Logging.g.cs which helps to understand things behind the scene.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI in case you weren't aware you can see them in IDE under the analyzer:

image

@reyang reyang changed the title Use struct in the complex type logging demo [docs-logs] Use struct in the complex type logging demo Apr 26, 2024
Copy link
Member

@CodeBlanch CodeBlanch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@CodeBlanch CodeBlanch merged commit c2558da into open-telemetry:main Apr 30, 2024
31 checks passed
@reyang reyang deleted the reyang/complex-type-logging branch May 8, 2024 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants