Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert ContentReadersCache Check #1557

Merged
merged 3 commits into from
May 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 Expand Up @@ -212,7 +214,7 @@
if (readerTypeName.Contains(", mscorlib"))
{
resolvedReaderTypeName = readerTypeName.Replace(", mscorlib", ", System.Private.CoreLib");
readerType = Type.GetType(resolvedReaderTypeName);

Check warning on line 217 in src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs

View workflow job for this annotation

GitHub Actions / build

Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'. It's not possible to guarantee the availability of the target type.
if (readerType != null)
return readerType;
}
Expand All @@ -223,7 +225,7 @@
if (readerTypeName.Contains(", System.Private.CoreLib"))
{
resolvedReaderTypeName = readerTypeName.Replace(", System.Private.CoreLib", ", mscorlib");
readerType = Type.GetType(resolvedReaderTypeName);

Check warning on line 228 in src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs

View workflow job for this annotation

GitHub Actions / build

Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'. It's not possible to guarantee the availability of the target type.
if (readerType != null)
return readerType;
}
Expand All @@ -234,7 +236,7 @@
resolvedReaderTypeName = resolvedReaderTypeName.Replace(", Microsoft.Xna.Framework.Graphics", string.Format(", {0}", _contentGraphicsAssemblyName));
resolvedReaderTypeName = resolvedReaderTypeName.Replace(", Microsoft.Xna.Framework.Video", string.Format(", {0}", _contentMediaAssemblyName));
resolvedReaderTypeName = resolvedReaderTypeName.Replace(", Microsoft.Xna.Framework", string.Format(", {0}", _contentAssemblyName));
readerType = Type.GetType(resolvedReaderTypeName);

Check warning on line 239 in src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs

View workflow job for this annotation

GitHub Actions / build

Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'. It's not possible to guarantee the availability of the target type.
if (readerType != null)
return readerType;

Expand All @@ -254,11 +256,11 @@

// map MonoGame build-in TypeReaders
resolvedReaderTypeName = readerTypeName.Replace(", MonoGame.Framework", string.Format(", {0}", _contentAssemblyName));
readerType = Type.GetType(resolvedReaderTypeName);

Check warning on line 259 in src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs

View workflow job for this annotation

GitHub Actions / build

Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'. It's not possible to guarantee the availability of the target type.
if (readerType != null)
return readerType;
resolvedReaderTypeName = readerTypeName.Replace(", MonoGame.Framework", string.Format(", {0}", _contentGraphicsAssemblyName));
readerType = Type.GetType(resolvedReaderTypeName);

Check warning on line 263 in src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs

View workflow job for this annotation

GitHub Actions / build

Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'. It's not possible to guarantee the availability of the target type.
if (readerType != null)
return readerType;
resolvedReaderTypeName = readerTypeName.Replace(", MonoGame.Framework", string.Format(", {0}", _contentAudioAssemblyName));
Expand Down
Loading