Browse Source

Fix #1980: IndexOutOfRangeException when choose `IL with C#` with System.Runtime.CompilerServices.Unsafe.Copy/InitBlock

pull/1984/head
Siegfried Pammer 5 years ago
parent
commit
d09190533a
  1. 4
      ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertMissingTokensDecorator.cs
  2. 14
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Comment.cs

4
ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertMissingTokensDecorator.cs

@ -43,6 +43,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
currentList.Add(node); currentList.Add(node);
nodes.Push(currentList); nodes.Push(currentList);
currentList = new List<AstNode>(); currentList = new List<AstNode>();
} else if (node is Comment comment) {
comment.SetStartLocation(locationProvider.Location);
} }
base.StartNode(node); base.StartNode(node);
} }
@ -62,6 +64,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
node.AddChildWithExistingRole(child); node.AddChildWithExistingRole(child);
} }
currentList = nodes.Pop(); currentList = nodes.Pop();
} else if (node is Comment comment) {
comment.SetEndLocation(locationProvider.Location);
} }
base.EndNode(node); base.EndNode(node);
} }

14
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Comment.cs

@ -102,7 +102,19 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return endLocation; return endLocation;
} }
} }
internal void SetStartLocation(TextLocation value)
{
ThrowIfFrozen();
this.startLocation = value;
}
internal void SetEndLocation(TextLocation value)
{
ThrowIfFrozen();
this.endLocation = value;
}
public Comment (string content, CommentType type = CommentType.SingleLine) public Comment (string content, CommentType type = CommentType.SingleLine)
{ {
this.CommentType = type; this.CommentType = type;

Loading…
Cancel
Save