Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Marked JsonLayout EscapeForwardSlash as obsolete and without any effect - #5767

#5767
Merged
snakefoot merged 1 commit into
NLog:devNLog/NLog:devfrom
snakefoot:ObsoleteEscapeForwardSlashsnakefoot/NLog:ObsoleteEscapeForwardSlashCopy head branch name to clipboard
Apr 5, 2025
Merged

Marked JsonLayout EscapeForwardSlash as obsolete and without any effect#5767
snakefoot merged 1 commit into
NLog:devNLog/NLog:devfrom
snakefoot:ObsoleteEscapeForwardSlashsnakefoot/NLog:ObsoleteEscapeForwardSlashCopy head branch name to clipboard

Conversation

@snakefoot

@snakefoot snakefoot commented Apr 5, 2025

Copy link
Copy Markdown
Contributor

Followup to #5695 and #4249 for NLog v6, where EscapeForwardSlash no longer has any effect.

@snakefoot snakefoot added the breaking behavior change Same API, different result label Apr 5, 2025
@snakefoot snakefoot added this to the 6.0 milestone Apr 5, 2025
@coderabbitai

coderabbitai Bot commented Apr 5, 2025

Copy link
Copy Markdown

Walkthrough

The changes update several EscapeForwardSlash properties across multiple classes to include the [EditorBrowsable(EditorBrowsableState.Never)] attribute, which hides them from design-time tools. In addition, the deprecation messaging on these properties has been refined in some cases. A minor refactoring in the SerializeObject method of the JSON serializer now uses a local variable to simplify accessing the EscapeUnicode option. Overall, these modifications affect attribute decorations and code clarity without changing runtime behavior.

Changes

File(s) Change Summary
src/NLog/.../JsonEncodeLayoutRendererWrapper.cs
src/NLog/.../JsonAttribute.cs
src/NLog/.../JsonLayout.cs
src/NLog/.../JsonSerializeOptions.cs
Added [EditorBrowsable(EditorBrowsableState.Never)] to the EscapeForwardSlash property. Also, updated deprecation messages in some classes (e.g., clarifying version details in JsonAttribute).
src/NLog/.../DefaultJsonSerializer.cs Introduced a local variable escapeUnicode in the SerializeObject method to simplify the conditional check.

Poem

I’m a rabbit in the code’s green glade,
Hopping on changes that have been made.
Attributes now hide what’s old and gray,
Guiding the devs on a clearer way.
With a twitch of my nose and a joyful leap,
I code and celebrate these changes deep! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d796c42 and a1c3677.

📒 Files selected for processing (5)
  • src/NLog/LayoutRenderers/Wrappers/JsonEncodeLayoutRendererWrapper.cs (2 hunks)
  • src/NLog/Layouts/JSON/JsonAttribute.cs (2 hunks)
  • src/NLog/Layouts/JSON/JsonLayout.cs (1 hunks)
  • src/NLog/Targets/DefaultJsonSerializer.cs (1 hunks)
  • src/NLog/Targets/JsonSerializeOptions.cs (1 hunks)
🧰 Additional context used
🧬 Code Definitions (3)
src/NLog/Targets/DefaultJsonSerializer.cs (1)
src/NLog.Targets.Network/Layouts/GelfLayout.cs (1)
  • RequiresJsonEscape (508-515)
src/NLog/Layouts/JSON/JsonAttribute.cs (1)
src/NLog/LogFactory.cs (9)
  • System (372-402)
  • System (680-713)
  • Obsolete (119-125)
  • Obsolete (515-521)
  • Obsolete (895-905)
  • Obsolete (913-920)
  • Obsolete (928-938)
  • Obsolete (945-950)
  • Obsolete (1026-1032)
src/NLog/LayoutRenderers/Wrappers/JsonEncodeLayoutRendererWrapper.cs (3)
src/NLog/LogFactory.cs (2)
  • System (372-402)
  • System (680-713)
src/NLog/Layouts/LayoutParser.cs (1)
  • System (507-547)
src/NLog/LayoutRenderers/ExceptionLayoutRenderer.cs (1)
  • System (397-411)
🔇 Additional comments (7)
src/NLog/Targets/JsonSerializeOptions.cs (1)

74-74: Appropriate addition of EditorBrowsable attribute to obsolete property

The addition of [EditorBrowsable(EditorBrowsableState.Never)] attribute to the already obsolete EscapeForwardSlash property enhances the deprecation strategy by hiding this property from IntelliSense and design-time tools, making it less likely to be used in new code.

src/NLog/Targets/DefaultJsonSerializer.cs (1)

98-101: Good refactoring for improved readability

Creating a local variable for options.EscapeUnicode simplifies the code by reducing property access repetition. This is a minor but worthwhile improvement to code readability without changing functionality.

src/NLog/LayoutRenderers/Wrappers/JsonEncodeLayoutRendererWrapper.cs (2)

37-37: Appropriate import added for attribute usage

Adding the System.ComponentModel import is necessary for using the EditorBrowsable attribute.


74-74: Consistent implementation of EditorBrowsable attribute

The addition of [EditorBrowsable(EditorBrowsableState.Never)] attribute to the obsolete EscapeForwardSlash property correctly follows the pattern established in other files, ensuring consistent handling of this deprecated feature across the library.

src/NLog/Layouts/JSON/JsonLayout.cs (1)

237-237: Consistent deprecation strategy applied

The addition of [EditorBrowsable(EditorBrowsableState.Never)] attribute to the JsonLayout's EscapeForwardSlash property completes the consistent application of this deprecation strategy across all relevant classes, effectively hiding this obsolete property from design-time tools.

src/NLog/Layouts/JSON/JsonAttribute.cs (2)

37-37: LGTM: Added appropriate namespace for EditorBrowsable attribute

The addition of System.ComponentModel namespace is necessary for using the EditorBrowsable attribute that's being applied to the EscapeForwardSlash property.


137-139: Well-structured obsolete annotation approach

The changes properly mark the EscapeForwardSlash property as obsolete with a clear message explaining why (forward slashes are valid in JSON). Additionally, the EditorBrowsable(EditorBrowsableState.Never) attribute hides this property from IntelliSense and design-time tools, further discouraging its use. This follows the established pattern in the codebase for handling obsolete members.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@snakefoot
snakefoot enabled auto-merge (squash) April 5, 2025 20:23
@snakefoot
snakefoot disabled auto-merge April 5, 2025 20:23
@snakefoot
snakefoot enabled auto-merge (squash) April 5, 2025 20:23
@snakefoot snakefoot changed the title Marked JsonLayout EscapeForwardSlash as obsolete and has no effect Marked JsonLayout EscapeForwardSlash as obsolete and without any effect Apr 5, 2025
@snakefoot
snakefoot disabled auto-merge April 5, 2025 20:28
@snakefoot
snakefoot enabled auto-merge (squash) April 5, 2025 20:28
@snakefoot snakefoot added breaking change Breaking API change (different to semantic change) and removed breaking change Breaking API change (different to semantic change) labels Apr 5, 2025
@sonarqubecloud

sonarqubecloud Bot commented Apr 5, 2025

Copy link
Copy Markdown

@snakefoot
snakefoot merged commit 53da53a into NLog:dev Apr 5, 2025
@snakefoot snakefoot added needs documentation on wiki breaking change Breaking API change (different to semantic change) json / json-layout and removed breaking behavior change Same API, different result labels Apr 24, 2025
@snakefoot

Copy link
Copy Markdown
Contributor Author

Updated wiki: https://github.com/NLog/NLog/wiki/JsonLayout

@snakefoot snakefoot added the documentation done all docs done (wiki, api docs, lists on nlog-project.org, xmldocs) label Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Breaking API change (different to semantic change) documentation done all docs done (wiki, api docs, lists on nlog-project.org, xmldocs) json / json-layout needs documentation on wiki size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.