C#: Warn about negative index when accessing arrays

Hey @m-gallesio , very good catch!

I am honestly surprised this is valid from the compiler’s perspective, since it is a guaranteed runtime exception. :slight_smile:

I made an issue in the C# analyzer repository. Click here
I also added some extra cases that are always runtime exceptions, such as 0 and >Length.
I also linked this thread to the issue.
Feel free to add any comments you might have there.

Cheers!

1 Like