-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Area-CompilersFeature - Pattern MatchingPattern MatchingPattern MatchingTestTest failures in roslyn-CITest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverageDescribes a specific feature or scenario that does not have test coverage
Milestone
Description
This is a placeholder for a test plan for the set of changes planned for pattern-matching in C# 9.
See dotnet/csharplang#2850 for a draft specification.
- Potential breaking changes
-
is (var x) _is a tuple pattern -
is and _ando is or _are type patterns -
is string andando is string orare type patterns- Behavior in earlier C# versions
-
-
is (var x)is a parenthesized var pattern - Language version on each new kind of pattern.
- Test the semantic model for the type pattern.
- Test IOperation for all new pattern forms.
- Test definite assignment under
andpattern combinator. - Verify which patterns/type permutations are allowed for relational patterns.
- Test
byteValue is < 1000should produce an error (1000 cannot convert tobyte) - Test expected behavior around subsumption for relational patterns of different types (e.g.
< 0 and < 0f) - Test subsumption of type patterns
-
x is BaseType and/or DerivedType -
x is BaseType and/or UnrelatedType -
x is SomeType and/or SomeInterfaceType -
x is SealedType and/or SomeInterfaceType
-
- Diagnostic for unreachable/constant cases [See Warn for is-pattern using a relational pattern with a known result. #42501]
-
o is not var x -
o is not _ -
short is > 65535
-
- Switch relational subsumption vs constant pattern, e.g.
c# i switch { < 10 => ..., 1 => ... // error, subsumed- All constant types,
(u)int, (s)byte, short, long, double, float, char
- All constant types,
- Relational pattern on enums
- Varying underlying
- Error comparing to non-enum types
- Subsumption uses domain of underlying type
- IL baseline for perf-sensitive compare e.g., ASCII check:
c switch { < 'z' and > 'a' => "lower", < 'Z' and > 'A' => "upper", _ => "non-alphabetical", }
- Diagnostic differences between
is type-patternandis typeexpression - Precedence of parenthesized pattern
- spec observability of side effects in pattern tests? (a or (b and c))
IDE
- Verify completion and formatting for different kinds of patterns
- The refactoring from
(object)x != nulltox is objectshould be changed to producex is not null
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-CompilersFeature - Pattern MatchingPattern MatchingPattern MatchingTestTest failures in roslyn-CITest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverageDescribes a specific feature or scenario that does not have test coverage