-
Notifications
You must be signed in to change notification settings - Fork 787
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
[docs-logs] Use struct in the complex type logging demo #5577
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. |
@@ -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); |
There was a problem hiding this comment.
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 struct
s be readonly
too? readonly struct
+ in
work always.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated.
There was a problem hiding this comment.
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.
67d5d42
to
afa7488
Compare
@@ -1,6 +1,7 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> | |||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Encourage the readers to write performant code.