diff --git a/Robust.Shared/ContentPack/AssemblyTypeChecker.cs b/Robust.Shared/ContentPack/AssemblyTypeChecker.cs index d56fb5bc1..40de3a085 100644 --- a/Robust.Shared/ContentPack/AssemblyTypeChecker.cs +++ b/Robust.Shared/ContentPack/AssemblyTypeChecker.cs @@ -193,6 +193,10 @@ namespace Robust.Shared.ContentPack _sawmill.Debug($"Unmanaged methods... {fullStopwatch.ElapsedMilliseconds}ms"); + CheckNoTypeAbuse(reader, errors); + + _sawmill.Debug($"Type abuse... {fullStopwatch.ElapsedMilliseconds}ms"); + CheckMemberReferences(loadedConfig, members, errors); foreach (var error in errors) @@ -311,6 +315,27 @@ namespace Robust.Shared.ContentPack } } + private static void CheckNoTypeAbuse(MetadataReader reader, ConcurrentBag errors) + { + foreach (var typeDefHandle in reader.TypeDefinitions) + { + var typeDef = reader.GetTypeDefinition(typeDefHandle); + if ((typeDef.Attributes & TypeAttributes.ExplicitLayout) != 0) + { + // The C# compiler emits explicit layout types for some array init logic. These have no fields. + // Only ban explicit layout if it has fields. + + var type = GetTypeFromDefinition(reader, typeDefHandle); + + if (typeDef.GetFields().Count > 0) + { + var err = $"Explicit layout type {type} may not have fields."; + errors.Add(new SandboxError(err)); + } + } + } + } + private void CheckMemberReferences( SandboxConfig sandboxConfig, List members, diff --git a/Robust.Shared/Timing/ProfilingManager.cs b/Robust.Shared/Timing/ProfilingManager.cs new file mode 100644 index 000000000..ff06b7e67 --- /dev/null +++ b/Robust.Shared/Timing/ProfilingManager.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using Robust.Shared.Utility.Collections; + +namespace Robust.Shared.Timing; + +// No interfaces here, +public sealed class ProfilingManager +{ + public bool IsEnabled; + + // I don't care that this isn't a tree I will call upon the string tree just like in BYOND. + private readonly Dictionary _stringTreeIndices = new(); + private ValueList _stringTree; + + public struct Cmd + { + public CmdType Type; + + public int StringId; + public float Value; + } + + public struct CmdSample + { + // public + } + + public enum CmdType + { + Invalid, + Sample + } +}