Mutagen-Modding / Mutagen

A .NET library for analyzing, creating, and manipulating Bethesda mods
GNU General Public License v3.0
123 stars 32 forks source link

MajorRecord Write generation refactor to common #526

Open Noggog opened 5 months ago

Noggog commented 5 months ago
        public void Write(
            MutagenWriter writer,
            IClassGetter item,
            TypedWriteParams translationParams)
        {
            using (HeaderExport.Record(
                writer: writer,
                record: translationParams.ConvertToCustom(RecordTypes.CLAS)))
            {
                try
                {
                    OblivionMajorRecordBinaryWriteTranslation.WriteEmbedded(
                        item: item,
                        writer: writer);
                    if (!item.IsDeleted)
                    {
                        writer.MetaData.FormVersion = item.FormVersion;
                        WriteRecordTypes(
                            item: item,
                            writer: writer,
                            translationParams: translationParams);
                        writer.MetaData.FormVersion = null;
                    }
                }
                catch (Exception ex)
                {
                    throw RecordException.Enrich(ex, item);
                }
            }
        }

These snippets might be all dups that can be refactored to some common translation helper