private TranslationContext(
     SymbolTable symbolTable,
     NameGenerator nameGenerator,
     KnownSerializersRegistry knownSerializersRegistry,
     TranslationContextData data = null)
 {
     _symbolTable   = Ensure.IsNotNull(symbolTable, nameof(symbolTable));
     _nameGenerator = Ensure.IsNotNull(nameGenerator, nameof(nameGenerator));
     _knownKnownSerializersRegistry = Ensure.IsNotNull(knownSerializersRegistry, nameof(knownSerializersRegistry));
     _data = data; // can be null
 }
        public static TranslationContext Create(Expression expression, IBsonSerializer serializer, TranslationContextData data = null)
        {
            var symbolTable   = new SymbolTable();
            var nameGenerator = new NameGenerator();

            if (serializer is ISetWindowFieldsPartitionSerializer partitionSerializer)
            {
                serializer = partitionSerializer.InputSerializer; // maybe this logic belongs in KnownSerializerFinder
            }
            var knownSerializersRegistry = KnownSerializerFinder.FindKnownSerializers(expression, (IBsonDocumentSerializer)serializer);

            return(new TranslationContext(symbolTable, nameGenerator, knownSerializersRegistry, data));
        }