Skip to content

Commit

Permalink
remove conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgerangel-msft committed Nov 20, 2024
1 parent 8188d90 commit c33dcf7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,17 +412,13 @@ private ScmMethodProvider BuildProtocolMethod(MethodProvider createRequestMethod
{
// If there are optional parameters, but the request options parameter is not optional, make the optional parameters nullable required.
// This is to ensure that the request options parameter is always the last parameter.

for (var i = 0; i < optionalParameters.Count; i++)
foreach (var parameter in optionalParameters)
{
// Ensure a new copy is made to avoid modifying the original reference.
var optionalParam = optionalParameters[i].ToPublicInputParameter();

optionalParam.DefaultValue = null;
optionalParam.Type = optionalParameters[i].Type.WithNullable(true);
requiredParameters.Add(optionalParam);
parameter.DefaultValue = null;
parameter.Type = parameter.Type.WithNullable(true);
}

requiredParameters.AddRange(optionalParameters);
optionalParameters.Clear();
}

Expand Down Expand Up @@ -495,14 +491,6 @@ private bool ShouldAddOptionalRequestOptionsParameter()
{
return true;
}
if (ProtocolMethodParameters[i].DefaultValue == null && ConvenienceMethodParameters[i].DefaultValue != null)
{
return true;
}
if (ProtocolMethodParameters[i].DefaultValue != null && ConvenienceMethodParameters[i].DefaultValue == null)
{
return true;
}
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@
"commandName": "Executable",
"executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe"
},
"http-resiliency-srv-driven-v1": {
"commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/resiliency/srv-driven/v1 -p StubLibraryPlugin",
"commandName": "Executable",
"executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe"
},
"http-routes": {
"commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/routes -p StubLibraryPlugin",
"commandName": "Executable",
Expand Down

0 comments on commit c33dcf7

Please sign in to comment.