Exemple #1
0
        public Task <SyntaxList <MemberDeclarationSyntax> > GenerateAsync(
            TransformationContext context,
            IProgress <Diagnostic> progress,
            CancellationToken cancellationToken)
        {
            if (context.ProcessingNode is TypeDeclarationSyntax applyTo &&
                (applyTo is ClassDeclarationSyntax || (applyTo is StructDeclarationSyntax)))
            {
                var record = CodeGenUtil.MakeCaseType(
                    context,
                    applyTo.Identifier,
                    applyTo.Members,
                    applyTo.TypeParameterList,
                    applyTo.Modifiers,
                    applyTo.ConstraintClauses,
                    applyTo.Identifier,
                    null,
                    CodeGenUtil.GetState(context, progress, AllowedType.ClassOrStruct, "Record code-gen").Fields,
                    BaseSpec.None,
                    caseIsClass: applyTo is ClassDeclarationSyntax,
                    caseIsPartial: true,
                    -1);


                return(Task.FromResult(List <MemberDeclarationSyntax>().Add(record)));
            }
Exemple #2
0
        public Task <SyntaxList <MemberDeclarationSyntax> > GenerateAsync(TransformationContext context, IProgress <Diagnostic> progress, CancellationToken cancellationToken)
        {
            var(partialClass, returnType, fields) = CodeGenUtil.GetState(context);

            partialClass = CodeGenUtil.AddWith(context, partialClass, returnType, fields);

            return(Task.FromResult(SyntaxFactory.List <MemberDeclarationSyntax>().Add(partialClass)));
        }