Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

ReadMe.md

Source Generator JSON Function

The SourceGeneratorJson project uses the new compile-time generated JSON serializer capabilities of the .NET 6 compiler.

The purpose of this project is compare JSON serializer performance of source generators for cold- and warm- starts with alternatives.

Code

using System.IO;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Amazon.Lambda.Core;

[assembly:LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.SourceGeneratorLambdaJsonSerializer<Benchmark.SourceGeneratorJson.FunctionSerializerContext>))]

namespace Benchmark.SourceGeneratorJson {

    [JsonSerializable(typeof(Root))]
    public partial class FunctionSerializerContext : JsonSerializerContext { }

    public sealed class Function {

        //--- Methods ---
        public async Task<Stream> ProcessAsync(Root request) {
            return Stream.Null;
        }
    }
}