Repository: dotnet/runtime
File: src/libraries/System.Collections.Concurrent/tests/ConcurrentDictionary/ConcurrentDictionaryTests.cs (C#)

Code before:

        private static void TestGetOrAddOrUpdate(int cLevel, int initSize, int threads, int addsPerThread, bool isAdd)
        {
            ConcurrentDictionary<int, int> dict = new ConcurrentDictionary<int, int>(cLevel, 1);

            int count = threads;
            using (ManualResetEvent mre = new ManualResetEvent(false))
            {
                for (int i = 0; i < threads; i++)
                {
                    int ii = i;
                    Task.Run(
                        () =>
                        {
                            for (int j = 0; j < addsPerThread; j++)
                            {
                                if (isAdd)
                                {
                                    //call one of the overloads of GetOrAdd
                                    switch (j % 3)
                                    {
                                        case 0:
                                            dict.GetOrAdd(j, -j);
                                            break;
                                        case 1:
                                            dict.GetOrAdd(j, x => { Assert.Equal(j, x); return -x; });
                                            break;
                                        case 2:
                                            dict.GetOrAdd(j, (x, m) => { Assert.Equal(j, x); Assert.Equal(-1, m); return x * m; }, -1);
                                            break;
                                    }
                                }
                                else
                                {
                                    switch (j % 3)
                                    {
                                        case 0:
                                            dict.AddOrUpdate(j, -j, (k, v) => { Assert.Equal(j, k); Assert.Equal(-j, v); return v; });
                                            break;
                                        case 1:
                                            dict.AddOrUpdate(j, (k) => { Assert.Equal(j, k); return -k; }, (k, v) => { Assert.Equal(j, k); Assert.Equal(-j, v); return -k; });
                                            break;
                                        case 2:
                                            dict.AddOrUpdate(j, (k, m) => { Assert.Equal(j, k); Assert.Equal(-1, m); return k * m; }, (k, v, m) => { Assert.Equal(j, k); Assert.Equal(-j, v); Assert.Equal(-1, m); return k * m; }, -1);
                                            break;
                                    }
                                }
                            }
                            if (Interlocked.Decrement(ref count) == 0) mre.Set();
                        });
                }

Review comment (suggestion):
@copilot, for all of these, please avoid putting multiple statements onto a single line, e.g. instead do:
```csharp
dict.GetOrAdd(j, x =>
{
    Assert.Equal(j, x);
    return -x;
});
```

Code after:

        private static void TestGetOrAddOrUpdate(int cLevel, int initSize, int threads, int addsPerThread, bool isAdd)
        {
            ConcurrentDictionary<int, int> dict = new ConcurrentDictionary<int, int>(cLevel, 1);

            int count = threads;
            using (ManualResetEvent mre = new ManualResetEvent(false))
            {
                for (int i = 0; i < threads; i++)
                {
                    int ii = i;
                    Task.Run(
                        () =>
                        {
                            for (int j = 0; j < addsPerThread; j++)
                            {
                                if (isAdd)
                                {
                                    //call one of the overloads of GetOrAdd
                                    switch (j % 3)
                                    {
                                        case 0:
                                            dict.GetOrAdd(j, -j);
                                            break;
                                        case 1:
                                            dict.GetOrAdd(j, x =>
                                            {
                                                Assert.Equal(j, x);
                                                return -x;
                                            });
                                            break;
                                        case 2:
                                            dict.GetOrAdd(j, (x, m) =>
                                            {
                                                Assert.Equal(j, x);
                                                Assert.Equal(-1, m);
                                                return x * m;
                                            }, -1);
                                            break;
                                    }
                                }
                                else
                                {
                                    switch (j % 3)
                                    {
                                        case 0:
                                            dict.AddOrUpdate(j, -j, (k, v) =>
                                            {
                                                Assert.Equal(j, k);
                                                Assert.Equal(-j, v);
                                                return v;