Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public enum CommandType
- {
- Usage
- }
- public class Options
- {
- [OptDef(OptValType.Flag)]
- [LongOptionName("help")]
- [Description("Displays this help")]
- public bool Help { get; set; }
- public CommandType CommandType
- {
- get { return CommandType.Usage; }
- }
- }
- TextWriter output = Console.Out;
- Options options = new Options { Help = true };
- Parser p = ParserFactory.BuildParser(options);
- p.Parse();
- output.WriteLine("Usage: Oasis.Console [--a]");
- UsageBuilder builder = new UsageBuilder();
- builder.BeginSection("Arguments:");
- builder.AddOptions(p.GetOptionDefinitions()); //could the issue be created here?
- builder.EndSection();
- builder.ToText(output, OptStyle.Unix, true); //The problem occurs here
- System.Xml.XPath.XPathException : Function 'ext:FormatText()' has failed.
- ----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
- ----> System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection.
- Parameter name: startIndex
- at MS.Internal.Xml.XPath.FunctionQuery.Evaluate(XPathNodeIterator nodeIterator)
- at System.Xml.Xsl.XsltOld.Processor.ValueOf(ActionFrame context, Int32 key)
- at System.Xml.Xsl.XsltOld.ValueOfAction.Execute(Processor processor, ActionFrame frame)
- at System.Xml.Xsl.XsltOld.ActionFrame.Execute(Processor processor)
- at System.Xml.Xsl.XsltOld.Processor.Execute()
- at System.Xml.Xsl.XsltOld.Processor.Execute(TextWriter writer)
- at System.Xml.Xsl.XslTransform.Transform(XPathNavigator input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
- at System.Xml.Xsl.XslTransform.Transform(IXPathNavigable input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
- at CommandLine.OptParse.UsageBuilder.ToText(TextWriter writer, OptStyle optStyle, Boolean includeDefaultValues, Int32 maxColumns)
- --TargetInvocationException
- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
- at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
- at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
- at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
- at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
- at System.Xml.Xsl.XsltOld.XsltCompileContext.FuncExtension.Invoke(XsltContext xsltContext, Object[] args, XPathNavigator docContext)
- at MS.Internal.Xml.XPath.FunctionQuery.Evaluate(XPathNodeIterator nodeIterator)
- --ArgumentOutOfRangeException
- at System.String.LastIndexOfAny(Char[] anyOf, Int32 startIndex, Int32 count)
- public TextTransformHelper(int maxColumns)
- {
- _maxColumns = maxColumns;
- if (_maxColumns == -1)
- {
- // try to determine console width
- string os = Environment.GetEnvironmentVariable("OS");
- if (os != null && os.StartsWith("Win"))
- {
- ConsoleUtils.ConsoleHelper ch = new ConsoleUtils.ConsoleHelper();
- _maxColumns = ch.GetScreenInfo().Size.X;
- }
- }
- }
- public TextTransformHelper(int maxColumns)
- {
- _maxColumns = maxColumns;
- if (_maxColumns == -1)
- {
- // try to determine console width
- string os = Environment.GetEnvironmentVariable("OS");
- if (os != null && os.StartsWith("Win"))
- {
- ConsoleUtils.ConsoleHelper ch = new ConsoleUtils.ConsoleHelper();
- _maxColumns = ch.GetScreenInfo().Size.X;
- if(_maxColumns == 0) //added
- _maxColumns = -1; //added
- }
- }
- }
- if (_maxColumns == -1)
- {
- output.Append((first) ? indentStr : handingIndentStr);
- output.Append(line);
- output.Append(Environment.NewLine);
- first = false;
- continue;
- }
Add Comment
Please, Sign In to add comment