- Operating system: Windows 10
- Visual Studio version: Visual Studio 2022
- SonarLint plugin version: 7.4.0.80741
- Programming language you’re coding in: C# 12
- Is connected mode used: No
I’ve created a few local functions inside a method in a custom Windows Forms control I’m creating. According to JetBrains ReSharper, local functions should be at the end of the method body after a return statement. However, when I add the empty return statement, SonarLint flags it because the method it’s in is a void method.
Here is a skeleton of the method in question:
protected override void OnPaint(PaintEventArgs e)
{
// code excluded
return;
void DrawDigit(char digit, Point digitOrigin)
{
// code excluded
}
IEnumerable<char> GetDigits()
{
// code excluded
}
IEnumerable<Segment> GetSegmentsForDigit(char digit)
{
// code excluded
}
}
Here is a screenshot of the return statement being flagged: