rspec/rules/S6677/why-dotnet.adoc
github-actions[bot] 6fa7fbe87e
Create rule S6677: Named placeholders should be unique (#2584)
* Create rule S6677

* Specify rule

* Address comments

* Address comments 2

* Remove vbnet until it gets implemented

* Add logging tag

* Fix asciidoc parsing issue

---------

Co-authored-by: csaba-sagi-sonarsource <csaba-sagi-sonarsource@users.noreply.github.com>
Co-authored-by: Čaba Šagi <csaba.sagi@sonarsource.com>
Co-authored-by: Gregory Paidis <gregory.paidis@sonarsource.com>
2024-02-26 12:36:08 +01:00

14 lines
1.0 KiB
Plaintext

== Why is this an issue?
Named placeholders in https://messagetemplates.org[message templates] should be unique. The meaning of the named placeholders is to store the value of the provided argument under that name, enabling easier log querying. Since the named placeholder is used multiple times, it cannot store the different values uniquely with each name hence not serving its original purpose.
There can be different behaviours when using the same named placeholder multiple times:
* https://www.nuget.org/packages/Microsoft.Extensions.Logging[Microsoft.Extensions.Logging] saves the different values under the same name
* https://www.nuget.org/packages/Serilog[Serilog] stores only the latest assigned value
* https://www.nuget.org/packages/NLog[Nlog] makes the name unique by suffixing it with ``++_index++``
The rule covers the following logging frameworks:
* https://www.nuget.org/packages/Microsoft.Extensions.Logging[Microsoft.Extensions.Logging]
* https://www.nuget.org/packages/Serilog[Serilog]
* https://www.nuget.org/packages/NLog[Nlog]