Skip to content

Commit f9b77b9

Browse files
authored
Merge pull request #44 from asynkron/codex/refactor-direction-assignment-in-getparameters
Refactor parameter direction detection using switch expression
2 parents 2c4684f + b8602c7 commit f9b77b9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Core/Syntax/LinqToSqlContextSyntaxWalker.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,12 @@ private List<ParameterMapping> GetParameters(MethodDeclarationSyntax method)
120120
{
121121
return method.ParameterList.Parameters.Select(p =>
122122
{
123-
var direction = "Input";
124-
if (p.Modifiers.Any(m => m.IsKind(SyntaxKind.OutKeyword)))
125-
direction = "Output";
126-
else if (p.Modifiers.Any(m => m.IsKind(SyntaxKind.RefKeyword)))
127-
direction = "InputOutput";
123+
var direction = p.Modifiers switch
124+
{
125+
var mods when mods.Any(m => m.IsKind(SyntaxKind.OutKeyword)) => "Output",
126+
var mods when mods.Any(m => m.IsKind(SyntaxKind.RefKeyword)) => "InputOutput",
127+
_ => "Input"
128+
};
128129

129130
int? size = null;
130131
var attr = p.AttributeLists.SelectMany(a => a.Attributes)

0 commit comments

Comments
 (0)