本文整理汇总了C#中Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationOptions.With方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerationOptions.With方法的具体用法?C# CodeGenerationOptions.With怎么用?C# CodeGenerationOptions.With使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationOptions
的用法示例。
在下文中一共展示了CodeGenerationOptions.With方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateNamedTypeDeclaration
public static MemberDeclarationSyntax GenerateNamedTypeDeclaration(
ICodeGenerationService service,
INamedTypeSymbol namedType,
CodeGenerationDestination destination,
CodeGenerationOptions options,
CancellationToken cancellationToken)
{
options = options ?? CodeGenerationOptions.Default;
var declaration = GetDeclarationSyntaxWithoutMembers(namedType, destination, options);
if (namedType.IsComImport)
{
// If we're generating a ComImport type, then do not attempt to do any
// reordering of members.
options = options.With(autoInsertionLocation: false, sortMembers: false);
}
// If we are generating members then make sure to exclude properties that cannot be generated.
// Reason: Calling AddProperty on a propertysymbol that can't be generated (like one with params) causes
// the getter and setter to get generated instead. Since the list of members is going to include
// the method symbols for the getter and setter, we don't want to generate them twice.
declaration = options.GenerateMembers && namedType.TypeKind != TypeKind.Delegate
? service.AddMembers(declaration,
GetMembers(namedType).Where(s => s.Kind != SymbolKind.Property || PropertyGenerator.CanBeGenerated((IPropertySymbol)s)),
options,
cancellationToken)
: declaration;
return AddCleanupAnnotationsTo(ConditionallyAddDocumentationCommentTo(declaration, namedType, options));
}