static TextLocation FindMethodStart(ICSharpCode.TextEditor.Document.IDocument document, DomRegion bodyRegion) { if (bodyRegion.IsEmpty) return TextLocation.Empty; int offset = document.PositionToOffset(new TextLocation(bodyRegion.BeginColumn - 1, bodyRegion.BeginLine - 1)); while (offset < document.TextLength) { if (document.GetCharAt(offset) == '{') { return document.OffsetToPosition(offset + 1); } offset++; } return TextLocation.Empty; }