mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix all warnings & Trim (#2226)
* Fix AutoFishing crash * Fix all warnings * Remove DotNetZip. * Fix the usage of HttpClient.
This commit is contained in:
parent
4aa6c1c99f
commit
1d52d1eadd
227 changed files with 2201 additions and 43564 deletions
|
|
@ -14,7 +14,7 @@ namespace DynamicRun.Builder
|
|||
{
|
||||
internal class CompileRunner
|
||||
{
|
||||
public object? Execute(byte[] compiledAssembly, string[] args, Dictionary<string, object> localVars, ChatBot apiHandler)
|
||||
public object? Execute(byte[] compiledAssembly, string[] args, Dictionary<string, object>? localVars, ChatBot apiHandler)
|
||||
{
|
||||
var assemblyLoadContextWeakRef = LoadAndExecute(compiledAssembly, args, localVars, apiHandler);
|
||||
|
||||
|
|
@ -29,20 +29,18 @@ namespace DynamicRun.Builder
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private static Tuple<WeakReference, object?> LoadAndExecute(byte[] compiledAssembly, string[] args, Dictionary<string, object> localVars, ChatBot apiHandler)
|
||||
private static Tuple<WeakReference, object?> LoadAndExecute(byte[] compiledAssembly, string[] args, Dictionary<string, object>? localVars, ChatBot apiHandler)
|
||||
{
|
||||
using (var asm = new MemoryStream(compiledAssembly))
|
||||
{
|
||||
var assemblyLoadContext = new SimpleUnloadableAssemblyLoadContext();
|
||||
using var asm = new MemoryStream(compiledAssembly);
|
||||
var assemblyLoadContext = new SimpleUnloadableAssemblyLoadContext();
|
||||
|
||||
var assembly = assemblyLoadContext.LoadFromStream(asm);
|
||||
var compiledScript = assembly.CreateInstance("ScriptLoader.Script");
|
||||
var execResult = compiledScript.GetType().GetMethod("__run").Invoke(compiledScript, new object[] { new CSharpAPI(apiHandler, localVars), args });
|
||||
|
||||
assemblyLoadContext.Unload();
|
||||
var assembly = assemblyLoadContext.LoadFromStream(asm);
|
||||
var compiledScript = assembly.CreateInstance("ScriptLoader.Script")!;
|
||||
var execResult = compiledScript.GetType().GetMethod("__run")!.Invoke(compiledScript, new object[] { new CSharpAPI(apiHandler, localVars), args });
|
||||
|
||||
return new (new WeakReference(assemblyLoadContext), execResult);
|
||||
}
|
||||
assemblyLoadContext.Unload();
|
||||
|
||||
return new(new WeakReference(assemblyLoadContext), execResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue