I can use a SyntaxGenerator to generate a parameter of type Int32 like so...
var generator = SyntaxGenerator.GetGenerator(document);
var paramType = generator.TypeExpression(SpecialType.System_Int32);
var param = generator.ParameterDeclaration("MyParam", paramType);
What equivalent code should I use to create a parameter of type Dataset ?
I presume I need to create an ITypeSymbol to pass to the generator.TypeExpression , but how to do this?
If you have access to a Compilation
, you can use GetTypeByMetadataName
, as explained in this blog post and this SO answer :
var dataSetType = compilation.GetTypeByMetadataName("System.Data.DataSet");
var paramType = generator.TypeExpression(dataSetType);
var param = generator.ParameterDeclaration("MyParam", paramType);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.