简体   繁体   English

如何使用roslyn向方法添加参数?

[英]How i can add parameters to method using roslyn?

Need add input parameters to method. 需要向方法添加输入参数。
I create new instance with type MethodDeclarationSyntax: 我用MethodDeclarationSyntax类型创建新实例:

MethodDeclarationSyntax lMethodDeclarationSyntax = Syntax.MethodDeclaration(
                Syntax.List<AttributeListSyntax>(), 
                Syntax.TokenList(Syntax.Token(SyntaxKind.PublicKeyword)), 
                Syntax.IdentifierName("MemoryStream"), 
                null, 
                Syntax.Identifier("Serialize"), 
                null, 
                Syntax.ParameterList(), 
                Syntax.List<TypeParameterConstraintClauseSyntax>(), 
                Syntax.Block(lList));  

How i can add input parameter like a 我怎样才能像这样添加输入参数

(MyType lMyType)?

代替在上面的示例中使用System.ParameterList() ,而是实际上构造一个带有参数的参数列表。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何指定Roslyn方法参数 - How to specify Roslyn method parameters 如何使用 Roslyn Analyzer 检测特定方法是否不包含 try catch 块? - How can i detect if a specific method does not contain try catch block using Roslyn Analyzer? 如何在Roslyn(Microsoft.CodeAnalysis)中向生成的方法添加参数? -需要确切的语法 - How to add parameters to generated method in Roslyn ( Microsoft.CodeAnalysis )? - Need exact syntax 使用 Roslyn CodeFixProvider 向方法添加访问修饰符? - Add access modifier to method using Roslyn CodeFixProvider? 如何使用 Roslyn 将 SyntaxTree 或 UnitCompilationRoot 包装在区域或注释中? - How can I wrap a SyntaxTree or UnitCompilationRoot in a region or comment using Roslyn? 如何使用Roslyn API访问特定类中方法参数自己的类型数据(C#代码分析) - How can I access to method parameter's own type data in specific class using Roslyn API(C# Code Analysis) 如何使用Roslyn获取方法定义? - How to get method definition using Roslyn? 如何使用Roslyn代码诊断识别和分析局部变量和参数? - How can I identify and analyze local variables and parameters with Roslyn code diagnostics? 如何从 Roslyn 的另一个方法中作为参数传递的方法获取返回类型? - How can I obtain return type from method passed as an argument in another method with Roslyn? 我怎样才能在 Roslyn 中获得一个方法的所有引用(方法被其他类调用)? - How can I have all references of a method in Roslyn (method is called by other classes)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM