Mutagen-Modding / Mutagen

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

MajorRecord Write generation refactor to common #526

Open Noggog opened 3 months ago

Noggog commented 3 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