public string GenerateListing(AssemblyMethod method) { var sb = new StringBuilder(); if (this._options.IncludeMethodName) { sb.AppendLine($"// Selected method: {method.Signature.MethodName}"); sb.AppendLine(); } if (this._options.ReadInstructionBytes) { this._bytesReader = new MethodBytesReader(method.MethodDefinition); } if (this._options.AlignListing) { this._longestOpCode = method.Instructions.Max(i => i.OpCode.Name.Length); if (this._options.ReadInstructionBytes) { this._longestByteSeq = method.Instructions.Max(i => i.GetSize()) * 2; } } foreach (var instruction in method.Instructions) { if (this._options.IgnoreNops && instruction.OpCode.Code == Code.Nop) { continue; } if (this._options.ProcessPDBFiles) { sb.Append(this.ParsePdbInformation(instruction.SequencePoint)); } sb.AppendLine(InstructionToString(instruction, _longestOpCode)); } string resultListing = sb.ToString(); if (_warnings.Count > 0) { var warnStr = String.Join(Environment.NewLine, this._warnings); resultListing = warnStr + Environment.NewLine + sb.ToString(); } return(resultListing); }
public string GenerateListing(AssemblyMethod method) { var sb = new StringBuilder(); if (this.options.IncludeMethodName) { sb.AppendLine($"// Selected method: {method.Signature.MethodName}"); sb.AppendLine(); } if (this.options.ReadInstructionBytes) { this.bytesReader = new MethodBytesReader(method.MethodDefinition); } if (this.options.AlignListing) { this.longestOpCode = method.Instructions.Max(i => i.OpCode.Name.Length); if (this.options.ReadInstructionBytes) { this.longestByteSeq = method.Instructions.Max(i => i.GetSize()) * 2; } } foreach (var instruction in method.Instructions) { if (this.options.IgnoreNops && instruction.OpCode.Code == Code.Nop) { continue; } if (this.options.ProcessPdbFiles) { sb.Append(this.ParsePdbInformation(instruction.SequencePoint)); } var info = Helpers.GetInstructionInformation(instruction.OpCode.Name); string descriptionComment = $"// {info.Name}: {info.Description}"; if (this.options.DescriptionMode == DescriptionMode.BeforeLine) { sb.AppendLine(descriptionComment); } string instructionData = this.InstructionToString(instruction, this.longestOpCode); if (this.options.DescriptionMode == DescriptionMode.AfterInstruction) { instructionData += " " + descriptionComment; } sb.AppendLine(instructionData); } string resultListing = sb.ToString(); if (this.warnings.Count <= 0) { return(resultListing); } return($"{String.Join(Environment.NewLine, this.warnings)}{Environment.NewLine}{sb}"); }