コード例 #1
0
        protected override CSharpSyntaxGeneratorResult Generate(
            InputObjectTypeDescriptor descriptor,
            CSharpSyntaxGeneratorSettings settings)
        {
            string name = NamingConventions.CreateInputValueInfo(descriptor.Name);

            InterfaceDeclarationSyntax interfaceDeclaration =
                SyntaxFactory.InterfaceDeclaration(name)
                .AddModifiers(SyntaxFactory.Token(SyntaxKind.InternalKeyword))
                .AddGeneratedAttribute();

            foreach (var prop in descriptor.Properties)
            {
                interfaceDeclaration = interfaceDeclaration.AddMembers(
                    SyntaxFactory.PropertyDeclaration(
                        SyntaxFactory.ParseTypeName(TypeNames.Boolean),
                        NamingConventions.CreateIsSetProperty(prop.Name))
                    .WithGetter());
            }

            return(new(
                       name,
                       State,
                       $"{descriptor.RuntimeType.NamespaceWithoutGlobal}.{State}",
                       interfaceDeclaration));
        }