Add check to prevent inheriting from static or sealed class in scripting

This commit is contained in:
Wojtek Figat
2021-08-30 14:52:01 +02:00
parent c69e620e04
commit 5d321c8c0c

View File

@@ -1,5 +1,6 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -65,6 +66,14 @@ namespace Flax.Build.Bindings
if (UniqueFunctionNames == null)
UniqueFunctionNames = new HashSet<string>();
if (BaseType is ClassInfo baseClass)
{
if (baseClass.IsStatic)
throw new Exception(string.Format("Class {0} inherits from thr class {1} that is {2}.", FullNameNative, baseClass.FullNameNative, "static"));
if (baseClass.IsSealed)
throw new Exception(string.Format("Class {0} inherits from the class {1} that is {2}.", FullNameNative, baseClass.FullNameNative, "sealed"));
}
foreach (var fieldInfo in Fields)
{
if (fieldInfo.Access == AccessLevel.Private)