Meziantou.Analyzer icon indicating copy to clipboard operation
Meziantou.Analyzer copied to clipboard

MA0124 Support case insensitive matching mode

Open latop2604 opened this issue 6 months ago • 5 comments

The rule MA0124 is really useful. (Others too but it's not the point).

It would be nice to have a way (csproj property maybe) to enable a case insensitive matching mode in order to not have to duplicate all parameter name variations in the LoggerParameterTypes.txt.

In my case, all parameters from my log message are translated in camelCase. So MyPropertyId and myPropertyId will be a single one at the end. But myPropertyId and mypropertyid will stay as two distinct properties. The full case insensitive would be enough, but camel case matching mode would be even better.

Voila voila, Have a nice day

latop2604 avatar Dec 28 '23 14:12 latop2604

It could also be per line configuration like javascript regex flag notation /\w+\s/gis;

latop2604 avatar Dec 28 '23 14:12 latop2604

  • Is it an issue because the parameters are not normalized in the code? In this case, would it be better to provide a code fix to update all log parameters in the code?
  • Should the case-sensitivity be per parameter? Or should it be global?

meziantou avatar Dec 28 '23 15:12 meziantou

Should the case-sensitivity be per parameter? Or should it be global?

Why not both? Master project property and/or per param. Both would fit my needs

Is it an issue because the parameters are not normalized in the code? In this case, would it be better to provide a code fix to update all log parameters in the code?

Even if the existing source code is normalised, if someone add an existing param but with a different casing, it will not trigger any warning if not already exactly defined in LoggerParameterTypes

latop2604 avatar Jan 08 '24 17:01 latop2604

Why not both? Master project property and/or per param. Both would fit my needs

Everything's possible, but time is not infinite. I prefer keeping the scope small if it fits the need.

Even if the existing source code is normalised, if someone add an existing param but with a different casing, it will not trigger any warning if not already exactly defined in LoggerParameterTypes

You can enable MA0135 to report all unconfigured parameters.

meziantou avatar Jan 23 '24 03:01 meziantou

MA0135 is a nice alternative. Thx.

latop2604 avatar Jan 23 '24 11:01 latop2604

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] avatar Mar 24 '24 01:03 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Apr 07 '24 01:04 github-actions[bot]