diff --git a/Source/Engine/Content/JsonAsset.cpp b/Source/Engine/Content/JsonAsset.cpp index 9928f00e4..43aa8676b 100644 --- a/Source/Engine/Content/JsonAsset.cpp +++ b/Source/Engine/Content/JsonAsset.cpp @@ -353,9 +353,11 @@ void JsonAsset::DeleteInstance() ScopeLock lock(Locker); // C# instance - if (MObject* object = GetManagedInstance()) + MObject* object = GetManagedInstance(); + MClass* klass = GetClass(); + if (object && klass) { - GetClass()->GetField("_instance")->SetValue(object, nullptr); + klass->GetField("_instance")->SetValue(object, nullptr); } // C++ instance diff --git a/Source/Engine/Engine/NativeInterop.cs b/Source/Engine/Engine/NativeInterop.cs index 07aba41f8..863583023 100644 --- a/Source/Engine/Engine/NativeInterop.cs +++ b/Source/Engine/Engine/NativeInterop.cs @@ -1,4 +1,7 @@ +// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. + #if USE_NETCORE + using System; using System.Collections.Generic; using System.Globalization; @@ -813,29 +816,29 @@ namespace FlaxEngine /// internal unsafe static partial class NativeInterop { - internal static Dictionary AssemblyLocations = new Dictionary(); + internal static Dictionary AssemblyLocations = new(); private static bool firstAssemblyLoaded = false; - private static Dictionary typeCache = new Dictionary(); + private static Dictionary typeCache = new(); private static IntPtr boolTruePtr = GCHandle.ToIntPtr(GCHandle.Alloc((int)1, GCHandleType.Pinned)); private static IntPtr boolFalsePtr = GCHandle.ToIntPtr(GCHandle.Alloc((int)0, GCHandleType.Pinned)); private static List methodHandles = new(); private static List methodHandlesCollectible = new(); - private static ConcurrentDictionary cachedDelegates = new ConcurrentDictionary(); - private static ConcurrentDictionary cachedDelegatesCollectible = new ConcurrentDictionary(); - private static Dictionary typeHandleCache = new Dictionary(); - private static Dictionary typeHandleCacheCollectible = new Dictionary(); + private static ConcurrentDictionary cachedDelegates = new(); + private static ConcurrentDictionary cachedDelegatesCollectible = new(); + private static Dictionary typeHandleCache = new(); + private static Dictionary typeHandleCacheCollectible = new(); private static List fieldHandleCache = new(); private static List fieldHandleCacheCollectible = new(); private static Dictionary classAttributesCacheCollectible = new(); - private static Dictionary assemblyHandles = new Dictionary(); + private static Dictionary assemblyHandles = new(); - private static Dictionary loadedNativeLibraries = new Dictionary(); - private static Dictionary nativeLibraryPaths = new Dictionary(); - private static Dictionary assemblyOwnedNativeLibraries = new Dictionary(); + private static Dictionary loadedNativeLibraries = new(); + private static Dictionary nativeLibraryPaths = new(); + private static Dictionary assemblyOwnedNativeLibraries = new(); private static AssemblyLoadContext scriptingAssemblyLoadContext; [System.Diagnostics.DebuggerStepThrough] @@ -1871,7 +1874,6 @@ namespace FlaxEngine marshalType = type; else marshalType = GetInternalType(type) ?? typeof(IntPtr); - return marshalType; } @@ -2723,4 +2725,5 @@ namespace FlaxEngine } } } + #endif diff --git a/Source/Engine/Engine/NativeInterop_Invoker.cs b/Source/Engine/Engine/NativeInterop_Invoker.cs index ad9a2da2a..eb06c40ad 100644 --- a/Source/Engine/Engine/NativeInterop_Invoker.cs +++ b/Source/Engine/Engine/NativeInterop_Invoker.cs @@ -1,3 +1,5 @@ +// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. + #if USE_NETCORE using System;