Introduce 'use pattern combinators' feature#43596
Introduce 'use pattern combinators' feature#43596CyrusNajmabadi merged 48 commits intodotnet:release/dev16.8-preview1from
Conversation
|
Sample results: 9699f28 /cc @CyrusNajmabadi |
| { | ||
| return variable is 0 or | ||
| 1 or | ||
| 2; |
There was a problem hiding this comment.
open question about the right thing to do here. it's arguable that if we get down to a primary expression/token that we might want to remove the newlines.
|
|
||
| private Not(AnalyzedPattern pattern) => Pattern = pattern; | ||
|
|
||
| private static BinaryOperatorKind Negate(BinaryOperatorKind kind) => kind switch |
There was a problem hiding this comment.
so we already have a negate helper for patterns. i dont' love that we now have two.
There was a problem hiding this comment.
There's lots of code that could be shared with if-to-switch. I just didn't go thought that yet. I'd prefer this to be done separately.
src/Features/CSharp/Portable/UsePatternCombinators/AnalyzedPattern.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
Show resolved
Hide resolved
src/Features/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
Outdated
Show resolved
Hide resolved
| BinaryOperatorKind.LessThan => SyntaxKind.LessThanToken, | ||
| BinaryOperatorKind.GreaterThan => SyntaxKind.GreaterThanToken, | ||
| BinaryOperatorKind.LessThanOrEqual => SyntaxKind.LessThanEqualsToken, | ||
| BinaryOperatorKind.GreaterThanOrEqual => SyntaxKind.GreaterThanEqualsToken, |
There was a problem hiding this comment.
i feel like we have this in a few places. could we move this helper to another directory and share any of this common stuff in a static class?
...Features/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
...Features/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
...Features/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
...tures/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsDiagnosticAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tures/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsDiagnosticAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsHelpers.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tures/CSharpTest/UsePatternCombinators/CSharpUsePatternCombinatorsDiagnosticAnalyzerTests.cs
Show resolved
Hide resolved
|
Very close to signing off. Just a few pieces of final feedback. |
| return (leftPattern, rightPattern) is (Not left, Not right) | ||
| ? Not.Create(new Binary(left.Pattern, right.Pattern, !isDisjunctive, token, target)) | ||
| : new Binary(leftPattern, rightPattern, isDisjunctive, token, target); | ||
| return new Binary(leftPattern, rightPattern, isDisjunctive, token, target); |
There was a problem hiding this comment.
i think it's a worth a comment that we are explicitly not trying to simplify here as user may not find the change substantively better for their domain.
There was a problem hiding this comment.
when we do want to do that, it'll be in another pass, not the factory method.
# Conflicts: # src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs # src/EditorFeatures/Test/Diagnostics/IDEDiagnosticIDConfigurationTests.cs
|
@CyrusNajmabadi #44513 and #45094 are going in. If we're gonna target either branch we can relax |
|
Let's just target master, and just allow for tihs (knowing that Neal's work will eventually flow in). |
# Conflicts: # src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs # src/EditorFeatures/Test/Diagnostics/IDEDiagnosticIDConfigurationTests.cs
|
@CyrusNajmabadi Done. quick question: when shared analyzer layer is going to reference latest bits? is it after final release or sometime sooner? |
Not certain. @mavasani do you know when we do this? |
|
@jinujoseph Do you know when master is open for new feature work? |
|
@CyrusNajmabadi , master will be open for new feature post 16.7.Preview6 |
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions.cs
Outdated
Show resolved
Hide resolved
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
code looks great! one question about what default state this is in. thanks!
|
Merged. Thanks! |
|
Thanks! I discovered two issues while testing this out in our codebase
If I find some time for it I'll open a follow up. |
Contributes to #42368