MonoGame
MonoGame copied to clipboard
Fixed _isRunningOnNetCore bug in ContentTypeReaderManager.cs
System.Private.CoreLib is an assembly, so Type.GetType("System.Private.CoreLib") always returned null. typeof(object).Assembly.GetName().Name == "System.Private.CoreLib" should fulfill the role the other line had intended to accomplish.
This should close #7872
I guess my IDE also picked up on some trailing whitespace in comments and removed those as well
I suspect that Assembly.GetName() might not work with NativeAOT and will crash, it's a case where Assembly or Name might be null on that runtime.
We should probably also reverse the check, that is have the condition be by default true, otherwise if mscorlib is available, set it to false.
typeof(object).Assembly.GetName().Name works as intended in NativeAOT
@harry-cpp if it's not System.Private.CoreLib shouldn't it be mscorlib then? Is there a reason reversing it is better?
If I had originally written Type.GetType("mscorlib") == null instead, it would be forward compatible in case the check itself failed, tho now that I think about it, I do remembered why I chose to check for System.Private.CoreLib originally, it was to ensure I don't break something on the console side.
You don't need to reverse the condition, it'll be fine.