WiseTechGlobal / WTG.Analyzers

Analyzers from WiseTech Global to enforce our styles, behaviours, and prevent common mistakes.
Other
16 stars 3 forks source link

WI00405814: Analyzer to warn against manually specified path separators. #146

Closed yaakov-h closed 3 years ago

yaakov-h commented 3 years ago

Resolves #122.

PR filed purely so I can better track the diff, but nowhere near ready - just getting started.

yaakov-h commented 3 years ago

Still TODO:

Path.Combine(new[] { /* values here */ });

And need to fix false-positives for older target runtimes:

error CS1501: No overload for method 'Combine' takes 4 arguments

yaakov-h commented 3 years ago

Bug:

int intValue;
Path.Combine(BasePath, $@"A\B\C\D{intValue}.e");

gets transformed into:

int intValue;
Path.Combine(BasePath, "A", "B", "C", "D", intValue);

rather than:

int intValue;
Path.Combine(BasePath, "A", "B", "C", "D{intValue}.e");
yaakov-h commented 3 years ago

Bug fixes and TODOs done. Could probably do with a bit of simplification and deduplication still.

yaakov-h commented 3 years ago

Ran WTG2008 with BulkAnalysisRunner against our two biggest repos again, no bugs found.