Example #1
0
            public Builder(int lengthLimit, ObjectFormattingOptions options, bool insertEllipsis)
            {
                Debug.Assert(lengthLimit <= options.MaxOutputLength);

                int lineLengthLimit = options.MaxLineLength;

                if (insertEllipsis)
                {
                    lengthLimit     = Math.Max(0, lengthLimit - options.Ellipsis.Length - 1);
                    lineLengthLimit = Math.Max(0, lineLengthLimit - options.Ellipsis.Length - 1);
                }

                _lengthLimit     = lengthLimit;
                _lineLengthLimit = lineLengthLimit;
                _currentLimit    = Math.Min(lineLengthLimit, lengthLimit);
                _insertEllipsis  = insertEllipsis;

                _options = options;
                _sb      = new StringBuilder();
            }
 public Formatter(CommonObjectFormatter language, ObjectFormattingOptions options)
 {
     this.options = options ?? ObjectFormattingOptions.Default;
     this.language = language;
 }
Example #3
0
 /// <summary>
 /// Formats an array type name (vector or multidimensional).
 /// </summary>
 public abstract string FormatArrayTypeName(Array array, ObjectFormattingOptions options);
Example #4
0
 // TODO (tomat): Use DebuggerDisplay.Type if specified?
 public abstract string FormatTypeName(Type type, ObjectFormattingOptions options);
Example #5
0
 public string FormatObject(object obj, ObjectFormattingOptions options = null)
 {
     return(new Formatter(this, options).FormatObject(obj));
 }
Example #6
0
 public Formatter(ObjectFormatter language, ObjectFormattingOptions options)
 {
     _options  = options ?? ObjectFormattingOptions.Default;
     _language = language;
 }
Example #7
0
        private ExecutionResult Execute(object assemblyInput)
        {
            var assembly = (ICodeAssembly)assemblyInput;
            var result = new ExecutionResult();
            var type = typeof(ByteCodeLoader);
            var formatter = ObjectFormatter.Instance;
            var formattingOptions = new ObjectFormattingOptions(maxOutputLength: 5120);

            var className = assembly.EntryPointClassName;
            var methodName = assembly.EntryPointMethodName;
            var resultProperty = "Result";
            var assemblyBytes = assembly.CompiledAssembly;

            try
            {
                var handle = Activator.CreateInstanceFrom(domain, type.Assembly.ManifestModule.FullyQualifiedName, type.FullName);
                var loader = (ByteCodeLoader)handle.Unwrap();
                var unformattedResult = loader.Run(className, methodName, resultProperty, assemblyBytes);

                result.Result = (unformattedResult != null) ? formatter.FormatObject(unformattedResult.ReturnValue, formattingOptions) : "null";
                result.ConsoleOutput = (unformattedResult != null) ? unformattedResult.ConsoleOutput : string.Empty;
                result.ProcessorTime = domain.MonitoringTotalProcessorTime;
                result.TotalMemoryAllocated = domain.MonitoringTotalAllocatedMemorySize;
            }
            catch (SerializationException ex)
            {
                result.Result = ex.Message;
            }
            catch (TargetInvocationException ex)
            {
                result.Result = ex.InnerException.ToString();
            }

            return result;
        }
Example #8
0
 public Formatter(CommonObjectFormatter language, ObjectFormattingOptions options)
 {
     this.options  = options ?? ObjectFormattingOptions.Default;
     this.language = language;
 }
 /// <summary>
 /// Formats an array type name (vector or multidimensional).
 /// </summary>
 public abstract string FormatArrayTypeName(Array array, ObjectFormattingOptions options);
 // TODO (tomat): Use DebuggerDisplay.Type if specified?
 public abstract string FormatTypeName(Type type, ObjectFormattingOptions options);
            public Builder(int lengthLimit, ObjectFormattingOptions options, bool insertEllipsis)
            {
                Debug.Assert(lengthLimit <= options.MaxOutputLength);

                int lineLengthLimit = options.MaxLineLength;
                if (insertEllipsis)
                {
                    lengthLimit = Math.Max(0, lengthLimit - options.Ellipsis.Length - 1);
                    lineLengthLimit = Math.Max(0, lineLengthLimit - options.Ellipsis.Length - 1);
                }

                this.lengthLimit = lengthLimit;
                this.lineLengthLimit = lineLengthLimit;
                this.currentLimit = Math.Min(lineLengthLimit, lengthLimit);
                this.insertEllipsis = insertEllipsis;

                this.options = options;
                this.sb = new StringBuilder();
            }
 public string FormatObject(object obj, ObjectFormattingOptions options = null)
 {
     return new Formatter(this, options).FormatObject(obj);
 }