{"record":{"id":"4d9e15bc20d8fa65","repo":"RicoSuter/NSwag","slug":"used-arguments-usedargs-count-provided-arguments","errorCode":null,"errorMessage":"Used arguments ({usedArgs.Count}) != Provided arguments ({commandArguments.Count()}) -> Check [{string.Join(\", \", unusedArgs)}]","messagePattern":"Used arguments \\((.+?)\\) != Provided arguments \\((.+?)\\) -> Check \\[(.+?)\\]","errorType":"exception","errorClass":"UnusedArgumentException","httpStatus":null,"severity":"error","filePath":"src/NSwag.Commands/NConsole/CommandLineProcessor.cs","lineNumber":181,"sourceCode":"                        if (value != null)\n                            property.SetValue(command, value);\n                        if (usedArg != null)\n                            usedArgs.Add(usedArg);\n                    }\n                }\n\n                if (usedArgs.Count != commandArguments.Count())\n                {\n                    var unusedArgs = new List<string>();\n                    foreach (string arg in commandArguments)\n                    {\n                        if (!usedArgs.Contains(arg))\n                        {\n                            unusedArgs.Add(arg);\n                        }\n                    }\n\n                    throw new UnusedArgumentException($\"Used arguments ({usedArgs.Count}) != Provided arguments ({commandArguments.Count()}) -> Check [{string.Join(\", \", unusedArgs)}]\");\n                }\n\n                var output = await command.RunAsync(this, _consoleHost);\n                return new CommandResult\n                {\n                    Command = command,\n                    Output = output\n                };\n            }\n            else\n                throw new InvalidOperationException(\"The command '\" + commandName + \"' could not be found.\");\n        }\n\n        /// <summary>Processes the command in the given command line arguments.</summary>\n        /// <param name=\"args\">The arguments.</param>\n        /// <param name=\"input\">The output from the previous command.</param>\n        /// <returns>The exeucuted command.</returns>\n        /// <exception cref=\"InvalidOperationException\">The command could not be found.</exception>","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/RicoSuter/NSwag/blob/63daf8fcc3a25151b62eb4b326a1e8ea048a0d41/src/NSwag.Commands/NConsole/CommandLineProcessor.cs#L163-L199","documentation":"After a command runs, ProcessSingleAsync verifies every argument token parsed from the command line was actually consumed by some command property. If usedArgs.Count != provided count, unused tokens (possibly looking like values rather than flags) are listed and it throws UnusedArgumentException. Usually a misspelled or unrecognized option slipped through the parser.","triggerScenarios":"Passing an argument that matches no [Argument] property — e.g. a typo like /intput:swagger.json, an option removed in a newer NSwag version, or a stray token (extra file path, unquoted space splitting an argument) — so it remains in unusedArgs after processing.","commonSituations":"Typo'd option names; upgrading NSwag where an option was renamed; copy-pasting options from an .nswag file onto the command line where they aren't valid; spaces inside paths breaking one argument into two.","solutions":["Compare the listed unused arguments against valid options for the command and fix typos (e.g. /input not /intput).","Check `nswag help <command>` (or the command's documentation) for the exact supported argument names in your NSwag version.","Quote paths containing spaces so one option doesn't split into stray tokens.","Remove options deprecated/renamed in your NSwag version."],"exampleFix":"// before\nnswag openapi2csclient /intput:swagger.json /output:Client.cs\n\n// after\nnswag openapi2csclient /input:swagger.json /output:Client.cs","handlingStrategy":"validation","validationCode":"var validOptions = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { \"input\", \"output\", \"namespace\", ... };\nvar unknown = rawArgs.Where(a => a.StartsWith(\"/\") && !validOptions.Contains(a.TrimStart('/').Split(':')[0])).ToList();\nif (unknown.Any()) throw new ArgumentException($\"Unrecognized options: {string.Join(\", \", unknown)}\");","typeGuard":null,"tryCatchPattern":"try { result = await processor.ProcessSingleAsync(args, typeof(cmd)); }\ncatch (UnusedArgumentException ex) { Console.Error.WriteLine($\"Check option names — {ex.Message}\"); }","preventionTips":["Verify option names with `nswag help <command>` for your NSwag version","Watch for typos like /intput vs /input — the parser reports them only after the command runs","Quote arguments containing spaces so they don't split into stray tokens","When upgrading NSwag, diff renamed/removed options before reusing old command lines"],"tags":["cli","unrecognized-argument","command-line"],"backgroundTag":"invalid-cli-argument","analyzedSha":"63daf8fcc3a25151b62eb4b326a1e8ea048a0d41","analyzedAt":"2026-09-14T11:38:15.205Z","contentChangedAt":"2026-09-14T11:38:15.205Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}