Skip to content

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Jan 24, 2022

In this PR we make support for Extended property patterns.
The idea is that the new form is de-sugared into a pattern expression in the old form. The only difference will be some slightly different locations.

@github-actions github-actions bot added the C# label Jan 24, 2022
@michaelnebel michaelnebel force-pushed the csharp/extended-prop-patterns branch 3 times, most recently from 8c1b2ac to c353515 Compare January 25, 2022 12:30
@michaelnebel michaelnebel force-pushed the csharp/extended-prop-patterns branch from c353515 to abe6d08 Compare January 25, 2022 14:00
@michaelnebel michaelnebel force-pushed the csharp/extended-prop-patterns branch from abe6d08 to f1d5d3a Compare January 25, 2022 14:13
@michaelnebel michaelnebel marked this pull request as ready for review January 25, 2022 15:28
@michaelnebel michaelnebel requested a review from a team as a code owner January 25, 2022 15:28
Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It would be nice to have data flow tests for this as well, e.g. in ql/test/library-tests/dataflow/fields/.

@michaelnebel
Copy link
Contributor Author

michaelnebel commented Jan 31, 2022

LGTM. It would be nice to have data flow tests for this as well, e.g. in ql/test/library-tests/dataflow/fields/.

Yes, that is a good idea, but I don't think that pattern matching is really supported in the dataflow library.
As an example, the following code results in a failure of flow not being detected by dataflow library.

public struct Struct
{
    public object Field;
    public object Prop { get; init; }
    public Struct(object field, object prop) => (Field, Prop) = (field, prop);
}

private void M1()
{
    var o = Source<object>(1);
    var s = new Struct(o, o);
    if (s is Struct { Field: object p })
    {
        Sink(p); // $ hasValueFlow=1
    }
}

An issue has been created for this.

@michaelnebel michaelnebel requested a review from hvitved January 31, 2022 09:35
@michaelnebel michaelnebel merged commit 56ac990 into github:main Jan 31, 2022
@michaelnebel michaelnebel deleted the csharp/extended-prop-patterns branch January 31, 2022 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants