-
Notifications
You must be signed in to change notification settings - Fork 481
Closed
Description
Analyzer
Diagnostic ID: CA1865: Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char
Analyzer source
NuGet Package: Microsoft.CodeAnalysis.NetAnalyzers
Version: 8.0.0-preview.23420.2
Describe the bug
For multiline statement fixer removes newline after fixed method call if it follows closing bracket ')' directly or have comment on next line
Steps To Reproduce
public class Class1
{
public static void Test(string str)
{
// newline preserved due to comment below
if (str.StartsWith(".", StringComparison.Ordinal)
// space after ) - newline preserved
|| str.EndsWith(".", StringComparison.Ordinal)
// don't trigger unwrap
|| str.IndexOf(".", StringComparison.Ordinal) == 3
// // newline removed
|| 2 == str.IndexOf(".", StringComparison.Ordinal)
|| str == "test")
{
return;
}
}
}
Expected behavior
public class Class1
{
public static void Test(string str)
{
// newline preserved due to comment below
if (str.StartsWith('.')
// space after ) - newline preserved
|| str.EndsWith('.')
// don't trigger unwrap
|| str.IndexOf('.') == 3
// // newline removed
|| 2 == str.IndexOf('.')
|| str == "test")
{
return;
}
}
}Actual behavior
public class Class1
{
public static void Test(string str)
{
// newline preserved due to comment below
if (str.StartsWith('.')
// space after ) - newline preserved
|| str.EndsWith('.')
// don't trigger unwrap
|| str.IndexOf('.') == 3
// // newline removed
|| 2 == str.IndexOf('.') || str == "test")
{
return;
}
}
}