public MemberDeclarationSyntax MakeInterface(TypeDefinition type) { var ifaceDecl = InterfaceDeclaration(_names.MakeTypeName(type, NameUsage.Interface).Identifier) .AddModifiers(Public) .AddAttributeLists( AttributeList() .AddAttributes( CommonSnippetGen.MakeTypeIdAttribute(type.Id), Attribute(IdentifierName("Proxy")) .AddArgumentListArguments( AttributeArgument( TypeOfExpression(_names.MakeGenericTypeNameForAttribute(type, NameUsage.Proxy)))), Attribute(IdentifierName("Skeleton")) .AddArgumentListArguments( AttributeArgument( TypeOfExpression(_names.MakeGenericTypeNameForAttribute(type, NameUsage.Skeleton)))))); if (type.GenericParameters.Count > 0) { ifaceDecl = ifaceDecl.AddTypeParameterListParameters(MakeTypeParameters(type).ToArray()); } if (type.Superclasses.Count == 0) { ifaceDecl = ifaceDecl.AddBaseListTypes(SimpleBaseType(IdentifierName(nameof(IDisposable)))); } else { foreach (var superClass in type.Superclasses) { ifaceDecl = ifaceDecl.AddBaseListTypes( SimpleBaseType(_names.MakeTypeSyntax( superClass, type, TypeUsage.NotRelevant))); } } foreach (var method in type.Methods) { var methodDecl = MethodDeclaration( TransformReturnType(method), _names.GetCodeIdentifier(method).Identifier) .AddParameterListParameters(TransformParameters(method)) .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); if (method.GenericParameters.Count > 0) { methodDecl = methodDecl .AddTypeParameterListParameters(MakeTypeParameters(method).ToArray()) .AddConstraintClauses(MakeTypeParameterConstraints(method).ToArray()); } ifaceDecl = ifaceDecl.AddMembers(methodDecl); } return(ifaceDecl); }
public static SyntaxList <AttributeListSyntax> MakeTypeIdAttributeLists(ulong id) => SingletonList <AttributeListSyntax>( AttributeList( SingletonSeparatedList <AttributeSyntax>( CommonSnippetGen.MakeTypeIdAttribute(id))));