Skip to content

Commit 63b4e71

Browse files
jessehouwingCopilot
andcommitted
Fix net462/C# 7.3 build: avoid switch-expression recursive patterns
CS8370: recursive patterns require C# 8+; the net462 (PS 5.1) target compiles with C# 7.3. Replaced the switch expression with an if/else chain. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 597b01c commit 63b4e71

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎Rules/UseCorrectCasingForDotSourcedFiles.cs‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,19 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
6565
}
6666

6767
Ast literalAst = commandAst.CommandElements[0];
68-
string raw = literalAst switch
68+
string raw;
69+
if (literalAst is StringConstantExpressionAst constant)
6970
{
70-
StringConstantExpressionAst constant => constant.Value,
71-
ExpandableStringExpressionAst expandable => expandable.Value,
72-
_ => null,
73-
};
71+
raw = constant.Value;
72+
}
73+
else if (literalAst is ExpandableStringExpressionAst expandable)
74+
{
75+
raw = expandable.Value;
76+
}
77+
else
78+
{
79+
raw = null;
80+
}
7481
if (string.IsNullOrWhiteSpace(raw))
7582
{
7683
continue;

0 commit comments

Comments
 (0)