You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got CA2208 message, which doesn't make sense. I was able to reproduce it:
Source code:
namespace ConsoleApp16;
internal class Program
{
static void Main()
{
Test([1, 2, 3]);
}
static void Test(byte[] data)
{
throw new ArgumentException("data.Length of encrypted data must be completely divisible by 8.");
}
}
The message only appears if argument of ArgumentException constructor starts with "data.Length". If I simply remove "data", then message disappears:
It seems static analyzer checks for parameter name matching starting value of string? Note: ArgumentException has different order of parameters in overload, where both text and parameter name are given, as e.g. ArgumentOutOfRangeException. I guess there is a bug, which assume it's must be first and text is used to determine whenever it's parameter name to show the message.
The suggested fix is also broken, it tries to put whole string into nameof(...), that clearly wouldn't work:
Original Comments
Feedback Bot on 4/19/2024, 00:31 AM:
(private comment, text removed)
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered:
@CollinAlpert, it was .Net 8.0. But I can't reproduce it anymore either. It seems the issue was fixed (I just installed Version 17.9.6 update for my VS2022 x64) or it was something local. Close the subject please.
This issue has been moved from a ticket on Developer Community.
I got CA2208 message, which doesn't make sense. I was able to reproduce it:
Source code:
The message only appears if argument of
ArgumentException
constructor starts with"data.Length"
. If I simply remove "data", then message disappears:It seems static analyzer checks for parameter name matching starting value of string? Note:
ArgumentException
has different order of parameters in overload, where both text and parameter name are given, as e.g.ArgumentOutOfRangeException
. I guess there is a bug, which assume it's must be first and text is used to determine whenever it's parameter name to show the message.The suggested fix is also broken, it tries to put whole string into
nameof(...)
, that clearly wouldn't work:Original Comments
Feedback Bot on 4/19/2024, 00:31 AM:
(private comment, text removed)
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered: