Skip to content

Conversation

@martincostello
Copy link
Member

@martincostello martincostello commented Nov 21, 2025

Changes

Enable .NET analyzers and address recommendations to:

  • avoid redundant work and formatted strings for logging;
  • fix incorrect use of ArgumentNullException;
  • avoiding an instance method that does not access state by making it static.

Running dotnet build --configuration Release with these changes has no compiler errors.

Relates to #2413 (comment).

/cc @martinjt

Merge Requirements

For new features contributions, please make sure you have completed the following
essential items:

  • CHANGELOG.md updated to document new feature additions
  • Appropriate documentation updates in the docs
  • Appropriate Helm chart updates in the helm-charts

Maintainers will not merge until the above have been completed. If you're unsure
which docs need to be changed ping the
@open-telemetry/demo-approvers.

@julianocosta89
Copy link
Member

@martincostello is this one good to go?

@martincostello
Copy link
Member Author

If people are happy with the direction, yes.

@martincostello martincostello marked this pull request as ready for review November 26, 2025 08:31
@martincostello martincostello requested a review from a team as a code owner November 26, 2025 08:31
Copilot AI review requested due to automatic review settings November 26, 2025 08:31
Copilot finished reviewing on behalf of martincostello November 26, 2025 08:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables .NET code analyzers in Release configuration and addresses analyzer warnings to improve code quality. The changes focus on optimizing logging performance, fixing incorrect exception usage, and applying best practices.

Key Changes:

  • Added AnalysisMode>Minimum</AnalysisMode> to enable .NET analyzers in Release builds for cart and accounting services
  • Converted string interpolation to structured logging with proper placeholders and added IsEnabled checks to avoid unnecessary work
  • Changed ArgumentNullException to InvalidOperationException for environment variable validation (correct exception type for missing configuration)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/cart/Directory.Build.props Enables minimum analysis mode for Release configuration
src/accounting/Directory.Build.props Enables minimum analysis mode for Release configuration
src/cart/src/cartstore/ValkeyCartStore.cs Converts logging to structured format with IsEnabled guards for performance optimization
src/accounting/Consumer.cs Fixes exception type, converts to structured logging, and makes BuildConsumer method static

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@julianocosta89
Copy link
Member

If people are happy with the direction, yes.

I'm okay with it!
It's 2 .NET Martin s against one not .NET Juliano 😅

Would you be able to take a look at Copilot review and check if it makes sense?
Honestly IDK where that came from 🤷🏽

@martincostello
Copy link
Member Author

Would you be able to take a look at Copilot review and check if it makes sense

Done.

Honestly IDK where that came from

I imagine someone's enabled the "ask for Copilot reviews" ruleset.

@martincostello
Copy link
Member Author

Well that last quick edit proved-out the CI failure 😅

Enable .NET analyzers and address recommendations to avoid redundant work, formatted strings, incorrect use of `ArgumentNullException` and avoiding an instance method that does not access state.
Update two placeholders for clarity and consistency.
Fix two additional CA1873 warnings.
@julianocosta89 julianocosta89 enabled auto-merge (squash) November 26, 2025 12:59
@julianocosta89 julianocosta89 merged commit ba6d15f into open-telemetry:main Nov 26, 2025
35 checks passed
@martincostello martincostello deleted the dotnet-analyzers branch November 26, 2025 13:52
julianocosta89 pushed a commit to julianocosta89/opentelemetry-demo that referenced this pull request Nov 26, 2025
* Enable .NET analyzers

Enable .NET analyzers and address recommendations to avoid redundant work, formatted strings, incorrect use of `ArgumentNullException` and avoiding an instance method that does not access state.

* Update placeholders

Update two placeholders for clarity and consistency.

* Fix CA1873 warnings

Fix two additional CA1873 warnings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants