diff --git a/Source/FlaxEngine.Gen.cs b/Source/FlaxEngine.Gen.cs index a7bea091b..b9a5609f6 100644 --- a/Source/FlaxEngine.Gen.cs +++ b/Source/FlaxEngine.Gen.cs @@ -2,6 +2,7 @@ using System.Reflection; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; [assembly: AssemblyTitle("FlaxEngine")] [assembly: AssemblyDescription("")] @@ -15,3 +16,4 @@ using System.Runtime.InteropServices; [assembly: Guid("b8442186-4a70-7c85-704a-857cc7990797")] [assembly: AssemblyVersion("1.5.6335")] [assembly: AssemblyFileVersion("1.5.6335")] +[assembly: DisableRuntimeMarshalling] diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs index c2179ba97..7f55e3223 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs @@ -17,7 +17,6 @@ namespace Flax.Build.Bindings private static readonly List CSharpUsedNamespacesSorted = new List(); private static readonly List CSharpAdditionalCode = new List(); private static readonly Dictionary CSharpAdditionalCodeCache = new Dictionary(); - private static string CSharpLastAssembly; public static event Action GenerateCSharpTypeInternals; @@ -457,7 +456,7 @@ namespace Flax.Build.Bindings if (CSharpAdditionalCode.Count != 0) { contents.AppendLine(); - foreach(var e in CSharpAdditionalCode) + foreach (var e in CSharpAdditionalCode) contents.Append(indent).AppendLine(e); CSharpAdditionalCode.Clear(); CSharpAdditionalCodeCache.Clear(); @@ -1285,7 +1284,7 @@ namespace Flax.Build.Bindings internal static IntPtr ToNative({{classInfo.Name}} managed) => GCHandleMarshaller.ToNative(managed); #pragma warning restore 1591 } - """).Split(new char[] { '\n'}))); + """).Split(new char[] { '\n' }))); } #endif // Namespace end @@ -1995,16 +1994,10 @@ namespace Flax.Build.Bindings CSharpUsedNamespaces.Add("System.Globalization"); CSharpUsedNamespaces.Add("System.Runtime.CompilerServices"); CSharpUsedNamespaces.Add("System.Runtime.InteropServices"); - CSharpUsedNamespaces.Add("FlaxEngine"); #if USE_NETCORE CSharpUsedNamespaces.Add("System.Runtime.InteropServices.Marshalling"); - if (CSharpLastAssembly != moduleInfo.Name) - { - // Add custom assembly attributes here, once per assembly - contents.AppendLine("[assembly: DisableRuntimeMarshalling]"); - CSharpLastAssembly = moduleInfo.Name; - } #endif + CSharpUsedNamespaces.Add("FlaxEngine"); // Process all API types from the file var useBindings = false; @@ -2070,6 +2063,9 @@ namespace Flax.Build.Bindings contents.AppendLine(); contents.AppendLine("using System.Reflection;"); contents.AppendLine("using System.Runtime.InteropServices;"); +#if USE_NETCORE + contents.AppendLine("using System.Runtime.CompilerServices;"); +#endif contents.AppendLine(); contents.AppendLine($"[assembly: AssemblyTitle(\"{binaryModuleName}\")]"); contents.AppendLine("[assembly: AssemblyDescription(\"\")]"); @@ -2083,6 +2079,9 @@ namespace Flax.Build.Bindings contents.AppendLine($"[assembly: Guid(\"{id:d}\")]"); contents.AppendLine($"[assembly: AssemblyVersion(\"{project.Version}\")]"); contents.AppendLine($"[assembly: AssemblyFileVersion(\"{project.Version}\")]"); +#if USE_NETCORE + contents.AppendLine("[assembly: DisableRuntimeMarshalling]"); +#endif Utilities.WriteFileIfChanged(dstFilePath, contents.ToString()); } }