Skip to content

SA1008 is returned for collection expressions containing multi-argument lambda. #3931

@TheBrambleShark

Description

@TheBrambleShark

I'm recreating the MultiValueDictionary type and part of that means recreating tests.

I'm working with a test for the Add(TKey, TValue) function, here:

https://github.com/dotnet/corefxlab/blob/archive/tests/Microsoft.Experimental.Collections.Tests/Microsoft/Collections/Extensions/MultiValueDictionaryTests.cs#L577-L582

private AddDelegate<TKey, TValue>[] Add<TKey, TValue>()
    {
        var ret = new AddDelegate<TKey, TValue>[1];
        ret[0] = (MultiValueDictionary<TKey, TValue> mvd, TKey key, TValue value) => mvd.Add(key, value);
        return ret;
    }

When I try to rebuild this method, I am using this code:

private static AddDelegate<TKey, TValue>[] Add<TKey, TValue>()
    where TKey : notnull
    => [(mvd, key, value) => mvd.Add(key, value)];
        ^ SA1008 Openening parenthesis should be preceded by a space.

If I follow its advice and provide a space, then I get a different error.

=> [ (mvd, key, value) => mvd.Add(key, value)];
   ^ SA1010 Opening square brackets should not be followed by a space.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions