System.CommandLine.CommandLineConfiguration.ThrowIfInvalid C# (CSharp) Method

ThrowIfInvalid() static private method

static private ThrowIfInvalid ( System.CommandLine.Command command ) : void
command System.CommandLine.Command
return void
            static void ThrowIfInvalid(Command command)
            {
                if (command.Parents.FlattenBreadthFirst(c => c.Parents).Any(ancestor => ancestor == command))
                {
                    throw new CommandLineConfigurationException($"Cycle detected in command tree. Command '{command.Name}' is its own ancestor.");
                }

                int count = command.Subcommands.Count + command.Options.Count;
                for (var i = 0; i < count; i++)
                {
                    IdentifierSymbol symbol1AsIdentifier = GetChild(i, command);
                    for (var j = i + 1; j < count; j++)
                    {
                        IdentifierSymbol symbol2AsIdentifier = GetChild(j, command);

                        foreach (var symbol2Alias in symbol2AsIdentifier.Aliases)
                        {
                            if (symbol1AsIdentifier.Name.Equals(symbol2Alias, StringComparison.Ordinal) ||
                                symbol1AsIdentifier.Aliases.Contains(symbol2Alias))
                            {
                                throw new CommandLineConfigurationException($"Duplicate alias '{symbol2Alias}' found on command '{command.Name}'.");
                            }
                        }
                    }

                    if (symbol1AsIdentifier is Command childCommand)
                    {
                        ThrowIfInvalid(childCommand);
                    }
                }
            }

Same methods

CommandLineConfiguration::ThrowIfInvalid ( ) : void