public override SyntaxNode VisitDelegateDeclaration(DelegateDeclarationSyntax node) { node = (DelegateDeclarationSyntax)base.VisitDelegateDeclaration(node); if (CrossArchSyntaxMap.IsPotentialCrossArch(node)) { var originalName = node.Identifier.ValueText; var name = originalName; HandleArchSpecific(node, out var removeNode, out var attributeList, ref name); if (removeNode) { return(null); } if (name != originalName) { node = node.WithIdentifier(SyntaxFactory.ParseToken(name)); } if (attributeList != null) { node = node.AddAttributeLists(attributeList); } } return(node); }
public static DelegateDeclarationSyntax AddUnmanagedFunctionPointerAttribute(this DelegateDeclarationSyntax member) { return(member.AddAttributeLists( AttributeList( SingletonSeparatedList( Attribute(IdentifierName(nameof(UnmanagedFunctionPointerAttribute))) .AddArgumentListArguments( AttributeArgument(MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, IdentifierName(nameof(CallingConvention)), IdentifierName(nameof(CallingConvention.Cdecl)))), AttributeArgument(LiteralExpression(SyntaxKind.FalseLiteralExpression)) .WithNameEquals(NameEquals(nameof(UnmanagedFunctionPointerAttribute.BestFitMapping))), AttributeArgument(LiteralExpression(SyntaxKind.FalseLiteralExpression)) .WithNameEquals(NameEquals(nameof(UnmanagedFunctionPointerAttribute.SetLastError)))))) .WithAdditionalAnnotations(new SyntaxAnnotation(Annotations.Namespace, InteropServices.ToFullString())))); }