开发者

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

开发者 https://www.devze.com 2022-12-08 02:46 出处:网络
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 thereturn default(int); it automatically generates. I know I can i

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

精彩评论

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