From 0a9fc77d787d1d621ef95d2b99ef2603c2863cff Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Sun, 12 May 2024 12:45:57 +0300 Subject: [PATCH 1/3] Revert "move TypeVersion check" This reverts commit aef352cb35a4ce1361afa466d507fe6b3ba542b4. --- .../Content/ContentTypeReaderManager.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs b/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs index f0029db4827..5d27b3f26d1 100644 --- a/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs +++ b/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs @@ -84,13 +84,6 @@ internal ContentTypeReader[] LoadAssetReaders(ContentReader reader, int typeRead typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader; needsInitialize[i] = true; _contentReadersCache.Add(typeReaderType, typeReader); - - if (readerTypeVersion != typeReader.TypeVersion) - { - throw new ContentLoadException( - String.Format("{0} of TypeVersion {1} does not match reader of TypeVersion {2}.", - typeReader.TargetType.Name, readerTypeVersion, typeReader.TypeVersion)); - } } else { @@ -101,6 +94,13 @@ internal ContentTypeReader[] LoadAssetReaders(ContentReader reader, int typeRead typeReader = _contentReadersCache[typeReaderType]; } + if (readerTypeVersion != typeReader.TypeVersion) + { + throw new ContentLoadException( + String.Format("{0} of TypeVersion {1} does not match reader of TypeVersion {2}.", + typeReader.TargetType.Name, readerTypeVersion, typeReader.TypeVersion)); + } + contentReaders[i] = typeReader; From 80950e8951fba1e50815892a8c453230dd0da27f Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Sun, 12 May 2024 12:47:15 +0300 Subject: [PATCH 2/3] Revert "simplify _contentReadersCache check" This reverts commit 489450884de3b39d88c45cd3ab22aa8a2800abb6. --- .../Content/ContentTypeReaderManager.cs | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs b/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs index 5d27b3f26d1..77484de3b33 100644 --- a/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs +++ b/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs @@ -79,19 +79,31 @@ internal ContentTypeReader[] LoadAssetReaders(ContentReader reader, int typeRead Type typeReaderType = ResolveReaderType(readerTypeName); _contentTypeReadersCache.Add(readerTypeName, typeReaderType); - System.Diagnostics.Debug.Assert(!_contentReadersCache.ContainsKey(typeReaderType)); - - typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader; - needsInitialize[i] = true; - _contentReadersCache.Add(typeReaderType, typeReader); + if (!_contentReadersCache.ContainsKey(typeReaderType)) + { + typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader; + needsInitialize[i] = true; + _contentReadersCache.Add(typeReaderType, typeReader); + } + else + { + typeReader = _contentReadersCache[typeReaderType]; + } } else { Type typeReaderType = _contentTypeReadersCache[readerTypeName]; - System.Diagnostics.Debug.Assert(_contentReadersCache.ContainsKey(typeReaderType)); - - typeReader = _contentReadersCache[typeReaderType]; + if (!_contentReadersCache.ContainsKey(typeReaderType)) + { + typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader; + needsInitialize[i] = true; + _contentReadersCache.Add(typeReaderType, typeReader); + } + else + { + typeReader = _contentReadersCache[typeReaderType]; + } } if (readerTypeVersion != typeReader.TypeVersion) From 0076ae869a70524a33a7664467f3bf68afa7d999 Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Sun, 12 May 2024 12:47:46 +0300 Subject: [PATCH 3/3] Revert "move _contentReadersCache" This reverts commit 5fba42e7a4b29d3008cb5df2fa98ba186146f3f8. --- .../Content/ContentTypeReaderManager.cs | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs b/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs index 77484de3b33..4280012e60e 100644 --- a/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs +++ b/src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs @@ -74,36 +74,26 @@ internal ContentTypeReader[] LoadAssetReaders(ContentReader reader, int typeRead int readerTypeVersion = reader.ReadInt32(); ContentTypeReader typeReader; + Type typeReaderType; if (!_contentTypeReadersCache.ContainsKey(readerTypeName)) { - Type typeReaderType = ResolveReaderType(readerTypeName); + typeReaderType = ResolveReaderType(readerTypeName); _contentTypeReadersCache.Add(readerTypeName, typeReaderType); + } + else + { + typeReaderType = _contentTypeReadersCache[readerTypeName]; + } - if (!_contentReadersCache.ContainsKey(typeReaderType)) - { - typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader; - needsInitialize[i] = true; - _contentReadersCache.Add(typeReaderType, typeReader); - } - else - { - typeReader = _contentReadersCache[typeReaderType]; - } + if (!_contentReadersCache.ContainsKey(typeReaderType)) + { + typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader; + needsInitialize[i] = true; + _contentReadersCache.Add(typeReaderType, typeReader); } else { - Type typeReaderType = _contentTypeReadersCache[readerTypeName]; - - if (!_contentReadersCache.ContainsKey(typeReaderType)) - { - typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader; - needsInitialize[i] = true; - _contentReadersCache.Add(typeReaderType, typeReader); - } - else - { - typeReader = _contentReadersCache[typeReaderType]; - } + typeReader = _contentReadersCache[typeReaderType]; } if (readerTypeVersion != typeReader.TypeVersion)