public static bool TryCreateFromCodeFile <TDelegate>( string filePath, Type returnType, Type parameterType, [NotNullWhen(true)] out TDelegate?result) where TDelegate : Delegate { if (!FileSystemHelpers.TryReadAllText(filePath, out string?content, f => WriteError(f))) { result = null; return(false); } Assembly?assembly = AssemblyFactory.FromSourceText(content); if (assembly == null) { result = null; return(false); } result = CreateDelegateAndCatchIfThrows <TDelegate>(assembly, returnType, new Type[] { parameterType }); return(result != null); }