roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

Suggestion: Analyzer for using Path.Combine

Open baruchiro opened this issue 6 years ago • 0 comments
trafficstars

In cross-platform development (and probably at all), you should not use a hard-coded path. For example,

var path = @"paTh\To\subfOlder";

Will not behave as expected on Linux. Each path must be by using Path.Combine, and with awareness about the case.

In addition, identify a line in the text:

var secondLine = text.split("\r\n")[1];

Will not run as expected on Linux, and will need to use:

var secondLine = text.split(Environment.NewLine)[1];

Is there such an analyzer? Is it possible to develop?

(I'm new in the Analyzers, but know AST and so on, so with some general intent or design, I believe I can develop myself)

baruchiro avatar Nov 14 '19 16:11 baruchiro