Return statements in anonymous functions causing unreachable code warnings?

brlutzbrlutz Posts: 1

I have some .NET C# code being analyzed with parasoft and it's flagging some fairly annoying warnings. The code has an anonymous function that contains a return statement that continues on to some other code, but I'm getting "unreachable code" error CS.PB.USC.UC-1.

Response _response = await this.WctCommunicationsService.SendAsync(
(Customer c) =>
{ return c.UpdateAsync(_request);},

if(_response.Status == "Success") // parasoft-suppress CS.PB.USC.UC-1

return _whatever;

Has anyone else run into this? I feel like this is a valid use case and fully valid .NET 4.6.1 code. Suppressing is also messy because we don't allow comments on block elements due to our lint/stylecop rules, so we have to suppress parasoft and then suppress the linter at the same time.



Sign In or Register to comment.