开发者

C# CodeFunction2 - How do you prevent creation of 'return'?

I am creating a C# class as per:

http://msdn.microsoft.com/en-us/library/x6h10s6x.aspx

however I want my own 'return' rather than the return default(int); it automatically generates. I know I can insert my own text using an EditPoi开发者_JS百科nt i.e

 editPoint.Insert("return records.AsEnumerable<" + tableNameAsSingular + ">();");

but it still tries to stick in its own 'return' too


A workaround can be to delete of the default content of the method:

TextPoint startPoint = method.GetStartPoint(vsCMPart.vsCMPartBody);
TextPoint endPoint = method.GetEndPoint(vsCMPart.vsCMPartBody);

var editPoint = startPoint.CreateEditPoint();
editPoint.Delete(endPoint);

This code should erase the default content of the method.


In CodeDOM, there is something like CodeMethodReturnStatement. There may be something similar in VS code generation extensibility.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜