Skip to content

Commit

Permalink
revert ContentReadersCache Check (#1557)
Browse files Browse the repository at this point in the history
* Revert "move TypeVersion check"

This reverts commit aef352c.

* Revert "simplify _contentReadersCache check"

This reverts commit 4894508.

* Revert "move _contentReadersCache"

This reverts commit 5fba42e.
  • Loading branch information
nkast authored May 12, 2024
1 parent d28b1eb commit 1c7e738
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,35 @@ 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];
}

System.Diagnostics.Debug.Assert(!_contentReadersCache.ContainsKey(typeReaderType));

if (!_contentReadersCache.ContainsKey(typeReaderType))
{
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
{
Type typeReaderType = _contentTypeReadersCache[readerTypeName];

System.Diagnostics.Debug.Assert(_contentReadersCache.ContainsKey(typeReaderType));

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;


Expand Down

0 comments on commit 1c7e738

Please sign in to comment.