diff --git a/OpenRA.FileFormats/Verifier.cs b/OpenRA.FileFormats/Verifier.cs index 0300bad1d6..673a066abc 100644 --- a/OpenRA.FileFormats/Verifier.cs +++ b/OpenRA.FileFormats/Verifier.cs @@ -29,11 +29,26 @@ namespace OpenRA.FileFormats public static class Verifier { static readonly string[] AllowedPatterns = { - /* todo */ - }; + "System.Collections.Generic.*", + "System.Linq.*", + "OpenRA.*", + "System.Collections.*", + "System.Func*", + "System.String:*", + "System.IDisposable:*", + "System.Action*", + "System.Object:*", + "System.Math:*", + "System.Predicate*", + "System.NotSupportedException:.ctor", + "System.Threading.Thread:get_CurrentThread", + "System.Threading.Thread:get_ManagedThreadId", + }; public static bool IsSafe(string filename, List failures) { + Log.Write("Start verification: {0}", filename); + AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += (s, a) => Assembly.ReflectionOnlyLoad(a.Name); var flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; @@ -53,13 +68,13 @@ namespace OpenRA.FileFormats .SelectMany(x => x.GetMembers(flags)) .SelectMany(x => FunctionsUsedBy(x)) .Where(x => x.DeclaringType.Assembly != assembly) - .Select(x => string.Format("{0}:{1}", x.DeclaringType.FullName, x)) + .Select(x => string.Format("{0}:{1}", x.DeclaringType.FullName, x.Name)) .OrderBy(x => x) .Distinct()) if (!IsAllowed(fn)) failures.Add("Unsafe function: {0}".F(fn)); - return failures.Count > 0; + return failures.Count == 0; } static bool IsAllowed(string fn) @@ -74,6 +89,8 @@ namespace OpenRA.FileFormats if (fn == p) return true; } + Log.Write(fn); + return false; } diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 1a0a288bc3..2c79a57e20 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -87,6 +87,8 @@ namespace OpenRA Log.Write("Assembly `{0}` cannot be verified. Failures:", a); foreach (var f in failures) Log.Write("\t{0}", f); + + throw new InvalidOperationException("Failed verification. See the log for further details."); } }